Increment manually a variable

Hy everybody,

I try to update the variable apQuizScore with javascript function.

image

How it’s work exactly ?
Exemple : i need to increment 10

Thank you

i need to edit the score at the end of quiz, but with the SCORM variable used.

Hi,
apQuizScore is a read-only variable, so you can not write a value to it. Please add following code into ActivePresenter > Project > Properties > Event:

if (!prez._initEx){
    prez._initEx = true;
    var fScore = prez.score;
    prez.score = function() {
        var customScore = prez.variable("myScore");
        return fScore.call(this) + customScore;
    }
}

Note that the “myScore” is the variable that is used to store custom score.

Regards,

Hi,

Thank you for reply !
I have test but not work

image

Here is my code sample

image

The score need to be send at the last slide, is it the good method ?
And, how can i edit the max score possible ?

Thank you again.

Have you tried adding Q_score as a Number variable? If it still doesn’t work, please share the project so we can check.

Yes i think

image

Where can i send you the project ? It’s confidential.
Thank you

You can send to support@atomisystems.com.
We’ll remove it completely after the issue is resolved.

Regards,

It’s in your mailbox !

Hi,

Thanks for sharing the file. In your case, you also need to set max score, so the code should look like:

if (!prez._initEx){

prez._initEx = true;

var fScore = prez.score;

prez.score = function() {

    var customScore = prez.variable("Q_score");

    return fScore.call(this) + customScore;

}
prez.maxScore = function() {
    return 10; //change max score here
}

}

You need to reduce the duration of the last slide (2 second is enough). After presentation runs to the end of the last slide, the result will be submitted to LMS.

Regards,

1 Like

Magnificent !
I do not regret having chosen this software, and your team is at the top!
thank you