]> git.mjollnir.org Git - moodle.git/commitdiff
Renamed from editweek to editsection
authormartin <martin>
Tue, 25 Jun 2002 11:46:12 +0000 (11:46 +0000)
committermartin <martin>
Tue, 25 Jun 2002 11:46:12 +0000 (11:46 +0000)
course/editsection.html [new file with mode: 0644]
course/editsection.php [new file with mode: 0644]

diff --git a/course/editsection.html b/course/editsection.html
new file mode 100644 (file)
index 0000000..cc84841
--- /dev/null
@@ -0,0 +1,12 @@
+<BLOCKQUOTE>
+<FORM name="form" method="post" action="editsection.php">
+<P><B>Summary of <? echo "$sectionname $form->section"; ?></B></P>
+<TEXTAREA NAME=summary COLS=60 ROWS=4 WRAP=virtual><?=$form->summary ?></TEXTAREA>
+<BR><FONT SIZE=1>(Maximum of 255 characters)</FONT>
+<P>
+<INPUT type="hidden" name=id value="<?=$form->id ?>">
+<INPUT type="submit" value="Save all changes">
+<INPUT type="reset" value="Revert">
+</P>
+</FORM>
+</BLOCKQUOTE>
diff --git a/course/editsection.php b/course/editsection.php
new file mode 100644 (file)
index 0000000..b06a24e
--- /dev/null
@@ -0,0 +1,53 @@
+<?PHP // $Id$
+
+    require("../config.php");
+    require("lib.php");
+
+    require_variable($id);    // Week ID
+
+    if (! $section = get_record("course_sections", "id", $id)) {
+        error("Course section is incorrect");
+    }
+
+    if (! $course = get_record("course", "id", $section->course)) {
+        error("Could not find the course!");
+    }
+
+    require_login($course->id);
+    
+    if (!isteacher($course->id)) {
+        error("Only teachers can edit this!");
+    }
+
+
+/// If data submitted, then process and store.
+
+    if (match_referer() && isset($HTTP_POST_VARS)) {
+
+        $timenow = time();
+
+        if (! set_field("course_sections", "summary", $summary, "id", $section->id)) {
+            error("Could not update the summary!");
+        }
+
+        add_to_log($course->id, "course", "editsection", "editsection.php?id=$section->id", "$section->section");
+        
+        redirect("view.php?id=$course->id");
+        exit;
+    }
+
+/// Otherwise fill and print the form.
+
+    if (! $form ) {
+        $form = $section;
+    }
+
+    $sectionname = $SECTION[$course->format];
+
+    print_header("Edit $sectionname $section->section", "Edit $sectionname $section->section", "", "form.summary");
+
+    include("editsection.html");
+
+    print_footer($course);
+
+?>