mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 13:38:32 +01:00
MDL-67702 gradereport_grader: user filters per report instance.
This commit is contained in:
parent
05680020e7
commit
3521d50c13
@ -43,14 +43,6 @@ $toggle_type = optional_param('toggle_type', 0, PARAM_ALPHANUM);
|
||||
$graderreportsifirst = optional_param('sifirst', null, PARAM_NOTAGS);
|
||||
$graderreportsilast = optional_param('silast', null, PARAM_NOTAGS);
|
||||
|
||||
// The report object is recreated each time, save search information to SESSION object for future use.
|
||||
if (isset($graderreportsifirst)) {
|
||||
$SESSION->gradereport['filterfirstname'] = $graderreportsifirst;
|
||||
}
|
||||
if (isset($graderreportsilast)) {
|
||||
$SESSION->gradereport['filtersurname'] = $graderreportsilast;
|
||||
}
|
||||
|
||||
$PAGE->set_url(new moodle_url('/grade/report/grader/index.php', array('id'=>$courseid)));
|
||||
$PAGE->requires->yui_module('moodle-gradereport_grader-gradereporttable', 'Y.M.gradereport_grader.init', null, null, true);
|
||||
|
||||
@ -61,6 +53,14 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
require_login($course);
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
// The report object is recreated each time, save search information to SESSION object for future use.
|
||||
if (isset($graderreportsifirst)) {
|
||||
$SESSION->gradereport["filterfirstname-{$context->id}"] = $graderreportsifirst;
|
||||
}
|
||||
if (isset($graderreportsilast)) {
|
||||
$SESSION->gradereport["filtersurname-{$context->id}"] = $graderreportsilast;
|
||||
}
|
||||
|
||||
require_capability('gradereport/grader:view', $context);
|
||||
require_capability('moodle/grade:viewall', $context);
|
||||
|
||||
@ -161,8 +161,8 @@ echo $report->group_selector;
|
||||
|
||||
// User search
|
||||
$url = new moodle_url('/grade/report/grader/index.php', array('id' => $course->id));
|
||||
$firstinitial = isset($SESSION->gradereport['filterfirstname']) ? $SESSION->gradereport['filterfirstname'] : '';
|
||||
$lastinitial = isset($SESSION->gradereport['filtersurname']) ? $SESSION->gradereport['filtersurname'] : '';
|
||||
$firstinitial = $SESSION->gradereport["filterfirstname-{$context->id}"] ?? '';
|
||||
$lastinitial = $SESSION->gradereport["filtersurname-{$context->id}"] ?? '';
|
||||
$totalusers = $report->get_numusers(true, false);
|
||||
$renderer = $PAGE->get_renderer('core_user');
|
||||
echo $renderer->user_search($url, $firstinitial, $lastinitial, $numusers, $totalusers, $report->currentgroupname);
|
||||
|
@ -394,15 +394,18 @@ abstract class grade_report {
|
||||
public function setup_users() {
|
||||
global $SESSION, $DB;
|
||||
|
||||
$filterfirstnamekey = "filterfirstname-{$this->context->id}";
|
||||
$filtersurnamekey = "filtersurname-{$this->context->id}";
|
||||
|
||||
$this->userwheresql = "";
|
||||
$this->userwheresql_params = array();
|
||||
if (isset($SESSION->gradereport['filterfirstname']) && !empty($SESSION->gradereport['filterfirstname'])) {
|
||||
if (!empty($SESSION->gradereport[$filterfirstnamekey])) {
|
||||
$this->userwheresql .= ' AND '.$DB->sql_like('u.firstname', ':firstname', false, false);
|
||||
$this->userwheresql_params['firstname'] = $SESSION->gradereport['filterfirstname'].'%';
|
||||
$this->userwheresql_params['firstname'] = $SESSION->gradereport[$filterfirstnamekey] . '%';
|
||||
}
|
||||
if (isset($SESSION->gradereport['filtersurname']) && !empty($SESSION->gradereport['filtersurname'])) {
|
||||
if (!empty($SESSION->gradereport[$filtersurnamekey])) {
|
||||
$this->userwheresql .= ' AND '.$DB->sql_like('u.lastname', ':lastname', false, false);
|
||||
$this->userwheresql_params['lastname'] = $SESSION->gradereport['filtersurname'].'%';
|
||||
$this->userwheresql_params['lastname'] = $SESSION->gradereport[$filtersurnamekey] . '%';
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user