From: martin Date: Tue, 25 Jun 2002 11:49:06 +0000 (+0000) Subject: Major changes throughout to change "week" notation to "section" notation. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=b5fe4c935deb57be765d6e944bfb54e2e77b9480;p=moodle.git Major changes throughout to change "week" notation to "section" notation. 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. --- diff --git a/admin/site.html b/admin/site.html index 3b2ad69efd..4cbe232327 100644 --- a/admin/site.html +++ b/admin/site.html @@ -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"]); ?> diff --git a/admin/site.php b/admin/site.php index f9301ac84f..25beac9e44 100644 --- a/admin/site.php +++ b/admin/site.php @@ -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", diff --git a/course/edit.html b/course/edit.html index 53768d8401..9b9b76ceb3 100644 --- a/course/edit.html +++ b/course/edit.html @@ -48,6 +48,26 @@ ?> + +

News items to show: + "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"]); + ?> + + +

Word for teacher: @@ -70,12 +90,13 @@ ?> -

End date: +

Number of weeks/topics: 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"]); ?> diff --git a/course/edit.php b/course/edit.php index 8d90e7eb0f..97bb32155e 100644 --- a/course/edit.php +++ b/course/edit.php @@ -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); @@ -55,10 +54,10 @@ $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"); @@ -81,16 +80,16 @@ 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; } @@ -109,7 +108,7 @@ 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"; diff --git a/course/lib.php b/course/lib.php index 694725fdbc..d09ee3cc76 100644 --- a/course/lib.php +++ b/course/lib.php @@ -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" ); diff --git a/course/mod.php b/course/mod.php index 1e4083cd06..cd6f2c30f7 100644 --- a/course/mod.php +++ b/course/mod.php @@ -33,17 +33,17 @@ 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; @@ -101,6 +101,10 @@ 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)) { @@ -108,10 +112,12 @@ } $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"); @@ -132,25 +138,25 @@ 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)) { @@ -161,27 +167,27 @@ } 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_weeks - WHERE course = '$mod->course' AND week = '$mod->week'") ) { + if ($cw = get_record_sql("SELECT * FROM course_sections + 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_weeks + if (!$rs = $db->Execute("INSERT into course_sections 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_weeks - WHERE course = '$mod->course' AND week = '$mod->week'")) { + if ($rs = $db->Execute("SELECT id FROM course_sections + 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_weeks - 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_sections + 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_weeks - WHERE course='$thisweek->course' - AND week='$nextweeknumber' ")) { + $nextsectionnumber = $thissection->section + 1; + if ($nextsection = get_record_sql("SELECT * FROM course_sections + 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; } diff --git a/course/mod_delete.html b/course/mod_delete.html index c7ca08aa92..3512f44fda 100644 --- a/course/mod_delete.html +++ b/course/mod_delete.html @@ -2,9 +2,9 @@

-modulename ?") ?> +fullmodulename '$form->instancename' ?") ?> - + diff --git a/course/social.php b/course/social.php index 6ed869b0fe..b75d58b453 100644 --- a/course/social.php +++ b/course/social.php @@ -34,7 +34,7 @@ } } if ($USER->editing) { - $readingdata[] = "id&week=0&add=reading\">Add reading..."; + $readingdata[] = "id§ion=0&add=reading\">Add reading..."; $readingicon[] = " "; } print_side_block("", $readingdata, "", $readingicon); diff --git a/course/topics.php b/course/topics.php index 2839fa25aa..912bcdabbd 100644 --- a/course/topics.php +++ b/course/topics.php @@ -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)) { @@ -100,28 +100,23 @@ 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 ""; - 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; @@ -131,30 +126,30 @@ echo ""; echo ""; echo ""; echo ""; echo ""; - $week++; - $weekdate = $nextweekdate; + $section++; } echo "
"; - echo "

$week

"; + echo "

$section

"; echo "
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 .= " id>\"Edit

"; + $thissection->summary .= " id>\"Edit

"; } - echo text_to_html($thisweek->summary); + echo text_to_html($thissection->summary); echo "

"; - 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 "modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">"; @@ -170,8 +165,8 @@ if ($USER->editing) { echo "

"; - 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§ion=$section&add=", + $modtypes, "section$section", "", "Add..."); echo "
"; } @@ -179,19 +174,18 @@ echo "
"; echo ""; if (isset($USER->topic)) { - echo "id&topic=all\" TITLE=\"Show all topics\">

"; + echo "id&topic=all\" TITLE=\"Show all topics\">

"; } else { - echo "id&topic=$week\" TITLE=\"Show only topic $week\">

"; + echo "id&topic=$section\" TITLE=\"Show only topic $section\">

"; } - if ($USER->editing and $course->marker != $week) { - echo "id&marker=$week\" TITLE=\"Mark this topic as the current topic\">

"; + if ($USER->editing and $course->marker != $section) { + echo "id&marker=$section\" TITLE=\"Mark this topic as the current topic\">

"; } echo "
"; @@ -204,7 +198,7 @@ print_simple_box("Latest News", $align="CENTER", $width="100%", $color="$THEME->cellheading"); print_simple_box_start("CENTER", "100%", "#FFFFFF", 3, 0); echo ""; - print_forum_latest_topics($news->id, 5, "minimal", "DESC", false); + print_forum_latest_topics($news->id, $course->newsitems, "minimal", "DESC", false); echo ""; print_simple_box_end(); } diff --git a/course/user.php b/course/user.php index 08864183da..86f89c77f6 100644 --- a/course/user.php +++ b/course/user.php @@ -41,15 +41,15 @@ // 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 "

Week $week->week

"; - 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 "

Week $section->section

"; + 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); diff --git a/course/view.php b/course/view.php index cdd23be2eb..b21293dc10 100644 --- a/course/view.php +++ b/course/view.php @@ -52,13 +52,13 @@ } 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: diff --git a/course/weeks.php b/course/weeks.php index 3e7e5be970..f6669819c3 100644 --- a/course/weeks.php +++ b/course/weeks.php @@ -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; } } @@ -95,9 +95,10 @@ $weekdate = $course->startdate; // this should be 0:00 Monday of that week $week = 1; $weekofseconds = 604800; + $course->enddate = $course->startdate + ($weekofseconds * $course->numsections); echo ""; - while ($weekdate < $course->enddate) { + while ($weekdate <= $course->enddate) { $nextweekdate = $weekdate + ($weekofseconds); @@ -128,11 +129,11 @@ echo ""; echo ""; @@ -193,7 +194,7 @@ print_simple_box("Latest News", $align="CENTER", $width="100%", $color="$THEME->cellheading"); print_simple_box_start("CENTER", "100%", "#FFFFFF", 3, 0); echo ""; - print_forum_latest_topics($news->id, 5, "minimal", "DESC", false); + print_forum_latest_topics($news->id, $course->newsitems, "minimal", "DESC", false); echo ""; print_simple_box_end(); } diff --git a/index.php b/index.php index 68ea276c50..4cfd8801b3 100644 --- a/index.php +++ b/index.php @@ -28,11 +28,11 @@ "; 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 ""; + echo "$journal->section"; echo "
cellcontent\" WIDTH=\"100%\">"; echo "

cellheading2\">$weekday - $endweekday

"; - 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) { @@ -162,8 +163,8 @@ if ($USER->editing) { echo "
"; - 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§ion=$week&add=", + $modtypes, "section$week", "", "Add..."); echo "
"; } @@ -171,9 +172,9 @@ echo "
"; echo ""; if (isset($USER->week)) { - echo "id&week=all\" TITLE=\"Show all weeks\">"; + echo "id&week=all\" TITLE=\"Show all weeks\">"; } else { - echo "id&week=$week\" TITLE=\"Show only week $week\">"; + echo "id&week=$week\" TITLE=\"Show only week $week\">"; } echo "
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 "
  • Courses
  • "; } @@ -60,7 +60,7 @@
    - format == 0 ) { + newsitems == 0 ) { print_simple_box("Available Courses", $align="CENTER", $width="100%", $color="$THEME->cellheading"); echo "\"\"
    "; print_all_courses(); @@ -87,7 +87,7 @@ } print_simple_box("$headertext", $align="CENTER", $width="100%", $color="$THEME->cellheading"); echo "\"\"
    "; - print_forum_latest_topics($newsforum->id, $site->format); + print_forum_latest_topics($newsforum->id, $site->newsitems); } ?> diff --git a/lib/db/mysql.sql b/lib/db/mysql.sql index 0f26fec676..6bd3e77006 100644 --- a/lib/db/mysql.sql +++ b/lib/db/mysql.sql @@ -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'; - - - diff --git a/mod/choice/index.php b/mod/choice/index.php index d383414565..65ea506876 100644 --- a/mod/choice/index.php +++ b/mod/choice/index.php @@ -16,7 +16,7 @@ "id>$course->shortname -> 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 ("

    $choice->week

    ", + $table->data[] = array ("

    $choice->section

    ", "

    coursemodule\">$choice->name

    ", "

    $aa

    "); } diff --git a/mod/choice/mod.html b/mod/choice/mod.html index ba9a919d76..1f471660c2 100644 --- a/mod/choice/mod.html +++ b/mod/choice/mod.html @@ -45,7 +45,7 @@
    - + diff --git a/mod/forum/mod.html b/mod/forum/mod.html index 45ee5ddd18..f402f78516 100644 --- a/mod/forum/mod.html +++ b/mod/forum/mod.html @@ -44,7 +44,7 @@
    - + diff --git a/mod/journal/index.php b/mod/journal/index.php index 332949374f..94bf8fdbd3 100644 --- a/mod/journal/index.php +++ b/mod/journal/index.php @@ -16,22 +16,30 @@ "id>$course->shortname -> 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 { @@ -46,9 +54,14 @@ } else { $text .= "View

    "; } - $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); diff --git a/mod/journal/mod.html b/mod/journal/mod.html index 988f385424..a58b4feb1e 100644 --- a/mod/journal/mod.html +++ b/mod/journal/mod.html @@ -37,7 +37,7 @@
    - + diff --git a/mod/journal/user.php b/mod/journal/user.php index 366d87d936..51c4928f08 100644 --- a/mod/journal/user.php +++ b/mod/journal/user.php @@ -23,7 +23,7 @@ echo "
    WeekJournal
    cellheading\">"; } - echo "$journal->weekcellcontent\">"; echo "

    wwwroot/mod/journal/view.php?id=$journal->coursemodule\">$journal->name

    "; if ($entry->modified) { diff --git a/mod/journal/view.php b/mod/journal/view.php index 62fe7197d3..4a693e0cd4 100644 --- a/mod/journal/view.php +++ b/mod/journal/view.php @@ -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"); } @@ -41,11 +41,19 @@ echo "
    "; $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) { diff --git a/mod/survey/details.php b/mod/survey/details.php index 0e280a47ea..11c0a3c7dd 100644 --- a/mod/survey/details.php +++ b/mod/survey/details.php @@ -46,7 +46,7 @@ - + diff --git a/mod/survey/index.php b/mod/survey/index.php index 1a92b232cb..42e95218a2 100644 --- a/mod/survey/index.php +++ b/mod/survey/index.php @@ -17,7 +17,7 @@ "id>$course->shortname -> 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 = "coursemodule\">Not done yet"; } - $table->data[] = array ("$survey->week", + $table->data[] = array ("$survey->section", "coursemodule\">$survey->name", "$ss"); } diff --git a/mod/survey/mod.html b/mod/survey/mod.html index 6e4f1607f4..87a8ccdf12 100644 --- a/mod/survey/mod.html +++ b/mod/survey/mod.html @@ -25,7 +25,7 @@ - +