From 82df4378de785ae67ca21e82e59f61fc3081377b Mon Sep 17 00:00:00 2001 From: scmmishra Date: Tue, 16 Oct 2018 13:04:40 +0530 Subject: [PATCH] Changes to get_quiz function --- erpnext/education/utils.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/erpnext/education/utils.py b/erpnext/education/utils.py index 809fa9e573..493a876a29 100644 --- a/erpnext/education/utils.py +++ b/erpnext/education/utils.py @@ -155,17 +155,17 @@ def get_quiz(content): :params content: name of a Content doctype with content_type quiz""" try: quiz_doc = frappe.get_doc("Content", content) - if quiz_doc.content_type == "Quiz": - import json - quiz = [frappe.get_doc("Question", item.question_link) for item in quiz_doc.questions] - data = [] - for question in quiz: - d = {} - d['Options'] = [{'option':item.option,'is_correct':item.is_correct} for item in quiz[0].options] - d['Question'] = question.question - data.append(d) - return json.dumps(data) - else: + if quiz_doc.content_type != "Quiz": frappe.throw("{0} is not a Quiz".format(content)) + + import json + quiz = [frappe.get_doc("Question", item.question_link) for item in quiz_doc.questions] + data = [] + for question in quiz: + d = {} + d['Question'] = question.question + d['Options'] = [item.option for item in quiz[0].options] + data.append(d) + return data except frappe.DoesNotExistError: - return None \ No newline at end of file + frappe.throw("The quiz \"{0}\" does not exist".format(content))