From 0d4135ec2bf6ec09cad670b742d033d0277a4fcb Mon Sep 17 00:00:00 2001 From: scmmishra Date: Thu, 18 Oct 2018 18:04:28 +0530 Subject: [PATCH] LMS: Fixed view for Quiz Co-authored-by: Chinmay Pai --- erpnext/education/doctype/quiz/quiz.py | 9 +++++++-- erpnext/www/lms/course.py | 5 +++++ erpnext/www/lms/templates/includes/quiz.html | 12 ++++++------ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/erpnext/education/doctype/quiz/quiz.py b/erpnext/education/doctype/quiz/quiz.py index a7d76d5dc3..2ecc4856ca 100644 --- a/erpnext/education/doctype/quiz/quiz.py +++ b/erpnext/education/doctype/quiz/quiz.py @@ -17,6 +17,11 @@ class Quiz(Document): pass - def get_question(self): - pass + def get_questions(self): + quiz_question = self.get_all_children() + if quiz_question: + questions = [frappe.get_doc('Question', question.question_link) for question in quiz_question] + return questions + else: + return None diff --git a/erpnext/www/lms/course.py b/erpnext/www/lms/course.py index a05725e436..35c28793e7 100644 --- a/erpnext/www/lms/course.py +++ b/erpnext/www/lms/course.py @@ -22,6 +22,11 @@ def get_context(context): context.program_name = program_name context.content_type = content_type context.next_content_type, context.next_content = get_next_content(content_name, content_type, current_course.get_content_info()) + if content_type == "Quiz": + context.questions = current_content.get_questions() + print(content_type) + print(current_content.title) + print(context.questions) def get_next_content(c_name, c_type, content_list): try: diff --git a/erpnext/www/lms/templates/includes/quiz.html b/erpnext/www/lms/templates/includes/quiz.html index 6f3a58edc8..83f598eb1c 100644 --- a/erpnext/www/lms/templates/includes/quiz.html +++ b/erpnext/www/lms/templates/includes/quiz.html @@ -1,15 +1,15 @@ {% macro quiz(loop_index, question) %} -
-
{{ loop_index }}{{ question['question'] }}
+
+
{{ loop_index }}{{ question.question }}
- {% for option in question['options'] %} + {% for option in question.options %}
- -
{% endfor %}