Not signed in (Sign In)

Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.

Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthorhemantam
    • CommentTimeSep 30th 2008
     
    Hi I am using pipwers as 2 and javascript wrapper to implement a quiz on moodle.
    The quiz runs ok, the score is got on the flash quiz and it ends sessions.
    The problem is:
    The score does not go to the LMS - Moodle. Please help..
    Below is the code which might be the problem:

    var lessonStatus:String;
    var lmsConnected:Boolean;
    var success:Boolean;
    var scorm:SCORM = new SCORM();
    lmsConnected = scorm.connect();
    if(lmsConnected)
    {
    Status = scorm.get("cmi.core.score.raw");
    if(Status >= 0 )
    {
    scorm.disconnect();
    }
    else
    {
    success = scorm.set("cmi.core.score.raw", "0");
    if(success)
    {
    scorm.save();
    }
    else
    {
    serverUnresponsive();
    }
    }
    }
    else
    {
    trace("Could not connect to LMS.");
    }

    if(TotalQuestion >= 0)
    {
    _root.success = scorm.set("cmi.core.score.raw", TotalQuestion);
    //trace(success1);
    if(_root.success1)
    {
    //trace("asds"+success1);
    scorm.save();
    }
    //_root.success = scorm.set("cmi.core.score.raw", TotalQuestion);
    scorm.save();
    scorm.disconnect();
    lmsConnected = false;
    }
    • CommentAuthorclewis13
    • CommentTimeOct 1st 2008 edited
     
    A couple things.

    Have you tested using ADL Test Suite or Scorm Reload Player? Testing off line saves frustration and helps narrow down the cause prior to loading into any LMS.

    Not sure what you are doing with "_root.success" and "_root.success1". Why are you referencing "_root"?

    If looks like you are going down the chain, but how is "TotalQuestion" being populated? Is this only a snippet of code?

    Try converting "TotalQuestion" to a string.
    • CommentAuthorphilip
    • CommentTimeOct 1st 2008
     
    first thing i notice is that Status is not declared. i'll assume it's declared somewhere.

    this line is probably the biggest culprit:
    if(Status >= 0 )

    two issues:

    1. you're testing to see if status is greater than or equal to 0. that means it always evaluates to true, which (because of your conditional statement) means you disconnect from the LMS immediately. it looks like you should drop the = and just use if(Status > 0 ).

    2. if you're evaluating if(Status >= 0 ), it means that you're testing Status as a number. scorm.get("cmi.core.score.raw") returns a string, so you should run a type conversion on it:
    Status = Number(scorm.get("cmi.core.score.raw"));

    #1 and #2 also apply to TotalQuestion.

    Here's a revised version of your example code (I renamed some variables for clarity):


    var lessonStatus:String;
    var lmsConnected:Boolean;
    var success:Boolean;
    var scorm:SCORM = new SCORM();
    var score:Number = 0;
    var minimumPassingScore:Number = 5; //whatever number you need it to be

    lmsConnected = scorm.connect();

    if(lmsConnected){

    score = Number(scorm.get("cmi.core.score.raw"));

    if(score > minimumPassingScore ){

    //already passed course
    scorm.disconnect();

    } else {

    //Reset score to 0 so learner can start quiz fresh
    success = scorm.set("cmi.core.score.raw", "0");

    if(success) {
    scorm.save();
    } else {
    serverUnresponsive();
    }
    }

    } else {

    trace("Could not connect to LMS.");

    }

    // LATER IN COURSE, after learner has completed quiz
    //quiz results stored in var score

    success = scorm.set("cmi.core.score.raw", score);

    if(score > minimumPassingScore) {

    scorm.disconnect();
    lmsConnected = false;

    } else {

    //don't disconnect
    //prompt learner to try again?

    }


    good luck
    - philip