From 6d812f5ea9b8f2fbc0aef679d1a613b205e0ec1b Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Tue, 1 Aug 2017 10:13:14 +1200 Subject: [PATCH] Swap multiple sessions settings and student recording settings also add new setting to allow expanded to be set for both setting groups. --- add_form.php | 85 ++++++++++++++++++++++-------------------- lang/en/attendance.php | 4 ++ settings.php | 8 ++++ 3 files changed, 56 insertions(+), 41 deletions(-) diff --git a/add_form.php b/add_form.php index fcc000f..21b4ea1 100644 --- a/add_form.php +++ b/add_form.php @@ -125,10 +125,53 @@ class mod_attendance_add_form extends moodleform { array('maxfiles' => EDITOR_UNLIMITED_FILES, 'noclean' => true, 'context' => $modcontext)); $mform->setType('sdescription', PARAM_RAW); + // For multiple sessions. + $mform->addElement('header', 'headeraddmultiplesessions', get_string('addmultiplesessions', 'attendance')); + if (!empty($pluginconfig->multisessionexpanded)) { + $mform->setExpanded('headeraddmultiplesessions'); + } + $mform->addElement('checkbox', 'addmultiply', '', get_string('repeatasfollows', 'attendance')); + $mform->addHelpButton('addmultiply', 'createmultiplesessions', 'attendance'); + + $sdays = array(); + if ($CFG->calendar_startwday === '0') { // Week start from sunday. + $sdays[] =& $mform->createElement('checkbox', 'Sun', '', get_string('sunday', 'calendar')); + } + $sdays[] =& $mform->createElement('checkbox', 'Mon', '', get_string('monday', 'calendar')); + $sdays[] =& $mform->createElement('checkbox', 'Tue', '', get_string('tuesday', 'calendar')); + $sdays[] =& $mform->createElement('checkbox', 'Wed', '', get_string('wednesday', 'calendar')); + $sdays[] =& $mform->createElement('checkbox', 'Thu', '', get_string('thursday', 'calendar')); + $sdays[] =& $mform->createElement('checkbox', 'Fri', '', get_string('friday', 'calendar')); + $sdays[] =& $mform->createElement('checkbox', 'Sat', '', get_string('saturday', 'calendar')); + if ($CFG->calendar_startwday !== '0') { // Week start from sunday. + $sdays[] =& $mform->createElement('checkbox', 'Sun', '', get_string('sunday', 'calendar')); + } + $mform->addGroup($sdays, 'sdays', get_string('repeaton', 'attendance'), array('     '), true); + $mform->disabledIf('sdays', 'addmultiply', 'notchecked'); + + $period = array(1 => 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36); + $periodgroup = array(); + $periodgroup[] =& $mform->createElement('select', 'period', '', $period, false, true); + $periodgroup[] =& $mform->createElement('static', 'perioddesc', '', get_string('week', 'attendance')); + $mform->addGroup($periodgroup, 'periodgroup', get_string('repeatevery', 'attendance'), array(' '), false); + $mform->disabledIf('periodgroup', 'addmultiply', 'notchecked'); + + $mform->addElement('date_selector', 'sessionenddate', get_string('repeatuntil', 'attendance')); + $mform->disabledIf('sessionenddate', 'addmultiply', 'notchecked'); + + $mform->addElement('hidden', 'coursestartdate', $course->startdate); + $mform->setType('coursestartdate', PARAM_INT); + + $mform->addElement('hidden', 'previoussessiondate', 0); + $mform->setType('previoussessiondate', PARAM_INT); + // Students can mark own attendance. if (!empty(get_config('attendance', 'studentscanmark'))) { $mform->addElement('header', 'headerstudentmarking', get_string('studentmarking', 'attendance'), true); - $mform->setExpanded('headerstudentmarking'); + if (!empty($pluginconfig->studentrecordingexpanded)) { + $mform->setExpanded('headerstudentmarking'); + } $mform->addElement('checkbox', 'studentscanmark', '', get_string('studentscanmark', 'attendance')); $mform->addHelpButton('studentscanmark', 'studentscanmark', 'attendance'); @@ -194,46 +237,6 @@ class mod_attendance_add_form extends moodleform { $mform->setType('subnet', PARAM_TEXT); } - // For multiple sessions. - - $mform->addElement('header', 'headeraddmultiplesessions', get_string('addmultiplesessions', 'attendance')); - - $mform->addElement('checkbox', 'addmultiply', '', get_string('repeatasfollows', 'attendance')); - $mform->addHelpButton('addmultiply', 'createmultiplesessions', 'attendance'); - - $sdays = array(); - if ($CFG->calendar_startwday === '0') { // Week start from sunday. - $sdays[] =& $mform->createElement('checkbox', 'Sun', '', get_string('sunday', 'calendar')); - } - $sdays[] =& $mform->createElement('checkbox', 'Mon', '', get_string('monday', 'calendar')); - $sdays[] =& $mform->createElement('checkbox', 'Tue', '', get_string('tuesday', 'calendar')); - $sdays[] =& $mform->createElement('checkbox', 'Wed', '', get_string('wednesday', 'calendar')); - $sdays[] =& $mform->createElement('checkbox', 'Thu', '', get_string('thursday', 'calendar')); - $sdays[] =& $mform->createElement('checkbox', 'Fri', '', get_string('friday', 'calendar')); - $sdays[] =& $mform->createElement('checkbox', 'Sat', '', get_string('saturday', 'calendar')); - if ($CFG->calendar_startwday !== '0') { // Week start from sunday. - $sdays[] =& $mform->createElement('checkbox', 'Sun', '', get_string('sunday', 'calendar')); - } - $mform->addGroup($sdays, 'sdays', get_string('repeaton', 'attendance'), array('     '), true); - $mform->disabledIf('sdays', 'addmultiply', 'notchecked'); - - $period = array(1 => 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36); - $periodgroup = array(); - $periodgroup[] =& $mform->createElement('select', 'period', '', $period, false, true); - $periodgroup[] =& $mform->createElement('static', 'perioddesc', '', get_string('week', 'attendance')); - $mform->addGroup($periodgroup, 'periodgroup', get_string('repeatevery', 'attendance'), array(' '), false); - $mform->disabledIf('periodgroup', 'addmultiply', 'notchecked'); - - $mform->addElement('date_selector', 'sessionenddate', get_string('repeatuntil', 'attendance')); - $mform->disabledIf('sessionenddate', 'addmultiply', 'notchecked'); - - $mform->addElement('hidden', 'coursestartdate', $course->startdate); - $mform->setType('coursestartdate', PARAM_INT); - - $mform->addElement('hidden', 'previoussessiondate', 0); - $mform->setType('previoussessiondate', PARAM_INT); - $this->add_action_buttons(true, get_string('add', 'attendance')); } diff --git a/lang/en/attendance.php b/lang/en/attendance.php index 93da957..df0d3f7 100644 --- a/lang/en/attendance.php +++ b/lang/en/attendance.php @@ -241,6 +241,8 @@ $string['months'] = 'Months'; $string['moreattendance'] = 'Attendance has been successfully taken for this page'; $string['moveleft'] = 'Move left'; $string['moveright'] = 'Move right'; +$string['multisessionexpanded'] = 'Multiple sessions expanded'; +$string['multisessionexpanded_desc'] = 'Show the "Multiple sessions" settings as expanded by default when creating new sessions.'; $string['mustselectusers'] = 'Must select users to export'; $string['newdate'] = 'New date'; $string['newduration'] = 'New duration'; @@ -410,6 +412,8 @@ $string['studentavailability_help'] = 'When students are marking their own atten $string['studentid'] = 'Student ID'; $string['studentmarking'] = 'Student recording'; $string['studentpassword'] = 'Student password'; +$string['studentrecordingexpanded'] = 'Student recording expanded'; +$string['studentrecordingexpanded_desc'] = 'Show the "Student recording" settings as expanded by default when creating new sessions.'; $string['studentscanmark'] = 'Allow students to record own attendance'; $string['studentscanmark_desc'] = 'If checked, teachers will be able to allow students to mark their own attendance.'; $string['studentscanmark_help'] = 'If checked students will be able to change their own attendance status for the session.'; diff --git a/settings.php b/settings.php index d89f3ad..42c8eb4 100644 --- a/settings.php +++ b/settings.php @@ -74,6 +74,14 @@ if ($ADMIN->fulltree) { get_string('defaultview', 'attendance'), get_string('defaultview_desc', 'attendance'), ATT_VIEW_WEEKS, $options)); + $settings->add(new admin_setting_configcheckbox('attendance/multisessionexpanded', + get_string('multisessionexpanded', 'attendance'), + get_string('multisessionexpanded_desc', 'attendance'), 0)); + + $settings->add(new admin_setting_configcheckbox('attendance/studentrecordingexpanded', + get_string('studentrecordingexpanded', 'attendance'), + get_string('studentrecordingexpanded_desc', 'attendance'), 1)); + $settings->add(new admin_setting_configcheckbox('attendance/enablecalendar', get_string('enablecalendar', 'attendance'), get_string('enablecalendar_desc', 'attendance'), 1));