3 require_once("../../config.php");
4 require_once("lib.php");
6 $id = required_param('id', PARAM_INT
); // Course Module ID
8 if (! $cm = get_coursemodule_from_id('journal', $id)) {
9 error("Course Module ID was incorrect");
12 if (! $course = get_record("course", "id", $cm->course
)) {
13 error("Course is misconfigured");
16 require_login($course->id
, true, $cm);
18 if (! $journal = get_record("journal", "id", $cm->instance
)) {
19 error("Course module is incorrect");
22 add_to_log($course->id
, "journal", "view", "view.php?id=$cm->id", $journal->id
, $cm->id
);
24 if (! $cw = get_record("course_sections", "id", $cm->section
)) {
25 error("Course module is incorrect");
28 $strjournal = get_string("modulename", "journal");
29 $strjournals = get_string("modulenameplural", "journal");
32 $navlinks[] = array('name' => $strjournals, 'link' => "index.php?id=$course->id", 'type' => 'activity');
33 $navlinks[] = array('name' => format_string($journal->name
), 'link' => '', 'type' => 'activityinstance');
34 $navigation = build_navigation($navlinks);
36 print_header_simple(format_string($journal->name
), '', $navigation, '', '', true,
37 update_module_button($cm->id
, $course->id
, $strjournal), navmenu($course, $cm));
39 /// Check to see if groups are being used here
40 $groupmode = groupmode($course, $cm);
41 $currentgroup = setup_and_print_groups($course, $groupmode, "view.php?id=$cm->id");
43 if (isteacher($course->id
)) {
44 $entrycount = journal_count_entries($journal, $currentgroup);
46 echo '<div class="reportlink"><a href="report.php?id='.$cm->id
.'">'.
47 get_string('viewallentries','journal', $entrycount).'</a></div>';
51 $journal->intro
= trim($journal->intro
);
53 if (!empty($journal->intro
)) {
54 print_box( format_text($journal->intro
, $journal->introformat
), 'generalbox', 'intro');
61 if ($course->format
== 'weeks' and $journal->days
) {
62 $timestart = $course->startdate +
(($cw->section
- 1) * 604800);
64 $timefinish = $timestart +
(3600 * 24 * $journal->days
);
66 $timefinish = $course->enddate
;
68 } else { // Have no time limits on the journals
70 $timestart = $timenow - 1;
71 $timefinish = $timenow +
1;
75 if ($timenow > $timestart) {
77 print_simple_box_start('center');
79 if ($timenow < $timefinish) {
80 $options = array ('id' => "$cm->id");
83 print_single_button('edit.php', $options, get_string('startoredit','journal'));
89 if ($entry = get_record('journal_entries', 'userid', $USER->id
, 'journal', $journal->id
)) {
91 if (empty($entry->text
)) {
92 echo '<p align="center"><b>'.get_string('blankentry','journal').'</b></p>';
94 echo format_text($entry->text
, $entry->format
);
98 echo '<span class="warning">'.get_string('notstarted','journal').'</span>';
101 print_simple_box_end();
103 if ($timenow < $timefinish) {
104 if (!empty($entry->modified
)) {
105 echo '<div class="lastedit"><strong>'.get_string('lastedited').':</strong> ';
106 echo userdate($entry->modified
);
107 echo ' ('.get_string('numwords', '', count_words($entry->text
)).')';
110 if (!empty($journal->days
)) {
111 echo '<div class="editend"><strong>'.get_string('editingends', 'journal').':</strong> ';
112 echo userdate($timefinish).'</div>';
115 echo '<div class="editend"><strong>'.get_string('editingended', 'journal').':</strong> ';
116 echo userdate($timefinish).'</div>';
119 if (!empty($entry->entrycomment
) or !empty($entry->rating
)) {
120 $grades = make_grades_menu($journal->assessed
);
121 print_heading(get_string('feedback'));
122 journal_print_feedback($course, $entry, $grades);
127 echo '<div class="warning">'.get_string('notopenuntil', 'journal').': ';
128 echo userdate($timestart).'</div>';
132 print_footer($course);