Davo Smith
10 years ago
16 changed files with 903 additions and 10 deletions
After Width: | Height: | Size: 47 KiB |
@ -0,0 +1,68 @@ |
|||||
|
<?php |
||||
|
// This file is part of Moodle - http://moodle.org/ |
||||
|
// |
||||
|
// Moodle is free software: you can redistribute it and/or modify |
||||
|
// it under the terms of the GNU General Public License as published by |
||||
|
// the Free Software Foundation, either version 3 of the License, or |
||||
|
// (at your option) any later version. |
||||
|
// |
||||
|
// Moodle is distributed in the hope that it will be useful, |
||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
// GNU General Public License for more details. |
||||
|
// |
||||
|
// You should have received a copy of the GNU General Public License |
||||
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. |
||||
|
|
||||
|
/** |
||||
|
* Form for creating temporary users. |
||||
|
* |
||||
|
* @package mod_attendance |
||||
|
* @copyright 2013 Davo Smith, Synergy Learning |
||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
||||
|
*/ |
||||
|
|
||||
|
defined('MOODLE_INTERNAL') || die(); |
||||
|
|
||||
|
global $CFG; |
||||
|
require_once($CFG->libdir.'/formslib.php'); |
||||
|
|
||||
|
class temp_form extends moodleform { |
||||
|
function definition() { |
||||
|
|
||||
|
$mform = $this->_form; |
||||
|
|
||||
|
$mform->addElement('hidden', 'id', 0); |
||||
|
$mform->setType('id', PARAM_INT); |
||||
|
|
||||
|
$mform->addElement('header', 'attheader', get_string('tempaddform', 'attendance')); |
||||
|
$mform->addElement('text', 'tname', get_string('tusername', 'attendance')); |
||||
|
$mform->addRule('tname', 'Required', 'required', null, 'client'); |
||||
|
$mform->setType('tname', PARAM_TEXT); |
||||
|
|
||||
|
$mform->addElement('text', 'temail', get_string('tuseremail', 'attendance')); |
||||
|
$mform->addRule('temail', 'Email', 'email', null, 'client'); |
||||
|
$mform->addRule('temail', '', 'callback', null, 'server'); |
||||
|
$mform->setType('temail', PARAM_EMAIL); |
||||
|
|
||||
|
$mform->addElement('submit', 'submitbutton', get_string('adduser', 'attendance')); |
||||
|
$mform->closeHeaderBefore('submit'); |
||||
|
} |
||||
|
|
||||
|
function definition_after_data() { |
||||
|
$mform = $this->_form; |
||||
|
$mform->applyFilter('tname', 'trim'); |
||||
|
} |
||||
|
|
||||
|
function validation($data, $files) { |
||||
|
$errors = parent::validation($data, $files); |
||||
|
|
||||
|
if ($err = attendance::check_existing_email($data['temail'])) { |
||||
|
$errors['temail'] = $err; |
||||
|
} |
||||
|
|
||||
|
return $errors; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,115 @@ |
|||||
|
<?php |
||||
|
// This file is part of Moodle - http://moodle.org/ |
||||
|
// |
||||
|
// Moodle is free software: you can redistribute it and/or modify |
||||
|
// it under the terms of the GNU General Public License as published by |
||||
|
// the Free Software Foundation, either version 3 of the License, or |
||||
|
// (at your option) any later version. |
||||
|
// |
||||
|
// Moodle is distributed in the hope that it will be useful, |
||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
// GNU General Public License for more details. |
||||
|
// |
||||
|
// You should have received a copy of the GNU General Public License |
||||
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. |
||||
|
|
||||
|
/** |
||||
|
* Attendance tempedit |
||||
|
* |
||||
|
* @package mod_attendance |
||||
|
* @copyright 2013 Davo Smith, Synergy Learning |
||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
||||
|
*/ |
||||
|
|
||||
|
require_once(dirname(__FILE__).'/../../config.php'); |
||||
|
|
||||
|
global $CFG, $DB, $PAGE, $OUTPUT; |
||||
|
require_once($CFG->dirroot.'/mod/attendance/locallib.php'); |
||||
|
require_once($CFG->dirroot.'/mod/attendance/tempedit_form.php'); |
||||
|
|
||||
|
$id = required_param('id', PARAM_INT); |
||||
|
$userid = required_param('userid', PARAM_INT); |
||||
|
$action = optional_param('action', null, PARAM_ALPHA); |
||||
|
|
||||
|
$cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); |
||||
|
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); |
||||
|
$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); |
||||
|
$tempuser = $DB->get_record('attendance_tempusers', array('id' => $userid), '*', MUST_EXIST); |
||||
|
|
||||
|
$att = new attendance($att, $cm, $course); |
||||
|
|
||||
|
$params = array('userid' => $tempuser->id); |
||||
|
if ($action) { |
||||
|
$params['action'] = $action; |
||||
|
} |
||||
|
$PAGE->set_url($att->url_tempedit($params)); |
||||
|
|
||||
|
require_login($course, true, $cm); |
||||
|
|
||||
|
$att->perm->require_managetemp_capability(); |
||||
|
|
||||
|
$PAGE->set_title($course->shortname.": ".$att->name.' - '.get_string('tempusersedit', 'attendance')); |
||||
|
$PAGE->set_heading($course->fullname); |
||||
|
$PAGE->set_cacheable(true); |
||||
|
$PAGE->navbar->add(get_string('tempusersedit', 'attendance')); |
||||
|
|
||||
|
/** @var mod_attendance_renderer $output */ |
||||
|
$output = $PAGE->get_renderer('mod_attendance'); |
||||
|
|
||||
|
if ($action == 'delete') { |
||||
|
if (optional_param('confirm', false, PARAM_BOOL)) { |
||||
|
require_sesskey(); |
||||
|
|
||||
|
// Remove the user from the grades table, the attendance log and the tempusers table. |
||||
|
$DB->delete_records('grade_grades', array('userid' => $tempuser->studentid)); |
||||
|
$DB->delete_records('attendance_log', array('studentid' => $tempuser->studentid)); |
||||
|
$DB->delete_records('attendance_tempusers', array('id' => $tempuser->id)); |
||||
|
|
||||
|
redirect($att->url_managetemp()); |
||||
|
} else { |
||||
|
|
||||
|
$info = (object)array( |
||||
|
'fullname' => $tempuser->fullname, |
||||
|
'email' => $tempuser->email, |
||||
|
); |
||||
|
$msg = get_string('confirmdeleteuser', 'attendance', $info); |
||||
|
$continue = new moodle_url($PAGE->url, array('confirm' => 1, 'sesskey' => sesskey())); |
||||
|
|
||||
|
echo $output->header(); |
||||
|
echo $output->confirm($msg, $continue, $att->url_managetemp()); |
||||
|
echo $output->footer(); |
||||
|
|
||||
|
die(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
$formdata = new stdClass(); |
||||
|
$formdata->id = $cm->id; |
||||
|
$formdata->tname = $tempuser->fullname; |
||||
|
$formdata->userid = $tempuser->id; |
||||
|
$formdata->temail = $tempuser->email; |
||||
|
|
||||
|
$mform = new tempedit_form(); |
||||
|
$mform->set_data($formdata); |
||||
|
|
||||
|
if ($mform->is_cancelled()) { |
||||
|
redirect($att->url_managetemp()); |
||||
|
} else if ($tempuser = $mform->get_data()) { |
||||
|
global $DB; |
||||
|
$updateuser = new stdClass(); |
||||
|
$updateuser->id = $tempuser->userid; |
||||
|
$updateuser->fullname = $tempuser->tname; |
||||
|
$updateuser->email = $tempuser->temail; |
||||
|
$DB->update_record('attendance_tempusers', $updateuser); |
||||
|
redirect($att->url_managetemp()); |
||||
|
} |
||||
|
|
||||
|
$tabs = new attendance_tabs($att, attendance_tabs::TAB_TEMPORARYUSERS); |
||||
|
|
||||
|
echo $output->header(); |
||||
|
echo $output->heading(get_string('tempusersedit', 'attendance').' : '.$course->fullname); |
||||
|
echo $output->render($tabs); |
||||
|
$mform->display(); |
||||
|
echo $output->footer($course); |
||||
|
|
@ -0,0 +1,71 @@ |
|||||
|
<?php |
||||
|
// This file is part of Moodle - http://moodle.org/ |
||||
|
// |
||||
|
// Moodle is free software: you can redistribute it and/or modify |
||||
|
// it under the terms of the GNU General Public License as published by |
||||
|
// the Free Software Foundation, either version 3 of the License, or |
||||
|
// (at your option) any later version. |
||||
|
// |
||||
|
// Moodle is distributed in the hope that it will be useful, |
||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
// GNU General Public License for more details. |
||||
|
// |
||||
|
// You should have received a copy of the GNU General Public License |
||||
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. |
||||
|
|
||||
|
/** |
||||
|
* Form for editing temporary users. |
||||
|
* |
||||
|
* @package mod_attendance |
||||
|
* @copyright 2013 Davo Smith, Synergy Learning |
||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
||||
|
*/ |
||||
|
|
||||
|
defined('MOODLE_INTERNAL') || die(); |
||||
|
|
||||
|
global $CFG; |
||||
|
require_once($CFG->libdir.'/formslib.php'); |
||||
|
|
||||
|
class tempedit_form extends moodleform { |
||||
|
|
||||
|
function definition() { |
||||
|
|
||||
|
$mform = $this->_form; |
||||
|
|
||||
|
$mform->addElement('hidden', 'userid', 0); |
||||
|
$mform->setType('userid', PARAM_INT); |
||||
|
$mform->addElement('hidden', 'id', 0); |
||||
|
$mform->setType('id', PARAM_INT); |
||||
|
|
||||
|
$mform->addElement('header', 'attheader', get_string('tempusersedit', 'attendance')); |
||||
|
$mform->addElement('text', 'tname', get_string('tusername', 'attendance')); |
||||
|
$mform->addRule('tname', 'Required', 'required', null, 'client'); |
||||
|
$mform->setType('tname', PARAM_TEXT); |
||||
|
|
||||
|
$mform->addElement('text', 'temail', get_string('tuseremail', 'attendance')); |
||||
|
$mform->addRule('temail', 'Email', 'email', null, 'client'); |
||||
|
$mform->setType('temail', PARAM_EMAIL); |
||||
|
|
||||
|
$buttonarray = array( |
||||
|
$mform->createElement('submit', 'submitbutton', get_string('edituser', 'attendance')), |
||||
|
$mform->createElement('cancel'), |
||||
|
); |
||||
|
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); |
||||
|
$mform->closeHeaderBefore('submit'); |
||||
|
} |
||||
|
|
||||
|
function definition_after_data() { |
||||
|
$mform = $this->_form; |
||||
|
$mform->applyFilter('tname', 'trim'); |
||||
|
} |
||||
|
|
||||
|
function validation($data, $files) { |
||||
|
$errors = parent::validation($data, $files); |
||||
|
|
||||
|
if ($err = attendance::check_existing_email($data['temail'], $data['userid'])) { |
||||
|
$errors['temail'] = $err; |
||||
|
} |
||||
|
return $errors; |
||||
|
} |
||||
|
} |
@ -0,0 +1,104 @@ |
|||||
|
<?php |
||||
|
// This file is part of Moodle - http://moodle.org/ |
||||
|
// |
||||
|
// Moodle is free software: you can redistribute it and/or modify |
||||
|
// it under the terms of the GNU General Public License as published by |
||||
|
// the Free Software Foundation, either version 3 of the License, or |
||||
|
// (at your option) any later version. |
||||
|
// |
||||
|
// Moodle is distributed in the hope that it will be useful, |
||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
// GNU General Public License for more details. |
||||
|
// |
||||
|
// You should have received a copy of the GNU General Public License |
||||
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. |
||||
|
|
||||
|
/** |
||||
|
* Merge temporary user with real user. |
||||
|
* |
||||
|
* @package mod_attendance |
||||
|
* @copyright 2013 Davo Smith, Synergy Learning |
||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
||||
|
*/ |
||||
|
|
||||
|
require_once(dirname(__FILE__).'/../../config.php'); |
||||
|
|
||||
|
global $CFG, $DB, $PAGE, $OUTPUT; |
||||
|
require_once($CFG->dirroot.'/mod/attendance/locallib.php'); |
||||
|
require_once($CFG->dirroot.'/mod/attendance/tempmerge_form.php'); |
||||
|
|
||||
|
$id = required_param('id', PARAM_INT); |
||||
|
$userid = required_param('userid', PARAM_INT); |
||||
|
|
||||
|
$cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); |
||||
|
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); |
||||
|
$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); |
||||
|
$tempuser = $DB->get_record('attendance_tempusers', array('id' => $userid), '*', MUST_EXIST); |
||||
|
|
||||
|
$att = new attendance($att, $cm, $course); |
||||
|
$params = array('userid' => $tempuser->id); |
||||
|
$PAGE->set_url($att->url_tempmerge($params)); |
||||
|
|
||||
|
require_login($course, true, $cm); |
||||
|
|
||||
|
$PAGE->set_title($course->shortname.": ".$att->name.' - '.get_string('tempusermerge', 'attendance')); |
||||
|
$PAGE->set_heading($course->fullname); |
||||
|
$PAGE->set_cacheable(true); |
||||
|
$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'attendance')); |
||||
|
$PAGE->navbar->add(get_string('tempusermerge', 'attendance')); |
||||
|
|
||||
|
$formdata = (object)array( |
||||
|
'id' => $cm->id, |
||||
|
'userid' => $tempuser->id, |
||||
|
); |
||||
|
|
||||
|
$custom = array( |
||||
|
'description' => format_string($tempuser->fullname).' ('.format_string($tempuser->email).')', |
||||
|
); |
||||
|
$mform = new tempmerge_form(null, $custom); |
||||
|
$mform->set_data($formdata); |
||||
|
|
||||
|
if ($mform->is_cancelled()) { |
||||
|
redirect($att->url_managetemp()); |
||||
|
|
||||
|
} else if ($data = $mform->get_data()) { |
||||
|
|
||||
|
$sql = "SELECT s.id, lr.id AS reallogid, lt.id AS templogid |
||||
|
FROM {attendance_sessions} s |
||||
|
LEFT JOIN {attendance_log} lr ON lr.sessionid = s.id AND lr.studentid = :realuserid |
||||
|
LEFT JOIN {attendance_log} lt ON lt.sessionid = s.id AND lt.studentid = :tempuserid |
||||
|
WHERE s.attendanceid = :attendanceid AND lt.id IS NOT NULL |
||||
|
ORDER BY s.id"; |
||||
|
$params = array( |
||||
|
'realuserid' => $data->participant, |
||||
|
'tempuserid' => $tempuser->studentid, |
||||
|
'attendanceid' => $att->id, |
||||
|
); |
||||
|
$logs = $DB->get_recordset_sql($sql, $params); |
||||
|
|
||||
|
foreach ($logs as $log) { |
||||
|
if (!is_null($log->reallogid)) { |
||||
|
// Remove the existing attendance for the real user for this session. |
||||
|
$DB->delete_records('attendance_log', array('id' => $log->reallogid)); |
||||
|
} |
||||
|
// Adjust the 'temp user' attendance record to point at the real user. |
||||
|
$DB->set_field('attendance_log', 'studentid', $data->participant, array('id' => $log->templogid)); |
||||
|
} |
||||
|
|
||||
|
// Delete the temp user. |
||||
|
$DB->delete_records('attendance_tempusers', array('id' => $tempuser->id)); |
||||
|
$att->update_users_grade(array($data->participant)); // Update the gradebook after the merge. |
||||
|
|
||||
|
redirect($att->url_managetemp()); |
||||
|
} |
||||
|
|
||||
|
/** @var mod_attendance_renderer $output */ |
||||
|
$output = $PAGE->get_renderer('mod_attendance'); |
||||
|
$tabs = new attendance_tabs($att, attendance_tabs::TAB_TEMPORARYUSERS); |
||||
|
|
||||
|
echo $output->header(); |
||||
|
echo $output->heading(get_string('tempusermerge', 'attendance').' : '.$course->fullname); |
||||
|
echo $output->render($tabs); |
||||
|
$mform->display(); |
||||
|
echo $output->footer($course); |
@ -0,0 +1,40 @@ |
|||||
|
<?php |
||||
|
|
||||
|
defined('MOODLE_INTERNAL') || die(); |
||||
|
|
||||
|
global $CFG; |
||||
|
require_once($CFG->libdir.'/formslib.php'); |
||||
|
|
||||
|
class tempmerge_form extends moodleform { |
||||
|
|
||||
|
function definition() { |
||||
|
global $COURSE; |
||||
|
|
||||
|
$context = context_course::instance($COURSE->id); |
||||
|
$namefields = get_all_user_name_fields(true, 'u'); |
||||
|
$students = get_enrolled_users($context, 'mod/attendance:canbelisted', 0, 'u.id,'.$namefields.',u.email', |
||||
|
'u.lastname, u.firstname', 0, 0, true); |
||||
|
$partarray = array(); |
||||
|
foreach ($students as $student) { |
||||
|
$partarray[$student->id] = fullname($student).' ('.$student->email.')'; |
||||
|
} |
||||
|
|
||||
|
$mform = $this->_form; |
||||
|
$description = $this->_customdata['description']; |
||||
|
|
||||
|
$mform->addElement('hidden', 'id', 0); |
||||
|
$mform->setType('id', PARAM_INT); |
||||
|
$mform->addElement('hidden', 'userid', 0); |
||||
|
$mform->setType('userid', PARAM_INT); |
||||
|
|
||||
|
$mform->addElement('header', 'attheader', get_string('tempusermerge', 'attendance')); |
||||
|
$mform->addElement('static', 'description', get_string('tempuser', 'attendance'), $description); |
||||
|
|
||||
|
$mform->addElement('select', 'participant', get_string('participant', 'attendance'), $partarray); |
||||
|
|
||||
|
$mform->addElement('static', 'requiredentries', '', get_string('requiredentries', 'attendance')); |
||||
|
$mform->addHelpButton('requiredentries', 'requiredentry', 'attendance'); |
||||
|
|
||||
|
$this->add_action_buttons(true, get_string('mergeuser', 'attendance')); |
||||
|
} |
||||
|
} |
@ -0,0 +1,127 @@ |
|||||
|
<?php |
||||
|
// This file is part of Moodle - http://moodle.org/ |
||||
|
// |
||||
|
// Moodle is free software: you can redistribute it and/or modify |
||||
|
// it under the terms of the GNU General Public License as published by |
||||
|
// the Free Software Foundation, either version 3 of the License, or |
||||
|
// (at your option) any later version. |
||||
|
// |
||||
|
// Moodle is distributed in the hope that it will be useful, |
||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
// GNU General Public License for more details. |
||||
|
// |
||||
|
// You should have received a copy of the GNU General Public License |
||||
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. |
||||
|
|
||||
|
/** |
||||
|
* Temporary user management. |
||||
|
* |
||||
|
* @package mod_attendance |
||||
|
* @copyright 2013 Davo Smith, Synergy Learning |
||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
||||
|
*/ |
||||
|
|
||||
|
require_once(dirname(__FILE__).'/../../config.php'); |
||||
|
global $CFG, $DB, $OUTPUT, $PAGE, $COURSE; |
||||
|
require_once($CFG->dirroot.'/mod/attendance/locallib.php'); |
||||
|
require_once($CFG->dirroot.'/mod/attendance/temp_form.php'); |
||||
|
|
||||
|
$id = required_param('id', PARAM_INT); |
||||
|
|
||||
|
$cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); |
||||
|
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); |
||||
|
$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); |
||||
|
|
||||
|
$att = new attendance($att, $cm, $course); |
||||
|
$PAGE->set_url($att->url_managetemp()); |
||||
|
|
||||
|
require_login($course, true, $cm); |
||||
|
|
||||
|
$att->perm->require_managetemp_capability(); |
||||
|
|
||||
|
$PAGE->set_title($course->shortname.": ".$att->name.' - '.get_string('tempusers', 'attendance')); |
||||
|
$PAGE->set_heading($course->fullname); |
||||
|
$PAGE->set_cacheable(true); |
||||
|
$PAGE->navbar->add(get_string('tempusers', 'attendance')); |
||||
|
|
||||
|
/** @var mod_attendance_renderer $output */ |
||||
|
$output = $PAGE->get_renderer('mod_attendance'); |
||||
|
$tabs = new attendance_tabs($att, attendance_tabs::TAB_TEMPORARYUSERS); |
||||
|
|
||||
|
$formdata = (object)array( |
||||
|
'id' => $cm->id, |
||||
|
); |
||||
|
$mform = new temp_form(); |
||||
|
$mform->set_data($formdata); |
||||
|
|
||||
|
if ($data = $mform->get_data()) { |
||||
|
// Create temp user in main user table. |
||||
|
$user = new stdClass(); |
||||
|
$user->auth = 'manual'; |
||||
|
$user->confirmed = 1; |
||||
|
$user->deleted = 1; |
||||
|
$user->email = time().'@ghost.user.de'; |
||||
|
$user->username = time().'@ghost.user.de'; |
||||
|
$user->idnumber = 'tempghost'; |
||||
|
$studentid = $DB->insert_record('user', $user); |
||||
|
|
||||
|
// Create the temporary user record. |
||||
|
$newtempuser = new stdClass(); |
||||
|
$newtempuser->fullname = $data->tname; |
||||
|
$newtempuser->courseid = $COURSE->id; |
||||
|
$newtempuser->email = $data->temail; |
||||
|
$newtempuser->created = time(); |
||||
|
$newtempuser->studentid = $studentid; |
||||
|
$DB->insert_record('attendance_tempusers', $newtempuser); |
||||
|
|
||||
|
redirect($att->url_managetemp()); |
||||
|
} |
||||
|
|
||||
|
/// Output starts here |
||||
|
echo $output->header(); |
||||
|
echo $output->heading(get_string('tempusers', 'attendance').' : '.$course->fullname); |
||||
|
echo $output->render($tabs); |
||||
|
$mform->display(); |
||||
|
|
||||
|
$tempusers = $DB->get_records('attendance_tempusers', array('courseid' => $course->id), 'fullname, email'); |
||||
|
|
||||
|
echo '<div>'; |
||||
|
echo '<p style="margin-left:10%;">'.get_string('tempuserslist', 'attendance').'</p>'; |
||||
|
if ($tempusers) { |
||||
|
print_tempusers($tempusers, $att); |
||||
|
} |
||||
|
echo '</div>'; |
||||
|
echo $output->footer($course); |
||||
|
|
||||
|
function print_tempusers($tempusers, attendance $att) { |
||||
|
echo '<p></p>'; |
||||
|
echo '<table border="1" bordercolor="#EEEEEE" style="background-color:#fff" cellpadding="2" align="center" width="80%" summary="'.get_string('temptable', 'attendance').'"><tr>'; |
||||
|
echo '<th class="header">'.get_string('tusername', 'attendance').'</th>'; |
||||
|
echo '<th class="header">'.get_string('tuseremail', 'attendance').'</th>'; |
||||
|
echo '<th class="header">'.get_string('tcreated', 'attendance').'</th>'; |
||||
|
echo '<th class="header">'.get_string('tactions', 'attendance').'</th>'; |
||||
|
echo '</tr>'; |
||||
|
|
||||
|
$even = false; // used to colour rows |
||||
|
foreach ($tempusers as $tempuser) { |
||||
|
if ($even) { |
||||
|
echo '<tr style="background-color: #FCFCFC">'; |
||||
|
} else { |
||||
|
echo '<tr>'; |
||||
|
} |
||||
|
$even = !$even; |
||||
|
echo '<td>'.format_string($tempuser->fullname).'</td>'; |
||||
|
echo '<td>'.format_string($tempuser->email).'</td>'; |
||||
|
echo '<td>'.userdate($tempuser->created, get_string('strftimedatetime')).'</td>'; |
||||
|
$params = array('userid' => $tempuser->id); |
||||
|
$editlink = html_writer::link($att->url_tempedit($params), get_string('edituser', 'attendance')); |
||||
|
$deletelink = html_writer::link($att->url_tempdelete($params), get_string('deleteuser', 'attendance')); |
||||
|
$mergelink = html_writer::link($att->url_tempmerge($params), get_string('mergeuser', 'attendance')); |
||||
|
echo '<td>'.$editlink.' | '.$deletelink.' | '.$mergelink.'</td>'; |
||||
|
echo '</tr>'; |
||||
|
} |
||||
|
echo '</table>'; |
||||
|
} |
||||
|
|
||||
|
|
@ -0,0 +1,112 @@ |
|||||
|
@mod @mod_attendance @javascript |
||||
|
Feature: Test the various new features in the attendance module |
||||
|
|
||||
|
Background: |
||||
|
Given the following "courses" exist: |
||||
|
| fullname | shortname | |
||||
|
| Course 1 | C1 | |
||||
|
And the following "users" exist: |
||||
|
| username | firstname | lastname | email | |
||||
|
| teacher1 | Teacher | 1 | teacher1@example.com | |
||||
|
| student1 | Student | 1 | student1@example.com | |
||||
|
| student2 | Student | 2 | student2@example.com | |
||||
|
| student3 | Student | 3 | student3@example.com | |
||||
|
| student4 | Student | 4 | student4@example.com | |
||||
|
| student5 | Student | 5 | student5@example.com | |
||||
|
And the following "course enrolments" exist: |
||||
|
| course | user | role | |
||||
|
| C1 | teacher1 | editingteacher | |
||||
|
| C1 | student1 | student | |
||||
|
| C1 | student2 | student | |
||||
|
| C1 | student3 | student | |
||||
|
And I log in as "teacher1" |
||||
|
And I follow "Course 1" |
||||
|
And I turn editing mode on |
||||
|
And I add a "Attendance" to section "1" and I fill the form with: |
||||
|
| Name | Test attendance | |
||||
|
And I log out |
||||
|
|
||||
|
Scenario: A teacher can create and update temporary users |
||||
|
Given I log in as "teacher1" |
||||
|
And I follow "Course 1" |
||||
|
And I follow "Test attendance" |
||||
|
And I follow "Temporary users" |
||||
|
|
||||
|
When I set the following fields to these values: |
||||
|
| Full name | Temporary user 1 | |
||||
|
| Email | | |
||||
|
And I press "Add user" |
||||
|
And I set the following fields to these values: |
||||
|
| Full name | Temporary user test 2 | |
||||
|
| Email | tempuser2test@example.com | |
||||
|
And I press "Add user" |
||||
|
Then I should see "Temporary user 1" |
||||
|
And "tempuser2test@example.com" "text" should exist in the "Temporary user test 2" "table_row" |
||||
|
|
||||
|
When I click on "Edit user" "link" in the "Temporary user test 2" "table_row" |
||||
|
And the following fields match these values: |
||||
|
| Full name | Temporary user test 2 | |
||||
|
| Email | tempuser2test@example.com | |
||||
|
And I set the following fields to these values: |
||||
|
| Full name | Temporary user 2 | |
||||
|
| Email | tempuser2@example.com | |
||||
|
And I press "Edit user" |
||||
|
Then "tempuser2@example.com" "text" should exist in the "Temporary user 2" "table_row" |
||||
|
|
||||
|
When I click on "Delete user" "link" in the "Temporary user 1" "table_row" |
||||
|
And I press "Continue" |
||||
|
Then I should not see "Temporary user 1" |
||||
|
And I should see "Temporary user 2" |
||||
|
|
||||
|
Scenario: A teacher can take attendance for temporary users |
||||
|
Given I log in as "teacher1" |
||||
|
And I follow "Course 1" |
||||
|
And I follow "Test attendance" |
||||
|
And I follow "Temporary users" |
||||
|
And I set the following fields to these values: |
||||
|
| Full name | Temporary user 1 | |
||||
|
| Email | | |
||||
|
And I press "Add user" |
||||
|
And I set the following fields to these values: |
||||
|
| Full name | Temporary user 2 | |
||||
|
| Email | tempuser2@example.com | |
||||
|
And I press "Add user" |
||||
|
|
||||
|
And I follow "Add" |
||||
|
And I set the following fields to these values: |
||||
|
| Create multiple sessions | 0 | |
||||
|
And I click on "submitbutton" "button" |
||||
|
And I follow "Sessions" |
||||
|
|
||||
|
When I follow "Take attendance" |
||||
|
# Present |
||||
|
And I click on "td.c2 input" "css_element" in the "Student 1" "table_row" |
||||
|
# Late |
||||
|
And I click on "td.c3 input" "css_element" in the "Student 2" "table_row" |
||||
|
# Excused |
||||
|
And I click on "td.c4 input" "css_element" in the "Temporary user 1" "table_row" |
||||
|
# Absent |
||||
|
And I click on "td.c5 input" "css_element" in the "Temporary user 2" "table_row" |
||||
|
And I press "Save attendance" |
||||
|
And I follow "Report" |
||||
|
Then "P" "text" should exist in the "Student 1" "table_row" |
||||
|
And "L" "text" should exist in the "Student 2" "table_row" |
||||
|
And "E" "text" should exist in the "Temporary user 1" "table_row" |
||||
|
And "A" "text" should exist in the "Temporary user 2" "table_row" |
||||
|
|
||||
|
When I follow "Temporary user 2" |
||||
|
Then I should see "Absent" |
||||
|
|
||||
|
# Merge user. |
||||
|
When I follow "Test attendance" |
||||
|
And I follow "Temporary users" |
||||
|
And I click on "Merge user" "link" in the "Temporary user 2" "table_row" |
||||
|
And I set the field "Participant" to "Student 3" |
||||
|
And I press "Merge user" |
||||
|
And I follow "Report" |
||||
|
|
||||
|
Then "P" "text" should exist in the "Student 1" "table_row" |
||||
|
And "L" "text" should exist in the "Student 2" "table_row" |
||||
|
And "E" "text" should exist in the "Temporary user 1" "table_row" |
||||
|
And "A" "text" should exist in the "Student 3" "table_row" |
||||
|
And I should not see "Temporary user 2" |
Loading…
Reference in new issue