Browse Source

Make display of user 'extrafields' optional in report. (#294)

MOODLE_32_STABLE
Nick Phillips 7 years ago
committed by Dan Marsden
parent
commit
b365a6facb
  1. 2
      backup/moodle2/backup_attendance_stepslib.php
  2. 6
      classes/report_page_params.php
  3. 6
      classes/structure.php
  4. 3
      db/install.xml
  5. 10
      db/upgrade.php
  6. 1
      lang/en/attendance.php
  7. 20
      renderer.php
  8. 1
      report.php
  9. 4
      version.php

2
backup/moodle2/backup_attendance_stepslib.php

@ -44,7 +44,7 @@ class backup_attendance_activity_structure_step extends backup_activity_structur
// XML nodes declaration - non-user data.
$attendance = new backup_nested_element('attendance', array('id'), array(
'name', 'intro', 'introformat', 'grade', 'showsessiondetails', 'sessiondetailspos', 'subnet'));
'name', 'intro', 'introformat', 'grade', 'showextrauserdetails', 'showsessiondetails', 'sessiondetailspos', 'subnet'));
$statuses = new backup_nested_element('statuses');
$status = new backup_nested_element('status', array('id'), array(

6
classes/report_page_params.php

@ -35,6 +35,8 @@ class mod_attendance_report_page_params extends mod_attendance_page_with_filter_
/** @var int */
public $sort;
/** @var int */
public $showextrauserdetails;
/** @var int */
public $showsessiondetails;
/** @var int */
public $sessiondetailspos;
@ -73,6 +75,10 @@ class mod_attendance_report_page_params extends mod_attendance_page_with_filter_
$params['sort'] = $this->sort;
}
if (empty($this->showextrauserdetails)) {
$params['showextrauserdetails'] = 0;
}
if (empty($this->showsessiondetails)) {
$params['showsessiondetails'] = 0;
}

6
classes/structure.php

@ -76,6 +76,9 @@ class mod_attendance_structure {
/** @var boolean flag set when automarking is complete. */
public $automarkcompleted;
/** @var int Define if extra user details should be shown in reports */
public $showextrauserdetails;
/** @var int Define if session details should be shown in reports */
public $showsessiondetails;
@ -125,6 +128,9 @@ class mod_attendance_structure {
$this->pageparams = $pageparams;
if (isset($pageparams->showextrauserdetails) && $pageparams->showextrauserdetails != $this->showextrauserdetails) {
$DB->set_field('attendance', 'showextrauserdetails', $pageparams->showextrauserdetails, array('id' => $this->id));
}
if (isset($pageparams->showsessiondetails) && $pageparams->showsessiondetails != $this->showsessiondetails) {
$DB->set_field('attendance', 'showsessiondetails', $pageparams->showsessiondetails, array('id' => $this->id));
}

3
db/install.xml

@ -16,6 +16,7 @@
<FIELD NAME="subnet" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="Default subnet used when creating sessions."/>
<FIELD NAME="sessiondetailspos" TYPE="char" LENGTH="5" NOTNULL="true" DEFAULT="left" SEQUENCE="false" COMMENT="Position for the session detail columns related to summary columns."/>
<FIELD NAME="showsessiondetails" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="Define if session details should be shown in reports."/>
<FIELD NAME="showextrauserdetails" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="Define if extra user details should be shown in reports."/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for attendance"/>
@ -148,4 +149,4 @@
</INDEXES>
</TABLE>
</TABLES>
</XMLDB>
</XMLDB>

10
db/upgrade.php

@ -465,5 +465,15 @@ function xmldb_attendance_upgrade($oldversion=0) {
upgrade_mod_savepoint(true, 2016121325, 'attendance');
}
if ($oldversion < 2016121328) {
$table = new xmldb_table('attendance');
$field = new xmldb_field('showextrauserdetails', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', 'subnet');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
upgrade_mod_savepoint(true, 2016121328, 'attendance');
}
return $result;
}

1
lang/en/attendance.php

@ -418,6 +418,7 @@ $string['setunmarked'] = 'Automatically set when not marked';
$string['setunmarked_help'] = 'If enabled in the session, set this status if a student has not marked their own attendance.';
$string['showdefaults'] = 'Show defaults';
$string['showduration'] = 'Show duration';
$string['showextrauserdetails'] = 'Show extra user details';
$string['showsessiondetails'] = 'Show session details';
$string['somedisabledstatus'] = '(Some options have been removed as the session has started.)';
$string['sortedgrid'] = 'Sorted grid';

20
renderer.php

@ -1212,13 +1212,31 @@ class mod_attendance_renderer extends plugin_renderer_base {
* @return array Array of html_table_row objects
*/
protected function get_user_rows(attendance_report_data $reportdata) {
global $OUTPUT;
$rows = array();
$extrafields = get_extra_user_fields($reportdata->att->context);
$showextrauserdetails = $reportdata->pageparams->showextrauserdetails;
$params = $reportdata->pageparams->get_significant_params();
$text = get_string('users');
if ($extrafields) {
if ($showextrauserdetails) {
$params['showextrauserdetails'] = 0;
$url = $reportdata->att->url_report($params);
$text .= $OUTPUT->action_icon($url, new pix_icon('t/switch_minus',
get_string('hideextrauserdetails', 'attendance')), null, null);
} else {
$params['showextrauserdetails'] = 1;
$url = $reportdata->att->url_report($params);
$text .= $OUTPUT->action_icon($url, new pix_icon('t/switch_plus',
get_string('showextrauserdetails', 'attendance')), null, null);
$extrafields = array();
}
}
$usercolspan = 1 + count($extrafields);
$row = new html_table_row();
$row->cells[] = $this->build_header_cell('');
$row->cells[] = $this->build_header_cell(get_string('users'), false, false, $usercolspan);
$row->cells[] = $this->build_header_cell($text, false, false, $usercolspan);
$rows[] = $row;
$row = new html_table_row();

1
report.php

@ -46,6 +46,7 @@ $context = context_module::instance($cm->id);
require_capability('mod/attendance:viewreports', $context);
$pageparams->init($cm);
$pageparams->showextrauserdetails = optional_param('showextrauserdetails', $attrecord->showextrauserdetails, PARAM_INT);
$pageparams->showsessiondetails = optional_param('showsessiondetails', $attrecord->showsessiondetails, PARAM_INT);
$pageparams->sessiondetailspos = optional_param('sessiondetailspos', $attrecord->sessiondetailspos, PARAM_TEXT);

4
version.php

@ -23,9 +23,9 @@
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2016121327;
$plugin->version = 2016121328;
$plugin->requires = 2016111800;
$plugin->release = '3.2.19';
$plugin->release = '3.2.20';
$plugin->maturity = MATURITY_STABLE;
$plugin->cron = 0;
$plugin->component = 'mod_attendance';

Loading…
Cancel
Save