diff --git a/classes/form/addsession.php b/classes/form/addsession.php index ece7d8b..331f1fe 100644 --- a/classes/form/addsession.php +++ b/classes/form/addsession.php @@ -207,19 +207,20 @@ class addsession extends moodleform { $mform->addElement('hidden', 'studentscanmark', '0'); $mform->settype('studentscanmark', PARAM_INT); } + if ($DB->record_exists('attendance_statuses', ['attendanceid' => $this->_customdata['att']->id, 'setunmarked' => 1])) { + $options = attendance_get_automarkoptions(); - $options = attendance_get_automarkoptions(); + $mform->addElement('select', 'automark', get_string('automark', 'attendance'), $options); + $mform->setType('automark', PARAM_INT); + $mform->addHelpButton('automark', 'automark', 'attendance'); + $mform->setDefault('automark', $this->_customdata['att']->automark); - $mform->addElement('select', 'automark', get_string('automark', 'attendance'), $options); - $mform->setType('automark', PARAM_INT); - $mform->addHelpButton('automark', 'automark', 'attendance'); - $mform->setDefault('automark', $this->_customdata['att']->automark); + $automarkcmoptions = attendance_get_coursemodulenames($course->id); - $automarkcmoptions = attendance_get_coursemodulenames($course->id); - - $mform->addElement('select', 'automarkcmid', get_string('selectactivity', 'attendance'), $automarkcmoptions); - $mform->setType('automarkcmid', PARAM_INT); - $mform->hideif('automarkcmid', 'automark', 'neq', '3'); + $mform->addElement('select', 'automarkcmid', get_string('selectactivity', 'attendance'), $automarkcmoptions); + $mform->setType('automarkcmid', PARAM_INT); + $mform->hideif('automarkcmid', 'automark', 'neq', '3'); + } if (!empty($studentscanmark)) { $mgroup = array(); diff --git a/classes/form/updatesession.php b/classes/form/updatesession.php index 140d538..e3bdab9 100644 --- a/classes/form/updatesession.php +++ b/classes/form/updatesession.php @@ -143,21 +143,22 @@ class updatesession extends \moodleform { $mform->settype('studentscanmark', PARAM_INT); } - $options2 = attendance_get_automarkoptions(); + if ($DB->record_exists('attendance_statuses', ['attendanceid' => $this->_customdata['att']->id, 'setunmarked' => 1])) { + $options2 = attendance_get_automarkoptions(); - $mform->addElement('select', 'automark', get_string('automark', 'attendance'), $options2); - $mform->setType('automark', PARAM_INT); - $mform->addHelpButton('automark', 'automark', 'attendance'); + $mform->addElement('select', 'automark', get_string('automark', 'attendance'), $options2); + $mform->setType('automark', PARAM_INT); + $mform->addHelpButton('automark', 'automark', 'attendance'); - $automarkcmoptions2 = attendance_get_coursemodulenames($COURSE->id); + $automarkcmoptions2 = attendance_get_coursemodulenames($COURSE->id); - $mform->addElement('select', 'automarkcmid', get_string('selectactivity', 'attendance'), $automarkcmoptions2); - $mform->setType('automarkcmid', PARAM_INT); - $mform->hideif('automarkcmid', 'automark', 'neq', '3'); - if (!empty($sess->automarkcompleted)) { - $mform->hardFreeze('automarkcmid,automark,studentscanmark'); + $mform->addElement('select', 'automarkcmid', get_string('selectactivity', 'attendance'), $automarkcmoptions2); + $mform->setType('automarkcmid', PARAM_INT); + $mform->hideif('automarkcmid', 'automark', 'neq', '3'); + if (!empty($sess->automarkcompleted)) { + $mform->hardFreeze('automarkcmid,automark,studentscanmark'); + } } - if (!empty($studentscanmark)) { $mform->addElement('text', 'studentpassword', get_string('studentpassword', 'attendance')); $mform->setType('studentpassword', PARAM_TEXT);