feat: quiz submission
This commit is contained in:
@@ -259,7 +259,7 @@ def check_answer(question, type, answers):
|
||||
|
||||
|
||||
def check_choice_answers(question, answers):
|
||||
fields = []
|
||||
fields = ["multiple"]
|
||||
is_correct = []
|
||||
for num in range(1, 5):
|
||||
fields.append(f"option_{cstr(num)}")
|
||||
@@ -267,6 +267,15 @@ def check_choice_answers(question, answers):
|
||||
|
||||
question_details = frappe.db.get_value("LMS Question", question, fields, as_dict=1)
|
||||
|
||||
""" if question_details.multiple:
|
||||
correct_answers = [ question_details[f"option_{num}"] for num in range(1,5) if question_details[f"is_correct_{num}"]]
|
||||
print(answers)
|
||||
for ans in correct_answers:
|
||||
if ans not in answers:
|
||||
is_correct.append(0)
|
||||
else:
|
||||
is_correct.append(1)
|
||||
else: """
|
||||
for num in range(1, 5):
|
||||
if question_details[f"option_{num}"] in answers:
|
||||
is_correct.append(question_details[f"is_correct_{num}"])
|
||||
|
||||
@@ -99,18 +99,18 @@
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "passing_percentage",
|
||||
"fieldtype": "Int",
|
||||
"label": "Passing Percentage",
|
||||
"non_negative": 1,
|
||||
"read_only": 1,
|
||||
"reqd": 1
|
||||
"fieldname": "passing_percentage",
|
||||
"fieldtype": "Int",
|
||||
"label": "Passing Percentage",
|
||||
"non_negative": 1,
|
||||
"read_only": 1,
|
||||
"reqd": 1
|
||||
}
|
||||
],
|
||||
"in_create": 1,
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2023-10-17 13:07:27.979975",
|
||||
"modified": "2024-01-01 15:53:33.357595",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Quiz Submission",
|
||||
@@ -127,6 +127,17 @@
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"if_owner": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "LMS Student",
|
||||
"share": 1
|
||||
}
|
||||
],
|
||||
"sort_field": "modified",
|
||||
|
||||
@@ -1412,3 +1412,15 @@ def get_country_code():
|
||||
except Exception:
|
||||
pass
|
||||
return
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_question_details(question):
|
||||
fields = ["question", "type", "multiple"]
|
||||
for i in range(1, 5):
|
||||
fields.append(f"option_{i}")
|
||||
fields.append(f"explanation_{i}")
|
||||
fields.append(f"is_correct_{i}")
|
||||
|
||||
question_details = frappe.db.get_value("LMS Question", question, fields, as_dict=1)
|
||||
return question_details
|
||||
|
||||
Reference in New Issue
Block a user