fix: redirect after quiz submission
This commit is contained in:
@@ -114,7 +114,7 @@
|
|||||||
<button class="btn btn-secondary btn-sm hide" id="summary">
|
<button class="btn btn-secondary btn-sm hide" id="summary">
|
||||||
{{ _("Submit") }}
|
{{ _("Submit") }}
|
||||||
</button>
|
</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") }}
|
{{ _("Try Again") }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ const quiz_summary = (e = undefined) => {
|
|||||||
)} ${total_questions}
|
)} ${total_questions}
|
||||||
</div>`
|
</div>`
|
||||||
);
|
);
|
||||||
$("#try-again").data("submission", data.message.submission);
|
$("#try-again").attr("data-submission", data.message.submission);
|
||||||
$("#try-again").removeClass("hide");
|
$("#try-again").removeClass("hide");
|
||||||
self.quiz_submitted = true;
|
self.quiz_submitted = true;
|
||||||
},
|
},
|
||||||
@@ -133,11 +133,12 @@ const quiz_summary = (e = undefined) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const try_quiz_again = (e) => {
|
const try_quiz_again = (e) => {
|
||||||
|
e.preventDefault();
|
||||||
if (window.location.href.includes("new-submission")) {
|
if (window.location.href.includes("new-submission")) {
|
||||||
window.location.href = window.location.pathname.replace(
|
const target = $(e.currentTarget);
|
||||||
"new-submission",
|
window.location.href = `/quiz-submission/${target.data(
|
||||||
$
|
"quiz"
|
||||||
);
|
)}/${target.data("submission")}`;
|
||||||
} else {
|
} else {
|
||||||
window.location.reload();
|
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.") }}
|
{{ _("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>
|
</p>
|
||||||
<div class="flex">
|
<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") }}
|
{{ _("Create Assignment") }}
|
||||||
</a>
|
</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") }}
|
{{ _("Create Quiz") }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ def get_context(context):
|
|||||||
|
|
||||||
if submission == "new-submission":
|
if submission == "new-submission":
|
||||||
context.submission = frappe._dict()
|
context.submission = frappe._dict()
|
||||||
|
context.no_of_attempts = 0
|
||||||
|
context.hide_quiz = False
|
||||||
else:
|
else:
|
||||||
context.submission = frappe.db.get_value(
|
context.submission = frappe.db.get_value(
|
||||||
"LMS Quiz Submission",
|
"LMS Quiz Submission",
|
||||||
@@ -45,4 +47,3 @@ def get_context(context):
|
|||||||
context.hide_quiz = (
|
context.hide_quiz = (
|
||||||
context.is_moderator and context.submission.member != frappe.session.user
|
context.is_moderator and context.submission.member != frappe.session.user
|
||||||
)
|
)
|
||||||
print(context.no_of_attempts)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user