MDL-11517 reserved word MOD used in table alias in questions backup code
[moodle-pu.git] / mod / journal / view.php
blob7233ee88af668937fbcb229a32bb36a70ad5f869
1 <?php // $Id$
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");
31 $navlinks = array();
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');
57 echo '<br />';
59 $timenow = time();
61 if ($course->format == 'weeks' and $journal->days) {
62 $timestart = $course->startdate + (($cw->section - 1) * 604800);
63 if ($journal->days) {
64 $timefinish = $timestart + (3600 * 24 * $journal->days);
65 } else {
66 $timefinish = $course->enddate;
68 } else { // Have no time limits on the journals
70 $timestart = $timenow - 1;
71 $timefinish = $timenow + 1;
72 $journal->days = 0;
75 if ($timenow > $timestart) {
77 print_simple_box_start('center');
79 if ($timenow < $timefinish) {
80 $options = array ('id' => "$cm->id");
81 echo '<center>';
82 if (!isguest()) {
83 print_single_button('edit.php', $options, get_string('startoredit','journal'));
85 echo '</center>';
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>';
93 } else {
94 echo format_text($entry->text, $entry->format);
97 } else {
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)).')';
108 echo "</div>";
110 if (!empty($journal->days)) {
111 echo '<div class="editend"><strong>'.get_string('editingends', 'journal').':</strong> ';
112 echo userdate($timefinish).'</div>';
114 } else {
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);
126 } else {
127 echo '<div class="warning">'.get_string('notopenuntil', 'journal').': ';
128 echo userdate($timestart).'</div>';
132 print_footer($course);