From 71d3d4efb61d9171b5a5ec1120c1aa3cdd572366 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 28 Jul 2016 17:30:44 +0200 Subject: [exams] Add autostart lecture feature --- .../exams/templates/page-add-edit-exam.html | 62 +++++++++++++++++++--- 1 file changed, 56 insertions(+), 6 deletions(-) (limited to 'modules-available/exams/templates/page-add-edit-exam.html') diff --git a/modules-available/exams/templates/page-add-edit-exam.html b/modules-available/exams/templates/page-add-edit-exam.html index 3f0ef372..744aad29 100644 --- a/modules-available/exams/templates/page-add-edit-exam.html +++ b/modules-available/exams/templates/page-add-edit-exam.html @@ -12,6 +12,7 @@
+

{{lang_locationInfo}}

+ + {{#lectures}} + + {{/lectures}} + +
+ +
+ bla +
+ +
@@ -112,7 +134,7 @@ document.addEventListener("DOMContentLoaded", function () { $('.datepicker').datepicker(dateSettings); $('.timepicker2').timepicker(timeSettings); - showDuration(); + startEndChanged(); }); $('#locations').multiselect({numberDisplayed: 1}); @@ -137,7 +159,7 @@ document.addEventListener("DOMContentLoaded", function () { } }); - var showDuration = function () { + var startEndChanged = function () { var sd = slxMoment(start_date.val() + ' ' + start_time.val(), 'YYYY-MM-DD H:mm'); var ed = slxMoment(end_date.val() + ' ' + end_time.val(), 'YYYY-MM-DD H:mm'); if (!sd.isValid() || !ed.isValid()) { @@ -145,12 +167,40 @@ document.addEventListener("DOMContentLoaded", function () { return; } rspan.text(slxMoment.duration(ed.diff(sd)).humanize()); + // Lecture selection + $('#lecturelist option').each(function (idx, elem) { + var e = $(elem); + var from = e.data('from'); + var to = e.data('to'); + if (!from || !to) + return; + from = slxMoment(from); + to = slxMoment(to); + if (from.isBefore(sd) || to.isAfter(ed)) { + e.css('color', '#999'); + e.data('inrange', false) + } else { + e.css('color', ''); + e.data('inrange', true); + } + }); + updateLectureInfo(); + } + + var updateLectureInfo = function() { + var sel = $('#lecturelist option:selected'); + if (sel.val() === '' || sel.data('inrange')) { + $('#lecture-info').text('-'); + } else { + $('#lecture-info').text('{{lang_lectureOutOfRange}} (' + slxMoment(sel.data('from')).format('YYYY-MM-DD H:mm') + ' - ' + slxMoment(sel.data('to')).format('YYYY-MM-DD H:mm') + ')'); + } } - start_date.change(showDuration); - start_time.change(showDuration); - end_date.change(showDuration); - end_time.change(showDuration); + start_date.change(startEndChanged); + start_time.change(startEndChanged); + end_date.change(startEndChanged); + end_time.change(startEndChanged); + $('#lecturelist').change(updateLectureInfo); }, false); // --> -- cgit v1.2.3-55-g7522