|
|
@ -28,6 +28,7 @@ require_once(dirname(__FILE__).'/locallib.php'); |
|
|
|
require_once(dirname(__FILE__).'/renderables.php'); |
|
|
|
require_once(dirname(__FILE__).'/renderhelpers.php'); |
|
|
|
require_once($CFG->libdir.'/tablelib.php'); |
|
|
|
require_once($CFG->libdir.'/moodlelib.php'); |
|
|
|
|
|
|
|
/** |
|
|
|
* Attendance module renderer class |
|
|
@ -414,6 +415,8 @@ class mod_attendance_renderer extends plugin_renderer_base { |
|
|
|
* @return string |
|
|
|
*/ |
|
|
|
protected function render_attendance_take_data(attendance_take_data $takedata) { |
|
|
|
user_preference_allow_ajax_update('mod_attendance_statusdropdown', PARAM_RAW); |
|
|
|
|
|
|
|
$controls = $this->render_attendance_take_controls($takedata); |
|
|
|
$table = html_writer::start_div('no-overflow'); |
|
|
|
if ($takedata->pageparams->viewmode == mod_attendance_take_page_params::SORTED_LIST) { |
|
|
@ -595,6 +598,26 @@ class mod_attendance_renderer extends plugin_renderer_base { |
|
|
|
return $controls; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Render statusdropdown |
|
|
|
* |
|
|
|
* @param string $preference |
|
|
|
* @return string |
|
|
|
*/ |
|
|
|
private function render_statusdropdown($preference) { |
|
|
|
if ($preference == 'unselected') { |
|
|
|
return " <select id='setallstatus-select'> |
|
|
|
<option value='all'>".get_string('statusall', 'attendance')."</option> |
|
|
|
<option selected value='unselected'>".get_string('statusunselected', 'attendance')."</option> |
|
|
|
</select>"; |
|
|
|
} else { |
|
|
|
return " <select id='setallstatus-select'> |
|
|
|
<option selected value='all'>".get_string('statusall', 'attendance')."</option> |
|
|
|
<option value='unselected'>".get_string('statusunselected', 'attendance')."</option> |
|
|
|
</select>"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Render take list. |
|
|
|
* |
|
|
@ -649,7 +672,11 @@ class mod_attendance_renderer extends plugin_renderer_base { |
|
|
|
foreach ($extrasearchfields as $field) { |
|
|
|
$row->cells[] = ''; |
|
|
|
} |
|
|
|
$row->cells[] = html_writer::div(get_string('setallstatuses', 'attendance'), 'setallstatuses'); |
|
|
|
|
|
|
|
$selectmenu = $this->render_statusdropdown(get_user_preferences('mod_attendance_statusdropdown')); |
|
|
|
|
|
|
|
$row->cells[] = html_writer::div(get_string('setallstatuses', 'attendance'). |
|
|
|
$selectmenu, 'setallstatuses'); |
|
|
|
foreach ($takedata->statuses as $st) { |
|
|
|
$attribs = array( |
|
|
|
'id' => 'radiocheckstatus'.$st->id, |
|
|
@ -663,11 +690,13 @@ class mod_attendance_renderer extends plugin_renderer_base { |
|
|
|
$PAGE->requires->js_amd_inline(" |
|
|
|
require(['jquery'], function($) { |
|
|
|
$('#radiocheckstatus".$st->id."').click(function(e) { |
|
|
|
if (e.shiftKey) { |
|
|
|
if ($('#setallstatus-select').val() == 'all') { |
|
|
|
$('#attendancetakeform').find('.st".$st->id."').prop('checked', true); |
|
|
|
M.util.set_user_preference('mod_attendance_statusdropdown','all'); |
|
|
|
} |
|
|
|
else { |
|
|
|
$('#attendancetakeform').find('input:indeterminate.st".$st->id."').prop('checked', true); |
|
|
|
M.util.set_user_preference('mod_attendance_statusdropdown','unselected'); |
|
|
|
} |
|
|
|
}); |
|
|
|
});"); |
|
|
@ -726,7 +755,12 @@ class mod_attendance_renderer extends plugin_renderer_base { |
|
|
|
} |
|
|
|
$table->attributes['class'] = 'generaltable takegrid'; |
|
|
|
$table->headspan = $takedata->pageparams->gridcols; |
|
|
|
|
|
|
|
$selectmenu = $this->render_statusdropdown(get_user_preferences('mod_attendance_statusdropdown')); |
|
|
|
|
|
|
|
$head = array(); |
|
|
|
$head[] = html_writer::div(get_string('setallstatuses', 'attendance'). |
|
|
|
$selectmenu, 'setallstatuses'); |
|
|
|
foreach ($takedata->statuses as $st) { |
|
|
|
$head[] = html_writer::link("#", $st->acronym, array('id' => 'checkstatus'.$st->id, |
|
|
|
'title' => get_string('setallstatusesto', 'attendance', $st->description))); |
|
|
@ -734,11 +768,13 @@ class mod_attendance_renderer extends plugin_renderer_base { |
|
|
|
$PAGE->requires->js_amd_inline(" |
|
|
|
require(['jquery'], function($) { |
|
|
|
$('#checkstatus".$st->id."').click(function(e) { |
|
|
|
if (e.shiftKey) { |
|
|
|
if ($('#setallstatus-select').val() == 'unselected') { |
|
|
|
$('#attendancetakeform').find('input:indeterminate.st".$st->id."').prop('checked', true); |
|
|
|
M.util.set_user_preference('mod_attendance_statusdropdown','unselected'); |
|
|
|
} |
|
|
|
else { |
|
|
|
$('#attendancetakeform').find('.st".$st->id."').prop('checked', true); |
|
|
|
M.util.set_user_preference('mod_attendance_statusdropdown','all'); |
|
|
|
} |
|
|
|
e.preventDefault(); |
|
|
|
}); |
|
|
|