1 | <?php |
||||
2 | /* For licensing terms, see /license.txt */ |
||||
3 | |||||
4 | /** |
||||
5 | * Class ch_personality. |
||||
6 | */ |
||||
7 | class ch_personality extends survey_question |
||||
8 | { |
||||
9 | /** |
||||
10 | * This function creates the form elements for the multiple response questions. |
||||
11 | * |
||||
12 | * @author Patrick Cool <[email protected]>, Ghent University |
||||
13 | * |
||||
14 | * @version January 2007 |
||||
15 | */ |
||||
16 | public function createForm($survey_data, $form_content) |
||||
17 | { |
||||
18 | parent::createForm($survey_data, $form_content); |
||||
19 | $this->html .= ' <tr>'; |
||||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||||
20 | $this->html .= ' <td colspan="2"><strong>'.get_lang('DisplayAnswersHorVert').'</strong></td>'; |
||||
21 | $this->html .= ' </tr>'; |
||||
22 | // Horizontal or vertical |
||||
23 | $this->html .= ' <tr>'; |
||||
24 | $this->html .= ' <td align="right" valign="top"> </td>'; |
||||
25 | $this->html .= ' <td>'; |
||||
26 | $this->html .= ' <input name="horizontalvertical" type="radio" value="horizontal" '; |
||||
27 | if (empty($form_content['horizontalvertical']) || $form_content['horizontalvertical'] == 'horizontal') { |
||||
28 | $this->html .= 'checked="checked"'; |
||||
29 | } |
||||
30 | $this->html .= '/>'.get_lang('Horizontal').'</label><br />'; |
||||
31 | $this->html .= ' <input name="horizontalvertical" type="radio" value="vertical" '; |
||||
32 | |||||
33 | if (isset($form_content['horizontalvertical']) && $form_content['horizontalvertical'] == 'vertical') { |
||||
34 | $this->html .= 'checked="checked"'; |
||||
35 | } |
||||
36 | |||||
37 | $this->html .= ' />'.get_lang('Vertical').'</label>'; |
||||
38 | $this->html .= ' </td>'; |
||||
39 | $this->html .= ' <td> </td>'; |
||||
40 | $this->html .= ' </tr>'; |
||||
41 | $this->html .= ' <tr> |
||||
42 | <td colspan=""> </td> |
||||
43 | </tr>'; |
||||
44 | |||||
45 | // The options |
||||
46 | $this->html .= ' <tr>'; |
||||
47 | $this->html .= ' <td colspan="3"><strong>'.get_lang('AnswerOptions').'</strong></td>'; |
||||
48 | $this->html .= ' </tr>'; |
||||
49 | $total_number_of_answers = count($form_content['answers']); |
||||
50 | |||||
51 | $question_values = []; |
||||
52 | |||||
53 | // Values of question options |
||||
54 | if (is_array($form_content['values'])) { // Check if data is correct |
||||
55 | foreach ($form_content['values'] as $key => &$value) { |
||||
56 | $question_values[] = '<input size="3" type="text" id="values['.$key.']" name="values['.$key.']" value="'.$value.'" />'; |
||||
57 | } |
||||
58 | } |
||||
59 | $count = 0; |
||||
60 | if (is_array($form_content['answers'])) { |
||||
61 | foreach ($form_content['answers'] as $key => &$value) { |
||||
62 | $this->html .= '<tr>'; |
||||
63 | $this->html .= '<td align="right"><label for="answers['.$key.']">'.($key + 1).'</label></td>'; |
||||
64 | $this->html .= '<td width="550">'.api_return_html_area('answers['.$key.']', api_html_entity_decode(stripslashes($form_content['answers'][$key])), '', '', null, ['ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120']).'</td>'; |
||||
0 ignored issues
–
show
The function
api_return_html_area was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
65 | $this->html .= '<td>'; |
||||
66 | |||||
67 | if ($total_number_of_answers > 2) { |
||||
68 | $this->html .= $question_values[$count]; |
||||
69 | } |
||||
70 | |||||
71 | if ($key < $total_number_of_answers - 1) { |
||||
72 | $this->html .= '<input type="image" style="width:22px" src="'.Display::returnIconPath('down.png').'" value="move_down['.$key.']" name="move_down['.$key.']"/>'; |
||||
73 | } |
||||
74 | if ($key > 0) { |
||||
75 | $this->html .= '<input type="image" style="width:22px" src="'.Display::returnIconPath('up.png').'" value="move_up['.$key.']" name="move_up['.$key.']"/>'; |
||||
76 | } |
||||
77 | if ($total_number_of_answers > 2) { |
||||
78 | $this->html .= '<input type="image" style="width:22px" src="'.Display::returnIconPath('delete.png').'" value="delete_answer['.$key.']" name="delete_answer['.$key.']"/>'; |
||||
79 | } |
||||
80 | $this->html .= '</td>'; |
||||
81 | $this->html .= '</tr>'; |
||||
82 | $count++; |
||||
83 | } |
||||
84 | } |
||||
85 | } |
||||
86 | |||||
87 | /** |
||||
88 | * @param array $questionData |
||||
89 | * @param array $answers |
||||
90 | */ |
||||
91 | public function render(FormValidator $form, $questionData = [], $answers = []) |
||||
92 | { |
||||
93 | $question = new ch_yesno(); |
||||
94 | $question->render($form, $questionData, $answers); |
||||
95 | } |
||||
96 | } |
||||
97 |