/**
  * @param array $survey_data
  * @param array $formData
  *
  * @return FormValidator
  */
 public function createForm($survey_data, $formData)
 {
     parent::createForm($survey_data, $formData);
     $options = array('horizontal' => get_lang('Horizontal'), 'vertical' => get_lang('Vertical'));
     $this->getForm()->addRadio('horizontalvertical', get_lang('DisplayAnswersHorVert'), $options);
     $formData['horizontalvertical'] = isset($formData['horizontalvertical']) ? $formData['horizontalvertical'] : 'horizontal';
     $this->getForm()->setDefaults($formData);
     $config = array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120');
     $total = count($formData['answers']);
     if (is_array($formData['answers'])) {
         foreach ($formData['answers'] as $key => $value) {
             $this->getForm()->addHtmlEditor('answers[' . $key . ']', null, false, false, $config);
             if ($key < $total - 1) {
                 //$this->getForm()->addButton("move_down[$key]", get_lang('Down'));
             }
             if ($key > 0) {
                 //$this->getForm()->addButton("move_up[$key]", get_lang('Up'));
             }
             if ($total > 2) {
                 $this->getForm()->addButton("delete_answer[{$key}]", get_lang('Delete'), 'trash', 'danger');
             }
         }
     }
     parent::addRemoveButtons($formData);
 }
 /**
  * @param array $survey_data
  * @param $formData
  *
  * @return FormValidator
  */
 public function createForm($survey_data, $formData)
 {
     parent::createForm($survey_data, $formData);
     if (is_array($formData['answers'])) {
         foreach ($formData['answers'] as $key => $value) {
             $this->getForm()->addText('answers[' . $key . ']', $key + 1);
         }
     }
     parent::addRemoveButtons($formData);
 }
Exemple #3
0
 /**
  * @param array $surveyData
  * @param array $formData
  */
 public function createForm($surveyData, $formData)
 {
     parent::createForm($surveyData, $formData);
     $options = array('horizontal' => get_lang('Horizontal'), 'vertical' => get_lang('Vertical'));
     $this->getForm()->addRadio('horizontalvertical', get_lang('DisplayAnswersHorVert'), $options);
     $formData['horizontalvertical'] = isset($formData['horizontalvertical']) ? $formData['horizontalvertical'] : 'horizontal';
     $this->getForm()->setDefaults($formData);
     // The options
     $config = array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120');
     $this->getForm()->addHtmlEditor('answers[0]', get_lang('AnswerOptions'), true, false, $config);
     $this->getForm()->addHtmlEditor('answers[1]', null, true, false, $config);
 }
Exemple #4
0
 /**
  * @param array $survey_data
  * @param $form_content
  */
 public function createForm($survey_data, $formData)
 {
     parent::createForm($survey_data, $formData);
     $this->getForm()->addText('maximum_score', get_lang('MaximumScore'));
     $config = array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120');
     if (is_array($formData['answers'])) {
         foreach ($formData['answers'] as $key => $value) {
             $this->getForm()->addHtmlEditor('answers[' . $key . ']', null, false, false, $config);
         }
     }
     parent::addRemoveButtons($formData);
 }
 /**
  * @param array $surveyData
  * @param array $formData
  */
 public function createForm($surveyData, $formData)
 {
     parent::createForm($surveyData, $formData);
     $options = array('horizontal' => get_lang('Horizontal'), 'vertical' => get_lang('Vertical'));
     $this->getForm()->addRadio('horizontalvertical', get_lang('DisplayAnswersHorVert'), $options);
     $formData['horizontalvertical'] = isset($formData['horizontalvertical']) ? $formData['horizontalvertical'] : 'horizontal';
     $this->getForm()->setDefaults($formData);
     $config = array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120');
     if (is_array($formData['answers'])) {
         foreach ($formData['answers'] as $key => $value) {
             $this->getForm()->addHtmlEditor('answers[' . $key . ']', null, false, false, $config);
         }
     }
     parent::addRemoveButtons($formData);
 }
Exemple #6
0
	if ($_POST) {
		$form_content = $_POST;
		$form_content = $form->handle_action(
            $survey_data,
            $form_content
        );
	}

	if ($error_message != '') {
		$form_content['question'] = $_SESSION['temp_user_message'];
		$form_content['answers'] = $_SESSION['temp_answers'];
		$form_content['values'] = $_SESSION['temp_values'];
		$form_content['horizontalvertical'] = $_SESSION['temp_horizontalvertical'];

		unset($_SESSION['temp_user_message']);
		unset($_SESSION['temp_answers']);
		unset($_SESSION['temp_values']);
		unset($_SESSION['temp_horizontalvertical']);
	}

	$form->create_form($survey_data, $form_content);
	$form->render_form();
} else {
	$form_content = $_POST;
	$form = new survey_question();
	$form->handle_action($survey_data, $form_content);
}

// Footer
Display :: display_footer();
 function create_form($form_content)
 {
     $this->html = parent::create_form($form_content);
     // The maximum score that can be given
     $this->html .= '	<div class="control-group">';
     $this->html .= '		<label class="control-label">';
     $this->html .= '			<span class="form_required">*</span>' . get_lang('MaximumScore');
     $this->html .= '		</label>';
     $this->html .= '		<div class="controls">';
     $this->html .= '			<input type="text" name="maximum_score" value="' . $form_content['maximum_score'] . '">';
     $this->html .= '		</div>';
     $this->html .= '	</div>';
     // The answers
     $this->html .= '	<div class="row">';
     $this->html .= '		<label class="control-label">';
     $this->html .= get_lang('AnswerOptions');
     $this->html .= '		</label>';
     $this->html .= '		<div class="formw">';
     $total_number_of_answers = count($form_content['answers']);
     $this->html .= ' 			<table>';
     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>';
         $this->html .= '		<td width="550">' . api_return_html_area('answers[' . $key . ']', stripslashes($form_content['answers'][$key]), '', '', null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120')) . '</td>';
         $this->html .= '		<td>';
         if ($key < $total_number_of_answers - 1) {
             $this->html .= '			<input type="image" style="width:22px"   src="../img/icons/22/down.png"  value="move_down[' . $key . ']" name="move_down[' . $key . ']"/>';
         }
         if ($key > 0) {
             $this->html .= '			<input type="image" style="width:22px"   src="../img/icons/22/up.png"  value="move_up[' . $key . ']" name="move_up[' . $key . ']"/>';
         }
         if ($total_number_of_answers > 2) {
             $this->html .= '			<input type="image" style="width:22px"   src="../img/icons/22/delete.png"  value="delete_answer[' . $key . ']" name="delete_answer[' . $key . ']"/>';
         }
         $this->html .= ' 		</td>';
         $this->html .= '	</tr>';
     }
     // The buttons for adding or removing
     $this->html .= ' 			</table>';
     $this->html .= '		</div>';
     $this->html .= '	</div>';
     $this->html .= parent::add_remove_buttons($form_content);
 }
    /**
     * This function creates the form elements for the multiple response questions
     *
     * @author Patrick Cool <*****@*****.**>, Ghent University
     * @version January 2007
     */
    public function createForm($survey_data, $form_content)
    {
        parent::createForm($survey_data, $form_content);
        $this->html .= '	<tr>';
        $this->html .= '		<td colspan="2"><strong>' . get_lang('DisplayAnswersHorVert') . '</strong></td>';
        $this->html .= '	</tr>';
        // Horizontal or vertical
        $this->html .= '	<tr>';
        $this->html .= '		<td align="right" valign="top">&nbsp;</td>';
        $this->html .= '		<td>';
        $this->html .= '		  <input name="horizontalvertical" type="radio" value="horizontal" ';
        if (empty($form_content['horizontalvertical']) || $form_content['horizontalvertical'] == 'horizontal') {
            $this->html .= 'checked="checked"';
        }
        $this->html .= '/>' . get_lang('Horizontal') . '</label><br />';
        $this->html .= '		  <input name="horizontalvertical" type="radio" value="vertical" ';
        if (isset($form_content['horizontalvertical']) && $form_content['horizontalvertical'] == 'vertical') {
            $this->html .= 'checked="checked"';
        }
        $this->html .= ' />' . get_lang('Vertical') . '</label>';
        $this->html .= '		</td>';
        $this->html .= '		<td>&nbsp;</td>';
        $this->html .= '	</tr>';
        $this->html .= '		<tr>
								<td colspan="">&nbsp;</td>
							</tr>';
        // The options
        $this->html .= '	<tr>';
        $this->html .= '		<td colspan="3"><strong>' . get_lang('AnswerOptions') . '</strong></td>';
        $this->html .= '	</tr>';
        $total_number_of_answers = count($form_content['answers']);
        $question_values = array();
        // Values of question options
        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;
        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>';
                $this->html .= '		<td width="550">' . api_return_html_area('answers[' . $key . ']', api_html_entity_decode(stripslashes($form_content['answers'][$key])), '', '', null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120')) . '</td>';
                $this->html .= '		<td>';
                if ($total_number_of_answers > 2) {
                    $this->html .= $question_values[$count];
                }
                if ($key < $total_number_of_answers - 1) {
                    $this->html .= '		<input type="image" style="width:22px"   src="../img/icons/22/down.png"  value="move_down[' . $key . ']" name="move_down[' . $key . ']"/>';
                }
                if ($key > 0) {
                    $this->html .= '		<input type="image" style="width:22px"   src="../img/icons/22/up.png"  value="move_up[' . $key . ']" name="move_up[' . $key . ']"/>';
                }
                if ($total_number_of_answers > 2) {
                    $this->html .= '			<input type="image" style="width:22px"   src="../img/icons/22/delete.png"  value="delete_answer[' . $key . ']" name="delete_answer[' . $key . ']"/>';
                }
                $this->html .= ' 		</td>';
                $this->html .= '	</tr>';
                $count++;
            }
        }
        // The buttons for adding or removing
        //$this->html .= parent :: add_remove_buttons($form_content);
    }
        $form_content['values'][3] = 2;
        $form_content['values'][4] = 3;
    }
    // We are editing a question
    if (isset($_GET['question_id']) && !empty($_GET['question_id'])) {
        $form_content = survey_manager::get_question($_GET['question_id']);
    }
    // An action has been performed (for instance adding a possible answer, moving an answer, ...)
    if ($_POST) {
        $form_content = $_POST;
        $form_content = $form->handle_action($form_content);
    }
    if ($error_message != '') {
        $form_content['question'] = $_SESSION['temp_user_message'];
        $form_content['answers'] = $_SESSION['temp_answers'];
        $form_content['values'] = $_SESSION['temp_values'];
        $form_content['horizontalvertical'] = $_SESSION['temp_horizontalvertical'];
        unset($_SESSION['temp_user_message']);
        unset($_SESSION['temp_answers']);
        unset($_SESSION['temp_values']);
        unset($_SESSION['temp_horizontalvertical']);
    }
    $form->create_form($form_content);
    $form->render_form();
} else {
    $form_content = $_POST;
    $form = new survey_question();
    $form->handle_action($form_content);
}
// Footer
Display::display_footer();