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.
"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>
$form = $course;
} else {
$form->category = 0;
- $form->format = 1;
+ $form->newsitems = 1;
}
print_header("Admin: Setting up site", "Administration: Setting up site",
?>
</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>
$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;
}
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";
$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"
);
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;
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);
}
SET course = '$mod->course',
module = '$mod->module',
instance = '$mod->instance',
- week = '$mod->week',
+ section = '$mod->section',
added = '$timenow' ")) {
return 0;
}
}
-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;
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;
}
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) {
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;
}
} 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;
}
<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) ?>">
}
}
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§ion=0&add=reading\">Add reading...</A>";
$readingicon[] = " ";
}
print_side_block("", $readingdata, "", $readingicon);
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 .= " <A HREF=editweek.php?id=$thisweek->id><IMG SRC=\"../pix/t/edit.gif\" BORDER=0 ALT=\"Edit summary\"></A></P>";
+ $thissection->summary .= " <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§ion=$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();
}
// 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);
}
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:
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§ion=$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();
}
<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>";
}
</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();
}
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);
}
?>
# 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`
`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',
# 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';
# --------------------------------------------------------
# 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;
# --------------------------------------------------------
# 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.';
# --------------------------------------------------------
# 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;
# --------------------------------------------------------
# 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';
# --------------------------------------------------------
# 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;
# --------------------------------------------------------
# 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';
-
-
-
"<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");
}
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>");
}
<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) ?>">
<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) ?>">
"<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);
<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) ?>">
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 {
} 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) {
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) {
<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) ?>">
"<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");
}
} 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");
}
<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) ?>">