Browse Source

allow random password to be used when creating sessions.

MOODLE_33_STABLE
Dan Marsden 8 years ago
parent
commit
b665424bf9
  1. 11
      add_form.php
  2. 4
      lang/en/attendance.php
  3. 12
      sessions.php
  4. 2
      update_form.php

11
add_form.php

@ -123,11 +123,18 @@ 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');
$mgroup = array();
$mgroup[] = & $mform->createElement('text', 'studentpassword', get_string('studentpassword', 'attendance'));
$mgroup[] = & $mform->createElement('checkbox', 'randompassword', '', get_string('randompassword', 'attendance'));
$mform->addGroup($mgroup, 'passwordgrp', get_string('passwordgrp', 'attendance'), array(' '), false);
$mform->addElement('text', 'studentpassword', get_string('studentpassword', 'attendance'));
$mform->setType('studentpassword', PARAM_TEXT); $mform->setType('studentpassword', PARAM_TEXT);
$mform->addHelpButton('studentpassword', 'studentpassword', 'attendance');
$mform->disabledif('studentpassword', 'studentscanmark', 'notchecked'); $mform->disabledif('studentpassword', 'studentscanmark', 'notchecked');
$mform->addHelpButton('passwordgrp', 'passwordgrp', 'attendance');
$mform->disabledif('randompassword', 'studentscanmark', 'notchecked');
$mform->disabledif('studentpassword', 'randompassword', 'checked');
} else { } else {
$mform->addElement('hidden', 'studentscanmark', '0'); $mform->addElement('hidden', 'studentscanmark', '0');
$mform->settype('studentscanmark', PARAM_INT); $mform->settype('studentscanmark', PARAM_INT);

4
lang/en/attendance.php

@ -185,6 +185,8 @@ $string['percentagesessionscompleted'] = 'Percentage over taken sessions';
$string['percentageallsessions'] = 'Percentage over all sessions'; $string['percentageallsessions'] = 'Percentage over all sessions';
$string['pluginname'] = 'Attendance'; $string['pluginname'] = 'Attendance';
$string['pluginadministration'] = 'Attendance administration'; $string['pluginadministration'] = 'Attendance administration';
$string['passwordgrp'] = 'Student password';
$string['passwordgrp_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['remark'] = 'Remark for: {$a}'; $string['remark'] = 'Remark for: {$a}';
$string['remarks'] = 'Remarks'; $string['remarks'] = 'Remarks';
$string['report'] = 'Report'; $string['report'] = 'Report';
@ -258,6 +260,7 @@ $string['sessiontypeshort'] = 'Type';
$string['sessionupdated'] = 'Session successfully updated'; $string['sessionupdated'] = 'Session successfully updated';
$string['setallstatuses'] = 'Set status for all users'; $string['setallstatuses'] = 'Set status for all users';
$string['setallstatusesto'] = 'Set status for all users to «{$a}»'; $string['setallstatusesto'] = 'Set status for all users to «{$a}»';
$string['randompassword'] = 'Random password';
$string['settings'] = 'Settings'; $string['settings'] = 'Settings';
$string['showdefaults'] = 'Show defaults'; $string['showdefaults'] = 'Show defaults';
$string['showduration'] = 'Show duration'; $string['showduration'] = 'Show duration';
@ -279,7 +282,6 @@ $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'] = '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';

12
sessions.php

@ -272,7 +272,11 @@ 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; if (!empty($formdata->randompassword)) {
$sess->studentpassword = random_string(5);
} else {
$sess->studentpassword = $formdata->studentpassword;
}
} else { } else {
$sess->studentpassword = ''; $sess->studentpassword = '';
} }
@ -298,7 +302,11 @@ function construct_sessions_data_for_add($formdata) {
$sess->studentpassword = ''; $sess->studentpassword = '';
if (isset($formdata->studentscanmark) && !empty($formdata->studentscanmark)) { // Students will be able to mark their own attendance. if (isset($formdata->studentscanmark) && !empty($formdata->studentscanmark)) { // Students will be able to mark their own attendance.
$sess->studentscanmark = 1; $sess->studentscanmark = 1;
$sess->studentpassword = $formdata->studentpassword; if (!empty($formdata->randompassword)) {
$sess->studentpassword = random_string(5);
} else {
$sess->studentpassword = $formdata->studentpassword;
}
} }
$sess->statusset = $formdata->statusset; $sess->statusset = $formdata->statusset;

2
update_form.php

@ -97,7 +97,7 @@ class mod_attendance_update_form extends moodleform {
$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);
$mform->addHelpButton('studentpassword', 'studentpassword', 'attendance'); $mform->addHelpButton('studentpassword', 'passwordgrp', 'attendance');
$mform->disabledif('studentpassword', 'studentscanmark', 'notchecked'); $mform->disabledif('studentpassword', 'studentscanmark', 'notchecked');
} else { } else {
$mform->addElement('hidden', 'studentscanmark', '0'); $mform->addElement('hidden', 'studentscanmark', '0');

Loading…
Cancel
Save