Explore the community Forums Lectora Lectora Questions & Answers What is name of the "Correct Answer" to a scored test question?

Tagged: , ,

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #365634 Score: 0
    Profile photo of Maura T. Sullivan
    Maura T. Sullivan
    Member
    beginner
    intermediate
    friend finder
    curious george
    wise owl
    contributor
    profile
    1 pt
    @msullivan3430

    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 <input> or <select> 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!

    #365649 Score: 0
    Profile photo of Maura T. Sullivan
    Maura T. Sullivan
    Member
    beginner
    intermediate
    friend finder
    curious george
    wise owl
    contributor
    profile
    1 pt
    @msullivan3430

    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”);

    #366530 Score: 0
    Profile photo of Jennifer Valley
    Jennifer Valley
    Member
    contributor
    beginner
    friend finder
    advanced
    lectora beginner
    verified member
    wise owl
    profile
    picture perfect
    curious george
    117 pts
    @jvalley4735

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

    #366660 Score: 0
    Profile photo of Tim K
    Tim K
    Member
    contributor
    beginner
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    wise owl
    curious george
    Group Member
    355 pts
    @timk

    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.

    #366692 Score: 0
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    209 pts
    @Klaatu

    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.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.