From bb0abe27cdbadb44b7307420b63ddd8f8af7ce98 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Thu, 22 Jun 2023 10:52:57 +0530 Subject: [PATCH] fix: redirect after quiz submission --- lms/templates/quiz/quiz.html | 2 +- lms/templates/quiz/quiz.js | 11 ++++++----- lms/www/classes/class.html | 4 ++-- lms/www/quiz_submission/quiz_submission.py | 3 ++- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lms/templates/quiz/quiz.html b/lms/templates/quiz/quiz.html index cf218135..4ae2b242 100644 --- a/lms/templates/quiz/quiz.html +++ b/lms/templates/quiz/quiz.html @@ -114,7 +114,7 @@ - diff --git a/lms/templates/quiz/quiz.js b/lms/templates/quiz/quiz.js index 05fd5889..e5aa0b00 100644 --- a/lms/templates/quiz/quiz.js +++ b/lms/templates/quiz/quiz.js @@ -125,7 +125,7 @@ const quiz_summary = (e = undefined) => { )} ${total_questions} ` ); - $("#try-again").data("submission", data.message.submission); + $("#try-again").attr("data-submission", data.message.submission); $("#try-again").removeClass("hide"); self.quiz_submitted = true; }, @@ -133,11 +133,12 @@ const quiz_summary = (e = undefined) => { }; const try_quiz_again = (e) => { + e.preventDefault(); if (window.location.href.includes("new-submission")) { - window.location.href = window.location.pathname.replace( - "new-submission", - $ - ); + const target = $(e.currentTarget); + window.location.href = `/quiz-submission/${target.data( + "quiz" + )}/${target.data("submission")}`; } else { window.location.reload(); } diff --git a/lms/www/classes/class.html b/lms/www/classes/class.html index 6f9e1d0e..ec398d4e 100644 --- a/lms/www/classes/class.html +++ b/lms/www/classes/class.html @@ -263,10 +263,10 @@ {{ _("To create a new assignment or quiz for this class, click on the buttons below. Once you have created the new assignment or quiz you can come back and add it from here.") }}

- + {{ _("Create Assignment") }} - + {{ _("Create Quiz") }}
diff --git a/lms/www/quiz_submission/quiz_submission.py b/lms/www/quiz_submission/quiz_submission.py index 4519f89b..f7d3f35b 100644 --- a/lms/www/quiz_submission/quiz_submission.py +++ b/lms/www/quiz_submission/quiz_submission.py @@ -17,6 +17,8 @@ def get_context(context): if submission == "new-submission": context.submission = frappe._dict() + context.no_of_attempts = 0 + context.hide_quiz = False else: context.submission = frappe.db.get_value( "LMS Quiz Submission", @@ -45,4 +47,3 @@ def get_context(context): context.hide_quiz = ( context.is_moderator and context.submission.member != frappe.session.user ) - print(context.no_of_attempts)