MDL-32888 Grader report: use SESSION object and DB functions

This commit is contained in:
Melissa Aitkin 2013-08-20 10:27:50 +10:00
parent d5f6d9ebef
commit d1a4346f86
3 changed files with 13 additions and 13 deletions

View File

@ -43,12 +43,12 @@ $toggle_type = optional_param('toggle_type', 0, PARAM_ALPHANUM);
$graderreportsifirst = optional_param('sifirst', NULL, PARAM_ALPHA);
$graderreportsilast = optional_param('silast', NULL, PARAM_ALPHA);
// The report object is recreated each time, save search information to USER object for future use.
// The report object is recreated each time, save search information to SESSION object for future use.
if (isset($graderreportsifirst)) {
$USER->filterfirstname = $graderreportsifirst;
$SESSION->filterfirstname = $graderreportsifirst;
}
if (isset($graderreportsilast)) {
$USER->filtersurname = $graderreportsilast;
$SESSION->filtersurname = $graderreportsilast;
}
$PAGE->set_url(new moodle_url('/grade/report/grader/index.php', array('id'=>$courseid)));
@ -153,8 +153,8 @@ echo $report->group_selector;
// User search
$url = new moodle_url('/grade/report/grader/index.php', array('id' => $course->id));
$firstinitial = isset($USER->filterfirstname) ? $USER->filterfirstname : '';
$lastinitial = isset($USER->filtersurname) ? $USER->filtersurname : '';
$firstinitial = isset($SESSION->filterfirstname) ? $SESSION->filterfirstname : '';
$lastinitial = isset($SESSION->filtersurname) ? $SESSION->filtersurname : '';
$totalusers = $report->get_numusers(true, false);
$renderer = $PAGE->get_renderer('core_user');
echo $renderer->user_search($url, $firstinitial, $lastinitial, $numusers, $totalusers, $report->currentgroupname);

View File

@ -158,7 +158,7 @@ class grade_report_grader extends grade_report {
public function process_data($data) {
global $DB;
$warnings = array();
$separategroups = false;
$mygroups = array();
if ($this->groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $this->context)) {

View File

@ -388,17 +388,17 @@ abstract class grade_report {
}
public function setup_users() {
global $USER;
global $SESSION, $DB;
$this->userwheresql = "";
$this->userwheresql_params = array();
if (isset($USER->filterfirstname) && !empty($USER->filterfirstname)) {
$this->userwheresql .= ' AND u.firstname ILIKE :firstname ';
$this->userwheresql_params['firstname'] = $USER->filterfirstname.'%';
if (isset($SESSION->filterfirstname) && !empty($SESSION->filterfirstname)) {
$this->userwheresql .= ' AND '.$DB->sql_like('u.firstname', ':firstname', false, false);
$this->userwheresql_params['firstname'] = $SESSION->filterfirstname.'%';
}
if (isset($USER->filtersurname) && !empty($USER->filtersurname)) {
$this->userwheresql .= ' AND u.lastname ILIKE :lastname ';
$this->userwheresql_params['lastname'] = $USER->filtersurname.'%';
if (isset($SESSION->filtersurname) && !empty($SESSION->filtersurname)) {
$this->userwheresql .= ' AND '.$DB->sql_like('u.lastname', ':lastname', false, false);
$this->userwheresql_params['lastname'] = $SESSION->filtersurname.'%';
}
}