Corrected the help text for numerical.html
[moodle.git] / course / view.php
CommitLineData
f9903ed0 1<?PHP // $Id$
2
3// Display the course home page.
4
b0e3a925 5 require_once("../config.php");
6 require_once("lib.php");
f9903ed0 7
388f8911 8 optional_variable($id);
9 optional_variable($name);
f9903ed0 10
388f8911 11 if (!$id and !$name) {
12 error("Must specify course id or short name");
13 }
f9903ed0 14
388f8911 15 if ($name) {
16 if (! $course = get_record("course", "shortname", $name) ) {
17 error("That's an invalid short course name");
18 }
19 } else {
20 if (! $course = get_record("course", "id", $id) ) {
21 error("That's an invalid course id");
22 }
f9903ed0 23 }
24
783da262 25 require_login($course->id);
388f8911 26
600149be 27 add_to_log($course->id, "course", "view", "view.php?id=$course->id", "$course->id");
f9903ed0 28
73047f2f 29 if (isteacheredit($course->id)) {
73fafc38 30 if (isset($edit)) {
9c9f7d77 31 if ($edit == "on") {
32 $USER->editing = true;
33 } else if ($edit == "off") {
34 $USER->editing = false;
35 }
f9903ed0 36 }
8223d271 37
73fafc38 38 if (isset($hide)) {
39 set_section_visible($course->id, $hide, "0");
40 }
7d99d695 41
73fafc38 42 if (isset($show)) {
43 set_section_visible($course->id, $show, "1");
44 }
12905134 45
46 if (!empty($section)) {
47 if (!empty($move)) {
56e34ee4 48 if (!move_section($course, $section, $move)) {
49 notify("An error occurred while moving a section");
50 }
12905134 51 }
52 }
48d72fa7 53 } else {
54 $USER->editing = false;
7d99d695 55 }
56
4c701e6f 57 $SESSION->fromdiscussion = "$CFG->wwwroot/course/view.php?id=$course->id";
4c701e6f 58
b8391635 59 if (! $course->category) { // This course is not a real course.
60 redirect("$CFG->wwwroot/");
61 }
62
dc0dc7d5 63 if (empty($THEME->custompix)) {
64 $pixpath = "../pix";
65 $modpixpath = "../mod";
66 } else {
67 $pixpath = "../theme/$CFG->theme/pix";
68 $modpixpath = "../theme/$CFG->theme/pix/mod";
69 }
b8391635 70
fa0626c6 71 $courseword = get_string("course");
72
b328523c 73 $loggedinas = "<p class=\"logininfo\">".user_login_string($course, $USER)."</p>";
a282d0ff 74
fa0626c6 75 print_header("$courseword: $course->fullname", "$course->fullname", "$course->shortname", "search.search", "", true,
a282d0ff 76 update_course_icon($course->id), $loggedinas);
f9903ed0 77
9c9f7d77 78 get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
19801b2b 79
dfec7b01 80 if (! $sections = get_all_sections($course->id)) { // No sections found
81 // Double-check to be extra sure
82 if (! $section = get_record("course_sections", "course", $course->id, "section", 0)) {
83 $section->course = $course->id; // Create a default section.
84 $section->section = 0;
85 $section->visible = 1;
86 $section->id = insert_record("course_sections", $section);
87 }
88 if (! $sections = get_all_sections($course->id) ) { // Try again
19801b2b 89 error("Error finding or creating section structures for this course");
90 }
91 }
7468bf01 92
51955364 93 if (empty($course->modinfo)) { // Course cache was never made
94 rebuild_course_cache($course->id);
95 }
96
d0e922a9 97 if (!file_exists("$CFG->dirroot/course/format/$course->format.php")) { // Default format is weeks
7142bc1b 98 $course->format = "weeks";
99 }
100
d0e922a9 101 require("$CFG->dirroot/course/format/$course->format.php"); // Include the actual course format
f9903ed0 102
2c26c985 103 print_footer();
f9903ed0 104
f9903ed0 105?>