Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

150 lines (111 sloc) 4.535 kB
<?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");
if (! $cw = get_record("course_sections", "id", $cm->section)) {
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));
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;
}
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> ";
echo userdate($entry->modified);
echo " (".count_words($entry->text)." words)";
echo "</FONT></P>";
}
if ($journal->days) {
echo "<P><FONT SIZE=-2><B>Editing period ends:</B> ";
echo userdate($timefinish)."</FONT></P>";
}
} else {
echo "<P><FONT SIZE=-2><B>Editing period has ended:</B> ";
echo userdate($timefinish)."</P>";
}
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>";
}
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>";
echo "</TR>";
echo "\n<TR><TD WIDTH=100% BGCOLOR=\"$THEME->cellcontent\">";
echo "<P ALIGN=RIGHT><FONT SIZE=-1><I>";
if ($RATING[$entry->rating]) {
echo "Overall rating: ";
echo $RATING[$entry->rating];
} else {
echo "No rating given";
}
echo "</I></FONT></P>";
echo text_to_html($entry->comment);
echo "</TD></TR></TABLE>";
}
?>
Jump to Line
Something went wrong with that request. Please try again.