mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-32888 Grader report: refined user search
This commit is contained in:
parent
8e4bf6cca6
commit
cbe8e5b325
@ -24,6 +24,7 @@
|
||||
|
||||
require_once '../../../config.php';
|
||||
require_once $CFG->libdir.'/gradelib.php';
|
||||
require_once $CFG->dirroot.'/user/renderer.php';
|
||||
require_once $CFG->dirroot.'/grade/lib.php';
|
||||
require_once $CFG->dirroot.'/grade/report/grader/lib.php';
|
||||
|
||||
@ -39,16 +40,22 @@ $target = optional_param('target', 0, PARAM_ALPHANUM);
|
||||
$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);
|
||||
|
||||
// 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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
$PAGE->set_url(new moodle_url('/grade/report/grader/index.php', array('id'=>$courseid)));
|
||||
|
||||
@ -150,55 +157,14 @@ $report->load_users();
|
||||
$report->load_final_grades();
|
||||
echo $report->group_selector;
|
||||
|
||||
// Initials Selection Section
|
||||
$baseurl = new moodle_url('/grade/report/grader/index.php', array('id' => $course->id));
|
||||
$firstinitial = isset($SESSION->graderreportsifirst) ? $SESSION->graderreportsifirst : "";
|
||||
$lastinitial = isset($SESSION->graderreportsilast) ? $SESSION->graderreportsilast : "";
|
||||
$strall = get_string('all');
|
||||
$alpha = explode(',', get_string('alphabet', 'langconfig'));
|
||||
$strallparticipants = get_string('allparticipants');
|
||||
$totalusers = $report->get_numusers(false, false);
|
||||
|
||||
echo '<form action="index.php">';
|
||||
echo '<div>';
|
||||
echo $OUTPUT->heading($strallparticipants.get_string('labelsep', 'langconfig').$numusers.'/'.$totalusers, 3);
|
||||
|
||||
// Bar of first initials
|
||||
echo '<div class="initialbar firstinitial">'.get_string('firstname').' : ';
|
||||
if (!empty($firstinitial)) {
|
||||
echo '<a href="'.$baseurl->out().'&sifirst=">'.$strall.'</a>';
|
||||
} else {
|
||||
echo '<strong>'.$strall.'</strong>';
|
||||
}
|
||||
foreach ($alpha as $letter) {
|
||||
if ($letter == $firstinitial) {
|
||||
echo ' <strong>'.$letter.'</strong>';
|
||||
} else {
|
||||
echo ' <a href="'.$baseurl->out().'&sifirst='.$letter.'">'.$letter.'</a>';
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
// Bar of last initials
|
||||
echo '<div class="initialbar lastinitial">'.get_string('lastname').' : ';
|
||||
if (!empty($lastinitial)) {
|
||||
echo '<a href="'.$baseurl->out().'&silast=">'.$strall.'</a>';
|
||||
} else {
|
||||
echo '<strong>'.$strall.'</strong>';
|
||||
}
|
||||
foreach ($alpha as $letter) {
|
||||
if ($letter == $lastinitial) {
|
||||
echo ' <strong>'.$letter.'</strong>';
|
||||
} else {
|
||||
echo ' <a href="'.$baseurl->out().'&silast='.$letter.'">'.$letter.'</a>';
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
echo '<div> </div>';
|
||||
echo '</form>';
|
||||
// Initials Selection Section
|
||||
// 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 : '';
|
||||
$totalusers = $report->get_numusers(true, false);
|
||||
$renderer = $PAGE->get_renderer('core_user');
|
||||
echo $renderer->user_search($url, $hiddenfields, $firstinitial, $lastinitial, $numusers, $totalusers, $report->currentgroupname);
|
||||
|
||||
//show warnings if any
|
||||
foreach($warnings as $warning) {
|
||||
@ -211,7 +177,12 @@ if (!empty($studentsperpage)) {
|
||||
echo $OUTPUT->paging_bar($numusers, $report->page, $studentsperpage, $report->pbarurl);
|
||||
}
|
||||
|
||||
$reporthtml = $report->get_grade_table();
|
||||
$displayaverages = true;
|
||||
if ($numusers == 0) {
|
||||
$displayaverages = false;
|
||||
}
|
||||
|
||||
$reporthtml = $report->get_grade_table($displayaverages);
|
||||
|
||||
// print submit button
|
||||
if ($USER->gradeediting[$course->id] && ($report->get_pref('showquickfeedback') || $report->get_pref('quickgrading'))) {
|
||||
|
@ -559,9 +559,10 @@ class grade_report_grader extends grade_report {
|
||||
* This consists of student names and icons, links to user reports and id numbers, as well
|
||||
* as header cells for these columns. It also includes the fillers required for the
|
||||
* categories displayed on the right side of the report.
|
||||
* @param boolean $displayaverages whether to display average rows in the table
|
||||
* @return array Array of html_table_row objects
|
||||
*/
|
||||
public function get_left_rows() {
|
||||
public function get_left_rows($displayaverages) {
|
||||
global $CFG, $USER, $OUTPUT;
|
||||
|
||||
$rows = array();
|
||||
@ -678,17 +679,20 @@ class grade_report_grader extends grade_report {
|
||||
}
|
||||
|
||||
$rows = $this->get_left_range_row($rows, $colspan);
|
||||
$rows = $this->get_left_avg_row($rows, $colspan, true);
|
||||
$rows = $this->get_left_avg_row($rows, $colspan);
|
||||
if ($displayaverages) {
|
||||
$rows = $this->get_left_avg_row($rows, $colspan, true);
|
||||
$rows = $this->get_left_avg_row($rows, $colspan);
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds and returns the rows that will make up the right part of the grader report
|
||||
* @param boolean $displayaverages whether to display average rows in the table
|
||||
* @return array Array of html_table_row objects
|
||||
*/
|
||||
public function get_right_rows() {
|
||||
public function get_right_rows($displayaverages) {
|
||||
global $CFG, $USER, $OUTPUT, $DB, $PAGE;
|
||||
|
||||
$rows = array();
|
||||
@ -1064,8 +1068,10 @@ class grade_report_grader extends grade_report {
|
||||
$PAGE->requires->strings_for_js(array('ajaxchoosescale','ajaxclicktoclose','ajaxerror','ajaxfailedupdate', 'ajaxfieldchanged'), 'gradereport_grader');
|
||||
|
||||
$rows = $this->get_right_range_row($rows);
|
||||
$rows = $this->get_right_avg_row($rows, true);
|
||||
$rows = $this->get_right_avg_row($rows);
|
||||
if ($displayaverages) {
|
||||
$rows = $this->get_right_avg_row($rows, true);
|
||||
$rows = $this->get_right_avg_row($rows);
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
@ -1074,14 +1080,15 @@ class grade_report_grader extends grade_report {
|
||||
* Depending on the style of report (fixedstudents vs traditional one-table),
|
||||
* arranges the rows of data in one or two tables, and returns the output of
|
||||
* these tables in HTML
|
||||
* @param boolean $displayaverages whether to display average rows in the table
|
||||
* @return string HTML
|
||||
*/
|
||||
public function get_grade_table() {
|
||||
public function get_grade_table($displayaverages = false) {
|
||||
global $OUTPUT;
|
||||
$fixedstudents = $this->is_fixed_students();
|
||||
|
||||
$leftrows = $this->get_left_rows();
|
||||
$rightrows = $this->get_right_rows();
|
||||
$leftrows = $this->get_left_rows($displayaverages);
|
||||
$rightrows = $this->get_right_rows($displayaverages);
|
||||
|
||||
$html = '';
|
||||
|
||||
|
@ -102,6 +102,12 @@ abstract class grade_report {
|
||||
*/
|
||||
public $currentgroup;
|
||||
|
||||
/**
|
||||
* The current groupname being displayed.
|
||||
* @var string $currentgroupname
|
||||
*/
|
||||
public $currentgroupname;
|
||||
|
||||
/**
|
||||
* Current course group mode
|
||||
* @var int $groupmode
|
||||
@ -341,6 +347,8 @@ abstract class grade_report {
|
||||
}
|
||||
|
||||
if ($this->currentgroup) {
|
||||
$group = groups_get_group($this->currentgroup);
|
||||
$this->currentgroupname = $group->name;
|
||||
$this->groupsql = " JOIN {groups_members} gm ON gm.userid = u.id ";
|
||||
$this->groupwheresql = " AND gm.groupid = :gr_grpid ";
|
||||
$this->groupwheresql_params = array('gr_grpid'=>$this->currentgroup);
|
||||
|
@ -77,6 +77,94 @@ class core_user_renderer extends plugin_renderer_base {
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
global $OUTPUT;
|
||||
|
||||
$strall = get_string('all');
|
||||
$alpha = explode(',', get_string('alphabet', 'langconfig'));
|
||||
|
||||
if (!isset($heading)) {
|
||||
$heading = get_string('allparticipants');
|
||||
}
|
||||
|
||||
$content = html_writer::start_tag('form', array('action' => new moodle_url($url)));
|
||||
$content .= html_writer::start_tag('div');
|
||||
|
||||
// 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
|
||||
$content .= html_writer::start_tag('div', array('class' => 'initialbar firstinitial'));
|
||||
$content .= html_writer::label(get_string('firstname').' : ', null);
|
||||
|
||||
if (!empty($firstinitial)) {
|
||||
$content .= html_writer::link($url.'&sifirst=', $strall);
|
||||
} else {
|
||||
$content .= html_writer::tag('strong', $strall);
|
||||
}
|
||||
|
||||
foreach ($alpha as $letter) {
|
||||
if ($letter == $firstinitial) {
|
||||
$content .= html_writer::tag('strong', $letter);
|
||||
} else {
|
||||
$content .= html_writer::link($url.'&sifirst='.$letter, $letter);
|
||||
}
|
||||
}
|
||||
$content .= html_writer::end_tag('div');
|
||||
|
||||
// Bar of last initials
|
||||
$content .= html_writer::start_tag('div', array('class' => 'initialbar lastinitial'));
|
||||
$content .= html_writer::label(get_string('lastname').' : ', null);
|
||||
|
||||
if (!empty($lastinitial)) {
|
||||
$content .= html_writer::link($url.'&silast=', $strall);
|
||||
} else {
|
||||
$content .= html_writer::tag('strong', $strall);
|
||||
}
|
||||
|
||||
foreach ($alpha as $letter) {
|
||||
if ($letter == $lastinitial) {
|
||||
$content .= html_writer::tag('strong', $letter);
|
||||
} else {
|
||||
$content .= html_writer::link($url.'&silast='.$letter, $letter);
|
||||
}
|
||||
}
|
||||
$content .= html_writer::end_tag('div');
|
||||
|
||||
// Reset button
|
||||
$content .= html_writer::tag('div', ' ');
|
||||
$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', ' ');
|
||||
$content .= html_writer::end_tag('form');
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class user_files_tree implements renderable {
|
||||
|
Loading…
x
Reference in New Issue
Block a user