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/>.
17 abstract class feedback_item_base {
24 public function __construct() {
28 //this function only can used after the call of build_editform()
29 public function show_editform() {
30 $this->item_form->display();
33 public function is_cancelled() {
34 return $this->item_form->is_cancelled();
37 public function get_data() {
38 if ($this->item = $this->item_form->get_data()) {
44 public function value_type() {
48 public function value_is_array() {
52 abstract public function init();
53 abstract public function build_editform($item, $feedback, $cm);
54 abstract public function save_item();
55 abstract public function check_value($value, $item);
56 abstract public function create_value($data);
57 abstract public function compare_value($item, $dbvalue, $dependvalue);
58 abstract public function get_presentation($data);
59 abstract public function get_hasvalue();
60 abstract public function can_switch_require();
63 * @param object $worksheet a reference to the pear_spreadsheet-object
64 * @param integer $row_offset
65 * @param object $item the db-object from feedback_item
66 * @param integer $groupid
67 * @param integer $courseid
68 * @return integer the new row_offset
70 abstract public function excelprint_item(&$worksheet, $row_offset,
72 $groupid, $courseid = false);
75 * @param $item the db-object from feedback_item
76 * @param string $itemnr
77 * @param integer $groupid
78 * @param integer $courseid
79 * @return integer the new itemnr
81 abstract public function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false);
84 * @param object $item the db-object from feedback_item
85 * @param string $value a item-related value from feedback_values
88 abstract public function get_printval($item, $value);
91 * returns an Array with three values(typ, name, XXX)
92 * XXX is also an Array (count of responses on type $this->type)
93 * each element is a structure (answertext, answercount)
94 * @param $item the db-object from feedback_item
95 * @param $groupid if given
96 * @param $courseid if given
99 abstract public function get_analysed($item, $groupid = false, $courseid = false);
102 * print the item at the edit-page of feedback
105 * @param object $item
108 abstract public function print_item_preview($item);
111 * print the item at the complete-page of feedback
114 * @param object $item
115 * @param string $value
116 * @param bool $highlightrequire
119 abstract public function print_item_complete($item, $value = '', $highlightrequire = false);
122 * print the item at the complete-page of feedback
125 * @param object $item
126 * @param string $value
129 abstract public function print_item_show_value($item, $value = '');
132 * cleans the userinput while submitting the form
134 * @param mixed $value
137 abstract public function clean_input_value($value);
141 //a dummy class to realize pagebreaks
142 class feedback_item_pagebreak extends feedback_item_base {
143 protected $type = "pagebreak";
145 public function show_editform() {
147 public function is_cancelled() {
149 public function get_data() {
151 public function init() {
153 public function build_editform($item, $feedback, $cm) {
155 public function save_item() {
157 public function check_value($value, $item) {
159 public function create_value($data) {
161 public function compare_value($item, $dbvalue, $dependvalue) {
163 public function get_presentation($data) {
165 public function get_hasvalue() {
167 public function excelprint_item(&$worksheet, $row_offset,
169 $groupid, $courseid = false) {
172 public function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
174 public function get_printval($item, $value) {
176 public function get_analysed($item, $groupid = false, $courseid = false) {
178 public function print_item_preview($item) {
180 public function print_item_complete($item, $value = '', $highlightrequire = false) {
182 public function print_item_show_value($item, $value = '') {
184 public function can_switch_require() {
186 public function value_type() {
188 public function clean_input_value($value) {