--- a/OSSEval/analysis/templatetags/custom_tags.py
+++ b/OSSEval/analysis/templatetags/custom_tags.py
@@ -1,4 +1,4 @@
-# This Source Code Form of OSSEval is subject to the terms of the GNU AFFERO
+ # This Source Code Form of OSSEval is subject to the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE, v. 3.0. If a copy of the AGPL was not
# distributed with this file, You can obtain one at http://www.gnu.org/licenses/agpl.txt
#
@@ -12,7 +12,7 @@
from django import template
-from analysis.models import Instance, Question, Answer, Page, MethodologyVersion
+from analysis.models import Instance, Question, Answer, Choice, Page, MethodologyVersion
register = template.Library()
@@ -41,12 +41,12 @@
instance = Instance.objects.get(pk=instance_id)
question = Question.objects.get(pk=question_id)
try:
- answer = Answer.objects.get(question=question, instance=instance)
- choice = question.choice_set.get(order=answer.value_integer)
- if choice.todo != "":
- return "<div title=\"" + choice.todo + "\">(" + str(answer.score) + ") " + choice.text + "</div>"
+ choices = Choice.objects.filter(question=question)
+ answer = Answer.objects.get(choice__in=choices, instance=instance)
+ if answer.choice.todo != "":
+ return "<div title=\"" + answer.choice.todo + "\">(" + str(answer.score) + ") " + answer.choice.text + "</div>"
else:
- return "(" + str(answer.score) + ") " + choice.text
+ return "(" + str(answer.score) + ") " + answer.choice.text
except:
return "<font color=red>not answered</font>"
@@ -58,7 +58,8 @@
score = 0
for question in page.question_set.all():
try:
- answer = Answer.objects.get(question=question, instance=instance)
+ choices = Choice.objects.filter(question=question)
+ answer = Answer.objects.get(choice__in=choices, instance=instance)
score += answer.score
except:
pass