echo '<td> </td>';
}
if($feedbackitem->typ != 'pagebreak') {
- feedback_print_item($feedbackitem, $value, false, false, $highlightrequired);
+ feedback_print_item_complete($feedbackitem, $value, $highlightrequired);
}
echo '</tr>';
echo '<tr><td> </td></tr>';
echo '<td> </td>';
}
if($feedbackitem->typ != 'pagebreak') {
- feedback_print_item($feedbackitem, $value, false, false, $highlightrequired);
+ feedback_print_item_complete($feedbackitem, $value, $highlightrequired);
}
echo '</tr>';
echo '<tr><td> </td></tr>';
echo '<td> </td>';
}
if($feedbackitem->typ != 'pagebreak') {
- feedback_print_item($feedbackitem, false, false, true);
+ feedback_print_item_preview($feedbackitem);
}else {
echo '<td class="feedback_pagebreak"><b>'.get_string('pagebreak', 'feedback').'</b></td><td><hr width="100%" size="8px" noshade="noshade" /></td>';
}
function excelprint_item(&$worksheet, $rowOffset, $item, $groupid, $courseid = false) {
return $rowOffset;
}
+
+ /**
+ * print the item at the edit-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @return void
+ */
+ function print_item_preview($item) {
+ global $SESSION, $CFG, $DB, $OUTPUT;
+
+ $align = right_to_left() ? 'right' : 'left';
+
+ $presentation = $item->presentation;
+ $SESSION->feedback->item->captcha->charcount = $presentation;
+
+ $cmid = 0;
+ $feedbackid = $item->feedback;
+ if($feedbackid > 0) {
+ $feedback = $DB->get_record('feedback', array('id'=>$feedbackid));
+ if($cm = get_coursemodule_from_instance("feedback", $feedback->id, $feedback->course)) {
+ $cmid = $cm->id;
+ }
+ }
- function print_item($item, $value = false, $readonly = false, $edit = false, $highlightrequire = false){
+ if(isset($SESSION->feedback->item->captcha->checked)) {
+ $checked = $SESSION->feedback->item->captcha->checked == true;
+ unset($SESSION->feedback->item->captcha->checked);
+ }else {
+ $checked = false;
+ }
+
+ $requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
+ ?>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ echo '('.$item->label.') ';
+ echo format_text($item->name . $requiredmark, true, false, false);
+ $imglink = new moodle_url('/mod/feedback/item/captcha/print_captcha.php', array('id'=>$cmid));
+ ?>
+ <img alt="<?php echo $this->type;?>" src="<?php echo $imglink->out();?>" />
+ </td>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ ?>
+ <input type="text" name="<?php echo $item->typ . '_' . $item->id;?>"
+ size="<?php echo $presentation;?>"
+ maxlength="<?php echo $presentation;?>"
+ value="" />
+ </td>
+ <?php
+ }
+
+ /**
+ * print the item at the complete-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @param string $value
+ * @param bool $highlightrequire
+ * @return void
+ */
+ function print_item_complete($item, $value = '', $highlightrequire = false) {
global $SESSION, $CFG, $DB, $OUTPUT;
$align = right_to_left() ? 'right' : 'left';
$SESSION->feedback->item->captcha->charcount = $presentation;
$cmid = 0;
- if(!$readonly) {
- $feedbackid = $item->feedback;
- if($feedbackid > 0) {
- $feedback = $DB->get_record('feedback', array('id'=>$feedbackid));
- if($cm = get_coursemodule_from_instance("feedback", $feedback->id, $feedback->course)) {
- $cmid = $cm->id;
- }
+ $feedbackid = $item->feedback;
+ if($feedbackid > 0) {
+ $feedback = $DB->get_record('feedback', array('id'=>$feedbackid));
+ if($cm = get_coursemodule_from_instance("feedback", $feedback->id, $feedback->course)) {
+ $cmid = $cm->id;
}
}
}
//check if an false value even the value is not required
- if(!$readonly AND !$item->required AND $value != '' AND $SESSION->feedback->item->captcha->checkchar != $value) {
+ if(!$item->required AND $value != '' AND $SESSION->feedback->item->captcha->checkchar != $value) {
$falsevalue = true;
}else {
$falsevalue = false;
$highlight = '';
}
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
- ?>
+ ?>
<td <?php echo $highlight;?> valign="top" align="<?php echo $align;?>">
<?php
- if($edit OR $readonly) {
- echo '('.$item->label.') ';
- }
echo format_text($item->name . $requiredmark, true, false, false);
$imglink = new moodle_url('/mod/feedback/item/captcha/print_captcha.php', array('id'=>$cmid));
?>
<img alt="<?php echo $this->type;?>" src="<?php echo $imglink->out();?>" />
</td>
<td valign="top" align="<?php echo $align;?>">
- <?php
- if($readonly){
- echo $OUTPUT->box_start('generalbox boxalign'.$align);
- echo $value ? $value : ' ';
- echo $OUTPUT->box_end();
- }else {
- ?>
<input type="text" name="<?php echo $item->typ . '_' . $item->id;?>"
size="<?php echo $presentation;?>"
maxlength="<?php echo $presentation;?>"
value="" />
- <?php
+ </td>
+ <?php
+ }
+
+ /**
+ * print the item at the complete-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @param string $value
+ * @return void
+ */
+ function print_item_show_value($item, $value = '') {
+ global $SESSION, $CFG, $DB, $OUTPUT;
+
+ $align = right_to_left() ? 'right' : 'left';
+
+ $presentation = $item->presentation;
+ $SESSION->feedback->item->captcha->charcount = $presentation;
+
+ $cmid = 0;
+
+ if(isset($SESSION->feedback->item->captcha->checked)) {
+ $checked = $SESSION->feedback->item->captcha->checked == true;
+ unset($SESSION->feedback->item->captcha->checked);
+ }else {
+ $checked = false;
}
- ?>
+
+ $requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
+ ?>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ echo '('.$item->label.') ';
+ echo format_text($item->name . $requiredmark, true, false, false);
+ $imglink = new moodle_url('/mod/feedback/item/captcha/print_captcha.php', array('id'=>$cmid));
+ ?>
+ <img alt="<?php echo $this->type;?>" src="<?php echo $imglink->out();?>" />
</td>
- <?php
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ echo $OUTPUT->box_start('generalbox boxalign'.$align);
+ echo $value ? $value : ' ';
+ echo $OUTPUT->box_end();
+ ?>
+ </td>
+ <?php
}
+
function check_value($value, $item) {
global $SESSION;
//if the item is not required, so the check is true if no value is given
$rowOffset++;
return $rowOffset;
}
+
+ /**
+ * print the item at the edit-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @return void
+ */
+ function print_item_preview($item) {
+ global $USER, $DB, $OUTPUT;
+ $align = right_to_left() ? 'right' : 'left';
- function print_item($item, $value = false, $readonly = false, $edit = false, $highlightrequire = false){
+ $presentation = $item->presentation;
+ $requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
+ ?>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ echo '('.$item->label.') ';
+ echo format_text($item->name . $requiredmark, true, false, false);
+ ?>
+ </td>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ $feedback = $DB->get_record('feedback', array('id'=>$item->feedback));
+ $course = $DB->get_record('course', array('id'=>$feedback->course));
+ $coursecategory = $DB->get_record('course_categories', array('id'=>$course->category));
+ switch($presentation) {
+ case 1:
+ $itemvalue = time();
+ $itemshowvalue = UserDate($itemvalue);
+ break;
+ case 2:
+ $itemvalue = $course->shortname;
+ $itemshowvalue = $itemvalue;
+ break;
+ case 3:
+ $itemvalue = $coursecategory->name;
+ $itemshowvalue = $itemvalue;
+ break;
+ }
+ ?>
+ <input type="hidden" name="<?php echo $item->typ . '_' . $item->id;?>"
+ value="<?php echo $itemvalue;?>" />
+ <span><?php echo $itemshowvalue;?></span>
+ </td>
+ <?php
+ }
+
+ /**
+ * print the item at the complete-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @param string $value
+ * @param bool $highlightrequire
+ * @return void
+ */
+ function print_item_complete($item, $value = '', $highlightrequire = false) {
global $USER, $DB, $OUTPUT;
$align = right_to_left() ? 'right' : 'left';
?>
<td <?php echo $highlight;?> valign="top" align="<?php echo $align;?>">
<?php
- if($edit OR $readonly) {
- echo '('.$item->label.') ';
- }
echo format_text($item->name . $requiredmark, true, false, false);
?>
</td>
<td valign="top" align="<?php echo $align;?>">
<?php
- if($readonly){
- echo $OUTPUT->box_start('generalbox boxalign'.$align);
- echo $value ? UserDate($value):' ';
- echo $OUTPUT->box_end();
- }else {
$feedback = $DB->get_record('feedback', array('id'=>$item->feedback));
$course = $DB->get_record('course', array('id'=>$feedback->course));
$coursecategory = $DB->get_record('course_categories', array('id'=>$course->category));
<input type="hidden" name="<?php echo $item->typ . '_' . $item->id;?>"
value="<?php echo $itemvalue;?>" />
<span><?php echo $itemshowvalue;?></span>
+ </td>
<?php
- }
+ }
+
+ /**
+ * print the item at the complete-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @param string $value
+ * @return void
+ */
+ function print_item_show_value($item, $value = '') {
+ global $USER, $DB, $OUTPUT;
+ $align = right_to_left() ? 'right' : 'left';
+
+ $presentation = $item->presentation;
+ $requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
+ ?>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ echo '('.$item->label.') ';
+ echo format_text($item->name . $requiredmark, true, false, false);
+ ?>
+ </td>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ echo $OUTPUT->box_start('generalbox boxalign'.$align);
+ echo $value ? UserDate($value):' ';
+ echo $OUTPUT->box_end();
?>
</td>
<?php
return $item_form;
}
- function print_item($item){
- ?>
- <td colspan="2">
- <?php echo format_text($item->presentation, FORMAT_HTML);?>
- </td>
- <?php
+
+ /**
+ * print the item at the edit-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @return void
+ */
+ function print_item_preview($item) {
+ $this->print_item($item);
+ }
+
+ /**
+ * print the item at the complete-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @param string $value
+ * @param bool $highlightrequire
+ * @return void
+ */
+ function print_item_complete($item, $value = '', $highlightrequire = false) {
+ $this->print_item($item);
+ }
+
+ /**
+ * print the item at the complete-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @param string $value
+ * @return void
+ */
+ function print_item_show_value($item, $value = '') {
+ $this->print_item($item);
}
function create_value($data) {
$rowOffset +=3 ;
return $rowOffset;
}
+
+ /**
+ * print the item at the edit-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @return void
+ */
+ function print_item_preview($item) {
+ global $OUTPUT;
+ $info = $this->get_info($item);
+ $align = right_to_left() ? 'right' : 'left';
+
+ $presentation = explode (FEEDBACK_MULTICHOICE_LINE_SEP, $info->presentation);
+
+
+ //test if required and no value is set so we have to mark this item
+ //we have to differ check and the other subtypes
+ if($info->subtype == 'c') {
+ $requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
+
+ echo '<td valign="top" align="'.$align.'">';
+ echo '('.$item->label.') ';
+ echo format_text($item->name.$requiredmark, true, false, false).'</td>';
+ echo '<td valign="top" align="'.$align.'">';
+ }else {
+ $requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
+ ?>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ echo '('.$item->label.') ';
+ echo format_text($item->name . $requiredmark, true, false, false);
+ ?>
+ </td>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ }
+ $index = 1;
+ $checked = '';
+ //print the "not_selected" item on radiobuttons
+ if($info->subtype == 'r') {
+ ?>
+ <table><tr>
+ <td valign="top" align="<?php echo $align;?>">
+ <input type="radio" name="<?php echo $item->typ . '_' . $item->id ;?>" id="<?php echo $item->typ . '_' . $item->id.'_xxx';?>" value="" checked="checked" />
+ </td>
+ <td align="<?php echo $align;?>">
+ <label for="<?php echo $item->typ . '_' . $item->id.'_xxx';?>"><?php print_string('not_selected', 'feedback');?> </label>
+ </td>
+ </tr></table>
+ <?php
+ }
+ if($info->subtype != 'd') {
+ if($info->horizontal) {
+ echo '<table><tr>';
+ }
+ }
- function print_item($item, $value = false, $readonly = false, $edit = false, $highlightrequire = false){
+ switch($info->subtype) {
+ case 'r':
+ $this->print_item_radio($presentation, $item, false, $info, $align);
+ break;
+ case 'c':
+ $this->print_item_check($presentation, $item, false, $info, $align);
+ break;
+ case 'd':
+ $this->print_item_dropdown($presentation, $item, false, $info, $align);
+ break;
+ }
+
+ if($info->subtype != 'd') {
+ if($info->horizontal) {
+ echo '</tr></table>';
+ }
+ }
+ /*
+ if($item->required == 1) {
+ echo '<input type="hidden" name="'.$item->typ . '_' . $item->id.'" value="1" />';
+ }
+ */
+ ?>
+ </td>
+ <?php
+ }
+
+ /**
+ * print the item at the complete-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @param string $value
+ * @param bool $highlightrequire
+ * @return void
+ */
+ function print_item_complete($item, $value = '', $highlightrequire = false) {
global $OUTPUT;
$info = $this->get_info($item);
$align = right_to_left() ? 'right' : 'left';
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
echo '<td '.$highlight.' valign="top" align="'.$align.'">';
- if($edit OR $readonly) {
- echo '('.$item->label.') ';
- }
echo format_text($item->name.$requiredmark, true, false, false).'</td>';
echo '<td valign="top" align="'.$align.'">';
}else {
?>
<td <?php echo $highlight;?> valign="top" align="<?php echo $align;?>">
<?php
- if($edit OR $readonly) {
- echo '('.$item->label.') ';
- }
echo format_text($item->name . $requiredmark, true, false, false);
?>
</td>
}
$index = 1;
$checked = '';
- if($readonly){
- if($info->subtype == 'c') {
- echo $OUTPUT->box_start('generalbox boxalign'.$align);
- foreach($presentation as $pres){
- foreach($values as $val) {
- if($val == $index){
- echo text_to_html($pres . '<br />', true, false, false);
- break;
- }
- }
- $index++;
- }
- echo $OUTPUT->box_end();
- }else {
- foreach($presentation as $pres){
- if($value == $index){
- echo $OUTPUT->box_start('generalbox boxalign'.$align);
- echo text_to_html($pres, true, false, false);
- echo $OUTPUT->box_end();
- break;
- }
- $index++;
- }
- }
- } else {
- //print the "not_selected" item on radiobuttons
- if($info->subtype == 'r') {
- ?>
- <table><tr>
- <td valign="top" align="<?php echo $align;?>"><input type="radio"
- name="<?php echo $item->typ . '_' . $item->id ;?>"
- id="<?php echo $item->typ . '_' . $item->id.'_xxx';?>"
- value="" <?php echo $value ? '' : 'checked="checked"';?> />
- </td>
- <td align="<?php echo $align;?>">
- <label for="<?php echo $item->typ . '_' . $item->id.'_xxx';?>"><?php print_string('not_selected', 'feedback');?> </label>
- </td>
- </tr></table>
- <?php
+ //print the "not_selected" item on radiobuttons
+ if($info->subtype == 'r') {
+ ?>
+ <table><tr>
+ <td valign="top" align="<?php echo $align;?>"><input type="radio"
+ name="<?php echo $item->typ . '_' . $item->id ;?>"
+ id="<?php echo $item->typ . '_' . $item->id.'_xxx';?>"
+ value="" <?php echo $value ? '' : 'checked="checked"';?> />
+ </td>
+ <td align="<?php echo $align;?>">
+ <label for="<?php echo $item->typ . '_' . $item->id.'_xxx';?>"><?php print_string('not_selected', 'feedback');?> </label>
+ </td>
+ </tr></table>
+ <?php
+ }
+ if($info->subtype != 'd') {
+ if($info->horizontal) {
+ echo '<table><tr>';
}
- if($info->subtype != 'd') {
- if($info->horizontal) {
- echo '<table><tr>';
- }
+ }
+
+ switch($info->subtype) {
+ case 'r':
+ $this->print_item_radio($presentation, $item, $value, $info, $align);
+ break;
+ case 'c':
+ $this->print_item_check($presentation, $item, $value, $info, $align);
+ break;
+ case 'd':
+ $this->print_item_dropdown($presentation, $item, $value, $info, $align);
+ break;
+ }
+
+ if($info->subtype != 'd') {
+ if($info->horizontal) {
+ echo '</tr></table>';
}
+ }
+ /*
+ if($item->required == 1) {
+ echo '<input type="hidden" name="'.$item->typ . '_' . $item->id.'" value="1" />';
+ }
+ */
+ ?>
+ </td>
+ <?php
+ }
- switch($info->subtype) {
- case 'r':
- $this->print_item_radio($presentation, $item, $value, $info, $align);
- break;
- case 'c':
- $this->print_item_check($presentation, $item, $value, $info, $align);
- break;
- case 'd':
- $this->print_item_dropdown($presentation, $item, $value, $info, $align);
- break;
+ /**
+ * print the item at the complete-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @param string $value
+ * @return void
+ */
+ function print_item_show_value($item, $value = '') {
+ global $OUTPUT;
+ $info = $this->get_info($item);
+ $align = right_to_left() ? 'right' : 'left';
+
+ $presentation = explode (FEEDBACK_MULTICHOICE_LINE_SEP, $info->presentation);
+
+
+ //test if required and no value is set so we have to mark this item
+ //we have to differ check and the other subtypes
+ if($info->subtype == 'c') {
+ if (is_array($value)) {
+ $values = $value;
+ }else {
+ $values = explode(FEEDBACK_MULTICHOICE_LINE_SEP, $value);
}
+ $requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
- if($info->subtype != 'd') {
- if($info->horizontal) {
- echo '</tr></table>';
+ echo '<td valign="top" align="'.$align.'">';
+ echo '('.$item->label.') ';
+ echo format_text($item->name.$requiredmark, true, false, false).'</td>';
+ echo '<td valign="top" align="'.$align.'">';
+ }else {
+ $requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
+ ?>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ echo '('.$item->label.') ';
+ echo format_text($item->name . $requiredmark, true, false, false);
+ ?>
+ </td>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ }
+ $index = 1;
+ $checked = '';
+ if($info->subtype == 'c') {
+ echo $OUTPUT->box_start('generalbox boxalign'.$align);
+ foreach($presentation as $pres){
+ foreach($values as $val) {
+ if($val == $index){
+ echo text_to_html($pres . '<br />', true, false, false);
+ break;
+ }
}
+ $index++;
}
- /*
- if($item->required == 1) {
- echo '<input type="hidden" name="'.$item->typ . '_' . $item->id.'" value="1" />';
+ echo $OUTPUT->box_end();
+ }else {
+ foreach($presentation as $pres){
+ if($value == $index){
+ echo $OUTPUT->box_start('generalbox boxalign'.$align);
+ echo text_to_html($pres, true, false, false);
+ echo $OUTPUT->box_end();
+ break;
+ }
+ $index++;
}
- */
}
?>
</td>
$rowOffset +=2 ;
return $rowOffset;
}
+
+ /**
+ * print the item at the edit-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @return void
+ */
+ function print_item_preview($item) {
+ global $OUTPUT;
+ $align = right_to_left() ? 'right' : 'left';
+ $info = $this->get_info($item);
- function print_item($item, $value = false, $readonly = false, $edit = false, $highlightrequire = false){
+ $lines = explode (FEEDBACK_MULTICHOICERATED_LINE_SEP, $info->presentation);
+ $requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
+ ?>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ echo '('.$item->label.') ';
+ echo format_text($item->name . $requiredmark, true, false, false);
+ ?>
+ </td>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ $index = 1;
+ $checked = '';
+ switch($info->subtype) {
+ case 'r':
+ $this->print_item_radio($item, false, $info, $align, true, $lines);
+ break;
+ case 'd':
+ $this->print_item_dropdown($item, false, $info, $align, true, $lines);
+ break;
+ }
+ ?>
+ </td>
+ <?php
+ }
+
+ /**
+ * print the item at the complete-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @param string $value
+ * @param bool $highlightrequire
+ * @return void
+ */
+ function print_item_complete($item, $value = '', $highlightrequire = false) {
global $OUTPUT;
$align = right_to_left() ? 'right' : 'left';
$info = $this->get_info($item);
}else {
$highlight = '';
}
- ?>
+ ?>
<td <?php echo $highlight;?> valign="top" align="<?php echo $align;?>">
<?php
- if($edit OR $readonly) {
- echo '('.$item->label.') ';
- }
+ echo format_text($item->name . $requiredmark, true, false, false);
+ ?>
+ </td>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ $index = 1;
+ $checked = '';
+ switch($info->subtype) {
+ case 'r':
+ $this->print_item_radio($item, $value, $info, $align, false, $lines);
+ break;
+ case 'd':
+ $this->print_item_dropdown($item, $value, $info, $align, false, $lines);
+ break;
+ }
+ ?>
+ </td>
+ <?php
+ }
+
+ /**
+ * print the item at the complete-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @param string $value
+ * @return void
+ */
+ function print_item_show_value($item, $value = '') {
+ global $OUTPUT;
+ $align = right_to_left() ? 'right' : 'left';
+ $info = $this->get_info($item);
+
+ $lines = explode (FEEDBACK_MULTICHOICERATED_LINE_SEP, $info->presentation);
+ $requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
+ ?>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ echo '('.$item->label.') ';
echo format_text($item->name . $requiredmark, true, false, false);
?>
</td>
<?php
$index = 1;
$checked = '';
- if($readonly){
- foreach($lines as $line){
- if($value == $index){
- $item_value = explode(FEEDBACK_MULTICHOICERATED_VALUE_SEP, $line);
- echo $OUTPUT->box_start('generalbox boxalign'.$align);
- echo text_to_html($item_value[1], true, false, false);
- echo $OUTPUT->box_end();
- break;
- }
- $index++;
- }
- } else {
- switch($info->subtype) {
- case 'r':
- $this->print_item_radio($item, $value, $info, $align, $edit, $lines);
- break;
- case 'd':
- $this->print_item_dropdown($item, $value, $info, $align, $edit, $lines);
- break;
+ foreach($lines as $line){
+ if($value == $index){
+ $item_value = explode(FEEDBACK_MULTICHOICERATED_VALUE_SEP, $line);
+ echo $OUTPUT->box_start('generalbox boxalign'.$align);
+ echo text_to_html($item_value[1], true, false, false);
+ echo $OUTPUT->box_end();
+ break;
}
+ $index++;
}
?>
</td>
return $info;
}
- function print_item_radio($item, $value, $info, $align, $edit, $lines) {
+ function print_item_radio($item, $value, $info, $align, $showrating, $lines) {
$index = 1;
$checked = '';
?>
id="<?php echo $inputid;?>"
value="<?php echo $index;?>" <?php echo $checked;?> />
</td><td align="<?php echo $align;?>"><label for="<?php echo $inputid;?>"><?php
- if($edit) {
+ if($showrating) {
echo text_to_html('('.$radio_value[0].') '.$radio_value[1], true, false, false);
}else {
echo text_to_html($radio_value[1], true, false, false);
id="<?php echo $inputid;?>"
value="<?php echo $index;?>" <?php echo $checked;?> />
</td><td align="<?php echo $align;?>"><label for="<?php echo $inputid;?>"><?php
- if($edit) {
+ if($showrating) {
echo text_to_html('('.$radio_value[0].') '.$radio_value[1], true, false, false);
}else {
echo text_to_html($radio_value[1], true, false, false);
}
}
- function print_item_dropdown($item, $value, $info, $align, $edit, $lines) {
+ function print_item_dropdown($item, $value, $info, $align, $showrating, $lines) {
echo '<select name="'. $item->typ . '_' . $item->id . '">';
echo '<option value="0"> </option>';
$index = 1;
$selected = '';
}
$dropdown_value = explode(FEEDBACK_MULTICHOICERATED_VALUE_SEP, $line);
- if($edit) {
+ if($showrating) {
echo '<option value="'. $index.'" '. $selected.'>'. clean_text('('.$dropdown_value[0].') '.$dropdown_value[1]).'</option>';
}else {
echo '<option value="'. $index.'" '. $selected.'>'. clean_text($dropdown_value[1]).'</option>';
$rowOffset++;
return $rowOffset;
}
+
+ /**
+ * print the item at the edit-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @return void
+ */
+ function print_item_preview($item) {
+ global $OUTPUT;
+ $align = right_to_left() ? 'right' : 'left';
- function print_item($item, $value = false, $readonly = false, $edit = false, $highlightrequire = false){
+ //get the range
+ $range_from_to = explode('|',$item->presentation);
+ //get the min-value
+ $range_from = (isset($range_from_to[0]) AND is_numeric($range_from_to[0])) ? floatval($range_from_to[0]) : 0;
+ //get the max-value
+ $range_to = (isset($range_from_to[1]) AND is_numeric($range_from_to[1])) ? floatval($range_from_to[1]) : 0;
+ $requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
+ ?>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ echo '('.$item->label.') ';
+ echo format_text($item->name . $requiredmark, true, false, false);
+ switch(true) {
+ case ($range_from === '-' AND is_numeric($range_to)):
+ echo ' ('.get_string('maximal', 'feedback').': '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_to).')';
+ break;
+ case (is_numeric($range_from) AND $range_to === '-'):
+ echo ' ('.get_string('minimal', 'feedback').': '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_from).')';
+ break;
+ case ($range_from === '-' AND $range_to === '-'):
+ break;
+ default:
+ echo ' ('.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_from).' - '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_to).')';
+ break;
+ }
+ ?>
+ </td>
+ <td valign="top" align="<?php echo $align;?>">
+ <input type="text" name="<?php echo $item->typ.'_'.$item->id; ?>" size="10" maxlength="10" value="" />
+ </td>
+ <?php
+ }
+
+ /**
+ * print the item at the complete-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @param string $value
+ * @param bool $highlightrequire
+ * @return void
+ */
+ function print_item_complete($item, $value = '', $highlightrequire = false) {
global $OUTPUT;
$align = right_to_left() ? 'right' : 'left';
$highlight = '';
}
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
- ?>
+ ?>
<td <?php echo $highlight;?> valign="top" align="<?php echo $align;?>">
<?php
- if($edit OR $readonly) {
- echo '('.$item->label.') ';
+ echo format_text($item->name . $requiredmark, true, false, false);
+ switch(true) {
+ case ($range_from === '-' AND is_numeric($range_to)):
+ echo ' ('.get_string('maximal', 'feedback').': '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_to).')';
+ break;
+ case (is_numeric($range_from) AND $range_to === '-'):
+ echo ' ('.get_string('minimal', 'feedback').': '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_from).')';
+ break;
+ case ($range_from === '-' AND $range_to === '-'):
+ break;
+ default:
+ echo ' ('.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_from).' - '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_to).')';
+ break;
}
+ ?>
+ </td>
+ <td valign="top" align="<?php echo $align;?>">
+ <input type="text" name="<?php echo $item->typ.'_'.$item->id; ?>" size="10" maxlength="10" value="<?php echo $value ? $value : ''; ?>" />
+ </td>
+ <?php
+ }
+
+ /**
+ * print the item at the complete-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @param string $value
+ * @return void
+ */
+ function print_item_show_value($item, $value = '') {
+ global $OUTPUT;
+ $align = right_to_left() ? 'right' : 'left';
+
+ //get the range
+ $range_from_to = explode('|',$item->presentation);
+ //get the min-value
+ $range_from = (isset($range_from_to[0]) AND is_numeric($range_from_to[0])) ? floatval($range_from_to[0]) : 0;
+ //get the max-value
+ $range_to = (isset($range_from_to[1]) AND is_numeric($range_from_to[1])) ? floatval($range_from_to[1]) : 0;
+ $requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
+ ?>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ echo '('.$item->label.') ';
echo format_text($item->name . $requiredmark, true, false, false);
switch(true) {
case ($range_from === '-' AND is_numeric($range_to)):
?>
</td>
<td valign="top" align="<?php echo $align;?>">
- <?php
- if($readonly){
- echo $OUTPUT->box_start('generalbox boxalign'.$align);
- echo (is_numeric($value)) ? number_format($value, 2, $this->sep_dec, $this->sep_thous) : ' ';
- echo $OUTPUT->box_end();
- }else {
- ?>
- <input type="text" name="<?php echo $item->typ.'_'.$item->id; ?>"
- size="10"
- maxlength="10"
- value="<?php echo $value ? $value : ''; ?>" />
- <?php
- }
- ?>
+ <?php
+ echo $OUTPUT->box_start('generalbox boxalign'.$align);
+ echo (is_numeric($value)) ? number_format($value, 2, $this->sep_dec, $this->sep_thous) : ' ';
+ echo $OUTPUT->box_end();
+ ?>
</td>
- <?php
+ <?php
}
function check_value($value, $item) {
$rowOffset++;
return $rowOffset;
}
+
+ /**
+ * print the item at the edit-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @return void
+ */
+ function print_item_preview($item) {
+ global $OUTPUT;
+ $align = right_to_left() ? 'right' : 'left';
- function print_item($item, $value = false, $readonly = false, $edit = false, $highlightrequire = false){
+ $presentation = explode ("|", $item->presentation);
+ $requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
+ ?>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ echo '('.$item->label.') ';
+ echo format_text($item->name . $requiredmark, true, false, false);
+ ?>
+ </td>
+ <td valign="top" align="<?php echo $align;?>">
+ <textarea name="<?php echo $item->typ . '_' . $item->id;?>"
+ cols="<?php echo $presentation[0];?>"
+ rows="<?php echo $presentation[1];?>"></textarea>
+ </td>
+ <?php
+ }
+
+ /**
+ * print the item at the complete-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @param string $value
+ * @param bool $highlightrequire
+ * @return void
+ */
+ function print_item_complete($item, $value = '', $highlightrequire = false) {
global $OUTPUT;
$align = right_to_left() ? 'right' : 'left';
$highlight = '';
}
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
- ?>
+ ?>
<td <?php echo $highlight;?> valign="top" align="<?php echo $align;?>">
<?php
- if($edit OR $readonly) {
- echo '('.$item->label.') ';
- }
echo format_text($item->name . $requiredmark, true, false, false);
?>
</td>
<td valign="top" align="<?php echo $align;?>">
- <?php
- if($readonly){
- echo $OUTPUT->box_start('generalbox boxalign'.$align);
- echo $value?str_replace("\n",'<br />',$value):' ';
- echo $OUTPUT->box_end();
- }else {
- ?>
<textarea name="<?php echo $item->typ . '_' . $item->id;?>"
cols="<?php echo $presentation[0];?>"
rows="<?php echo $presentation[1];?>"><?php echo $value?htmlspecialchars($value):'';?></textarea>
- <?php
- }
- ?>
</td>
- <?php
+ <?php
+ }
+
+ /**
+ * print the item at the complete-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @param string $value
+ * @return void
+ */
+ function print_item_show_value($item, $value = '') {
+ global $OUTPUT;
+ $align = right_to_left() ? 'right' : 'left';
+
+ $presentation = explode ("|", $item->presentation);
+ $requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
+ ?>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ echo '('.$item->label.') ';
+ echo format_text($item->name . $requiredmark, true, false, false);
+ ?>
+ </td>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ echo $OUTPUT->box_start('generalbox boxalign'.$align);
+ echo $value?str_replace("\n",'<br />',$value):' ';
+ echo $OUTPUT->box_end();
+ ?>
+ </td>
+ <?php
}
function check_value($value, $item) {
$rowOffset++;
return $rowOffset;
}
+
+ /**
+ * print the item at the edit-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @return void
+ */
+ function print_item_preview($item) {
+ global $OUTPUT;
+ $align = right_to_left() ? 'right' : 'left';
- function print_item($item, $value = false, $readonly = false, $edit = false, $highlightrequire = false){
+ $presentation = explode ("|", $item->presentation);
+ $requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
+ ?>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ echo '('.$item->label.') ';
+ echo format_text($item->name . $requiredmark, true, false, false);
+ ?>
+ </td>
+ <td valign="top" align="<?php echo $align;?>">
+ <input type="text" name="<?php echo $item->typ . '_' . $item->id;?>" size="<?php echo $presentation[0];?>" maxlength="<?php echo $presentation[1];?>" value="" />
+ </td>
+ <?php
+ }
+
+ /**
+ * print the item at the complete-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @param string $value
+ * @param bool $highlightrequire
+ * @return void
+ */
+ function print_item_complete($item, $value = '', $highlightrequire = false) {
global $OUTPUT;
$align = right_to_left() ? 'right' : 'left';
$highlight = '';
}
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
- ?>
+ ?>
<td <?php echo $highlight;?> valign="top" align="<?php echo $align;?>">
<?php
- if($edit OR $readonly) {
- echo '('.$item->label.') ';
- }
echo format_text($item->name . $requiredmark, true, false, false);
?>
</td>
<td valign="top" align="<?php echo $align;?>">
- <?php
- if($readonly){
- echo $OUTPUT->box_start('generalbox boxalign'.$align);
- echo $value?$value:' ';
- echo $OUTPUT->box_end();
- }else {
- ?>
- <input type="text" name="<?php echo $item->typ . '_' . $item->id;?>"
- size="<?php echo $presentation[0];?>"
- maxlength="<?php echo $presentation[1];?>"
- value="<?php echo $value?htmlspecialchars($value):'';?>" />
- <?php
- }
- ?>
+ <input type="text" name="<?php echo $item->typ . '_' . $item->id;?>" size="<?php echo $presentation[0];?>" maxlength="<?php echo $presentation[1];?>" value="<?php echo $value ? htmlspecialchars($value) : '';?>" />
</td>
- <?php
+ <?php
+ }
+
+ /**
+ * print the item at the complete-page of feedback
+ *
+ * @global object
+ * @param object $item
+ * @param string $value
+ * @return void
+ */
+ function print_item_show_value($item, $value = '') {
+ global $OUTPUT;
+ $align = right_to_left() ? 'right' : 'left';
+
+ $presentation = explode ("|", $item->presentation);
+ $requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
+ ?>
+ <td <?php echo $highlight;?> valign="top" align="<?php echo $align;?>">
+ <?php
+ echo '('.$item->label.') ';
+ echo format_text($item->name . $requiredmark, true, false, false);
+ ?>
+ </td>
+ <td valign="top" align="<?php echo $align;?>">
+ <?php
+ echo $OUTPUT->box_start('generalbox boxalign'.$align);
+ echo $value?$value:' ';
+ echo $OUTPUT->box_end();
+ ?>
+ </td>
+ <?php
}
function check_value($value, $item) {
return false;
}
+/**
+ * prints the given item.
+ * if $readonly is set true so the ouput only is for showing responses and not for editing or completing.
+ * each item-class has an own print_item function implemented.
+ *
+ * @param object $item the item what we want to print out
+ * @return void
+ */
+function feedback_print_item_preview($item){
+ global $CFG;
+ if($item->typ == 'pagebreak') {
+ return;
+ }
+ //get the class of the given item-typ
+ $itemclass = 'feedback_item_'.$item->typ;
+ if (!class_exists($itemclass)) {
+ require_once($CFG->dirroot.'/mod/feedback/item/'.$item->typ.'/lib.php');
+ }
+ //get the instance of the item-class
+ $itemobj = new $itemclass();
+ $itemobj->print_item_preview($item);
+}
+
/**
* prints the given item.
* if $readonly is set true so the ouput only is for showing responses and not for editing or completing.
*
* @param object $item the item what we want to print out
* @param mixed $value the value if $readonly is set true and we showing responses
- * @param boolean $readonly
- * @param boolean $edit should the item print out for completing or for editing?
* @param boolean $highlightrequire if this set true and the value are false on completing so the item will be highlighted
* @return void
*/
-function feedback_print_item($item, $value = false, $readonly = false, $edit = false, $highlightrequire = false){
+function feedback_print_item_complete($item, $value = false, $highlightrequire = false){
global $CFG;
- if($item->typ == 'pagebreak') return;
- if($readonly)$ro = 'readonly="readonly" disabled="disabled"';
+ if($item->typ == 'pagebreak') {
+ return;
+ }
//get the class of the given item-typ
$itemclass = 'feedback_item_'.$item->typ;
}
//get the instance of the item-class
$itemobj = new $itemclass();
- $itemobj->print_item($item, $value, $readonly, $edit, $highlightrequire);
+ $itemobj->print_item_complete($item, $value, $highlightrequire);
+}
+
+/**
+ * prints the given item.
+ * if $readonly is set true so the ouput only is for showing responses and not for editing or completing.
+ * each item-class has an own print_item function implemented.
+ *
+ * @param object $item the item what we want to print out
+ * @param mixed $value the value if $readonly is set true and we showing responses
+ * @return void
+ */
+function feedback_print_item_show_value($item, $value = false){
+ global $CFG;
+ if($item->typ == 'pagebreak') {
+ return;
+ }
+
+ //get the class of the given item-typ
+ $itemclass = 'feedback_item_'.$item->typ;
+ if (!class_exists($itemclass)) {
+ require_once($CFG->dirroot.'/mod/feedback/item/'.$item->typ.'/lib.php');
+ }
+ //get the instance of the item-class
+ $itemobj = new $itemclass();
+ $itemobj->print_item_show_value($item, $value);
}
/**
echo '<td> </td>';
}
if($feedbackitem->typ != 'pagebreak') {
- feedback_print_item($feedbackitem, false, false, true);
+ feedback_print_item_complete($feedbackitem, false, false);
}else {
echo '<td class="feedback_print_pagebreak" colspan="2"> </td>';
}
if($feedbackitem->typ != 'pagebreak') {
if(isset($value->value)) {
- feedback_print_item($feedbackitem, $value->value, true);
+ feedback_print_item_show_value($feedbackitem, $value->value);
}else {
- feedback_print_item($feedbackitem, false, true);
+ feedback_print_item_show_value($feedbackitem, false);
}
}else {
echo '<td><hr /></td>';
}
if($feedbackitem->typ != 'pagebreak') {
$itemvalue = isset($value->value) ? $value->value : false;
- feedback_print_item($feedbackitem, $itemvalue, true);
+ feedback_print_item_show_value($feedbackitem, $itemvalue);
}else {
echo '<td colspan="2"><hr /></td>';
}
echo '<td> </td>';
}
if($templateitem->typ != 'pagebreak') {
- feedback_print_item($templateitem);
+ feedback_print_item_preview($templateitem);
}else {
echo '<td><hr /></td><td>'.get_string('pagebreak', 'feedback').'</td>';
}