2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 * print a printview of feedback-items
20 * @author Andreas Grabs
21 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
25 require_once("../../config.php");
26 require_once("lib.php");
28 $id = required_param('id', PARAM_INT
);
30 $PAGE->set_url('/mod/feedback/print.php', array('id'=>$id));
32 if (! $cm = get_coursemodule_from_id('feedback', $id)) {
33 print_error('invalidcoursemodule');
36 if (! $course = $DB->get_record("course", array("id"=>$cm->course
))) {
37 print_error('coursemisconf');
40 if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance
))) {
41 print_error('invalidcoursemodule');
44 if (!$context = get_context_instance(CONTEXT_MODULE
, $cm->id
)) {
45 print_error('badcontext');
48 require_login($course, true, $cm);
50 require_capability('mod/feedback:view', $context);
51 $PAGE->set_pagelayout('embedded');
53 /// Print the page header
54 $strfeedbacks = get_string("modulenameplural", "feedback");
55 $strfeedback = get_string("modulename", "feedback");
57 $feedback_url = new moodle_url('/mod/feedback/index.php', array('id'=>$course->id
));
58 $PAGE->navbar
->add($strfeedbacks, $feedback_url);
59 $PAGE->navbar
->add(format_string($feedback->name
));
61 $PAGE->set_title(format_string($feedback->name
));
62 $PAGE->set_heading(format_string($course->fullname
));
63 echo $OUTPUT->header();
65 /// Print the main part of the page
66 ///////////////////////////////////////////////////////////////////////////
67 ///////////////////////////////////////////////////////////////////////////
68 ///////////////////////////////////////////////////////////////////////////
69 echo $OUTPUT->heading(format_text($feedback->name
));
71 $feedbackitems = $DB->get_records('feedback_item', array('feedback'=>$feedback->id
), 'position');
72 echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
73 echo $OUTPUT->continue_button('view.php?id='.$id);
74 if (is_array($feedbackitems)) {
76 $align = right_to_left() ?
'right' : 'left';
78 echo $OUTPUT->box_start('feedback_items printview');
79 //check, if there exists required-elements
80 $params = array('feedback'=>$feedback->id
, 'required'=>1);
81 $countreq = $DB->count_records('feedback_item', $params);
83 echo '<span class="feedback_required_mark">(*)';
84 echo get_string('items_are_required', 'feedback');
87 //print the inserted items
89 foreach ($feedbackitems as $feedbackitem) {
90 echo $OUTPUT->box_start('feedback_item_box_'.$align);
92 //Items without value only are labels
93 if ($feedbackitem->hasvalue
== 1 AND $feedback->autonumbering
) {
95 echo $OUTPUT->box_start('feedback_item_number_'.$align);
97 echo $OUTPUT->box_end();
99 echo $OUTPUT->box_start('box generalbox boxalign_'.$align);
100 if ($feedbackitem->typ
!= 'pagebreak') {
101 feedback_print_item_complete($feedbackitem, false, false);
103 echo $OUTPUT->box_start('feedback_pagebreak');
104 echo '<hr class="feedback_pagebreak" />';
105 echo $OUTPUT->box_end();
107 echo $OUTPUT->box_end();
108 echo $OUTPUT->box_end();
110 echo $OUTPUT->box_end();
112 echo $OUTPUT->box(get_string('no_items_available_yet', 'feedback'),
113 'generalbox boxaligncenter boxwidthwide');
115 echo $OUTPUT->continue_button('view.php?id='.$id);
116 echo $OUTPUT->box_end();
118 ///////////////////////////////////////////////////////////////////////////
119 ///////////////////////////////////////////////////////////////////////////
120 ///////////////////////////////////////////////////////////////////////////
122 echo $OUTPUT->footer();