mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-32508 course: Add basic 'add a section' button at the bottom of the course page
With thanks to LUNS who provided this code from when I did it working there.
This commit is contained in:
parent
1804b7c1bc
commit
1abf12532d
3 changed files with 49 additions and 0 deletions
37
course/addsection.php
Normal file
37
course/addsection.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
require_once(dirname(__FILE__).'/../config.php');
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
|
||||
|
||||
$PAGE->set_url('/course/addsection.php', array('courseid' => $courseid));
|
||||
|
||||
// Authorisation checks.
|
||||
require_login($course);
|
||||
require_capability('moodle/course:update', context_course::instance($course->id));
|
||||
require_sesskey();
|
||||
|
||||
// Add an additional section.
|
||||
$course->numsections++;
|
||||
$DB->update_record('course', $course);
|
||||
|
||||
// Redirect to where we were..
|
||||
redirect(course_get_url($course));
|
Loading…
Add table
Add a link
Reference in a new issue