MDL-32888 Grader report: refined user search

This commit is contained in:
Melissa Aitkin 2013-06-26 11:27:29 +10:00
parent 8e4bf6cca6
commit cbe8e5b325
4 changed files with 140 additions and 66 deletions

View file

@ -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', '&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');
return $content;
}
}
class user_files_tree implements renderable {