diff --git a/course/renderer.php b/course/renderer.php
index 9d1439c7ad8..ba33b0647b8 100644
--- a/course/renderer.php
+++ b/course/renderer.php
@@ -372,13 +372,14 @@ class core_course_renderer extends plugin_renderer_base {
$inputsize = 30;
}
- $data = (object) [
- 'searchurl' => (new moodle_url('/course/search.php'))->out(false),
- 'id' => $formid,
- 'inputid' => $inputid,
- 'inputsize' => $inputsize,
- 'value' => $value
- ];
+ $data = new stdClass();
+ $data->searchurl = \core_search\manager::get_course_search_url()->out(false);
+ $data->id = $formid;
+ $data->inputid = $inputid;
+ $data->inputsize = $inputsize;
+ $data->value = $value;
+ $data->areaids = 'core_course-course';
+
if ($format != 'navbar') {
$helpicon = new \help_icon('coursesearch', 'core');
$data->helpicon = $helpicon->export_for_template($this);
diff --git a/course/search.php b/course/search.php
index 9dcd11292a2..144767d452f 100644
--- a/course/search.php
+++ b/course/search.php
@@ -24,6 +24,7 @@
require_once("../config.php");
require_once($CFG->dirroot.'/course/lib.php');
+$q = optional_param('q', '', PARAM_RAW); // Global search words.
$search = optional_param('search', '', PARAM_RAW); // search words
$page = optional_param('page', 0, PARAM_INT); // which page to show
$perpage = optional_param('perpage', '', PARAM_RAW); // how many per page, may be integer or 'all'
@@ -31,6 +32,11 @@ $blocklist = optional_param('blocklist', 0, PARAM_INT);
$modulelist= optional_param('modulelist', '', PARAM_PLUGIN);
$tagid = optional_param('tagid', '', PARAM_INT); // searches for courses tagged with this tag id
+// Use global search.
+if ($q) {
+ $search = $q;
+}
+
// List of minimum capabilities which user need to have for editing/moving course
$capabilities = array('moodle/course:create', 'moodle/category:manage');
diff --git a/course/templates/course_search_form.mustache b/course/templates/course_search_form.mustache
index c2e729a4cab..d00ea369413 100644
--- a/course/templates/course_search_form.mustache
+++ b/course/templates/course_search_form.mustache
@@ -14,10 +14,30 @@
You should have received a copy of the GNU General Public License
along with Moodle. If not, see