PennController for IBEX › Forums › Support › About keyresponse in Question
- This topic has 5 replies, 2 voices, and was last updated 2 years, 11 months ago by
xkyan.
-
AuthorPosts
-
October 19, 2022 at 1:05 am #9587
xkyanParticipantHi 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 3 years ago by
xkyan.
October 19, 2022 at 6:58 pm #9596
JeremyKeymasterHi Karen,
Add
randomOrder: falseto the Question controller:newController("Question", {q: "Is it reasonable?", as: [["F","reasonable"], ["J","unreasonable"]], hasCorrect: row.Corr, randomOrder: false})Jeremy
October 20, 2022 at 5:12 pm #9605
xkyanParticipantOh great it works well! Thanks Jeremy.
October 20, 2022 at 6:02 pm #9606
xkyanParticipantHi Jeremy,
Here’s a following question I have. I found that there’s something wrong with my
hasCorrect:row.Corrbecause 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 3 years ago by
xkyan.
October 25, 2022 at 4:08 pm #9615
JeremyKeymasterHi Karen,
When the Question controller’s
asparameter 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 ashasCorrect: you need to either passtrue, in which case it means the first answer is the correct one, or a integer between0and the length of the array minus one, so in your case where you have two answers, either0(first answer in the array, selectable by pressing F) or1(second answer in the array, selectable by pressing J)Now, there is a subtlety, which is that values fetched from the table in
Templateare interpreted as strings by default, so even if you list0s and1s in your “Corr” column, they’ll still be interpreted as strings when you referencerow.Corr. The solution is to force a coercion into an integer, usingparseInt:newController("Question", {q: "Is it reasonable?", as: [["F","reasonable"], ["J","unreasonable"]], hasCorrect: parseInt(row.Corr), randomOrder: false})Jeremy
November 25, 2022 at 5:56 pm #9736
xkyanParticipantOhhh! I finally understand how it works! Thank you a lot Jeremy! 🙂
-
This topic was modified 3 years ago by
-
AuthorPosts
- You must be logged in to reply to this topic.