fix: quiz and timetable issues
This commit is contained in:
@@ -182,7 +182,7 @@ const check_answer = (e = undefined) => {
|
||||
$(".explanation").removeClass("hide");
|
||||
$("#check").addClass("hide");
|
||||
|
||||
if (current_index == total_questions) {
|
||||
if (current_index == total_questions - 1) {
|
||||
$("#summary").removeClass("hide");
|
||||
} else if (this.show_answers) {
|
||||
$("#next").removeClass("hide");
|
||||
|
||||
@@ -658,7 +658,7 @@ const setup_calendar = (events) => {
|
||||
const calendar = new Calendar(container, options);
|
||||
this.calendar_ = calendar;
|
||||
|
||||
create_events(calendar, events);
|
||||
create_events(calendar, events, calendar_id);
|
||||
add_links_to_events(calendar, events);
|
||||
scroll_to_date(calendar, events);
|
||||
set_calendar_range(calendar, events);
|
||||
@@ -710,8 +710,8 @@ const create_events = (calendar, events, calendar_id) => {
|
||||
id: `event${idx}`,
|
||||
calendarId: calendar_id,
|
||||
title: event.title,
|
||||
start: `${event.date}T${event.start_time}`,
|
||||
end: `${event.date}T${event.end_time}`,
|
||||
start: `${event.date}T${format_time(event.start_time)}`,
|
||||
end: `${event.date}T${format_time(event.end_time)}`,
|
||||
isAllday: event.start_time ? false : true,
|
||||
borderColor: clr,
|
||||
backgroundColor: "var(--fg-color)",
|
||||
@@ -735,6 +735,12 @@ const create_events = (calendar, events, calendar_id) => {
|
||||
calendar.createEvents(calendar_events);
|
||||
};
|
||||
|
||||
const format_time = (time) => {
|
||||
let time_arr = time.split(":");
|
||||
if (time_arr[0] < 10) time_arr[0] = "0" + time_arr[0];
|
||||
return time_arr.join(":");
|
||||
};
|
||||
|
||||
const add_links_to_events = (calendar) => {
|
||||
calendar.on("clickEvent", ({ event }) => {
|
||||
let event_date = event.start.d.d;
|
||||
|
||||
@@ -47,9 +47,20 @@ def get_context(context):
|
||||
quiz.questions.append(details)
|
||||
context.quiz = quiz
|
||||
|
||||
context.all_submissions = frappe.get_all(
|
||||
"LMS Quiz Submission",
|
||||
{
|
||||
"quiz": context.quiz.name,
|
||||
"member": frappe.session.user,
|
||||
},
|
||||
["name", "score", "creation"],
|
||||
order_by="creation desc",
|
||||
)
|
||||
|
||||
context.no_of_attempts = len(context.all_submissions) or 0
|
||||
|
||||
if submission == "new-submission":
|
||||
context.submission = frappe._dict()
|
||||
context.no_of_attempts = 0
|
||||
context.hide_quiz = False
|
||||
else:
|
||||
context.submission = frappe.db.get_value(
|
||||
@@ -65,17 +76,6 @@ def get_context(context):
|
||||
if not context.quiz or not context.submission:
|
||||
raise frappe.PermissionError(_("Invalid Submission URL"))
|
||||
|
||||
context.all_submissions = frappe.get_all(
|
||||
"LMS Quiz Submission",
|
||||
{
|
||||
"quiz": context.quiz.name,
|
||||
"member": context.submission.member,
|
||||
},
|
||||
["name", "score", "creation"],
|
||||
order_by="creation desc",
|
||||
)
|
||||
|
||||
context.no_of_attempts = len(context.all_submissions) or 0
|
||||
context.hide_quiz = (
|
||||
context.is_moderator and context.submission.member != frappe.session.user
|
||||
context.is_moderator or context.submission.member != frappe.session.user
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user