summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authorPalaparthy Adityachandra2020-05-13 16:32:29 +0530
committerGitHub2020-05-13 16:32:29 +0530
commit61d4096697a84873473ad28afb0dc79f211a54b3 (patch)
tree117068fb9a2ddef2a3a2dc81567ff07a3069f0bf /yaksh/models.py
parent31e8b94b8ebf74d77cc8596411c6acfa2112f949 (diff)
parentb264b673a2f84def1b9736a7a596b1acd5bb4d72 (diff)
downloadonline_test-61d4096697a84873473ad28afb0dc79f211a54b3.tar.gz
online_test-61d4096697a84873473ad28afb0dc79f211a54b3.tar.bz2
online_test-61d4096697a84873473ad28afb0dc79f211a54b3.zip
Merge branch 'master' into change-create_question
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index d67a8e3..69894a2 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -1455,6 +1455,19 @@ class Question(models.Model):
tc_list.extend(test_case)
return tc_list
+ def get_test_cases_as_dict(self, **kwargs):
+ tc_list = []
+ for tc in self.testcase_set.values_list("type", flat=True).distinct():
+ test_case_ctype = ContentType.objects.get(app_label="yaksh",
+ model=tc)
+ test_case = test_case_ctype.get_all_objects_for_this_type(
+ question=self,
+ **kwargs
+ )
+ for tc in test_case:
+ tc_list.append(model_to_dict(tc))
+ return tc_list
+
def get_test_case(self, **kwargs):
for tc in self.testcase_set.all():
test_case_type = tc.type
@@ -1746,6 +1759,7 @@ class QuestionPaper(models.Model):
for question_set in self.random_questions.all():
marks += question_set.marks * question_set.num_questions
self.total_marks = marks
+ self.save()
def _get_questions_for_answerpaper(self):
""" Returns fixed and random questions for the answer paper"""