MDL-69454 core_search: consistent course management search

This commit is contained in:
Bas Brands
2020-09-23 17:36:14 +02:00
committed by Eloy Lafuente (stronk7)
parent 42c1cf3b03
commit b5e39191fc
3 changed files with 17 additions and 52 deletions
+10 -47
View File
@@ -1291,56 +1291,19 @@ class core_course_management_renderer extends plugin_renderer_base {
* Renders html to display a course search form
*
* @param string $value default value to populate the search field
* @param string $format display format - 'plain' (default), 'short' or 'navbar'
* @return string
*/
public function course_search_form($value = '', $format = 'plain') {
static $count = 0;
$formid = 'coursesearch';
if ((++$count) > 1) {
$formid .= $count;
}
public function course_search_form($value = '') {
switch ($format) {
case 'navbar' :
$formid = 'coursesearchnavbar';
$inputid = 'navsearchbox';
$inputsize = 20;
break;
case 'short' :
$inputid = 'shortsearchbox';
$inputsize = 12;
break;
default :
$inputid = 'coursesearchbox';
$inputsize = 30;
}
$strsearchcourses = get_string("searchcourses");
$searchurl = new moodle_url('/course/management.php');
$output = html_writer::start_div('row');
$output .= html_writer::start_div('col-md-12');
$output .= html_writer::start_tag('form', array('class' => 'card', 'id' => $formid,
'action' => $searchurl, 'method' => 'get'));
$output .= html_writer::start_tag('fieldset', array('class' => 'coursesearchbox invisiblefieldset'));
$output .= html_writer::tag('legend', $this->output->heading($strsearchcourses.': ', 2, 'm-0'),
array('class' => 'card-header'));
$output .= html_writer::start_div('card-body');
$output .= html_writer::start_div('input-group col-sm-6 col-lg-4 m-auto');
$output .= html_writer::empty_tag('input', array('class' => 'form-control', 'type' => 'text', 'id' => $inputid,
'size' => $inputsize, 'name' => 'search', 'value' => s($value), 'aria-label' => get_string('searchcourses')));
$output .= html_writer::start_tag('span', array('class' => 'input-group-btn'));
$output .= html_writer::tag('button', get_string('go'), array('class' => 'btn btn-primary', 'type' => 'submit'));
$output .= html_writer::end_tag('span');
$output .= html_writer::end_div();
$output .= html_writer::end_div();
$output .= html_writer::end_tag('fieldset');
$output .= html_writer::end_tag('form');
$output .= html_writer::end_div();
$output .= html_writer::end_div();
return $output;
$data = [
'action' => new moodle_url('/course/management.php'),
'btnclass' => 'btn-primary',
'extraclasses' => 'my-3 d-flex justify-content-center',
'inputname' => 'search',
'searchstring' => get_string('searchcourses'),
'value' => $value
];
return $this->render_from_template('core/search_input', $data);
}
/**
+3 -1
View File
@@ -487,6 +487,9 @@ if (count($notificationsfail) > 0) {
}
// Start the management form.
echo $renderer->course_search_form($search);
echo $renderer->management_form_start();
echo $renderer->accessible_skipto_links($displaycategorylisting, $displaycourselisting, $displaycoursedetail);
@@ -518,6 +521,5 @@ echo $renderer->grid_end();
// End of the management form.
echo $renderer->management_form_end();
echo $renderer->course_search_form($search);
echo $renderer->footer();
+4 -4
View File
@@ -20,8 +20,8 @@ Feature: Courses can be searched for and moved in bulk.
Scenario: Search courses finds correct results
Given I log in as "admin"
And I go to the courses management page
When I set the field "coursesearchbox" to "Biology"
And I press "Go"
When I set the field "Search" to "Biology"
And I press "Search"
Then I should see "Biology Y1"
And I should see "Biology Y2"
And I should not see "English Y1"
@@ -31,8 +31,8 @@ Feature: Courses can be searched for and moved in bulk.
Scenario: Search courses and move results in bulk
Given I log in as "admin"
And I go to the courses management page
And I set the field "coursesearchbox" to "Biology"
And I press "Go"
And I set the field "Search" to "Biology"
And I press "Search"
When I select course "Biology Y1" in the management interface
And I select course "Biology Y2" in the management interface
And I set the field "menumovecoursesto" to "Science"