/** * This function does the generic part of any survey question: the question field * * @author Patrick Cool <*****@*****.**>, Ghent University * @version January 2007 * * @todo the form_text has to become a wysiwyg editor or adding a question_comment field * @todo consider adding a question_comment form element */ function create_form($form_content) { global $survey_data; //$tool_name = '<img src="../img/'.self::icon_question($_GET['type']).'" alt="'.get_lang(ucfirst($_GET['type'])).'" title="'.get_lang(ucfirst($_GET['type'])).'" />'; $tool_name = Display::return_icon(survey_manager::icon_question(Security::remove_XSS($_GET['type'])), get_lang(ucfirst(Security::remove_XSS($_GET['type']))), array('align' => 'middle', 'height' => '22px')) . ' '; if ($_GET['action'] == 'add') { $tool_name .= get_lang('AddQuestion'); } if ($_GET['action'] == 'edit') { $tool_name .= get_lang('EditQuestion'); } if ($_GET['type'] == 'yesno') { $tool_name .= ': ' . get_lang('YesNo'); } else { if ($_GET['type'] == 'multiplechoice') { $tool_name .= ': ' . get_lang('UniqueSelect'); } else { $tool_name .= ': ' . get_lang(api_ucfirst(Security::remove_XSS($_GET['type']))); } } $question_id = isset($_GET['question_id']) ? Security::remove_XSS($_GET['question_id']) : null; $this->html .= '<form class="form-horizontal" id="question_form" name="question_form" method="post" action="' . api_get_self() . '?action=' . Security::remove_XSS($_GET['action']) . '&type=' . Security::remove_XSS($_GET['type']) . '&survey_id=' . Security::remove_XSS($_GET['survey_id']) . '&question_id=' . $question_id . '">'; $this->html .= '<legend>' . $tool_name . '</legend>'; $this->html .= ' <input type="hidden" name="survey_id" id="survey_id" value="' . Security::remove_XSS($_GET['survey_id']) . '"/>'; $this->html .= ' <input type="hidden" name="question_id" id="question_id" value="' . $question_id . '"/>'; $this->html .= ' <input type="hidden" name="shared_question_id" id="shared_question_id" value="' . Security::remove_XSS($form_content['shared_question_id']) . '"/>'; $this->html .= ' <input type="hidden" name="type" id="type" value="' . Security::remove_XSS($_GET['type']) . '"/>'; // question field $this->html .= ' <div class="control-group">'; $this->html .= ' <label class="control-label">'; $this->html .= ' <span class="form_required">*</span> ' . get_lang('Question'); $this->html .= ' </label>'; $this->html .= ' <div class="controls">'; $this->html .= api_return_html_area('question', Security::remove_XSS($form_content['question'], STUDENT), '', '', null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120')); $this->html .= ' </div>'; $this->html .= ' </div>'; if ($survey_data['survey_type'] == 1) { $table_survey_question_group = Database::get_course_table(TABLE_SURVEY_QUESTION_GROUP); $sql = 'SELECT id,name FROM ' . $table_survey_question_group . ' WHERE survey_id = ' . (int) $_GET['survey_id'] . ' ORDER BY name'; $rs = Database::query($sql); $glist = null; while ($row = Database::fetch_array($rs, 'NUM')) { $glist .= '<option value="' . $row[0] . '" >' . $row[1] . '</option>'; } $grouplist = $grouplist1 = $grouplist2 = $glist; if (!empty($form_content['assigned'])) { $grouplist = str_replace('<option value="' . $form_content['assigned'] . '"', '<option value="' . $form_content['assigned'] . '" selected', $glist); } if (!empty($form_content['assigned1'])) { $grouplist1 = str_replace('<option value="' . $form_content['assigned1'] . '"', '<option value="' . $form_content['assigned1'] . '" selected', $glist); } if (!empty($form_content['assigned2'])) { $grouplist2 = str_replace('<option value="' . $form_content['assigned2'] . '"', '<option value="' . $form_content['assigned2'] . '" selected', $glist); } $this->html .= ' <tr><td colspan=""> <fieldset style="border:1px solid black"><legend>' . get_lang('Condition') . '</legend> <b>' . get_lang('Primary') . '</b><br /> ' . '<input type="radio" name="choose" value="1" ' . ($form_content['choose'] == 1 ? 'checked' : '') . '><select name="assigned">' . $grouplist . '</select><br />'; $this->html .= ' <b>' . get_lang('Secondary') . '</b><br /> ' . '<input type="radio" name="choose" value="2" ' . ($form_content['choose'] == 2 ? 'checked' : '') . '><select name="assigned1">' . $grouplist1 . '</select> ' . '<select name="assigned2">' . $grouplist2 . '</select>' . '</fieldset><br />'; } return $this->html; }