* 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;
- }
-
- 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;
+ public function course_search_form($value = '') {
+
+ $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);
}
/**
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"
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"