Conditions | 13 |
Paths | 144 |
Total Lines | 67 |
Code Lines | 45 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
16 | public function createForm($survey_data, $form_content) |
||
17 | { |
||
18 | parent::createForm($survey_data, $form_content); |
||
19 | $this->html .= ' <tr>'; |
||
|
|||
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>'; |
||
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 | } |
||
97 |