summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authorankitjavalkar2019-01-29 14:55:56 +0530
committerGitHub2019-01-29 14:55:56 +0530
commitcedceac0c7b64e2116b5cfd5ec9461fdff98842c (patch)
tree41081e047397ab7717b61c6bb4b08cb948eca7f5 /yaksh/models.py
parenta70751c25afd688f20ee46924c5ddc591c89f7e1 (diff)
parent010d302e9b925736674ce5c5eda4f6a7ffbebb98 (diff)
downloadonline_test-cedceac0c7b64e2116b5cfd5ec9461fdff98842c.tar.gz
online_test-cedceac0c7b64e2116b5cfd5ec9461fdff98842c.tar.bz2
online_test-cedceac0c7b64e2116b5cfd5ec9461fdff98842c.zip
Merge pull request #528 from CruiseDevice/fix-legend
Fix legend on Quiz interface
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 427b584..cce90e7 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -6,7 +6,8 @@ import ruamel.yaml
from ruamel.yaml.scalarstring import PreservedScalarString
from ruamel.yaml.comments import CommentedMap
from random import sample
-from collections import Counter
+from collections import Counter, defaultdict
+
from django.db import models
from django.contrib.auth.models import User, Group, Permission
from django.contrib.contenttypes.models import ContentType
@@ -80,6 +81,17 @@ string_check_type = (
("exact", "Case Sensitive"),
)
+legend_display_types = {
+ "mcq": {"label": "Objective Type"},
+ "mcc": {"label": "Objective Type"},
+ "code": {"label": "Programming"},
+ "upload": {"label": "Upload"},
+ "integer": {"label": "Objective Type"},
+ "string": {"label": "Objective Type"},
+ "float": {"label": "Objective Type"},
+ "arrange": {"label": "Objective Type"},
+ }
+
attempts = [(i, i) for i in range(1, 6)]
attempts.append((-1, 'Infinite'))
@@ -2091,6 +2103,16 @@ class AnswerPaper(models.Model):
def get_previous_answers(self, question):
return self.answers.filter(question=question).order_by('-id')
+ def get_categorized_question_indices(self):
+ category_question_map = defaultdict(list)
+ for index, question in enumerate(self.get_all_ordered_questions(), 1):
+ question_category = legend_display_types.get(question.type)
+ if question_category:
+ category_question_map[
+ question_category["label"]
+ ].append(index)
+ return dict(category_question_map)
+
def validate_answer(self, user_answer, question, json_data=None, uid=None,
server_port=SERVER_POOL_PORT):
"""