diff --git a/erpnext/education/doctype/question/question.py b/erpnext/education/doctype/question/question.py index 57d8de4d651..8cd23983ce9 100644 --- a/erpnext/education/doctype/question/question.py +++ b/erpnext/education/doctype/question/question.py @@ -14,20 +14,20 @@ class Question(Document): self.check_minimum_one_correct_answer() def check_at_least_one_option(self): - if len(self.get_all_children()) <= 1: + if len(self.options) <= 1: frappe.throw(_("A question must have more than one options")) else: pass def check_minimum_one_correct_answer(self): - correct_options = [question.is_correct for question in self.get_all_children()] + correct_options = [option.is_correct for option in self.options] if bool(sum(correct_options)): pass else: frappe.throw(_("A qustion must have at least one correct options")) def get_answer(self): - options = self.get_all_children() + options = self.options answers = [item.name for item in options if item.is_correct == True] if len(answers) == 0: frappe.throw("No correct answer is set for {0}".format(self.name)) diff --git a/erpnext/education/doctype/quiz/quiz.py b/erpnext/education/doctype/quiz/quiz.py index 2c436925880..4bd7cad453b 100644 --- a/erpnext/education/doctype/quiz/quiz.py +++ b/erpnext/education/doctype/quiz/quiz.py @@ -40,7 +40,13 @@ class Quiz(Document): 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] + questions = [frappe.get_doc('Question', question.question_link).as_dict() for question in quiz_question] + for question in questions: + correct_options = [option.is_correct for option in question.options] + if sum(correct_options) > 1: + question['type'] = "MultipleChoice" + else: + question['type'] = "SingleChoice" return questions else: return None diff --git a/erpnext/public/js/education/lms/components/Quiz.vue b/erpnext/public/js/education/lms/components/Quiz.vue index 41f5f3a81ef..afb61860f5e 100644 --- a/erpnext/public/js/education/lms/components/Quiz.vue +++ b/erpnext/public/js/education/lms/components/Quiz.vue @@ -10,7 +10,7 @@