Browse Source

rebase changes

MOODLE_26_STABLE
Joseph Baxter 11 years ago
parent
commit
750a15a38d
  1. 4
      db/upgrade.php
  2. 31
      locallib.php
  3. 37
      renderer.php

4
db/upgrade.php

@ -32,6 +32,8 @@ function xmldb_attendance_upgrade($oldversion=0) {
global $CFG, $THEME, $DB; global $CFG, $THEME, $DB;
$dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes. $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
$result = true;
if ($oldversion < 2013082901) { if ($oldversion < 2013082901) {
$table = new xmldb_table('attendance_sessions'); $table = new xmldb_table('attendance_sessions');
@ -41,7 +43,7 @@ function xmldb_attendance_upgrade($oldversion=0) {
$dbman->add_field($table, $field); $dbman->add_field($table, $field);
} }
upgrade_mod_savepoint(true, 2013082901, 'attendance'); upgrade_mod_savepoint($result, 2013082901, 'attendance');
} }
if ($oldversion < 2013082902) { if ($oldversion < 2013082902) {

31
locallib.php

@ -1190,7 +1190,7 @@ class attendance {
GROUP BY al.statusid"; GROUP BY al.statusid";
} }
}
// Make the filter array into a SQL string. // Make the filter array into a SQL string.
if (!empty($processed_filters)) { if (!empty($processed_filters)) {
@ -1315,7 +1315,7 @@ class attendance {
// It would be better as a UNION query butunfortunatly MS SQL does not seem to support doing a DISTINCT on a the description field. // It would be better as a UNION query butunfortunatly MS SQL does not seem to support doing a DISTINCT on a the description field.
$id = $DB->sql_concat(':value', 'ats.id'); $id = $DB->sql_concat(':value', 'ats.id');
if ($this->get_group_mode()) { if ($this->get_group_mode()) {
$sql = "SELECT $id, ats.id, ats.groupid, ats.sessdate, ats.duration, ats.description, al.statusid, al.remarks $sql = "SELECT $id, ats.id, ats.groupid, ats.sessdate, ats.duration, ats.description, al.statusid, al.remarks, ats.studentscanmark
FROM {attendance_sessions} ats FROM {attendance_sessions} ats
RIGHT JOIN {attendance_log} al RIGHT JOIN {attendance_log} al
ON ats.id = al.sessionid AND al.studentid = :uid ON ats.id = al.sessionid AND al.studentid = :uid
@ -1323,7 +1323,7 @@ class attendance {
WHERE $where AND (ats.groupid = 0 or gm.id is NOT NULL) WHERE $where AND (ats.groupid = 0 or gm.id is NOT NULL)
ORDER BY ats.sessdate ASC"; ORDER BY ats.sessdate ASC";
} else { } else {
$sql = "SELECT $id, ats.id, ats.groupid, ats.sessdate, ats.duration, ats.description, al.statusid, al.remarks $sql = "SELECT $id, ats.id, ats.groupid, ats.sessdate, ats.duration, ats.description, al.statusid, al.remarks, ats.studentscanmark
FROM {attendance_sessions} ats FROM {attendance_sessions} ats
RIGHT JOIN {attendance_log} al RIGHT JOIN {attendance_log} al
ON ats.id = al.sessionid AND al.studentid = :uid ON ats.id = al.sessionid AND al.studentid = :uid
@ -1353,7 +1353,7 @@ class attendance {
$where = "ats.attendanceid = :aid AND ats.sessdate >= :csdate AND ats.groupid $gsql"; $where = "ats.attendanceid = :aid AND ats.sessdate >= :csdate AND ats.groupid $gsql";
} }
$sql = "SELECT $id, ats.id, ats.groupid, ats.sessdate, ats.duration, ats.description, al.statusid, al.remarks $sql = "SELECT $id, ats.id, ats.groupid, ats.sessdate, ats.duration, ats.description, al.statusid, al.remarks, ats.studentscanmark
FROM {attendance_sessions} ats FROM {attendance_sessions} ats
LEFT JOIN {attendance_log} al LEFT JOIN {attendance_log} al
ON ats.id = al.sessionid AND al.studentid = :uid ON ats.id = al.sessionid AND al.studentid = :uid
@ -1395,9 +1395,6 @@ class attendance {
$DB->update_record('attendance_sessions', $sess); $DB->update_record('attendance_sessions', $sess);
} }
$sessions->close(); $sessions->close();
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)); $this->log('sessions duration updated', $this->url_manage(), get_string('sessionsids', 'attendance').implode(', ', $sessionsids));
} }
@ -1452,6 +1449,26 @@ class attendance {
$this->log('status updated', $this->url_preferences(), implode(' ', $updated)); $this->log('status updated', $this->url_preferences(), implode(' ', $updated));
} }
/**
* wrapper around {@see add_to_log()}
*
* @param string $action to be logged
* @param moodle_url $url absolute url, if null will be used $this->url_manage()
* @param mixed $info additional info, usually id in a table
*/
public function log($action, moodle_url $url = null, $info = null) {
if (is_null($url)) {
$url = $this->url_manage();
}
if (is_null($info)) {
$info = $this->id;
}
$logurl = att_log_convert_url($url);
add_to_log($this->course->id, 'attforblock', $action, $logurl, $info, $this->cm->id);
}
} }

37
renderer.php

@ -820,7 +820,6 @@ class mod_attendance_renderer extends plugin_renderer_base {
$table->size[] = '1px'; $table->size[] = '1px';
} }
if ($reportdata->sessionslog) { if ($reportdata->sessionslog) {
$table->head[] = get_string('remarks', 'attendance'); $table->head[] = get_string('remarks', 'attendance');
$table->align[] = 'center'; $table->align[] = 'center';
@ -852,24 +851,6 @@ class mod_attendance_renderer extends plugin_renderer_base {
$row->cells[] = html_writer::checkbox('user'.$user->id, 'on', false); $row->cells[] = html_writer::checkbox('user'.$user->id, 'on', false);
} }
$table->data[] = $row;
}
if ($bulkmessagecapability) { // Require that the user can bulk message users.
// Display check boxes that will allow the user to send a message to the students that have been checked.
$output = html_writer::empty_tag('input', array('name' => 'sesskey', 'type' => 'hidden', 'value' => sesskey()));
$output .= html_writer::empty_tag('input', array('name' => 'formaction', 'type' => 'hidden', 'value' => 'messageselect.php'));
$output .= html_writer::empty_tag('input', array('name' => 'id', 'type' => 'hidden', 'value' => $GLOBALS['COURSE']->id));
$output .= html_writer::empty_tag('input', array('name' => 'returnto', 'type' => 'hidden', 'value' => s(me())));
$output .= html_writer::table($table);
$output .= html_writer::tag('div',
html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('messageselectadd'))),
array('class' => 'buttons'));
$url = new moodle_url('/user/action_redir.php');
return html_writer::tag('form', $output, array('action' => $url->out(), 'method' => 'post'));
} else {
return html_writer::table($table);
}
if ($reportdata->sessionslog) { if ($reportdata->sessionslog) {
if (isset($sess) && isset($reportdata->sessionslog[$user->id][$sess->id]->remarks)) { if (isset($sess) && isset($reportdata->sessionslog[$user->id][$sess->id]->remarks)) {
$row->cells[] = $reportdata->sessionslog[$user->id][$sess->id]->remarks; $row->cells[] = $reportdata->sessionslog[$user->id][$sess->id]->remarks;
@ -900,7 +881,23 @@ class mod_attendance_renderer extends plugin_renderer_base {
} }
$table->data[] = $statrow; $table->data[] = $statrow;
return html_writer::table($table).html_writer::tag('div', get_string('users').': '.count($reportdata->users)); if ($bulkmessagecapability) { // Require that the user can bulk message users.
// Display check boxes that will allow the user to send a message to the students that have been checked.
$output = html_writer::empty_tag('input', array('name' => 'sesskey', 'type' => 'hidden', 'value' => sesskey()));
$output .= html_writer::empty_tag('input', array('name' => 'formaction', 'type' => 'hidden', 'value' => 'messageselect.php'));
$output .= html_writer::empty_tag('input', array('name' => 'id', 'type' => 'hidden', 'value' => $GLOBALS['COURSE']->id));
$output .= html_writer::empty_tag('input', array('name' => 'returnto', 'type' => 'hidden', 'value' => s(me())));
$output .= html_writer::table($table);
$output .= html_writer::tag('div',
html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('messageselectadd'))),
array('class' => 'buttons'));
$url = new moodle_url('/user/action_redir.php');
html_writer::tag('div', get_string('users').': '.count($reportdata->users));
return html_writer::tag('form', $output, array('action' => $url->out(), 'method' => 'post'));
} else {
return html_writer::table($table).html_writer::tag('div', get_string('users').': '.count($reportdata->users));
}
} }
protected function render_attendance_preferences_data(attendance_preferences_data $prefdata) { protected function render_attendance_preferences_data(attendance_preferences_data $prefdata) {

Loading…
Cancel
Save