Fixes participant count bug in Quiz Statistics

MultipleAnswersQuestions were being interrogated for participant counts
which counted each student mutliple times.

Closes CNVS-18499

Test Plan:
  - Build a quiz with various question types
  - Take the quiz 5 times
  - Confirm that each question has 5 attempts.

Change-Id: I9c60d5c15f55b3519387e97a595ab659d2ac9d70
Reviewed-on: https://gerrit.instructure.com/49780
Tested-by: Jenkins
Reviewed-by: Brian Finney <bfinney@instructure.com>
QA-Review: Amber Taniuchi <amber@instructure.com>
Product-Review: Matt Fairbourn <mfairbourn@instructure.com>
This commit is contained in:
Ryan Taylor 2015-03-03 10:18:39 -07:00 committed by Matt Fairbourn
parent f398d9f792
commit 22d238b89d
2 changed files with 24 additions and 2 deletions

View File

@ -40,7 +40,9 @@ define(function(require) {
else {
answerPool = question.answers;
}
if (question.questionType === 'multiple_answers_question') {
return question.responses; // This will not indicate a response for blank responses
}
return wrap(answerPool).reduce(function(sum, answer) {
return sum + (answer.responses || 0);
}, 0);
@ -55,7 +57,7 @@ define(function(require) {
answer.text = I18n.t('no_answer', 'No Answer');
}
else if (answer.id === 'other') {
answer.text = I18n.t('unknown_answer', 'Something Else');
answer.text = I18n.t('unknown_answer', 'Something Else'); // This is where we need to handle the answer changed thing
}
if (participantCount > 0) {

View File

@ -65,6 +65,26 @@ define(function(require) {
expect(subject.get('questionStatistics')[0].participantCount).toEqual(5);
});
it("should work with multiple_answers_questions", function() {
var subject = new Subject({
question_statistics: [
{
question_type:"multiple_answers_question",
responses:2,
correct:1,
answers:[
{id:"6122",text:"a",correct:true,responses:2},
{id:"6863",text:"b",correct:true,responses:2},
{id:"3938",text:"c",correct:true,responses:2},
{id:"938",text:"d",correct:false,responses:1}
]
}
]
}, {parse: true});
expect(subject.get("questionStatistics")[0].participantCount).toEqual(2);
});
});
});
});