fix: redirect after quiz submission
This commit is contained in:
@@ -114,7 +114,7 @@
|
||||
<button class="btn btn-secondary btn-sm hide" id="summary">
|
||||
{{ _("Submit") }}
|
||||
</button>
|
||||
<button class="btn btn-secondary btn-sm mx-auto hide" id="try-again">
|
||||
<button class="btn btn-secondary btn-sm mx-auto hide" id="try-again" data-quiz="{{ quiz.name }}">
|
||||
{{ _("Try Again") }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -125,7 +125,7 @@ const quiz_summary = (e = undefined) => {
|
||||
)} ${total_questions}
|
||||
</div>`
|
||||
);
|
||||
$("#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();
|
||||
}
|
||||
|
||||
@@ -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.") }}
|
||||
</p>
|
||||
<div class="flex">
|
||||
<a class="btn btn-secondary btn-sm" href="/assignments/new-assignment">
|
||||
<a class="btn btn-default btn-sm" href="/assignments/new-assignment">
|
||||
{{ _("Create Assignment") }}
|
||||
</a>
|
||||
<a class="btn btn-secondary btn-sm ml-2" href="/assignments/new-quiz">
|
||||
<a class="btn btn-default btn-sm ml-2" href="/assignments/new-quiz">
|
||||
{{ _("Create Quiz") }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user