Browse Source

Option to export remarks

MOODLE_26_STABLE
Gregory Faller 11 years ago
parent
commit
3bfcc5a476
  1. 5
      export.php
  2. 1
      export_form.php
  3. 1
      lang/en/attendance.php
  4. 3
      renderer.php
  5. 17
      renderhelpers.php

5
export.php

@ -98,6 +98,9 @@ if ($mform->is_submitted()) {
$text .= ' ';
$text .= $sess->groupid ? $reportdata->groups[$sess->groupid]->name : get_string('commonsession', 'attendance');
$data->tabhead[] = $text;
if (isset($formdata->includeremarks)) {
$data->tabhead[] = get_string('remark', 'attendance', $text);
}
}
} else {
print_error('sessionsnotfound', 'attendance', $att->url_manage());
@ -118,7 +121,7 @@ if ($mform->is_submitted()) {
$data->table[$i][] = $user->lastname;
$data->table[$i][] = $user->firstname;
$cellsgenerator = new user_sessions_cells_text_generator($reportdata, $user);
$data->table[$i] = array_merge($data->table[$i], $cellsgenerator->get_cells());
$data->table[$i] = array_merge($data->table[$i], $cellsgenerator->get_cells($formdata->includeremarks));
if ($reportdata->gradable) {
$data->table[$i][] = $reportdata->grades[$user->id].' / '.$reportdata->maxgrades[$user->id];
}

1
export_form.php

@ -72,6 +72,7 @@ class mod_attendance_export_form extends moodleform {
$mform->addElement('checkbox', 'includeallsessions', get_string('includeall', 'attendance'), get_string('yes'));
$mform->setDefault('includeallsessions', true);
$mform->addElement('checkbox', 'includenottaken', get_string('includenottaken', 'attendance'), get_string('yes'));
$mform->addElement('checkbox', 'includeremarks', get_string('includeremarks', 'attendance'), get_string('yes'));
$mform->addElement('date_selector', 'sessionstartdate', get_string('startofperiod', 'attendance'));
$mform->setDefault('sessionstartdate', $course->startdate);
$mform->disabledIf('sessionstartdate', 'includeallsessions', 'checked');

1
lang/en/attendance.php

@ -153,6 +153,7 @@ $string['olddate'] = 'Old date';
$string['period'] = 'Frequency';
$string['pluginname'] = 'Attendance';
$string['pluginadministration'] = 'Attendance administration';
$string['remark'] = 'Remark for: {a}';
$string['remarks'] = 'Remarks';
$string['report'] = 'Report';
$string['required'] = 'Required*';

3
renderer.php

@ -600,7 +600,8 @@ class mod_attendance_renderer extends plugin_renderer_base {
}
$params = array(
'type' => 'text',
'name' => 'remarks'.$user->id);
'name' => 'remarks'.$user->id,
'maxlength' => 255);
if (array_key_exists($user->id, $takedata->sessionlog)) {
$params['value'] = $takedata->sessionlog[$user->id]->remarks;
}

17
renderhelpers.php

@ -43,7 +43,7 @@ class user_sessions_cells_generator {
$this->user = $user;
}
public function get_cells() {
public function get_cells($remarks = false) {
$this->init_cells();
foreach ($this->reportdata->sessions as $sess) {
if (array_key_exists($sess->id, $this->reportdata->sessionslog[$this->user->id])) {
@ -53,6 +53,9 @@ class user_sessions_cells_generator {
} else {
$this->construct_hidden_status_cell($this->reportdata->allstatuses[$statusid]->acronym);
}
if ($remarks) {
$this->construct_remarks_cell($this->reportdata->sessionslog[$this->user->id][$sess->id]->remarks);
}
} else {
if ($this->user->enrolmentstart > $sess->sessdate) {
$starttext = get_string('enrolmentstart', 'attendance', userdate($this->user->enrolmentstart, '%d.%m.%Y'));
@ -71,6 +74,9 @@ class user_sessions_cells_generator {
$this->construct_not_existing_for_user_session_cell('');
}
}
if ($remarks) {
$this->construct_remarks_cell('');
}
}
}
$this->finalize_cells();
@ -98,6 +104,10 @@ class user_sessions_cells_generator {
$this->cells[] = $text;
}
protected function construct_remarks_cell($text) {
$this->cells[] = $text;
}
protected function construct_not_existing_for_user_session_cell($text) {
$this->cells[] = $text;
}
@ -151,6 +161,11 @@ class user_sessions_cells_html_generator extends user_sessions_cells_generator {
$this->cells[] = $text;
}
protected function construct_remarks_cell($text) {
$this->close_open_cell_if_needed();
$this->cells[] = $text;
}
protected function construct_not_existing_for_user_session_cell($text) {
$this->close_open_cell_if_needed();
$this->cells[] = $text;

Loading…
Cancel
Save