mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-73140 grade history: fix badly formatted lists
This commit is contained in:
parent
bd9c2a4bc2
commit
42055d95cd
6 changed files with 24 additions and 22 deletions
|
@ -50,7 +50,8 @@ class filter_form extends \moodleform {
|
||||||
$itemids = $this->_customdata['itemids'];
|
$itemids = $this->_customdata['itemids'];
|
||||||
$graders = $this->_customdata['graders'];
|
$graders = $this->_customdata['graders'];
|
||||||
$userbutton = $this->_customdata['userbutton'];
|
$userbutton = $this->_customdata['userbutton'];
|
||||||
$names = \html_writer::span('', 'selectednames');
|
$userfullnames = $this->_customdata['userfullnames'];
|
||||||
|
$names = \html_writer::span($userfullnames, 'selectednames');
|
||||||
|
|
||||||
$mform->addElement('static', 'userselect', get_string('selectusers', 'gradereport_history'), $userbutton);
|
$mform->addElement('static', 'userselect', get_string('selectusers', 'gradereport_history'), $userbutton);
|
||||||
$mform->addElement('static', 'selectednames', get_string('selectedusers', 'gradereport_history'), $names);
|
$mform->addElement('static', 'selectednames', get_string('selectedusers', 'gradereport_history'), $names);
|
||||||
|
@ -79,16 +80,4 @@ class filter_form extends \moodleform {
|
||||||
// Add a submit button.
|
// Add a submit button.
|
||||||
$mform->addElement('submit', 'submitbutton', get_string('submit'));
|
$mform->addElement('submit', 'submitbutton', get_string('submit'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method implements changes to the form that need to be made once the form data is set.
|
|
||||||
*/
|
|
||||||
public function definition_after_data() {
|
|
||||||
$mform = $this->_form;
|
|
||||||
|
|
||||||
if ($userfullnames = $mform->getElementValue('userfullnames')) {
|
|
||||||
$mform->getElement('selectednames')->setValue(\html_writer::span($userfullnames, 'selectednames'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -519,7 +519,8 @@ class tablelog extends \table_sql implements \renderable {
|
||||||
|
|
||||||
$idlist = explode(',', $this->filters->userids);
|
$idlist = explode(',', $this->filters->userids);
|
||||||
list($where, $params) = $DB->get_in_or_equal($idlist);
|
list($where, $params) = $DB->get_in_or_equal($idlist);
|
||||||
return $DB->get_records_select('user', "id $where", $params);
|
[$order] = users_order_by_sql();
|
||||||
|
return $DB->get_records_select('user', "id $where", $params, $order);
|
||||||
|
|
||||||
}
|
}
|
||||||
return $idlist;
|
return $idlist;
|
||||||
|
|
|
@ -58,7 +58,8 @@ $itemids = array(0 => get_string('allgradeitems', 'gradereport_history')) + $ite
|
||||||
|
|
||||||
$output = $PAGE->get_renderer('gradereport_history');
|
$output = $PAGE->get_renderer('gradereport_history');
|
||||||
$graders = \gradereport_history\helper::get_graders($course->id);
|
$graders = \gradereport_history\helper::get_graders($course->id);
|
||||||
$params = array('course' => $course, 'itemids' => $itemids, 'graders' => $graders, 'userbutton' => null);
|
$params = ['course' => $course, 'itemids' => $itemids, 'graders' => $graders,
|
||||||
|
'userbutton' => null, 'userfullnames' => ''];
|
||||||
$mform = new \gradereport_history\filter_form(null, $params);
|
$mform = new \gradereport_history\filter_form(null, $params);
|
||||||
$filters = array();
|
$filters = array();
|
||||||
if ($data = $mform->get_data()) {
|
if ($data = $mform->get_data()) {
|
||||||
|
@ -85,7 +86,7 @@ $names = array();
|
||||||
foreach ($table->get_selected_users() as $key => $user) {
|
foreach ($table->get_selected_users() as $key => $user) {
|
||||||
$names[$key] = fullname($user);
|
$names[$key] = fullname($user);
|
||||||
}
|
}
|
||||||
$filters['userfullnames'] = implode(',', $names);
|
$userfullnames = implode(', ', $names);
|
||||||
|
|
||||||
// Set up js.
|
// Set up js.
|
||||||
\gradereport_history\helper::init_js($course->id, $names);
|
\gradereport_history\helper::init_js($course->id, $names);
|
||||||
|
@ -94,7 +95,8 @@ $filters['userfullnames'] = implode(',', $names);
|
||||||
$button = new \gradereport_history\output\user_button($PAGE->url, get_string('selectusers', 'gradereport_history'), 'get');
|
$button = new \gradereport_history\output\user_button($PAGE->url, get_string('selectusers', 'gradereport_history'), 'get');
|
||||||
|
|
||||||
$userbutton = $output->render($button);
|
$userbutton = $output->render($button);
|
||||||
$params = array('course' => $course, 'itemids' => $itemids, 'graders' => $graders, 'userbutton' => $userbutton);
|
$params = ['course' => $course, 'itemids' => $itemids, 'graders' => $graders,
|
||||||
|
'userbutton' => $userbutton, 'userfullnames' => $userfullnames];
|
||||||
$mform = new \gradereport_history\filter_form(null, $params);
|
$mform = new \gradereport_history\filter_form(null, $params);
|
||||||
$mform->set_data($filters);
|
$mform->set_data($filters);
|
||||||
|
|
||||||
|
|
|
@ -58,11 +58,22 @@ Feature: A teacher checks the grade history report in a course
|
||||||
| Student 1 | Rewarding assignment | 60.00 | 80.00 | Teacher 2 |
|
| Student 1 | Rewarding assignment | 60.00 | 80.00 | Teacher 2 |
|
||||||
| Student 2 | The greatest assignment ever | 50.00 | 70.00 | Teacher 2 |
|
| Student 2 | The greatest assignment ever | 50.00 | 70.00 | Teacher 2 |
|
||||||
| Student 2 | Rewarding assignment | 60.00 | 80.00 | Teacher 2 |
|
| Student 2 | Rewarding assignment | 60.00 | 80.00 | Teacher 2 |
|
||||||
|
# Test filtering by student - display of several users.
|
||||||
|
And I press "Select users"
|
||||||
|
And I click on "Student 1" "checkbox"
|
||||||
|
And I click on "Student 2" "checkbox"
|
||||||
|
And I press "Finish selecting users"
|
||||||
|
And I should see "Student 1, Student 2"
|
||||||
|
And I press "Submit"
|
||||||
|
And I should see "Student 1, Student 2"
|
||||||
# Test filtering by student.
|
# Test filtering by student.
|
||||||
And I press "Select users"
|
And I press "Select users"
|
||||||
And I set the field with xpath "//form/input[@class='usp-search-field']" to "Student 1"
|
And I set the field with xpath "//form/input[@class='usp-search-field']" to "Student 2"
|
||||||
And I click on "Search" "button" in the "//div[@class='usp-search']" "xpath_element"
|
And I click on "Search" "button" in the "Select users" "dialogue"
|
||||||
And I set the field with xpath "//div[@class='usp-checkbox']/input" to "1"
|
And I should see "Student 2" in the "Select users" "dialogue"
|
||||||
|
And I should not see "Student 1" in the "Select users" "dialogue"
|
||||||
|
# Deselect.
|
||||||
|
And I click on "Student 2" "checkbox"
|
||||||
And I press "Finish selecting users"
|
And I press "Finish selecting users"
|
||||||
And I press "Submit"
|
And I press "Submit"
|
||||||
And the following should exist in the "gradereport_history" table:
|
And the following should exist in the "gradereport_history" table:
|
||||||
|
|
|
@ -70,7 +70,6 @@ foreach ($users as $user) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$outcome->success = true;
|
$outcome->success = true;
|
||||||
|
|
||||||
echo $OUTPUT->header();
|
echo $OUTPUT->header();
|
||||||
echo json_encode($outcome);
|
echo json_encode($outcome);
|
||||||
echo $OUTPUT->footer();
|
echo $OUTPUT->footer();
|
||||||
|
|
|
@ -341,7 +341,7 @@ function users_search_sql(string $search, string $u = 'u', bool $searchanywhere
|
||||||
* @param array $customfieldmappings associative array of mappings for custom fields returned by \core_user\fields::get_sql.
|
* @param array $customfieldmappings associative array of mappings for custom fields returned by \core_user\fields::get_sql.
|
||||||
* @return array with two elements:
|
* @return array with two elements:
|
||||||
* string SQL fragment to use in the ORDER BY clause. For example, "firstname, lastname".
|
* string SQL fragment to use in the ORDER BY clause. For example, "firstname, lastname".
|
||||||
* array of parameters used in the SQL fragment.
|
* array of parameters used in the SQL fragment. If $search is not given, this is guaranteed to be an empty array.
|
||||||
*/
|
*/
|
||||||
function users_order_by_sql(string $usertablealias = '', string $search = null, context $context = null,
|
function users_order_by_sql(string $usertablealias = '', string $search = null, context $context = null,
|
||||||
array $customfieldmappings = []) {
|
array $customfieldmappings = []) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue