CourseLab is shaping up to be a superb alternative to high-priced authoring tools, bravo!
I've read every thread related to JavaScript in the Actions, and in particular, how to retrieve object variables. But I'm struggling to understand how I can instantiate local variables, so that I can pass these object properties onto a script.
For example, I'd like to get the scaled score of my "Current Results" object by calling JavaScript in the Actions menu of my test object (called in the "On Test End" event):
//begin code
//create our score object constructor
function Score(objectiveID, rawScore, scaledScore, maxScore) {
this.objectiveID=objectiveID;
this.rawScore=rawScore;
this.scaledScore=scaledScore;
this.maxScore=maxScore;
}
//create our local score object
theScore = new Score(g_arSlideVars['$OBJ_10.objectiveID'], g_arSlideVars["$OBJ_10.rawScore"], g_arSlideVars["$OBJ_10.scaledScore"], g_arSlideVars["$OBJ_10.maxScore"]);
//override the base theScore.toString()
Score.prototype.toString = function scoreToString() {
var ret = this.objectiveID + ", " + this.rawScore + ", " + this.scaledScore + ", " + this.maxScore;
return ret;
}
//display the overridden string value of theScore (instead of returning [object Object])
alert(theScore.toString); //returns score objects
//end code
This returns "undefinded, undefined, undefined, undefined." If I change “alert(theScore.toString);” to “alert(theScore.toString());” I get function scoreToString () {
var ret = this.objectiveID + ", " + this.rawScore + ", " + this.scaledScore + ", " + this.maxScore;
return ret;”
Can you please provide a working example?
I already have functional JavaScript code, which is capable of sending information to a SharePoint list (via a SOAP enclosure). Despite the availability of SharePoint Learning Kit, I am not in a position to install a server template, but I would like to track simple, internal variables without the need for an LMS or near-LMS. Once I can get this final piece of information, I'll be happy to publish the code for all those who may be intereste
CourseLab is shaping up to be a superb alternative to high-priced authoring tools, bravo!
I've read every thread related to JavaScript in the Actions, and in particular, how to retrieve object variables. But I'm struggling to understand how I can instantiate local variables, so that I can pass these object properties onto a script.
For example, I'd like to get the scaled score of my "Current Results" object by calling JavaScript in the Actions menu of my test object (called in the "On Test End" event):
//begin code
//create our score object constructor
function Score(objectiveID, rawScore, scaledScore, maxScore) {
this.objectiveID=objectiveID;
this.rawScore=rawScore;
this.scaledScore=scaledScore;
this.maxScore=maxScore;
}
//create our local score object
theScore = new Score(g_arSlideVars['$OBJ_10.objectiveID'], g_arSlideVars["$OBJ_10.rawScore"], g_arSlideVars["$OBJ_10.scaledScore"], g_arSlideVars["$OBJ_10.maxScore"]);
//override the base theScore.toString()
Score.prototype.toString = function scoreToString() {
var ret = this.objectiveID + ", " + this.rawScore + ", " + this.scaledScore + ", " + this.maxScore;
return ret;
}
//display the overridden string value of theScore (instead of returning [object Object])
alert(theScore.toString); //returns score objects
//end code
This returns "undefinded, undefined, undefined, undefined." If I change “alert(theScore.toString);” to “alert(theScore.toString());” I get function scoreToString () {
var ret = this.objectiveID + ", " + this.rawScore + ", " + this.scaledScore + ", " + this.maxScore;
return ret;”
Can you please provide a working example?
I already have functional JavaScript code, which is capable of sending information to a SharePoint list (via a SOAP enclosure). Despite the availability of SharePoint Learning Kit, I am not in a position to install a server template, but I would like to track simple, internal variables without the need for an LMS or near-LMS. Once I can get this final piece of information, I'll be happy to publish the code for all those who may be intereste