moodle/mod/journal/index.php

92 lines
2.9 KiB
PHP
Raw Normal View History

2001-11-22 06:23:56 +00:00
<?PHP // $Id$
require_once("../../config.php");
require_once("lib.php");
2001-11-22 06:23:56 +00:00
require_variable($id); // course
if (! $course = get_record("course", "id", $id)) {
error("Course ID is incorrect");
}
require_login($course->id);
add_to_log($course->id, "journal", "view all", "index.php?id=$course->id", "");
2001-11-22 06:23:56 +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");
$stredit = get_string("edit");
$strview = get_string("view");
$strweek = get_string("week");
$strtopic = get_string("topic");
$strquestion = get_string("question");
$stranswer = get_string("answer");
2002-11-10 08:43:44 +00:00
print_header("$course->shortname: $strjournals", "$course->fullname", "$navigation $strjournals",
"", "", true, "", navmenu($course));
2001-11-22 06:23:56 +00:00
if (! $journals = get_all_instances_in_course("journal", $course)) {
2001-11-22 06:23:56 +00:00
notice("There are no journals", "../../course/view.php?id=$course->id");
die;
}
$timenow = time();
if ($course->format == "weeks") {
2002-08-12 09:38:31 +00:00
$table->head = array ($strweek, $strquestion, $stranswer);
$table->align = array ("CENTER", "LEFT", "LEFT");
} else if ($course->format == "topics") {
2002-08-12 09:38:31 +00:00
$table->head = array ($strtopic, $strquestion, $stranswer);
$table->align = array ("CENTER", "LEFT", "LEFT");
} else {
2002-08-12 09:38:31 +00:00
$table->head = array ($strquestion, $stranswer);
$table->align = array ("LEFT", "LEFT");
}
2001-11-22 06:23:56 +00:00
foreach ($journals as $journal) {
$journal->timestart = $course->startdate + (($journal->section - 1) * 608400);
2003-01-01 07:18:43 +00:00
if (!empty($journal->daysopen)) {
2001-11-22 06:23:56 +00:00
$journal->timefinish = $journal->timestart + (3600 * 24 * $journal->daysopen);
} else {
$journal->timefinish = 9999999999;
}
$journalopen = ($journal->timestart < $timenow && $timenow < $journal->timefinish);
2003-04-26 12:38:53 +00:00
$entrytext = get_field("journal_entries", "text", "userid", $USER->id, "journal", $journal->id);
$text = text_to_html($entrytext)."<p align=right><a href=\"view.php?id=$journal->coursemodule\">";
2001-11-22 06:23:56 +00:00
if ($journalopen) {
2003-04-26 12:38:53 +00:00
$text .= "$stredit</a></p>";
2001-11-22 06:23:56 +00:00
} else {
2003-04-26 12:38:53 +00:00
$text .= "$strview</a></p>";
2001-11-22 06:23:56 +00:00
}
2003-01-01 07:18:43 +00:00
if (!empty($journal->section)) {
$section = "$journal->section";
} else {
$section = "";
}
if ($course->format == "weeks" or $course->format == "topics") {
$table->data[] = array ($section,
text_to_html($journal->intro),
$text);
} else {
$table->data[] = array (text_to_html($journal->intro),
$text);
}
2001-11-22 06:23:56 +00:00
}
2003-04-26 12:38:53 +00:00
echo "<br />";
2002-08-12 09:38:31 +00:00
2001-11-22 06:23:56 +00:00
print_table($table);
print_footer($course);
?>