Browse Source

Prevent automarking settings from being used if setunmarked status not in place.

40-behatfixes
Dan Marsden 3 years ago
parent
commit
4e4c2542d2
  1. 21
      classes/form/addsession.php
  2. 23
      classes/form/updatesession.php

21
classes/form/addsession.php

@ -207,19 +207,20 @@ class addsession extends moodleform {
$mform->addElement('hidden', 'studentscanmark', '0'); $mform->addElement('hidden', 'studentscanmark', '0');
$mform->settype('studentscanmark', PARAM_INT); $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); $automarkcmoptions = attendance_get_coursemodulenames($course->id);
$mform->setType('automark', PARAM_INT);
$mform->addHelpButton('automark', 'automark', 'attendance');
$mform->setDefault('automark', $this->_customdata['att']->automark);
$automarkcmoptions = attendance_get_coursemodulenames($course->id); $mform->addElement('select', 'automarkcmid', get_string('selectactivity', 'attendance'), $automarkcmoptions);
$mform->setType('automarkcmid', PARAM_INT);
$mform->addElement('select', 'automarkcmid', get_string('selectactivity', 'attendance'), $automarkcmoptions); $mform->hideif('automarkcmid', 'automark', 'neq', '3');
$mform->setType('automarkcmid', PARAM_INT); }
$mform->hideif('automarkcmid', 'automark', 'neq', '3');
if (!empty($studentscanmark)) { if (!empty($studentscanmark)) {
$mgroup = array(); $mgroup = array();

23
classes/form/updatesession.php

@ -143,21 +143,22 @@ class updatesession extends \moodleform {
$mform->settype('studentscanmark', PARAM_INT); $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->addElement('select', 'automark', get_string('automark', 'attendance'), $options2);
$mform->setType('automark', PARAM_INT); $mform->setType('automark', PARAM_INT);
$mform->addHelpButton('automark', 'automark', 'attendance'); $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->addElement('select', 'automarkcmid', get_string('selectactivity', 'attendance'), $automarkcmoptions2);
$mform->setType('automarkcmid', PARAM_INT); $mform->setType('automarkcmid', PARAM_INT);
$mform->hideif('automarkcmid', 'automark', 'neq', '3'); $mform->hideif('automarkcmid', 'automark', 'neq', '3');
if (!empty($sess->automarkcompleted)) { if (!empty($sess->automarkcompleted)) {
$mform->hardFreeze('automarkcmid,automark,studentscanmark'); $mform->hardFreeze('automarkcmid,automark,studentscanmark');
}
} }
if (!empty($studentscanmark)) { if (!empty($studentscanmark)) {
$mform->addElement('text', 'studentpassword', get_string('studentpassword', 'attendance')); $mform->addElement('text', 'studentpassword', get_string('studentpassword', 'attendance'));
$mform->setType('studentpassword', PARAM_TEXT); $mform->setType('studentpassword', PARAM_TEXT);

Loading…
Cancel
Save