mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
Merge branch 'MDL-73140' of https://github.com/timhunt/moodle
This commit is contained in:
commit
ca8f2deea4
@ -50,7 +50,8 @@ class filter_form extends \moodleform {
|
||||
$itemids = $this->_customdata['itemids'];
|
||||
$graders = $this->_customdata['graders'];
|
||||
$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', 'selectednames', get_string('selectedusers', 'gradereport_history'), $names);
|
||||
@ -79,16 +80,4 @@ class filter_form extends \moodleform {
|
||||
// Add a submit button.
|
||||
$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'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -529,7 +529,8 @@ class tablelog extends \table_sql implements \renderable {
|
||||
|
||||
$idlist = explode(',', $this->filters->userids);
|
||||
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;
|
||||
|
@ -58,7 +58,8 @@ $itemids = array(0 => get_string('allgradeitems', 'gradereport_history')) + $ite
|
||||
|
||||
$output = $PAGE->get_renderer('gradereport_history');
|
||||
$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);
|
||||
$filters = array();
|
||||
if ($data = $mform->get_data()) {
|
||||
@ -85,7 +86,7 @@ $names = array();
|
||||
foreach ($table->get_selected_users() as $key => $user) {
|
||||
$names[$key] = fullname($user);
|
||||
}
|
||||
$filters['userfullnames'] = implode(',', $names);
|
||||
$userfullnames = implode(', ', $names);
|
||||
|
||||
// Set up js.
|
||||
\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');
|
||||
|
||||
$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->set_data($filters);
|
||||
|
||||
|
@ -65,11 +65,22 @@ Feature: A teacher checks the grade history report in a course
|
||||
| Student 1 | student1@example.com | apple | Rewarding assignment | 60.00 | 80.00 | Teacher 2 |
|
||||
| Student 2 | student2@example.com | orange | The greatest assignment ever | 50.00 | 70.00 | Teacher 2 |
|
||||
| Student 2 | student2@example.com | orange | 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.
|
||||
And I press "Select users"
|
||||
And I set the field with xpath "//form/input[@class='usp-search-field']" to "Student 1"
|
||||
And I click on "Search" "button" in the "//div[@class='usp-search']" "xpath_element"
|
||||
And I set the field with xpath "//div[@class='usp-checkbox']/input" to "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 "Select users" "dialogue"
|
||||
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 "Submit"
|
||||
And the following should exist in the "gradereport_history" table:
|
||||
|
@ -61,16 +61,17 @@ foreach ($users as $user) {
|
||||
$newuser->userid = $user->id;
|
||||
$newuser->picture = $OUTPUT->user_picture($user, $useroptions);
|
||||
$newuser->fullname = fullname($user);
|
||||
$fieldvalues = [];
|
||||
foreach ($extrafields as $field) {
|
||||
if ($user->{$field}) {
|
||||
$newuser->extrafields[] = $user->{$field};
|
||||
$fieldvalues[] = $user->{$field};
|
||||
}
|
||||
}
|
||||
$newuser->extrafields = implode(', ', $fieldvalues);
|
||||
$outcome->response['users'][] = $newuser;
|
||||
}
|
||||
|
||||
$outcome->success = true;
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo json_encode($outcome);
|
||||
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.
|
||||
* @return array with two elements:
|
||||
* 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,
|
||||
array $customfieldmappings = []) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user