the function feedback_print_item() now is splitted into 3 functions

feedback_print_item_preview()
feedback_print_item_complete()
feedback_print_item_show_value()
Now there is more control over the output
This commit is contained in:
Andreas Grabs
2010-04-21 11:48:49 +00:00
parent 88f77c3c26
commit 9d5fbd6554
16 changed files with 855 additions and 215 deletions
+1 -1
View File
@@ -392,7 +392,7 @@ if($feedback_can_submit) {
echo '<td>&nbsp;</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>&nbsp;</td></tr>';
+1 -1
View File
@@ -350,7 +350,7 @@ if($feedback_can_submit) {
echo '<td>&nbsp;</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>&nbsp;</td></tr>';
+1 -1
View File
@@ -265,7 +265,7 @@ if($do_show == 'edit') {
echo '<td>&nbsp;</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>';
}
+117 -25
View File
@@ -57,8 +57,15 @@ class feedback_item_captcha extends feedback_item_base {
function excelprint_item(&$worksheet, $rowOffset, $item, $groupid, $courseid = false) {
return $rowOffset;
}
function print_item($item, $value = false, $readonly = false, $edit = false, $highlightrequire = false){
/**
* 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';
@@ -67,13 +74,65 @@ class feedback_item_captcha extends feedback_item_base {
$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;
}
}
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';
$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;
}
}
@@ -85,7 +144,7 @@ class feedback_item_captcha extends feedback_item_base {
}
//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;
@@ -97,36 +156,69 @@ class feedback_item_captcha extends feedback_item_base {
$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 : '&nbsp;';
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
<?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>
<td valign="top" align="<?php echo $align;?>">
<?php
echo $OUTPUT->box_start('generalbox boxalign'.$align);
echo $value ? $value : '&nbsp;';
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
+86 -10
View File
@@ -103,8 +103,64 @@ class feedback_item_info extends feedback_item_base {
$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';
@@ -118,19 +174,11 @@ class feedback_item_info extends feedback_item_base {
?>
<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):'&nbsp;';
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));
@@ -152,8 +200,36 @@ class feedback_item_info extends feedback_item_base {
<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):'&nbsp;';
echo $OUTPUT->box_end();
?>
</td>
<?php
+35 -6
View File
@@ -17,12 +17,41 @@ class feedback_item_label extends feedback_item_base {
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) {
+201 -68
View File
@@ -194,8 +194,101 @@ class feedback_item_multichoice extends feedback_item_base {
$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';
function print_item($item, $value = false, $readonly = false, $edit = false, $highlightrequire = false){
$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');?>&nbsp;</label>
</td>
</tr></table>
<?php
}
if($info->subtype != 'd') {
if($info->horizontal) {
echo '<table><tr>';
}
}
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';
@@ -219,9 +312,6 @@ class feedback_item_multichoice extends feedback_item_base {
$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 {
@@ -234,9 +324,6 @@ class feedback_item_multichoice extends feedback_item_base {
?>
<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>
@@ -245,74 +332,120 @@ class feedback_item_multichoice extends feedback_item_base {
}
$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();
//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');?>&nbsp;</label>
</td>
</tr></table>
<?php
}
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
}
/**
* 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 {
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();
$values = explode(FEEDBACK_MULTICHOICE_LINE_SEP, $value);
}
$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 = '';
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++;
}
$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');?>&nbsp;</label>
</td>
</tr></table>
<?php
}
if($info->subtype != 'd') {
if($info->horizontal) {
echo '<table><tr>';
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++;
}
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>
+101 -29
View File
@@ -184,8 +184,55 @@ class feedback_item_multichoicerated extends feedback_item_base {
$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);
@@ -197,12 +244,48 @@ class feedback_item_multichoicerated extends feedback_item_base {
}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>
@@ -210,26 +293,15 @@ class feedback_item_multichoicerated extends feedback_item_base {
<?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>
@@ -294,7 +366,7 @@ class feedback_item_multichoicerated extends feedback_item_base {
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 = '';
?>
@@ -328,7 +400,7 @@ class feedback_item_multichoicerated extends feedback_item_base {
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);
@@ -344,7 +416,7 @@ class feedback_item_multichoicerated extends feedback_item_base {
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);
@@ -360,7 +432,7 @@ class feedback_item_multichoicerated extends feedback_item_base {
}
}
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">&nbsp;</option>';
$index = 1;
@@ -372,7 +444,7 @@ class feedback_item_multichoicerated extends feedback_item_base {
$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>';
+113 -27
View File
@@ -134,8 +134,15 @@ class feedback_item_numeric extends feedback_item_base {
$rowOffset++;
return $rowOffset;
}
function print_item($item, $value = false, $readonly = false, $edit = false, $highlightrequire = false){
/**
* 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';
@@ -145,18 +152,11 @@ class feedback_item_numeric extends feedback_item_base {
$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;
if($highlightrequire AND (!$this->check_value($value, $item))) {
$highlight = 'bgcolor="#FFAAAA" class="missingrequire"';
}else {
$highlight = '';
}
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
?>
<td <?php echo $highlight;?> valign="top" align="<?php echo $align;?>">
?>
<td valign="top" align="<?php echo $align;?>">
<?php
if($edit OR $readonly) {
echo '('.$item->label.') ';
}
echo '('.$item->label.') ';
echo format_text($item->name . $requiredmark, true, false, false);
switch(true) {
case ($range_from === '-' AND is_numeric($range_to)):
@@ -174,22 +174,108 @@ class feedback_item_numeric extends feedback_item_base {
?>
</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) : '&nbsp;';
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
}
?>
<input type="text" name="<?php echo $item->typ.'_'.$item->id; ?>" size="10" maxlength="10" value="" />
</td>
<?php
<?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';
//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;
if($highlightrequire AND (!$this->check_value($value, $item))) {
$highlight = 'bgcolor="#FFAAAA" class="missingrequire"';
}else {
$highlight = '';
}
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
?>
<td <?php echo $highlight;?> valign="top" align="<?php echo $align;?>">
<?php
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)):
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;?>">
<?php
echo $OUTPUT->box_start('generalbox boxalign'.$align);
echo (is_numeric($value)) ? number_format($value, 2, $this->sep_dec, $this->sep_thous) : '&nbsp;';
echo $OUTPUT->box_end();
?>
</td>
<?php
}
function check_value($value, $item) {
+71 -16
View File
@@ -98,8 +98,45 @@ class feedback_item_textarea extends feedback_item_base {
$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';
@@ -110,31 +147,49 @@ class feedback_item_textarea extends feedback_item_base {
$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):'&nbsp;';
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):'&nbsp;';
echo $OUTPUT->box_end();
?>
</td>
<?php
}
function check_value($value, $item) {
+70 -20
View File
@@ -95,8 +95,43 @@ class feedback_item_textfield extends feedback_item_base {
$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';
@@ -107,32 +142,47 @@ class feedback_item_textfield extends feedback_item_base {
$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:'&nbsp;';
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:'&nbsp;';
echo $OUTPUT->box_end();
?>
</td>
<?php
}
function check_value($value, $item) {
+53 -6
View File
@@ -1130,6 +1130,29 @@ function feedback_move_item($moveitem, $pos){
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.
@@ -1137,15 +1160,14 @@ function feedback_move_item($moveitem, $pos){
*
* @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;
@@ -1154,7 +1176,32 @@ function feedback_print_item($item, $value = false, $readonly = false, $edit = f
}
//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);
}
/**
+1 -1
View File
@@ -74,7 +74,7 @@ if(is_array($feedbackitems)){
echo '<td>&nbsp;</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">&nbsp;</td>';
}
+2 -2
View File
@@ -230,9 +230,9 @@ if($do_show == 'showoneentry') {
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>';
+1 -1
View File
@@ -148,7 +148,7 @@ if(isset($formdata->showanonym) && $formdata->showanonym == FEEDBACK_ANONYMOUS_Y
}
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>';
}
+1 -1
View File
@@ -106,7 +106,7 @@ if(is_array($templateitems)){
echo '<td>&nbsp;</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>';
}