Added a validation for the foreach in group with the tests CT#191

skala
Arthur Portugal 15 years ago
parent 01c0043d7e
commit abace4f499
  1. 20
      main/survey/survey.lib.php

@ -1686,6 +1686,8 @@ class yesno extends question
*/
function render_question($form_content, $answers=array())
{
if (is_array($form_content['options'])) { // check if data is correct
foreach ($form_content['options'] as $key=>$value)
{
$this->html .= '<label><input name="question'.$form_content['question_id'].'" type="radio" value="'.$key.'"';
@ -1705,6 +1707,7 @@ class yesno extends question
$this->html .= '/>'.$value.'</label>';
}
}
}
echo '<div class="survey_question_wrapper">';
echo '<div class="survey_question">'.$form_content['survey_question'].'</div>';
echo '<div class="survey_question_options">';
@ -1756,6 +1759,7 @@ class multiplechoice extends question
$this->html .= ' <div class="formw">';
$total_number_of_answers = count($form_content['answers']);
$this->html .= ' <table>';
if (is_array($form_content['answers'])) { // check if data is correct
foreach ($form_content['answers'] as $key=>$value) {
$this->html .= ' <tr>';
$this->html .= ' <td align="right"><label for="answers['.$key.']">'.($key+1).'</label></td>';
@ -1774,6 +1778,7 @@ class multiplechoice extends question
$this->html .= ' </td>';
$this->html .= ' </tr>';
}
}
// The buttons for adding or removing
$this->html .= ' </table>';
$this->html .= ' </div>';
@ -1849,15 +1854,14 @@ class personality extends question
$question_values=array();
// values of question options
foreach ($form_content['values'] as $key=>$value)
{
if(is_array($form_content['values'])) { // check if data is correct
foreach ($form_content['values'] as $key=>$value) {
$question_values [] = '<input size="3" type="text" id="values['.$key.']" name="values['.$key.']" value="'.$value.'" />';
}
}
$count=0;
foreach ($form_content['answers'] as $key=>$value)
{
if(is_array($form_content['answers'])) {
foreach ($form_content['answers'] as $key=>$value) {
$this->html .= ' <tr>';
$this->html .= ' <td align="right"><label for="answers['.$key.']">'.($key+1).'</label></td>';
//$this->html .= ' <td><input type="text" name="answers['.$key.']" id="answers['.$key.']" value="'.$form_content['answers'][$key].'" /></td>';
@ -1885,7 +1889,7 @@ class personality extends question
$this->html .= ' </tr>';
$count++;
}
}
// The buttons for adding or removing
//$this->html .= parent :: add_remove_buttons($form_content);
}
@ -1949,6 +1953,7 @@ class multipleresponse extends question
$this->html .= ' <div class="formw">';
$total_number_of_answers = count($form_content['answers']);
$this->html .= ' <table>';
if(is_array($form_content['answers'])) { // values of question options
foreach ($form_content['answers'] as $key=>$value) {
$this->html .= ' <tr>';
$this->html .= ' <td align="right"><label for="answers['.$key.']">'.($key+1).'</label></td>';
@ -1969,6 +1974,7 @@ class multipleresponse extends question
$this->html .= ' </td>';
$this->html .= ' </tr>';
}
}
// The buttons for adding or removing
$this->html .= ' </table>';
$this->html .= ' </div>';

Loading…
Cancel
Save