I am trying to use the .NET TinCan Library for use within my own Learning Management System. I have included the TinCan 0.0.2 Nuget package in my application and uploaded the GolfExample_TCAPI test course. The GolfExample course loads at the following URL when testing locally:
https://127.0.0.1/TINCAN/MYCOMPANY/GolfExample_TCAPI%20(1)/index.html?
On looking at the launch documentation that I could find it seems that at a minimum you are required to pass in the endpoint, the auth, and the actor so I have attempted to do so using the dll as follows within my viewmodel.
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 = "[email protected]";
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();
When debugging I can see that this created the URL for the launch window as follows:
"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\":\"[email protected]\"}"
This looks like the correct format according to the documentation that I can see but when I proceed the window launches with the URL as:
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":"[email protected]"}
I then get a warning message as follows:
[warning] There was a problem communicating with the Learning Record Store. (400 | Statement 3bd49829-dc0b-4daa-a689-71a84c44e6ad does not have an actor assigned.)
If anyone could see what I am doing wrong here it would be greatly appreciated.
Minimally the query string parameters need to be URLEncoded. You would need to wrap
lrs.endpoint
,lrs.auth
andactor.ToJSON()
inHttpUtility.UrlEncode()
.Based on the warning message it sounds like you are passing this through to TinCanJS. We'd need to see that code to troubleshoot further. The code that is instantiating the
TinCan
object needs to pass it theurl
to parse, which seems to be working, but the actor is not being found possibly because of the incorrect URL encoding.Note that the fact that you are getting a 400 status with that response means it is connecting to the LRS successfully, just what is sent in the request isn't valid.