Browse Source

Fix #292 studentpassword undefined warning

also allow absenteereport setting to be updated.
MOODLE_33_STABLE
Dan Marsden 7 years ago
parent
commit
79c40ad826
  1. 3
      classes/structure.php
  2. 13
      locallib.php
  3. 7
      update_form.php

3
classes/structure.php

@ -523,6 +523,9 @@ class mod_attendance_structure {
$sess->subnet = '';
$sess->automark = 0;
$sess->automarkcompleted = 0;
if (!empty(get_config('attendance', 'enablewarnings'))) {
$sess->absenteereport = empty($formdata->absenteereport) ? 0 : 1;
}
if (!empty($formdata->autoassignstatus)) {
$sess->autoassignstatus = $formdata->autoassignstatus;
}

13
locallib.php

@ -537,6 +537,12 @@ function attendance_construct_sessions_data_for_add($formdata, mod_attendance_st
$sesendtime = $formdata->sestime['endhour'] * HOURSECS + $formdata->sestime['endminute'] * MINSECS;
$sessiondate = $formdata->sessiondate + $sesstarttime;
$duration = $sesendtime - $sesstarttime;
if (empty(get_config('attendance', 'enablewarnings'))) {
$absenteereport = get_config('attendance', 'absenteereport_default');
} else {
$absenteereport = empty($formdata->absenteereport) ? 0 : 1;
}
$now = time();
if (empty(get_config('attendance', 'studentscanmark'))) {
@ -576,6 +582,8 @@ function attendance_construct_sessions_data_for_add($formdata, mod_attendance_st
$sess->description = $formdata->sdescription['text'];
$sess->descriptionformat = $formdata->sdescription['format'];
$sess->timemodified = $now;
$sess->absenteereport = $absenteereport;
$sess->studentpassword = '';
if (isset($formdata->studentscanmark)) { // Students will be able to mark their own attendance.
$sess->studentscanmark = 1;
if (!empty($formdata->usedefaultsubnet)) {
@ -590,11 +598,10 @@ function attendance_construct_sessions_data_for_add($formdata, mod_attendance_st
$sess->automarkcompleted = 0;
if (!empty($formdata->randompassword)) {
$sess->studentpassword = attendance_random_string();
} else {
} else if (!empty($formdata->studentpassword)) {
$sess->studentpassword = $formdata->studentpassword;
}
} else {
$sess->studentpassword = '';
$sess->subnet = '';
$sess->automark = 0;
$sess->automarkcompleted = 0;
@ -623,7 +630,7 @@ function attendance_construct_sessions_data_for_add($formdata, mod_attendance_st
$sess->studentpassword = '';
$sess->automark = 0;
$sess->automarkcompleted = 0;
$sess->absenteereport = 1;
$sess->absenteereport = $absenteereport;
if (isset($formdata->studentscanmark) && !empty($formdata->studentscanmark)) {
// Students will be able to mark their own attendance.

7
update_form.php

@ -71,6 +71,7 @@ class mod_attendance_update_form extends moodleform {
'autoassignstatus' => $sess->autoassignstatus,
'subnet' => $sess->subnet,
'automark' => $sess->automark,
'absenteereport' => $sess->absenteereport,
'automarkcompleted' => 0);
if ($sess->subnet == $attendancesubnet) {
$data['usedefaultsubnet'] = 1;
@ -104,6 +105,12 @@ class mod_attendance_update_form extends moodleform {
array('rows' => 1, 'columns' => 80), $defopts);
$mform->setType('sdescription', PARAM_RAW);
// If warnings allow selector for reporting.
if (!empty(get_config('attendance', 'enablewarnings'))) {
$mform->addElement('checkbox', 'absenteereport', '', get_string('includeabsentee', 'attendance'));
$mform->addHelpButton('absenteereport', 'includeabsentee', 'attendance');
}
// Students can mark own attendance.
if (!empty(get_config('attendance', 'studentscanmark'))) {
$mform->addElement('header', 'headerstudentmarking', get_string('studentmarking', 'attendance'), true);

Loading…
Cancel
Save