FAQ
Products Showcase Download Extras Support
 
Home :: Support :: Community :: CourseLab Issues

JavaScript functional sample?

JavaScript functional sample? 
Author:  Pete
Date: 04.07.2008 07:18:58
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 interested.

 
...

Welcome to CourseLab Community! If you have any questions regarding CourseLab - please post it here in corresponding thread. If you cannot find the thread that exactly fit to your question - you can place New thread message. If such thread already exists - please post your question there. Threads are time slipping - last changed threads are always on the top of the threads list.

Total number of threads: 609
Total number of comments: 2250
Filter by main thread topic:
Search for:  
 
v :)
Subject Author Date
JavaScript functional sample? Pete 04.07.08
 
Re: (1) JavaScript functional sample? - Resolved Pete 16.07.08
 
Re: (2) (1) JavaScript functional sample? - Resolved Pete 16.07.08
 
Re: (2) (2) (1) JavaScript functional sample? - Resolved Nickj 16.07.08
 
Re: (2) (2) (2) (1) JavaScript functional sample? - Resolved Pete 21.07.08
 
Previous threads>>

Reply

You can also post this message as registered user. [Log in]
Author:
E-mail:
Subject:
Options:  Notify me if there is a new reply
Message emoticon:
Message body:
Insert smilie into text:
 
Jump to thread: