From: mark-nielsen Date: Wed, 6 Sep 2006 04:02:02 +0000 (+0000) Subject: Added function for printing a standard header for lesson X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9fcf51d9bf3f762b6153835b382c8cddc7317762;p=moodle.git Added function for printing a standard header for lesson Added function for fetching course module, course and lesson based on course module id or lesson id --- diff --git a/mod/lesson/locallib.php b/mod/lesson/locallib.php index b7833ff546..5e4f1e4a54 100644 --- a/mod/lesson/locallib.php +++ b/mod/lesson/locallib.php @@ -1,4 +1,4 @@ -category) { + $navigation = "wwwroot/course/view.php?id=$course->id\" title=\"$course->fullname\">$course->shortname ->"; + } else { + $navigation = ''; + } + + $strlessons = get_string('modulenameplural', 'lesson'); + $strlesson = get_string('modulename', 'lesson'); + $strname = format_string($lesson->name, true); + +/// Print header, heading, tabs and messages + print_header("$course->shortname: $strname", $course->fullname, + "$navigation id\" title=\"$strlessons\">$strlessons -> $strname", + '', '', true, update_module_button($cm->id, $course->id, $strlesson), + navmenu($course, $cm)); + + if ($printheading) { + print_heading_with_help(format_string($lesson->name, true), "overview", "lesson"); + } + + if (!empty($currenttab) and isteacher($course->id)) { + include($CFG->dirroot.'/mod/lesson/tabs.php'); + } +} + +/** + * Returns course module, course and module instance given + * either the course module ID or a lesson module ID. + * + * @param int $cmid Course Module ID + * @param int $lessonid Lesson module instance ID + * @return array array($cm, $course, $lesson) + **/ +function lesson_get_basics($cmid = 0, $lessonid = 0) { + if ($cmid) { + if (!$cm = get_record('course_modules', 'id', $cmid)) { + error('Course Module ID was incorrect'); + } + if (!$course = get_record('course', 'id', $cm->course)) { + error('Course is misconfigured'); + } + if (!$lesson = get_record('lesson', 'id', $cm->instance)) { + error('Course module is incorrect'); + } + } else if ($lessonid) { + if (!$lesson = get_record('lesson', 'id', $lessonid)) { + error('Course module is incorrect'); + } + if (!$course = get_record('course', 'id', $lesson->course)) { + error('Course is misconfigured'); + } + if (!$cm = get_coursemodule_from_instance('lesson', $lesson->id, $course->id)) { + error('Course Module ID was incorrect'); + } + } else { + error('No course module ID or lesson ID were passed'); + } + + return array($cm, $course, $lesson); +} + /** * Given some question info and some data about the the answers * this function parses, organises and saves the question