Browse Source

first round of fixes

MOODLE_26_STABLE
Joseph Baxter 11 years ago
parent
commit
91d19e10ea
  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. 4
      locallib.php
  6. 8
      renderer.php
  7. 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->addElement('checkbox', 'addmultiply', '', get_string('createmultiplesessions', 'attendance'));
$mform->addHelpButton('addmultiply', 'createmultiplesessions', 'attendance'); $mform->addHelpButton('addmultiply', 'createmultiplesessions', 'attendance');
// Studetns can mark own attendance. // Students can mark own attendance.
$mform->addElement('checkbox', 'studentscanmark', '', get_string('studentscanmark','attforblock')); $mform->addElement('checkbox', 'studentscanmark', '', get_string('studentscanmark','attendance'));
$mform->addHelpButton('studentscanmark', 'studentscanmark', 'attforblock'); $mform->addHelpButton('studentscanmark', 'studentscanmark', 'attendance');
$mform->addElement('date_time_selector', 'sessiondate', get_string('sessiondate', 'attendance')); $mform->addElement('date_time_selector', 'sessiondate', get_string('sessiondate', 'attendance'));

18
attendance.php

@ -18,7 +18,7 @@
* Prints attendance info for particular user * Prints attendance info for particular user
* *
* @package mod * @package mod
* @subpackage attforblock * @subpackage attendance
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @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); $attforsession = $DB->get_record('attendance_sessions', array('id' => $id), '*', MUST_EXIST);
$attforblock = $DB->get_record('attforblock', array('id' => $attforsession->attendanceid), '*', MUST_EXIST); $attendance = $DB->get_record('attendance', array('id' => $attforsession->attendanceid), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('attforblock', $attforblock->id, 0, false, 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); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
// Require the user is logged in. // Require the user is logged in.
require_login($course, true, $cm); require_login($course, true, $cm);
$pageparams->sessionid = $id; $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 that a session key is passed to this page.
require_sesskey(); require_sesskey();
// Create the form. // 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)); array('course' => $course, 'cm' => $cm, 'modcontext' => $PAGE->context, 'session' => $attforsession, 'attendance' => $att));
if ($mform->is_cancelled()) { if ($mform->is_cancelled()) {
// The user cancelled the form, so redirect them to the view page. // 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); redirect($url);
} else if ($fromform = $mform->get_data()) { } else if ($fromform = $mform->get_data()) {
if (!empty($fromform->status)) { if (!empty($fromform->status)) {
$success = $att->take_from_student($fromform); $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) { if ($success) {
// Redirect back to the view page for the block. // Redirect back to the view page for the block.
redirect($url); redirect($url);
} else { } 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->set_cacheable(true);
$PAGE->navbar->add($att->name); $PAGE->navbar->add($att->name);
$output = $PAGE->get_renderer('mod_attforblock'); $output = $PAGE->get_renderer('mod_attendance');
echo $output->header(); echo $output->header();
$mform->display(); $mform->display();
echo $output->footer(); 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. // Link to attendance view by moduleid.
$search = "/(" . $base . "\/mod\/attendance\/view.php\?id\=)([0-9]+)/"; $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. // Link to attendance view by moduleid and studentid.
$search = "/(" . $base . "\/mod\/attendance\/view.php\?id\=)([0-9]+)\&studentid\=([0-9]+)/"; $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; 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() { static public function define_decode_rules() {
$rules = array(); $rules = array();
$rules[] = new restore_decode_rule('ATTFORBLOCKVIEWBYID', $rules[] = new restore_decode_rule('ATTENDANCEVIEWBYID',
'/mod/attendance/view.php?id=$1', 'course_module'); '/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')); '/mod/attendance/view.php?id=$1&studentid=$2', array('course_module', 'user'));
return $rules; return $rules;

4
locallib.php

@ -854,7 +854,7 @@ class attendance {
$record->studentid = $USER->id; $record->studentid = $USER->id;
$record->statusid = $mformdata->status; $record->statusid = $mformdata->status;
$record->statusset = $statuses; $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->sessionid = $mformdata->sessid;
$record->timetaken = $now; $record->timetaken = $now;
$record->takenby = $USER->id; $record->takenby = $USER->id;
@ -882,7 +882,7 @@ class attendance {
$params = array( $params = array(
'sessionid' => $mformdata->sessid); 'sessionid' => $mformdata->sessid);
$url = $this->url_take($params); $url = $this->url_take($params);
$this->log('attendance taked', $url, $USER->firstname.' '.$USER->lastname); add_to_log($this->course->id, 'attendance', 'taken', $url, '', $USER->id);
return true; return true;
} }

8
renderer.php

@ -174,7 +174,7 @@ class mod_attendance_renderer extends plugin_renderer_base {
$views[ATT_VIEW_ALL] = get_string('all', 'attendance'); $views[ATT_VIEW_ALL] = get_string('all', 'attendance');
$views[ATT_VIEW_ALLPAST] = get_string('allpast', 'attendance'); $views[ATT_VIEW_ALLPAST] = get_string('allpast', 'attendance');
if ($fcontrols->reportcontrol) { 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_MONTHS] = get_string('months', 'attendance');
$views[ATT_VIEW_WEEKS] = get_string('weeks', 'attendance'); $views[ATT_VIEW_WEEKS] = get_string('weeks', 'attendance');
@ -739,9 +739,9 @@ class mod_attendance_renderer extends plugin_renderer_base {
} else { } else {
if (!empty($sess->studentscanmark)) { // Student can mark their own attendance. if (!empty($sess->studentscanmark)) { // Student can mark their own attendance.
// URL to the page that lets the student modify their 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())); 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; $cell->colspan = 2;
$row->cells[] = $cell; $row->cells[] = $cell;
} else { // Student cannot mark their own attendace. } else { // Student cannot mark their own attendace.
@ -766,7 +766,7 @@ class mod_attendance_renderer extends plugin_renderer_base {
global $PAGE; global $PAGE;
// Initilise Javascript used to (un)check all checkboxes. // 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. // 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); $bulkmessagecapability = has_capability('moodle/course:bulkmessaging', $PAGE->context);

6
student_attenance_form.php

@ -16,7 +16,7 @@
require_once($CFG->libdir.'/formslib.php'); 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() { public function definition() {
global $CFG, $USER; 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. // Set a title as the date and time of the session.
$sesstiontitle = userdate($attforsession->sessdate, get_string('strftimedate')).' ' $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); $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. // 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->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(); $this->add_action_buttons();
} }

Loading…
Cancel
Save