moodle/mod/journal/index.php
2001-11-22 06:23:56 +00:00

61 lines
1.8 KiB
PHP

<?PHP // $Id$
require("../../config.php");
require("lib.php");
require_variable($id); // course
if (! $course = get_record("course", "id", $id)) {
error("Course ID is incorrect");
}
require_login($course->id);
add_to_log("View all journals", $course->id);
print_header("$course->shortname: Journals", "$course->fullname",
"<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")) {
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");
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);
if ($journal->daysopen) {
$journal->timefinish = $journal->timestart + (3600 * 24 * $journal->daysopen);
} else {
$journal->timefinish = 9999999999;
}
$journalopen = ($journal->timestart < $timenow && $timenow < $journal->timefinish);
$text = text_to_html($entry->text)."<P ALIGN=right><A HREF=\"view.php?id=$journal->coursemodule\">";
if ($journalopen) {
$text .= "Edit</A></P>";
} else {
$text .= "View</A></P>";
}
$table->data[] = array ("$journal->week",
text_to_html($journal->intro),
$text);
}
print_table($table);
print_footer($course);
?>