Browse Source

Merged in drjosephbaxter/moodle-mod_attendance/UoNChanges (pull request #1)

completion of mod_atforblock migration to mod_attendance
MOODLE_26_STABLE
Neill Magill 11 years ago
parent
commit
b0da107108
  1. 6
      add_form.php
  2. 18
      attendance.php
  3. 4
      backup/moodle2/backup_attendance_activity_task.class.php
  4. 4
      backup/moodle2/restore_attendance_activity_task.class.php
  5. 42
      locallib.php
  6. 8
      renderer.php
  7. 4
      report.php
  8. 6
      student_attenance_form.php

6
add_form.php

@ -103,9 +103,9 @@ class mod_attendance_add_form extends moodleform {
$mform->addElement('checkbox', 'addmultiply', '', get_string('createmultiplesessions', 'attendance'));
$mform->addHelpButton('addmultiply', 'createmultiplesessions', 'attendance');
// Studetns can mark own attendance.
$mform->addElement('checkbox', 'studentscanmark', '', get_string('studentscanmark','attforblock'));
$mform->addHelpButton('studentscanmark', 'studentscanmark', 'attforblock');
// Students can mark own attendance.
$mform->addElement('checkbox', 'studentscanmark', '', get_string('studentscanmark','attendance'));
$mform->addHelpButton('studentscanmark', 'studentscanmark', 'attendance');
$mform->addElement('date_time_selector', 'sessiondate', get_string('sessiondate', 'attendance'));

18
attendance.php

@ -18,7 +18,7 @@
* Prints attendance info for particular user
*
* @package mod
* @subpackage attforblock
* @subpackage attendance
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -34,37 +34,37 @@ $attendance_session_id = required_param('sessid', PARAM_INT);
$attforsession = $DB->get_record('attendance_sessions', array('id' => $id), '*', MUST_EXIST);
$attforblock = $DB->get_record('attforblock', array('id' => $attforsession->attendanceid), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('attforblock', $attforblock->id, 0, false, MUST_EXIST);
$attendance = $DB->get_record('attendance', array('id' => $attforsession->attendanceid), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('attendance', $attendance->id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
// Require the user is logged in.
require_login($course, true, $cm);
$pageparams->sessionid = $id;
$att = new attforblock($attforblock, $cm, $course, $PAGE->context, $pageparams);
$att = new attendance($attendance, $cm, $course, $PAGE->context, $pageparams);
// Require that a session key is passed to this page.
require_sesskey();
// Create the form.
$mform = new mod_attforblock_student_attendance_form(null,
$mform = new mod_attendance_student_attendance_form(null,
array('course' => $course, 'cm' => $cm, 'modcontext' => $PAGE->context, 'session' => $attforsession, 'attendance' => $att));
if ($mform->is_cancelled()) {
// The user cancelled the form, so redirect them to the view page.
$url = new moodle_url('/mod/attforblock/view.php', array('id' => $cm->id));
$url = new moodle_url('/mod/attendance/view.php', array('id' => $cm->id));
redirect($url);
} else if ($fromform = $mform->get_data()) {
if (!empty($fromform->status)) {
$success = $att->take_from_student($fromform);
$url = new moodle_url('/mod/attforblock/view.php', array('id' => $cm->id));
$url = new moodle_url('/mod/attendance/view.php', array('id' => $cm->id));
if ($success) {
// Redirect back to the view page for the block.
redirect($url);
} else {
print_error ('attendance_already_submitted', 'mod_attforblock', $url);
print_error ('attendance_already_submitted', 'mod_attendance', $url);
}
}
@ -78,7 +78,7 @@ $PAGE->set_heading($course->fullname);
$PAGE->set_cacheable(true);
$PAGE->navbar->add($att->name);
$output = $PAGE->get_renderer('mod_attforblock');
$output = $PAGE->get_renderer('mod_attendance');
echo $output->header();
$mform->display();
echo $output->footer();

4
backup/moodle2/backup_attendance_activity_task.class.php

@ -60,11 +60,11 @@ class backup_attendance_activity_task extends backup_activity_task {
// Link to attendance view by moduleid.
$search = "/(" . $base . "\/mod\/attendance\/view.php\?id\=)([0-9]+)/";
$content= preg_replace($search, '$@ATTFORBLOCKVIEWBYID*$2@$', $content);
$content= preg_replace($search, '$@ATTENDANCEVIEWBYID*$2@$', $content);
// Link to attendance view by moduleid and studentid.
$search = "/(" . $base . "\/mod\/attendance\/view.php\?id\=)([0-9]+)\&studentid\=([0-9]+)/";
$content= preg_replace($search, '$@ATTFORBLOCKVIEWBYIDSTUD*$2*$3@$', $content);
$content= preg_replace($search, '$@ATTENDANCEVIEWBYIDSTUD*$2*$3@$', $content);
return $content;
}

4
backup/moodle2/restore_attendance_activity_task.class.php

@ -67,9 +67,9 @@ class restore_attendance_activity_task extends restore_activity_task {
static public function define_decode_rules() {
$rules = array();
$rules[] = new restore_decode_rule('ATTFORBLOCKVIEWBYID',
$rules[] = new restore_decode_rule('ATTENDANCEVIEWBYID',
'/mod/attendance/view.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('ATTFORBLOCKVIEWBYIDSTUD',
$rules[] = new restore_decode_rule('ATTENDANCEVIEWBYIDSTUD',
'/mod/attendance/view.php?id=$1&studentid=$2', array('course_module', 'user'));
return $rules;

42
locallib.php

@ -811,8 +811,8 @@ class attendance {
}
$i++;
}
add_to_log($this->course->id, 'attendance', 'sessions added', $this->url_manage(),
implode(',', $info_array), $this->cm->id);
$this->log('sessions added', $this->url_manage(), implode(', ', $info_array));
}
public function update_session_from_form_data($formdata, $sessionid) {
@ -834,7 +834,7 @@ class attendance {
$url = $this->url_sessions(array('sessionid' => $sessionid, 'action' => att_sessions_page_params::ACTION_UPDATE));
$info = construct_session_full_date_time($sess->sessdate, $sess->duration);
add_to_log($this->course->id, 'attendance', 'session updated', $url, $info, $this->cm->id);
$this->log('session updated', $url, $info);
}
/**
@ -855,7 +855,7 @@ class attendance {
$record->studentid = $USER->id;
$record->statusid = $mformdata->status;
$record->statusset = $statuses;
$record->remarks = get_string('set_by_student', 'mod_attforblock');
$record->remarks = get_string('set_by_student', 'mod_attendance');
$record->sessionid = $mformdata->sessid;
$record->timetaken = $now;
$record->takenby = $USER->id;
@ -879,12 +879,19 @@ class attendance {
// Update the users grade.
$this->update_users_grade(array($USER->id));
// Log the change.
/* create url for link in log screen
* need to set grouptype to 0 to allow take attendance page to be called
* from report/log page */
$params = array(
'sessionid' => $mformdata->sessid);
'sessionid' => $this->pageparams->sessionid,
'grouptype' => 0);
$url = $this->url_take($params);
$this->log('attendance taked', $url, $USER->firstname.' '.$USER->lastname);
// Log the change.
$this->log('taken by student', $url, $USER->firstname.' '.$USER->lastname);
return true;
}
@ -935,11 +942,15 @@ class attendance {
$this->update_users_grade(array_keys($sesslog));
}
// create url for link in log screen
$params = array(
'sessionid' => $this->pageparams->sessionid,
'grouptype' => $this->pageparams->grouptype);
$url = $this->url_take($params);
add_to_log($this->course->id, 'attendance', 'taken', $url, '', $this->cm->id);
// Log the change.
$this->log('taken', $url, $USER->firstname.' '.$USER->lastname);
redirect($this->url_manage(), get_string('attendancesuccess', 'attendance'));
}
@ -1248,8 +1259,7 @@ class attendance {
list($sql, $params) = $DB->get_in_or_equal($sessionsids);
$DB->delete_records_select('attendance_log', "sessionid $sql", $params);
$DB->delete_records_list('attendance_sessions', 'id', $sessionsids);
add_to_log($this->course->id, 'attendance', 'sessions deleted', $this->url_manage(),
get_string('sessionsids', 'attendance').implode(', ', $sessionsids), $this->cm->id);
$this->log('sessions deleted', null, get_string('sessionsids', 'attendance').implode(', ', $sessionsids));
}
public function update_sessions_duration($sessionsids, $duration) {
@ -1262,8 +1272,8 @@ class attendance {
$sess->timemodified = $now;
$DB->update_record('attendance_sessions', $sess);
}
add_to_log($this->course->id, 'attendance', 'sessions duration updated', $this->url_manage(),
get_string('sessionsids', 'attendance').implode(', ', $sessionsids), $this->cm->id);
$this->log('sessions duration updated', $this->url_manage(), get_string('sessionsids', 'attendance').implode(', ', $sessionsids));
}
public function remove_status($statusid) {
@ -1284,8 +1294,7 @@ class attendance {
$rec->grade = $grade;
$DB->insert_record('attendance_statuses', $rec);
add_to_log($this->course->id, 'attendance', 'status added', $this->url_preferences(),
$acronym.': '.$description.' ('.$grade.')', $this->cm->id);
$this->log('status added', $this->url_preferences(), $acronym.': '.$description.' ('.$grade.')');
} else {
print_error('cantaddstatus', 'attendance', $this->url_preferences());
}
@ -1316,8 +1325,7 @@ class attendance {
}
$DB->update_record('attendance_statuses', $status);
add_to_log($this->course->id, 'attendance', 'status updated', $this->url_preferences(),
implode(' ', $updated), $this->cm->id);
$this->log('status updated', $this->url_preferences(), implode(' ', $updated));
}
}

8
renderer.php

@ -141,7 +141,7 @@ class mod_attendance_renderer extends plugin_renderer_base {
$views[ATT_VIEW_ALL] = get_string('all', 'attendance');
$views[ATT_VIEW_ALLPAST] = get_string('allpast', 'attendance');
if ($fcontrols->reportcontrol) {
$views[ATT_VIEW_NOTPRESENT] = get_string('lowgrade', 'attforblock');
$views[ATT_VIEW_NOTPRESENT] = get_string('lowgrade', 'attendance');
}
$views[ATT_VIEW_MONTHS] = get_string('months', 'attendance');
$views[ATT_VIEW_WEEKS] = get_string('weeks', 'attendance');
@ -649,9 +649,9 @@ class mod_attendance_renderer extends plugin_renderer_base {
} else {
if (!empty($sess->studentscanmark)) { // Student can mark their own attendance.
// URL to the page that lets the student modify their attendance.
$url = new moodle_url('/mod/attforblock/attendance.php',
$url = new moodle_url('/mod/attendance/attendance.php',
array('sessid' => $sess->id, 'sesskey' => sesskey()));
$cell = new html_table_cell(html_writer::link($url, get_string('submitattendance', 'attforblock')));
$cell = new html_table_cell(html_writer::link($url, get_string('submitattendance', 'attendance')));
$cell->colspan = 2;
$row->cells[] = $cell;
} else { // Student cannot mark their own attendace.
@ -676,7 +676,7 @@ class mod_attendance_renderer extends plugin_renderer_base {
global $PAGE;
// Initilise Javascript used to (un)check all checkboxes.
$this->page->requires->js_init_call('M.mod_attforblock.init_manage');
$this->page->requires->js_init_call('M.mod_attendance.init_manage');
// Check if the user should be able to bulk send messages to other users on the course.
$bulkmessagecapability = has_capability('moodle/course:bulkmessaging', $PAGE->context);

4
report.php

@ -55,8 +55,8 @@ $PAGE->navbar->add(get_string('report', 'attendance'));
$output = $PAGE->get_renderer('mod_attendance');
$tabs = new attendance_tabs($att, attendance_tabs::TAB_REPORT);
$filtercontrols = new attendance_filter_controls($att);
$reportdata = new attendance_report_data($att, true);
$filtercontrols = new attendance_filter_controls($att, true);
$reportdata = new attendance_report_data($att);
add_to_log($course->id, 'attendance', 'report viewed', '/mod/attendance/report.php?id='.$id, '', $cm->id);

6
student_attenance_form.php

@ -16,7 +16,7 @@
require_once($CFG->libdir.'/formslib.php');
class mod_attforblock_student_attendance_form extends moodleform {
class mod_attendance_student_attendance_form extends moodleform {
public function definition() {
global $CFG, $USER;
@ -40,7 +40,7 @@ class mod_attforblock_student_attendance_form extends moodleform {
// Set a title as the date and time of the session.
$sesstiontitle = userdate($attforsession->sessdate, get_string('strftimedate')).' '
.userdate($attforsession->sessdate, get_string('strftimehm', 'mod_attforblock'));
.userdate($attforsession->sessdate, get_string('strftimehm', 'mod_attendance'));
$mform->addElement('header', 'session', $sesstiontitle);
@ -56,7 +56,7 @@ class mod_attforblock_student_attendance_form extends moodleform {
}
// Add the radio buttons as a control with the user's name in front.
$mform->addGroup($radioarray, 'statusarray', $USER->firstname.' '.$USER->lastname.':', array(''), false);
$mform->addRule('statusarray', get_string('attendancenotset', 'attforblock'), 'required', '', 'client', false, false);
$mform->addRule('statusarray', get_string('attendancenotset', 'attendance'), 'required', '', 'client', false, false);
$this->add_action_buttons();
}

Loading…
Cancel
Save