if (!empty(get_config('attendance', 'studentscanmark'))) {
$mform->addElement('checkbox', 'studentscanmark', '', get_string('studentscanmark', 'attendance'));
$mform->addHelpButton('studentscanmark', 'studentscanmark', 'attendance');
+
+ $mform->addElement('text', 'studentpassword', get_string('studentpassword', 'attendance'));
+ $mform->setType('studentpassword', PARAM_TEXT);
+ $mform->addHelpButton('studentpassword', 'studentpassword', 'attendance');
+ $mform->disabledif('studentpassword', 'studentscanmark', 'notchecked');
} else {
$mform->addElement('hidden', 'studentscanmark', '0');
$mform->settype('studentscanmark', PARAM_INT);
$url = new moodle_url('/mod/attendance/view.php', array('id' => $cm->id));
redirect($url);
} else if ($fromform = $mform->get_data()) {
+ // check if password required and if set correctly.
+ if (!empty($attforsession->studentpassword) &&
+ $attforsession->studentpassword !== $fromform->studentpassword) {
+
+ $url = new moodle_url('/mod/attendance/attendance.php', array('sessid' => $id, 'sesskey' => sesskey()));
+ redirect($url, get_string('incorrectpassword', 'mod_attendance'));
+ }
+
if (!empty($fromform->status)) {
$success = $att->take_from_student($fromform);
$sessions = new backup_nested_element('sessions');
$session = new backup_nested_element('session', array('id'), array(
'groupid', 'sessdate', 'duration', 'lasttaken', 'lasttakenby',
- 'timemodified', 'description', 'descriptionformat', 'studentscanmark', 'statusset', 'caleventid'));
+ 'timemodified', 'description', 'descriptionformat', 'studentscanmark', 'studentpassword',
+ 'statusset', 'caleventid'));
// XML nodes declaration - user data.
$logs = new backup_nested_element('logs');
$sess->lasttaken = 0;
$sess->lasttakenby = 0;
$sess->studentscanmark = 0;
+
$event->add_record_snapshot('attendance_sessions', $sess);
$event->trigger();
}
$sess->description = $description;
$sess->descriptionformat = $formdata->sdescription['format'];
+ $sess->studentscanmark = 0;
+ $sess->studentpassword = '';
+
+ if (!empty(get_config('attendance', 'studentscanmark')) &&
+ !empty($formdata->studentscanmark)) {
+ $sess->studentscanmark = $formdata->studentscanmark;
+ $sess->studentpassword = $formdata->studentpassword;
+ }
+
$sess->timemodified = time();
$DB->update_record('attendance_sessions', $sess);
<FIELD NAME="description" TYPE="text" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="descriptionformat" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="studentscanmark" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
+ <FIELD NAME="studentpassword" TYPE="char" LENGTH="50" NOTNULL="true" DEFAULT="" SEQUENCE="false"/>
<FIELD NAME="statusset" TYPE="int" LENGTH="5" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Which set of statuses to use"/>
<FIELD NAME="caleventid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
</FIELDS>
upgrade_mod_savepoint(true, 2017020700, 'attendance');
}
+ if ($oldversion < 2017042800) {
+ $table = new xmldb_table('attendance_sessions');
+
+ $field = new xmldb_field('studentpassword');
+ $field->set_attributes(XMLDB_TYPE_CHAR, '50', null, null, null, '', 'studentscanmark');
+ if (!$dbman->field_exists($table, $field)) {
+ $dbman->add_field($table, $field);
+ }
+
+ upgrade_mod_savepoint(true, 2017042800, 'attendance');
+ }
+
return $result;
}
$string['includeall'] = 'Select all sessions';
$string['includenottaken'] = 'Include not taken sessions';
$string['includeremarks'] = 'Include remarks';
+$string['incorrectpassword'] = 'You have entered an incorrect password';
$string['indetail'] = 'In detail...';
$string['invalidsessionenddate'] = 'This date can not be earlier than the session date';
$string['invalidaction'] = 'You must select an action';
$string['olddate'] = 'Old date';
$string['onlyselectedusers'] = 'Export specific users';
$string['participant'] = 'Participant';
+$string['password'] = 'Password';
+$string['passwordrequired'] = 'You must enter the session password before you can submit your attendance';
$string['percentage'] = 'Percentage';
$string['percentagesessionscompleted'] = 'Percentage over taken sessions';
$string['percentageallsessions'] = 'Percentage over all sessions';
$string['strftimehm'] = '%l:%M%P';
$string['strftimeshortdate'] = '%d.%m.%Y';
$string['studentid'] = 'Student ID';
+$string['studentpassword'] = 'Student password';
+$string['studentpassword_help'] = 'If set students will be required to enter this password before they can set their own attendance status for the session. If empty, no password is required.';
$string['summary'] = 'Summary';
$string['takeattendance'] = 'Take attendance';
$string['takensessions'] = 'Taken sessions';
$sess->timemodified = $now;
if (isset($formdata->studentscanmark)) { // Students will be able to mark their own attendance.
$sess->studentscanmark = 1;
+ $sess->studentpassword = $formdata->studentpassword;
+ } else {
+ $sess->studentpassword = '';
}
$sess->statusset = $formdata->statusset;
$sess->timemodified = $now;
if (isset($formdata->studentscanmark)) { // Students will be able to mark their own attendance.
$sess->studentscanmark = 1;
+ $sess->studentpassword = $formdata->studentpassword;
+ } else {
+ $sess->studentpassword = '';
}
$sess->statusset = $formdata->statusset;
if (!empty($attforsession->description)) {
$mform->addElement('html', $attforsession->description);
}
-
+ if (!empty($attforsession->studentpassword)) {
+ $mform->addElement('text', 'studentpassword', get_string('password', 'attendance'));
+ $mform->setType('studentpassword', PARAM_TEXT);
+ $mform->addRule('studentpassword', get_string('passwordrequired', 'attendance'), 'required');
+ }
// Create radio buttons for setting the attendance status.
$radioarray = array();
foreach ($statuses as $status) {
$data = array('sessiondate' => $sess->sessdate,
'sestime' => array('starthour' => $starthour, 'startminute' => $startminute,
'endhour' => $endhour, 'endminute' => $endminute),
- 'sdescription' => $sess->description_editor);
+ 'sdescription' => $sess->description_editor,
+ 'studentscanmark' => $sess->studentscanmark,
+ 'studentpassword' => $sess->studentpassword);
$mform->addElement('header', 'general', get_string('changesession', 'attendance'));
attendance_get_setname($this->_customdata['att']->id, $sess->statusset));
}
+ // Students can mark own attendance.
+ if (!empty(get_config('attendance', 'studentscanmark'))) {
+ $mform->addElement('checkbox', 'studentscanmark', '', get_string('studentscanmark', 'attendance'));
+ $mform->addHelpButton('studentscanmark', 'studentscanmark', 'attendance');
+
+ $mform->addElement('text', 'studentpassword', get_string('studentpassword', 'attendance'));
+ $mform->setType('studentpassword', PARAM_TEXT);
+ $mform->addHelpButton('studentpassword', 'studentpassword', 'attendance');
+ $mform->disabledif('studentpassword', 'studentscanmark', 'notchecked');
+ } else {
+ $mform->addElement('hidden', 'studentscanmark', '0');
+ $mform->settype('studentscanmark', PARAM_INT);
+ }
+
$mform->addElement('editor', 'sdescription', get_string('description', 'attendance'),
array('rows' => 1, 'columns' => 80), $defopts);
$mform->setType('sdescription', PARAM_RAW);
*/
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2017020700;
+$plugin->version = 2017042800;
$plugin->requires = 2017011900;
-$plugin->release = '3.3.2';
+$plugin->release = '3.3.3';
$plugin->maturity = MATURITY_STABLE;
$plugin->cron = 0;
$plugin->component = 'mod_attendance';