From 9d9bc9fd999ef958c12502e3deb70a3464cf79db Mon Sep 17 00:00:00 2001 From: semteacher Date: Sun, 23 Nov 2014 15:45:25 +0200 Subject: [PATCH 01/16] refactoring aperiodic session feature --- teacherview.php | 1 + version.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/teacherview.php b/teacherview.php index 73942843..21f12b55 100644 --- a/teacherview.php +++ b/teacherview.php @@ -398,6 +398,7 @@ function scheduler_print_schedulebox(scheduler_instance $scheduler, $studentid, $addbuttons = array(); $addbuttons[] = $commandbar->action_link(new moodle_url($actionurl, array('what' => 'addsession')), 'addsession', 't/add'); +$addbuttons[] = $commandbar->action_link(new moodle_url($actionurl, array('what' => 'addaperiodsession')), 'addaperiodsession', 't/add'); $addbuttons[] = $commandbar->action_link(new moodle_url($actionurl, array('what' => 'addslot')), 'addsingleslot', 't/add'); $commandbar->add_group(get_string('addcommands', 'scheduler'), $addbuttons); diff --git a/version.php b/version.php index 367bfbff..70bff2a7 100644 --- a/version.php +++ b/version.php @@ -16,7 +16,7 @@ */ $plugin->component = 'mod_scheduler'; // Full name of the plugin (used for diagnostics) -$plugin->version = 2014090200; // The current module version (Date: YYYYMMDDXX) +$plugin->version = 2014090202; // The current module version (Date: YYYYMMDDXX) $plugin->release = '2.x dev'; // Human-friendly version name $plugin->requires = 2014050600; // Requires Moodle 2.7 $plugin->maturity = MATURITY_ALPHA; // Alpha development code - not for production sites From b83308280835e649fd0c69754d875bb7b38e70bd Mon Sep 17 00:00:00 2001 From: semteacher Date: Sun, 23 Nov 2014 15:59:48 +0200 Subject: [PATCH 02/16] refactoring $action == 'addaperiodsession' --- teacherview.php | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/teacherview.php b/teacherview.php index 21f12b55..239c0ee6 100644 --- a/teacherview.php +++ b/teacherview.php @@ -197,7 +197,7 @@ function scheduler_print_schedulebox(scheduler_instance $scheduler, $studentid, } } -/************************************ Add session multiple slots form ****************************************/ +/************************************ Add session multiple slots (weekly) form ****************************************/ if ($action == 'addsession') { $actionurl = new moodle_url('/mod/scheduler/view.php', @@ -223,6 +223,43 @@ function scheduler_print_schedulebox(scheduler_instance $scheduler, $studentid, } } +/************************************ Add session multiple slots (aperiodically) form ************************************/ +if ($action == 'addaperiodsession') { + //TODO: remove? it was the jquery localization option + $courselang = substr($COURSE->lang, 0, 2); +// if ($courselang == 'en'){ +// $courselang = ''; +// } + + $actionurl = new moodle_url('/mod/scheduler/view.php', + array('what' => 'addaperiodsession', 'id' => $cm->id, 'subpage' => $subpage)); + $returnurl = new moodle_url('/mod/scheduler/view.php', + array('what' => 'view', 'id' => $cm->id, 'subpage' => $subpage)); + + if (!scheduler_has_teachers($context)) { + print_error('needteachers', 'scheduler', $returnurl); + } + //create form + $mform = new scheduler_addaperiodsession_form($actionurl, $scheduler, $cm, $usergroups); + //process form responce + if ($mform->is_cancelled()) { + redirect($returnurl); + } else if ($formdata = $mform->get_data()) { + scheduler_action_doaddaperiodsession($scheduler, $formdata); + } else { + //prepare and load the YUI module + $calconfig=array($courselang); + $calfunction ='M.mod_scheduler.calpane.init'; + $calmodule = 'moodle-mod_scheduler-calpane'; + $PAGE->requires->yui_module($calmodule, $calfunction, $calconfig); + //display form + echo $output->heading(get_string('addaperiodsession', 'scheduler')); + $mform->display(); + echo $output->footer($course); + die; + } +} + /************************************ Schedule a student form ***********************************************/ if ($action == 'schedule') { if ($subaction == 'dochooseslot') { From 89f17f72b2c74b655c4add4e7b66c54f21b9a039 Mon Sep 17 00:00:00 2001 From: semteacher Date: Sun, 23 Nov 2014 16:01:04 +0200 Subject: [PATCH 03/16] refactoring YUI calendar readded --- .../moodle-mod_scheduler-calpane-debug.js | 84 +++++++++++++++++++ .../moodle-mod_scheduler-calpane-min.js | 1 + .../moodle-mod_scheduler-calpane.js | 84 +++++++++++++++++++ yui/src/calpane/build.json | 10 +++ yui/src/calpane/js/calpane.js | 80 ++++++++++++++++++ yui/src/calpane/meta/calpane.json | 11 +++ 6 files changed, 270 insertions(+) create mode 100644 yui/build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane-debug.js create mode 100644 yui/build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane-min.js create mode 100644 yui/build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane.js create mode 100644 yui/src/calpane/build.json create mode 100644 yui/src/calpane/js/calpane.js create mode 100644 yui/src/calpane/meta/calpane.json diff --git a/yui/build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane-debug.js b/yui/build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane-debug.js new file mode 100644 index 00000000..792acb38 --- /dev/null +++ b/yui/build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane-debug.js @@ -0,0 +1,84 @@ +YUI.add('moodle-mod_scheduler-calpane', function (Y, NAME) { + +M.mod_scheduler = M.mod_scheduler || {}; +M.mod_scheduler.calpane = { + init: function(langconf) { + Y.Intl.add("datatype-date-format", "uk-UK", { + "a":["Нд","Пн","Вт","Ср","Чт","Пт","Сб"], + "A":["Неділя","Понеділок","Вівторк","Середа","Четвер","П'ятниця","Субота"], + "B":["Січень","Лютий","Березень","Квітень","Травень","Червень","Липень","Серпень","Вересень","Жовтень","Листопад","Грудень"] + }); +// Y.Intl.add("datatype-date-format", "ru-RU", { +// "a":["Вс","Пн","Вт","Ср","Чт","Пт","Сб"], +// "A":["Воскресенье","Понедельник","Вторник","Среда","Четверг","Пятница","Суббота"], +// "B":["Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"] +// }); + Y.CalendarBase.CONTENT_TEMPLATE = Y.CalendarBase.THREE_PANE_TEMPLATE; + // Setup basic calendar parameters + var calend = new Y.Calendar({ + contentBox: "#calContainer", + width:'750px', + showPrevMonth: true, + showNextMonth: true, + selectionMode: 'multiple-sticky', + minimumDate: new Date(), + date: new Date()}); + //Localization + if (langconf === "uk") { + calend.set("strings.very_short_weekdays", ["Нд","Пн","Вт","Ср","Чт","Пт","Сб"]); + Y.Intl.setLang("datatype-date-format", "uk-UK"); + } else if (langconf === "ru") { + calend.set("strings.very_short_weekdays", ["Вс","Пн","Вт","Ср","Чт","Пт","Сб"]); + Y.Intl.setLang("datatype-date-format", "ru");//not working + } + // Draw calendar instance + calend.render(); + // Create a set of rules to match specific dates. In this case, + // the "all_weekends" rule will match any Saturday or Sunday. + var rules = { + "all": { + "all": { + "all": { + "0,6": "all_weekends" + } + } + } + }; + // Set the calendar customRenderer, provides the rules defined above. + calend.set("customRenderer", { + rules: rules, + filterFunction: function (date, node, rules) { + if (Y.Array.indexOf(rules, 'all_weekends') >= 0) { + node.addClass("redtext"); + } + } + }); + // Set a custom header renderer with a callback function, + // which receives the current date and outputs a string. + calend.set("headerRenderer", function (curDate) { + var ydate = Y.DataType.Date, + output = ydate.format(curDate, { + format: "%B %Y" + }) + " — " + ydate.format(ydate.addMonths(curDate, 1), { + format: "%B %Y" + })+ " — " + ydate.format(ydate.addMonths(curDate, 2), { + format: "%B %Y" + }); + return output; + }); + // Listen to calendar's selectionChange event. + calend.on("selectionChange", function (ev) { + var dtdate = Y.DataType.Date; + var listdates = '[{'; + // Collect dates from selection + for (var i = 0; i < ev.newSelection.length; i++) { + listdates += (i === 0 ? "" : ",") + '"'+ i +'":"'+ dtdate.format(ev.newSelection[i])+'"'; + } + listdates += "}]"; + //set dates to HTML control + Y.one(document.getElementsByName('getlistdates')[0]).set('value', listdates); + }); + } +}; + +}, '@VERSION@', {"requires": ["base", "calendar", "datatype-date", "node", "intl"]}); diff --git a/yui/build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane-min.js b/yui/build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane-min.js new file mode 100644 index 00000000..b1c3c7eb --- /dev/null +++ b/yui/build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane-min.js @@ -0,0 +1 @@ +YUI.add("moodle-mod_scheduler-calpane",function(e,t){M.mod_scheduler=M.mod_scheduler||{},M.mod_scheduler.calpane={init:function(t){e.Intl.add("datatype-date-format","uk-UK",{a:["\u041d\u0434","\u041f\u043d","\u0412\u0442","\u0421\u0440","\u0427\u0442","\u041f\u0442","\u0421\u0431"],A:["\u041d\u0435\u0434\u0456\u043b\u044f","\u041f\u043e\u043d\u0435\u0434\u0456\u043b\u043e\u043a","\u0412\u0456\u0432\u0442\u043e\u0440\u043a","\u0421\u0435\u0440\u0435\u0434\u0430","\u0427\u0435\u0442\u0432\u0435\u0440","\u041f'\u044f\u0442\u043d\u0438\u0446\u044f","\u0421\u0443\u0431\u043e\u0442\u0430"],B:["\u0421\u0456\u0447\u0435\u043d\u044c","\u041b\u044e\u0442\u0438\u0439","\u0411\u0435\u0440\u0435\u0437\u0435\u043d\u044c","\u041a\u0432\u0456\u0442\u0435\u043d\u044c","\u0422\u0440\u0430\u0432\u0435\u043d\u044c","\u0427\u0435\u0440\u0432\u0435\u043d\u044c","\u041b\u0438\u043f\u0435\u043d\u044c","\u0421\u0435\u0440\u043f\u0435\u043d\u044c","\u0412\u0435\u0440\u0435\u0441\u0435\u043d\u044c","\u0416\u043e\u0432\u0442\u0435\u043d\u044c","\u041b\u0438\u0441\u0442\u043e\u043f\u0430\u0434","\u0413\u0440\u0443\u0434\u0435\u043d\u044c"]}),e.CalendarBase.CONTENT_TEMPLATE=e.CalendarBase.THREE_PANE_TEMPLATE;var n=new e.Calendar({contentBox:"#calContainer",width:"750px",showPrevMonth:!0,showNextMonth:!0,selectionMode:"multiple-sticky",minimumDate:new Date,date:new Date});t==="uk"?(n.set("strings.very_short_weekdays",["\u041d\u0434","\u041f\u043d","\u0412\u0442","\u0421\u0440","\u0427\u0442","\u041f\u0442","\u0421\u0431"]),e.Intl.setLang("datatype-date-format","uk-UK")):t==="ru"&&(n.set("strings.very_short_weekdays",["\u0412\u0441","\u041f\u043d","\u0412\u0442","\u0421\u0440","\u0427\u0442","\u041f\u0442","\u0421\u0431"]),e.Intl.setLang("datatype-date-format","ru")),n.render();var r={all:{all:{all:{"0,6":"all_weekends"}}}};n.set("customRenderer",{rules:r,filterFunction:function(t,n,r){e.Array.indexOf(r,"all_weekends")>=0&&n.addClass("redtext")}}),n.set("headerRenderer",function(t){var n=e.DataType.Date,r=n.format(t,{format:"%B %Y"})+" — "+n.format(n.addMonths(t,1),{format:"%B %Y"})+" — "+n.format(n.addMonths(t,2),{format:"%B %Y"});return r}),n.on("selectionChange",function(t){var n=e.DataType.Date,r="[{";for(var i=0;i= 0) { + node.addClass("redtext"); + } + } + }); + // Set a custom header renderer with a callback function, + // which receives the current date and outputs a string. + calend.set("headerRenderer", function (curDate) { + var ydate = Y.DataType.Date, + output = ydate.format(curDate, { + format: "%B %Y" + }) + " — " + ydate.format(ydate.addMonths(curDate, 1), { + format: "%B %Y" + })+ " — " + ydate.format(ydate.addMonths(curDate, 2), { + format: "%B %Y" + }); + return output; + }); + // Listen to calendar's selectionChange event. + calend.on("selectionChange", function (ev) { + var dtdate = Y.DataType.Date; + var listdates = '[{'; + // Collect dates from selection + for (var i = 0; i < ev.newSelection.length; i++) { + listdates += (i === 0 ? "" : ",") + '"'+ i +'":"'+ dtdate.format(ev.newSelection[i])+'"'; + } + listdates += "}]"; + //set dates to HTML control + Y.one(document.getElementsByName('getlistdates')[0]).set('value', listdates); + }); + } +}; + +}, '@VERSION@', {"requires": ["base", "calendar", "datatype-date", "node", "intl"]}); diff --git a/yui/src/calpane/build.json b/yui/src/calpane/build.json new file mode 100644 index 00000000..a791f4c5 --- /dev/null +++ b/yui/src/calpane/build.json @@ -0,0 +1,10 @@ +{ + "name": "moodle-mod_scheduler-calpane", + "builds": { + "moodle-mod_scheduler-calpane": { + "jsfiles": [ + "calpane.js" + ] + } + } +} \ No newline at end of file diff --git a/yui/src/calpane/js/calpane.js b/yui/src/calpane/js/calpane.js new file mode 100644 index 00000000..df75bfc0 --- /dev/null +++ b/yui/src/calpane/js/calpane.js @@ -0,0 +1,80 @@ +M.mod_scheduler = M.mod_scheduler || {}; +M.mod_scheduler.calpane = { + init: function(langconf) { + Y.Intl.add("datatype-date-format", "uk-UK", { + "a":["Нд","Пн","Вт","Ср","Чт","Пт","Сб"], + "A":["Неділя","Понеділок","Вівторк","Середа","Четвер","П'ятниця","Субота"], + "B":["Січень","Лютий","Березень","Квітень","Травень","Червень","Липень","Серпень","Вересень","Жовтень","Листопад","Грудень"] + }); +// Y.Intl.add("datatype-date-format", "ru-RU", { +// "a":["Вс","Пн","Вт","Ср","Чт","Пт","Сб"], +// "A":["Воскресенье","Понедельник","Вторник","Среда","Четверг","Пятница","Суббота"], +// "B":["Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"] +// }); + Y.CalendarBase.CONTENT_TEMPLATE = Y.CalendarBase.THREE_PANE_TEMPLATE; + // Setup basic calendar parameters + var calend = new Y.Calendar({ + contentBox: "#calContainer", + width:'750px', + showPrevMonth: true, + showNextMonth: true, + selectionMode: 'multiple-sticky', + minimumDate: new Date(), + date: new Date()}); + //Localization + if (langconf === "uk") { + calend.set("strings.very_short_weekdays", ["Нд","Пн","Вт","Ср","Чт","Пт","Сб"]); + Y.Intl.setLang("datatype-date-format", "uk-UK"); + } else if (langconf === "ru") { + calend.set("strings.very_short_weekdays", ["Вс","Пн","Вт","Ср","Чт","Пт","Сб"]); + Y.Intl.setLang("datatype-date-format", "ru");//not working + } + // Draw calendar instance + calend.render(); + // Create a set of rules to match specific dates. In this case, + // the "all_weekends" rule will match any Saturday or Sunday. + var rules = { + "all": { + "all": { + "all": { + "0,6": "all_weekends" + } + } + } + }; + // Set the calendar customRenderer, provides the rules defined above. + calend.set("customRenderer", { + rules: rules, + filterFunction: function (date, node, rules) { + if (Y.Array.indexOf(rules, 'all_weekends') >= 0) { + node.addClass("redtext"); + } + } + }); + // Set a custom header renderer with a callback function, + // which receives the current date and outputs a string. + calend.set("headerRenderer", function (curDate) { + var ydate = Y.DataType.Date, + output = ydate.format(curDate, { + format: "%B %Y" + }) + " — " + ydate.format(ydate.addMonths(curDate, 1), { + format: "%B %Y" + })+ " — " + ydate.format(ydate.addMonths(curDate, 2), { + format: "%B %Y" + }); + return output; + }); + // Listen to calendar's selectionChange event. + calend.on("selectionChange", function (ev) { + var dtdate = Y.DataType.Date; + var listdates = '[{'; + // Collect dates from selection + for (var i = 0; i < ev.newSelection.length; i++) { + listdates += (i === 0 ? "" : ",") + '"'+ i +'":"'+ dtdate.format(ev.newSelection[i])+'"'; + } + listdates += "}]"; + //set dates to HTML control + Y.one(document.getElementsByName('getlistdates')[0]).set('value', listdates); + }); + } +}; \ No newline at end of file diff --git a/yui/src/calpane/meta/calpane.json b/yui/src/calpane/meta/calpane.json new file mode 100644 index 00000000..aefbcd9c --- /dev/null +++ b/yui/src/calpane/meta/calpane.json @@ -0,0 +1,11 @@ +{ + "moodle-mod_scheduler-calpane": { + "requires": [ + "base", + "calendar", + "datatype-date", + "node", + "intl" + ] + } +} \ No newline at end of file From de5a6059af97ec24b94a4f9dabdf86e82f2ee4dd Mon Sep 17 00:00:00 2001 From: semteacher Date: Sun, 23 Nov 2014 16:08:06 +0200 Subject: [PATCH 04/16] refactoring scheduler_addaperiodsession_form --- slotforms.php | 194 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 194 insertions(+) diff --git a/slotforms.php b/slotforms.php index c3521d18..285b2c69 100644 --- a/slotforms.php +++ b/slotforms.php @@ -475,3 +475,197 @@ public function validation($data, $files) { return $errors; } } +//TDMU +class scheduler_addaperiodsession_form extends scheduler_slotform_base { + + protected function definition() { + + global $DB, $CFG, $COURSE; + + $mform = $this->_form; + + // Start and end of range +// $mform->addElement('date_selector', 'rangestart', get_string('date', 'scheduler')); +// $mform->setDefault('rangestart', time()); + +// $mform->addElement('date_selector', 'rangeend', get_string('enddate', 'scheduler')); +// $mform->setDefault('rangeend', time()); + + // Weekdays selection +// $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday'); +// foreach ($weekdays as $day) { +// $label = ($day == 'monday') ? get_string('addondays', 'scheduler') : ''; +// $mform->addElement('advcheckbox', $day, $label, get_string($day, 'scheduler')); +// $mform->setDefault($day, true); +// } +// $mform->addElement('advcheckbox', 'saturday', '', get_string('saturday', 'scheduler')); +// $mform->addElement('advcheckbox', 'sunday', '', get_string('sunday', 'scheduler')); + + //TODO: remove? it was the jquery localization option +// $courselang = substr($COURSE->lang, 0, 2); +// if ($courselang == 'en'){ +// $courselang = ''; +// } + + $listdates = ""; +// $rangestart = time(); + +// $mform->addElement('hidden', 'rangestart', $rangestart); + $mform->addElement('hidden', 'getlistdates', $listdates); + // Define Calendar panel + $mform->addElement('html', '
'); + $mform->addElement('html', '
'); + $mform->addElement('html', '
'); + // Start and end time + $hours = array(); + $minutes = array(); + for ($i=0; $i<=23; $i++) { + $hours[$i] = sprintf("%02d", $i); + } + for ($i=0; $i<60; $i+=5) { + $minutes[$i] = sprintf("%02d", $i); + } + $starttimegroup = array(); + $starttimegroup[] = $mform->createElement('select', 'starthour', get_string('hour', 'form'), $hours); + $starttimegroup[] = $mform->createElement('select', 'startminute', get_string('minute', 'form'), $minutes); + $mform->addGroup ($starttimegroup, 'starttime', get_string('starttime', 'scheduler'), null, false); + $endtimegroup = array(); + $endtimegroup[] = $mform->createElement('select', 'endhour', get_string('hour', 'form'), $hours); + $endtimegroup[] = $mform->createElement('select', 'endminute', get_string('minute', 'form'), $minutes); + $mform->addGroup ($endtimegroup, 'endtime', get_string('endtime', 'scheduler'), null, false); + + // Divide into slots? + $mform->addElement('selectyesno', 'divide', get_string('divide', 'scheduler')); + $mform->setDefault('divide', 1); + + // Duration of the slot + $this->add_duration_field('minutesperslot'); + + // Ignore conflict checkbox + $mform->addElement('checkbox', 'ignoreconflicts', get_string('ignoreconflicts', 'scheduler')); + $mform->setDefault('ignoreconflicts', false); + $mform->addHelpButton('ignoreconflicts', 'ignoreconflicts', 'scheduler'); + + // Break between slots + $this->add_minutes_field('break', 'break', 0, 'minutes'); + + // Force when overlap? + $mform->addElement('selectyesno', 'forcewhenoverlap', get_string('forcewhenoverlap', 'scheduler')); + + // Common fields + $this->add_base_fields(); + + // Display slot from date - relative + $hideuntilsel = array(); + $hideuntilsel[0] = get_string('now', 'scheduler'); + $hideuntilsel[DAYSECS] = get_string('onedaybefore', 'scheduler'); + for ($i = 2; $i < 7; $i++) { + $hideuntilsel[DAYSECS*$i] = get_string('xdaysbefore', 'scheduler', $i); + } + $hideuntilsel[WEEKSECS] = get_string('oneweekbefore', 'scheduler'); + for ($i = 2; $i < 7; $i++) { + $hideuntilsel[WEEKSECS*$i] = get_string('xweeksbefore', 'scheduler', $i); + } + $mform->addElement('select', 'hideuntilrel', get_string('displayfrom', 'scheduler'), $hideuntilsel); + $mform->setDefault('hideuntilsel', 0); + + // E-mail reminder from + $remindersel = array(); + $remindersel[-1] = get_string('never', 'scheduler'); + $remindersel[0] = get_string('onthemorningofappointment', 'scheduler'); + $remindersel[DAYSECS] = get_string('onedaybefore', 'scheduler'); + for ($i = 2; $i < 7; $i++) { + $remindersel[DAYSECS * $i] = get_string('xdaysbefore', 'scheduler', $i); + } + $remindersel[WEEKSECS] = get_string('oneweekbefore', 'scheduler'); + for ($i = 2; $i < 7; $i++) { + $remindersel[WEEKSECS*$i] = get_string('xweeksbefore', 'scheduler', $i); + } + + $mform->addElement('select', 'emaildaterel', get_string('emailreminder', 'scheduler'), $remindersel); + $mform->setDefault('remindersel', -1); + + $this->add_action_buttons(); + + } + + public function validation($data, $files) { + $errors = parent::validation($data, $files); + + // Range is negative +// $fordays = ($data['rangeend'] - $data['rangestart']) / DAYSECS; +// if ($fordays < 0) { +// $errors['rangeend'] = get_string('negativerange', 'scheduler'); +// } + + // Time range is negative + $starttime = $data['starthour']*60+$data['startminute']; + $endtime = $data['endhour']*60+$data['endminute']; + if ($starttime > $endtime) { + $errors['endtime'] = get_string('negativerange', 'scheduler'); + } + + //TODO: need one more field to pass this: First slot is in the past +// if ($data['rangestart'] < time() - DAYSECS) { +// $errors['rangestart'] = get_string('startpast', 'scheduler'); +// } + + // Break must be nonnegative + if ($data['break'] < 0) { + $errors['breakgroup'] = get_string('breaknotnegative', 'scheduler'); + } + + // TODO conflict checks + + /* + + /// make a base slot for generating + $slot = new stdClass(); + $slot->appointmentlocation = $data->appointmentlocation; + $slot->exclusivity = $data->exclusivity; + $slot->reuse = $data->reuse; + $slot->duration = $data->duration; + $slot->schedulerid = $scheduler->id; + $slot->timemodified = time(); + $slot->teacherid = $data->teacherid; + + /// check if overlaps. Check also if some slots are in allowed day range + $startfrom = $data->rangestart; + $noslotsallowed = true; + for ($d = 0; $d <= $fordays; $d ++){ + $starttime = $startfrom + ($d * DAYSECS); + $eventdate = usergetdate($starttime); + $dayofweek = $eventdate['wday']; + if ((($dayofweek == 1) && ($data->monday == 1)) || + (($dayofweek == 2) && ($data->tuesday == 1)) || + (($dayofweek == 3) && ($data->wednesday == 1)) || + (($dayofweek == 4) && ($data->thursday == 1)) || + (($dayofweek == 5) && ($data->friday == 1)) || + (($dayofweek == 6) && ($data->saturday == 1)) || + (($dayofweek == 0) && ($data->sunday == 1))){ + $noslotsallowed = false; + $data->starttime = make_timestamp($eventdate['year'], $eventdate['mon'], $eventdate['mday'], $data->starthour, $data->startminute); + $conflicts = scheduler_get_conflicts($scheduler->id, $data->starttime, $data->starttime + $data->duration * 60, $data->teacherid, 0, SCHEDULER_ALL, false); + if (!$data->forcewhenoverlap){ + if ($conflicts){ + unset($erroritem); + $erroritem->message = get_string('overlappings', 'scheduler'); + $erroritem->on = 'range'; + $errors[] = $erroritem; + } + } + } + } + + /// Finally check if some slots are allowed (an error is thrown to ask care to this situation) + if ($noslotsallowed){ + unset($erroritem); + $erroritem->message = get_string('allslotsincloseddays', 'scheduler'); + $erroritem->on = 'days'; + $errors[] = $erroritem; + } + */ + + return $errors; + } +} From e642737e637bab6ee4d3f611afeadd34e886cd6d Mon Sep 17 00:00:00 2001 From: semteacher Date: Sun, 23 Nov 2014 17:30:32 +0200 Subject: [PATCH 05/16] clean-up --- slotforms.php | 37 --------------- teacherview.controller.php | 94 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 37 deletions(-) diff --git a/slotforms.php b/slotforms.php index 285b2c69..ce77bd72 100644 --- a/slotforms.php +++ b/slotforms.php @@ -484,33 +484,7 @@ protected function definition() { $mform = $this->_form; - // Start and end of range -// $mform->addElement('date_selector', 'rangestart', get_string('date', 'scheduler')); -// $mform->setDefault('rangestart', time()); - -// $mform->addElement('date_selector', 'rangeend', get_string('enddate', 'scheduler')); -// $mform->setDefault('rangeend', time()); - - // Weekdays selection -// $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday'); -// foreach ($weekdays as $day) { -// $label = ($day == 'monday') ? get_string('addondays', 'scheduler') : ''; -// $mform->addElement('advcheckbox', $day, $label, get_string($day, 'scheduler')); -// $mform->setDefault($day, true); -// } -// $mform->addElement('advcheckbox', 'saturday', '', get_string('saturday', 'scheduler')); -// $mform->addElement('advcheckbox', 'sunday', '', get_string('sunday', 'scheduler')); - - //TODO: remove? it was the jquery localization option -// $courselang = substr($COURSE->lang, 0, 2); -// if ($courselang == 'en'){ -// $courselang = ''; -// } - $listdates = ""; -// $rangestart = time(); - -// $mform->addElement('hidden', 'rangestart', $rangestart); $mform->addElement('hidden', 'getlistdates', $listdates); // Define Calendar panel $mform->addElement('html', '
'); @@ -592,12 +566,6 @@ protected function definition() { public function validation($data, $files) { $errors = parent::validation($data, $files); - // Range is negative -// $fordays = ($data['rangeend'] - $data['rangestart']) / DAYSECS; -// if ($fordays < 0) { -// $errors['rangeend'] = get_string('negativerange', 'scheduler'); -// } - // Time range is negative $starttime = $data['starthour']*60+$data['startminute']; $endtime = $data['endhour']*60+$data['endminute']; @@ -605,11 +573,6 @@ public function validation($data, $files) { $errors['endtime'] = get_string('negativerange', 'scheduler'); } - //TODO: need one more field to pass this: First slot is in the past -// if ($data['rangestart'] < time() - DAYSECS) { -// $errors['rangestart'] = get_string('startpast', 'scheduler'); -// } - // Break must be nonnegative if ($data['break'] < 0) { $errors['breakgroup'] = get_string('breaknotnegative', 'scheduler'); diff --git a/teacherview.controller.php b/teacherview.controller.php index ad0f32a5..a63bcf79 100644 --- a/teacherview.controller.php +++ b/teacherview.controller.php @@ -107,6 +107,100 @@ function scheduler_action_doaddsession($scheduler, $formdata) { echo $output->action_message(get_string('slotsadded', 'scheduler', $countslots)); } +/************************************ Saving a aperiod session with slots ********************************/ +function scheduler_action_doaddaperiodsession($scheduler, $formdata) { + + global $DB, $output; + + $data = (object) $formdata; + +// $fordays = (($data->rangeend - $data->rangestart) / DAYSECS); + + // Create as many slots of $duration on the given dates list $listdates and that do not conflict. + $countslots = 0; + $couldnotcreateslots = ''; +// $startfrom = $data->rangestart+($data->starthour*60+$data->startminute)*60; +// $endat = $data->rangestart+($data->endhour*60+$data->endminute)*60; + $slot = new stdClass(); + $slot->schedulerid = $scheduler->id; + $slot->teacherid = $data->teacherid; + $slot->appointmentlocation = $data->appointmentlocation; + $slot->reuse = $data->reuse; + $slot->exclusivity = $data->exclusivity; + $slot->duration = $data->duration; + $slot->notes = ''; + $slot->notesformat = FORMAT_HTML; + $slot->timemodified = time(); + +/// $listdatesarr = json_decode($data->listdates, true); + $listdatesarr = json_decode($data->getlistdates, true); + + for ($d = 0; $d <= count($listdatesarr[0])-1; $d ++){ + $year = date("Y", strtotime($listdatesarr[0][$d])); + $month = date("m", strtotime($listdatesarr[0][$d])); + $day = date("d", strtotime($listdatesarr[0][$d])); + $slot->starttime = make_timestamp($year, $month, $day, $data->starthour, $data->startminute); + $eventdate = usergetdate($slot->starttime); + $data->timestart = $slot->starttime; + $data->timeend = make_timestamp(date('Y',$data->timestart), date('m',$data->timestart), date('d',$data->timestart), $data->endhour, $data->endminute); + + // this corrects around midnight bug + if ($data->timestart > $data->timeend){ + $data->timeend += DAYSECS; + } + if ($data->hideuntilrel == 0) { + $slot->hideuntil = time(); + } else { + $slot->hideuntil = make_timestamp($eventdate['year'], $eventdate['mon'], $eventdate['mday'], 6, 0) - $data->hideuntilrel; + } + if ($data->emaildaterel == -1) { + $slot->emaildate = 0; + } else { + $slot->emaildate = make_timestamp($eventdate['year'], $eventdate['mon'], $eventdate['mday'], 0, 0) - $data->emaildaterel; + } + + while ($slot->starttime <= $data->timeend - $data->duration * 60) { + //TDMU exclusivity check-out + //if ($scheduler->allowmulticourseappointment) { + if ($data->ignoreconflicts) { + $exclusive_condition = true; + } + else { + $exclusive_condition = false; + } + $conflictsRemote = scheduler_get_conflicts($scheduler->id, $data->timestart, $data->timestart + $data->duration * 60, $data->teacherid, 0, SCHEDULER_OTHERS, $exclusive_condition); + $conflictsLocal = scheduler_get_conflicts($scheduler->id, $data->timestart, $data->timestart + $data->duration * 60, $data->teacherid, 0, SCHEDULER_SELF, false); + if (!$conflictsRemote) $conflictsRemote = array(); + if (!$conflictsLocal) $conflictsLocal = array(); + $conflicts = $conflictsRemote + $conflictsLocal; + if ($conflicts) { + if (!$data->forcewhenoverlap){ + print_string('conflictingslots', 'scheduler'); + echo '
    '; + foreach ($conflicts as $aconflict){ + $conflictinfo = scheduler_get_courseinfobyslotid($aconflict->id);//TDMU + $msg = userdate($conflictinfo->starttime) . ' ' . usertime($conflictinfo->starttime) . ' ' . get_string('incourse', 'scheduler') . ': '; + $msg .= $conflictinfo->shortname . ' - ' . $conflictinfo->fullname; + echo html_writer::tag('li', $msg); + } + echo '

'; + } + else { // we force, so delete all conflicting before inserting + foreach($conflicts as $conflict){ + scheduler_delete_slot($conflict->id); + } + } + } + else { + $DB->insert_record('scheduler_slots', $slot, false, true); + $countslots++; + } + $slot->starttime += ($data->duration + $data->break) * 60; + $data->timestart += ($data->duration + $data->break) * 60; + } + } + echo $output->heading(get_string('slotsadded', 'scheduler', $countslots)); +} // Require valid session key for all actions. require_sesskey(); From d63299c198979b441b61791dd166c51752ab7648 Mon Sep 17 00:00:00 2001 From: semteacher Date: Sun, 23 Nov 2014 18:48:01 +0200 Subject: [PATCH 06/16] refactoring function added clean-up --- lang/en/scheduler.php | 2 ++ locallib.php | 29 +++++++++++++++++++++++++++++ teacherview.controller.php | 14 ++++++++------ 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/lang/en/scheduler.php b/lang/en/scheduler.php index 4b782fe9..9a27b1d6 100644 --- a/lang/en/scheduler.php +++ b/lang/en/scheduler.php @@ -39,6 +39,8 @@ $string['addcommands'] = 'Add slots'; $string['addondays'] = 'Add appointments on'; $string['addscheduled'] = 'Add scheduled student'; +$string['addaperiodsession'] = 'Add multiple slots free';//@TDMU +$string['addsession'] = 'Add repeated slots';//@TDMU-renamed $string['addsession'] = 'Add repeated slots'; $string['addsingleslot'] = 'Add single slot'; $string['addslot'] = 'You can add additional appointment slots at any time.'; diff --git a/locallib.php b/locallib.php index 608f3168..0ac77ee7 100644 --- a/locallib.php +++ b/locallib.php @@ -31,6 +31,35 @@ function scheduler_get_attendants($cmid){ return $attendants; } +/** +* Get a course info by the sheduler slot id +* @param int $slotid the any sheduler slot id +* @return a course shortname, fullname and selected slot starttime +*/ +function scheduler_get_courseinfobyslotid($slotid) { + global $CFG, $DB; + + $sql = " + SELECT + c.id, + c.fullname, + c.shortname, + s.name as schedname, + sl.starttime + FROM + {course} c, + {scheduler} s, + {scheduler_slots} sl + WHERE + s.course = c.id AND + sl.schedulerid = s.id AND + sl.id = {$slotid} + "; + $courseshortinfo = $DB->get_record_sql($sql); + + return $courseshortinfo; +} + /** * Returns an array of slots that would overlap with this one. * @param int $schedulerid the current activity module id diff --git a/teacherview.controller.php b/teacherview.controller.php index a63bcf79..5d46c9cf 100644 --- a/teacherview.controller.php +++ b/teacherview.controller.php @@ -78,10 +78,11 @@ function scheduler_action_doaddsession($scheduler, $formdata) { print_string('conflictingslots', 'scheduler'); echo '
    '; foreach ($conflicts as $aconflict) { - $sql = 'SELECT c.fullname, c.shortname, s.name as schedname, sl.starttime ' - .'FROM {course} c, {scheduler} s, {scheduler_slots} sl ' - .'WHERE s.course = c.id AND sl.schedulerid = s.id AND sl.id = :conflictid'; - $conflictinfo = $DB->get_record_sql($sql, array('conflictid' => $aconflict->id)); + //$sql = 'SELECT c.fullname, c.shortname, s.name as schedname, sl.starttime ' + // .'FROM {course} c, {scheduler} s, {scheduler_slots} sl ' + // .'WHERE s.course = c.id AND sl.schedulerid = s.id AND sl.id = :conflictid'; + //$conflictinfo = $DB->get_record_sql($sql, array('conflictid' => $aconflict->id)); + $conflictinfo = scheduler_get_courseinfobyslotid($aconflict->id);//TDMU $msg = $output->userdate($conflictinfo->starttime) . ', ' . $output->usertime($conflictinfo->starttime) . ': '; $msg .= s($conflictinfo->schedname). ' '.get_string('incourse', 'scheduler') . ' '; $msg .= $conflictinfo->shortname . ' - ' . $conflictinfo->fullname; @@ -179,7 +180,8 @@ function scheduler_action_doaddaperiodsession($scheduler, $formdata) { echo '
      '; foreach ($conflicts as $aconflict){ $conflictinfo = scheduler_get_courseinfobyslotid($aconflict->id);//TDMU - $msg = userdate($conflictinfo->starttime) . ' ' . usertime($conflictinfo->starttime) . ' ' . get_string('incourse', 'scheduler') . ': '; + $msg = $output->userdate($conflictinfo->starttime) . ', ' . $output->usertime($conflictinfo->starttime) . ': '; + $msg .= s($conflictinfo->schedname). ' '.get_string('incourse', 'scheduler') . ' '; $msg .= $conflictinfo->shortname . ' - ' . $conflictinfo->fullname; echo html_writer::tag('li', $msg); } @@ -199,7 +201,7 @@ function scheduler_action_doaddaperiodsession($scheduler, $formdata) { $data->timestart += ($data->duration + $data->break) * 60; } } - echo $output->heading(get_string('slotsadded', 'scheduler', $countslots)); + echo $output->action_message(get_string('slotsadded', 'scheduler', $countslots)); } // Require valid session key for all actions. From de1147a4a179ce7b3ca2305b2179db9da56dfe1a Mon Sep 17 00:00:00 2001 From: semteacher Date: Sun, 23 Nov 2014 22:32:11 +0200 Subject: [PATCH 07/16] fix "calendar pane" script for the "add aperiodic slots" function --- styles.css | 4 +++ .../moodle-mod_scheduler-calpane-coverage.js | 6 +++++ .../moodle-mod_scheduler-calpane-debug.js | 26 +++++++++++-------- .../moodle-mod_scheduler-calpane-min.js | 2 +- .../moodle-mod_scheduler-calpane.js | 26 +++++++++++-------- yui/src/calpane/js/calpane.js | 24 ++++++++++------- yui/src/calpane/meta/calpane.json | 1 + 7 files changed, 56 insertions(+), 33 deletions(-) create mode 100644 yui/build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane-coverage.js diff --git a/styles.css b/styles.css index 86375c51..706f4edb 100644 --- a/styles.css +++ b/styles.css @@ -142,3 +142,7 @@ body.path-mod-scheduler.jsenabled input.studentselectsubmit { background-color: ##FFB2B8; border-color: #F40000; } + +.yui3-skin-sam .redtext { + color:#ff0000; +} diff --git a/yui/build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane-coverage.js b/yui/build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane-coverage.js new file mode 100644 index 00000000..d6757a13 --- /dev/null +++ b/yui/build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane-coverage.js @@ -0,0 +1,6 @@ +if (typeof __coverage__ === 'undefined') { __coverage__ = {}; } +if (!__coverage__['build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane.js']) { + __coverage__['build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane.js'] = {"path":"build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane.js","s":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0},"b":{"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0]},"f":{"1":0,"2":0,"3":0,"4":0,"5":0},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":40},"end":{"line":1,"column":59}}},"2":{"name":"(anonymous_2)","line":8,"loc":{"start":{"line":8,"column":11},"end":{"line":8,"column":30}}},"3":{"name":"(anonymous_3)","line":55,"loc":{"start":{"line":55,"column":24},"end":{"line":55,"column":53}}},"4":{"name":"(anonymous_4)","line":63,"loc":{"start":{"line":63,"column":33},"end":{"line":63,"column":52}}},"5":{"name":"(anonymous_5)","line":75,"loc":{"start":{"line":75,"column":33},"end":{"line":75,"column":47}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":88,"column":109}},"2":{"start":{"line":3,"column":0},"end":{"line":3,"column":8}},"3":{"start":{"line":5,"column":0},"end":{"line":5,"column":40}},"4":{"start":{"line":6,"column":0},"end":{"line":6,"column":35}},"5":{"start":{"line":8,"column":0},"end":{"line":86,"column":4}},"6":{"start":{"line":9,"column":4},"end":{"line":13,"column":7}},"7":{"start":{"line":14,"column":4},"end":{"line":18,"column":7}},"8":{"start":{"line":19,"column":4},"end":{"line":19,"column":73}},"9":{"start":{"line":21,"column":4},"end":{"line":28,"column":27}},"10":{"start":{"line":30,"column":4},"end":{"line":38,"column":5}},"11":{"start":{"line":31,"column":8},"end":{"line":31,"column":88}},"12":{"start":{"line":32,"column":8},"end":{"line":32,"column":56}},"13":{"start":{"line":33,"column":11},"end":{"line":38,"column":5}},"14":{"start":{"line":34,"column":8},"end":{"line":34,"column":88}},"15":{"start":{"line":35,"column":8},"end":{"line":35,"column":56}},"16":{"start":{"line":37,"column":8},"end":{"line":37,"column":56}},"17":{"start":{"line":40,"column":4},"end":{"line":40,"column":20}},"18":{"start":{"line":43,"column":4},"end":{"line":51,"column":6}},"19":{"start":{"line":53,"column":4},"end":{"line":60,"column":7}},"20":{"start":{"line":56,"column":12},"end":{"line":58,"column":13}},"21":{"start":{"line":57,"column":16},"end":{"line":57,"column":41}},"22":{"start":{"line":63,"column":4},"end":{"line":73,"column":7}},"23":{"start":{"line":64,"column":8},"end":{"line":71,"column":15}},"24":{"start":{"line":72,"column":8},"end":{"line":72,"column":22}},"25":{"start":{"line":75,"column":4},"end":{"line":85,"column":7}},"26":{"start":{"line":76,"column":8},"end":{"line":76,"column":37}},"27":{"start":{"line":77,"column":8},"end":{"line":77,"column":29}},"28":{"start":{"line":79,"column":8},"end":{"line":81,"column":3}},"29":{"start":{"line":80,"column":12},"end":{"line":80,"column":101}},"30":{"start":{"line":82,"column":8},"end":{"line":82,"column":26}},"31":{"start":{"line":84,"column":8},"end":{"line":84,"column":85}}},"branchMap":{"1":{"line":5,"type":"binary-expr","locations":[{"start":{"line":5,"column":18},"end":{"line":5,"column":33}},{"start":{"line":5,"column":37},"end":{"line":5,"column":39}}]},"2":{"line":30,"type":"if","locations":[{"start":{"line":30,"column":4},"end":{"line":30,"column":4}},{"start":{"line":30,"column":4},"end":{"line":30,"column":4}}]},"3":{"line":33,"type":"if","locations":[{"start":{"line":33,"column":11},"end":{"line":33,"column":11}},{"start":{"line":33,"column":11},"end":{"line":33,"column":11}}]},"4":{"line":56,"type":"if","locations":[{"start":{"line":56,"column":12},"end":{"line":56,"column":12}},{"start":{"line":56,"column":12},"end":{"line":56,"column":12}}]},"5":{"line":80,"type":"cond-expr","locations":[{"start":{"line":80,"column":36},"end":{"line":80,"column":38}},{"start":{"line":80,"column":41},"end":{"line":80,"column":44}}]}},"code":["(function () { YUI.add('moodle-mod_scheduler-calpane', function (Y, NAME) {","","var MOD;\r","\r","M.mod_scheduler = M.mod_scheduler || {};\r","MOD = M.mod_scheduler.calpane = {};\r","\r","MOD.init = function(langconf) {\r"," Y.Intl.add(\"datatype-date-format\", \"uk-UK\", {\r"," \"a\":[\"Нд\",\"Пн\",\"Вт\",\"Ср\",\"Чт\",\"Пт\",\"Сб\"],\r"," \"A\":[\"Неділя\",\"Понеділок\",\"Вівторк\",\"Середа\",\"Четвер\",\"П'ятниця\",\"Субота\"],\r"," \"B\":[\"Січень\",\"Лютий\",\"Березень\",\"Квітень\",\"Травень\",\"Червень\",\"Липень\",\"Серпень\",\"Вересень\",\"Жовтень\",\"Листопад\",\"Грудень\"]\r"," });\r"," Y.Intl.add(\"datatype-date-format\", \"ru-RU\", {\r"," \"a\":[\"Вс\",\"Пн\",\"Вт\",\"Ср\",\"Чт\",\"Пт\",\"Сб\"],\r"," \"A\":[\"Воскресенье\",\"Понедельник\",\"Вторник\",\"Среда\",\"Четверг\",\"Пятница\",\"Суббота\"],\r"," \"B\":[\"Январь\",\"Февраль\",\"Март\",\"Апрель\",\"Май\",\"Июнь\",\"Июль\",\"Август\",\"Сентябрь\",\"Октябрь\",\"Ноябрь\",\"Декабрь\"]\r"," });\r"," Y.CalendarBase.CONTENT_TEMPLATE = Y.CalendarBase.THREE_PANE_TEMPLATE;\r"," // Setup basic calendar parameters\r"," var calend = new Y.Calendar({\r"," contentBox: \"#calContainer\",\r"," width:'750px',\r"," showPrevMonth: true,\r"," showNextMonth: true,\r"," selectionMode: 'multiple-sticky',\r"," minimumDate: new Date(),\r"," date: new Date()});\r"," //Localization\r"," if (langconf === \"uk\") {\r"," calend.set(\"strings.very_short_weekdays\", [\"Нд\",\"Пн\",\"Вт\",\"Ср\",\"Чт\",\"Пт\",\"Сб\"]);\r"," Y.Intl.setLang(\"datatype-date-format\", \"uk-UK\");\r"," } else if (langconf === \"ru\") {\r"," calend.set(\"strings.very_short_weekdays\", [\"Вс\",\"Пн\",\"Вт\",\"Ср\",\"Чт\",\"Пт\",\"Сб\"]);\r"," Y.Intl.setLang(\"datatype-date-format\", \"ru-RU\");\r"," } else {\r"," Y.Intl.setLang(\"datatype-date-format\", \"en-US\");\r"," }\r"," // Draw calendar instance\r"," calend.render();\r"," // Create a set of rules to match specific dates. In this case,\r"," // the \"all_weekends\" rule will match any Saturday or Sunday.\r"," var rules = {\r"," \"all\": {\r"," \"all\": {\r"," \"all\": {\r"," \"0,6\": \"all_weekends\"\r"," }\r"," }\r"," }\r"," };\r"," // Set the calendar customRenderer, provides the rules defined above.\r"," calend.set(\"customRenderer\", {\r"," rules: rules,\r"," filterFunction: function (date, node, rules) {\r"," if (Y.Array.indexOf(rules, 'all_weekends') >= 0) {\r"," node.addClass(\"redtext\");\r"," }\r"," }\r"," });\r"," // Set a custom header renderer with a callback function,\r"," // which receives the current date and outputs a string.\r"," calend.set(\"headerRenderer\", function (curDate) {\r"," var ydate = Y.DataType.Date,\r"," output = ydate.format(curDate, {\r"," format: \"%B %Y\"\r"," }) + \" — \" + ydate.format(ydate.addMonths(curDate, 1), {\r"," format: \"%B %Y\"\r"," })+ \" — \" + ydate.format(ydate.addMonths(curDate, 2), {\r"," format: \"%B %Y\"\r"," });\r"," return output;\r"," });\r"," // Listen to calendar's selectionChange event.\r"," calend.on(\"selectionChange\", function (ev) {\r"," var dtdate = Y.DataType.Date;\r"," var listdates = '[{';\r"," // Collect dates from selection\r"," for (var i = 0; i < ev.newSelection.length; i++) {\r"," listdates += (i === 0 ? \"\" : \",\") + '\"'+ i +'\":\"'+ dtdate.format(ev.newSelection[i])+'\"';\r","\t\t}\r"," listdates += \"}]\";\r"," //set dates to HTML control\r"," Y.one(document.getElementsByName('getlistdates')[0]).set('value', listdates);\r"," });\r"," };","","}, '@VERSION@', {\"requires\": [\"base\", \"calendar\", \"datatype-date\", \"datatype-date-format\", \"node\", \"intl\"]});","","}());"]}; +} +var __cov_VfNixH5rFGHdVHAfsTIltg = __coverage__['build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane.js']; +__cov_VfNixH5rFGHdVHAfsTIltg.s['1']++;YUI.add('moodle-mod_scheduler-calpane',function(Y,NAME){__cov_VfNixH5rFGHdVHAfsTIltg.f['1']++;__cov_VfNixH5rFGHdVHAfsTIltg.s['2']++;var MOD;__cov_VfNixH5rFGHdVHAfsTIltg.s['3']++;M.mod_scheduler=(__cov_VfNixH5rFGHdVHAfsTIltg.b['1'][0]++,M.mod_scheduler)||(__cov_VfNixH5rFGHdVHAfsTIltg.b['1'][1]++,{});__cov_VfNixH5rFGHdVHAfsTIltg.s['4']++;MOD=M.mod_scheduler.calpane={};__cov_VfNixH5rFGHdVHAfsTIltg.s['5']++;MOD.init=function(langconf){__cov_VfNixH5rFGHdVHAfsTIltg.f['2']++;__cov_VfNixH5rFGHdVHAfsTIltg.s['6']++;Y.Intl.add('datatype-date-format','uk-UK',{'a':['\u041d\u0434','\u041f\u043d','\u0412\u0442','\u0421\u0440','\u0427\u0442','\u041f\u0442','\u0421\u0431'],'A':['\u041d\u0435\u0434\u0456\u043b\u044f','\u041f\u043e\u043d\u0435\u0434\u0456\u043b\u043e\u043a','\u0412\u0456\u0432\u0442\u043e\u0440\u043a','\u0421\u0435\u0440\u0435\u0434\u0430','\u0427\u0435\u0442\u0432\u0435\u0440','\u041f\'\u044f\u0442\u043d\u0438\u0446\u044f','\u0421\u0443\u0431\u043e\u0442\u0430'],'B':['\u0421\u0456\u0447\u0435\u043d\u044c','\u041b\u044e\u0442\u0438\u0439','\u0411\u0435\u0440\u0435\u0437\u0435\u043d\u044c','\u041a\u0432\u0456\u0442\u0435\u043d\u044c','\u0422\u0440\u0430\u0432\u0435\u043d\u044c','\u0427\u0435\u0440\u0432\u0435\u043d\u044c','\u041b\u0438\u043f\u0435\u043d\u044c','\u0421\u0435\u0440\u043f\u0435\u043d\u044c','\u0412\u0435\u0440\u0435\u0441\u0435\u043d\u044c','\u0416\u043e\u0432\u0442\u0435\u043d\u044c','\u041b\u0438\u0441\u0442\u043e\u043f\u0430\u0434','\u0413\u0440\u0443\u0434\u0435\u043d\u044c']});__cov_VfNixH5rFGHdVHAfsTIltg.s['7']++;Y.Intl.add('datatype-date-format','ru-RU',{'a':['\u0412\u0441','\u041f\u043d','\u0412\u0442','\u0421\u0440','\u0427\u0442','\u041f\u0442','\u0421\u0431'],'A':['\u0412\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435','\u041f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a','\u0412\u0442\u043e\u0440\u043d\u0438\u043a','\u0421\u0440\u0435\u0434\u0430','\u0427\u0435\u0442\u0432\u0435\u0440\u0433','\u041f\u044f\u0442\u043d\u0438\u0446\u0430','\u0421\u0443\u0431\u0431\u043e\u0442\u0430'],'B':['\u042f\u043d\u0432\u0430\u0440\u044c','\u0424\u0435\u0432\u0440\u0430\u043b\u044c','\u041c\u0430\u0440\u0442','\u0410\u043f\u0440\u0435\u043b\u044c','\u041c\u0430\u0439','\u0418\u044e\u043d\u044c','\u0418\u044e\u043b\u044c','\u0410\u0432\u0433\u0443\u0441\u0442','\u0421\u0435\u043d\u0442\u044f\u0431\u0440\u044c','\u041e\u043a\u0442\u044f\u0431\u0440\u044c','\u041d\u043e\u044f\u0431\u0440\u044c','\u0414\u0435\u043a\u0430\u0431\u0440\u044c']});__cov_VfNixH5rFGHdVHAfsTIltg.s['8']++;Y.CalendarBase.CONTENT_TEMPLATE=Y.CalendarBase.THREE_PANE_TEMPLATE;__cov_VfNixH5rFGHdVHAfsTIltg.s['9']++;var calend=new Y.Calendar({contentBox:'#calContainer',width:'750px',showPrevMonth:true,showNextMonth:true,selectionMode:'multiple-sticky',minimumDate:new Date(),date:new Date()});__cov_VfNixH5rFGHdVHAfsTIltg.s['10']++;if(langconf==='uk'){__cov_VfNixH5rFGHdVHAfsTIltg.b['2'][0]++;__cov_VfNixH5rFGHdVHAfsTIltg.s['11']++;calend.set('strings.very_short_weekdays',['\u041d\u0434','\u041f\u043d','\u0412\u0442','\u0421\u0440','\u0427\u0442','\u041f\u0442','\u0421\u0431']);__cov_VfNixH5rFGHdVHAfsTIltg.s['12']++;Y.Intl.setLang('datatype-date-format','uk-UK');}else{__cov_VfNixH5rFGHdVHAfsTIltg.b['2'][1]++;__cov_VfNixH5rFGHdVHAfsTIltg.s['13']++;if(langconf==='ru'){__cov_VfNixH5rFGHdVHAfsTIltg.b['3'][0]++;__cov_VfNixH5rFGHdVHAfsTIltg.s['14']++;calend.set('strings.very_short_weekdays',['\u0412\u0441','\u041f\u043d','\u0412\u0442','\u0421\u0440','\u0427\u0442','\u041f\u0442','\u0421\u0431']);__cov_VfNixH5rFGHdVHAfsTIltg.s['15']++;Y.Intl.setLang('datatype-date-format','ru-RU');}else{__cov_VfNixH5rFGHdVHAfsTIltg.b['3'][1]++;__cov_VfNixH5rFGHdVHAfsTIltg.s['16']++;Y.Intl.setLang('datatype-date-format','en-US');}}__cov_VfNixH5rFGHdVHAfsTIltg.s['17']++;calend.render();__cov_VfNixH5rFGHdVHAfsTIltg.s['18']++;var rules={'all':{'all':{'all':{'0,6':'all_weekends'}}}};__cov_VfNixH5rFGHdVHAfsTIltg.s['19']++;calend.set('customRenderer',{rules:rules,filterFunction:function(date,node,rules){__cov_VfNixH5rFGHdVHAfsTIltg.f['3']++;__cov_VfNixH5rFGHdVHAfsTIltg.s['20']++;if(Y.Array.indexOf(rules,'all_weekends')>=0){__cov_VfNixH5rFGHdVHAfsTIltg.b['4'][0]++;__cov_VfNixH5rFGHdVHAfsTIltg.s['21']++;node.addClass('redtext');}else{__cov_VfNixH5rFGHdVHAfsTIltg.b['4'][1]++;}}});__cov_VfNixH5rFGHdVHAfsTIltg.s['22']++;calend.set('headerRenderer',function(curDate){__cov_VfNixH5rFGHdVHAfsTIltg.f['4']++;__cov_VfNixH5rFGHdVHAfsTIltg.s['23']++;var ydate=Y.DataType.Date,output=ydate.format(curDate,{format:'%B %Y'})+' — '+ydate.format(ydate.addMonths(curDate,1),{format:'%B %Y'})+' — '+ydate.format(ydate.addMonths(curDate,2),{format:'%B %Y'});__cov_VfNixH5rFGHdVHAfsTIltg.s['24']++;return output;});__cov_VfNixH5rFGHdVHAfsTIltg.s['25']++;calend.on('selectionChange',function(ev){__cov_VfNixH5rFGHdVHAfsTIltg.f['5']++;__cov_VfNixH5rFGHdVHAfsTIltg.s['26']++;var dtdate=Y.DataType.Date;__cov_VfNixH5rFGHdVHAfsTIltg.s['27']++;var listdates='[{';__cov_VfNixH5rFGHdVHAfsTIltg.s['28']++;for(var i=0;i=0&&n.addClass("redtext")}}),n.set("headerRenderer",function(t){var n=e.DataType.Date,r=n.format(t,{format:"%B %Y"})+" — "+n.format(n.addMonths(t,1),{format:"%B %Y"})+" — "+n.format(n.addMonths(t,2),{format:"%B %Y"});return r}),n.on("selectionChange",function(t){var n=e.DataType.Date,r="[{";for(var i=0;i=0&&n.addClass("redtext")}}),n.set("headerRenderer",function(t){var n=e.DataType.Date,r=n.format(t,{format:"%B %Y"})+" — "+n.format(n.addMonths(t,1),{format:"%B %Y"})+" — "+n.format(n.addMonths(t,2),{format:"%B %Y"});return r}),n.on("selectionChange",function(t){var n=e.DataType.Date,r="[{";for(var i=0;i Date: Mon, 24 Nov 2014 13:10:28 +0200 Subject: [PATCH 08/16] refactoring add "ignore conflicts" option into the add aperiodic session form now it pass only unlimited slots --- teacherview.controller.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/teacherview.controller.php b/teacherview.controller.php index 5d46c9cf..d3fb8703 100644 --- a/teacherview.controller.php +++ b/teacherview.controller.php @@ -162,8 +162,7 @@ function scheduler_action_doaddaperiodsession($scheduler, $formdata) { while ($slot->starttime <= $data->timeend - $data->duration * 60) { //TDMU exclusivity check-out - //if ($scheduler->allowmulticourseappointment) { - if ($data->ignoreconflicts) { + if (isset($data->ignoreconflicts)) { $exclusive_condition = true; } else { @@ -189,7 +188,8 @@ function scheduler_action_doaddaperiodsession($scheduler, $formdata) { } else { // we force, so delete all conflicting before inserting foreach($conflicts as $conflict){ - scheduler_delete_slot($conflict->id); + $cslot = $scheduler->get_slot($conflict->id); + $cslot->delete(); } } } From 2eecf011da2b5d0e08c90ebdf86766d649a6092f Mon Sep 17 00:00:00 2001 From: semteacher Date: Mon, 24 Nov 2014 17:18:20 +0200 Subject: [PATCH 09/16] clean-up --- slotforms.php | 49 -------------------------------------- teacherview.controller.php | 9 ------- teacherview.php | 7 ++---- 3 files changed, 2 insertions(+), 63 deletions(-) diff --git a/slotforms.php b/slotforms.php index ce77bd72..a29665a9 100644 --- a/slotforms.php +++ b/slotforms.php @@ -580,55 +580,6 @@ public function validation($data, $files) { // TODO conflict checks - /* - - /// make a base slot for generating - $slot = new stdClass(); - $slot->appointmentlocation = $data->appointmentlocation; - $slot->exclusivity = $data->exclusivity; - $slot->reuse = $data->reuse; - $slot->duration = $data->duration; - $slot->schedulerid = $scheduler->id; - $slot->timemodified = time(); - $slot->teacherid = $data->teacherid; - - /// check if overlaps. Check also if some slots are in allowed day range - $startfrom = $data->rangestart; - $noslotsallowed = true; - for ($d = 0; $d <= $fordays; $d ++){ - $starttime = $startfrom + ($d * DAYSECS); - $eventdate = usergetdate($starttime); - $dayofweek = $eventdate['wday']; - if ((($dayofweek == 1) && ($data->monday == 1)) || - (($dayofweek == 2) && ($data->tuesday == 1)) || - (($dayofweek == 3) && ($data->wednesday == 1)) || - (($dayofweek == 4) && ($data->thursday == 1)) || - (($dayofweek == 5) && ($data->friday == 1)) || - (($dayofweek == 6) && ($data->saturday == 1)) || - (($dayofweek == 0) && ($data->sunday == 1))){ - $noslotsallowed = false; - $data->starttime = make_timestamp($eventdate['year'], $eventdate['mon'], $eventdate['mday'], $data->starthour, $data->startminute); - $conflicts = scheduler_get_conflicts($scheduler->id, $data->starttime, $data->starttime + $data->duration * 60, $data->teacherid, 0, SCHEDULER_ALL, false); - if (!$data->forcewhenoverlap){ - if ($conflicts){ - unset($erroritem); - $erroritem->message = get_string('overlappings', 'scheduler'); - $erroritem->on = 'range'; - $errors[] = $erroritem; - } - } - } - } - - /// Finally check if some slots are allowed (an error is thrown to ask care to this situation) - if ($noslotsallowed){ - unset($erroritem); - $erroritem->message = get_string('allslotsincloseddays', 'scheduler'); - $erroritem->on = 'days'; - $errors[] = $erroritem; - } - */ - return $errors; } } diff --git a/teacherview.controller.php b/teacherview.controller.php index d3fb8703..3347a000 100644 --- a/teacherview.controller.php +++ b/teacherview.controller.php @@ -78,10 +78,6 @@ function scheduler_action_doaddsession($scheduler, $formdata) { print_string('conflictingslots', 'scheduler'); echo '
        '; foreach ($conflicts as $aconflict) { - //$sql = 'SELECT c.fullname, c.shortname, s.name as schedname, sl.starttime ' - // .'FROM {course} c, {scheduler} s, {scheduler_slots} sl ' - // .'WHERE s.course = c.id AND sl.schedulerid = s.id AND sl.id = :conflictid'; - //$conflictinfo = $DB->get_record_sql($sql, array('conflictid' => $aconflict->id)); $conflictinfo = scheduler_get_courseinfobyslotid($aconflict->id);//TDMU $msg = $output->userdate($conflictinfo->starttime) . ', ' . $output->usertime($conflictinfo->starttime) . ': '; $msg .= s($conflictinfo->schedname). ' '.get_string('incourse', 'scheduler') . ' '; @@ -115,13 +111,9 @@ function scheduler_action_doaddaperiodsession($scheduler, $formdata) { $data = (object) $formdata; -// $fordays = (($data->rangeend - $data->rangestart) / DAYSECS); - // Create as many slots of $duration on the given dates list $listdates and that do not conflict. $countslots = 0; $couldnotcreateslots = ''; -// $startfrom = $data->rangestart+($data->starthour*60+$data->startminute)*60; -// $endat = $data->rangestart+($data->endhour*60+$data->endminute)*60; $slot = new stdClass(); $slot->schedulerid = $scheduler->id; $slot->teacherid = $data->teacherid; @@ -133,7 +125,6 @@ function scheduler_action_doaddaperiodsession($scheduler, $formdata) { $slot->notesformat = FORMAT_HTML; $slot->timemodified = time(); -/// $listdatesarr = json_decode($data->listdates, true); $listdatesarr = json_decode($data->getlistdates, true); for ($d = 0; $d <= count($listdatesarr[0])-1; $d ++){ diff --git a/teacherview.php b/teacherview.php index 239c0ee6..b793a931 100644 --- a/teacherview.php +++ b/teacherview.php @@ -225,11 +225,8 @@ function scheduler_print_schedulebox(scheduler_instance $scheduler, $studentid, /************************************ Add session multiple slots (aperiodically) form ************************************/ if ($action == 'addaperiodsession') { - //TODO: remove? it was the jquery localization option - $courselang = substr($COURSE->lang, 0, 2); -// if ($courselang == 'en'){ -// $courselang = ''; -// } + //need to localization option + $courselang = substr($COURSE->lang, 0, 2); $actionurl = new moodle_url('/mod/scheduler/view.php', array('what' => 'addaperiodsession', 'id' => $cm->id, 'subpage' => $subpage)); From 6419638a1a56a93ae401a3a09048bcf95dc51304 Mon Sep 17 00:00:00 2001 From: semteacher Date: Mon, 24 Nov 2014 18:05:24 +0200 Subject: [PATCH 10/16] use same conflictsLocal setting as in "add single slot" --- teacherview.controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/teacherview.controller.php b/teacherview.controller.php index 3347a000..1c62b01f 100644 --- a/teacherview.controller.php +++ b/teacherview.controller.php @@ -160,7 +160,7 @@ function scheduler_action_doaddaperiodsession($scheduler, $formdata) { $exclusive_condition = false; } $conflictsRemote = scheduler_get_conflicts($scheduler->id, $data->timestart, $data->timestart + $data->duration * 60, $data->teacherid, 0, SCHEDULER_OTHERS, $exclusive_condition); - $conflictsLocal = scheduler_get_conflicts($scheduler->id, $data->timestart, $data->timestart + $data->duration * 60, $data->teacherid, 0, SCHEDULER_SELF, false); + $conflictsLocal = scheduler_get_conflicts($scheduler->id, $data->timestart, $data->timestart + $data->duration * 60, $data->teacherid, 0, SCHEDULER_SELF, true); if (!$conflictsRemote) $conflictsRemote = array(); if (!$conflictsLocal) $conflictsLocal = array(); $conflicts = $conflictsRemote + $conflictsLocal; From 343430e47016b4c237f2941d031e683fcb581244 Mon Sep 17 00:00:00 2001 From: semteacher Date: Mon, 24 Nov 2014 20:02:03 +0200 Subject: [PATCH 11/16] clean-up script improve localization --- .../moodle-mod_scheduler-calpane-coverage.js | 4 ++-- .../moodle-mod_scheduler-calpane-debug.js | 19 ++++++++----------- .../moodle-mod_scheduler-calpane-min.js | 2 +- .../moodle-mod_scheduler-calpane.js | 19 ++++++++----------- yui/src/calpane/js/calpane.js | 19 ++++++++----------- 5 files changed, 27 insertions(+), 36 deletions(-) diff --git a/yui/build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane-coverage.js b/yui/build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane-coverage.js index d6757a13..46a4b130 100644 --- a/yui/build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane-coverage.js +++ b/yui/build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane-coverage.js @@ -1,6 +1,6 @@ if (typeof __coverage__ === 'undefined') { __coverage__ = {}; } if (!__coverage__['build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane.js']) { - __coverage__['build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane.js'] = {"path":"build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane.js","s":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0},"b":{"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0]},"f":{"1":0,"2":0,"3":0,"4":0,"5":0},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":40},"end":{"line":1,"column":59}}},"2":{"name":"(anonymous_2)","line":8,"loc":{"start":{"line":8,"column":11},"end":{"line":8,"column":30}}},"3":{"name":"(anonymous_3)","line":55,"loc":{"start":{"line":55,"column":24},"end":{"line":55,"column":53}}},"4":{"name":"(anonymous_4)","line":63,"loc":{"start":{"line":63,"column":33},"end":{"line":63,"column":52}}},"5":{"name":"(anonymous_5)","line":75,"loc":{"start":{"line":75,"column":33},"end":{"line":75,"column":47}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":88,"column":109}},"2":{"start":{"line":3,"column":0},"end":{"line":3,"column":8}},"3":{"start":{"line":5,"column":0},"end":{"line":5,"column":40}},"4":{"start":{"line":6,"column":0},"end":{"line":6,"column":35}},"5":{"start":{"line":8,"column":0},"end":{"line":86,"column":4}},"6":{"start":{"line":9,"column":4},"end":{"line":13,"column":7}},"7":{"start":{"line":14,"column":4},"end":{"line":18,"column":7}},"8":{"start":{"line":19,"column":4},"end":{"line":19,"column":73}},"9":{"start":{"line":21,"column":4},"end":{"line":28,"column":27}},"10":{"start":{"line":30,"column":4},"end":{"line":38,"column":5}},"11":{"start":{"line":31,"column":8},"end":{"line":31,"column":88}},"12":{"start":{"line":32,"column":8},"end":{"line":32,"column":56}},"13":{"start":{"line":33,"column":11},"end":{"line":38,"column":5}},"14":{"start":{"line":34,"column":8},"end":{"line":34,"column":88}},"15":{"start":{"line":35,"column":8},"end":{"line":35,"column":56}},"16":{"start":{"line":37,"column":8},"end":{"line":37,"column":56}},"17":{"start":{"line":40,"column":4},"end":{"line":40,"column":20}},"18":{"start":{"line":43,"column":4},"end":{"line":51,"column":6}},"19":{"start":{"line":53,"column":4},"end":{"line":60,"column":7}},"20":{"start":{"line":56,"column":12},"end":{"line":58,"column":13}},"21":{"start":{"line":57,"column":16},"end":{"line":57,"column":41}},"22":{"start":{"line":63,"column":4},"end":{"line":73,"column":7}},"23":{"start":{"line":64,"column":8},"end":{"line":71,"column":15}},"24":{"start":{"line":72,"column":8},"end":{"line":72,"column":22}},"25":{"start":{"line":75,"column":4},"end":{"line":85,"column":7}},"26":{"start":{"line":76,"column":8},"end":{"line":76,"column":37}},"27":{"start":{"line":77,"column":8},"end":{"line":77,"column":29}},"28":{"start":{"line":79,"column":8},"end":{"line":81,"column":3}},"29":{"start":{"line":80,"column":12},"end":{"line":80,"column":101}},"30":{"start":{"line":82,"column":8},"end":{"line":82,"column":26}},"31":{"start":{"line":84,"column":8},"end":{"line":84,"column":85}}},"branchMap":{"1":{"line":5,"type":"binary-expr","locations":[{"start":{"line":5,"column":18},"end":{"line":5,"column":33}},{"start":{"line":5,"column":37},"end":{"line":5,"column":39}}]},"2":{"line":30,"type":"if","locations":[{"start":{"line":30,"column":4},"end":{"line":30,"column":4}},{"start":{"line":30,"column":4},"end":{"line":30,"column":4}}]},"3":{"line":33,"type":"if","locations":[{"start":{"line":33,"column":11},"end":{"line":33,"column":11}},{"start":{"line":33,"column":11},"end":{"line":33,"column":11}}]},"4":{"line":56,"type":"if","locations":[{"start":{"line":56,"column":12},"end":{"line":56,"column":12}},{"start":{"line":56,"column":12},"end":{"line":56,"column":12}}]},"5":{"line":80,"type":"cond-expr","locations":[{"start":{"line":80,"column":36},"end":{"line":80,"column":38}},{"start":{"line":80,"column":41},"end":{"line":80,"column":44}}]}},"code":["(function () { YUI.add('moodle-mod_scheduler-calpane', function (Y, NAME) {","","var MOD;\r","\r","M.mod_scheduler = M.mod_scheduler || {};\r","MOD = M.mod_scheduler.calpane = {};\r","\r","MOD.init = function(langconf) {\r"," Y.Intl.add(\"datatype-date-format\", \"uk-UK\", {\r"," \"a\":[\"Нд\",\"Пн\",\"Вт\",\"Ср\",\"Чт\",\"Пт\",\"Сб\"],\r"," \"A\":[\"Неділя\",\"Понеділок\",\"Вівторк\",\"Середа\",\"Четвер\",\"П'ятниця\",\"Субота\"],\r"," \"B\":[\"Січень\",\"Лютий\",\"Березень\",\"Квітень\",\"Травень\",\"Червень\",\"Липень\",\"Серпень\",\"Вересень\",\"Жовтень\",\"Листопад\",\"Грудень\"]\r"," });\r"," Y.Intl.add(\"datatype-date-format\", \"ru-RU\", {\r"," \"a\":[\"Вс\",\"Пн\",\"Вт\",\"Ср\",\"Чт\",\"Пт\",\"Сб\"],\r"," \"A\":[\"Воскресенье\",\"Понедельник\",\"Вторник\",\"Среда\",\"Четверг\",\"Пятница\",\"Суббота\"],\r"," \"B\":[\"Январь\",\"Февраль\",\"Март\",\"Апрель\",\"Май\",\"Июнь\",\"Июль\",\"Август\",\"Сентябрь\",\"Октябрь\",\"Ноябрь\",\"Декабрь\"]\r"," });\r"," Y.CalendarBase.CONTENT_TEMPLATE = Y.CalendarBase.THREE_PANE_TEMPLATE;\r"," // Setup basic calendar parameters\r"," var calend = new Y.Calendar({\r"," contentBox: \"#calContainer\",\r"," width:'750px',\r"," showPrevMonth: true,\r"," showNextMonth: true,\r"," selectionMode: 'multiple-sticky',\r"," minimumDate: new Date(),\r"," date: new Date()});\r"," //Localization\r"," if (langconf === \"uk\") {\r"," calend.set(\"strings.very_short_weekdays\", [\"Нд\",\"Пн\",\"Вт\",\"Ср\",\"Чт\",\"Пт\",\"Сб\"]);\r"," Y.Intl.setLang(\"datatype-date-format\", \"uk-UK\");\r"," } else if (langconf === \"ru\") {\r"," calend.set(\"strings.very_short_weekdays\", [\"Вс\",\"Пн\",\"Вт\",\"Ср\",\"Чт\",\"Пт\",\"Сб\"]);\r"," Y.Intl.setLang(\"datatype-date-format\", \"ru-RU\");\r"," } else {\r"," Y.Intl.setLang(\"datatype-date-format\", \"en-US\");\r"," }\r"," // Draw calendar instance\r"," calend.render();\r"," // Create a set of rules to match specific dates. In this case,\r"," // the \"all_weekends\" rule will match any Saturday or Sunday.\r"," var rules = {\r"," \"all\": {\r"," \"all\": {\r"," \"all\": {\r"," \"0,6\": \"all_weekends\"\r"," }\r"," }\r"," }\r"," };\r"," // Set the calendar customRenderer, provides the rules defined above.\r"," calend.set(\"customRenderer\", {\r"," rules: rules,\r"," filterFunction: function (date, node, rules) {\r"," if (Y.Array.indexOf(rules, 'all_weekends') >= 0) {\r"," node.addClass(\"redtext\");\r"," }\r"," }\r"," });\r"," // Set a custom header renderer with a callback function,\r"," // which receives the current date and outputs a string.\r"," calend.set(\"headerRenderer\", function (curDate) {\r"," var ydate = Y.DataType.Date,\r"," output = ydate.format(curDate, {\r"," format: \"%B %Y\"\r"," }) + \" — \" + ydate.format(ydate.addMonths(curDate, 1), {\r"," format: \"%B %Y\"\r"," })+ \" — \" + ydate.format(ydate.addMonths(curDate, 2), {\r"," format: \"%B %Y\"\r"," });\r"," return output;\r"," });\r"," // Listen to calendar's selectionChange event.\r"," calend.on(\"selectionChange\", function (ev) {\r"," var dtdate = Y.DataType.Date;\r"," var listdates = '[{';\r"," // Collect dates from selection\r"," for (var i = 0; i < ev.newSelection.length; i++) {\r"," listdates += (i === 0 ? \"\" : \",\") + '\"'+ i +'\":\"'+ dtdate.format(ev.newSelection[i])+'\"';\r","\t\t}\r"," listdates += \"}]\";\r"," //set dates to HTML control\r"," Y.one(document.getElementsByName('getlistdates')[0]).set('value', listdates);\r"," });\r"," };","","}, '@VERSION@', {\"requires\": [\"base\", \"calendar\", \"datatype-date\", \"datatype-date-format\", \"node\", \"intl\"]});","","}());"]}; + __coverage__['build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane.js'] = {"path":"build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane.js","s":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0},"b":{"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0]},"f":{"1":0,"2":0,"3":0,"4":0,"5":0},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":40},"end":{"line":1,"column":59}}},"2":{"name":"(anonymous_2)","line":8,"loc":{"start":{"line":8,"column":11},"end":{"line":8,"column":30}}},"3":{"name":"(anonymous_3)","line":53,"loc":{"start":{"line":53,"column":24},"end":{"line":53,"column":53}}},"4":{"name":"(anonymous_4)","line":60,"loc":{"start":{"line":60,"column":33},"end":{"line":60,"column":52}}},"5":{"name":"(anonymous_5)","line":72,"loc":{"start":{"line":72,"column":33},"end":{"line":72,"column":47}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":85,"column":109}},"2":{"start":{"line":3,"column":0},"end":{"line":3,"column":8}},"3":{"start":{"line":5,"column":0},"end":{"line":5,"column":40}},"4":{"start":{"line":6,"column":0},"end":{"line":6,"column":35}},"5":{"start":{"line":8,"column":0},"end":{"line":83,"column":4}},"6":{"start":{"line":9,"column":4},"end":{"line":12,"column":7}},"7":{"start":{"line":13,"column":4},"end":{"line":16,"column":7}},"8":{"start":{"line":17,"column":4},"end":{"line":17,"column":73}},"9":{"start":{"line":19,"column":4},"end":{"line":26,"column":27}},"10":{"start":{"line":28,"column":4},"end":{"line":32,"column":5}},"11":{"start":{"line":29,"column":8},"end":{"line":29,"column":88}},"12":{"start":{"line":30,"column":11},"end":{"line":32,"column":5}},"13":{"start":{"line":31,"column":8},"end":{"line":31,"column":88}},"14":{"start":{"line":33,"column":4},"end":{"line":37,"column":5}},"15":{"start":{"line":34,"column":8},"end":{"line":34,"column":65}},"16":{"start":{"line":36,"column":8},"end":{"line":36,"column":88}},"17":{"start":{"line":39,"column":4},"end":{"line":39,"column":20}},"18":{"start":{"line":41,"column":4},"end":{"line":49,"column":6}},"19":{"start":{"line":51,"column":4},"end":{"line":58,"column":7}},"20":{"start":{"line":54,"column":12},"end":{"line":56,"column":13}},"21":{"start":{"line":55,"column":16},"end":{"line":55,"column":41}},"22":{"start":{"line":60,"column":4},"end":{"line":70,"column":7}},"23":{"start":{"line":61,"column":8},"end":{"line":68,"column":15}},"24":{"start":{"line":69,"column":8},"end":{"line":69,"column":22}},"25":{"start":{"line":72,"column":4},"end":{"line":82,"column":7}},"26":{"start":{"line":73,"column":8},"end":{"line":73,"column":37}},"27":{"start":{"line":74,"column":8},"end":{"line":74,"column":29}},"28":{"start":{"line":76,"column":8},"end":{"line":78,"column":3}},"29":{"start":{"line":77,"column":12},"end":{"line":77,"column":101}},"30":{"start":{"line":79,"column":8},"end":{"line":79,"column":26}},"31":{"start":{"line":81,"column":8},"end":{"line":81,"column":85}}},"branchMap":{"1":{"line":5,"type":"binary-expr","locations":[{"start":{"line":5,"column":18},"end":{"line":5,"column":33}},{"start":{"line":5,"column":37},"end":{"line":5,"column":39}}]},"2":{"line":28,"type":"if","locations":[{"start":{"line":28,"column":4},"end":{"line":28,"column":4}},{"start":{"line":28,"column":4},"end":{"line":28,"column":4}}]},"3":{"line":30,"type":"if","locations":[{"start":{"line":30,"column":11},"end":{"line":30,"column":11}},{"start":{"line":30,"column":11},"end":{"line":30,"column":11}}]},"4":{"line":33,"type":"if","locations":[{"start":{"line":33,"column":4},"end":{"line":33,"column":4}},{"start":{"line":33,"column":4},"end":{"line":33,"column":4}}]},"5":{"line":54,"type":"if","locations":[{"start":{"line":54,"column":12},"end":{"line":54,"column":12}},{"start":{"line":54,"column":12},"end":{"line":54,"column":12}}]},"6":{"line":77,"type":"cond-expr","locations":[{"start":{"line":77,"column":36},"end":{"line":77,"column":38}},{"start":{"line":77,"column":41},"end":{"line":77,"column":44}}]}},"code":["(function () { YUI.add('moodle-mod_scheduler-calpane', function (Y, NAME) {","","var MOD;\r","\r","M.mod_scheduler = M.mod_scheduler || {};\r","MOD = M.mod_scheduler.calpane = {};\r","\r","MOD.init = function(langconf) {\r"," Y.Intl.add(\"datatype-date-format\", \"uk-UK\", {\r"," \"A\":[\"Неділя\",\"Понеділок\",\"Вівторк\",\"Середа\",\"Четвер\",\"П'ятниця\",\"Субота\"],\r"," \"B\":[\"Січень\",\"Лютий\",\"Березень\",\"Квітень\",\"Травень\",\"Червень\",\"Липень\",\"Серпень\",\"Вересень\",\"Жовтень\",\"Листопад\",\"Грудень\"]\r"," });\r"," Y.Intl.add(\"datatype-date-format\", \"ru-RU\", {\r"," \"A\":[\"Воскресенье\",\"Понедельник\",\"Вторник\",\"Среда\",\"Четверг\",\"Пятница\",\"Суббота\"],\r"," \"B\":[\"Январь\",\"Февраль\",\"Март\",\"Апрель\",\"Май\",\"Июнь\",\"Июль\",\"Август\",\"Сентябрь\",\"Октябрь\",\"Ноябрь\",\"Декабрь\"]\r"," });\r"," Y.CalendarBase.CONTENT_TEMPLATE = Y.CalendarBase.THREE_PANE_TEMPLATE;\r"," // Setup basic calendar parameters\r"," var calend = new Y.Calendar({\r"," contentBox: \"#calContainer\",\r"," width:'760px',\r"," showPrevMonth: true,\r"," showNextMonth: true,\r"," selectionMode: 'multiple-sticky',\r"," minimumDate: new Date(),\r"," date: new Date()});\r"," //Localization. Have some troubles\r"," if (langconf === \"uk\") {\r"," calend.set(\"strings.very_short_weekdays\", [\"Нд\",\"Пн\",\"Вт\",\"Ср\",\"Чт\",\"Пт\",\"Сб\"]);\r"," } else if (langconf === \"ru\") {\r"," calend.set(\"strings.very_short_weekdays\", [\"Вс\",\"Пн\",\"Вт\",\"Ср\",\"Чт\",\"Пт\",\"Сб\"]);\r"," }\r"," if (langconf === \"en\") {\r"," Y.Intl.setLang(\"datatype-date-format\", langconf + \"-US\");\r"," } else {\r"," Y.Intl.setLang(\"datatype-date-format\", langconf + \"-\" + langconf.toUpperCase());\r"," }\r"," // Draw calendar instance\r"," calend.render();\r"," // Create a set of rules to match specific dates. In this case, the \"all_weekends\" rule will match any Saturday or Sunday.\r"," var rules = {\r"," \"all\": {\r"," \"all\": {\r"," \"all\": {\r"," \"0,6\": \"all_weekends\"\r"," }\r"," }\r"," }\r"," };\r"," // Set the calendar customRenderer, provides the rules defined above.\r"," calend.set(\"customRenderer\", {\r"," rules: rules,\r"," filterFunction: function (date, node, rules) {\r"," if (Y.Array.indexOf(rules, 'all_weekends') >= 0) {\r"," node.addClass(\"redtext\");\r"," }\r"," }\r"," });\r"," // Set a custom header renderer with a callback function, which receives the current date and outputs a string.\r"," calend.set(\"headerRenderer\", function (curDate) {\r"," var ydate = Y.DataType.Date,\r"," output = ydate.format(curDate, {\r"," format: \"%B %Y\"\r"," }) + \" — \" + ydate.format(ydate.addMonths(curDate, 1), {\r"," format: \"%B %Y\"\r"," })+ \" — \" + ydate.format(ydate.addMonths(curDate, 2), {\r"," format: \"%B %Y\"\r"," });\r"," return output;\r"," });\r"," // Listen to calendar's selectionChange event.\r"," calend.on(\"selectionChange\", function (ev) {\r"," var dtdate = Y.DataType.Date;\r"," var listdates = '[{';\r"," // Collect dates from selection\r"," for (var i = 0; i < ev.newSelection.length; i++) {\r"," listdates += (i === 0 ? \"\" : \",\") + '\"'+ i +'\":\"'+ dtdate.format(ev.newSelection[i])+'\"';\r","\t\t}\r"," listdates += \"}]\";\r"," //set dates to HTML control\r"," Y.one(document.getElementsByName('getlistdates')[0]).set('value', listdates);\r"," });\r"," };","","}, '@VERSION@', {\"requires\": [\"base\", \"calendar\", \"datatype-date\", \"datatype-date-format\", \"node\", \"intl\"]});","","}());"]}; } var __cov_VfNixH5rFGHdVHAfsTIltg = __coverage__['build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane.js']; -__cov_VfNixH5rFGHdVHAfsTIltg.s['1']++;YUI.add('moodle-mod_scheduler-calpane',function(Y,NAME){__cov_VfNixH5rFGHdVHAfsTIltg.f['1']++;__cov_VfNixH5rFGHdVHAfsTIltg.s['2']++;var MOD;__cov_VfNixH5rFGHdVHAfsTIltg.s['3']++;M.mod_scheduler=(__cov_VfNixH5rFGHdVHAfsTIltg.b['1'][0]++,M.mod_scheduler)||(__cov_VfNixH5rFGHdVHAfsTIltg.b['1'][1]++,{});__cov_VfNixH5rFGHdVHAfsTIltg.s['4']++;MOD=M.mod_scheduler.calpane={};__cov_VfNixH5rFGHdVHAfsTIltg.s['5']++;MOD.init=function(langconf){__cov_VfNixH5rFGHdVHAfsTIltg.f['2']++;__cov_VfNixH5rFGHdVHAfsTIltg.s['6']++;Y.Intl.add('datatype-date-format','uk-UK',{'a':['\u041d\u0434','\u041f\u043d','\u0412\u0442','\u0421\u0440','\u0427\u0442','\u041f\u0442','\u0421\u0431'],'A':['\u041d\u0435\u0434\u0456\u043b\u044f','\u041f\u043e\u043d\u0435\u0434\u0456\u043b\u043e\u043a','\u0412\u0456\u0432\u0442\u043e\u0440\u043a','\u0421\u0435\u0440\u0435\u0434\u0430','\u0427\u0435\u0442\u0432\u0435\u0440','\u041f\'\u044f\u0442\u043d\u0438\u0446\u044f','\u0421\u0443\u0431\u043e\u0442\u0430'],'B':['\u0421\u0456\u0447\u0435\u043d\u044c','\u041b\u044e\u0442\u0438\u0439','\u0411\u0435\u0440\u0435\u0437\u0435\u043d\u044c','\u041a\u0432\u0456\u0442\u0435\u043d\u044c','\u0422\u0440\u0430\u0432\u0435\u043d\u044c','\u0427\u0435\u0440\u0432\u0435\u043d\u044c','\u041b\u0438\u043f\u0435\u043d\u044c','\u0421\u0435\u0440\u043f\u0435\u043d\u044c','\u0412\u0435\u0440\u0435\u0441\u0435\u043d\u044c','\u0416\u043e\u0432\u0442\u0435\u043d\u044c','\u041b\u0438\u0441\u0442\u043e\u043f\u0430\u0434','\u0413\u0440\u0443\u0434\u0435\u043d\u044c']});__cov_VfNixH5rFGHdVHAfsTIltg.s['7']++;Y.Intl.add('datatype-date-format','ru-RU',{'a':['\u0412\u0441','\u041f\u043d','\u0412\u0442','\u0421\u0440','\u0427\u0442','\u041f\u0442','\u0421\u0431'],'A':['\u0412\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435','\u041f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a','\u0412\u0442\u043e\u0440\u043d\u0438\u043a','\u0421\u0440\u0435\u0434\u0430','\u0427\u0435\u0442\u0432\u0435\u0440\u0433','\u041f\u044f\u0442\u043d\u0438\u0446\u0430','\u0421\u0443\u0431\u0431\u043e\u0442\u0430'],'B':['\u042f\u043d\u0432\u0430\u0440\u044c','\u0424\u0435\u0432\u0440\u0430\u043b\u044c','\u041c\u0430\u0440\u0442','\u0410\u043f\u0440\u0435\u043b\u044c','\u041c\u0430\u0439','\u0418\u044e\u043d\u044c','\u0418\u044e\u043b\u044c','\u0410\u0432\u0433\u0443\u0441\u0442','\u0421\u0435\u043d\u0442\u044f\u0431\u0440\u044c','\u041e\u043a\u0442\u044f\u0431\u0440\u044c','\u041d\u043e\u044f\u0431\u0440\u044c','\u0414\u0435\u043a\u0430\u0431\u0440\u044c']});__cov_VfNixH5rFGHdVHAfsTIltg.s['8']++;Y.CalendarBase.CONTENT_TEMPLATE=Y.CalendarBase.THREE_PANE_TEMPLATE;__cov_VfNixH5rFGHdVHAfsTIltg.s['9']++;var calend=new Y.Calendar({contentBox:'#calContainer',width:'750px',showPrevMonth:true,showNextMonth:true,selectionMode:'multiple-sticky',minimumDate:new Date(),date:new Date()});__cov_VfNixH5rFGHdVHAfsTIltg.s['10']++;if(langconf==='uk'){__cov_VfNixH5rFGHdVHAfsTIltg.b['2'][0]++;__cov_VfNixH5rFGHdVHAfsTIltg.s['11']++;calend.set('strings.very_short_weekdays',['\u041d\u0434','\u041f\u043d','\u0412\u0442','\u0421\u0440','\u0427\u0442','\u041f\u0442','\u0421\u0431']);__cov_VfNixH5rFGHdVHAfsTIltg.s['12']++;Y.Intl.setLang('datatype-date-format','uk-UK');}else{__cov_VfNixH5rFGHdVHAfsTIltg.b['2'][1]++;__cov_VfNixH5rFGHdVHAfsTIltg.s['13']++;if(langconf==='ru'){__cov_VfNixH5rFGHdVHAfsTIltg.b['3'][0]++;__cov_VfNixH5rFGHdVHAfsTIltg.s['14']++;calend.set('strings.very_short_weekdays',['\u0412\u0441','\u041f\u043d','\u0412\u0442','\u0421\u0440','\u0427\u0442','\u041f\u0442','\u0421\u0431']);__cov_VfNixH5rFGHdVHAfsTIltg.s['15']++;Y.Intl.setLang('datatype-date-format','ru-RU');}else{__cov_VfNixH5rFGHdVHAfsTIltg.b['3'][1]++;__cov_VfNixH5rFGHdVHAfsTIltg.s['16']++;Y.Intl.setLang('datatype-date-format','en-US');}}__cov_VfNixH5rFGHdVHAfsTIltg.s['17']++;calend.render();__cov_VfNixH5rFGHdVHAfsTIltg.s['18']++;var rules={'all':{'all':{'all':{'0,6':'all_weekends'}}}};__cov_VfNixH5rFGHdVHAfsTIltg.s['19']++;calend.set('customRenderer',{rules:rules,filterFunction:function(date,node,rules){__cov_VfNixH5rFGHdVHAfsTIltg.f['3']++;__cov_VfNixH5rFGHdVHAfsTIltg.s['20']++;if(Y.Array.indexOf(rules,'all_weekends')>=0){__cov_VfNixH5rFGHdVHAfsTIltg.b['4'][0]++;__cov_VfNixH5rFGHdVHAfsTIltg.s['21']++;node.addClass('redtext');}else{__cov_VfNixH5rFGHdVHAfsTIltg.b['4'][1]++;}}});__cov_VfNixH5rFGHdVHAfsTIltg.s['22']++;calend.set('headerRenderer',function(curDate){__cov_VfNixH5rFGHdVHAfsTIltg.f['4']++;__cov_VfNixH5rFGHdVHAfsTIltg.s['23']++;var ydate=Y.DataType.Date,output=ydate.format(curDate,{format:'%B %Y'})+' — '+ydate.format(ydate.addMonths(curDate,1),{format:'%B %Y'})+' — '+ydate.format(ydate.addMonths(curDate,2),{format:'%B %Y'});__cov_VfNixH5rFGHdVHAfsTIltg.s['24']++;return output;});__cov_VfNixH5rFGHdVHAfsTIltg.s['25']++;calend.on('selectionChange',function(ev){__cov_VfNixH5rFGHdVHAfsTIltg.f['5']++;__cov_VfNixH5rFGHdVHAfsTIltg.s['26']++;var dtdate=Y.DataType.Date;__cov_VfNixH5rFGHdVHAfsTIltg.s['27']++;var listdates='[{';__cov_VfNixH5rFGHdVHAfsTIltg.s['28']++;for(var i=0;i=0){__cov_VfNixH5rFGHdVHAfsTIltg.b['5'][0]++;__cov_VfNixH5rFGHdVHAfsTIltg.s['21']++;node.addClass('redtext');}else{__cov_VfNixH5rFGHdVHAfsTIltg.b['5'][1]++;}}});__cov_VfNixH5rFGHdVHAfsTIltg.s['22']++;calend.set('headerRenderer',function(curDate){__cov_VfNixH5rFGHdVHAfsTIltg.f['4']++;__cov_VfNixH5rFGHdVHAfsTIltg.s['23']++;var ydate=Y.DataType.Date,output=ydate.format(curDate,{format:'%B %Y'})+' — '+ydate.format(ydate.addMonths(curDate,1),{format:'%B %Y'})+' — '+ydate.format(ydate.addMonths(curDate,2),{format:'%B %Y'});__cov_VfNixH5rFGHdVHAfsTIltg.s['24']++;return output;});__cov_VfNixH5rFGHdVHAfsTIltg.s['25']++;calend.on('selectionChange',function(ev){__cov_VfNixH5rFGHdVHAfsTIltg.f['5']++;__cov_VfNixH5rFGHdVHAfsTIltg.s['26']++;var dtdate=Y.DataType.Date;__cov_VfNixH5rFGHdVHAfsTIltg.s['27']++;var listdates='[{';__cov_VfNixH5rFGHdVHAfsTIltg.s['28']++;for(var i=0;i=0&&n.addClass("redtext")}}),n.set("headerRenderer",function(t){var n=e.DataType.Date,r=n.format(t,{format:"%B %Y"})+" — "+n.format(n.addMonths(t,1),{format:"%B %Y"})+" — "+n.format(n.addMonths(t,2),{format:"%B %Y"});return r}),n.on("selectionChange",function(t){var n=e.DataType.Date,r="[{";for(var i=0;i=0&&n.addClass("redtext")}}),n.set("headerRenderer",function(t){var n=e.DataType.Date,r=n.format(t,{format:"%B %Y"})+" — "+n.format(n.addMonths(t,1),{format:"%B %Y"})+" — "+n.format(n.addMonths(t,2),{format:"%B %Y"});return r}),n.on("selectionChange",function(t){var n=e.DataType.Date,r="[{";for(var i=0;i Date: Wed, 26 Nov 2014 21:24:32 +0200 Subject: [PATCH 12/16] fix localization issue - calendar do not shown when a course language was not forced --- .../moodle-mod_scheduler-calpane-coverage.js | 4 ++-- .../moodle-mod_scheduler-calpane-debug.js | 17 +++++++++-------- .../moodle-mod_scheduler-calpane-min.js | 2 +- .../moodle-mod_scheduler-calpane.js | 17 +++++++++-------- yui/src/calpane/js/calpane.js | 17 +++++++++-------- 5 files changed, 30 insertions(+), 27 deletions(-) diff --git a/yui/build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane-coverage.js b/yui/build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane-coverage.js index 46a4b130..dcadbd0c 100644 --- a/yui/build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane-coverage.js +++ b/yui/build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane-coverage.js @@ -1,6 +1,6 @@ if (typeof __coverage__ === 'undefined') { __coverage__ = {}; } if (!__coverage__['build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane.js']) { - __coverage__['build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane.js'] = {"path":"build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane.js","s":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0},"b":{"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0]},"f":{"1":0,"2":0,"3":0,"4":0,"5":0},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":40},"end":{"line":1,"column":59}}},"2":{"name":"(anonymous_2)","line":8,"loc":{"start":{"line":8,"column":11},"end":{"line":8,"column":30}}},"3":{"name":"(anonymous_3)","line":53,"loc":{"start":{"line":53,"column":24},"end":{"line":53,"column":53}}},"4":{"name":"(anonymous_4)","line":60,"loc":{"start":{"line":60,"column":33},"end":{"line":60,"column":52}}},"5":{"name":"(anonymous_5)","line":72,"loc":{"start":{"line":72,"column":33},"end":{"line":72,"column":47}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":85,"column":109}},"2":{"start":{"line":3,"column":0},"end":{"line":3,"column":8}},"3":{"start":{"line":5,"column":0},"end":{"line":5,"column":40}},"4":{"start":{"line":6,"column":0},"end":{"line":6,"column":35}},"5":{"start":{"line":8,"column":0},"end":{"line":83,"column":4}},"6":{"start":{"line":9,"column":4},"end":{"line":12,"column":7}},"7":{"start":{"line":13,"column":4},"end":{"line":16,"column":7}},"8":{"start":{"line":17,"column":4},"end":{"line":17,"column":73}},"9":{"start":{"line":19,"column":4},"end":{"line":26,"column":27}},"10":{"start":{"line":28,"column":4},"end":{"line":32,"column":5}},"11":{"start":{"line":29,"column":8},"end":{"line":29,"column":88}},"12":{"start":{"line":30,"column":11},"end":{"line":32,"column":5}},"13":{"start":{"line":31,"column":8},"end":{"line":31,"column":88}},"14":{"start":{"line":33,"column":4},"end":{"line":37,"column":5}},"15":{"start":{"line":34,"column":8},"end":{"line":34,"column":65}},"16":{"start":{"line":36,"column":8},"end":{"line":36,"column":88}},"17":{"start":{"line":39,"column":4},"end":{"line":39,"column":20}},"18":{"start":{"line":41,"column":4},"end":{"line":49,"column":6}},"19":{"start":{"line":51,"column":4},"end":{"line":58,"column":7}},"20":{"start":{"line":54,"column":12},"end":{"line":56,"column":13}},"21":{"start":{"line":55,"column":16},"end":{"line":55,"column":41}},"22":{"start":{"line":60,"column":4},"end":{"line":70,"column":7}},"23":{"start":{"line":61,"column":8},"end":{"line":68,"column":15}},"24":{"start":{"line":69,"column":8},"end":{"line":69,"column":22}},"25":{"start":{"line":72,"column":4},"end":{"line":82,"column":7}},"26":{"start":{"line":73,"column":8},"end":{"line":73,"column":37}},"27":{"start":{"line":74,"column":8},"end":{"line":74,"column":29}},"28":{"start":{"line":76,"column":8},"end":{"line":78,"column":3}},"29":{"start":{"line":77,"column":12},"end":{"line":77,"column":101}},"30":{"start":{"line":79,"column":8},"end":{"line":79,"column":26}},"31":{"start":{"line":81,"column":8},"end":{"line":81,"column":85}}},"branchMap":{"1":{"line":5,"type":"binary-expr","locations":[{"start":{"line":5,"column":18},"end":{"line":5,"column":33}},{"start":{"line":5,"column":37},"end":{"line":5,"column":39}}]},"2":{"line":28,"type":"if","locations":[{"start":{"line":28,"column":4},"end":{"line":28,"column":4}},{"start":{"line":28,"column":4},"end":{"line":28,"column":4}}]},"3":{"line":30,"type":"if","locations":[{"start":{"line":30,"column":11},"end":{"line":30,"column":11}},{"start":{"line":30,"column":11},"end":{"line":30,"column":11}}]},"4":{"line":33,"type":"if","locations":[{"start":{"line":33,"column":4},"end":{"line":33,"column":4}},{"start":{"line":33,"column":4},"end":{"line":33,"column":4}}]},"5":{"line":54,"type":"if","locations":[{"start":{"line":54,"column":12},"end":{"line":54,"column":12}},{"start":{"line":54,"column":12},"end":{"line":54,"column":12}}]},"6":{"line":77,"type":"cond-expr","locations":[{"start":{"line":77,"column":36},"end":{"line":77,"column":38}},{"start":{"line":77,"column":41},"end":{"line":77,"column":44}}]}},"code":["(function () { YUI.add('moodle-mod_scheduler-calpane', function (Y, NAME) {","","var MOD;\r","\r","M.mod_scheduler = M.mod_scheduler || {};\r","MOD = M.mod_scheduler.calpane = {};\r","\r","MOD.init = function(langconf) {\r"," Y.Intl.add(\"datatype-date-format\", \"uk-UK\", {\r"," \"A\":[\"Неділя\",\"Понеділок\",\"Вівторк\",\"Середа\",\"Четвер\",\"П'ятниця\",\"Субота\"],\r"," \"B\":[\"Січень\",\"Лютий\",\"Березень\",\"Квітень\",\"Травень\",\"Червень\",\"Липень\",\"Серпень\",\"Вересень\",\"Жовтень\",\"Листопад\",\"Грудень\"]\r"," });\r"," Y.Intl.add(\"datatype-date-format\", \"ru-RU\", {\r"," \"A\":[\"Воскресенье\",\"Понедельник\",\"Вторник\",\"Среда\",\"Четверг\",\"Пятница\",\"Суббота\"],\r"," \"B\":[\"Январь\",\"Февраль\",\"Март\",\"Апрель\",\"Май\",\"Июнь\",\"Июль\",\"Август\",\"Сентябрь\",\"Октябрь\",\"Ноябрь\",\"Декабрь\"]\r"," });\r"," Y.CalendarBase.CONTENT_TEMPLATE = Y.CalendarBase.THREE_PANE_TEMPLATE;\r"," // Setup basic calendar parameters\r"," var calend = new Y.Calendar({\r"," contentBox: \"#calContainer\",\r"," width:'760px',\r"," showPrevMonth: true,\r"," showNextMonth: true,\r"," selectionMode: 'multiple-sticky',\r"," minimumDate: new Date(),\r"," date: new Date()});\r"," //Localization. Have some troubles\r"," if (langconf === \"uk\") {\r"," calend.set(\"strings.very_short_weekdays\", [\"Нд\",\"Пн\",\"Вт\",\"Ср\",\"Чт\",\"Пт\",\"Сб\"]);\r"," } else if (langconf === \"ru\") {\r"," calend.set(\"strings.very_short_weekdays\", [\"Вс\",\"Пн\",\"Вт\",\"Ср\",\"Чт\",\"Пт\",\"Сб\"]);\r"," }\r"," if (langconf === \"en\") {\r"," Y.Intl.setLang(\"datatype-date-format\", langconf + \"-US\");\r"," } else {\r"," Y.Intl.setLang(\"datatype-date-format\", langconf + \"-\" + langconf.toUpperCase());\r"," }\r"," // Draw calendar instance\r"," calend.render();\r"," // Create a set of rules to match specific dates. In this case, the \"all_weekends\" rule will match any Saturday or Sunday.\r"," var rules = {\r"," \"all\": {\r"," \"all\": {\r"," \"all\": {\r"," \"0,6\": \"all_weekends\"\r"," }\r"," }\r"," }\r"," };\r"," // Set the calendar customRenderer, provides the rules defined above.\r"," calend.set(\"customRenderer\", {\r"," rules: rules,\r"," filterFunction: function (date, node, rules) {\r"," if (Y.Array.indexOf(rules, 'all_weekends') >= 0) {\r"," node.addClass(\"redtext\");\r"," }\r"," }\r"," });\r"," // Set a custom header renderer with a callback function, which receives the current date and outputs a string.\r"," calend.set(\"headerRenderer\", function (curDate) {\r"," var ydate = Y.DataType.Date,\r"," output = ydate.format(curDate, {\r"," format: \"%B %Y\"\r"," }) + \" — \" + ydate.format(ydate.addMonths(curDate, 1), {\r"," format: \"%B %Y\"\r"," })+ \" — \" + ydate.format(ydate.addMonths(curDate, 2), {\r"," format: \"%B %Y\"\r"," });\r"," return output;\r"," });\r"," // Listen to calendar's selectionChange event.\r"," calend.on(\"selectionChange\", function (ev) {\r"," var dtdate = Y.DataType.Date;\r"," var listdates = '[{';\r"," // Collect dates from selection\r"," for (var i = 0; i < ev.newSelection.length; i++) {\r"," listdates += (i === 0 ? \"\" : \",\") + '\"'+ i +'\":\"'+ dtdate.format(ev.newSelection[i])+'\"';\r","\t\t}\r"," listdates += \"}]\";\r"," //set dates to HTML control\r"," Y.one(document.getElementsByName('getlistdates')[0]).set('value', listdates);\r"," });\r"," };","","}, '@VERSION@', {\"requires\": [\"base\", \"calendar\", \"datatype-date\", \"datatype-date-format\", \"node\", \"intl\"]});","","}());"]}; + __coverage__['build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane.js'] = {"path":"build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane.js","s":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0},"b":{"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0],"7":[0,0]},"f":{"1":0,"2":0,"3":0,"4":0,"5":0},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":40},"end":{"line":1,"column":59}}},"2":{"name":"(anonymous_2)","line":8,"loc":{"start":{"line":8,"column":11},"end":{"line":8,"column":30}}},"3":{"name":"(anonymous_3)","line":54,"loc":{"start":{"line":54,"column":24},"end":{"line":54,"column":53}}},"4":{"name":"(anonymous_4)","line":61,"loc":{"start":{"line":61,"column":33},"end":{"line":61,"column":52}}},"5":{"name":"(anonymous_5)","line":73,"loc":{"start":{"line":73,"column":33},"end":{"line":73,"column":47}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":86,"column":109}},"2":{"start":{"line":3,"column":0},"end":{"line":3,"column":8}},"3":{"start":{"line":5,"column":0},"end":{"line":5,"column":40}},"4":{"start":{"line":6,"column":0},"end":{"line":6,"column":35}},"5":{"start":{"line":8,"column":0},"end":{"line":84,"column":4}},"6":{"start":{"line":9,"column":4},"end":{"line":12,"column":7}},"7":{"start":{"line":13,"column":4},"end":{"line":16,"column":7}},"8":{"start":{"line":17,"column":4},"end":{"line":17,"column":73}},"9":{"start":{"line":19,"column":4},"end":{"line":26,"column":27}},"10":{"start":{"line":28,"column":4},"end":{"line":38,"column":5}},"11":{"start":{"line":29,"column":8},"end":{"line":29,"column":56}},"12":{"start":{"line":31,"column":8},"end":{"line":31,"column":88}},"13":{"start":{"line":33,"column":8},"end":{"line":37,"column":9}},"14":{"start":{"line":34,"column":12},"end":{"line":34,"column":92}},"15":{"start":{"line":35,"column":15},"end":{"line":37,"column":9}},"16":{"start":{"line":36,"column":12},"end":{"line":36,"column":92}},"17":{"start":{"line":40,"column":4},"end":{"line":40,"column":20}},"18":{"start":{"line":42,"column":4},"end":{"line":50,"column":6}},"19":{"start":{"line":52,"column":4},"end":{"line":59,"column":7}},"20":{"start":{"line":55,"column":12},"end":{"line":57,"column":13}},"21":{"start":{"line":56,"column":16},"end":{"line":56,"column":41}},"22":{"start":{"line":61,"column":4},"end":{"line":71,"column":7}},"23":{"start":{"line":62,"column":8},"end":{"line":69,"column":15}},"24":{"start":{"line":70,"column":8},"end":{"line":70,"column":22}},"25":{"start":{"line":73,"column":4},"end":{"line":83,"column":7}},"26":{"start":{"line":74,"column":8},"end":{"line":74,"column":37}},"27":{"start":{"line":75,"column":8},"end":{"line":75,"column":29}},"28":{"start":{"line":77,"column":8},"end":{"line":79,"column":3}},"29":{"start":{"line":78,"column":12},"end":{"line":78,"column":101}},"30":{"start":{"line":80,"column":8},"end":{"line":80,"column":26}},"31":{"start":{"line":82,"column":8},"end":{"line":82,"column":85}}},"branchMap":{"1":{"line":5,"type":"binary-expr","locations":[{"start":{"line":5,"column":18},"end":{"line":5,"column":33}},{"start":{"line":5,"column":37},"end":{"line":5,"column":39}}]},"2":{"line":28,"type":"if","locations":[{"start":{"line":28,"column":4},"end":{"line":28,"column":4}},{"start":{"line":28,"column":4},"end":{"line":28,"column":4}}]},"3":{"line":28,"type":"binary-expr","locations":[{"start":{"line":28,"column":8},"end":{"line":28,"column":26}},{"start":{"line":28,"column":30},"end":{"line":28,"column":47}}]},"4":{"line":33,"type":"if","locations":[{"start":{"line":33,"column":8},"end":{"line":33,"column":8}},{"start":{"line":33,"column":8},"end":{"line":33,"column":8}}]},"5":{"line":35,"type":"if","locations":[{"start":{"line":35,"column":15},"end":{"line":35,"column":15}},{"start":{"line":35,"column":15},"end":{"line":35,"column":15}}]},"6":{"line":55,"type":"if","locations":[{"start":{"line":55,"column":12},"end":{"line":55,"column":12}},{"start":{"line":55,"column":12},"end":{"line":55,"column":12}}]},"7":{"line":78,"type":"cond-expr","locations":[{"start":{"line":78,"column":36},"end":{"line":78,"column":38}},{"start":{"line":78,"column":41},"end":{"line":78,"column":44}}]}},"code":["(function () { YUI.add('moodle-mod_scheduler-calpane', function (Y, NAME) {","","var MOD;\r","\r","M.mod_scheduler = M.mod_scheduler || {};\r","MOD = M.mod_scheduler.calpane = {};\r","\r","MOD.init = function(langconf) {\r"," Y.Intl.add(\"datatype-date-format\", \"uk-UK\", {\r"," \"A\":[\"Неділя\",\"Понеділок\",\"Вівторк\",\"Середа\",\"Четвер\",\"П'ятниця\",\"Субота\"],\r"," \"B\":[\"Січень\",\"Лютий\",\"Березень\",\"Квітень\",\"Травень\",\"Червень\",\"Липень\",\"Серпень\",\"Вересень\",\"Жовтень\",\"Листопад\",\"Грудень\"]\r"," });\r"," Y.Intl.add(\"datatype-date-format\", \"ru-RU\", {\r"," \"A\":[\"Воскресенье\",\"Понедельник\",\"Вторник\",\"Среда\",\"Четверг\",\"Пятница\",\"Суббота\"],\r"," \"B\":[\"Январь\",\"Февраль\",\"Март\",\"Апрель\",\"Май\",\"Июнь\",\"Июль\",\"Август\",\"Сентябрь\",\"Октябрь\",\"Ноябрь\",\"Декабрь\"]\r"," });\r"," Y.CalendarBase.CONTENT_TEMPLATE = Y.CalendarBase.THREE_PANE_TEMPLATE;\r"," // Setup basic calendar parameters\r"," var calend = new Y.Calendar({\r"," contentBox: \"#calContainer\",\r"," width:'760px',\r"," showPrevMonth: true,\r"," showNextMonth: true,\r"," selectionMode: 'multiple-sticky',\r"," minimumDate: new Date(),\r"," date: new Date()});\r"," //Set localization options\r"," if (langconf === false || langconf === \"en\") {\r"," Y.Intl.setLang(\"datatype-date-format\", \"en-US\");\r"," } else {\r"," Y.Intl.setLang(\"datatype-date-format\", langconf + \"-\" + langconf.toUpperCase());\r"," //set additional calendar options for the Ukrainian and Russian\r"," if (langconf === \"uk\") {\r"," calend.set(\"strings.very_short_weekdays\", [\"Нд\",\"Пн\",\"Вт\",\"Ср\",\"Чт\",\"Пт\",\"Сб\"]);\r"," } else if (langconf === \"ru\") {\r"," calend.set(\"strings.very_short_weekdays\", [\"Вс\",\"Пн\",\"Вт\",\"Ср\",\"Чт\",\"Пт\",\"Сб\"]);\r"," }\r"," }\r"," // Draw calendar instance\r"," calend.render();\r"," // Create a set of rules to match specific dates. In this case, the \"all_weekends\" rule will match any Saturday or Sunday.\r"," var rules = {\r"," \"all\": {\r"," \"all\": {\r"," \"all\": {\r"," \"0,6\": \"all_weekends\"\r"," }\r"," }\r"," }\r"," };\r"," // Set the calendar customRenderer, provides the rules defined above.\r"," calend.set(\"customRenderer\", {\r"," rules: rules,\r"," filterFunction: function (date, node, rules) {\r"," if (Y.Array.indexOf(rules, 'all_weekends') >= 0) {\r"," node.addClass(\"redtext\");\r"," }\r"," }\r"," });\r"," // Set a custom header renderer with a callback function, which receives the current date and outputs a string.\r"," calend.set(\"headerRenderer\", function (curDate) {\r"," var ydate = Y.DataType.Date,\r"," output = ydate.format(curDate, {\r"," format: \"%B %Y\"\r"," }) + \" — \" + ydate.format(ydate.addMonths(curDate, 1), {\r"," format: \"%B %Y\"\r"," })+ \" — \" + ydate.format(ydate.addMonths(curDate, 2), {\r"," format: \"%B %Y\"\r"," });\r"," return output;\r"," });\r"," // Listen to calendar's selectionChange event.\r"," calend.on(\"selectionChange\", function (ev) {\r"," var dtdate = Y.DataType.Date;\r"," var listdates = '[{';\r"," // Collect dates from selection\r"," for (var i = 0; i < ev.newSelection.length; i++) {\r"," listdates += (i === 0 ? \"\" : \",\") + '\"'+ i +'\":\"'+ dtdate.format(ev.newSelection[i])+'\"';\r","\t\t}\r"," listdates += \"}]\";\r"," //set dates to HTML control\r"," Y.one(document.getElementsByName('getlistdates')[0]).set('value', listdates);\r"," });\r"," };","","}, '@VERSION@', {\"requires\": [\"base\", \"calendar\", \"datatype-date\", \"datatype-date-format\", \"node\", \"intl\"]});","","}());"]}; } var __cov_VfNixH5rFGHdVHAfsTIltg = __coverage__['build/moodle-mod_scheduler-calpane/moodle-mod_scheduler-calpane.js']; -__cov_VfNixH5rFGHdVHAfsTIltg.s['1']++;YUI.add('moodle-mod_scheduler-calpane',function(Y,NAME){__cov_VfNixH5rFGHdVHAfsTIltg.f['1']++;__cov_VfNixH5rFGHdVHAfsTIltg.s['2']++;var MOD;__cov_VfNixH5rFGHdVHAfsTIltg.s['3']++;M.mod_scheduler=(__cov_VfNixH5rFGHdVHAfsTIltg.b['1'][0]++,M.mod_scheduler)||(__cov_VfNixH5rFGHdVHAfsTIltg.b['1'][1]++,{});__cov_VfNixH5rFGHdVHAfsTIltg.s['4']++;MOD=M.mod_scheduler.calpane={};__cov_VfNixH5rFGHdVHAfsTIltg.s['5']++;MOD.init=function(langconf){__cov_VfNixH5rFGHdVHAfsTIltg.f['2']++;__cov_VfNixH5rFGHdVHAfsTIltg.s['6']++;Y.Intl.add('datatype-date-format','uk-UK',{'A':['\u041d\u0435\u0434\u0456\u043b\u044f','\u041f\u043e\u043d\u0435\u0434\u0456\u043b\u043e\u043a','\u0412\u0456\u0432\u0442\u043e\u0440\u043a','\u0421\u0435\u0440\u0435\u0434\u0430','\u0427\u0435\u0442\u0432\u0435\u0440','\u041f\'\u044f\u0442\u043d\u0438\u0446\u044f','\u0421\u0443\u0431\u043e\u0442\u0430'],'B':['\u0421\u0456\u0447\u0435\u043d\u044c','\u041b\u044e\u0442\u0438\u0439','\u0411\u0435\u0440\u0435\u0437\u0435\u043d\u044c','\u041a\u0432\u0456\u0442\u0435\u043d\u044c','\u0422\u0440\u0430\u0432\u0435\u043d\u044c','\u0427\u0435\u0440\u0432\u0435\u043d\u044c','\u041b\u0438\u043f\u0435\u043d\u044c','\u0421\u0435\u0440\u043f\u0435\u043d\u044c','\u0412\u0435\u0440\u0435\u0441\u0435\u043d\u044c','\u0416\u043e\u0432\u0442\u0435\u043d\u044c','\u041b\u0438\u0441\u0442\u043e\u043f\u0430\u0434','\u0413\u0440\u0443\u0434\u0435\u043d\u044c']});__cov_VfNixH5rFGHdVHAfsTIltg.s['7']++;Y.Intl.add('datatype-date-format','ru-RU',{'A':['\u0412\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435','\u041f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a','\u0412\u0442\u043e\u0440\u043d\u0438\u043a','\u0421\u0440\u0435\u0434\u0430','\u0427\u0435\u0442\u0432\u0435\u0440\u0433','\u041f\u044f\u0442\u043d\u0438\u0446\u0430','\u0421\u0443\u0431\u0431\u043e\u0442\u0430'],'B':['\u042f\u043d\u0432\u0430\u0440\u044c','\u0424\u0435\u0432\u0440\u0430\u043b\u044c','\u041c\u0430\u0440\u0442','\u0410\u043f\u0440\u0435\u043b\u044c','\u041c\u0430\u0439','\u0418\u044e\u043d\u044c','\u0418\u044e\u043b\u044c','\u0410\u0432\u0433\u0443\u0441\u0442','\u0421\u0435\u043d\u0442\u044f\u0431\u0440\u044c','\u041e\u043a\u0442\u044f\u0431\u0440\u044c','\u041d\u043e\u044f\u0431\u0440\u044c','\u0414\u0435\u043a\u0430\u0431\u0440\u044c']});__cov_VfNixH5rFGHdVHAfsTIltg.s['8']++;Y.CalendarBase.CONTENT_TEMPLATE=Y.CalendarBase.THREE_PANE_TEMPLATE;__cov_VfNixH5rFGHdVHAfsTIltg.s['9']++;var calend=new Y.Calendar({contentBox:'#calContainer',width:'760px',showPrevMonth:true,showNextMonth:true,selectionMode:'multiple-sticky',minimumDate:new Date(),date:new Date()});__cov_VfNixH5rFGHdVHAfsTIltg.s['10']++;if(langconf==='uk'){__cov_VfNixH5rFGHdVHAfsTIltg.b['2'][0]++;__cov_VfNixH5rFGHdVHAfsTIltg.s['11']++;calend.set('strings.very_short_weekdays',['\u041d\u0434','\u041f\u043d','\u0412\u0442','\u0421\u0440','\u0427\u0442','\u041f\u0442','\u0421\u0431']);}else{__cov_VfNixH5rFGHdVHAfsTIltg.b['2'][1]++;__cov_VfNixH5rFGHdVHAfsTIltg.s['12']++;if(langconf==='ru'){__cov_VfNixH5rFGHdVHAfsTIltg.b['3'][0]++;__cov_VfNixH5rFGHdVHAfsTIltg.s['13']++;calend.set('strings.very_short_weekdays',['\u0412\u0441','\u041f\u043d','\u0412\u0442','\u0421\u0440','\u0427\u0442','\u041f\u0442','\u0421\u0431']);}else{__cov_VfNixH5rFGHdVHAfsTIltg.b['3'][1]++;}}__cov_VfNixH5rFGHdVHAfsTIltg.s['14']++;if(langconf==='en'){__cov_VfNixH5rFGHdVHAfsTIltg.b['4'][0]++;__cov_VfNixH5rFGHdVHAfsTIltg.s['15']++;Y.Intl.setLang('datatype-date-format',langconf+'-US');}else{__cov_VfNixH5rFGHdVHAfsTIltg.b['4'][1]++;__cov_VfNixH5rFGHdVHAfsTIltg.s['16']++;Y.Intl.setLang('datatype-date-format',langconf+'-'+langconf.toUpperCase());}__cov_VfNixH5rFGHdVHAfsTIltg.s['17']++;calend.render();__cov_VfNixH5rFGHdVHAfsTIltg.s['18']++;var rules={'all':{'all':{'all':{'0,6':'all_weekends'}}}};__cov_VfNixH5rFGHdVHAfsTIltg.s['19']++;calend.set('customRenderer',{rules:rules,filterFunction:function(date,node,rules){__cov_VfNixH5rFGHdVHAfsTIltg.f['3']++;__cov_VfNixH5rFGHdVHAfsTIltg.s['20']++;if(Y.Array.indexOf(rules,'all_weekends')>=0){__cov_VfNixH5rFGHdVHAfsTIltg.b['5'][0]++;__cov_VfNixH5rFGHdVHAfsTIltg.s['21']++;node.addClass('redtext');}else{__cov_VfNixH5rFGHdVHAfsTIltg.b['5'][1]++;}}});__cov_VfNixH5rFGHdVHAfsTIltg.s['22']++;calend.set('headerRenderer',function(curDate){__cov_VfNixH5rFGHdVHAfsTIltg.f['4']++;__cov_VfNixH5rFGHdVHAfsTIltg.s['23']++;var ydate=Y.DataType.Date,output=ydate.format(curDate,{format:'%B %Y'})+' — '+ydate.format(ydate.addMonths(curDate,1),{format:'%B %Y'})+' — '+ydate.format(ydate.addMonths(curDate,2),{format:'%B %Y'});__cov_VfNixH5rFGHdVHAfsTIltg.s['24']++;return output;});__cov_VfNixH5rFGHdVHAfsTIltg.s['25']++;calend.on('selectionChange',function(ev){__cov_VfNixH5rFGHdVHAfsTIltg.f['5']++;__cov_VfNixH5rFGHdVHAfsTIltg.s['26']++;var dtdate=Y.DataType.Date;__cov_VfNixH5rFGHdVHAfsTIltg.s['27']++;var listdates='[{';__cov_VfNixH5rFGHdVHAfsTIltg.s['28']++;for(var i=0;i=0){__cov_VfNixH5rFGHdVHAfsTIltg.b['6'][0]++;__cov_VfNixH5rFGHdVHAfsTIltg.s['21']++;node.addClass('redtext');}else{__cov_VfNixH5rFGHdVHAfsTIltg.b['6'][1]++;}}});__cov_VfNixH5rFGHdVHAfsTIltg.s['22']++;calend.set('headerRenderer',function(curDate){__cov_VfNixH5rFGHdVHAfsTIltg.f['4']++;__cov_VfNixH5rFGHdVHAfsTIltg.s['23']++;var ydate=Y.DataType.Date,output=ydate.format(curDate,{format:'%B %Y'})+' — '+ydate.format(ydate.addMonths(curDate,1),{format:'%B %Y'})+' — '+ydate.format(ydate.addMonths(curDate,2),{format:'%B %Y'});__cov_VfNixH5rFGHdVHAfsTIltg.s['24']++;return output;});__cov_VfNixH5rFGHdVHAfsTIltg.s['25']++;calend.on('selectionChange',function(ev){__cov_VfNixH5rFGHdVHAfsTIltg.f['5']++;__cov_VfNixH5rFGHdVHAfsTIltg.s['26']++;var dtdate=Y.DataType.Date;__cov_VfNixH5rFGHdVHAfsTIltg.s['27']++;var listdates='[{';__cov_VfNixH5rFGHdVHAfsTIltg.s['28']++;for(var i=0;i=0&&n.addClass("redtext")}}),n.set("headerRenderer",function(t){var n=e.DataType.Date,r=n.format(t,{format:"%B %Y"})+" — "+n.format(n.addMonths(t,1),{format:"%B %Y"})+" — "+n.format(n.addMonths(t,2),{format:"%B %Y"});return r}),n.on("selectionChange",function(t){var n=e.DataType.Date,r="[{";for(var i=0;i=0&&n.addClass("redtext")}}),n.set("headerRenderer",function(t){var n=e.DataType.Date,r=n.format(t,{format:"%B %Y"})+" — "+n.format(n.addMonths(t,1),{format:"%B %Y"})+" — "+n.format(n.addMonths(t,2),{format:"%B %Y"});return r}),n.on("selectionChange",function(t){var n=e.DataType.Date,r="[{";for(var i=0;i Date: Sat, 13 Dec 2014 20:43:12 +0200 Subject: [PATCH 13/16] fix bug when was impossible to overlap conflict in the "remote" scheduler --- teacherview.controller.php | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/teacherview.controller.php b/teacherview.controller.php index 1c62b01f..6524245a 100644 --- a/teacherview.controller.php +++ b/teacherview.controller.php @@ -87,8 +87,18 @@ function scheduler_action_doaddsession($scheduler, $formdata) { echo '

      '; } else { // we force, so delete all conflicting before inserting foreach ($conflicts as $conflict) { - $cslot = $scheduler->get_slot($conflict->id); - $cslot->delete(); + if ($conflict->schedulerid == $scheduler->id) { + //scheduler "local" conflict + $cslot = $scheduler->get_slot($conflict->id); + $cslot->delete(); + } else { + //scheduler "remote" conflict + $remote_sceduler = new StdClass; + $remote_sceduler = scheduler_instance::load_by_id($conflict->schedulerid); + $cslot = $remote_sceduler->get_slot($conflict->id); + $cslot->delete(); + unset($remote_sceduler); + } } } } @@ -179,8 +189,18 @@ function scheduler_action_doaddaperiodsession($scheduler, $formdata) { } else { // we force, so delete all conflicting before inserting foreach($conflicts as $conflict){ - $cslot = $scheduler->get_slot($conflict->id); - $cslot->delete(); + if ($conflict->schedulerid == $scheduler->id) { + //scheduler "local" conflict + $cslot = $scheduler->get_slot($conflict->id); + $cslot->delete(); + } else { + //scheduler "remote" conflict + $remote_sceduler = new StdClass; + $remote_sceduler = scheduler_instance::load_by_id($conflict->schedulerid); + $cslot = $remote_sceduler->get_slot($conflict->id); + $cslot->delete(); + unset($remote_sceduler); + } } } } From f60db65498e8befb534f77ef8af5e55c82fdbf3e Mon Sep 17 00:00:00 2001 From: Andriy Semenets Date: Sat, 5 Nov 2016 19:27:55 +0200 Subject: [PATCH 14/16] Moodle 3.1 version changes adopted in general --- lang/en/scheduler.php | 5 ++--- slotforms.php | 36 +++++++++++++++++++----------------- teacherview.controller.php | 1 - teacherview.php | 17 +++++++++-------- version.php | 2 +- 5 files changed, 31 insertions(+), 30 deletions(-) diff --git a/lang/en/scheduler.php b/lang/en/scheduler.php index 65c3901e..f0bd7a62 100644 --- a/lang/en/scheduler.php +++ b/lang/en/scheduler.php @@ -55,9 +55,8 @@ $string['addappointment'] = 'Add another student'; $string['addcommands'] = 'Add slots'; $string['addondays'] = 'Add appointments on'; -$string['addaperiodsession'] = 'Add multiple slots free';//@TDMU -$string['addsession'] = 'Add repeated slots';//@TDMU-renamed -$string['addsession'] = 'Add repeated slots'; +$string['addaperiodsession'] = 'Add repeated slots (via calendar)'; +$string['addsession'] = 'Add repeated slots (by weekdays)'; $string['addsingleslot'] = 'Add single slot'; $string['addslot'] = 'You can add additional appointment slots at any time.'; $string['addstudenttogroup'] = 'Add this student to appointment group'; diff --git a/slotforms.php b/slotforms.php index bfb9e7de..3b80296c 100644 --- a/slotforms.php +++ b/slotforms.php @@ -539,7 +539,7 @@ public function validation($data, $files) { return $errors; } } -//TDMU + class scheduler_addaperiodsession_form extends scheduler_slotform_base { protected function definition() { @@ -547,9 +547,10 @@ protected function definition() { global $DB, $CFG, $COURSE; $mform = $this->_form; - + $listdates = ""; $mform->addElement('hidden', 'getlistdates', $listdates); + // Define Calendar panel $mform->addElement('html', '
      '); $mform->addElement('html', '
      '); @@ -563,15 +564,16 @@ protected function definition() { for ($i=0; $i<60; $i+=5) { $minutes[$i] = sprintf("%02d", $i); } - $starttimegroup = array(); - $starttimegroup[] = $mform->createElement('select', 'starthour', get_string('hour', 'form'), $hours); - $starttimegroup[] = $mform->createElement('select', 'startminute', get_string('minute', 'form'), $minutes); - $mform->addGroup ($starttimegroup, 'starttime', get_string('starttime', 'scheduler'), null, false); - $endtimegroup = array(); - $endtimegroup[] = $mform->createElement('select', 'endhour', get_string('hour', 'form'), $hours); - $endtimegroup[] = $mform->createElement('select', 'endminute', get_string('minute', 'form'), $minutes); - $mform->addGroup ($endtimegroup, 'endtime', get_string('endtime', 'scheduler'), null, false); + $timegroup = array(); + $timegroup[] = $mform->createElement('static', 'timefrom', '', get_string('timefrom', 'scheduler')); + $timegroup[] = $mform->createElement('select', 'starthour', get_string('hour', 'form'), $hours); + $timegroup[] = $mform->createElement('select', 'startminute', get_string('minute', 'form'), $minutes); + $timegroup[] = $mform->createElement('static', 'timeto', '', get_string('timeto', 'scheduler')); + $timegroup[] = $mform->createElement('select', 'endhour', get_string('hour', 'form'), $hours); + $timegroup[] = $mform->createElement('select', 'endminute', get_string('minute', 'form'), $minutes); + $mform->addGroup($timegroup, 'timerange', get_string('timerange', 'scheduler'), null, false); + // Divide into slots? $mform->addElement('selectyesno', 'divide', get_string('divide', 'scheduler')); $mform->setDefault('divide', 1); @@ -579,17 +581,17 @@ protected function definition() { // Duration of the slot $this->add_duration_field('minutesperslot'); + // Break between slots + $this->add_minutes_field('break', 'break', 0, 'minutes'); + + // Force when overlap? + $mform->addElement('selectyesno', 'forcewhenoverlap', get_string('forcewhenoverlap', 'scheduler')); + // Ignore conflict checkbox $mform->addElement('checkbox', 'ignoreconflicts', get_string('ignoreconflicts', 'scheduler')); $mform->setDefault('ignoreconflicts', false); $mform->addHelpButton('ignoreconflicts', 'ignoreconflicts', 'scheduler'); - // Break between slots - $this->add_minutes_field('break', 'break', 0, 'minutes'); - - // Force when overlap? - $mform->addElement('selectyesno', 'forcewhenoverlap', get_string('forcewhenoverlap', 'scheduler')); - // Common fields $this->add_base_fields(); @@ -642,7 +644,7 @@ public function validation($data, $files) { $errors['breakgroup'] = get_string('breaknotnegative', 'scheduler'); } - // TODO conflict checks + // Conflict checks are now being done after submitting the form. return $errors; } diff --git a/teacherview.controller.php b/teacherview.controller.php index c76af27d..8a891e53 100644 --- a/teacherview.controller.php +++ b/teacherview.controller.php @@ -176,7 +176,6 @@ function scheduler_delete_slots_from_ui(array $slots, $action) { echo $output->action_message($msg); } -/************************************ Saving a aperiod session with slots ********************************/ function scheduler_action_doaddaperiodsession($scheduler, $formdata) { global $DB, $output; diff --git a/teacherview.php b/teacherview.php index 4889e811..2ee63ba2 100644 --- a/teacherview.php +++ b/teacherview.php @@ -163,7 +163,7 @@ function scheduler_print_schedulebox(scheduler_instance $scheduler, $studentid, } } -/************************************ Add session multiple slots (weekly) form ****************************************/ +/************************************ Add session multiple slots (by weekdays) form ****************************************/ if ($action == 'addsession') { $actionurl = new moodle_url('/mod/scheduler/view.php', @@ -189,22 +189,23 @@ function scheduler_print_schedulebox(scheduler_instance $scheduler, $studentid, } } -/************************************ Add session multiple slots (aperiodically) form ************************************/ +/************************************ Add session multiple slots (via YUI calendar) form ************************************/ if ($action == 'addaperiodsession') { - //need to localization option - $courselang = substr($COURSE->lang, 0, 2); + + $courselang = substr($COURSE->lang, 0, 2); //need to localization option $actionurl = new moodle_url('/mod/scheduler/view.php', array('what' => 'addaperiodsession', 'id' => $cm->id, 'subpage' => $subpage)); $returnurl = new moodle_url('/mod/scheduler/view.php', array('what' => 'view', 'id' => $cm->id, 'subpage' => $subpage)); - if (!scheduler_has_teachers($context)) { + if (!$scheduler->has_available_teachers()) { print_error('needteachers', 'scheduler', $returnurl); - } - //create form + } + $mform = new scheduler_addaperiodsession_form($actionurl, $scheduler, $cm, $usergroups); - //process form responce + + //process form response if ($mform->is_cancelled()) { redirect($returnurl); } else if ($formdata = $mform->get_data()) { diff --git a/version.php b/version.php index 44b882b2..3a777d4d 100644 --- a/version.php +++ b/version.php @@ -15,7 +15,7 @@ */ $plugin->component = 'mod_scheduler'; // Full name of the plugin (used for diagnostics). -$plugin->version = 2016100500; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2016103000; // The current module version (Date: YYYYMMDDXX). $plugin->release = '3.x dev'; // Human-friendly version name. $plugin->requires = 2016052300; // Requires Moodle 3.1. $plugin->maturity = MATURITY_ALPHA; // Alpha development code - not for production sites! From 091767e4914eae3482d00487547ee9b82913df1c Mon Sep 17 00:00:00 2001 From: Andriy Semenets Date: Sat, 5 Nov 2016 20:37:37 +0200 Subject: [PATCH 15/16] Adopt conflict management according v.3.1. style --- teacherview.controller.php | 86 +++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 44 deletions(-) diff --git a/teacherview.controller.php b/teacherview.controller.php index 8a891e53..ac5aedf7 100644 --- a/teacherview.controller.php +++ b/teacherview.controller.php @@ -181,6 +181,8 @@ function scheduler_action_doaddaperiodsession($scheduler, $formdata) { global $DB, $output; $data = (object) $formdata; + + $listdatesarr = json_decode($data->getlistdates, true); // Create as many slots of $duration on the given dates list $listdates and that do not conflict. $countslots = 0; @@ -189,14 +191,15 @@ function scheduler_action_doaddaperiodsession($scheduler, $formdata) { $slot->schedulerid = $scheduler->id; $slot->teacherid = $data->teacherid; $slot->appointmentlocation = $data->appointmentlocation; - $slot->reuse = $data->reuse; - $slot->exclusivity = $data->exclusivity; - $slot->duration = $data->duration; + $slot->exclusivity = $data->exclusivityenable ? $data->exclusivity : 0; + if ($data->divide) { + $slot->duration = $data->duration; + } else { + $slot->duration = $data->endhour * 60 + $data->endminute - $data->starthour * 60 - $data->startminute; + }; $slot->notes = ''; $slot->notesformat = FORMAT_HTML; $slot->timemodified = time(); - - $listdatesarr = json_decode($data->getlistdates, true); for ($d = 0; $d <= count($listdatesarr[0])-1; $d ++){ $year = date("Y", strtotime($listdatesarr[0][$d])); @@ -222,51 +225,46 @@ function scheduler_action_doaddaperiodsession($scheduler, $formdata) { $slot->emaildate = make_timestamp($eventdate['year'], $eventdate['mon'], $eventdate['mday'], 0, 0) - $data->emaildaterel; } - while ($slot->starttime <= $data->timeend - $data->duration * 60) { - //TDMU exclusivity check-out - if (isset($data->ignoreconflicts)) { - $exclusive_condition = true; + while ($slot->starttime <= $data->timeend - $data->duration * 60) { + if (!isset($data->ignoreconflicts)) { + //check against ALL conflicts + $conflicts = $scheduler->get_conflicts($data->timestart, $data->timestart + $slot->duration * 60, + $data->teacherid, 0, SCHEDULER_ALL); } else { - $exclusive_condition = false; + //check against LOCAL conflicts only + $conflicts = $scheduler->get_conflicts($data->timestart, $data->timestart + $slot->duration * 60, + $data->teacherid, 0, SCHEDULER_SELF); } - $conflictsRemote = scheduler_get_conflicts($scheduler->id, $data->timestart, $data->timestart + $data->duration * 60, $data->teacherid, 0, SCHEDULER_OTHERS, $exclusive_condition); - $conflictsLocal = scheduler_get_conflicts($scheduler->id, $data->timestart, $data->timestart + $data->duration * 60, $data->teacherid, 0, SCHEDULER_SELF, true); - if (!$conflictsRemote) $conflictsRemote = array(); - if (!$conflictsLocal) $conflictsLocal = array(); - $conflicts = $conflictsRemote + $conflictsLocal; + $resolvable = (boolean) $data->forcewhenoverlap; + foreach ($conflicts as $conflict) { + $resolvable = $resolvable + && $conflict->isself == 1 // Do not delete slots outside the current scheduler. + && $conflict->numstudents == 0; // Do not delete slots with bookings. + } + if ($conflicts) { - if (!$data->forcewhenoverlap){ - print_string('conflictingslots', 'scheduler'); - echo '
        '; - foreach ($conflicts as $aconflict){ - $conflictinfo = scheduler_get_courseinfobyslotid($aconflict->id);//TDMU - $msg = $output->userdate($conflictinfo->starttime) . ', ' . $output->usertime($conflictinfo->starttime) . ': '; - $msg .= s($conflictinfo->schedname). ' '.get_string('incourse', 'scheduler') . ' '; - $msg .= $conflictinfo->shortname . ' - ' . $conflictinfo->fullname; - echo html_writer::tag('li', $msg); - } - echo '

      '; - } - else { // we force, so delete all conflicting before inserting - foreach($conflicts as $conflict){ - if ($conflict->schedulerid == $scheduler->id) { - //scheduler "local" conflict - $cslot = $scheduler->get_slot($conflict->id); - $cslot->delete(); - } else { - //scheduler "remote" conflict - $remote_sceduler = new StdClass; - $remote_sceduler = scheduler_instance::load_by_id($conflict->schedulerid); - $cslot = $remote_sceduler->get_slot($conflict->id); - $cslot->delete(); - unset($remote_sceduler); - } + $cl = new scheduler_conflict_list(); + $cl->add_conflicts($conflicts); + if (!$resolvable) { + print_string('conflictingslots', 'scheduler', userdate($data->timestart)); + echo $output->doc_link('mod/scheduler/conflict', '', true); + echo $output->render($cl); + } else { // We force, so delete all conflicting before inserting. + foreach ($conflicts as $conflict) { + $cslot = $scheduler->get_slot($conflict->id); + \mod_scheduler\event\slot_deleted::create_from_slot($cslot, 'addsession-conflict')->trigger(); + $cslot->delete(); } + print_string('deletedconflictingslots', 'scheduler', userdate($data->timestart)); + echo $output->doc_link('mod/scheduler/conflict', '', true); + echo $output->render($cl); } - } - else { - $DB->insert_record('scheduler_slots', $slot, false, true); + } + if (!$conflicts || $resolvable) { + $slotid = $DB->insert_record('scheduler_slots', $slot, true, true); + $slotobj = $scheduler->get_slot($slotid); + \mod_scheduler\event\slot_added::create_from_slot($slotobj)->trigger(); $countslots++; } $slot->starttime += ($data->duration + $data->break) * 60; From cb73d917509fef2cfc3418551d0b3eb5504f13c3 Mon Sep 17 00:00:00 2001 From: Andriy Semenets Date: Sat, 5 Nov 2016 21:06:50 +0200 Subject: [PATCH 16/16] remove obsolete functions --- locallib.php | 135 --------------------------------------------------- 1 file changed, 135 deletions(-) diff --git a/locallib.php b/locallib.php index d7e1f08b..f41c92bf 100644 --- a/locallib.php +++ b/locallib.php @@ -19,141 +19,6 @@ /* Events related functions */ -/** -* Get a course info by the sheduler slot id -* @param int $slotid the any sheduler slot id -* @return a course shortname, fullname and selected slot starttime -*/ -function scheduler_get_courseinfobyslotid($slotid) { - global $CFG, $DB; - - $sql = " - SELECT - c.id, - c.fullname, - c.shortname, - s.name as schedname, - sl.starttime - FROM - {course} c, - {scheduler} s, - {scheduler_slots} sl - WHERE - s.course = c.id AND - sl.schedulerid = s.id AND - sl.id = {$slotid} - "; - $courseshortinfo = $DB->get_record_sql($sql); - - return $courseshortinfo; -} - -/** - * Returns an array of slots that would overlap with this one. - * @param int $schedulerid the current activity module id - * @param int $starttimethe start of time slot as a timestamp - * @param int $endtime end of time slot as a timestamp - * @param int $teacher if not null, the id of the teacher constraint, 0 otherwise standas for "all teachers" - * @param int $others selects where to search for conflicts, [SCHEDULER_SELF, SCHEDULER_OTHERS, SCHEDULER_ALL] - * @param boolean $careexclusive if false, conflict will consider all slots wether exlusive or not. Use it for testing if user is appointed in the given scope. - * @uses $CFG - * @uses $DB - * @return array array of conflicting slots - */ -function scheduler_get_conflicts($schedulerid, $starttime, $endtime, $teacher=0, $student=0, $others=SCHEDULER_SELF, $careexclusive=true) { - global $CFG, $DB; - - switch ($others){ - case SCHEDULER_SELF: - $schedulerScope = "s.schedulerid = {$schedulerid} AND "; - break; - case SCHEDULER_OTHERS: - $schedulerScope = "s.schedulerid != {$schedulerid} AND "; - break; - default: - $schedulerScope = ''; - } - $teacherScope = ($teacher != 0) ? "s.teacherid = {$teacher} AND " : '' ; - $studentJoin = ($student != 0) ? "JOIN {scheduler_appointment} a ON a.slotid = s.id AND a.studentid = {$student} " : '' ; - $exclusiveClause = ($careexclusive) ? "exclusivity != 0 AND " : '' ; - $timeClause = "( (s.starttime <= {$starttime} AND s.starttime + s.duration * 60 > {$starttime}) OR ". - " (s.starttime < {$endtime} AND s.starttime + s.duration * 60 >= {$endtime}) OR ". - " (s.starttime >= {$starttime} AND s.starttime + s.duration * 60 <= {$endtime}) ) "; - - $sql = 'SELECT s.* from {scheduler_slots} s '.$studentJoin.' WHERE '. - $schedulerScope.$teacherScope.$exclusiveClause.$timeClause; - - $conflicting = $DB->get_records_sql($sql); - - return $conflicting; -} - - -/** - * checks if user has an appointment in this scheduler - * @param object $userlist - * @param object $scheduler - * @param boolean $student, if true, is a student, a teacher otherwise - * @param boolean $unattended, if true, only checks for unattended slots - * @param string $otherthan giving a slotid, excludes this slot from the search - * @uses $CFG - * @uses $DB - * @return the count of records - */ -function scheduler_has_slot($userlist, &$scheduler, $student=true, $unattended = false, $otherthan = 0){ - global $CFG, $DB; - - $userlist = str_replace(',', "','", $userlist); - - $unattendedClause = ($unattended) ? ' AND a.attended = 0 ' : '' ; - $otherthanClause = ($otherthan) ? " AND a.slotid != $otherthan " : '' ; - - if ($student){ - $sql = " - SELECT - COUNT(*) - FROM - {scheduler_slots} s, - {scheduler_appointment} a - WHERE - a.slotid = s.id AND - s.schedulerid = ? AND - a.studentid IN ('{$userlist}') - $unattendedClause - $otherthanClause - "; - return $DB->count_records_sql($sql, array($scheduler->id)); - } else { - return $DB->count_records('scheduler_slots', array('teacherid' => $userlist, 'schedulerid' => $scheduler->id)); - } -} - -/** - * returns an array of appointed user records for a certain slot. - * @param int $slotid - * @uses $CFG - * @uses $DB - * @return an array of users - */ -function scheduler_get_appointed($slotid){ - global $CFG, $DB; - - $sql = " - SELECT - u.* - FROM - {user} u, - {scheduler_appointment} a - WHERE - u.id = a.studentid AND - a.slotid = ? - "; - return $DB->get_records_sql($sql, array($slotid)); -} - - -/// Events related functions - /** * Will delete calendar events for a given scheduler slot, and not complain if the record does not exist. * The only argument this function requires is the complete database record of a scheduler slot.