Permalink
Browse files

MDL-32888 Grader report: refined user search with no reset

  • Loading branch information...
Melissa Aitkin
Melissa Aitkin committed Jul 10, 2013
1 parent cbe8e5b commit 4187784925ae183ea7133052609ed20b5418f177
Showing with 23 additions and 43 deletions.
  1. +10 −17 grade/report/grader/index.php
  2. +3 −2 grade/report/grader/lib.php
  3. +7 −6 grade/report/lib.php
  4. +3 −18 user/renderer.php
@@ -40,22 +40,16 @@
$toggle = optional_param('toggle', NULL, PARAM_INT);
$toggle_type = optional_param('toggle_type', 0, PARAM_ALPHANUM);
-$reset = optional_param('Reset', NULL, PARAM_ALPHA);
$graderreportsifirst = optional_param('sifirst', NULL, PARAM_ALPHA);
$graderreportsilast = optional_param('silast', NULL, PARAM_ALPHA);
-if (isset($reset)) {
- $SESSION->graderreportsifirst = '';
- $SESSION->graderreportsilast = '';
-} else {
- // the report object is recreated each time, save search information to session for future use
- if (isset($graderreportsifirst)) {
- $SESSION->graderreportsifirst = $graderreportsifirst;
- }
- if (isset($graderreportsilast)) {
- $SESSION->graderreportsilast = $graderreportsilast;
- }
-}
+// The report object is recreated each time, save search information to USER object for future use.
+if (isset($graderreportsifirst)) {
+ $USER->filterfirstname = $graderreportsifirst;
+}
+if (isset($graderreportsilast)) {
+ $USER->filtersurname = $graderreportsilast;
+}
$PAGE->set_url(new moodle_url('/grade/report/grader/index.php', array('id'=>$courseid)));
@@ -159,12 +153,11 @@
// User search
$url = new moodle_url('/grade/report/grader/index.php', array('id' => $course->id));
-$hiddenfields = array('group' => 0);
-$firstinitial = isset($SESSION->graderreportsifirst) ? $SESSION->graderreportsifirst : '';
-$lastinitial = isset($SESSION->graderreportsilast) ? $SESSION->graderreportsilast : '';
+$firstinitial = isset($USER->filterfirstname) ? $USER->filterfirstname : '';
+$lastinitial = isset($USER->filtersurname) ? $USER->filtersurname : '';
$totalusers = $report->get_numusers(true, false);
$renderer = $PAGE->get_renderer('core_user');
-echo $renderer->user_search($url, $hiddenfields, $firstinitial, $lastinitial, $numusers, $totalusers, $report->currentgroupname);
+echo $renderer->user_search($url, $firstinitial, $lastinitial, $numusers, $totalusers, $report->currentgroupname);
//show warnings if any
foreach($warnings as $warning) {
@@ -400,7 +400,7 @@ public function load_users() {
}
$this->setup_users();
- //limit to users with a gradeable role
+ // Limit to users with a gradeable role.
list($gradebookrolessql, $gradebookrolesparams) = $DB->get_in_or_equal(explode(',', $this->gradebookroles), SQL_PARAMS_NAMED, 'grbr0');
// Limit to users with an active enrollment.
@@ -414,7 +414,8 @@ public function load_users() {
// If the user has clicked one of the sort asc/desc arrows.
if (is_numeric($this->sortitemid)) {
- $params = array_merge(array('gitemid'=>$this->sortitemid), $gradebookrolesparams, $this->userwheresql_params, $this->groupwheresql_params, $enrolledparams);
+ $params = array_merge(array('gitemid' => $this->sortitemid), $gradebookrolesparams, $this->userwheresql_params,
+ $this->groupwheresql_params, $enrolledparams, $relatedctxparams);
$sortjoin = "LEFT JOIN {grade_grades} g ON g.userid = u.id AND g.itemid = $this->sortitemid";
$sort = "g.finalgrade $this->sortorder";
View
@@ -138,7 +138,7 @@
*/
protected $groupwheresql_params = array();
-//// USER VARIABLES (including SQL)
+ // USER VARIABLES (including SQL).
/**
* An SQL constraint to append to the queries used by this object to build the report.
@@ -357,16 +357,17 @@ protected function setup_groups() {
}
public function setup_users() {
- global $SESSION;
+ global $USER;
+
$this->userwheresql = "";
$this->userwheresql_params = array();
- if (isset($SESSION->graderreportsifirst) && !empty($SESSION->graderreportsifirst)) {
+ if (isset($USER->filterfirstname) && !empty($USER->filterfirstname)) {
$this->userwheresql .= ' AND u.firstname ILIKE :firstname ';
- $this->userwheresql_params['firstname'] = $SESSION->graderreportsifirst.'%';
+ $this->userwheresql_params['firstname'] = $USER->filterfirstname.'%';
}
- if (isset($SESSION->graderreportsilast) && !empty($SESSION->graderreportsilast)) {
+ if (isset($USER->filtersurname) && !empty($USER->filtersurname)) {
$this->userwheresql .= ' AND u.lastname ILIKE :lastname ';
- $this->userwheresql_params['lastname'] = $SESSION->graderreportsilast.'%';
+ $this->userwheresql_params['lastname'] = $USER->filtersurname.'%';
}
}
View
@@ -82,15 +82,14 @@ protected function htmllize_tree($tree, $dir) {
* Prints user search utility that can search user by first initial of firstname and/or first initial of lastname
* Prints a header with a title and the number of users found within that subset
* @param string $url the url to return to, complete with any parameters needed for the return
- * @param string $hiddenfields any extra hidden fields needed by the selection process or to comlete the reset process
* @param string $firstinitial the first initial of the firstname
* @param string $lastinitial the first initial of the lastname
* @param int $usercount the amount of users meeting the search criteria
* @param int $totalcount the amount of users of the set/subset being searched
* @param string $heading heading of the subset being searched, default is All Participants
* @return string html output
*/
- public function user_search($url, $hiddenfields, $firstinitial, $lastinitial, $usercount, $totalcount, $heading = null) {
+ public function user_search($url, $firstinitial, $lastinitial, $usercount, $totalcount, $heading = null) {
global $OUTPUT;
$strall = get_string('all');
@@ -103,18 +102,10 @@ public function user_search($url, $hiddenfields, $firstinitial, $lastinitial, $u
$content = html_writer::start_tag('form', array('action' => new moodle_url($url)));
$content .= html_writer::start_tag('div');
- // Search utility heading
+ // Search utility heading.
$content .= $OUTPUT->heading($heading.get_string('labelsep', 'langconfig').$usercount.'/'.$totalcount, 3);
- // Hidden fields
- $content .= html_writer::input_hidden_params($url);
- $content .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => get_string('reset')));
- if (isset($hiddenfields)) {
- foreach ($hiddenfields as $key => $value) {
- $content .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value));
- }
- }
- // Bar of first initials
+ // Bar of first initials.
$content .= html_writer::start_tag('div', array('class' => 'initialbar firstinitial'));
$content .= html_writer::label(get_string('firstname').' : ', null);
@@ -152,12 +143,6 @@ public function user_search($url, $hiddenfields, $firstinitial, $lastinitial, $u
}
$content .= html_writer::end_tag('div');
- // Reset button
- $content .= html_writer::tag('div', '&nbsp');
- $content .= html_writer::start_tag('div', array('class' => 'mdl-align'));
- $content .= html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('reset')));
- $content .= html_writer::end_tag('div');
-
$content .= html_writer::end_tag('div');
$content .= html_writer::tag('div', '&nbsp');
$content .= html_writer::end_tag('form');

0 comments on commit 4187784

Please sign in to comment.