From 28af88f364121306be40844acd9ef72f6e2f6726 Mon Sep 17 00:00:00 2001 From: Daniel Neis Araujo Date: Tue, 25 Sep 2018 14:31:50 -0300 Subject: [PATCH] MDL-62334 admin: add a new course link on admin/search --- admin/settings/courses.php | 6 ++++++ course/edit.php | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/admin/settings/courses.php b/admin/settings/courses.php index 64ef1506a61..cf9b286ea8c 100644 --- a/admin/settings/courses.php +++ b/admin/settings/courses.php @@ -43,6 +43,12 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) { array('moodle/category:manage') ) ); + $ADMIN->add('courses', + new admin_externalpage('addnewcourse', new lang_string('addnewcourse'), + new moodle_url('/course/edit.php', array('category' => 0)), + array('moodle/category:manage') + ) + ); $ADMIN->add('courses', new admin_externalpage('restorecourse', new lang_string('restorecourse', 'admin'), new moodle_url('/backup/restorefile.php', array('contextid' => context_system::instance()->id)), diff --git a/course/edit.php b/course/edit.php index 727a1f70c82..81626d8f87a 100644 --- a/course/edit.php +++ b/course/edit.php @@ -103,8 +103,13 @@ if ($id) { $PAGE->set_context($catcontext); } else { + // Creating new course in default category. + $course = null; require_login(); - print_error('needcoursecategroyid'); + $category = core_course_category::get_default(); + $catcontext = context_coursecat::instance($category->id); + require_capability('moodle/course:create', $catcontext); + $PAGE->set_context($catcontext); } // Prepare course and the editor.