From 95fe3908ceca6bfb35e641ed21b32f2d37c04b7c Mon Sep 17 00:00:00 2001
From: Christoph Thelen <christoph.thelen@mni.thm.de>
Date: Wed, 29 Apr 2015 16:52:49 +0200
Subject: [PATCH] Allow likert/vote questions for learning progress

---
 src/main/resources/views/learning_progress | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/resources/views/learning_progress b/src/main/resources/views/learning_progress
index d544ae3..fead8d5 100644
--- a/src/main/resources/views/learning_progress
+++ b/src/main/resources/views/learning_progress
@@ -4,7 +4,7 @@
 	"views": {
 		"maximum_value_of_question": {
 			"comment": "This view returns the maximum number that can be achieved when answering this question.",
-			"map": "function(doc) { /*The question's value is determined by the maximum of all possibleAnswer values. We assume that a correct answer is assigned a positive value, while a negative value suggests a wrong answer. The goal then is to get the highest possible value. This leaves us with two cases: 1) On any single choice question, the value is the maximum of all possibleAnswer values. 2) On a multiple choice question, we add up all positive values.*/ var value = 0, answers = [], positiveAnswers = [], score = 0; if (doc.type === 'skill_question' && ['freetext', 'vote', 'school', 'flashcard'].indexOf(doc.questionType) === -1) { answers = doc.possibleAnswers.map(function(answer) { return answer.value || 0; }); /*find the maximum value*/ value = Math.max.apply(null, [0].concat(answers)); /*special case for mc and grid questions: add up all positive answers.*/ if (['grid', 'mc'].indexOf(doc.questionType) !== -1) { positiveAnswers = answers.filter(function(val) { return val >= 0; }); if (positiveAnswers.length > 0) { value = positiveAnswers.reduce(function(prev, cur) { return prev + cur; }, 0); } } emit([doc.sessionId, doc._id], { value: value, questionVariant: doc.questionVariant, piRound: doc.piRound }); } }"
+			"map": "function(doc) { /*The question's value is determined by the maximum of all possibleAnswer values. We assume that a correct answer is assigned a positive value, while a negative value suggests a wrong answer. The goal then is to get the highest possible value. This leaves us with two cases: 1) On any single choice question, the value is the maximum of all possibleAnswer values. 2) On a multiple choice question, we add up all positive values.*/ var value = 0, answers = [], positiveAnswers = [], score = 0; if (doc.type === 'skill_question' && ['freetext', 'school', 'flashcard'].indexOf(doc.questionType) === -1) { answers = doc.possibleAnswers.map(function(answer) { return answer.value || 0; }); /*find the maximum value*/ value = Math.max.apply(null, [0].concat(answers)); /*ignore likert ('vote') questions without any points*/ if (doc.questionType === 'vote' && value === 0) { return; } /*special case for mc and grid questions: add up all positive answers.*/ if (['grid', 'mc'].indexOf(doc.questionType) !== -1) { positiveAnswers = answers.filter(function(val) { return val >= 0; }); if (positiveAnswers.length > 0) { value = positiveAnswers.reduce(function(prev, cur) { return prev + cur; }, 0); } } emit([doc.sessionId, doc._id], { value: value, questionVariant: doc.questionVariant, piRound: doc.piRound }); } }"
 		},
 		"question_value_achieved_for_user": {
 			"comment": "This view returns the points users scored for answered questions.",
-- 
GitLab