$string['submitattendance'] = 'Submit attendance';
$string['attendancenotset'] = 'You must set your attendance';
$string['export'] = 'Export';
+$string['points'] = 'Points';
+$string['unknowngroup'] = 'Unknown group';
+$string['notmember'] = 'not member';
+
+$string['deletehiddensessions'] = 'Delete all hidden sessions';
+$string['confirmdeletehiddensessions'] = 'Are you sure you want to delete {$a->count} sessions scheduled before the course start date ({$a->date})?';
+$string['hiddensessionsdeleted'] = 'All hidden sessions were delete';
const ACTION_DELETE = 3;
const ACTION_DELETE_SELECTED = 4;
const ACTION_CHANGE_DURATION = 5;
+ const ACTION_DELETE_HIDDEN = 6;
/** @var int view mode of taking attendance page*/
public $action;
return $DB->count_records_select('attendance_sessions', $where, $params);
}
+ /**
+ * Returns the hidden sessions for this attendance
+ *
+ * Fetches data from {attendance_sessions}
+ *
+ * @return hidden sessions
+ */
+ public function get_hidden_sessions() {
+ global $DB;
+
+ $where = "attendanceid = :aid AND sessdate < :csdate";
+ $params = array(
+ 'aid' => $this->id,
+ 'csdate'=> $this->course->startdate);
+
+ return $DB->get_records_select('attendance_sessions', $where, $params);
+ }
+
public function get_filtered_sessions() {
global $DB;
}
protected function render_sess_manage_control(attendance_manage_data $sessdata) {
+ global $OUTPUT;
+
$table = new html_table();
$table->attributes['class'] = ' ';
$table->width = '100%';
get_string('hiddensessions', 'attendance').': '.$sessdata->hiddensessionscount);
if (has_capability('mod/attendance:manageattendances', $sessdata->att->context)) {
+ if ($sessdata->hiddensessionscount > 0) {
+ $attributes = array(
+ 'type' => 'submit',
+ 'name' => 'deletehiddensessions',
+ 'value' => get_string('deletehiddensessions', 'attendance'));
+ $table->data[1][] = html_writer::empty_tag('input', $attributes);
+ }
+
$options = array(
att_sessions_page_params::ACTION_DELETE_SELECTED => get_string('delete'),
att_sessions_page_params::ACTION_CHANGE_DURATION => get_string('changeduration', 'attendance'));
$id = required_param('id', PARAM_INT);
$pageparams->action = required_param('action', PARAM_INT);
+if (optional_param('deletehiddensessions', false, PARAM_TEXT)) {
+ $pageparams->action = att_sessions_page_params::ACTION_DELETE_HIDDEN;
+}
+
if (empty($pageparams->action)) {
// The form on manage.php can submit with the "choose" option - this should be fixed in the long term,
// but in the meantime show a useful error and redirect when it occurs.
}
break;
+ case att_sessions_page_params::ACTION_DELETE_HIDDEN:
+ $confirm = optional_param('confirm', null, PARAM_INT);
+ if ($confirm && confirm_sesskey()) {
+ $sessions = $att->get_hidden_sessions();
+ $att->delete_sessions(array_keys($sessions));
+ redirect($att->url_manage(), get_string('hiddensessionsdeleted', 'attendance'));
+ }
+
+ $a = new stdClass();
+ $a->count = $att->get_hidden_sessions_count();
+ $a->date = userdate($course->startdate);
+ $message = get_string('confirmdeletehiddensessions', 'attendance', $a);
+
+ $params = array('action' => $att->pageparams->action, 'confirm' => 1, 'sesskey' => sesskey());
+ echo $OUTPUT->header();
+ echo $OUTPUT->heading(get_string('attendanceforthecourse', 'attendance').' :: ' .format_string($course->fullname));
+ echo $OUTPUT->confirm($message, $att->url_sessions($params), $att->url_manage());
+ echo $OUTPUT->footer();
+ exit;
}
$output = $PAGE->get_renderer('mod_attendance');