moodle/mod/journal/view.php

150 lines
4.4 KiB
PHP
Raw Normal View History

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");
}
add_to_log($course->id, "journal", "view", "view.php?id=$cm->id", "$journal->id");
2001-11-22 06:23:56 +00:00
if (! $cw = get_record("course_sections", "id", $cm->section)) {
2001-11-22 06:23:56 +00:00
error("Course module is incorrect");
}
print_header("$course->shortname: $journal->name", "$course->fullname",
"<A HREF=../../course/view.php?id=$course->id>$course->shortname</A> ->
<A HREF=index.php?id=$course->id>Journals</A> -> $journal->name", "", "", true,
update_module_icon($cm->id, $course->id));
2001-11-22 06:23:56 +00:00
if (isteacher($course->id)) {
echo "<P align=right><A HREF=\"report.php?id=$cm->id\">View all responses</A></P>";
}
echo "<CENTER>\n";
print_simple_box( text_to_html($journal->intro) , "center");
echo "<BR>";
$timenow = time();
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>";
print_single_button("edit.php", $options, "Start or edit my journal entry");
echo "</CENTER>";
}
if ($entry = get_record_sql("SELECT * FROM journal_entries
WHERE user='$USER->id' AND journal='$journal->id'")) {
if (empty($entry->text)) {
echo "<P ALIGN=center><B>Blank entry</B></P>";
} else {
echo text_to_html($entry->text);
}
} else {
echo "<B><I>You have not started this journal yet.</I></B>";
}
print_simple_box_end();
if ($timenow < $timefinish) {
if ($entry->modified) {
echo "<P><FONT SIZE=-2><B>Last edited:</B> ";
2002-07-29 06:20:27 +00:00
echo userdate($entry->modified);
echo " (".count_words($entry->text)." words)";
echo "</FONT></P>";
2001-11-22 06:23:56 +00:00
}
if ($journal->days) {
echo "<P><FONT SIZE=-2><B>Editing period ends:</B> ";
echo userdate($timefinish)."</FONT></P>";
2001-11-22 06:23:56 +00:00
}
} else {
echo "<P><FONT SIZE=-2><B>Editing period has ended:</B> ";
echo userdate($timefinish)."</P>";
2001-11-22 06:23:56 +00:00
}
if ($entry->comment || $entry->rating) {
print_heading("Feedback");
print_feedback($course, $entry);
}
} else {
echo "<P><B>This journal won't be open until: ";
echo userdate($timestart)."</B></P>";
2001-11-22 06:23:56 +00:00
}
print_footer($course);
// Functions
function print_feedback($course, $entry) {
global $CFG, $THEME, $RATING;
if (! $teacher = get_record("user", "id", $entry->teacher)) {
error("Weird journal error");
}
echo "\n<TABLE BORDER=1 CELLSPACING=0 valign=top cellpadding=10>";
echo "\n<TR>";
echo "\n<TD ROWSPAN=3 BGCOLOR=\"$THEME->body\" WIDTH=35 VALIGN=TOP>";
print_user_picture($teacher->id, $course->id, $teacher->picture);
echo "</TD>";
echo "<TD NOWRAP WIDTH=100% BGCOLOR=\"$THEME->cellheading\">$teacher->firstname $teacher->lastname";
echo "&nbsp;&nbsp;<FONT SIZE=2><I>".userdate($entry->timemarked)."</I>";
2001-11-22 06:23:56 +00:00
echo "</TR>";
echo "\n<TR><TD WIDTH=100% BGCOLOR=\"$THEME->cellcontent\">";
2002-07-23 18:02:05 +00:00
echo "<P ALIGN=RIGHT><FONT SIZE=-1><I>";
2001-11-22 06:23:56 +00:00
if ($RATING[$entry->rating]) {
2002-07-23 18:02:05 +00:00
echo "Overall rating: ";
2001-11-22 06:23:56 +00:00
echo $RATING[$entry->rating];
} else {
2002-07-23 18:02:05 +00:00
echo "No rating given";
2001-11-22 06:23:56 +00:00
}
2002-07-23 18:02:05 +00:00
echo "</I></FONT></P>";
2001-11-22 06:23:56 +00:00
echo text_to_html($entry->comment);
echo "</TD></TR></TABLE>";
}
?>