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));
|
|
@ -507,8 +507,19 @@ abstract class format_renderer_base extends plugin_renderer_base {
|
||||||
print_section($course, $thissection, $mods, $modnamesused);
|
print_section($course, $thissection, $mods, $modnamesused);
|
||||||
echo $this->stealth_section_footer();
|
echo $this->stealth_section_footer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$straddsection = get_string('addanadditionalsection', 'moodle');
|
||||||
|
echo html_writer::start_tag('div', array('class' => 'mdl-align'));
|
||||||
|
echo $this->output->action_link(
|
||||||
|
new moodle_url('/course/addsection.php',
|
||||||
|
array('courseid' => $course->id, 'sesskey' => sesskey())
|
||||||
|
), $this->output->pix_icon('t/add', $straddsection).$straddsection, null,
|
||||||
|
array('class' => 'addsectionlink')
|
||||||
|
);
|
||||||
|
echo html_writer::end_tag('div');
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $this->end_section_list();
|
echo $this->end_section_list();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ $string['activityweighted'] = 'Activity per user';
|
||||||
$string['add'] = 'Add';
|
$string['add'] = 'Add';
|
||||||
$string['addactivity'] = 'Add an activity...';
|
$string['addactivity'] = 'Add an activity...';
|
||||||
$string['addadmin'] = 'Add admin';
|
$string['addadmin'] = 'Add admin';
|
||||||
|
$string['addanadditionalsection'] = 'Add an additional section';
|
||||||
$string['addblock'] = 'Add a block';
|
$string['addblock'] = 'Add a block';
|
||||||
$string['addcomment'] = 'Add a comment...';
|
$string['addcomment'] = 'Add a comment...';
|
||||||
$string['addcountertousername'] = 'Create user by adding number to username';
|
$string['addcountertousername'] = 'Create user by adding number to username';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue