diff options
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 9bcb132..b64ac77 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -773,14 +773,20 @@ class LearningModule(models.Model): def get_passing_status(self, user, course): course_status = CourseStatus.objects.filter(user=user, course=course) + ordered_units = [] if course_status.exists(): - learning_units_with_quiz = self.learning_unit.filter(type='quiz') + learning_units_with_quiz = self.learning_unit.filter( + type='quiz' + ).order_by("order") ordered_units = learning_units_with_quiz.order_by("order") - statuses = [ - unit.quiz.get_answerpaper_passing_status(user, course) - for unit in ordered_units - ] + if ordered_units: + statuses = [ + unit.quiz.get_answerpaper_passing_status(user, course) + for unit in ordered_units + ] + else: + statuses = [] if not statuses: status = False @@ -1452,6 +1458,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 @@ -1743,6 +1762,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""" |