From db73441ae5abfdfa0f04d049a1c33a156ab553f4 Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Tue, 3 Oct 2017 16:41:52 +0530 Subject: Allow file field and tags field to be skipped altogether in an yaml file --- yaksh/models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 787daa6..9603282 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -420,9 +420,11 @@ class Question(models.Model): msg = "Questions Uploaded Successfully" for question in questions: question['user'] = user - file_names = question.pop('files') + file_names = question.pop('files') \ + if 'files' in question \ + else None + tags = question.pop('tags') if 'tags' in question else None test_cases = question.pop('testcase') - tags = question.pop('tags') que, result = Question.objects.get_or_create(**question) if file_names: que._add_files_to_db(file_names, file_path) -- cgit From d433fe75da28d7051b96f2fbdc5a01d5b5c159b1 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Mon, 9 Oct 2017 15:12:09 +0530 Subject: Fix bug that prevents students from revisiting AnswerPaper with only one question --- yaksh/models.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 787daa6..e5285ba 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1215,10 +1215,7 @@ class AnswerPaper(models.Model): self.questions_answered.add(question_id) self.questions_unanswered.remove(question_id) - next_question = self.next_question(question_id) - if next_question and next_question.id == int(question_id): - return None - return next_question + return self.next_question(question_id) def next_question(self, question_id): """ -- cgit From 1ad1ef1c69cb8208e4d330a9695442b4d78134ac Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Thu, 12 Oct 2017 18:05:11 +0530 Subject: Fix User data UI bug and auto-updates demo course total marks --- yaksh/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 9603282..f7d9906 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -925,7 +925,6 @@ class QuestionPaper(models.Model): def create_demo_quiz_ppr(self, demo_quiz, user): question_paper = QuestionPaper.objects.create(quiz=demo_quiz, - total_marks=6.0, shuffle_questions=False ) summaries = ['Roots of quadratic equation', 'Print Output', @@ -941,6 +940,8 @@ class QuestionPaper(models.Model): question_paper.save() # add fixed set of questions to the question paper question_paper.fixed_questions.add(*questions) + question_paper.update_total_marks() + question_paper.save() def get_ordered_questions(self): ques = [] -- cgit From 8939dfcefc151ba41c7cb0a2ed32effab9120b0e Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Wed, 11 Oct 2017 15:56:44 +0530 Subject: Add tests to verify the change --- yaksh/models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index e5285ba..6dc8ce2 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1223,8 +1223,9 @@ class AnswerPaper(models.Model): available question. """ if self.questions_order: - all_questions = [int(q_id) - for q_id in self.questions_order.split(',')] + all_questions = [ + int(q_id) for q_id in self.questions_order.split(',') + ] else: all_questions = list(self.questions.all().values_list( 'id', flat=True)) -- cgit From 90e8295819f606bcf794a5bcd521b4ef08cb98e0 Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Fri, 13 Oct 2017 14:57:35 +0530 Subject: Sort students' name in grade user in alphabetical order --- yaksh/models.py | 1 + 1 file changed, 1 insertion(+) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index f7d9906..3fcfa39 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1097,6 +1097,7 @@ class AnswerPaperManager(models.Manager): def get_users_for_questionpaper(self, questionpaper_id): return self._get_answerpapers_for_quiz(questionpaper_id, status=True)\ .values("user__id", "user__first_name", "user__last_name")\ + .order_by("user__first_name")\ .distinct() def get_user_all_attempts(self, questionpaper, user): -- cgit From 9e31fd95ac56165c4ed4923e92fd7b673295cf79 Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Tue, 17 Oct 2017 12:14:40 +0530 Subject: Yaml fields are sorted according to relevance --- yaksh/models.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 3fcfa39..87f153c 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -506,8 +506,20 @@ class Question(models.Model): tmp_file_path = tempfile.mkdtemp() yaml_path = os.path.join(tmp_file_path, "questions_dump.yaml") for elem in q_dict: - sorted_dict = CommentedMap(sorted(elem.items(), key=lambda x:x[0])) - yaml_block = dict_to_yaml(sorted_dict) + relevant_dict = CommentedMap() + irrelevant_dict = CommentedMap() + relevant_dict['summary'] = elem.pop('summary') + relevant_dict['type'] = elem.pop('type') + relevant_dict['language'] = elem.pop('language') + relevant_dict['description'] = elem.pop('description') + relevant_dict['points'] = elem.pop('points') + relevant_dict['testcase'] = elem.pop('testcase') + relevant_dict.update(CommentedMap(sorted(elem.items(), + key=lambda x:x[0] + )) + ) + + yaml_block = dict_to_yaml(relevant_dict) with open(yaml_path, "a") as yaml_file: yaml_file.write(yaml_block) zip_file.write(yaml_path, os.path.basename(yaml_path)) -- cgit From 90402ae9b0f2d4038099e9ea4e39f832063dd0dd Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Wed, 18 Oct 2017 15:40:58 +0530 Subject: - Fix and add test cases - Fix god-mode/user-mode url pattern --- yaksh/models.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 6dc8ce2..de794c4 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1196,11 +1196,12 @@ class AnswerPaper(models.Model): def get_current_question(self, questions): if self.questions_order: - question_id = int(self.questions_order.split(',')[0]) - question = questions.get(id=question_id) - else: - question = questions.first() - return question + available_question_ids = questions.values_list('id', flat=True) + ordered_question_ids = [int(q) for q in self.questions_order.split(',')] + for qid in ordered_question_ids: + if qid in available_question_ids: + return questions.get(id=qid) + return questions.first() def questions_left(self): """Returns the number of questions left.""" -- cgit