MDL-32508 course: Introduce course_get_url()

This commit is contained in:
Dan Poltawski 2012-04-26 21:36:02 +08:00
parent 45774bddf7
commit 5218b9bb7d
4 changed files with 36 additions and 15 deletions

View file

@ -4512,3 +4512,24 @@ function include_course_ajax($course, $modules = array(), $config = null) {
$PAGE->requires->string_for_js('pluginname', $module);
}
}
/**
* The URL to use for the specified course (with section)
*
* @param stdClass $course The course to get the section name for
* @param int $sectionno The section number to return a link to
* @return moodle_url The url of course
*/
function course_get_url($course, $sectionno = null) {
$url = new moodle_url('/course/view.php', array('id' => $course->id));
if (!is_null($sectionno)) {
if ($course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
$url->param('section', $sectionno);
} else {
$url->set_anchor('section-'.$sectionno);
}
}
return $url;
}