About keyresponse in Question

PennController for IBEX Forums Support About keyresponse in Question

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #9587
    xkyan
    Participant

    Hi Jeremy,

    I got a question about the Controller Question. I have a judgement for subjects to make after spr as “F”: reasonable and “J”: unreasonable. How can I set the available key responses to “F” and “J” instead of 1 and 2?

    Currently my code is:

        newController("Question", {q: "Is it reasonable?", as: [["F","reasonable"], ["J","unreasonable"]], hasCorrect: row.Corr})
            .print()
            .log()
            .wait()
            .remove()

    I always got an error that: Alert from preview: ERROR: Cannot set ‘randomOrder’ option to a list of keys when keys are included with the ‘as’ option.

    Thanks for your help.

    Best,
    Karen

    • This topic was modified 1 year, 6 months ago by xkyan.
    #9596
    Jeremy
    Keymaster

    Hi Karen,

    Add randomOrder: false to the Question controller: newController("Question", {q: "Is it reasonable?", as: [["F","reasonable"], ["J","unreasonable"]], hasCorrect: row.Corr, randomOrder: false})

    Jeremy

    #9605
    xkyan
    Participant

    Oh great it works well! Thanks Jeremy.

    #9606
    xkyan
    Participant

    Hi Jeremy,

    Here’s a following question I have. I found that there’s something wrong with my hasCorrect:row.Corr because everytime I included it, the whole question would disappear when running. I suppose it might be because of inappropriate value I put in the .csv file. I’ve tried to put “F”/”J” (the keys) and “reasonable”/”unreasonable” (the exact values) and all didn’t work. Do you have any insight on this? Thank you.

    Best,
    Karen

    • This reply was modified 1 year, 6 months ago by xkyan.
    #9615
    Jeremy
    Keymaster

    Hi Karen,

    When the Question controller’s as parameter is not an array of strings, but an array of pairs of strings (whose first member represents a key and the second member is the printed answer) you cannot pass a string as hasCorrect: you need to either pass true, in which case it means the first answer is the correct one, or a integer between 0 and the length of the array minus one, so in your case where you have two answers, either 0 (first answer in the array, selectable by pressing F) or 1 (second answer in the array, selectable by pressing J)

    Now, there is a subtlety, which is that values fetched from the table in Template are interpreted as strings by default, so even if you list 0s and 1s in your “Corr” column, they’ll still be interpreted as strings when you reference row.Corr. The solution is to force a coercion into an integer, using parseInt: newController("Question", {q: "Is it reasonable?", as: [["F","reasonable"], ["J","unreasonable"]], hasCorrect: parseInt(row.Corr), randomOrder: false})

    Jeremy

    #9736
    xkyan
    Participant

    Ohhh! I finally understand how it works! Thank you a lot Jeremy! 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.