Browse Source

Allow a password to be set when using student self marking.

MOODLE_33_STABLE
Dan Marsden 8 years ago
parent
commit
1a40f5a199
  1. 5
      add_form.php
  2. 8
      attendance.php
  3. 3
      backup/moodle2/backup_attendance_stepslib.php
  4. 10
      classes/structure.php
  5. 1
      db/install.xml
  6. 12
      db/upgrade.php
  7. 5
      lang/en/attendance.php
  8. 6
      sessions.php
  9. 6
      student_attendance_form.php
  10. 18
      update_form.php
  11. 4
      version.php

5
add_form.php

@ -123,6 +123,11 @@ class mod_attendance_add_form extends moodleform {
if (!empty(get_config('attendance', 'studentscanmark'))) { if (!empty(get_config('attendance', 'studentscanmark'))) {
$mform->addElement('checkbox', 'studentscanmark', '', get_string('studentscanmark', 'attendance')); $mform->addElement('checkbox', 'studentscanmark', '', get_string('studentscanmark', 'attendance'));
$mform->addHelpButton('studentscanmark', '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 { } else {
$mform->addElement('hidden', 'studentscanmark', '0'); $mform->addElement('hidden', 'studentscanmark', '0');
$mform->settype('studentscanmark', PARAM_INT); $mform->settype('studentscanmark', PARAM_INT);

8
attendance.php

@ -67,6 +67,14 @@ if ($mform->is_cancelled()) {
$url = new moodle_url('/mod/attendance/view.php', array('id' => $cm->id)); $url = new moodle_url('/mod/attendance/view.php', array('id' => $cm->id));
redirect($url); redirect($url);
} else if ($fromform = $mform->get_data()) { } 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)) { if (!empty($fromform->status)) {
$success = $att->take_from_student($fromform); $success = $att->take_from_student($fromform);

3
backup/moodle2/backup_attendance_stepslib.php

@ -53,7 +53,8 @@ class backup_attendance_activity_structure_step extends backup_activity_structur
$sessions = new backup_nested_element('sessions'); $sessions = new backup_nested_element('sessions');
$session = new backup_nested_element('session', array('id'), array( $session = new backup_nested_element('session', array('id'), array(
'groupid', 'sessdate', 'duration', 'lasttaken', 'lasttakenby', 'groupid', 'sessdate', 'duration', 'lasttaken', 'lasttakenby',
'timemodified', 'description', 'descriptionformat', 'studentscanmark', 'statusset', 'caleventid')); 'timemodified', 'description', 'descriptionformat', 'studentscanmark', 'studentpassword',
'statusset', 'caleventid'));
// XML nodes declaration - user data. // XML nodes declaration - user data.
$logs = new backup_nested_element('logs'); $logs = new backup_nested_element('logs');

10
classes/structure.php

@ -395,6 +395,7 @@ class mod_attendance_structure {
$sess->lasttaken = 0; $sess->lasttaken = 0;
$sess->lasttakenby = 0; $sess->lasttakenby = 0;
$sess->studentscanmark = 0; $sess->studentscanmark = 0;
$event->add_record_snapshot('attendance_sessions', $sess); $event->add_record_snapshot('attendance_sessions', $sess);
$event->trigger(); $event->trigger();
} }
@ -419,6 +420,15 @@ class mod_attendance_structure {
$sess->description = $description; $sess->description = $description;
$sess->descriptionformat = $formdata->sdescription['format']; $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(); $sess->timemodified = time();
$DB->update_record('attendance_sessions', $sess); $DB->update_record('attendance_sessions', $sess);

1
db/install.xml

@ -37,6 +37,7 @@
<FIELD NAME="description" TYPE="text" NOTNULL="true" SEQUENCE="false"/> <FIELD NAME="description" TYPE="text" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="descriptionformat" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" 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="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="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"/> <FIELD NAME="caleventid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
</FIELDS> </FIELDS>

12
db/upgrade.php

@ -233,5 +233,17 @@ function xmldb_attendance_upgrade($oldversion=0) {
upgrade_mod_savepoint(true, 2017020700, 'attendance'); 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; return $result;
} }

5
lang/en/attendance.php

@ -133,6 +133,7 @@ $string['identifyby'] = 'Identify student by';
$string['includeall'] = 'Select all sessions'; $string['includeall'] = 'Select all sessions';
$string['includenottaken'] = 'Include not taken sessions'; $string['includenottaken'] = 'Include not taken sessions';
$string['includeremarks'] = 'Include remarks'; $string['includeremarks'] = 'Include remarks';
$string['incorrectpassword'] = 'You have entered an incorrect password';
$string['indetail'] = 'In detail...'; $string['indetail'] = 'In detail...';
$string['invalidsessionenddate'] = 'This date can not be earlier than the session date'; $string['invalidsessionenddate'] = 'This date can not be earlier than the session date';
$string['invalidaction'] = 'You must select an action'; $string['invalidaction'] = 'You must select an action';
@ -177,6 +178,8 @@ $string['noupgradefromthisversion'] = 'The Attendance module cannot upgrade from
$string['olddate'] = 'Old date'; $string['olddate'] = 'Old date';
$string['onlyselectedusers'] = 'Export specific users'; $string['onlyselectedusers'] = 'Export specific users';
$string['participant'] = 'Participant'; $string['participant'] = 'Participant';
$string['password'] = 'Password';
$string['passwordrequired'] = 'You must enter the session password before you can submit your attendance';
$string['percentage'] = 'Percentage'; $string['percentage'] = 'Percentage';
$string['percentagesessionscompleted'] = 'Percentage over taken sessions'; $string['percentagesessionscompleted'] = 'Percentage over taken sessions';
$string['percentageallsessions'] = 'Percentage over all sessions'; $string['percentageallsessions'] = 'Percentage over all sessions';
@ -275,6 +278,8 @@ $string['strftimeh'] = '%l%P';
$string['strftimehm'] = '%l:%M%P'; $string['strftimehm'] = '%l:%M%P';
$string['strftimeshortdate'] = '%d.%m.%Y'; $string['strftimeshortdate'] = '%d.%m.%Y';
$string['studentid'] = 'Student ID'; $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['summary'] = 'Summary';
$string['takeattendance'] = 'Take attendance'; $string['takeattendance'] = 'Take attendance';
$string['takensessions'] = 'Taken sessions'; $string['takensessions'] = 'Taken sessions';

6
sessions.php

@ -272,6 +272,9 @@ function construct_sessions_data_for_add($formdata) {
$sess->timemodified = $now; $sess->timemodified = $now;
if (isset($formdata->studentscanmark)) { // Students will be able to mark their own attendance. if (isset($formdata->studentscanmark)) { // Students will be able to mark their own attendance.
$sess->studentscanmark = 1; $sess->studentscanmark = 1;
$sess->studentpassword = $formdata->studentpassword;
} else {
$sess->studentpassword = '';
} }
$sess->statusset = $formdata->statusset; $sess->statusset = $formdata->statusset;
@ -293,6 +296,9 @@ function construct_sessions_data_for_add($formdata) {
$sess->timemodified = $now; $sess->timemodified = $now;
if (isset($formdata->studentscanmark)) { // Students will be able to mark their own attendance. if (isset($formdata->studentscanmark)) { // Students will be able to mark their own attendance.
$sess->studentscanmark = 1; $sess->studentscanmark = 1;
$sess->studentpassword = $formdata->studentpassword;
} else {
$sess->studentpassword = '';
} }
$sess->statusset = $formdata->statusset; $sess->statusset = $formdata->statusset;

6
student_attendance_form.php

@ -46,7 +46,11 @@ class mod_attendance_student_attendance_form extends moodleform {
if (!empty($attforsession->description)) { if (!empty($attforsession->description)) {
$mform->addElement('html', $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. // Create radio buttons for setting the attendance status.
$radioarray = array(); $radioarray = array();
foreach ($statuses as $status) { foreach ($statuses as $status) {

18
update_form.php

@ -64,7 +64,9 @@ class mod_attendance_update_form extends moodleform {
$data = array('sessiondate' => $sess->sessdate, $data = array('sessiondate' => $sess->sessdate,
'sestime' => array('starthour' => $starthour, 'startminute' => $startminute, 'sestime' => array('starthour' => $starthour, 'startminute' => $startminute,
'endhour' => $endhour, 'endminute' => $endminute), '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')); $mform->addElement('header', 'general', get_string('changesession', 'attendance'));
@ -88,6 +90,20 @@ class mod_attendance_update_form extends moodleform {
attendance_get_setname($this->_customdata['att']->id, $sess->statusset)); 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'), $mform->addElement('editor', 'sdescription', get_string('description', 'attendance'),
array('rows' => 1, 'columns' => 80), $defopts); array('rows' => 1, 'columns' => 80), $defopts);
$mform->setType('sdescription', PARAM_RAW); $mform->setType('sdescription', PARAM_RAW);

4
version.php

@ -23,9 +23,9 @@
*/ */
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$plugin->version = 2017020700; $plugin->version = 2017042800;
$plugin->requires = 2017011900; $plugin->requires = 2017011900;
$plugin->release = '3.3.2'; $plugin->release = '3.3.3';
$plugin->maturity = MATURITY_STABLE; $plugin->maturity = MATURITY_STABLE;
$plugin->cron = 0; $plugin->cron = 0;
$plugin->component = 'mod_attendance'; $plugin->component = 'mod_attendance';

Loading…
Cancel
Save