]> git.mjollnir.org Git - moodle.git/commitdiff
Major changes throughout to change "week" notation to "section" notation.
authormartin <martin>
Tue, 25 Jun 2002 11:49:06 +0000 (11:49 +0000)
committermartin <martin>
Tue, 25 Jun 2002 11:49:06 +0000 (11:49 +0000)
Sections covers "weeks", "topics" and anything else that may come along.
Note, again, some databases have changed esp course_weeks -> course_sections
and several fields called "week" are now "section.  Also course no longer
has an enddate, but instead has a numsections field.

24 files changed:
admin/site.html
admin/site.php
course/edit.html
course/edit.php
course/lib.php
course/mod.php
course/mod_delete.html
course/social.php
course/topics.php
course/user.php
course/view.php
course/weeks.php
index.php
lib/db/mysql.sql
mod/choice/index.php
mod/choice/mod.html
mod/forum/mod.html
mod/journal/index.php
mod/journal/mod.html
mod/journal/user.php
mod/journal/view.php
mod/survey/details.php
mod/survey/index.php
mod/survey/mod.html

index 3b2ad69efd55d47b70e1dfea3f9f30d8f96b9fcf..4cbe232327013a43eaaccd9fec891eac3e3e05b7 100644 (file)
@@ -32,8 +32,8 @@
                             "8" => "8 news items",
                             "9" => "9 news items",
                             "10" => "10 news items");
-           choose_from_menu ($options, "format", "$form->format");
-           formerr($err["format"]);
+           choose_from_menu ($options, "newsitems", "$form->newsitems");
+           formerr($err["newsitems"]);
         ?>
         </td>
 </tr>
index f9301ac84faf628c6b0605f19ab4eeb506ac0690..25beac9e44c9ba8c3bf5ef6b3f6f62f3655cc802 100644 (file)
@@ -49,7 +49,7 @@
         $form = $course;
     } else {
         $form->category = 0;
-        $form->format = 1;
+        $form->newsitems = 1;
     }
 
     print_header("Admin: Setting up site", "Administration: Setting up site",
index 53768d8401a85e72703f3c5f67ed0face71360e8..9b9b76ceb3326fc9ed72a9f52f76f530f53118c0 100644 (file)
         ?>
        </td>
 </tr>
+<tr valign=top>
+    <td><P>News items to show:</td>
+    <td><? 
+       $options = array("0" => "0 news items",
+                        "1" => "1 news item",
+                        "2" => "2 news items",
+                        "3" => "3 news items",
+                        "4" => "4 news items",
+                        "5" => "5 news items",
+                        "6" => "6 news items",
+                        "7" => "7 news items",
+                        "8" => "8 news items",
+                        "9" => "9 news items",
+                        "10" => "10 news items");
+       choose_from_menu ($options, "newsitems", "$form->newsitems");
+       formerr($err["newsitems"]);
+    ?>
+    </td>
+</tr>
+
 <tr valign=top>
        <td><P>Word for teacher:</td>
        <td><input type="text" name="teacher" size=25 value="<? p($form->teacher) ?>">
        ?></td>
 </tr>
 <tr valign=top>
-       <td><P>End date:</td>
+       <td><P>Number of weeks/topics:</td>
        <td><?
-           choose_from_menu ($form->days, "endday", "$form->endday");
-           choose_from_menu ($form->months, "endmonth", "$form->endmonth");
-           choose_from_menu ($form->years, "endyear", "$form->endyear");
-              formerr($err["enddate"]);
+           for ($i=1; $i<=20; $i++) {
+              $sectionmenu[$i] = "$i";
+           }
+           choose_from_menu ($sectionmenu, "numsections", "$form->numsections");
+              formerr($err["numsections"]);
        ?></td>
 </tr>
 <tr>
index 8d90e7eb0fd45ce00397a5cd36bbdf60b82b9a91..97bb32155e939980cfe1ca1375087e61fa71d3cb 100644 (file)
@@ -35,7 +35,6 @@
         $form = (object)$HTTP_POST_VARS;
 
         $form->startdate = mktime(0,0,0,(int)$form->startmonth,(int)$form->startday,(int)$form->startyear);
-        $form->enddate   = mktime(0,0,0,(int)$form->endmonth,(int)$form->endday,(int)$form->endyear);
 
         validate_form($course, $form, $err);
 
                 $form->timecreated = time();
 
                 if ($newid = insert_record("course", $form)) {  // Set up new course
-                    $week->course = $newid;   // Create a default week.
-                    $week->week = 0;
-                    $week->timemodified = time();
-                    $week->id = insert_record("course_weeks", $week);
+                    $section->course = $newid;   // Create a default section.
+                    $section->section = 0;
+                    $section->timemodified = time();
+                    $section->id = insert_record("course_sections", $section);
 
                     add_to_log($newid, "course", "new", "view.php?id=$newid", "");
                            redirect("$CFG->wwwroot/admin/teacher.php?id=$newid", "Changes saved");
         if ($course) {
             $form = $course;
             $ts = getdate($course->startdate);
-            $te = getdate($course->enddate);
         } else {
             $ts = getdate(time() + 3600 * 24);
-            $te = getdate(time() + 3600 * 24 * 7 * 16);
             $form->teacher = "Facilitator";
             $form->student = "Student";
             $form->fullname = "Course Fullname 101";
             $form->shortname = "CF101";
             $form->summary = "Write a concise and interesting paragraph here that explains what this course is about.";
-            $form->format = 0;
+            $form->format = "weeks";
+            $form->numsections = 10;
+            $form->newsitems = 5;
             $form->category = 1;
         }
 
     for ($i=1;$i<=12;$i++) {
         $form->months[$i] = date("F", mktime(0,0,0,$i,1,2000));
     }
-    for ($i=2000;$i<=2005;$i++) {
+    for ($i=2000;$i<=2010;$i++) {
         $form->years[$i] = $i;
     }
 
@@ -155,14 +154,6 @@ function validate_form($course, &$form, &$err) {
     if (empty($form->student))
         $err["student"] = "Must choose something";
 
-    if ($form->startdate > $form->enddate)
-        $err["startdate"] = "Starts after it ends!";
-
-#    if (($form->startdate < time()) && ($course->format <> $form->format)) {
-#        $err["format"] = "Can't change the format now";
-#        $form->format = $course->format;
-#    }
-
     if (! $form->category)
         $err["category"] = "You need to choose a category";
 
index 694725fdbc570cbbe1d33fc40ef4a7caf0908c0a..d09ee3cc760ce09b6a15c2ff3c86be1ed6772a8f 100644 (file)
@@ -3,15 +3,15 @@
 $MAXNEWSDISPLAY = 4;
 
 $FORMATS = array (
-             "1" => "Weekly layout",
-             "2" => "Social layout",
-             "3" => "Topics layout"
+             "weeks" => "Weekly layout",
+             "social" => "Social layout",
+             "topics" => "Topics layout"
            );
 
 $SECTION = array (
-             "1" => "week",
-             "2" => "section",
-             "3" => "topic"
+             "weeks" => "week",
+             "social" => "section",
+             "topics" => "topic"
            );
 
 
index 1e4083cd06504077255603ae2b474051821167cc..cd6f2c30f7fa59c174757a8dec890171e7716408 100644 (file)
                 if (! $mod->instance = add_instance($mod)) {
                     error("Could not add a new instance of $mod->modulename");
                 }
-                // course_modules and course_weeks each contain a reference 
+                // course_modules and course_sections each contain a reference 
                 // to each other, so we have to update one of them twice.
 
                 if (! $mod->coursemodule = add_course_module($mod) ) {
                     error("Could not add a new course module");
                 }
-                if (! $weekid = add_mod_to_week($mod) ) {
-                    error("Could not add the new course module to that week");
+                if (! $sectionid = add_mod_to_section($mod) ) {
+                    error("Could not add the new course module to that section");
                 }
-                if (! set_field("course_modules", "week", $weekid, "id", $mod->coursemodule)) {
-                    error("Could not update the course module with the correct week");
+                if (! set_field("course_modules", "section", $sectionid, "id", $mod->coursemodule)) {
+                    error("Could not update the course module with the correct section");
                 }   
                 add_to_log($mod->course, "course", "add mod", "../mod/$mod->modulename/view.php?id=$mod->coursemodule", "$mod->modulename $mod->instance"); 
                 break;
@@ -54,8 +54,8 @@
                 if (! delete_course_module($mod->coursemodule)) {
                     notify("Could not delete the $mod->modulename (coursemodule)");
                 }
-                if (! delete_mod_from_week($mod->coursemodule, "$mod->week")) {
-                    notify("Could not delete the $mod->modulename from that week");
+                if (! delete_mod_from_section($mod->coursemodule, "$mod->section")) {
+                    notify("Could not delete the $mod->modulename from that section");
                 }
                 add_to_log($mod->course, "course", "delete mod", "view.php?id=$mod->course", "$mod->modulename $mod->instance"); 
                 break;
             error("This module doesn't exist");
         }
 
+        if (! $instance = get_record($module->name, "id", $cm->instance)) {
+            error("The required instance of this module doesn't exist");
+        }
+
         require_login($course->id);
 
         if (!isteacher($course->id)) {
         }
 
         $form->coursemodule = $cm->id;
-        $form->week         = $cm->week;
+        $form->section      = $cm->section;
         $form->course       = $cm->course;
         $form->instance     = $cm->instance;
         $form->modulename   = $module->name;
+        $form->fullmodulename  = strtolower($module->fullname);
+        $form->instancename = $instance->name;
 
         include("mod_delete.html");
 
             error("This module doesn't exist");
         }
 
-        $section = $SECTION[$course->format];
+        $sectionname = $SECTION[$course->format];
 
         if (! $form = get_record($module->name, "id", $cm->instance)) {
             error("The required instance of this module doesn't exist");
         }
         
-        if (! $cw = get_record("course_weeks", "id", $cm->week)) {
-            error("This course week doesn't exist");
+        if (! $cw = get_record("course_sections", "id", $cm->section)) {
+            error("This course section doesn't exist");
         }
 
         $form->coursemodule = $cm->id;
-        $form->week       = $cm->week;     // The week ID
-        $form->course     = $course->id;
-        $form->module     = $module->id;
-        $form->modulename = $module->name;
-        $form->instance   = $cm->instance;
-        $form->mode       = "update";
+        $form->section      = $cm->section;     // The section ID
+        $form->course       = $course->id;
+        $form->module       = $module->id;
+        $form->modulename   = $module->name;
+        $form->instance     = $cm->instance;
+        $form->mode         = "update";
 
-        $pageheading = "Updating a ".strtolower($module->fullname)." in $section $cw->week";
+        $pageheading = "Updating a ".strtolower($module->fullname)." in $sectionname $cw->section";
 
         
     } else if (isset($add)) {
         }
 
         require_variable($id);
-        require_variable($week);
+        require_variable($section);
 
         if (! $course = get_record("course", "id", $id)) {
             error("This course doesn't exist");
         }
 
-        $section = $SECTION[$course->format];
+        $sectionname = $SECTION[$course->format];
 
         if (! $module = get_record("modules", "name", $add)) {
             error("This module type doesn't exist");
         }
 
-        $form->week       = $week;         // The week number itself
+        $form->section    = $section;         // The section number itself
         $form->course     = $course->id;
         $form->module     = $module->id;
         $form->modulename = $module->name;
         $form->instance   = $cm->instance;
         $form->mode       = "add";
 
-        if ($form->week) {
-            $pageheading = "Adding a new ".strtolower($module->fullname)." to $section $form->week";
+        if ($form->section) {
+            $pageheading = "Adding a new ".strtolower($module->fullname)." to $sectionname $form->section";
         } else {
             $pageheading = "Adding a new ".strtolower($module->fullname);
         }
@@ -236,7 +242,7 @@ function add_course_module($mod) {
                                 SET course   = '$mod->course', 
                                     module   = '$mod->module',
                                     instance = '$mod->instance',
-                                    week     = '$mod->week',
+                                    section     = '$mod->section',
                                     added    = '$timenow' ")) {
         return 0;
     }
@@ -251,35 +257,35 @@ function add_course_module($mod) {
 
 }
 
-function add_mod_to_week($mod) {
-// Returns the course_weeks ID where the mod is inserted
+function add_mod_to_section($mod) {
+// Returns the course_sections ID where the mod is inserted
     GLOBAL $db;
 
-    if ($cw = get_record_sql("SELECT * FROM course_week
-                              WHERE course = '$mod->course' AND week = '$mod->week'") ) {
+    if ($cw = get_record_sql("SELECT * FROM course_section
+                              WHERE course = '$mod->course' AND section = '$mod->section'") ) {
 
         if ($cw->sequence) {
             $newsequence = "$cw->sequence,$mod->coursemodule";
         } else {
             $newsequence = "$mod->coursemodule";
         }
-        if (!$rs = $db->Execute("UPDATE course_weeks SET sequence = '$newsequence' WHERE id = '$cw->id'")) {
+        if (!$rs = $db->Execute("UPDATE course_sections SET sequence = '$newsequence' WHERE id = '$cw->id'")) {
             return 0;
         } else {
-            return $cw->id;     // Return course_weeks ID that was used.
+            return $cw->id;     // Return course_sections ID that was used.
         }
        
     } else {  // Insert a new record
-        if (!$rs = $db->Execute("INSERT into course_week
+        if (!$rs = $db->Execute("INSERT into course_section
                                  SET course   = '$mod->course', 
-                                     week     = '$mod->week',
+                                     section     = '$mod->section',
                                      summary  = '',
                                      sequence = '$mod->coursemodule' ")) {
             return 0;
         }
         // Get it out again - this is the most compatible way to determine the ID
-        if ($rs = $db->Execute("SELECT id FROM course_week
-                                WHERE course = '$mod->course' AND week = '$mod->week'")) {
+        if ($rs = $db->Execute("SELECT id FROM course_section
+                                WHERE course = '$mod->course' AND section = '$mod->section'")) {
             return $rs->fields[0];
         } else {
             return 0;
@@ -291,17 +297,17 @@ function delete_course_module($mod) {
     return set_field("course_modules", "deleted", 1, "id", $mod);
 }
 
-function delete_mod_from_week($mod, $week) {
+function delete_mod_from_section($mod, $section) {
     GLOBAL $db;
 
-    if ($cw = get_record("course_weeks", "id", "$week") ) {
+    if ($cw = get_record("course_sections", "id", "$section") ) {
 
         $modarray = explode(",", $cw->sequence);
 
         if ($key = array_keys ($modarray, $mod)) {
             array_splice($modarray, $key[0], 1);
             $newsequence = implode(",", $modarray);
-            return set_field("course_weeks", "sequence", $newsequence, "id", $cw->id);
+            return set_field("course_sections", "sequence", $newsequence, "id", $cw->id);
         } else {
             return false;
         }
@@ -323,18 +329,18 @@ function move_module($id, $move) {
         error("This course module doesn't exist");
     }
     
-    if (! $thisweek = get_record("course_weeks", "id", $cm->week)) {
-        error("This course week doesn't exist");
+    if (! $thissection = get_record("course_sections", "id", $cm->section)) {
+        error("This course section doesn't exist");
     }
 
-    $mods = explode(",", $thisweek->sequence);
+    $mods = explode(",", $thissection->sequence);
 
     $len = count($mods);
     $pos = array_keys($mods, $cm->id);
     $thepos = $pos[0];
 
     if ($len == 0 || count($pos) == 0 ) {
-        error("Very strange. Could not find the required module in this week.");
+        error("Very strange. Could not find the required module in this section.");
     }
 
     if ($len == 1) {
@@ -348,47 +354,47 @@ function move_module($id, $move) {
     if ($move < 0) {    // Moving the module up
 
         if ($first) {
-            if ($thisweek->week == 1) {  // First week, do nothing
+            if ($thissection->section == 1) {  // First section, do nothing
                 return true;
-            } else {               // Push onto end of previous week
-                $prevweeknumber = $thisweek->week - 1;
-                if (! $prevweek = get_record_sql("SELECT * FROM course_week
-                                                  WHERE course='$thisweek->course'
-                                                  AND week='$prevweeknumber' ")) {
-                    error("Previous week ($prevweek->id) doesn't exist");
+            } else {               // Push onto end of previous section
+                $prevsectionnumber = $thissection->section - 1;
+                if (! $prevsection = get_record_sql("SELECT * FROM course_section
+                                                  WHERE course='$thissection->course'
+                                                  AND section='$prevsectionnumber' ")) {
+                    error("Previous section ($prevsection->id) doesn't exist");
                 }
 
-                if ($prevweek->sequence) {
-                    $newsequence = "$prevweek->sequence,$cm->id";
+                if ($prevsection->sequence) {
+                    $newsequence = "$prevsection->sequence,$cm->id";
                 } else {
                     $newsequence = "$cm->id";
                 }
 
-                if (! set_field("course_weeks", "sequence", $newsequence, "id", $prevweek->id)) {
-                    error("Previous week could not be updated");
+                if (! set_field("course_sections", "sequence", $newsequence, "id", $prevsection->id)) {
+                    error("Previous section could not be updated");
                 }
 
-                if (! set_field("course_modules", "week", $prevweek->id, "id", $cm->id)) {
+                if (! set_field("course_modules", "section", $prevsection->id, "id", $cm->id)) {
                     error("Module could not be updated");
                 }
 
                 array_splice($mods, 0, 1);
                 $newsequence = implode(",", $mods);
-                if (! set_field("course_weeks", "sequence", $newsequence, "id", $thisweek->id)) {
+                if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
                     error("Module could not be updated");
                 }
 
                 return true;
 
             }
-        } else {        // move up within this week
+        } else {        // move up within this section
             $swap = $mods[$thepos-1];
             $mods[$thepos-1] = $mods[$thepos];
             $mods[$thepos] = $swap;
             
             $newsequence = implode(",", $mods);
-            if (! set_field("course_weeks", "sequence", $newsequence, "id", $thisweek->id)) {
-                error("This week could not be updated");
+            if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
+                error("This section could not be updated");
             }
             return true;
         }
@@ -396,44 +402,44 @@ function move_module($id, $move) {
     } else {            // Moving the module down
 
         if ($last) {
-            $nextweeknumber = $thisweek->week + 1;
-            if ($nextweek = get_record_sql("SELECT * FROM course_week
-                                            WHERE course='$thisweek->course'
-                                            AND week='$nextweeknumber' ")) {
+            $nextsectionnumber = $thissection->section + 1;
+            if ($nextsection = get_record_sql("SELECT * FROM course_section
+                                            WHERE course='$thissection->course'
+                                            AND section='$nextsectionnumber' ")) {
 
-                if ($nextweek->sequence) {
-                    $newsequence = "$cm->id,$nextweek->sequence";
+                if ($nextsection->sequence) {
+                    $newsequence = "$cm->id,$nextsection->sequence";
                 } else {
                     $newsequence = "$cm->id";
                 }
 
-                if (! set_field("course_weeks", "sequence", $newsequence, "id", $nextweek->id)) {
-                    error("Next week could not be updated");
+                if (! set_field("course_sections", "sequence", $newsequence, "id", $nextsection->id)) {
+                    error("Next section could not be updated");
                 }
 
-                if (! set_field("course_modules", "week", $nextweek->id, "id", $cm->id)) {
+                if (! set_field("course_modules", "section", $nextsection->id, "id", $cm->id)) {
                     error("Module could not be updated");
                 }
 
                 array_splice($mods, $thepos, 1);
                 $newsequence = implode(",", $mods);
-                if (! set_field("course_weeks", "sequence", $newsequence, "id", $thisweek->id)) {
-                    error("This week could not be updated");
+                if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
+                    error("This section could not be updated");
                 }
                 return true;
 
-            } else {        // There is no next week, so just return
+            } else {        // There is no next section, so just return
                 return true;
 
             }
-        } else {      // move down within this week
+        } else {      // move down within this section
             $swap = $mods[$thepos+1];
             $mods[$thepos+1] = $mods[$thepos];
             $mods[$thepos] = $swap;
             
             $newsequence = implode(",", $mods);
-            if (! set_field("course_weeks", "sequence", $newsequence, "id", $thisweek->id)) {
-                error("This week could not be updated");
+            if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
+                error("This section could not be updated");
             }
             return true;
         }
index c7ca08aa92685cdc870d29a20936aad3a13326e1..3512f44fdae28cec2663243043bcd92778e6528c 100644 (file)
@@ -2,9 +2,9 @@
 
 <CENTER>
 <FORM name="form" method="post" action="<?=$ME ?>">
-<? print_heading("Are you absolutely sure you want to delete the $form->modulename ?") ?>
+<? print_heading("Are you absolutely sure you want to delete the $form->fullmodulename '$form->instancename' ?") ?>
 <input type="hidden" name=mode         value="delete">
-<input type="hidden" name=week         value="<? echo $form->week; ?>">
+<input type="hidden" name=section      value="<? echo $form->section; ?>">
 <input type="hidden" name=course       value="<? p($form->course) ?>">
 <input type="hidden" name=coursemodule value="<? p($form->coursemodule) ?>">
 <input type="hidden" name=modulename   value="<? p($form->modulename) ?>">
index 6ed869b0feee272650e0a4b9ba10454e49d2fac9..b75d58b453cda1980d9d4d6be86d8036f32d32b1 100644 (file)
@@ -34,7 +34,7 @@
           }
       }
       if ($USER->editing) {
-          $readingdata[] = "<A HREF=\"mod.php?id=$course->id&week=0&add=reading\">Add reading...</A>";
+          $readingdata[] = "<A HREF=\"mod.php?id=$course->id&section=0&add=reading\">Add reading...</A>";
           $readingicon[] = "&nbsp;";
       }
       print_side_block("", $readingdata, "", $readingicon);
index 2839fa25aa1ed4ce27cce5898548cef57c6278d9..912bcdabbd728f05c5358025a053355ef19029e0 100644 (file)
@@ -8,17 +8,17 @@
 
     include("../mod/forum/lib.php");
 
-    if (! $rawweeks = get_records("course_weeks", "course", $course->id) ) {
-        $week->course = $course->id;   // Create a default week.
-        $week->week = 0;
-        $week->id = insert_record("course_weeks", $week);
-        if (! $rawweeks = get_records("course_weeks", "course", $course->id) ) {
-            error("Error finding or creating week structures for this course");
+    if (! $rawsections = get_records("course_sections", "course", $course->id) ) {
+        $section->course = $course->id;   // Create a default section.
+        $section->section = 0;
+        $section->id = insert_record("course_sections", $section);
+        if (! $rawsections = get_records("course_sections", "course", $course->id) ) {
+            error("Error finding or creating section structures for this course");
         }
     }
     
-    foreach($rawweeks as $cw) {  //Index the weeks
-        $weeks[$cw->week] = $cw;
+    foreach($rawsections as $cw) {  //Index the sections
+        $sections[$cw->section] = $cw;
     }
 
     if (isset($topic)) {
 
     print_simple_box("Topic Outline", $align="CENTER", $width="100%", $color="$THEME->cellheading");
     
-    // Everything below uses "week" terminology - each "week" is a topic.
+    // Everything below uses "section" terminology - each "section" is a topic.
 
-    // Now all the weekly modules
+    // Now all the sectionly modules
     $timenow = time();
-    $weekdate = $course->startdate;    // this should be 0:00 Monday of that week
-    $week = 1;
-    $weekofseconds = 604800;
+    $section = 1;
 
     echo "<TABLE BORDER=0 CELLPADDING=8 CELLSPACING=0 WIDTH=100%>";
-    while ($weekdate < $course->enddate) {
-
-        $nextweekdate = $weekdate + ($weekofseconds);
+    while ($section <= $course->numsections) {
 
         if (isset($USER->topic)) {         // Just display a single topic
-            if ($USER->topic != $week) { 
-                $week++;
-                $weekdate = $nextweekdate;
+            if ($USER->topic != $section) { 
+                $section++;
                 continue;
             }
         }
 
-        $currenttopic = ($course->marker == $week);
+        $currenttopic = ($course->marker == $section);
 
         if ($currenttopic) {
             $highlightcolor = $THEME->cellheading2;
 
         echo "<TR>";
         echo "<TD NOWRAP BGCOLOR=\"$highlightcolor\" VALIGN=top WIDTH=20>";
-        echo "<P ALIGN=CENTER><FONT SIZE=3><B>$week</B></FONT></P>";
+        echo "<P ALIGN=CENTER><FONT SIZE=3><B>$section</B></FONT></P>";
         echo "</TD>";
 
         echo "<TD VALIGN=top BGCOLOR=\"$THEME->cellcontent\" WIDTH=\"100%\">";
 
-        if (! $thisweek = $weeks[$week]) {
-            $thisweek->course = $course->id;   // Create a new week structure
-            $thisweek->week = $week;
-            $thisweek->summary = "";
-            $thisweek->id = insert_record("course_weeks", $thisweek);
+        if (! $thissection = $sections[$section]) {
+            $thissection->course = $course->id;   // Create a new section structure
+            $thissection->section = $section;
+            $thissection->summary = "";
+            $thissection->id = insert_record("course_sections", $thissection);
         }
 
         if ($USER->editing) {
-            $thisweek->summary .= "&nbsp;<A HREF=editweek.php?id=$thisweek->id><IMG SRC=\"../pix/t/edit.gif\" BORDER=0 ALT=\"Edit summary\"></A></P>";
+            $thissection->summary .= "&nbsp;<A HREF=editsection.php?id=$thissection->id><IMG SRC=\"../pix/t/edit.gif\" BORDER=0 ALT=\"Edit summary\"></A></P>";
         }
 
-        echo text_to_html($thisweek->summary);
+        echo text_to_html($thissection->summary);
 
         echo "<P>";
-        if ($thisweek->sequence) {
+        if ($thissection->sequence) {
 
-            $thisweekmods = explode(",", $thisweek->sequence);
+            $thissectionmods = explode(",", $thissection->sequence);
 
-            foreach ($thisweekmods as $modnumber) {
+            foreach ($thissectionmods as $modnumber) {
                 $mod = $mods[$modnumber];
                 $instancename = get_field("$mod->modname", "name", "id", "$mod->instance");
                 echo "<IMG SRC=\"../mod/$mod->modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">";
 
         if ($USER->editing) {
             echo "<DIV ALIGN=right>";
-            popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&week=$week&add=", 
-                        $modtypes, "week$week", "", "Add...");
+            popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$section&add=", 
+                        $modtypes, "section$section", "", "Add...");
             echo "</DIV>";
         }
 
         echo "<TD NOWRAP BGCOLOR=\"$highlightcolor\" VALIGN=top ALIGN=CENTER WIDTH=10>";
         echo "<FONT SIZE=1>";
         if (isset($USER->topic)) {
-            echo "<A HREF=\"view.php?id=$course->id&topic=all\" TITLE=\"Show all topics\"><IMG SRC=../pix/i/allweeks.gif BORDER=0></A><BR><BR>";
+            echo "<A HREF=\"view.php?id=$course->id&topic=all\" TITLE=\"Show all topics\"><IMG SRC=../pix/i/all.gif BORDER=0></A><BR><BR>";
         } else {
-            echo "<A HREF=\"view.php?id=$course->id&topic=$week\" TITLE=\"Show only topic $week\"><IMG SRC=../pix/i/oneweek.gif BORDER=0></A><BR><BR>";
+            echo "<A HREF=\"view.php?id=$course->id&topic=$section\" TITLE=\"Show only topic $section\"><IMG SRC=../pix/i/one.gif BORDER=0></A><BR><BR>";
         }
-        if ($USER->editing and $course->marker != $week) {
-            echo "<A HREF=\"view.php?id=$course->id&marker=$week\" TITLE=\"Mark this topic as the current topic\"><IMG SRC=../pix/i/marker.gif BORDER=0></A><BR><BR>";
+        if ($USER->editing and $course->marker != $section) {
+            echo "<A HREF=\"view.php?id=$course->id&marker=$section\" TITLE=\"Mark this topic as the current topic\"><IMG SRC=../pix/i/marker.gif BORDER=0></A><BR><BR>";
         }
         echo "</TD>";
         echo "</TR>";
         echo "<TR><TD COLSPAN=3><IMG SRC=\"../pix/spacer.gif\" WIDTH=1 HEIGHT=1></TD></TR>";
 
-        $week++;
-        $weekdate = $nextweekdate;
+        $section++;
     }
     echo "</TABLE>";
     
         print_simple_box("Latest News", $align="CENTER", $width="100%", $color="$THEME->cellheading");
         print_simple_box_start("CENTER", "100%", "#FFFFFF", 3, 0);
         echo "<FONT SIZE=1>";
-        print_forum_latest_topics($news->id, 5, "minimal", "DESC", false);
+        print_forum_latest_topics($news->id, $course->newsitems, "minimal", "DESC", false);
         echo "</FONT>";
         print_simple_box_end();
     }
index 08864183daf58b3e7ce39eace535b11f2b0e8e62..86f89c77f62b9bfc2fd547035f93b084680d328a 100644 (file)
 
 
     // Replace all the following with a better log-based method.
-    if ($course->format == 1) {
-        if ($weeks = get_records_sql("SELECT * FROM course_weeks WHERE course = '$course->id' ORDER BY week")) {
-            foreach ($weeks as $www) {
-                $week = (object)$www;
-                echo "<H2>Week $week->week</H2>";
-                if ($week->sequence) {
-                    $weekmods = explode(",", $week->sequence);
-                    foreach ($weekmods as $weekmod) {
-                        $mod = $mods[$weekmod];
+    if ($course->format == "weeks") {
+        if ($sections = get_records_sql("SELECT * FROM course_sections WHERE course = '$course->id' ORDER BY section")) {
+            foreach ($sections as $www) {
+                $section = (object)$www;
+                echo "<H2>Week $section->section</H2>";
+                if ($section->sequence) {
+                    $sectionmods = explode(",", $section->sequence);
+                    foreach ($sectionmods as $sectionmod) {
+                        $mod = $mods[$sectionmod];
                         $instance = get_record("$mod->modname", "id", "$mod->instance");
                         $userfile = "$CFG->dirroot/mod/$mod->name/user.php";
                         include($userfile);
index cdd23be2ebc6695263d0ff039b3843feb81ba965..b21293dc10fa30c8423141591d7834621a1269c1 100644 (file)
     }
 
     switch ($course->format) {
-        case 1:
+        case "weeks":
             include("weeks.php");
             break;
-        case 2:
+        case "social":
             include("social.php");
             break;
-        case 3:
+        case "topics":
             include("topics.php");
             break;
         default:
index 3e7e5be9708a374b5475cfe662272e18002fa3e1..f6669819c398d00b9a4c009e443fc2d88b0f98e7 100644 (file)
@@ -4,24 +4,24 @@
 
     include("../mod/forum/lib.php");
 
-    if (! $rawweeks = get_records("course_weeks", "course", $course->id) ) {
-        $week->course = $course->id;   // Create a default week.
-        $week->week = 0;
-        $week->id = insert_record("course_weeks", $week);
-        if (! $rawweeks = get_records("course_weeks", "course", $course->id) ) {
-            error("Error finding or creating week structures for this course");
+    if (! $rawsections = get_records("course_sections", "course", $course->id) ) {
+        $section->course = $course->id;   // Create a default section.
+        $section->section = 0;
+        $section->id = insert_record("course_sections", $section);
+        if (! $rawsections = get_records("course_sections", "course", $course->id) ) {
+            error("Error finding or creating section structures for this course");
         }
     }
     
-    foreach($rawweeks as $cw) {  //Index the weeks
-        $weeks[$cw->week] = $cw;
+    foreach($rawsections as $cw) {  //Index the sections
+        $sections[$cw->section] = $cw;
     }
 
-    if (isset($week)) {
-        if ($week == "all") {
-            unset($USER->week);
+    if (isset($section)) {
+        if ($section == "all") {
+            unset($USER->section);
         } else {
-            $USER->week = $week;
+            $USER->section = $section;
         }
     }
 
     $weekdate = $course->startdate;    // this should be 0:00 Monday of that week
     $week = 1;
     $weekofseconds = 604800;
+    $course->enddate = $course->startdate + ($weekofseconds * $course->numsections);
 
     echo "<TABLE BORDER=0 CELLPADDING=8 CELLSPACING=0 WIDTH=100%>";
-    while ($weekdate < $course->enddate) {
+    while ($weekdate <= $course->enddate) {
 
         $nextweekdate = $weekdate + ($weekofseconds);
 
         echo "<TD VALIGN=top BGCOLOR=\"$THEME->cellcontent\" WIDTH=\"100%\">";
         echo "<P><FONT SIZE=3 COLOR=\"$THEME->cellheading2\">$weekday - $endweekday</FONT></P>";
 
-        if (! $thisweek = $weeks[$week]) {
+        if (! $thisweek = $sections[$week]) {
             $thisweek->course = $course->id;   // Create a new week structure
             $thisweek->week = $week;
             $thisweek->summary = "";
-            $thisweek->id = insert_record("course_weeks", $thisweek);
+            $thisweek->id = insert_record("course_sections", $thisweek);
         }
 
         if ($USER->editing) {
 
         if ($USER->editing) {
             echo "<DIV ALIGN=right>";
-            popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&week=$week&add=", 
-                        $modtypes, "week$week", "", "Add...");
+            popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$week&add=", 
+                        $modtypes, "section$week", "", "Add...");
             echo "</DIV>";
         }
 
         echo "<TD NOWRAP BGCOLOR=\"$highlightcolor\" VALIGN=top ALIGN=CENTER WIDTH=10>";
         echo "<FONT SIZE=1>";
         if (isset($USER->week)) {
-            echo "<A HREF=\"view.php?id=$course->id&week=all\" TITLE=\"Show all weeks\"><IMG SRC=../pix/i/allweeks.gif BORDER=0></A></FONT>";
+            echo "<A HREF=\"view.php?id=$course->id&week=all\" TITLE=\"Show all weeks\"><IMG SRC=../pix/i/all.gif BORDER=0></A></FONT>";
         } else {
-            echo "<A HREF=\"view.php?id=$course->id&week=$week\" TITLE=\"Show only week $week\"><IMG SRC=../pix/i/oneweek.gif BORDER=0></A></FONT>";
+            echo "<A HREF=\"view.php?id=$course->id&week=$week\" TITLE=\"Show only week $week\"><IMG SRC=../pix/i/one.gif BORDER=0></A></FONT>";
         }
         echo "</TD>";
         echo "</TR>";
         print_simple_box("Latest News", $align="CENTER", $width="100%", $color="$THEME->cellheading");
         print_simple_box_start("CENTER", "100%", "#FFFFFF", 3, 0);
         echo "<FONT SIZE=1>";
-        print_forum_latest_topics($news->id, 5, "minimal", "DESC", false);
+        print_forum_latest_topics($news->id, $course->newsitems, "minimal", "DESC", false);
         echo "</FONT>";
         print_simple_box_end();
     }
index 68ea276c50335e776639b5299671ee824a9388e2..4cfd8801b398e83312a0dd6318cc62dcfb87a98b 100644 (file)
--- a/index.php
+++ b/index.php
     <TD VALIGN="TOP" NOWRAP>
       <? $readings = list_all_readings();
       
-         if ($site->format > 0 or $readings or $USER->editing) {
+         if ($site->newsitems > 0 or $readings or $USER->editing) {
       
              print_simple_box("Main Menu", $align="CENTER", $width="100%", $color="$THEME->cellheading");
 
-             if ($site->format > 0 ) {
+             if ($site->newsitems > 0 ) {
                  echo "<LI><A TITLE=\"Available courses on this server\" HREF=\"course/\"><B>Courses</B></A><BR></LI>";
              } 
 
@@ -60,7 +60,7 @@
     </TD>
 
     <TD WIDTH="70%" VALIGN="TOP">
-      <? if ($site->format == 0 ) {
+      <? if ($site->newsitems == 0 ) {
              print_simple_box("Available Courses", $align="CENTER", $width="100%", $color="$THEME->cellheading");
              echo "<IMG HEIGHT=8 SRC=\"pix/spacer.gif\" ALT=\"\"><BR>";
              print_all_courses();
@@ -87,7 +87,7 @@
              }
              print_simple_box("$headertext", $align="CENTER", $width="100%", $color="$THEME->cellheading");
              echo "<IMG HEIGHT=8 SRC=\"pix/spacer.gif\" ALT=\"\"><BR>";
-             print_forum_latest_topics($newsforum->id, $site->format);
+             print_forum_latest_topics($newsforum->id, $site->newsitems);
          }
       ?>
 
index 0f26fec676bffb7bf1f9dececcd992d6ca2d7e06..6bd3e770067004a2bba9a7ae1d9c678a3c9c9e8c 100644 (file)
@@ -4,7 +4,7 @@
 # http://www.phpmyadmin.net/ (download page)
 #
 # Host: localhost
-# Generation Time: May 29, 2002 at 05:19 PM
+# Generation Time: Jun 25, 2002 at 05:04 PM
 # Server version: 3.23.49
 # PHP Version: 4.1.2
 # Database : `moodle`
@@ -21,12 +21,13 @@ CREATE TABLE `course` (
   `fullname` varchar(254) NOT NULL default '',
   `shortname` varchar(15) NOT NULL default '',
   `summary` text NOT NULL,
-  `format` tinyint(4) NOT NULL default '1',
+  `format` enum('weeks','social','topics') NOT NULL default 'weeks',
+  `newsitems` smallint(5) unsigned NOT NULL default '1',
   `teacher` varchar(100) NOT NULL default 'Teacher',
   `student` varchar(100) NOT NULL default 'Student',
   `guest` tinyint(1) unsigned NOT NULL default '0',
   `startdate` int(10) unsigned NOT NULL default '0',
-  `enddate` int(10) unsigned NOT NULL default '0',
+  `numsections` int(10) unsigned NOT NULL default '0',
   `marker` int(10) unsigned NOT NULL default '0',
   `timecreated` int(10) unsigned NOT NULL default '0',
   `timemodified` int(10) unsigned NOT NULL default '0',
@@ -38,11 +39,11 @@ CREATE TABLE `course` (
 # Table structure for table `course_categories`
 #
 
-CREATE TABLE course_categories (
-  id int(10) unsigned NOT NULL auto_increment,
-  name varchar(255) NOT NULL default '',
-  PRIMARY KEY  (id),
-  UNIQUE KEY id (id)
+CREATE TABLE `course_categories` (
+  `id` int(10) unsigned NOT NULL auto_increment,
+  `name` varchar(255) NOT NULL default '',
+  PRIMARY KEY  (`id`),
+  UNIQUE KEY `id` (`id`)
 ) TYPE=MyISAM COMMENT='Course categories';
 # --------------------------------------------------------
 
@@ -50,31 +51,31 @@ CREATE TABLE course_categories (
 # Table structure for table `course_modules`
 #
 
-CREATE TABLE course_modules (
-  id int(10) unsigned NOT NULL auto_increment,
-  course int(10) unsigned NOT NULL default '0',
-  module int(10) unsigned NOT NULL default '0',
-  instance int(10) unsigned NOT NULL default '0',
-  week int(10) unsigned NOT NULL default '0',
-  added int(10) unsigned NOT NULL default '0',
-  deleted tinyint(1) unsigned NOT NULL default '0',
-  score tinyint(4) NOT NULL default '0',
-  PRIMARY KEY  (id),
-  UNIQUE KEY id (id)
+CREATE TABLE `course_modules` (
+  `id` int(10) unsigned NOT NULL auto_increment,
+  `course` int(10) unsigned NOT NULL default '0',
+  `module` int(10) unsigned NOT NULL default '0',
+  `instance` int(10) unsigned NOT NULL default '0',
+  `section` int(10) unsigned NOT NULL default '0',
+  `added` int(10) unsigned NOT NULL default '0',
+  `deleted` tinyint(1) unsigned NOT NULL default '0',
+  `score` tinyint(4) NOT NULL default '0',
+  PRIMARY KEY  (`id`),
+  UNIQUE KEY `id` (`id`)
 ) TYPE=MyISAM;
 # --------------------------------------------------------
 
 #
-# Table structure for table `course_weeks`
+# Table structure for table `course_sections`
 #
 
-CREATE TABLE course_weeks (
-  id int(10) unsigned NOT NULL auto_increment,
-  course int(10) unsigned NOT NULL default '0',
-  week int(10) unsigned NOT NULL default '0',
-  summary varchar(255) NOT NULL default '',
-  sequence varchar(255) NOT NULL default '',
-  PRIMARY KEY  (id)
+CREATE TABLE `course_sections` (
+  `id` int(10) unsigned NOT NULL auto_increment,
+  `course` int(10) unsigned NOT NULL default '0',
+  `section` int(10) unsigned NOT NULL default '0',
+  `summary` varchar(255) NOT NULL default '',
+  `sequence` varchar(255) NOT NULL default '',
+  PRIMARY KEY  (`id`)
 ) TYPE=MyISAM;
 # --------------------------------------------------------
 
@@ -82,17 +83,17 @@ CREATE TABLE course_weeks (
 # Table structure for table `log`
 #
 
-CREATE TABLE log (
-  id int(10) unsigned NOT NULL auto_increment,
-  time int(10) unsigned NOT NULL default '0',
-  user int(10) unsigned NOT NULL default '0',
-  ip varchar(15) NOT NULL default '',
-  course int(10) unsigned NOT NULL default '0',
-  module varchar(10) NOT NULL default '',
-  action varchar(15) NOT NULL default '',
-  url varchar(100) NOT NULL default '',
-  info varchar(255) NOT NULL default '',
-  PRIMARY KEY  (id)
+CREATE TABLE `log` (
+  `id` int(10) unsigned NOT NULL auto_increment,
+  `time` int(10) unsigned NOT NULL default '0',
+  `user` int(10) unsigned NOT NULL default '0',
+  `ip` varchar(15) NOT NULL default '',
+  `course` int(10) unsigned NOT NULL default '0',
+  `module` varchar(10) NOT NULL default '',
+  `action` varchar(15) NOT NULL default '',
+  `url` varchar(100) NOT NULL default '',
+  `info` varchar(255) NOT NULL default '',
+  PRIMARY KEY  (`id`)
 ) TYPE=MyISAM COMMENT='Every action is logged as far as possible.';
 # --------------------------------------------------------
 
@@ -112,16 +113,16 @@ CREATE TABLE `log_display` (
 # Table structure for table `modules`
 #
 
-CREATE TABLE modules (
-  id int(10) unsigned NOT NULL auto_increment,
-  name varchar(20) NOT NULL default '',
-  fullname varchar(255) NOT NULL default '',
-  version int(10) NOT NULL default '0',
-  cron int(10) unsigned NOT NULL default '0',
-  lastcron int(10) unsigned NOT NULL default '0',
-  search varchar(255) NOT NULL default '',
-  PRIMARY KEY  (id),
-  UNIQUE KEY id (id)
+CREATE TABLE `modules` (
+  `id` int(10) unsigned NOT NULL auto_increment,
+  `name` varchar(20) NOT NULL default '',
+  `fullname` varchar(255) NOT NULL default '',
+  `version` int(10) NOT NULL default '0',
+  `cron` int(10) unsigned NOT NULL default '0',
+  `lastcron` int(10) unsigned NOT NULL default '0',
+  `search` varchar(255) NOT NULL default '',
+  PRIMARY KEY  (`id`),
+  UNIQUE KEY `id` (`id`)
 ) TYPE=MyISAM;
 # --------------------------------------------------------
 
@@ -129,38 +130,38 @@ CREATE TABLE modules (
 # Table structure for table `user`
 #
 
-CREATE TABLE user (
-  id int(10) unsigned NOT NULL auto_increment,
-  confirmed tinyint(1) NOT NULL default '0',
-  username varchar(100) NOT NULL default '',
-  password varchar(32) NOT NULL default '',
-  idnumber varchar(12) default NULL,
-  firstname varchar(20) NOT NULL default '',
-  lastname varchar(20) NOT NULL default '',
-  email varchar(100) NOT NULL default '',
-  icq varchar(15) default NULL,
-  phone1 varchar(20) default NULL,
-  phone2 varchar(20) default NULL,
-  institution varchar(40) default NULL,
-  department varchar(30) default NULL,
-  address varchar(70) default NULL,
-  city varchar(20) default NULL,
-  country char(2) default NULL,
-  timezone float NOT NULL default '99',
-  firstaccess int(10) unsigned NOT NULL default '0',
-  lastaccess int(10) unsigned NOT NULL default '0',
-  lastlogin int(10) unsigned NOT NULL default '0',
-  currentlogin int(10) unsigned NOT NULL default '0',
-  lastIP varchar(15) default NULL,
-  personality varchar(5) default NULL,
-  picture tinyint(1) default NULL,
-  url varchar(255) default NULL,
-  description text,
-  mailformat tinyint(1) unsigned NOT NULL default '1',
-  timemodified int(10) unsigned NOT NULL default '0',
-  PRIMARY KEY  (id),
-  UNIQUE KEY username (username),
-  UNIQUE KEY id (id)
+CREATE TABLE `user` (
+  `id` int(10) unsigned NOT NULL auto_increment,
+  `confirmed` tinyint(1) NOT NULL default '0',
+  `username` varchar(100) NOT NULL default '',
+  `password` varchar(32) NOT NULL default '',
+  `idnumber` varchar(12) default NULL,
+  `firstname` varchar(20) NOT NULL default '',
+  `lastname` varchar(20) NOT NULL default '',
+  `email` varchar(100) NOT NULL default '',
+  `icq` varchar(15) default NULL,
+  `phone1` varchar(20) default NULL,
+  `phone2` varchar(20) default NULL,
+  `institution` varchar(40) default NULL,
+  `department` varchar(30) default NULL,
+  `address` varchar(70) default NULL,
+  `city` varchar(20) default NULL,
+  `country` char(2) default NULL,
+  `timezone` float NOT NULL default '99',
+  `firstaccess` int(10) unsigned NOT NULL default '0',
+  `lastaccess` int(10) unsigned NOT NULL default '0',
+  `lastlogin` int(10) unsigned NOT NULL default '0',
+  `currentlogin` int(10) unsigned NOT NULL default '0',
+  `lastIP` varchar(15) default NULL,
+  `personality` varchar(5) default NULL,
+  `picture` tinyint(1) default NULL,
+  `url` varchar(255) default NULL,
+  `description` text,
+  `mailformat` tinyint(1) unsigned NOT NULL default '1',
+  `timemodified` int(10) unsigned NOT NULL default '0',
+  PRIMARY KEY  (`id`),
+  UNIQUE KEY `id` (`id`),
+  UNIQUE KEY `username` (`username`)
 ) TYPE=MyISAM COMMENT='One record for each person';
 # --------------------------------------------------------
 
@@ -180,15 +181,15 @@ CREATE TABLE `user_admins` (
 # Table structure for table `user_students`
 #
 
-CREATE TABLE user_students (
-  id int(10) unsigned NOT NULL auto_increment,
-  user int(10) unsigned NOT NULL default '0',
-  course int(10) unsigned NOT NULL default '0',
-  start int(10) unsigned NOT NULL default '0',
-  end int(10) unsigned NOT NULL default '0',
-  time int(10) unsigned NOT NULL default '0',
-  PRIMARY KEY  (id),
-  UNIQUE KEY id (id)
+CREATE TABLE `user_students` (
+  `id` int(10) unsigned NOT NULL auto_increment,
+  `user` int(10) unsigned NOT NULL default '0',
+  `course` int(10) unsigned NOT NULL default '0',
+  `start` int(10) unsigned NOT NULL default '0',
+  `end` int(10) unsigned NOT NULL default '0',
+  `time` int(10) unsigned NOT NULL default '0',
+  PRIMARY KEY  (`id`),
+  UNIQUE KEY `id` (`id`)
 ) TYPE=MyISAM;
 # --------------------------------------------------------
 
@@ -196,15 +197,12 @@ CREATE TABLE user_students (
 # Table structure for table `user_teachers`
 #
 
-CREATE TABLE user_teachers (
-  id int(10) unsigned NOT NULL auto_increment,
-  user int(10) unsigned NOT NULL default '0',
-  course int(10) unsigned NOT NULL default '0',
-  authority varchar(10) default NULL,
-  PRIMARY KEY  (id),
-  UNIQUE KEY id (id)
+CREATE TABLE `user_teachers` (
+  `id` int(10) unsigned NOT NULL auto_increment,
+  `user` int(10) unsigned NOT NULL default '0',
+  `course` int(10) unsigned NOT NULL default '0',
+  `authority` varchar(10) default NULL,
+  PRIMARY KEY  (`id`),
+  UNIQUE KEY `id` (`id`)
 ) TYPE=MyISAM COMMENT='One record per teacher per course';
 
-    
-
-
index d3834145652c6a442a7cfb2641e955cbe6af84f6..65ea50687689e5d0d4f932a39c9eacc65deed815 100644 (file)
@@ -16,7 +16,7 @@
                  "<A HREF=../../course/view.php?id=$course->id>$course->shortname</A> -> Choices", "");
 
 
-    if (! $choices = get_all_instances_in_course("choice", $course->id, "cw.week ASC")) {
+    if (! $choices = get_all_instances_in_course("choice", $course->id, "cw.section ASC")) {
         notice("There are no choices", "../../course/view.php?id=$course->id");
     }
 
@@ -49,7 +49,7 @@
                 break;
         }
 
-        $table->data[] = array ("<P>$choice->week</P>",
+        $table->data[] = array ("<P>$choice->section</P>",
                                 "<P><A HREF=\"view.php?id=$choice->coursemodule\">$choice->name</A></P>",
                                 "<P>$aa</P>");
     }
index ba9a919d7691ea351550f654e7d7d5e6e7c142c8..1f471660c23cd42386585bfc54d0eba0a3080d97 100644 (file)
@@ -45,7 +45,7 @@
 <CENTER>
 <input type="hidden" name=course     value="<? p($form->course) ?>">
 <input type="hidden" name=coursemodule  value="<? p($form->coursemodule) ?>">
-<input type="hidden" name=week       value="<? p($form->week) ?>">
+<input type="hidden" name=section       value="<? p($form->section) ?>">
 <input type="hidden" name=module     value="<? p($form->module) ?>">
 <input type="hidden" name=modulename value="<? p($form->modulename) ?>">
 <input type="hidden" name=instance   value="<? p($form->instance) ?>">
index 45ee5ddd18ec96b46af263a7cb6b4d3ee995e362..f402f785164d8bed3f3672f7f127c3266df78bb1 100644 (file)
@@ -44,7 +44,7 @@
 <CENTER>
 <input type="hidden" name=course     value="<? p($form->course) ?>">
 <input type="hidden" name=coursemodule  value="<? p($form->coursemodule) ?>">
-<input type="hidden" name=week       value="<? p($form->week) ?>">
+<input type="hidden" name=section       value="<? p($form->section) ?>">
 <input type="hidden" name=module     value="<? p($form->module) ?>">
 <input type="hidden" name=modulename value="<? p($form->modulename) ?>">
 <input type="hidden" name=instance   value="<? p($form->instance) ?>">
index 332949374fce334c3721bf58fb50263562ec4e83..94bf8fdbd3a0f1793b6fd8fe5f3d9a18b2c426bd 100644 (file)
                  "<A HREF=../../course/view.php?id=$course->id>$course->shortname</A> -> Journals", "");
 
 
-    if (! $journals = get_all_instances_in_course("journal", $course->id, "cw.week ASC")) {
+    if (! $journals = get_all_instances_in_course("journal", $course->id, "cw.section ASC")) {
         notice("There are no journals", "../../course/view.php?id=$course->id");
         die;
     }
 
     $timenow = time();
 
-    $table->head  = array ("Week", "Question", "Answer");
-    $table->align = array ("CENTER", "LEFT", "LEFT");
+    if ($course->format == "weeks") {
+        $table->head  = array ("Week", "Question", "Answer");
+        $table->align = array ("CENTER", "LEFT", "LEFT");
+    } else if ($course->format == "topics") {
+        $table->head  = array ("Topic", "Question", "Answer");
+        $table->align = array ("CENTER", "LEFT", "LEFT");
+    } else {
+        $table->head  = array ("Name", "Answer");
+        $table->align = array ("LEFT", "LEFT");
+    }
 
     foreach ($journals as $journal) {
 
         $entry = get_record_sql("SELECT text FROM journal_entries 
                                  WHERE user='$USER->id' AND journal='$journal->id'");
 
-        $journal->timestart  = $course->startdate + (($journal->week - 1) * 608400);
+        $journal->timestart  = $course->startdate + (($journal->section - 1) * 608400);
         if ($journal->daysopen) {
             $journal->timefinish = $journal->timestart + (3600 * 24 * $journal->daysopen);
         } else {
         } else {
             $text .= "View</A></P>";
         }
-        $table->data[] = array ("$journal->week",
-                                text_to_html($journal->intro),
-                                $text);
+        if ($course->format == "weeks" or $course->format == "topics") {
+            $table->data[] = array ("$journal->section",
+                                    text_to_html($journal->intro),
+                                    $text);
+        } else {
+            $table->data[] = array (text_to_html($journal->intro),
+                                    $text);
+        }
     }
 
     print_table($table);
index 988f3854243f87d2d3c143e9927abedc0a91f04f..a58b4feb1e2de01451c3063c23f2774fee5178b4 100644 (file)
@@ -37,7 +37,7 @@
 <CENTER>
 <input type="hidden" name=course     value="<? p($form->course) ?>">
 <input type="hidden" name=coursemodule  value="<? p($form->coursemodule) ?>">
-<input type="hidden" name=week       value="<? p($form->week) ?>">
+<input type="hidden" name=section       value="<? p($form->section) ?>">
 <input type="hidden" name=module     value="<? p($form->module) ?>">
 <input type="hidden" name=modulename value="<? p($form->modulename) ?>">
 <input type="hidden" name=instance   value="<? p($form->instance) ?>">
index 366d87d9363fe8f332bf290fceecb2445c115333..51c4928f08ef0c2f81aacbf73e4fff88dd398186 100644 (file)
@@ -23,7 +23,7 @@
     echo "<TR><TH>Week<TH>Journal</TR>";
     foreach ($journals as $journal) {
 
-        $journal->timestart  = $course->startdate + (($journal->week - 1) * 608400);
+        $journal->timestart  = $course->startdate + (($journal->section - 1) * 608400);
         if ($journal->daysopen) {
             $journal->timefinish = $journal->timestart + (3600 * 24 * $journal->daysopen);
         } else {
@@ -41,7 +41,7 @@
             } else {
                 echo "<TD BGCOLOR=\"$THEME->cellheading\">";
             }
-            echo "$journal->week</TD>";
+            echo "$journal->section</TD>";
             echo "<TD BGCOLOR=\"$THEME->cellcontent\">";
             echo "<P><A HREF=\"$CFG->wwwroot/mod/journal/view.php?id=$journal->coursemodule\">$journal->name</A></P>";
             if ($entry->modified) {
index 62fe7197d33e50139ce7da7c3137bd3c05332fab..4a693e0cd41f93b97e2d4554ef88c6a7656914e3 100644 (file)
@@ -21,7 +21,7 @@
 
     add_to_log($course->id, "journal", "view", "view.php?id=$cm->id", "$journal->id");
 
-    if (! $cw = get_record("course_weeks", "id", $cm->week)) {
+    if (! $cw = get_record("course_sections", "id", $cm->section)) {
         error("Course module is incorrect");
     }
 
     echo "<BR>";
 
     $timenow = time();
-    $timestart = $course->startdate + (($cw->week - 1) * 608400);
-    if ($journal->days) {
-        $timefinish = $timestart + (3600 * 24 * $journal->days);
-    } else {
-        $timefinish = $course->enddate;
+
+    if ($course->format == "weeks" and $journal->days) {
+        $timestart = $course->startdate + (($cw->section - 1) * 608400);
+        if ($journal->days) {
+            $timefinish = $timestart + (3600 * 24 * $journal->days);
+        } else {
+            $timefinish = $course->enddate;
+        }
+    } else {  // Have no time limits on the journals
+
+        $timestart = $timenow - 1;
+        $timefinish = $timenow + 1;
+        $journal->days = 0;
     }
 
     if ($timenow > $timestart) {
index 0e280a47eac4949d1ff2591bb9acbf3b20e06e46..11c0a3c7dd87bbc4181504670a1e53161a41fd3a 100644 (file)
@@ -46,7 +46,7 @@
 
         <input type="hidden" name=course     value="<? p($form->course) ?>">
         <input type="hidden" name=coursemodule     value="<? p($form->coursemodule) ?>">
-        <input type="hidden" name=week       value="<? p($form->week) ?>">
+        <input type="hidden" name=section       value="<? p($form->section) ?>">
         <input type="hidden" name=module     value="<? p($form->module) ?>">
         <input type="hidden" name=modulename value="<? p($form->modulename) ?>">
         <input type="hidden" name=instance   value="<? p($form->instance) ?>">
index 1a92b232cbbd7c8f410858f55a0fba8b122d3178..42e95218a22330d5f4447172162042811fb105a1 100644 (file)
@@ -17,7 +17,7 @@
                  "<A HREF=../../course/view.php?id=$course->id>$course->shortname</A> -> Surveys", "");
 
 
-    if (! $surveys = get_all_instances_in_course("survey", $course->id, "cw.week ASC")) {
+    if (! $surveys = get_all_instances_in_course("survey", $course->id, "cw.section ASC")) {
         notice("There are no surveys.", "../../course/view.php?id=$course->id");
     }
     
@@ -30,7 +30,7 @@
         } else {
             $ss = "<A HREF=\"view.php?id=$survey->coursemodule\">Not done yet</A>";
         }
-        $table->data[] = array ("$survey->week", 
+        $table->data[] = array ("$survey->section", 
                                 "<A HREF=\"view.php?id=$survey->coursemodule\">$survey->name</A>",
                                 "$ss");
     }
index 6e4f1607f458148576cf9ac9af082e361c066839..87a8ccdf12334bf09f67083d15458bd06946dcec 100644 (file)
@@ -25,7 +25,7 @@
 
 <input type="hidden" name=course     value="<? p($form->course) ?>">
 <input type="hidden" name=coursemodule  value="<? p($form->coursemodule) ?>">
-<input type="hidden" name=week       value="<? p($form->week) ?>">
+<input type="hidden" name=section       value="<? p($form->section) ?>">
 <input type="hidden" name=module     value="<? p($form->module) ?>">
 <input type="hidden" name=modulename value="<? p($form->modulename) ?>">
 <input type="hidden" name=instance   value="<? p($form->instance) ?>">