Hi,
I'm trying to figure out how to get the incorrect and partly correct feedback to display on a custom component. I have the correct feedback displaying properly. It seems I'm either not calling the other feedback options correctly or there is some other way to set up the feedback that I'm not seeing.
I see examples of components that have isCorrect for individual answers. I don't see any examples that relate to what I'm doing, which is checking the order of a sortable list and providing feedback based on if the list is in proper order or not.
I've looked in the quetionView.js file but it's not clear to me what it's looking for to get the other feedback options to display.
Heres the code I'm using:
JS file:
checkAnswers: function() {
var numCorrect = 0;
var numQs = this.getNumQuestions();
$(".sortable-item-inner").each(function(index) {
if ($.trim($(this).text()) == correctOrder[index]) numCorrect++;
});
if (numCorrect == numQs) {
this.setupCorrectFeedback();
console.log('correct')
} else if (numCorrect > 0) {
this.setupPartlyCorrectFeedback();
console.log('partial correct')
} else {
this.setupIncorrectFeedback();
console.log('incorrect')
}
this.showFeedback();
},
getNumQuestions: function() {
return this.model.get("_items").length;
},
setUpCorrectFeedback: function() {
this.model.set({
feedbackTitle: this.model.get('title'),
feedbackMessage: this.model.get('_feedback.correct')
});
},
setupPartlyCorrectFeedback: function() {
this.model.set({
feedbackTitle: this.model.get('title'),
feedbackMessage: this.model.get('_feedback._partlyCorrect.final') // Not working
});
console.log('fb msg partlyCorrect ' + this.model.get('_feedback._partlyCorrect.final'))
},
setupIncorrectFeedback: function() {
this.model.set({
feedbackTitle: this.model.get('title'),
feedbackMessage: this.model.get('_feedback._incorrect.final') // Not working
});
console.log('fb msg incorrect ' + this.model.get('_feedback._incorrect.final'))
},
components file:
{ "_id": "c-45",
"_parentId": "b-45",
"_type":"component",
"_component":"sortable",
"_classes":"sortableComponent",
"_layout":"center",
"title":"Sortable Component",
"displayTitle":"Sortable Component",
"body":"Sortable Component",
"instruction":"Sortable Component",
"_isRandom": true,
"_selectable": 0,
"_canShowMarking" : false,
"_canShowFeedback": "true",
"_itemOrder" : "",
"_items": [
{
"text": "1917"
},
{
"text": "1888"
},
{
"text": "1953"
},
{
"text": "1977"
}
],
"_buttons": {
"_submit": "Submit",
"_reset": "Reset"
},
"_pageLevelProgress": {
"_isEnabled": true
},
"_feedback": {
"correct": "Correct answer feedback.<br><br>You put all the answers in the correct order.",
"_incorrect": {
"notFinal": "",
"final": "Incorrect answer feedback.<br><br>This feedback will appear if you answered the question incorrectly."
},
"_partlyCorrect": {
"notFinal": "",
"final": "Partly correct answer feedback.<br><br> This feedback will appear if you answered the question correctly."
}
}
},
Thanks,
Sean