/** * 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); }
/** * Create a new instance of the logtable * * @param int $ownerid if set, display only coupons from given owner * @param int $filter table filter */ public function __construct($ownerid = null, $filter = 3) { global $USER; parent::__construct(__CLASS__ . '-' . $USER->id . '-' . (int) $ownerid); $this->ownerid = (int) $ownerid; $this->filter = (int) $filter; $this->sortable(true, 'c.senddate', 'DESC'); $this->strdelete = get_string('action:coupon:delete', 'block_coupon'); $this->strdeleteconfirm = get_string('action:coupon:delete:confirm', 'block_coupon'); }
/** * 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); }
/** * Constructor * @param string $uniqueid * @param object $quiz * @param context $context * @param string $qmsubselect * @param mod_quiz_attempts_report_options $options * @param array $groupstudents * @param array $students * @param array $questions * @param moodle_url $reporturl */ public function __construct($uniqueid, $quiz, $context, $qmsubselect, mod_quiz_attempts_report_options $options, $groupstudents, $students, $questions, $reporturl) { parent::__construct($uniqueid); $this->quiz = $quiz; $this->context = $context; $this->qmsubselect = $qmsubselect; $this->groupstudents = $groupstudents; $this->students = $students; $this->questions = $questions; $this->includecheckboxes = $options->checkboxcolumn; $this->reporturl = $reporturl; $this->options = $options; }
/** * 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; }
function quiz_report_responses_table($quiz , $qmsubselect, $groupstudents, $students, $questions, $candelete, $reporturl, $displayoptions, $context){ parent::__construct('mod-quiz-report-responses-report'); $this->quiz = $quiz; $this->qmsubselect = $qmsubselect; $this->groupstudents = $groupstudents; $this->students = $students; $this->questions = $questions; $this->candelete = $candelete; $this->reporturl = $reporturl; $this->displayoptions = $displayoptions; $this->context = $context; }
/** * Constructor. * * @param string $uniqueid Unique ID. * @param int $courseid Course ID. * @param int $groupid Group ID. */ public function __construct($uniqueid, $courseid, $groupid) { 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 all the users that are enrolled and can earn XP. $ids = array(); $users = get_enrolled_users($context, 'block/xp:earnxp', $groupid); foreach ($users as $user) { $ids[$user->id] = $user->id; } unset($users); // Get the users which might not be enrolled or are revoked the permission, but still should // be displayed in the report for the teachers' benefit. We need to filter out the users which // are not a member of the group though. if (empty($groupid)) { $sql = 'SELECT userid FROM {block_xp} WHERE courseid = :courseid'; $params = array('courseid' => $courseid); } else { $sql = 'SELECT b.userid FROM {block_xp} b JOIN {groups_members} gm ON b.userid = gm.userid AND gm.groupid = :groupid WHERE courseid = :courseid'; $params = array('courseid' => $courseid, 'groupid' => $groupid); } $entries = $DB->get_recordset_sql($sql, $params); 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') . ', COALESCE(x.lvl, 1) AS lvl, x.xp, ' . context_helper::get_preload_record_columns_sql('ctx'); $this->sql->from = "{user} u\n JOIN {context} ctx\n ON ctx.instanceid = u.id\n AND ctx.contextlevel = :contextlevel\n LEFT JOIN {block_xp} x\n ON (x.userid = u.id AND x.courseid = :courseid)"; $this->sql->where = "u.id {$insql}"; $this->sql->params = array_merge($inparams, array('courseid' => $courseid, 'contextlevel' => CONTEXT_USER)); // Define various table settings. $this->sortable(true, 'lvl', SORT_DESC); $this->no_sorting('userpic'); $this->no_sorting('progress'); $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. */ 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', '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. */ 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); }
/** * 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'); }
/** * 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); }
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); }
/** * This table loads a list of the old assignment instances and tests them to see * if they can be upgraded * * @param int $perpage How many per page * @param int $rowoffset The starting row for pagination */ public function __construct($perpage, $rowoffset = 0) { global $PAGE; parent::__construct('tool_assignmentupgrade_assignments'); $this->perpage = $perpage; $this->output = $PAGE->get_renderer('tool_assignmentupgrade'); $this->define_baseurl(new moodle_url('/admin/tool/assignmentupgrade/listnotupgraded.php')); $this->anyupgradableassignments = tool_assignmentupgrade_any_upgradable_assignments(); // Do some business - then set the sql. if ($rowoffset) { $this->rownum = $rowoffset - 1; } $fields = 'a.id as id, a.name as name, a.assignmenttype as type, c.shortname as courseshortname, c.id as courseid, COUNT(s.id) as submissioncount'; $from = '{assignment} a JOIN {course} c ON a.course = c.id ' . ' LEFT JOIN {assignment_submissions} s ON a.id = s.assignment'; $where = '1 = 1'; $where .= ' GROUP BY a.id, a.name, a.assignmenttype, c.shortname, c.id '; $this->set_sql($fields, $from, $where, array()); $this->set_count_sql('SELECT COUNT(*) FROM {assignment} a JOIN {course} c ON a.course = c.id', array()); $columns = array(); $headers = array(); $columns[] = 'select'; $headers[] = get_string('select', 'tool_assignmentupgrade') . '<div class="selectall">' . '<input type="checkbox" name="selectall" title="' . get_string('selectall') . '"/>' . '</div>'; $columns[] = 'upgradable'; $headers[] = get_string('upgradable', 'tool_assignmentupgrade'); $columns[] = 'id'; $headers[] = get_string('assignmentid', 'tool_assignmentupgrade'); $columns[] = 'courseshortname'; $headers[] = get_string('course'); $columns[] = 'name'; $headers[] = get_string('name'); $columns[] = 'type'; $headers[] = get_string('assignmenttype', 'tool_assignmentupgrade'); $columns[] = 'submissioncount'; $headers[] = get_string('submissions', 'tool_assignmentupgrade'); // Set the columns. $this->define_columns($columns); $this->define_headers($headers); $this->no_sorting('upgradable'); $this->no_sorting('select'); }
/** * 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'); }
/** * 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); }
/** * 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); }
/** * Constructor * * @param mod_feedback_structure $feedbackstructure */ public function __construct(mod_feedback_structure $feedbackstructure) { $this->feedbackstructure = $feedbackstructure; parent::__construct('feedback-showentry-list-' . $feedbackstructure->get_cm()->instance); $this->showall = optional_param($this->showallparamname, 0, PARAM_BOOL); $this->define_baseurl(new moodle_url('/mod/feedback/show_entries.php', ['id' => $this->feedbackstructure->get_cm()->id])); if ($courseid = $this->feedbackstructure->get_courseid()) { $this->baseurl->param('courseid', $courseid); } if ($this->showall) { $this->baseurl->param($this->showallparamname, $this->showall); } $name = format_string($feedbackstructure->get_feedback()->name); $this->is_downloadable(true); $this->is_downloading(optional_param($this->downloadparamname, 0, PARAM_ALPHA), $name, get_string('responses', 'feedback')); $this->useridfield = 'userid'; $this->init(); }
/** * 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); }
/** * overridden constructor keeps a reference to the assignment class that is displaying this table * * @param assign $assignment The assignment class * @param int $perpage how many per page * @param string $filter The current filter * @param int $rowoffset For showing a subsequent page of results * @param bool $quickgrading Is this table wrapped in a quickgrading form? * @param string $downloadfilename */ public function __construct(assign $assignment, $perpage, $filter, $rowoffset, $quickgrading, $downloadfilename = null) { global $CFG, $PAGE, $DB, $USER; parent::__construct('mod_assign_grading'); $this->is_persistent(true); $this->assignment = $assignment; // Check permissions up front. $this->hasgrantextension = has_capability('mod/assign:grantextension', $this->assignment->get_context()); $this->hasgrade = $this->assignment->can_grade(); // Check if we have the elevated view capablities to see the blind details. $this->hasviewblind = has_capability('mod/assign:viewblinddetails', $this->assignment->get_context()); foreach ($assignment->get_feedback_plugins() as $plugin) { if ($plugin->is_visible() && $plugin->is_enabled()) { foreach ($plugin->get_grading_batch_operations() as $action => $description) { if (empty($this->plugingradingbatchoperations)) { $this->plugingradingbatchoperations[$plugin->get_type()] = array(); } $this->plugingradingbatchoperations[$plugin->get_type()][$action] = $description; } } } $this->perpage = $perpage; $this->quickgrading = $quickgrading && $this->hasgrade; $this->output = $PAGE->get_renderer('mod_assign'); $urlparams = array('action' => 'grading', 'id' => $assignment->get_course_module()->id); $url = new moodle_url($CFG->wwwroot . '/mod/assign/view.php', $urlparams); $this->define_baseurl($url); // Do some business - then set the sql. $currentgroup = groups_get_activity_group($assignment->get_course_module(), true); if ($rowoffset) { $this->rownum = $rowoffset - 1; } $users = array_keys($assignment->list_participants($currentgroup, true)); if (count($users) == 0) { // Insert a record that will never match to the sql is still valid. $users[] = -1; } $params = array(); $params['assignmentid1'] = (int) $this->assignment->get_instance()->id; $params['assignmentid2'] = (int) $this->assignment->get_instance()->id; $params['assignmentid3'] = (int) $this->assignment->get_instance()->id; $extrauserfields = get_extra_user_fields($this->assignment->get_context()); $fields = user_picture::fields('u', $extrauserfields) . ', '; $fields .= 'u.id as userid, '; $fields .= 's.status as status, '; $fields .= 's.id as submissionid, '; $fields .= 's.timecreated as firstsubmission, '; $fields .= 's.timemodified as timesubmitted, '; $fields .= 's.attemptnumber as attemptnumber, '; $fields .= 'g.id as gradeid, '; $fields .= 'g.grade as grade, '; $fields .= 'g.timemodified as timemarked, '; $fields .= 'g.timecreated as firstmarked, '; $fields .= 'uf.mailed as mailed, '; $fields .= 'uf.locked as locked, '; $fields .= 'uf.extensionduedate as extensionduedate, '; $fields .= 'uf.workflowstate as workflowstate, '; $fields .= 'uf.allocatedmarker as allocatedmarker '; $from = '{user} u LEFT JOIN {assign_submission} s ON u.id = s.userid AND s.assignment = :assignmentid1 AND s.latest = 1 LEFT JOIN {assign_grades} g ON u.id = g.userid AND g.assignment = :assignmentid2 '; // For group submissions we don't immediately create an entry in the assign_submission table for each user, // instead the userid is set to 0. In this case we use a different query to retrieve the grade for the user. if ($this->assignment->get_instance()->teamsubmission) { $params['assignmentid4'] = (int) $this->assignment->get_instance()->id; $grademaxattempt = 'SELECT mxg.userid, MAX(mxg.attemptnumber) AS maxattempt FROM {assign_grades} mxg WHERE mxg.assignment = :assignmentid4 GROUP BY mxg.userid'; $from .= 'LEFT JOIN (' . $grademaxattempt . ') gmx ON u.id = gmx.userid AND g.attemptnumber = gmx.maxattempt '; } else { $from .= 'AND g.attemptnumber = s.attemptnumber '; } $from .= 'LEFT JOIN {assign_user_flags} uf ON u.id = uf.userid AND uf.assignment = :assignmentid3'; $userparams = array(); $userindex = 0; list($userwhere, $userparams) = $DB->get_in_or_equal($users, SQL_PARAMS_NAMED, 'user'); $where = 'u.id ' . $userwhere; $params = array_merge($params, $userparams); // The filters do not make sense when there are no submissions, so do not apply them. if ($this->assignment->is_any_submission_plugin_enabled()) { if ($filter == ASSIGN_FILTER_SUBMITTED) { $where .= ' AND (s.timemodified IS NOT NULL AND s.status = :submitted) '; $params['submitted'] = ASSIGN_SUBMISSION_STATUS_SUBMITTED; } else { if ($filter == ASSIGN_FILTER_NOT_SUBMITTED) { $where .= ' AND (s.timemodified IS NULL OR s.status != :submitted) '; $params['submitted'] = ASSIGN_SUBMISSION_STATUS_SUBMITTED; } else { if ($filter == ASSIGN_FILTER_REQUIRE_GRADING) { $where .= ' AND (s.timemodified IS NOT NULL AND s.status = :submitted AND (s.timemodified >= g.timemodified OR g.timemodified IS NULL OR g.grade IS NULL))'; $params['submitted'] = ASSIGN_SUBMISSION_STATUS_SUBMITTED; } else { if (strpos($filter, ASSIGN_FILTER_SINGLE_USER) === 0) { $userfilter = (int) array_pop(explode('=', $filter)); $where .= ' AND (u.id = :userid)'; $params['userid'] = $userfilter; } } } } } if ($this->assignment->get_instance()->markingworkflow && $this->assignment->get_instance()->markingallocation) { if (has_capability('mod/assign:manageallocations', $this->assignment->get_context())) { // Check to see if marker filter is set. $markerfilter = (int) get_user_preferences('assign_markerfilter', ''); if (!empty($markerfilter)) { if ($markerfilter == ASSIGN_MARKER_FILTER_NO_MARKER) { $where .= ' AND (uf.allocatedmarker IS NULL OR uf.allocatedmarker = 0)'; } else { $where .= ' AND uf.allocatedmarker = :markerid'; $params['markerid'] = $markerfilter; } } } else { // Only show users allocated to this marker. $where .= ' AND uf.allocatedmarker = :markerid'; $params['markerid'] = $USER->id; } } if ($this->assignment->get_instance()->markingworkflow) { $workflowstates = $this->assignment->get_marking_workflow_states_for_current_user(); if (!empty($workflowstates)) { $workflowfilter = get_user_preferences('assign_workflowfilter', ''); if ($workflowfilter == ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED) { $where .= ' AND (uf.workflowstate = :workflowstate OR uf.workflowstate IS NULL OR ' . $DB->sql_isempty('assign_user_flags', 'workflowstate', true, true) . ')'; $params['workflowstate'] = $workflowfilter; } else { if (array_key_exists($workflowfilter, $workflowstates)) { $where .= ' AND uf.workflowstate = :workflowstate'; $params['workflowstate'] = $workflowfilter; } } } } $this->set_sql($fields, $from, $where, $params); if ($downloadfilename) { $this->is_downloading('csv', $downloadfilename); } $columns = array(); $headers = array(); // Select. if (!$this->is_downloading() && $this->hasgrade) { $columns[] = 'select'; $headers[] = get_string('select') . '<div class="selectall"><label class="accesshide" for="selectall">' . get_string('selectall') . '</label> <input type="checkbox" id="selectall" name="selectall" title="' . get_string('selectall') . '"/></div>'; } // User picture. if ($this->hasviewblind || !$this->assignment->is_blind_marking()) { if (!$this->is_downloading()) { $columns[] = 'picture'; $headers[] = get_string('pictureofuser'); } else { $columns[] = 'recordid'; $headers[] = get_string('recordid', 'assign'); } // Fullname. $columns[] = 'fullname'; $headers[] = get_string('fullname'); foreach ($extrauserfields as $extrafield) { $columns[] = $extrafield; $headers[] = get_user_field_name($extrafield); } } else { // Record ID. $columns[] = 'recordid'; $headers[] = get_string('recordid', 'assign'); } // Submission status. $columns[] = 'status'; $headers[] = get_string('status', 'assign'); // Team submission columns. if ($assignment->get_instance()->teamsubmission) { $columns[] = 'team'; $headers[] = get_string('submissionteam', 'assign'); } // Allocated marker. if ($this->assignment->get_instance()->markingworkflow && $this->assignment->get_instance()->markingallocation && has_capability('mod/assign:manageallocations', $this->assignment->get_context())) { // Add a column for the allocated marker. $columns[] = 'allocatedmarker'; $headers[] = get_string('marker', 'assign'); } // Grade. $columns[] = 'grade'; $headers[] = get_string('grade'); if ($this->is_downloading()) { if ($this->assignment->get_instance()->grade >= 0) { $columns[] = 'grademax'; $headers[] = get_string('maxgrade', 'assign'); } else { // This is a custom scale. $columns[] = 'scale'; $headers[] = get_string('scale', 'assign'); } if ($this->assignment->get_instance()->markingworkflow) { // Add a column for the marking workflow state. $columns[] = 'workflowstate'; $headers[] = get_string('markingworkflowstate', 'assign'); } // Add a column for the list of valid marking workflow states. $columns[] = 'gradecanbechanged'; $headers[] = get_string('gradecanbechanged', 'assign'); } if (!$this->is_downloading() && $this->hasgrade) { // We have to call this column userid so we can use userid as a default sortable column. $columns[] = 'userid'; $headers[] = get_string('edit'); } // Submission plugins. if ($assignment->is_any_submission_plugin_enabled()) { $columns[] = 'timesubmitted'; $headers[] = get_string('lastmodifiedsubmission', 'assign'); foreach ($this->assignment->get_submission_plugins() as $plugin) { if ($this->is_downloading()) { if ($plugin->is_visible() && $plugin->is_enabled()) { foreach ($plugin->get_editor_fields() as $field => $description) { $index = 'plugin' . count($this->plugincache); $this->plugincache[$index] = array($plugin, $field); $columns[] = $index; $headers[] = $plugin->get_name(); } } } else { if ($plugin->is_visible() && $plugin->is_enabled() && $plugin->has_user_summary()) { $index = 'plugin' . count($this->plugincache); $this->plugincache[$index] = array($plugin); $columns[] = $index; $headers[] = $plugin->get_name(); } } } } // Time marked. $columns[] = 'timemarked'; $headers[] = get_string('lastmodifiedgrade', 'assign'); // Feedback plugins. foreach ($this->assignment->get_feedback_plugins() as $plugin) { if ($this->is_downloading()) { if ($plugin->is_visible() && $plugin->is_enabled()) { foreach ($plugin->get_editor_fields() as $field => $description) { $index = 'plugin' . count($this->plugincache); $this->plugincache[$index] = array($plugin, $field); $columns[] = $index; $headers[] = $description; } } } else { if ($plugin->is_visible() && $plugin->is_enabled() && $plugin->has_user_summary()) { $index = 'plugin' . count($this->plugincache); $this->plugincache[$index] = array($plugin); $columns[] = $index; $headers[] = $plugin->get_name(); } } } // Exclude 'Final grade' column in downloaded grading worksheets. if (!$this->is_downloading()) { // Final grade. $columns[] = 'finalgrade'; $headers[] = get_string('finalgrade', 'grades'); } // Load the grading info for all users. $this->gradinginfo = grade_get_grades($this->assignment->get_course()->id, 'mod', 'assign', $this->assignment->get_instance()->id, $users); if (!empty($CFG->enableoutcomes) && !empty($this->gradinginfo->outcomes)) { $columns[] = 'outcomes'; $headers[] = get_string('outcomes', 'grades'); } // Set the columns. $this->define_columns($columns); $this->define_headers($headers); foreach ($extrauserfields as $extrafield) { $this->column_class($extrafield, $extrafield); } $this->no_sorting('recordid'); $this->no_sorting('finalgrade'); $this->no_sorting('userid'); $this->no_sorting('select'); $this->no_sorting('outcomes'); if ($assignment->get_instance()->teamsubmission) { $this->no_sorting('team'); } $plugincolumnindex = 0; foreach ($this->assignment->get_submission_plugins() as $plugin) { if ($plugin->is_visible() && $plugin->is_enabled() && $plugin->has_user_summary()) { $submissionpluginindex = 'plugin' . $plugincolumnindex++; $this->no_sorting($submissionpluginindex); } } foreach ($this->assignment->get_feedback_plugins() as $plugin) { if ($plugin->is_visible() && $plugin->is_enabled() && $plugin->has_user_summary()) { $feedbackpluginindex = 'plugin' . $plugincolumnindex++; $this->no_sorting($feedbackpluginindex); } } // When there is no data we still want the column headers printed in the csv file. if ($this->is_downloading()) { $this->start_output(); } }
/** * Constructor. * * @param string $uniqueid Unique ID. * @param int $courseid Course ID. * @param int $groupid Group ID. */ public function __construct($uniqueid, $courseid, $groupid, array $options = array(), $userid = null) { global $PAGE, $USER; parent::__construct($uniqueid); if (isset($options['rankmode'])) { $this->rankmode = $options['rankmode']; } if (isset($options['neighboursonly'])) { $this->neighboursonly = $options['neighboursonly']; } if (isset($options['neighboursabove'])) { $this->neighboursabove = $options['neighboursabove']; } if (isset($options['neighboursbelow'])) { $this->neighboursbelow = $options['neighboursbelow']; } if (isset($options['identitymode'])) { $this->identitymode = $options['identitymode']; } // The user ID we're viewing the ladder for. if ($userid === null) { $userid = $USER->id; } $this->userid = $userid; // Block XP stuff. $this->xpmanager = block_xp_manager::get($courseid); $this->xpoutput = $PAGE->get_renderer('block_xp'); // Define columns, and headers. $columns = array(); $headers = array(); if ($this->rankmode != block_xp_manager::RANK_OFF) { $columns += array('rank'); if ($this->rankmode == block_xp_manager::RANK_REL) { $headers += array(get_string('difference', 'block_xp')); } else { $headers += array(get_string('rank', 'block_xp')); } } $columns = array_merge($columns, array('userpic', 'fullname', 'lvl', 'xp', 'progress')); $headers = array_merge($headers, array('', get_string('fullname'), get_string('level', 'block_xp'), get_string('xp', 'block_xp'), get_string('progress', 'block_xp'))); $this->define_columns($columns); $this->define_headers($headers); // Define SQL. $sqlfrom = ''; $sqlparams = array(); if ($groupid) { $sqlfrom = '{block_xp} x JOIN {groups_members} gm ON gm.groupid = :groupid AND gm.userid = x.userid JOIN {user} u ON x.userid = u.id'; $sqlparams = array('groupid' => $groupid); } else { $sqlfrom = '{block_xp} x JOIN {user} u ON x.userid = u.id'; } $sqlfrom .= " JOIN {context} ctx\n ON ctx.instanceid = u.id\n AND ctx.contextlevel = :contextlevel"; $sqlparams += array('contextlevel' => CONTEXT_USER); $this->sql = new stdClass(); $this->sql->fields = 'x.*, ' . user_picture::fields('u', null, 'userid') . ', ' . context_helper::get_preload_record_columns_sql('ctx'); $this->sql->from = $sqlfrom; $this->sql->where = 'courseid = :courseid'; $this->sql->params = array_merge(array('courseid' => $courseid), $sqlparams); // Define various table settings. $this->sortable(false); $this->no_sorting('userpic'); $this->no_sorting('progress'); $this->collapsible(false); }
/** * overridden constructor keeps a reference to the assignment class that is displaying this table * * @param assign $assignment The assignment class * @param int $perpage how many per page * @param string $filter The current filter * @param int $rowoffset For showing a subsequent page of results * @param bool $quickgrading Is this table wrapped in a quickgrading form? */ public function __construct(assign $assignment, $perpage, $filter, $rowoffset, $quickgrading, $downloadfilename = null) { global $CFG, $PAGE, $DB; parent::__construct('mod_assign_grading'); $this->assignment = $assignment; foreach ($assignment->get_feedback_plugins() as $plugin) { if ($plugin->is_visible() && $plugin->is_enabled()) { foreach ($plugin->get_grading_batch_operations() as $action => $description) { if (empty($this->plugingradingbatchoperations)) { $this->plugingradingbatchoperations[$plugin->get_type()] = array(); } $this->plugingradingbatchoperations[$plugin->get_type()][$action] = $description; } } } $this->perpage = $perpage; $this->quickgrading = $quickgrading; $this->output = $PAGE->get_renderer('mod_assign'); $this->define_baseurl(new moodle_url($CFG->wwwroot . '/mod/assign/view.php', array('action' => 'grading', 'id' => $assignment->get_course_module()->id))); // do some business - then set the sql $currentgroup = groups_get_activity_group($assignment->get_course_module(), true); if ($rowoffset) { $this->rownum = $rowoffset - 1; } $users = array_keys($assignment->list_participants($currentgroup, true)); if (count($users) == 0) { // insert a record that will never match to the sql is still valid. $users[] = -1; } $params = array(); $params['assignmentid1'] = (int) $this->assignment->get_instance()->id; $params['assignmentid2'] = (int) $this->assignment->get_instance()->id; $fields = user_picture::fields('u') . ', '; $fields .= 'u.id as userid, '; $fields .= 's.status as status, '; $fields .= 's.id as submissionid, '; $fields .= 's.timecreated as firstsubmission, '; $fields .= 's.timemodified as timesubmitted, '; $fields .= 'g.id as gradeid, '; $fields .= 'g.grade as grade, '; $fields .= 'g.timemodified as timemarked, '; $fields .= 'g.timecreated as firstmarked, '; $fields .= 'g.mailed as mailed, '; $fields .= 'g.locked as locked, '; $fields .= 'g.extensionduedate as extensionduedate'; $from = '{user} u LEFT JOIN {assign_submission} s ON u.id = s.userid AND s.assignment = :assignmentid1' . ' LEFT JOIN {assign_grades} g ON u.id = g.userid AND g.assignment = :assignmentid2'; $userparams = array(); $userindex = 0; list($userwhere, $userparams) = $DB->get_in_or_equal($users, SQL_PARAMS_NAMED, 'user'); $where = 'u.id ' . $userwhere; $params = array_merge($params, $userparams); if ($filter == ASSIGN_FILTER_SUBMITTED) { $where .= ' AND s.timecreated > 0 '; } if ($filter == ASSIGN_FILTER_REQUIRE_GRADING) { $where .= ' AND (s.timemodified > g.timemodified OR (s.timemodified IS NOT NULL AND g.timemodified IS NULL))'; } if (strpos($filter, ASSIGN_FILTER_SINGLE_USER) === 0) { $userfilter = (int) array_pop(explode('=', $filter)); $where .= ' AND (u.id = :userid)'; $params['userid'] = $userfilter; } $this->set_sql($fields, $from, $where, $params); if ($downloadfilename) { $this->is_downloading('csv', $downloadfilename); } $columns = array(); $headers = array(); // Select. if (!$this->is_downloading()) { $columns[] = 'select'; $headers[] = get_string('select') . '<div class="selectall"><label class="accesshide" for="selectall">' . get_string('selectall') . '</label> <input type="checkbox" id="selectall" name="selectall" title="' . get_string('selectall') . '"/></div>'; } // User picture. if (!$this->assignment->is_blind_marking()) { if (!$this->is_downloading()) { $columns[] = 'picture'; $headers[] = get_string('pictureofuser'); } else { $columns[] = 'recordid'; $headers[] = get_string('recordid', 'assign'); } // Fullname. $columns[] = 'fullname'; $headers[] = get_string('fullname'); } else { // Record ID. $columns[] = 'recordid'; $headers[] = get_string('recordid', 'assign'); } // Submission status if ($assignment->is_any_submission_plugin_enabled()) { $columns[] = 'status'; $headers[] = get_string('status'); } // Team submission columns if ($assignment->get_instance()->teamsubmission) { $columns[] = 'team'; $headers[] = get_string('submissionteam', 'assign'); $columns[] = 'teamstatus'; $headers[] = get_string('teamsubmissionstatus', 'assign'); } // Grade $columns[] = 'grade'; $headers[] = get_string('grade'); if ($this->is_downloading()) { if ($this->assignment->get_instance()->grade >= 0) { $columns[] = 'grademax'; $headers[] = get_string('maxgrade', 'assign'); } else { // This is a custom scale. $columns[] = 'scale'; $headers[] = get_string('scale', 'assign'); } } if (!$this->is_downloading()) { // We have to call this column userid so we can use userid as a default sortable column. $columns[] = 'userid'; $headers[] = get_string('edit'); } // Submission plugins if ($assignment->is_any_submission_plugin_enabled()) { $columns[] = 'timesubmitted'; $headers[] = get_string('lastmodifiedsubmission', 'assign'); foreach ($this->assignment->get_submission_plugins() as $plugin) { if ($this->is_downloading()) { if ($plugin->is_visible() && $plugin->is_enabled()) { foreach ($plugin->get_editor_fields() as $field => $description) { $index = 'plugin' . count($this->plugincache); $this->plugincache[$index] = array($plugin, $field); $columns[] = $index; $headers[] = $plugin->get_name(); } } } else { if ($plugin->is_visible() && $plugin->is_enabled() && $plugin->has_user_summary()) { $index = 'plugin' . count($this->plugincache); $this->plugincache[$index] = array($plugin); $columns[] = $index; $headers[] = $plugin->get_name(); } } } } // time marked $columns[] = 'timemarked'; $headers[] = get_string('lastmodifiedgrade', 'assign'); // Feedback plugins foreach ($this->assignment->get_feedback_plugins() as $plugin) { if ($this->is_downloading()) { if ($plugin->is_visible() && $plugin->is_enabled()) { foreach ($plugin->get_editor_fields() as $field => $description) { $index = 'plugin' . count($this->plugincache); $this->plugincache[$index] = array($plugin, $field); $columns[] = $index; $headers[] = $description; } } } else { if ($plugin->is_visible() && $plugin->is_enabled() && $plugin->has_user_summary()) { $index = 'plugin' . count($this->plugincache); $this->plugincache[$index] = array($plugin); $columns[] = $index; $headers[] = $plugin->get_name(); } } } // Exclude 'Final grade' column in downloaded grading worksheets. if (!$this->is_downloading()) { // Final grade. $columns[] = 'finalgrade'; $headers[] = get_string('finalgrade', 'grades'); } // load the grading info for all users $this->gradinginfo = grade_get_grades($this->assignment->get_course()->id, 'mod', 'assign', $this->assignment->get_instance()->id, $users); $this->hasgrantextension = has_capability('mod/assign:grantextension', $this->assignment->get_context()); if (!empty($CFG->enableoutcomes) && !empty($this->gradinginfo->outcomes)) { $columns[] = 'outcomes'; $headers[] = get_string('outcomes', 'grades'); } // set the columns $this->define_columns($columns); $this->define_headers($headers); // We require at least one unique column for the sort. $this->sortable(true, 'userid'); $this->no_sorting('recordid'); $this->no_sorting('finalgrade'); $this->no_sorting('userid'); $this->no_sorting('select'); $this->no_sorting('outcomes'); if ($assignment->get_instance()->teamsubmission) { $this->no_sorting('team'); $this->no_sorting('teamstatus'); } $plugincolumnindex = 0; foreach ($this->assignment->get_submission_plugins() as $plugin) { if ($plugin->is_visible() && $plugin->is_enabled() && $plugin->has_user_summary()) { $submissionpluginindex = 'plugin' . $plugincolumnindex++; $this->no_sorting($submissionpluginindex); } } foreach ($this->assignment->get_feedback_plugins() as $plugin) { if ($plugin->is_visible() && $plugin->is_enabled() && $plugin->has_user_summary()) { $feedbackpluginindex = 'plugin' . $plugincolumnindex++; $this->no_sorting($feedbackpluginindex); } } // When there is no data we still want the column headers printed in the csv file. if ($this->is_downloading()) { $this->start_output(); } }
public function __construct($uniqueid, $quiz, $context, $qmsubselect, $groupstudents, $students, $questions, $candelete, $reporturl, $displayoptions) { parent::__construct($uniqueid); $this->quiz = $quiz; $this->context = $context; $this->qmsubselect = $qmsubselect; $this->groupstudents = $groupstudents; $this->students = $students; $this->questions = $questions; $this->candelete = $candelete; $this->reporturl = $reporturl; $this->displayoptions = $displayoptions; }
/** * overridden constructor keeps a reference to the assignment class that is displaying this table * * @param assign $assignment The assignment class * @param int $perpage how many per page * @param string $filter The current filter * @param int $rowoffset For showing a subsequent page of results * @param bool $quickgrading Is this table wrapped in a quickgrading form? */ function __construct(assign $assignment, $perpage, $filter, $rowoffset, $quickgrading) { global $CFG, $PAGE, $DB; parent::__construct('mod_assign_grading'); $this->assignment = $assignment; $this->perpage = $perpage; $this->quickgrading = $quickgrading; $this->output = $PAGE->get_renderer('mod_assign'); $this->define_baseurl(new moodle_url($CFG->wwwroot . '/mod/assign/view.php', array('action'=>'grading', 'id'=>$assignment->get_course_module()->id))); // do some business - then set the sql $currentgroup = groups_get_activity_group($assignment->get_course_module(), true); if ($rowoffset) { $this->rownum = $rowoffset - 1; } $users = array_keys( $assignment->list_participants($currentgroup, true)); if (count($users) == 0) { // insert a record that will never match to the sql is still valid. $users[] = -1; } $params = array(); $params['assignmentid1'] = (int)$this->assignment->get_instance()->id; $params['assignmentid2'] = (int)$this->assignment->get_instance()->id; $fields = user_picture::fields('u') . ', u.id as userid, u.firstname as firstname, u.lastname as lastname, '; $fields .= 's.status as status, s.id as submissionid, s.timecreated as firstsubmission, s.timemodified as timesubmitted, '; $fields .= 'g.id as gradeid, g.grade as grade, g.timemodified as timemarked, g.timecreated as firstmarked, g.mailed as mailed, g.locked as locked'; $from = '{user} u LEFT JOIN {assign_submission} s ON u.id = s.userid AND s.assignment = :assignmentid1' . ' LEFT JOIN {assign_grades} g ON u.id = g.userid AND g.assignment = :assignmentid2'; $userparams = array(); $userindex = 0; list($userwhere, $userparams) = $DB->get_in_or_equal($users, SQL_PARAMS_NAMED, 'user'); $where = 'u.id ' . $userwhere; $params = array_merge($params, $userparams); if ($filter == ASSIGN_FILTER_SUBMITTED) { $where .= ' AND s.timecreated > 0 '; } if ($filter == ASSIGN_FILTER_REQUIRE_GRADING) { $where .= ' AND (s.timemodified > g.timemodified OR (s.timemodified IS NOT NULL AND g.timemodified IS NULL))'; } if (strpos($filter, ASSIGN_FILTER_SINGLE_USER) === 0) { $userfilter = (int) array_pop(explode('=', $filter)); $where .= ' AND (u.id = :userid)'; $params['userid'] = $userfilter; } $this->set_sql($fields, $from, $where, $params); $columns = array(); $headers = array(); // Select $columns[] = 'select'; $headers[] = get_string('select') . '<div class="selectall"><input type="checkbox" name="selectall" title="' . get_string('selectall') . '"/></div>'; // Edit links if (!$this->is_downloading()) { $columns[] = 'edit'; $headers[] = get_string('edit'); } // User picture $columns[] = 'picture'; $headers[] = get_string('pictureofuser'); // Fullname $columns[] = 'fullname'; $headers[] = get_string('fullname'); // Submission status if ($assignment->is_any_submission_plugin_enabled()) { $columns[] = 'status'; $headers[] = get_string('status'); } // Grade $columns[] = 'grade'; $headers[] = get_string('grade'); // Submission plugins if ($assignment->is_any_submission_plugin_enabled()) { $columns[] = 'timesubmitted'; $headers[] = get_string('lastmodifiedsubmission', 'assign'); foreach ($this->assignment->get_submission_plugins() as $plugin) { if ($plugin->is_visible() && $plugin->is_enabled()) { $columns[] = 'assignsubmission_' . $plugin->get_type(); $headers[] = $plugin->get_name(); } } } // time marked $columns[] = 'timemarked'; $headers[] = get_string('lastmodifiedgrade', 'assign'); // Feedback plugins foreach ($this->assignment->get_feedback_plugins() as $plugin) { if ($plugin->is_visible() && $plugin->is_enabled()) { $columns[] = 'assignfeedback_' . $plugin->get_type(); $headers[] = $plugin->get_name(); } } // final grade $columns[] = 'finalgrade'; $headers[] = get_string('finalgrade', 'grades'); // load the grading info for all users $this->gradinginfo = grade_get_grades($this->assignment->get_course()->id, 'mod', 'assign', $this->assignment->get_instance()->id, $users); if (!empty($CFG->enableoutcomes) && !empty($this->gradinginfo->outcomes)) { $columns[] = 'outcomes'; $headers[] = get_string('outcomes', 'grades'); } // set the columns $this->define_columns($columns); $this->define_headers($headers); $this->no_sorting('finalgrade'); $this->no_sorting('edit'); $this->no_sorting('select'); $this->no_sorting('outcomes'); foreach ($this->assignment->get_submission_plugins() as $plugin) { if ($plugin->is_visible() && $plugin->is_enabled()) { $this->no_sorting('assignsubmission_' . $plugin->get_type()); } } foreach ($this->assignment->get_feedback_plugins() as $plugin) { if ($plugin->is_visible() && $plugin->is_enabled()) { $this->no_sorting('assignfeedback_' . $plugin->get_type()); } } }
/** * Constructor * * @param int $uniqueid */ function __construct($uniqueid, $output) { parent::__construct($uniqueid); $this->output = $output; $this->strtimeformat = get_string($this->timeformat); }