echo "</td></tr><tr align='left'><td> \n"; echo feedback_create_action_form('print_picture', array('You clicked on the first example')); echo "</td><td> \n"; echo "echo feedback_create_action_form('print_picture', array('You clicked on the first example'));\n"; echo "</td></tr><tr align='left'><td> \n"; echo "<tr align='left'><td> \n"; echo feedback_create_action_form('print_picture', array('You clicked on the second example')); echo "</td><td> \n"; echo "echo feedback_create_action_form('print_picture', array('You clicked on the second example'));\n"; echo "</td></tr><tr align='left'><td> \n"; echo "<tr align='left'><td> \n"; echo feedback_create_action_form('prnt', array('This will produce an error')); echo "</td><td> \n"; echo "echo feedback_create_action_form('prnt', array('This will produce an error'));\n"; echo "</td></tr><tr align='left'><td> \n"; echo feedback_create_action_form('print_picture', array('You were redirect to testpage_2'), 'move.gif', 'print_picture', 'testpage_2.php?id=' . $SESSION->feedback->coursemoduleid); echo "</td><td> \n"; echo " echo feedback_create_action_form('print_picture', array('You will be redirected to testpage_2'),'move.gif','print_picture','testpage_2.php?id='.\$SESSION->feedback->coursemoduleid);\n"; echo "</td></tr><tr align='left'><td> \n"; echo "</td><td> \n"; echo "</td></tr></table> \n"; //------------------------------------------------------------------------------- //the same stuff on a large form //------------------------------------------------------------------------------- echo '<form action="testpage_1.php?id=' . $SESSION->feedback->coursemoduleid . '" method="post">'; echo "<br /><table><tr align='left'><td width='200px'> \n"; echo "<strong>These guys are sitting on a large form <br />Icon to click on:</strong>"; echo "</td><td> \n"; echo "<strong>PHP to create the button: </strong>\n"; echo "</td></tr><tr align='left'><td> \n"; echo feedback_create_action('print_picture', array('You clicked on the third example'));
/** * outputs HTML for picture item * * Outputs HTML code to browser window showing the picture item, * item may have already a $value (a sumitted form has been received), and * it is possible to show only the selected picture ($readonly=true) * * Radio button values are numbered starting from 1 ($index) * * @param object $item contains the item data (a record from prefix_feedback_item table) * @param integer $value gives the index to the selected picture (if any) * @param boolean $readonly if true, only the selected picture is shown */ function print_feedback_picture($item, $value = false, $readonly = false) { global $CFG; global $SESSION; $presentation = explode("|", $item->presentation); $requiredmark = $item->required == 1 ? '<font color="red">*</font>' : ''; ?> <td valign="top" align="left" style="padding-right: 40px;"><?php echo text_to_html(stripslashes_safe($item->name) . $requiredmark, true, false, false); ?> </td> <td valign="top" align="left"> <?php $index = 1; $checked = ''; if ($readonly) { // here we want to show the selected picture only, $value must be provided // this is used by feedback/show_entries.php, for example foreach ($presentation as $pic) { if ($value == $index) { print_simple_box_start('left'); echo '<img style="padding-left: 20px;" src="' . $CFG->wwwroot . feedback_PICTURE_FILES . '/' . $pic . '" />'; print_simple_box_end(); break; } $index++; } } else { // this is what we want most of the time, to show the picture item so that answering is possible // item may have already a value, after a failed saving attempt, say) $currentpic = 0; $piccount = count($presentation); $course_module = get_record('course_modules', 'id', $SESSION->feedback->coursemoduleid); foreach ($presentation as $pic) { // do we have somehting already selected? if ($value == $index) { $checked = 'checked="checked"'; } else { $checked = ''; } // generate the HTML for the item ?> <table><tr> <td valign="top"><input type="radio" name="<?php echo $item->typ . '_' . $item->id; ?> " value="<?php echo $index; ?> " <?php echo $checked; ?> /> </td><td><?php echo '<img style="padding-left: 20px;" src="' . $CFG->wwwroot . feedback_PICTURE_FILES . '/' . $pic . '" />'; ?> <?php $currentpic++; if (isadmin() || isteacher($course_module->course)) { if ($currentpic != 1) { echo '</td><td width="20"> ' . feedback_create_action_form('moveup_picture', array($item, $currentpic), 'up.gif'); } else { echo '</td><td width="20"> '; } if ($currentpic < $piccount) { echo '</td><td width="50"> ' . feedback_create_action_form('movedown_picture', array($item, $currentpic), 'down.gif'); } else { echo '</td><td width="50"> '; } } ?> </td></tr></table> <?php $index++; } } ?> </td> <?php }