2001-11-22 06:23:56 +00:00
|
|
|
<?PHP // $Id$
|
|
|
|
|
|
|
|
require("../../config.php");
|
|
|
|
require("lib.php");
|
|
|
|
|
|
|
|
require_variable($id); // Course Module ID
|
|
|
|
|
|
|
|
if (! $cm = get_record("course_modules", "id", $id)) {
|
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! $course = get_record("course", "id", $cm->course)) {
|
|
|
|
error("Course is misconfigured");
|
|
|
|
}
|
|
|
|
|
|
|
|
require_login($course->id);
|
|
|
|
|
|
|
|
if (! $journal = get_record("journal", "id", $cm->instance)) {
|
|
|
|
error("Course module is incorrect");
|
|
|
|
}
|
|
|
|
|
2002-05-31 09:07:11 +00:00
|
|
|
add_to_log($course->id, "journal", "view", "view.php?id=$cm->id", "$journal->id");
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-06-25 11:49:06 +00:00
|
|
|
if (! $cw = get_record("course_sections", "id", $cm->section)) {
|
2001-11-22 06:23:56 +00:00
|
|
|
error("Course module is incorrect");
|
|
|
|
}
|
|
|
|
|
2002-08-03 08:16:31 +00:00
|
|
|
if ($course->category) {
|
|
|
|
$navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
|
|
|
|
}
|
2002-08-12 09:38:31 +00:00
|
|
|
|
|
|
|
$strjournal = get_string("modulename", "journal");
|
|
|
|
$strjournals = get_string("modulenameplural", "journal");
|
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
print_header("$course->shortname: $journal->name", "$course->fullname",
|
2002-08-12 09:38:31 +00:00
|
|
|
"$navigation <A HREF=index.php?id=$course->id>$strjournals</A> -> $journal->name", "", "", true,
|
2002-11-10 07:37:15 +00:00
|
|
|
update_module_button($cm->id, $course->id, $strjournal), navmenu($course, $cm));
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-09-22 03:16:40 +00:00
|
|
|
if (isteacher($course->id)) {
|
|
|
|
if ($allentries = get_records("journal_entries", "journal", $journal->id)) {
|
|
|
|
$entrycount = count($allentries);
|
|
|
|
} else {
|
|
|
|
$entrycount = 0;
|
|
|
|
}
|
|
|
|
echo "<P align=right><A HREF=\"report.php?id=$cm->id\">".get_string("viewallentries","journal", $entrycount)."</A></P>";
|
|
|
|
}
|
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
echo "<CENTER>\n";
|
|
|
|
|
|
|
|
print_simple_box( text_to_html($journal->intro) , "center");
|
|
|
|
|
|
|
|
echo "<BR>";
|
|
|
|
|
|
|
|
$timenow = time();
|
2002-06-25 11:49:06 +00:00
|
|
|
|
|
|
|
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;
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($timenow > $timestart) {
|
|
|
|
|
|
|
|
print_simple_box_start("center");
|
|
|
|
|
|
|
|
if ($timenow < $timefinish) {
|
|
|
|
$options = array ("id" => "$cm->id");
|
|
|
|
echo "<CENTER>";
|
2002-09-24 09:06:17 +00:00
|
|
|
if (!isguest()) {
|
|
|
|
print_single_button("edit.php", $options, get_string("startoredit","journal"));
|
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
echo "</CENTER>";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($entry = get_record_sql("SELECT * FROM journal_entries
|
|
|
|
WHERE user='$USER->id' AND journal='$journal->id'")) {
|
|
|
|
|
|
|
|
if (empty($entry->text)) {
|
2002-08-12 09:38:31 +00:00
|
|
|
echo "<P ALIGN=center><B>".get_string("blankentry","journal")."</B></P>";
|
2001-11-22 06:23:56 +00:00
|
|
|
} else {
|
2002-10-12 06:20:56 +00:00
|
|
|
echo format_text($entry->text, $entry->format);
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2002-08-12 09:38:31 +00:00
|
|
|
echo "<B><I>".get_string("notstarted","journal")."</I></B>";
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
print_simple_box_end();
|
|
|
|
|
|
|
|
if ($timenow < $timefinish) {
|
|
|
|
if ($entry->modified) {
|
2002-08-12 09:38:31 +00:00
|
|
|
echo "<P><FONT SIZE=-2><B>".get_string("lastedited").":</B> ";
|
2002-07-29 06:20:27 +00:00
|
|
|
echo userdate($entry->modified);
|
2002-08-12 09:38:31 +00:00
|
|
|
echo " (".get_string("numwords", "", count_words($entry->text)).")";
|
2002-07-29 06:20:27 +00:00
|
|
|
echo "</FONT></P>";
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
if ($journal->days) {
|
2002-08-12 09:38:31 +00:00
|
|
|
echo "<P><FONT SIZE=-2><B>".get_string("editingends", "journal").":</B> ";
|
2002-06-05 03:15:30 +00:00
|
|
|
echo userdate($timefinish)."</FONT></P>";
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
} else {
|
2002-08-12 09:38:31 +00:00
|
|
|
echo "<P><FONT SIZE=-2><B>".get_string("editingended", "journal").":</B> ";
|
2002-06-05 03:15:30 +00:00
|
|
|
echo userdate($timefinish)."</P>";
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($entry->comment || $entry->rating) {
|
2002-08-12 09:38:31 +00:00
|
|
|
print_heading(get_string("feedback"));
|
2002-08-04 18:19:42 +00:00
|
|
|
journal_print_feedback($course, $entry);
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
2002-08-12 09:38:31 +00:00
|
|
|
echo "<P><B>".get_string("notopenuntil", "journal").": ";
|
2002-06-05 03:15:30 +00:00
|
|
|
echo userdate($timestart)."</B></P>";
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
print_footer($course);
|
|
|
|
|
|
|
|
?>
|