I have created an eLearning system and I am now trying to integrate tincanapi using the Javascript library that Rustici have created and I am wondering if it is possible to call a javascript method from the MVC controller. In the web view I create tincan statements using the following code:
<script type="text/javascript" src= "@Url.Content("~/Scripts/tincan.js")"></script>
var tincan = new TinCan
(
{
recordStores: [
{
endpoint: "https://cloud.scorm.com/tc/V4FF9VBCSY/",
username: "myusername",
password: "mypassword"
}
]
}
);
function AcceptFriend(fullName,emailAddress)
{
tincan.sendStatement
(
{
actor: {
name: "@Model.User.Forename" + " @Model.User.Surname",
mbox: "@Model.User.Email"
},
verb: {
id: "http://adlnet.gov/expapi/verbs/answered",
display: {
"en-US": "accepted a friend request from"
}
},
target: {
objectType: "Agent",
name: fullName,
mbox: emailAddress
}
}
);
};
This code is called upon click of an accept friend request button which is working so well and so good.
But now I want to track when a user uploads a course, of course I can do this on the submission of the form but this leaves me unsure of whether the upload was successful so I thought that it would be best to make these calls on the controller action if possible. Can this be done? How could I call similar statements to those above within this code:
public ActionResult NewCampaign()
{
evm.GetCampaignTypes();
evm.GetCampaignFormats();
evm.GetCampaignTemplates();
//Set ViewBag values.
ViewBag.UserID = evm.User.UserID;
ViewBag.NewMessageCount = evm.NewMessageCount;
ViewBag.PendingFriendRequests = evm.PendingFriendRequests;
ViewBag.NewFriendRequest = evm.NewFriendRequest;
ViewBag.NewFriendCount = evm.NewFriendCount;
ViewBag.UserForename = evm.User.Forename;
return View(evm);
}