Example #1
1
 /**
  * Constructor
  *
  * @param int $tagcollid
  */
 public function __construct($tagcollid)
 {
     global $USER, $CFG, $PAGE;
     parent::__construct('tag-management-list-' . $USER->id);
     $this->tagcollid = $tagcollid;
     $perpage = optional_param('perpage', DEFAULT_PAGE_SIZE, PARAM_INT);
     $page = optional_param('page', 0, PARAM_INT);
     $baseurl = new moodle_url('/tag/manage.php', array('tc' => $tagcollid, 'perpage' => $perpage, 'page' => $page));
     $tablecolumns = array('select', 'name', 'fullname', 'count', 'flag', 'timemodified', 'tagtype', 'controls');
     $tableheaders = array(get_string('select', 'tag'), get_string('name', 'tag'), get_string('owner', 'tag'), get_string('count', 'tag'), get_string('flag', 'tag'), get_string('timemodified', 'tag'), get_string('officialtag', 'tag'), '');
     $this->define_columns($tablecolumns);
     $this->define_headers($tableheaders);
     $this->define_baseurl($baseurl);
     $this->column_class('select', 'mdl-align col-select');
     $this->column_class('name', 'col-name');
     $this->column_class('owner', 'col-owner');
     $this->column_class('count', 'mdl-align col-count');
     $this->column_class('flag', 'mdl-align col-flag');
     $this->column_class('timemodified', 'col-timemodified');
     $this->column_class('tagtype', 'mdl-align col-tagtype');
     $this->column_class('controls', 'mdl-align col-controls');
     $this->sortable(true, 'flag', SORT_DESC);
     $this->no_sorting('select');
     $this->no_sorting('controls');
     $this->set_attribute('cellspacing', '0');
     $this->set_attribute('id', 'tag-management-list');
     $this->set_attribute('class', 'admintable generaltable tag-management-table');
     $totalcount = "SELECT COUNT(id)\n            FROM {tag}\n            WHERE tagcollid = :tagcollid";
     $params = array('tagcollid' => $this->tagcollid);
     $this->set_count_sql($totalcount, $params);
     $this->set_sql('', '', '', $params);
     $this->collapsible(true);
     $PAGE->requires->js_call_amd('core/tag', 'init_manage_page', array());
 }
 /**
  * Constructor.
  *
  * @param string $uniqueid Unique ID.
  * @param int $courseid Course ID.
  * @param int $groupid Group ID.
  */
 public function __construct($uniqueid, $courseid, $groupid)
 {
     parent::__construct($uniqueid);
     $this->courseid = $courseid;
     // Define columns.
     $this->define_columns(array('time', 'fullname', 'xp', 'eventname'));
     $this->define_headers(array(get_string('eventtime', 'block_xp'), get_string('fullname'), get_string('xp', 'block_xp'), get_string('eventname', 'block_xp')));
     // Define SQL.
     $sqlfrom = '';
     $sqlparams = array();
     if ($groupid) {
         $sqlfrom = '{block_xp_log} x
                  JOIN {groups_members} gm
                    ON gm.groupid = :groupid
                   AND gm.userid = x.userid
             LEFT JOIN {user} u
                    ON x.userid = u.id';
         $sqlparams = array('groupid' => $groupid);
     } else {
         $sqlfrom = '{block_xp_log} x LEFT JOIN {user} u ON x.userid = u.id';
     }
     // Define SQL.
     $this->sql = new stdClass();
     $this->sql->fields = 'x.*, ' . get_all_user_name_fields(true, 'u');
     $this->sql->from = $sqlfrom;
     $this->sql->where = 'courseid = :courseid';
     $this->sql->params = array_merge(array('courseid' => $courseid), $sqlparams);
     // Define various table settings.
     $this->sortable(true, 'time', SORT_DESC);
     $this->collapsible(false);
 }
Example #3
0
 /**
  * @return string sql to add to where statement.
  */
 function get_sql_where()
 {
     $filter = optional_param('filter', '', PARAM_NOTAGS);
     list($wsql, $wparams) = parent::get_sql_where();
     if ($filter !== '') {
         $wsql .= ($wsql ? ' AND ' : '') . 'tg.name LIKE :tagfilter';
         $wparams['tagfilter'] = '%' . $filter . '%';
     }
     return array($wsql, $wparams);
 }
 /**
  * Constructor
  * @param int $uniqueid all tables have to have a unique id, this is used
  *      as a key when storing table properties like sort order in the session.
  */
 public function __construct($uniqueid)
 {
     parent::__construct($uniqueid);
     // Define the list of columns to show.
     $columns = array('course_code', 'course_name', 'empctry', 'email', 'firstname', 'completion_date', 'completion_status');
     // Define the titles of columns to show in header.
     $headers = array(get_string('coursecode', 'block_ps_selfstudy'), get_string('title', 'block_ps_selfstudy'), get_string('empserial', 'block_ps_selfstudy'), get_string('email', 'block_ps_selfstudy'), get_string('name', 'block_ps_selfstudy'), get_string('completiondate', 'block_ps_selfstudy'), get_string('completionstatus', 'block_ps_selfstudy'));
     $this->sortable(true, 'course_code', SORT_ASC);
     $this->collapsible(false);
     $this->define_columns($columns);
     $this->define_headers($headers);
 }
 /**
  * Constructor
  * @param int $uniqueid all tables have to have a unique id, this is used
  *      as a key when storing table properties like sort order in the session.
  */
 function __construct($uniqueid)
 {
     parent::__construct($uniqueid);
     // Define the list of columns to show.
     $columns = array('selected', 'completed', 'institution', 'fullname', 'timecreated');
     $this->define_columns($columns);
     // Define the titles of columns to show in header.
     $headers = array('', get_string('completed', 'mod_booking'), get_string('institution', 'mod_booking'), get_string('fullname', 'mod_booking'), get_string('timecreated', 'mod_booking'));
     $this->define_headers($headers);
     $this->collapsible(false);
     $this->sortable(true);
     $this->pageable(true);
 }
Example #6
0
 /**
  * Sets up the table.
  *
  * @param string $courseid The id of the course.
  */
 public function __construct($courseid)
 {
     parent::__construct('enrol_lti_manage_table');
     $this->define_columns(array('name', 'url', 'secret', 'edit'));
     $this->define_headers(array(get_string('name'), get_string('url'), get_string('secret', 'enrol_lti'), get_string('edit')));
     $this->collapsible(false);
     $this->sortable(false);
     // Set the variables we need access to.
     $this->ltiplugin = enrol_get_plugin('lti');
     $this->ltienabled = enrol_is_enabled('lti');
     $this->canconfig = has_capability('moodle/course:enrolconfig', \context_course::instance($courseid));
     $this->courseid = $courseid;
 }
 /**
  * Constructor
  * @param int $uniqueid all tables have to have a unique id, this is used
  *      as a key when storing table properties like sort order in the session.
  */
 public function __construct($uniqueid)
 {
     parent::__construct($uniqueid);
     // Define the list of columns to show.
     $columns = array('course_code', 'course_platform', 'course_name', 'course_description', 'course_hours', 'course_type', 'actions');
     $this->sortable(true, 'course_code', SORT_ASC);
     $this->collapsible(false);
     $this->no_sorting('actions');
     $this->no_sorting('course_description');
     $this->define_columns($columns);
     // Define the titles of columns to show in header.
     $headers = array('Course Code', 'Course Platform', 'Course Name', 'Description', 'Hours', 'Course Type', 'Action');
     $this->define_headers($headers);
 }
 /**
  * Constructor
  * @param int $uniqueid all tables have to have a unique id, this is used
  *      as a key when storing table properties like sort order in the session.
  */
 function __construct($uniqueid)
 {
     parent::__construct($uniqueid);
     // Define the list of columns to show.
     $columns = array('name', 'selected');
     $this->define_columns($columns);
     // Define the titles of columns to show in header.
     $headers = array(get_string('selectcategory', 'local_saml_site'), '');
     $this->define_headers($headers);
     $this->collapsible(false);
     $this->sortable(true);
     $this->pageable(true);
     $this->rulestype[1] = get_string('usernamedomainname', 'local_saml_site');
 }
 /**
  * Constructor
  * @param int $uniqueid all tables have to have a unique id,  this is used
  *      as a key when storing table properties like sort order in the session.
  */
 public function __construct($uniqueid)
 {
     parent::__construct($uniqueid);
     // Define the list of columns to show.
     $columns = array('course_code', 'course_platform', 'course_name', 'course_description', 'course_hours', 'course_type', 'course_status', 'date_created', 'actions');
     $this->sortable(true, 'course_code', SORT_ASC);
     $this->collapsible(false);
     $this->no_sorting('actions');
     $this->no_sorting('course_description');
     $this->define_columns($columns);
     // Define the titles of columns to show in header.
     $headers = array(get_string('coursecode', 'block_ps_selfstudy'), get_string('platform', 'block_ps_selfstudy'), get_string('coursename', 'block_ps_selfstudy'), get_string('description', 'block_ps_selfstudy'), get_string('hours', 'block_ps_selfstudy'), get_string('coursetype', 'block_ps_selfstudy'), get_string('status', 'block_ps_selfstudy'), get_string('datecreated', 'block_ps_selfstudy'), get_string('action', 'block_ps_selfstudy'));
     $this->define_headers($headers);
 }
Example #10
0
 /**
  * Sets up the table_log parameters.
  *
  * @param string $uniqueid unique id of form.
  * @param \moodle_url $url url where this table is displayed.
  * @param int $courseid course id.
  * @param int $perpage Number of rules to display per page.
  */
 public function __construct($uniqueid, \moodle_url $url, $courseid = 0, $perpage = 100)
 {
     parent::__construct($uniqueid);
     $this->set_attribute('class', 'toolmonitor subscriptions generaltable generalbox');
     $this->define_columns(array('name', 'description', 'course', 'plugin', 'instance', 'eventname', 'filters', 'unsubscribe'));
     $this->define_headers(array(get_string('rulename', 'tool_monitor'), get_string('description'), get_string('course'), get_string('area', 'tool_monitor'), get_string('moduleinstance', 'tool_monitor'), get_string('event', 'tool_monitor'), get_string('frequency', 'tool_monitor'), get_string('unsubscribe', 'tool_monitor')));
     $this->courseid = $courseid;
     $this->pagesize = $perpage;
     $systemcontext = \context_system::instance();
     $this->context = empty($courseid) ? $systemcontext : \context_course::instance($courseid);
     $this->collapsible(false);
     $this->sortable(false);
     $this->pageable(true);
     $this->is_downloadable(false);
     $this->define_baseurl($url);
 }
 /**
  * Constructor
  * @param int $uniqueid all tables have to have a unique id, this is used
  *      as a key when storing table properties like sort order in the session.
  */
 function __construct($uniqueid)
 {
     parent::__construct($uniqueid);
     // Define the list of columns to show.
     $columns = array('purchase_date', 'id', 'user_id', 'amount', 'items', 'gateway', 'txn_id', 'status', 'actions');
     $this->define_columns($columns);
     // Define the titles of columns to show in header.
     $headers = array(get_string('transaction_field_date', 'local_moodec'), get_string('transaction_field_id', 'local_moodec'), get_string('transaction_field_user', 'local_moodec'), get_string('transaction_field_amount', 'local_moodec'), get_string('transaction_field_items', 'local_moodec'), get_string('transaction_field_gateway', 'local_moodec'), get_string('transaction_field_txn', 'local_moodec'), get_string('transaction_field_status', 'local_moodec'), get_string('transaction_field_actions', 'local_moodec'));
     $this->define_headers($headers);
     $this->sortable(true, 'purchase_date', SORT_DESC);
     $this->no_sorting('user_id');
     $this->no_sorting('amount');
     $this->no_sorting('items');
     $this->no_sorting('txn_id');
     $this->no_sorting('gateway');
     $this->no_sorting('actions');
 }
 public function __construct($uniqueid)
 {
     global $PAGE, $USER;
     parent::__construct($uniqueid);
     $this->define_columns(array('userpic', 'fullname', 'total', 'posts', 'replies', 'substantive'));
     $this->define_headers(array('', get_string('fullnameuser'), get_string('totalposts', 'hsuforum'), get_string('posts', 'hsuforum'), get_string('replies', 'hsuforum'), get_string('substantive', 'hsuforum')));
     $fields = user_picture::fields('u', null, 'id');
     $params = array('forumid' => $PAGE->activityrecord->id);
     if (!has_capability('mod/hsuforum:viewposters', $PAGE->context)) {
         $params['userid'] = $USER->id;
         $usersql = ' AND u.id = :userid ';
     } else {
         $usersql = '';
     }
     $this->set_sql("{$fields},\n             COUNT(*) AS total,\n             SUM(CASE WHEN p.parent = 0 THEN 1 ELSE 0 END) AS posts,\n             SUM(CASE WHEN p.parent != 0 THEN 1 ELSE 0 END) AS replies,\n             SUM(CASE WHEN p.flags LIKE '%substantive%' THEN 1 ELSE 0 END) AS substantive", '{hsuforum_posts} p, {hsuforum_discussions} d, {hsuforum} f, {user} u', "u.id = p.userid AND p.discussion = d.id AND d.forum = f.id AND f.id = :forumid{$usersql} GROUP BY p.userid", $params);
     $this->set_count_sql("\n            SELECT COUNT(DISTINCT p.userid)\n              FROM {hsuforum_posts} p\n              JOIN {user} u ON u.id = p.userid\n              JOIN {hsuforum_discussions} d ON d.id = p.discussion\n              JOIN {hsuforum} f ON f.id = d.forum\n              WHERE f.id = :forumid{$usersql}\n        ", $params);
 }
 /**
  * Constructor.
  *
  * @param string $uniqueid Unique ID.
  */
 public function __construct($uniqueid, $courseid)
 {
     parent::__construct($uniqueid);
     $this->courseid = $courseid;
     // Define columns.
     $this->define_columns(array('time', 'fullname', 'xp', 'eventname', 'actions'));
     $this->define_headers(array(get_string('eventtime', 'block_xp'), get_string('fullname'), get_string('xp', 'block_xp'), get_string('eventname', 'block_xp'), ''));
     // Define SQL.
     $this->sql = new stdClass();
     $this->sql->fields = 'x.*, ' . get_all_user_name_fields(true, 'u');
     $this->sql->from = '{block_xp_log} x LEFT JOIN {user} u ON x.userid = u.id';
     $this->sql->where = 'courseid = :courseid';
     $this->sql->params = array('courseid' => $courseid);
     // Define various table settings.
     $this->sortable(true, 'time', SORT_DESC);
     $this->collapsible(false);
 }
 /**
  * Constructor
  * @param int $uniqueid all tables have to have a unique id, this is used
  *      as a key when storing table properties like sort order in the session.
  */
 public function __construct($uniqueid)
 {
     parent::__construct($uniqueid);
     // Define the list of columns to show.
     $columns = array('course_code', 'course_name', 'email', 'firstname', 'address', 'address2', 'city', 'state', 'zipcode', 'country', 'phone1', 'request_date', 'request_status');
     // Define the titles of columns to show in header.
     $headers = array(get_string('coursecode', 'block_ps_selfstudy'), get_string('title', 'block_ps_selfstudy'), get_string('email', 'block_ps_selfstudy'), get_string('firstname', 'block_ps_selfstudy'), get_string('address', 'block_ps_selfstudy'), get_string('address2', 'block_ps_selfstudy'), get_string('city', 'block_ps_selfstudy'), get_string('state', 'block_ps_selfstudy'), get_string('zip', 'block_ps_selfstudy'), get_string('country', 'block_ps_selfstudy'), get_string('phone1', 'block_ps_selfstudy'), get_string('requestdate', 'block_ps_selfstudy'), get_string('status', 'block_ps_selfstudy'));
     if (!$this->is_downloading()) {
         $columns[] = 'actions';
         $headers[] = 'Action';
     }
     global $DB;
     $this->sortable(true, 'course_code', SORT_ASC);
     $this->collapsible(false);
     $this->no_sorting('actions');
     $this->define_columns($columns);
     $this->define_headers($headers);
 }
Example #15
0
 /**
  * Sets up the table_log parameters.
  *
  * @param string $uniqueid unique id of form.
  * @param \moodle_url $url url where this table is displayed.
  * @param int $courseid course id.
  * @param int $perpage Number of rules to display per page.
  */
 public function __construct($uniqueid, \moodle_url $url, $courseid = 0, $perpage = 100)
 {
     global $PAGE;
     parent::__construct($uniqueid);
     $this->set_attribute('class', 'toolmonitor subscriptions generaltable generalbox');
     $this->define_columns(array('name', 'course', 'instance', 'unsubscribe', 'editrule'));
     $this->define_headers(array(get_string('name'), get_string('course'), get_string('moduleinstance', 'tool_monitor'), get_string('unsubscribe', 'tool_monitor'), get_string('editrule', 'tool_monitor')));
     $this->courseid = $courseid;
     $this->pagesize = $perpage;
     $systemcontext = \context_system::instance();
     $this->context = empty($courseid) ? $systemcontext : \context_course::instance($courseid);
     $this->collapsible(false);
     $this->sortable(false);
     $this->pageable(true);
     $this->is_downloadable(false);
     $this->define_baseurl($url);
     $this->helpiconrenderer = $PAGE->get_renderer('tool_monitor', 'helpicon');
 }
 /**
  * Sets up the table_log parameters.
  *
  * @param string $uniqueid unique id of form.
  * @param stdClass $filterparams (optional) filter params.
  *     - int courseid: id of course
  *     - int userid: user id
  *     - int|string modid: Module id or "site_errors" to view site errors
  *     - int groupid: Group id
  *     - \core\log\sql_select_reader logreader: reader from which data will be fetched.
  *     - int edulevel: educational level.
  *     - string action: view action
  *     - int date: Date from which logs to be viewed.
  */
 public function __construct($uniqueid, $filterparams = null)
 {
     parent::__construct($uniqueid);
     $this->set_attribute('class', 'reportlog generaltable generalbox');
     $this->filterparams = $filterparams;
     // Add course column if logs are displayed for site.
     $cols = array();
     $headers = array();
     if (empty($filterparams->courseid)) {
         $cols = array('course');
         $headers = array(get_string('course'));
     }
     $this->define_columns(array_merge($cols, array('time', 'fullnameuser', 'relatedfullnameuser', 'context', 'component', 'eventname', 'description', 'origin', 'ip')));
     $this->define_headers(array_merge($headers, array(get_string('time'), get_string('fullnameuser'), get_string('eventrelatedfullnameuser', 'report_log'), get_string('eventcontext', 'report_log'), get_string('eventcomponent', 'report_log'), get_string('eventname'), get_string('description'), get_string('eventorigin', 'report_log'), get_string('ip_address'))));
     $this->collapsible(false);
     $this->sortable(false);
     $this->pageable(true);
 }
Example #17
0
 /**
  * Sets up the table_log parameters.
  *
  * @param string $uniqueid unique id of table.
  * @param \context_course $context Context of the report.
  * @param \moodle_url $url url of the page where this table would be displayed.
  * @param array $filters options are:
  *                          userids : limit to specific users (default: none)
  *                          itemid : limit to specific grade item (default: all)
  *                          grader : limit to specific graders (default: all)
  *                          datefrom : start of date range
  *                          datetill : end of date range
  *                          revisedonly : only show revised grades (default: false)
  *                          format : page | csv | excel (default: page)
  * @param string $download Represents download format, pass '' no download at this time.
  * @param int $page The current page being displayed.
  * @param int $perpage Number of rules to display per page.
  */
 public function __construct($uniqueid, \context_course $context, $url, $filters = array(), $download = '', $page = 0, $perpage = 100)
 {
     parent::__construct($uniqueid);
     $this->set_attribute('class', 'gradereport_history generaltable generalbox');
     // Set protected properties.
     $this->context = $context;
     $this->courseid = $this->context->instanceid;
     $this->pagesize = $perpage;
     $this->page = $page;
     $this->filters = (object) $filters;
     $this->gradeitems = \grade_item::fetch_all(array('courseid' => $this->courseid));
     $this->cms = get_fast_modinfo($this->courseid);
     $this->useridfield = 'userid';
     // Define columns in the table.
     $this->define_table_columns();
     // Define configs.
     $this->define_table_configs($url);
     // Set download status.
     $this->is_downloading($download, get_string('exportfilename', 'gradereport_history'));
 }
 /**
  * Constructor.
  *
  * @param string $uniqueid Unique ID.
  */
 public function __construct($uniqueid, $courseid)
 {
     global $PAGE;
     parent::__construct($uniqueid);
     // Block XP stuff.
     $this->xpmanager = block_xp_manager::get($courseid);
     $this->xpoutput = $PAGE->get_renderer('block_xp');
     // Define columns.
     $this->define_columns(array('rank', 'userpic', 'fullname', 'lvl', 'xp', 'progress'));
     $this->define_headers(array(get_string('rank', 'block_xp'), '', get_string('fullname'), get_string('level', 'block_xp'), get_string('xp', 'block_xp'), get_string('progress', 'block_xp')));
     // Define SQL.
     $this->sql = new stdClass();
     $this->sql->fields = 'x.*, ' . user_picture::fields('u');
     $this->sql->from = '{block_xp} x LEFT JOIN {user} u ON x.userid = u.id';
     $this->sql->where = 'courseid = :courseid';
     $this->sql->params = array('courseid' => $courseid);
     // Define various table settings.
     $this->sortable(false);
     $this->no_sorting('userpic');
     $this->no_sorting('progress');
     $this->collapsible(false);
 }
 /**
  * Constructor.
  *
  * @param string $uniqueid Unique ID.
  */
 public function __construct($uniqueid, $courseid)
 {
     global $DB, $PAGE;
     parent::__construct($uniqueid);
     // Block XP stuff.
     $this->xpmanager = block_xp_manager::get($courseid);
     $this->xpoutput = $PAGE->get_renderer('block_xp');
     $context = context_course::instance($courseid);
     // Define columns.
     $this->define_columns(array('userpic', 'fullname', 'lvl', 'xp', 'progress', 'actions'));
     $this->define_headers(array('', get_string('fullname'), get_string('level', 'block_xp'), get_string('xp', 'block_xp'), get_string('progress', 'block_xp'), ''));
     // Get the relevant user IDs, users enrolled or users with XP.
     // This might be a performance issue at some point.
     $ids = array();
     $users = get_enrolled_users($context, 'block/xp:earnxp');
     foreach ($users as $user) {
         $ids[$user->id] = $user->id;
     }
     unset($users);
     $entries = $DB->get_recordset_sql('SELECT userid FROM {block_xp} WHERE courseid = :courseid', array('courseid' => $courseid));
     foreach ($entries as $entry) {
         $ids[$entry->userid] = $entry->userid;
     }
     $entries->close();
     list($insql, $inparams) = $DB->get_in_or_equal($ids, SQL_PARAMS_NAMED, 'param', true, null);
     // Define SQL.
     $this->sql = new stdClass();
     $this->sql->fields = user_picture::fields('u') . ', x.lvl, x.xp';
     $this->sql->from = "{user} u LEFT JOIN {block_xp} x ON (x.userid = u.id AND x.courseid = :courseid)";
     $this->sql->where = "u.id {$insql}";
     $this->sql->params = array_merge($inparams, array('courseid' => $courseid));
     // Define various table settings.
     $this->sortable(true, 'lvl', SORT_DESC);
     $this->no_sorting('userpic');
     $this->no_sorting('progress');
     $this->collapsible(false);
 }
 /**
  * Construct the ORDER BY clause.
  *
  * We override this to ensure that XP set to null appears at the bottom, not the top.
  *
  * @param array $cols The columns.
  * @param array $textsortcols The text columns.
  * @return string
  */
 public static function construct_order_by($cols, $textsortcols = array())
 {
     $newcols = array();
     // We use a foreach to maintain the order in which the fields were defined.
     foreach ($cols as $field => $sortorder) {
         if ($field == 'xp') {
             $field = 'COALESCE(xp, 0)';
         }
         $newcols[$field] = $sortorder;
     }
     return parent::construct_order_by($newcols, $textsortcols);
 }
 /**
  * Formats the column fullname.
  *
  * @param stdClass $row Table row.
  * @return string Output produced.
  */
 public function col_fullname($row)
 {
     if ($this->identitymode == block_xp_manager::IDENTITY_OFF && $row->userid != $this->userid) {
         return get_string('someoneelse', 'block_xp');
     }
     return parent::col_fullname($row);
 }
Example #22
0
 /**
  * Overides setup to ensure it will only run a single time.
  */
 public function setup()
 {
     // Check if the setup function has been called before, we should not run it twice.
     // If we do the sortorder of the table will be broken.
     if (!empty($this->setup)) {
         return;
     }
     parent::setup();
 }
Example #23
0
 /**
  * Override the table show_hide_link to not show for select column
  *
  * @param string $column the column name, index into various names.
  * @param int $index numerical index of the column.
  * @return string HTML fragment.
  */
 protected function show_hide_link($column, $index)
 {
     if ($index > 0) {
         return parent::show_hide_link($column, $index);
     }
     return '';
 }
 /**
  * Display the general status log table.
  *
  * @param int $pagesize
  * @param bool $useinitialsbar
  */
 public function render($pagesize, $useinitialsbar = true)
 {
     $columns = array('owner', 'for_user_email', 'senddate', 'enrolperiod', 'submission_code', 'course', 'cohorts', 'groups', 'issend');
     if ($this->filter === self::UNUSED) {
         $columns[] = 'action';
     }
     $this->define_table_columns($columns);
     // Generate SQL.
     $fields = 'c.*, ' . get_all_user_name_fields(true, 'u');
     if ($this->filter === self::UNUSED) {
         $fields .= ', NULL as action';
     }
     $from = '{block_coupon} c LEFT JOIN {user} u ON c.ownerid=u.id';
     $where = array();
     $params = array();
     if ($this->ownerid > 0) {
         $where[] = 'c.ownerid = ?';
         $params[] = $this->ownerid;
     }
     switch ($this->filter) {
         case self::USED:
             $where[] = 'c.userid IS NOT NULL AND c.userid <> 0';
             break;
         case self::UNUSED:
             $where[] = 'c.userid IS NULL';
             break;
         case self::ALL:
             // Has no extra where clause.
             break;
     }
     parent::set_sql($fields, $from, implode(' AND ', $where), $params);
     $this->out($pagesize, $useinitialsbar);
 }
Example #25
0
 /**
  * Set up the table.
  * @param table_sql $table the table being constructed.
  * @param array $columns the list of columns.
  * @param array $headers the columns headings.
  * @param moodle_url $reporturl the URL of this report.
  * @param mod_quiz_attempts_report_options $options the display options.
  * @param bool $collapsible whether to allow columns in the report to be collapsed.
  */
 protected function set_up_table_columns($table, $columns, $headers, $reporturl, mod_quiz_attempts_report_options $options, $collapsible)
 {
     $table->define_columns($columns);
     $table->define_headers($headers);
     $table->sortable(true, 'uniqueid');
     $table->define_baseurl($options->get_url());
     $this->configure_user_columns($table);
     $table->no_sorting('feedbacktext');
     $table->column_class('sumgrades', 'bold');
     $table->set_attribute('id', 'attempts');
     $table->collapsible($collapsible);
 }
 public function get_sort_columns() {
     // Add attemptid as a final tie-break to the sort. This ensures that
     // Attempts by the same student appear in order when just sorting by name.
     $sortcolumns = parent::get_sort_columns();
     $sortcolumns['quiza.id'] = SORT_ASC;
     return $sortcolumns;
 }
Example #27
0
 /**
  * override parent class method, because we may want to specify a default sort
  *
  * @return xxx
  */
 function get_sql_sort()
 {
     // if user has specified a sort column, use that
     if ($sort = parent::get_sql_sort()) {
         return $sort;
     }
     // if there is a "fullname" column, sort by first/last name
     if ($this->has_column('fullname')) {
         $sort = 'u.firstname, u.lastname';
         if ($this->has_column('attempt')) {
             $sort .= ', ha.attempt ASC';
         }
         return $sort;
     }
     // no sort column, and no "fullname" column
     return '';
 }
Example #28
0
 function query_db($pagesize, $useinitialsbar = true)
 {
     // Add table joins so we can sort by question answer
     // unfortunately can't join all tables necessary to fetch all answers
     // to get the state for one question per attempt row we must join two tables
     // and there is a limit to how many joins you can have in one query. In MySQL it
     // is 61. This means that when having more than 29 questions the query will fail.
     // So we join just the tables needed to sort the attempts.
     if ($sort = $this->get_sql_sort()) {
         $this->sql->from .= ' ';
         $sortparts = explode(',', $sort);
         $matches = array();
         foreach ($sortparts as $sortpart) {
             $sortpart = trim($sortpart);
             if (preg_match('/^qsanswer([0-9]+)/', $sortpart, $matches)) {
                 $qid = intval($matches[1]);
                 $this->sql->fields .= ", qs{$qid}.grade AS qsgrade{$qid}, qs{$qid}.answer AS qsanswer{$qid}, qs{$qid}.event AS qsevent{$qid}, qs{$qid}.id AS qsid{$qid}";
                 $this->sql->from .= "LEFT JOIN {question_sessions} qns{$qid} ON qns{$qid}.attemptid = qa.uniqueid AND qns{$qid}.questionid = :qid{$qid} ";
                 $this->sql->from .= "LEFT JOIN  {question_states} qs{$qid} ON qs{$qid}.id = qns{$qid}.newgraded ";
                 $this->sql->params['qid' . $qid] = $qid;
             }
         }
     }
     parent::query_db($pagesize, $useinitialsbar);
     $qsfields = 'qs.id, qs.grade, qs.event, qs.question, qs.answer, qs.attempt';
     if (!$this->is_downloading()) {
         $attemptids = array();
         foreach ($this->rawdata as $attempt) {
             if ($attempt->uniqueid > 0) {
                 $attemptids[] = $attempt->uniqueid;
             }
         }
         $this->gradedstatesbyattempt = quiz_get_newgraded_states($attemptids, true, $qsfields);
     } else {
         $this->gradedstatesbyattempt = quiz_get_newgraded_states($this->sql, true, $qsfields);
     }
 }
 /**
  * Override the table show_hide_link to not show for select column.
  *
  * @param string $column the column name, index into various names.
  * @param int $index numerical index of the column.
  * @return string HTML fragment.
  */
 protected function show_hide_link($column, $index)
 {
     if ($index > 0 || !$this->hasgrade) {
         return parent::show_hide_link($column, $index);
     }
     return '';
 }
Example #30
0
 /**
  * Convenience method to call a number of methods for you to display the
  * table.
  * @param int $pagesize
  * @param bool $useinitialsbar
  * @param string $downloadhelpbutton
  */
 public function out($pagesize, $useinitialsbar, $downloadhelpbutton = '')
 {
     $this->add_all_values_to_output();
     parent::out($pagesize, $useinitialsbar, $downloadhelpbutton);
 }