7684ef1f3f7c079bbeebff33ad9caa58052f3a4d
[moodle.git] / course / editweek.php
1 <?PHP // $Id$
3     require("../config.php");
5     require_variable($id);    // Week ID
7     if (! $week = get_record("course_weeks", "id", $id)) {
8         error("Course week is incorrect");
9     }
11     if (! $course = get_record("course", "id", $week->course)) {
12         error("Could not find the course!");
13     }
15     require_login($course->id);
17     add_to_log("Edit week", $course->id);
18     
19     if (!isteacher($course->id)) {
20         error("Only teachers can edit this!");
21     }
24 /// If data submitted, then process and store.
26     if (match_referer() && isset($HTTP_POST_VARS)) {
28         $timenow = time();
30         if (! set_field("course_weeks", "summary", $summary, "id", $week->id)) {
31             error("Could not update the summary!");
32         }
33         
34         redirect("view.php?id=$course->id");
35         exit;
36     }
38 /// Otherwise fill and print the form.
40     if (! $form ) {
41         $form = $week;
42     }
44     print_header("Edit week $week->week", "Edit week $week->week", "", "form.summary");
46     include("editweek.html");
48     print_footer($course);
50 ?>