fix: quiz submission page rendering
This commit is contained in:
@@ -1,8 +1,14 @@
|
|||||||
// Copyright (c) 2023, Frappe and contributors
|
// Copyright (c) 2023, Frappe and contributors
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
// frappe.ui.form.on("LMS Payment", {
|
frappe.ui.form.on("LMS Payment", {
|
||||||
// refresh(frm) {
|
onload(frm) {
|
||||||
|
frm.set_query("member", function (doc) {
|
||||||
// },
|
return {
|
||||||
// });
|
filters: {
|
||||||
|
ignore_user_type: 1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ def quiz_summary(quiz, results):
|
|||||||
"score_out_of": score_out_of,
|
"score_out_of": score_out_of,
|
||||||
"submission": submission.name,
|
"submission": submission.name,
|
||||||
"pass": percentage == quiz_details.passing_percentage,
|
"pass": percentage == quiz_details.passing_percentage,
|
||||||
|
"percentage": percentage,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -667,10 +667,17 @@ def notify_mentions(doc, topic):
|
|||||||
subject = _("{0} mentioned you in a comment").format(sender_fullname)
|
subject = _("{0} mentioned you in a comment").format(sender_fullname)
|
||||||
template = "mention_template"
|
template = "mention_template"
|
||||||
|
|
||||||
|
if topic.reference_doctype == "LMS Batch":
|
||||||
|
link = f"/batches/{topic.reference_docname}#discussions"
|
||||||
|
if topic.reference_doctype == "Course Lesson":
|
||||||
|
course = frappe.db.get_value("Course Lesson", topic.reference_docname, "course")
|
||||||
|
lesson_index = get_lesson_index(topic.reference_docname)
|
||||||
|
link = get_lesson_url(course, lesson_index)
|
||||||
|
|
||||||
args = {
|
args = {
|
||||||
"sender": sender_fullname,
|
"sender": sender_fullname,
|
||||||
"content": doc.reply,
|
"content": doc.reply,
|
||||||
"batch_link": "/batches/" + topic.reference_docname + "#discussions",
|
"link": link,
|
||||||
}
|
}
|
||||||
|
|
||||||
for recipient in recipients:
|
for recipient in recipients:
|
||||||
|
|||||||
@@ -7,5 +7,5 @@
|
|||||||
</blockquote>
|
</blockquote>
|
||||||
</p>
|
</p>
|
||||||
<div class="more-info">
|
<div class="more-info">
|
||||||
<a href="{{ batch_link }}">{{ _("Open Batch") }}</a>
|
<a href="{{ link }}">{{ _("Check Discussion") }}</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -10,9 +10,6 @@
|
|||||||
<li>
|
<li>
|
||||||
{{ _("You will have to get {0}% correct answers in order to pass the quiz.").format(quiz.passing_percentage) }}
|
{{ _("You will have to get {0}% correct answers in order to pass the quiz.").format(quiz.passing_percentage) }}
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
{{ _("Without passing the quiz you won't be able to complete the lesson.") }}
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if quiz.max_attempts %}
|
{% if quiz.max_attempts %}
|
||||||
|
|||||||
@@ -134,6 +134,9 @@ const quiz_summary = (e = undefined) => {
|
|||||||
$(".quiz-footer span").addClass("hide");
|
$(".quiz-footer span").addClass("hide");
|
||||||
$("#quiz-form").prepend(
|
$("#quiz-form").prepend(
|
||||||
`<div class="summary bold-heading text-center">
|
`<div class="summary bold-heading text-center">
|
||||||
|
${__("You got")} ${data.message.percentage}% ${__("correct answers")}
|
||||||
|
</div>
|
||||||
|
<div class="summary bold-heading text-center mt-2">
|
||||||
${__("Your score is")} ${data.message.score}
|
${__("Your score is")} ${data.message.score}
|
||||||
${__("out of")} ${data.message.score_out_of}
|
${__("out of")} ${data.message.score_out_of}
|
||||||
</div>`
|
</div>`
|
||||||
|
|||||||
@@ -13,7 +13,39 @@ def get_context(context):
|
|||||||
submission = frappe.form_dict["submission"]
|
submission = frappe.form_dict["submission"]
|
||||||
quiz_name = frappe.form_dict["quiz"]
|
quiz_name = frappe.form_dict["quiz"]
|
||||||
|
|
||||||
context.quiz = frappe.get_doc("LMS Quiz", quiz_name)
|
quiz = frappe.db.get_value(
|
||||||
|
"LMS Quiz",
|
||||||
|
quiz_name,
|
||||||
|
[
|
||||||
|
"name",
|
||||||
|
"title",
|
||||||
|
"max_attempts",
|
||||||
|
"show_answers",
|
||||||
|
"show_submission_history",
|
||||||
|
"passing_percentage",
|
||||||
|
],
|
||||||
|
as_dict=True,
|
||||||
|
)
|
||||||
|
quiz.questions = []
|
||||||
|
fields = ["name", "question", "type", "multiple"]
|
||||||
|
for num in range(1, 5):
|
||||||
|
fields.append(f"option_{num}")
|
||||||
|
fields.append(f"is_correct_{num}")
|
||||||
|
fields.append(f"explanation_{num}")
|
||||||
|
fields.append(f"possibility_{num}")
|
||||||
|
|
||||||
|
questions = frappe.get_all(
|
||||||
|
"LMS Quiz Question",
|
||||||
|
filters={"parent": quiz.name},
|
||||||
|
fields=["question", "marks"],
|
||||||
|
order_by="idx",
|
||||||
|
)
|
||||||
|
|
||||||
|
for question in questions:
|
||||||
|
details = frappe.db.get_value("LMS Question", question.question, fields, as_dict=1)
|
||||||
|
details["marks"] = question.marks
|
||||||
|
quiz.questions.append(details)
|
||||||
|
context.quiz = quiz
|
||||||
|
|
||||||
if submission == "new-submission":
|
if submission == "new-submission":
|
||||||
context.submission = frappe._dict()
|
context.submission = frappe._dict()
|
||||||
|
|||||||
Reference in New Issue
Block a user