我正在尝试使用.NET TinCan库在我自己的学习管理系统中使用。我已经在我的应用程序中包含了TinCan 0.0.2 Nuget包,并上传了GolfExample_TCAPI测试课程。在本地测试时,GolfExample课程将以以下URL加载:
https://127.0.0.1/TINCAN/MYCOMPANY/GolfExample_TCAPI%20(1)/index.html?在查看启动文档时,我可以发现,似乎至少需要您传递端点、auth和参与者,因此我尝试使用dll进行传递,如下所示。
var lrs = new RemoteLRS("https://cloud.scorm.com/tc/public/", "<username>", "<password>");
var actor = new TinCan.Agent();
actor.name = "John Paul Mc Feely";
actor.mbox = "jpmcfeely@hsl-data.com";
TINCANStartPage = HttpContext.Current.Request.Url.Scheme + "://" + @HttpContext.Current.Request.Url.Host + ":" +
@HttpContext.Current.Request.Url.Port + HttpContext.Current.Request.ApplicationPath + this.Course.BlobURL + "/index.html" + "?endpoint=" + lrs.endpoint + "&auth=" + lrs.auth + "&actor=" + actor.ToJSON(); 调试时,我可以看到这为启动窗口创建了URL,如下所示:
"https://127.0.0.1/TINCAN/MYCOMPANY/GolfExample_TCAPI (1)/index.html?endpoint=https://cloud.scorm.com/tc/public/&auth=Basic anBtY2ZlZWx5QGhzbC1kYXRhLmNvbTpwbGFzbWExMQ==&actor={\"objectType\":\"Agent\",\"name\":\"John Paul Mc Feely\",\"mbox\":\"jpmcfeely@hsl-data.com\"}"根据我可以看到的文档,这看起来是正确的格式,但当我继续操作时,窗口将以URL启动,如下所示:
https://127.0.0.1/TINCAN/MYCOMPANY/GolfExample_TCAPI%20(1)/index.html?endpoint=https://cloud.scorm.com/tc/public/&auth=Basic%20anBtY2ZlZWx5QGhzbC1kYXRhLmNvbTpwbGFzbWExMQ==&actor={"objectType":"Agent","name":"John%20Paul%20Mc%20Feely","mbox":"jpmcfeely@hsl-data.com"}然后,我收到如下警告消息:
警告:与学习记录存储区通信存在问题。(400x语句3bd49829-dc0b-4daa-A 689-71a84c44e6ad没有指定一个参与者)。
如果有人能看出我在这里做错了什么,我们将不胜感激。
发布于 2014-06-04 12:35:38
查询字符串参数最少需要为URLEncoded。您需要将lrs.endpoint、lrs.auth和actor.ToJSON()包装在HttpUtility.UrlEncode()中。
using System.Web;
TINCANStartPage = HttpContext.Current.Request.Url.Scheme +
"://" +
@HttpContext.Current.Request.Url.Host +
":" +
@HttpContext.Current.Request.Url.Port +
HttpContext.Current.Request.ApplicationPath +
this.Course.BlobURL +
"/index.html" +
"?endpoint=" +
HttpUtility.UrlEncode(lrs.endpoint) +
"&auth=" +
HttpUtility.UrlEncode(lrs.auth) +
"&actor=" +
HttpUtility.UrlEncode(actor.ToJSON());根据警告消息,它听起来像是要传递给TinCanJS。我们需要看到这些代码来进一步排除故障。实例化TinCan对象的代码需要将解析的url传递给它,这似乎是有效的,但可能由于不正确的url编码,无法找到参与者。
请注意,使用该响应获得400状态意味着它正在成功地连接到LRS,在请求中发送的内容是无效的。
https://stackoverflow.com/questions/24032979
复制相似问题