What is name of the "Correct Answer" to a scored test question?

I’m trying to compare the user’s stored answer to the “correct answer” retained by Lectora for a graded test question, but can’t figure out how to locate the “correct answer” in order to do the comparison.

I am attaching external files: CSS, JS, jQuery. I have a long form (PNG created from Illustrator) which has many scored questions on it (could be 30 or more items, usually TEBs). When the user clicks on a checkBtn then the items should be evaluated and if the user’s entry is incorrect the undefined will be outlined in red.

I do realize that the variable that stores the answer needs to have a “VAR” prepended to it when working with the code.

Example: question1 with a variable name=_myVariable would be referenced as “Var_myVariable” in code. What would the stored correct answer in Lectora be called so that I can write my statement?

Thanks!

Discussion (4)

I was hoping that if the two items were not equal (===) then I could do something like:

$this.css("border", "2px solid red");

or

$(this).toggleClass("error");

Neither of these is working form me.

I can get the following to work in the Chrome Console: $("div[class=quest]").css("border", "2px solid red");

@Klaatu or @timk Didn't one of you post a similar question?

There's no variable that contains the correct answer, but you can always use the normal Condition If Question_0001 is correct / is not correct to run javascript.

Use Tim's suggestion, it's your best bet.

I do not want to write in the forum how Lectora goes about checking the answer because the code does something so that you cannot easily get the answer using the browsers developers tools.

What I can say is that if you already know the correct selection then you can check the Lectora question variable (ex. Question_0001) against the text of the correct selection. ;-)

If the question was multiple choice and the correct selection was "Choice Two" then:

if(VarQuestion_0001.value == 'Choice Two')

{

$('span.text45Font1').css({"color":"green","font-weight":"bolder","font-size":"20px","text-shadow":"2px 2px #FFFFFF"});

alert("CORRECT");

}

else if(VarQuestion_0001.value == '~~~null~~~')

{

alert('You must first select an answer.');

}

else

{

alert('WRONG');

}

This will alter the style of the correct text in the question.

You could also check the answer against '~~~null~~~' to be sure an answer was selected.

Basically, the only difference between doing this and what Lectora does internally is that the above will not register the answer with the program/LMS.

I hope I explained this sufficiently.

Discussions have been disabled for this post