LMS: Fixed view for Quiz
Co-authored-by: Chinmay Pai <chinmaydpai@gmail.com>
diff --git a/erpnext/education/doctype/quiz/quiz.py b/erpnext/education/doctype/quiz/quiz.py
index a7d76d5..2ecc485 100644
--- a/erpnext/education/doctype/quiz/quiz.py
+++ b/erpnext/education/doctype/quiz/quiz.py
@@ -17,6 +17,11 @@
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 a05725e..35c2879 100644
--- a/erpnext/www/lms/course.py
+++ b/erpnext/www/lms/course.py
@@ -22,6 +22,11 @@
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 6f3a58e..83f598e 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) %}
-<div class="question mt-4" id="question['question']" data-question="{{ question['id'] }}">
- <h5>{{ loop_index }}{{ question['question'] }}</h5>
+<div class="question mt-4" id="{{ question.question }}" data-question="{{ question.name }}">
+ <h5>{{ loop_index }}{{ question.question }}</h5>
<div class="options ml-2">
<div class="form-check pb-1 hidden">
<input class="form-check-input" type="radio" name="{{ question['id'] }}" value="0" checked>
</div>
- {% for option in question['options'] %}
+ {% for option in question.options %}
<div class="form-check pb-1">
- <input class="form-check-input" type="radio" name="{{ question['id'] }}" id="{{loop_index}}-{{ option }}" value="{{ option }}">
- <label class="form-check-label" for="{{loop_index}}-{{ option }}">
- {{ option }}
+ <input class="form-check-input" type="radio" name="{{ question.name }}" id="{{loop_index}}-{{ option.option }}" value="{{ option.option }}">
+ <label class="form-check-label" for="{{loop_index}}-{{ option.option }}">
+ {{ option.option }}
</label>
</div>
{% endfor %}