Helpful Information
 
 
Category: Mobile Programming
quizz with wmlscript

I'm trying to figure out how to score a quizz using wmlscript. I have the correct/incorrect answer part working, I'm trying to create a function that keeps score by incrementing the value of a variable, I'm not sure what I'm doing wrong.

the script:

function addscore(){
var points;
points=points++;
return points;
}

extern function validateAnswer(Answer)
{
var validResponse = WMLBrowser.getVar("Answer");
if (validResponse != "value")
{
WMLBrowser.go("poll2.wml#NResults");
}
else
{
WMLBrowser.go("poll2.wml#YResults1");
var number = addscore();
WMLBrowser.setVar("score", number);
}
};

extern function validateAnswer2(Answer){
var validResponse = WMLBrowser.getVar("Answer");
if (validResponse != "value")
{
WMLBrowser.go("poll2.wml#NResults");
}
else
{
WMLBrowser.go("poll2.wml#YResults3");
var number = addscore();
WMLBrowser.setVar("score", number);
}
};

The card that's supposed to show the score:

<card id="YResults3" title="Results:">
<p>
Yes: Answer $(Answer) is correct "
</p>
<p>
Score: $(score) out of 3 "
</p>
<p>
<a href="poll2.wml#Trivia1">Start Over</a>
</p>
</card>

I would make sure of two things:

(1) That you have the correct initial value of points in the addscore function, and

(2) That you are calling the addscore function before you go to the YResults3 card.










privacy (GDPR)