Replies: 2 comments 2 replies
-
First, You are not making your question clear either. I do not know whether you want to display the explanation in the current trial or set up a new trial for that. In the first case, you can add the corresponding event listeners in the trial's |
Beta Was this translation helpful? Give feedback.
-
I have added comments to things you have not done properly. let mathQuestion = {
// jsPsych trial type needs to be an object, not a string
type: jsPsychSurveyMultiChoice,
questions: [
{
prompt: "请问1 + 2 =?",
name: "math_response",
options: ["A3", "B4", "B5", "D6"],
},
],
button_label: "下一步",
};
// You do not need a conditional timeline at all
let feedbackTrial = {
type: jsPsychHtmlButtonResponse,
stimulus: function () {
var data = jsPsych.data.get().last(1).values()[0];
// Your values are A3 / B4 / C5, how can they possibly equal 3?
var response = data.response.math_response[1] === "3";
var feedback;
if (response) {
feedback = "回答正确";
} else {
feedback = "回答不正确,答案为A";
}
// HTML strings should be wrapped in quotation marks, not parenthesis
var html = `<p style="text-align:center;line-height:45px;margin:0%;width:100%;font-weight:200">${feedback}</p>`;
return html;
},
choices: ["下一步"],
};
main_timeline.push(mathQuestion, feedbackTrial); |
Beta Was this translation helpful? Give feedback.
-
let quiz_question = {
type: 'jsPsychSurveyMultiChoice',
questions: [
{
name: 'quiz_question',
options: ["3", "4", "5", "6"],
required: true,
horizontal: false,
},
],
button_label: "提交",
conditional_function: function(){
var data = jsPsych.data.get().last(1).values()[0];
if(data.response.quiz_question === "4")
{
jsPsych.data.addProperties({showCorrectFeedback: true, showIncorrectFeedback: false});
} else {
var explanation = "抱歉,答案不正确。2 + 2 等于 4。";
jsPsych.data.addProperties({showCorrectFeedback: false, showIncorrectFeedback: true, explanation: explanation});
}
return true;
}
};
main_timeline.push(quiz_question);
I would like to know what is wrong with this program? Why isn't it working?How do I modify the program in the above paragraph so that when incorrect answers 3, 5, and 6 are selected, the explanation of the question appears, and when 4 is selected, the hint that the answer is correct appears?
Beta Was this translation helpful? Give feedback.
All reactions