Completed
Pull Request — 1.11.x (#1318)
by José
66:27 queued 30:05
created
main/survey/survey.php 1 patch
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 // Coach can't view this page
21 21
 $extend_rights_for_coachs = api_get_setting('extend_rights_for_coach_on_survey');
22 22
 $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
23
-	api_get_user_id(),
24
-	api_get_course_info()
23
+    api_get_user_id(),
24
+    api_get_course_info()
25 25
 );
26 26
 
27 27
 if ($isDrhOfCourse) {
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     (api_is_course_coach() && $extend_rights_for_coachs == 'false')
33 33
 ) {    
34 34
     api_not_allowed(true);
35
-	exit;
35
+    exit;
36 36
 }
37 37
 
38 38
 // Database table definitions
@@ -49,21 +49,21 @@  discard block
 block discarded – undo
49 49
 
50 50
 // Breadcrumbs
51 51
 $interbreadcrumb[] = array(
52
-		'url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php',
53
-		'name' => get_lang('SurveyList'),
52
+        'url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php',
53
+        'name' => get_lang('SurveyList'),
54 54
 );
55 55
 
56 56
 // Getting the survey information
57 57
 if (!empty($_GET['survey_id'])) {
58
-	$course_code = api_get_course_id();
59
-	if ($course_code!=-1) {
60
-		$survey_data = SurveyManager::get_survey($survey_id);
61
-	} else {
62
-		Display :: display_header(get_lang('ToolSurvey'));
63
-		Display :: display_error_message(get_lang('NotAllowed'), false);
64
-		Display :: display_footer();
65
-		exit;
66
-	}
58
+    $course_code = api_get_course_id();
59
+    if ($course_code!=-1) {
60
+        $survey_data = SurveyManager::get_survey($survey_id);
61
+    } else {
62
+        Display :: display_header(get_lang('ToolSurvey'));
63
+        Display :: display_error_message(get_lang('NotAllowed'), false);
64
+        Display :: display_footer();
65
+        exit;
66
+    }
67 67
 } else {
68 68
     Display :: display_header(get_lang('ToolSurvey'));
69 69
     Display :: display_error_message(get_lang('NotAllowed'), false);
@@ -76,30 +76,30 @@  discard block
 block discarded – undo
76 76
 $is_survey_type_1 = $survey_data['survey_type'] == 1;
77 77
 
78 78
 if (api_strlen(strip_tags($survey_data['title'])) > 40) {
79
-	$tool_name .= '...';
79
+    $tool_name .= '...';
80 80
 }
81 81
 
82 82
 if ($is_survey_type_1 && ($action == 'addgroup' || $action == 'deletegroup')) {
83
-	$_POST['name'] = trim($_POST['name']);
84
-	if ($action == 'addgroup') {
85
-		if (!empty($_POST['group_id'])) {
86
-			Database::query('UPDATE '.$table_survey_question_group.' SET description = \''.Database::escape_string($_POST['description']).'\'
83
+    $_POST['name'] = trim($_POST['name']);
84
+    if ($action == 'addgroup') {
85
+        if (!empty($_POST['group_id'])) {
86
+            Database::query('UPDATE '.$table_survey_question_group.' SET description = \''.Database::escape_string($_POST['description']).'\'
87 87
 			                 WHERE c_id = '.$course_id.' AND id = \''.Database::escape_string($_POST['group_id']).'\'');
88
-			$sendmsg = 'GroupUpdatedSuccessfully';
89
-		} elseif(!empty($_POST['name'])) {
90
-			Database::query('INSERT INTO '.$table_survey_question_group.' (c_id, name,description,survey_id) values ('.$course_id.', \''.Database::escape_string($_POST['name']).'\',\''.Database::escape_string($_POST['description']).'\',\''.Database::escape_string($survey_id).'\') ');
91
-			$sendmsg = 'GroupCreatedSuccessfully';
92
-		} else {
93
-			$sendmsg = 'GroupNeedName';
94
-		}
95
-	}
96
-
97
-	if ($action == 'deletegroup') {
98
-		Database::query('DELETE FROM '.$table_survey_question_group.' WHERE c_id = '.$course_id.' AND id = '.intval($_GET['gid']).' and survey_id = '.intval($survey_id));
99
-		$sendmsg = 'GroupDeletedSuccessfully';
100
-	}
101
-	header('Location: '.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&sendmsg='.$sendmsg);
102
-	exit;
88
+            $sendmsg = 'GroupUpdatedSuccessfully';
89
+        } elseif(!empty($_POST['name'])) {
90
+            Database::query('INSERT INTO '.$table_survey_question_group.' (c_id, name,description,survey_id) values ('.$course_id.', \''.Database::escape_string($_POST['name']).'\',\''.Database::escape_string($_POST['description']).'\',\''.Database::escape_string($survey_id).'\') ');
91
+            $sendmsg = 'GroupCreatedSuccessfully';
92
+        } else {
93
+            $sendmsg = 'GroupNeedName';
94
+        }
95
+    }
96
+
97
+    if ($action == 'deletegroup') {
98
+        Database::query('DELETE FROM '.$table_survey_question_group.' WHERE c_id = '.$course_id.' AND id = '.intval($_GET['gid']).' and survey_id = '.intval($survey_id));
99
+        $sendmsg = 'GroupDeletedSuccessfully';
100
+    }
101
+    header('Location: '.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&sendmsg='.$sendmsg);
102
+    exit;
103 103
 }
104 104
 
105 105
 // Displaying the header
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
 $message_information    = isset($_GET['message']) ? Security::remove_XSS($_GET['message']) : null;
114 114
 
115 115
 if (isset($action)) {
116
-	if (($action == 'moveup' || $action == 'movedown') && isset($_GET['question_id'])) {
117
-		SurveyManager::move_survey_question($my_action_survey,$my_question_id_survey,$my_survey_id_survey);
118
-		Display::display_confirmation_message(get_lang('SurveyQuestionMoved'));
119
-	}
120
-	if ($action == 'delete' AND is_numeric($_GET['question_id'])) {
121
-		SurveyManager::delete_survey_question($my_survey_id_survey, $my_question_id_survey, $survey_data['is_shared']);
122
-	}
116
+    if (($action == 'moveup' || $action == 'movedown') && isset($_GET['question_id'])) {
117
+        SurveyManager::move_survey_question($my_action_survey,$my_question_id_survey,$my_survey_id_survey);
118
+        Display::display_confirmation_message(get_lang('SurveyQuestionMoved'));
119
+    }
120
+    if ($action == 'delete' AND is_numeric($_GET['question_id'])) {
121
+        SurveyManager::delete_survey_question($my_survey_id_survey, $my_question_id_survey, $survey_data['is_shared']);
122
+    }
123 123
 }
124 124
 
125 125
 if (!empty($survey_data['survey_version'])) echo '<b>'.get_lang('Version').': '.$survey_data['survey_version'].'</b>';
@@ -137,26 +137,26 @@  discard block
 block discarded – undo
137 137
 echo '<div class="actions">'.$survey_actions.'</div>';
138 138
 
139 139
 if ($survey_data['survey_type'] == 0) {
140
-	echo '<div class="panel panel-default">';
140
+    echo '<div class="panel panel-default">';
141 141
         echo '<div class="panel-body">';
142
-	echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=yesno&amp;survey_id='.$survey_id.'">'.Display::return_icon('yesno.png', get_lang('YesNo'), null, ICON_SIZE_BIG).'</a>';
143
-	echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=multiplechoice&amp;survey_id='.$survey_id.'">'.Display::return_icon('mcua.png', get_lang('UniqueSelect'), null, ICON_SIZE_BIG).'</a>';
144
-	echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=multipleresponse&amp;survey_id='.$survey_id.'">'.Display::return_icon('mcma.png', get_lang('MultipleResponse'), null, ICON_SIZE_BIG).'</a>';
145
-	echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=open&amp;survey_id='.$survey_id.'">'.Display::return_icon('open_answer.png', get_lang('Open'), null, ICON_SIZE_BIG).'</a>';
146
-	echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=dropdown&amp;survey_id='.$survey_id.'">'.Display::return_icon('dropdown.png', get_lang('Dropdown'), null, ICON_SIZE_BIG).'</a>';
147
-	echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=percentage&amp;survey_id='.$survey_id.'">'.Display::return_icon('percentagequestion.png', get_lang('Percentage'), null, ICON_SIZE_BIG).'</a>';
148
-	echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=score&amp;survey_id='.$survey_id.'">'.Display::return_icon('scorequestion.png', get_lang('Score'), null, ICON_SIZE_BIG).'</a>';
149
-	echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=comment&amp;survey_id='.$survey_id.'">'.Display::return_icon('commentquestion.png', get_lang('Comment'), null, ICON_SIZE_BIG).'</a>';
150
-	echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=pagebreak&amp;survey_id='.$survey_id.'">'.Display::return_icon('page_end.png', get_lang('Pagebreak'), null, ICON_SIZE_BIG).'</a>';
151
-	echo '</div>';
142
+    echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=yesno&amp;survey_id='.$survey_id.'">'.Display::return_icon('yesno.png', get_lang('YesNo'), null, ICON_SIZE_BIG).'</a>';
143
+    echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=multiplechoice&amp;survey_id='.$survey_id.'">'.Display::return_icon('mcua.png', get_lang('UniqueSelect'), null, ICON_SIZE_BIG).'</a>';
144
+    echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=multipleresponse&amp;survey_id='.$survey_id.'">'.Display::return_icon('mcma.png', get_lang('MultipleResponse'), null, ICON_SIZE_BIG).'</a>';
145
+    echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=open&amp;survey_id='.$survey_id.'">'.Display::return_icon('open_answer.png', get_lang('Open'), null, ICON_SIZE_BIG).'</a>';
146
+    echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=dropdown&amp;survey_id='.$survey_id.'">'.Display::return_icon('dropdown.png', get_lang('Dropdown'), null, ICON_SIZE_BIG).'</a>';
147
+    echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=percentage&amp;survey_id='.$survey_id.'">'.Display::return_icon('percentagequestion.png', get_lang('Percentage'), null, ICON_SIZE_BIG).'</a>';
148
+    echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=score&amp;survey_id='.$survey_id.'">'.Display::return_icon('scorequestion.png', get_lang('Score'), null, ICON_SIZE_BIG).'</a>';
149
+    echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=comment&amp;survey_id='.$survey_id.'">'.Display::return_icon('commentquestion.png', get_lang('Comment'), null, ICON_SIZE_BIG).'</a>';
150
+    echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=pagebreak&amp;survey_id='.$survey_id.'">'.Display::return_icon('page_end.png', get_lang('Pagebreak'), null, ICON_SIZE_BIG).'</a>';
151
+    echo '</div>';
152 152
         echo '</div>';
153 153
 } else {
154
-	echo '<div class="panel panel-default">';
154
+    echo '<div class="panel panel-default">';
155 155
         echo '<div class="panel-body">';
156
-	echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=personality&amp;survey_id='.$survey_id.'">';
157
-	echo Display::return_icon("yesno.png");
158
-	echo '</a></div>';
159
-	echo '</div>';
156
+    echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=personality&amp;survey_id='.$survey_id.'">';
157
+    echo Display::return_icon("yesno.png");
158
+    echo '</a></div>';
159
+    echo '</div>';
160 160
         echo '</div>';
161 161
 }
162 162
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 echo '		<th width="50" >'.get_lang('NumberOfOptions').'</th>';
170 170
 echo '		<th width="100">'.get_lang('Modify').'</th>';
171 171
 if ($is_survey_type_1) {
172
-	echo '<th width="100">'.get_lang('Condition').'</th>';
172
+    echo '<th width="100">'.get_lang('Condition').'</th>';
173 173
     echo '<th width="40">'.get_lang('Group').'</th>';
174 174
 }
175 175
 echo '	</tr>';
@@ -196,97 +196,97 @@  discard block
 block discarded – undo
196 196
 $result = Database::query($sql);
197 197
 $question_counter_max = Database::num_rows($result);
198 198
 while ($row = Database::fetch_array($result, 'ASSOC')) {
199
-	echo '<tr>';
200
-	echo '	<td>'.$question_counter.'</td>';
201
-	echo '	<td>';
202
-	if (api_strlen($row['survey_question']) > 100) {
203
-		echo api_substr(strip_tags($row['survey_question']), 0, 100).' ... ';
204
-	} else {
205
-		echo $row['survey_question'];
206
-	}
207
-
208
-	if ($row['type'] == 'yesno') {
209
-		$tool_name = get_lang('YesNo');
210
-	} else if ($row['type'] == 'multiplechoice') {
211
-		$tool_name = get_lang('UniqueSelect');
212
-	} else {
213
-		$tool_name = get_lang(api_ucfirst(Security::remove_XSS($row['type'])));
214
-	}
215
-
216
-	echo '</td>';
217
-	echo '	<td>'.$tool_name.'</td>';
218
-	echo '	<td>'.$row['number_of_options'].'</td>';
219
-	echo '	<td>';
220
-	echo '		<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=edit&amp;type='.$row['type'].'&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'">'.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>';
221
-	echo '		<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&amp;action=delete&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurveyQuestion").'?',ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
222
-	if ($question_counter > 1) {
223
-		echo '		<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&amp;action=moveup&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'">'.Display::return_icon('up.png', get_lang('MoveUp'),'',ICON_SIZE_SMALL).'</a>';
224
-	} else {
225
-		Display::display_icon('up_na.png','&nbsp;','',ICON_SIZE_SMALL);
226
-	}
227
-	if ($question_counter < $question_counter_max) {
228
-		echo '		<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&amp;action=movedown&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'">'.Display::return_icon('down.png', get_lang('MoveDown'),'',ICON_SIZE_SMALL).'</a>';
229
-	} else {
230
-		Display::display_icon('down_na.png','&nbsp;','',ICON_SIZE_SMALL);
231
-	}
232
-	echo '	</td>';
233
-	$question_counter++;
234
-
235
-	if ($is_survey_type_1) {
236
-    	echo '<td>'.(($row['survey_group_pri']==0)?get_lang('Secondary'):get_lang('Primary')).'</td>';
199
+    echo '<tr>';
200
+    echo '	<td>'.$question_counter.'</td>';
201
+    echo '	<td>';
202
+    if (api_strlen($row['survey_question']) > 100) {
203
+        echo api_substr(strip_tags($row['survey_question']), 0, 100).' ... ';
204
+    } else {
205
+        echo $row['survey_question'];
206
+    }
207
+
208
+    if ($row['type'] == 'yesno') {
209
+        $tool_name = get_lang('YesNo');
210
+    } else if ($row['type'] == 'multiplechoice') {
211
+        $tool_name = get_lang('UniqueSelect');
212
+    } else {
213
+        $tool_name = get_lang(api_ucfirst(Security::remove_XSS($row['type'])));
214
+    }
215
+
216
+    echo '</td>';
217
+    echo '	<td>'.$tool_name.'</td>';
218
+    echo '	<td>'.$row['number_of_options'].'</td>';
219
+    echo '	<td>';
220
+    echo '		<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=edit&amp;type='.$row['type'].'&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'">'.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>';
221
+    echo '		<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&amp;action=delete&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurveyQuestion").'?',ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
222
+    if ($question_counter > 1) {
223
+        echo '		<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&amp;action=moveup&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'">'.Display::return_icon('up.png', get_lang('MoveUp'),'',ICON_SIZE_SMALL).'</a>';
224
+    } else {
225
+        Display::display_icon('up_na.png','&nbsp;','',ICON_SIZE_SMALL);
226
+    }
227
+    if ($question_counter < $question_counter_max) {
228
+        echo '		<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&amp;action=movedown&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'">'.Display::return_icon('down.png', get_lang('MoveDown'),'',ICON_SIZE_SMALL).'</a>';
229
+    } else {
230
+        Display::display_icon('down_na.png','&nbsp;','',ICON_SIZE_SMALL);
231
+    }
232
+    echo '	</td>';
233
+    $question_counter++;
234
+
235
+    if ($is_survey_type_1) {
236
+        echo '<td>'.(($row['survey_group_pri']==0)?get_lang('Secondary'):get_lang('Primary')).'</td>';
237 237
         echo '<td>'.(($row['survey_group_pri']==0)?$groups[$row['survey_group_sec1']].'-'.$groups[$row['survey_group_sec2']]:$groups[$row['survey_group_pri']]).'</td>';
238 238
     }
239
-	echo '</tr>';
239
+    echo '</tr>';
240 240
 }
241 241
 
242 242
 echo '</table>';
243 243
 
244 244
 if ($is_survey_type_1) {
245
-	echo '<br /><br /><b>'.get_lang('ManageGroups').'</b><br /><br />';
246
-
247
-	if (in_array($_GET['sendmsg'], array('GroupUpdatedSuccessfully', 'GroupDeletedSuccessfully', 'GroupCreatedSuccessfully'))) {
248
-		echo Display::display_confirmation_message(get_lang($_GET['sendmsg']), false);
249
-	}
250
-
251
-	if (in_array($_GET['sendmsg'], array('GroupNeedName'))){
252
-		echo Display::display_warning_message(get_lang($_GET['sendmsg']), false);
253
-	}
254
-	echo '<table border="0"><tr><td width="100">'.get_lang('Name').'</td><td>'.get_lang('Description').'</td></tr></table>';
255
-	echo '<form action="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?action=addgroup&survey_id='.$survey_id.'" method="post">';
256
-	if ($_GET['action'] == 'editgroup') {
257
-		$sql = 'SELECT name,description FROM '.$table_survey_question_group.' WHERE id = '.intval($_GET['gid']).' AND survey_id = '.intval($survey_id).' limit 1';
258
-		$rs = Database::query($sql);
259
-		$editedrow = Database::fetch_array($rs,'ASSOC');
260
-		echo	'<input type="text" maxlength="20" name="name" value="'.$editedrow['name'].'" size="10" disabled>';
261
-		echo	'<input type="text" maxlength="150" name="description" value="'.$editedrow['description'].'" size="40">';
262
-		echo	'<input type="hidden" name="group_id" value="'.Security::remove_XSS($_GET['gid']).'">';
263
-		echo	'<input type="submit" value="'.get_lang('Save').'"'.'<input type="button" value="'.get_lang('Cancel').'" onclick="window.location.href = \'survey.php?survey_id='.Security::remove_XSS($survey_id).'\';" />';
264
-	} else {
265
-		echo	'<input type="text" maxlength="20" name="name" value="" size="10">';
266
-		echo	'<input type="text" maxlength="250" name="description" value="" size="80">';
267
-		echo	'<input type="submit" value="'.get_lang('Create').'"';
268
-	}
269
-	echo	'</form><br />';
270
-
271
-	echo '<table class="data_table">';
272
-	echo '	<tr class="row_odd">';
273
-	echo '		<th width="200">'.get_lang('Name').'</th>';
274
-	echo '		<th>'.get_lang('Description').'</th>';
275
-	echo '		<th width="100">'.get_lang('Modify').'</th>';
276
-	echo '	</tr>';
277
-
278
-	$sql = 'SELECT id,name,description FROM '.$table_survey_question_group.' WHERE c_id = '.$course_id.' AND survey_id = '.intval($survey_id).' ORDER BY name';
279
-
280
-	$rs = Database::query($sql);
281
-	while($row = Database::fetch_array($rs,ASSOC)){
282
-		$grouplist .= '<tr><td>'.$row['name'].'</td><td>'.$row['description'].'</td><td>'.
283
-		'<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=editgroup">'.
284
-		Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a> '.
285
-		'<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=deletegroup" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('DeleteSurveyGroup'),$row['name']).'?',ENT_QUOTES)).'\')) return false;">'.
286
-		Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'.
287
-		'</td></tr>';
288
-	}
289
-	echo $grouplist.'</table>';
245
+    echo '<br /><br /><b>'.get_lang('ManageGroups').'</b><br /><br />';
246
+
247
+    if (in_array($_GET['sendmsg'], array('GroupUpdatedSuccessfully', 'GroupDeletedSuccessfully', 'GroupCreatedSuccessfully'))) {
248
+        echo Display::display_confirmation_message(get_lang($_GET['sendmsg']), false);
249
+    }
250
+
251
+    if (in_array($_GET['sendmsg'], array('GroupNeedName'))){
252
+        echo Display::display_warning_message(get_lang($_GET['sendmsg']), false);
253
+    }
254
+    echo '<table border="0"><tr><td width="100">'.get_lang('Name').'</td><td>'.get_lang('Description').'</td></tr></table>';
255
+    echo '<form action="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?action=addgroup&survey_id='.$survey_id.'" method="post">';
256
+    if ($_GET['action'] == 'editgroup') {
257
+        $sql = 'SELECT name,description FROM '.$table_survey_question_group.' WHERE id = '.intval($_GET['gid']).' AND survey_id = '.intval($survey_id).' limit 1';
258
+        $rs = Database::query($sql);
259
+        $editedrow = Database::fetch_array($rs,'ASSOC');
260
+        echo	'<input type="text" maxlength="20" name="name" value="'.$editedrow['name'].'" size="10" disabled>';
261
+        echo	'<input type="text" maxlength="150" name="description" value="'.$editedrow['description'].'" size="40">';
262
+        echo	'<input type="hidden" name="group_id" value="'.Security::remove_XSS($_GET['gid']).'">';
263
+        echo	'<input type="submit" value="'.get_lang('Save').'"'.'<input type="button" value="'.get_lang('Cancel').'" onclick="window.location.href = \'survey.php?survey_id='.Security::remove_XSS($survey_id).'\';" />';
264
+    } else {
265
+        echo	'<input type="text" maxlength="20" name="name" value="" size="10">';
266
+        echo	'<input type="text" maxlength="250" name="description" value="" size="80">';
267
+        echo	'<input type="submit" value="'.get_lang('Create').'"';
268
+    }
269
+    echo	'</form><br />';
270
+
271
+    echo '<table class="data_table">';
272
+    echo '	<tr class="row_odd">';
273
+    echo '		<th width="200">'.get_lang('Name').'</th>';
274
+    echo '		<th>'.get_lang('Description').'</th>';
275
+    echo '		<th width="100">'.get_lang('Modify').'</th>';
276
+    echo '	</tr>';
277
+
278
+    $sql = 'SELECT id,name,description FROM '.$table_survey_question_group.' WHERE c_id = '.$course_id.' AND survey_id = '.intval($survey_id).' ORDER BY name';
279
+
280
+    $rs = Database::query($sql);
281
+    while($row = Database::fetch_array($rs,ASSOC)){
282
+        $grouplist .= '<tr><td>'.$row['name'].'</td><td>'.$row['description'].'</td><td>'.
283
+        '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=editgroup">'.
284
+        Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a> '.
285
+        '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=deletegroup" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('DeleteSurveyGroup'),$row['name']).'?',ENT_QUOTES)).'\')) return false;">'.
286
+        Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'.
287
+        '</td></tr>';
288
+    }
289
+    echo $grouplist.'</table>';
290 290
 }
291 291
 
292 292
 Session::erase('answer_count');
Please login to merge, or discard this patch.
main/survey/preview.php 1 patch
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 // We exit here if there is no valid $_GET parameter
45 45
 if (!isset($_GET['survey_id']) || !is_numeric($_GET['survey_id'])) {
46 46
     api_not_allowed(true, Display::return_message(get_lang('InvallidSurvey'), 'error', false));
47
-	exit;
47
+    exit;
48 48
 }
49 49
 
50 50
 // Getting the survey information
@@ -53,13 +53,13 @@  discard block
 block discarded – undo
53 53
 
54 54
 if (empty($survey_data)) {
55 55
     api_not_allowed(true, Display::return_message(get_lang('InvallidSurvey'), 'error', false));
56
-	exit;
56
+    exit;
57 57
 }
58 58
 
59 59
 $urlname = strip_tags($survey_data['title']);
60 60
 if (api_is_allowed_to_edit()) {
61
-	// Breadcrumbs
62
-	$interbreadcrumb[] = array(
61
+    // Breadcrumbs
62
+    $interbreadcrumb[] = array(
63 63
         'url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq(),
64 64
         'name' => get_lang('SurveyList')
65 65
     );
@@ -86,57 +86,57 @@  discard block
 block discarded – undo
86 86
 $counter_question = 0;
87 87
 // Only a course admin is allowed to preview a survey: you are a course admin
88 88
 if (api_is_course_admin() ||
89
-	(api_is_course_admin() && $_GET['isStudentView'] == 'true') ||
90
-	api_is_allowed_to_session_edit(false, true)
89
+    (api_is_course_admin() && $_GET['isStudentView'] == 'true') ||
90
+    api_is_allowed_to_session_edit(false, true)
91 91
 ) {
92
-	// Survey information
93
-	echo '<div id="survey_title">'.$survey_data['survey_title'].'</div>';
94
-	echo '<div id="survey_subtitle">'.$survey_data['survey_subtitle'].'</div>';
92
+    // Survey information
93
+    echo '<div id="survey_title">'.$survey_data['survey_title'].'</div>';
94
+    echo '<div id="survey_subtitle">'.$survey_data['survey_subtitle'].'</div>';
95 95
 
96
-	// Displaying the survey introduction
97
-	if (!isset($_GET['show'])) {
96
+    // Displaying the survey introduction
97
+    if (!isset($_GET['show'])) {
98 98
         if (!empty($survey_data['survey_introduction'])) {
99 99
             echo '<div id="survey_content" class="survey_content">'.$survey_data['survey_introduction'].'</div>';
100 100
         }
101
-		$limit = 0;
102
-	}
101
+        $limit = 0;
102
+    }
103 103
 
104
-	// Displaying the survey thanks message
105
-	if (isset($_POST['finish_survey'])) {
106
-		Display::display_confirmation_message(get_lang('SurveyFinished'));
104
+    // Displaying the survey thanks message
105
+    if (isset($_POST['finish_survey'])) {
106
+        Display::display_confirmation_message(get_lang('SurveyFinished'));
107 107
         echo $survey_data['survey_thanks'];
108
-		Display :: display_footer();
109
-		exit;
110
-	}
108
+        Display :: display_footer();
109
+        exit;
110
+    }
111 111
 
112 112
     $questions = array();
113 113
 
114
-	if (isset($_GET['show'])) {
115
-		// Getting all the questions for this page and add them to a
116
-		// multidimensional array where the first index is the page.
117
-		// as long as there is no pagebreak fount we keep adding questions to the page
118
-		$questions_displayed = array();
119
-		$paged_questions = array();
120
-		$counter = 0;
121
-		$sql = "SELECT * FROM $table_survey_question
114
+    if (isset($_GET['show'])) {
115
+        // Getting all the questions for this page and add them to a
116
+        // multidimensional array where the first index is the page.
117
+        // as long as there is no pagebreak fount we keep adding questions to the page
118
+        $questions_displayed = array();
119
+        $paged_questions = array();
120
+        $counter = 0;
121
+        $sql = "SELECT * FROM $table_survey_question
122 122
 		        WHERE c_id = $course_id AND survey_id = '".intval($survey_id)."'
123 123
 				ORDER BY sort ASC";
124
-		$result = Database::query($sql);
124
+        $result = Database::query($sql);
125 125
         $questions_exists = true;
126 126
         if (Database::num_rows($result)) {
127
-    		while ($row = Database::fetch_array($result)) {
128
-    			if ($row['type'] == 'pagebreak') {
129
-    				$counter++;
130
-    			} else {
131
-    				$paged_questions[$counter][] = $row['question_id'];
132
-    			}
133
-    		}
127
+            while ($row = Database::fetch_array($result)) {
128
+                if ($row['type'] == 'pagebreak') {
129
+                    $counter++;
130
+                } else {
131
+                    $paged_questions[$counter][] = $row['question_id'];
132
+                }
133
+            }
134 134
         } else {
135 135
             $questions_exists = false;
136 136
         }
137 137
 
138
-		if (array_key_exists($_GET['show'], $paged_questions)) {
139
-			$sql = "SELECT
138
+        if (array_key_exists($_GET['show'], $paged_questions)) {
139
+            $sql = "SELECT
140 140
                         survey_question.question_id,
141 141
                         survey_question.survey_id,
142 142
                         survey_question.survey_question,
@@ -158,75 +158,75 @@  discard block
 block discarded – undo
158 158
 						survey_question.c_id =  $course_id
159 159
 					ORDER BY survey_question.sort, survey_question_option.sort ASC";
160 160
 
161
-			$result = Database::query($sql);
162
-			$question_counter_max = Database::num_rows($result);
163
-			$limit = 0;
164
-			while ($row = Database::fetch_array($result)) {
165
-				// If the type is not a pagebreak we store it in the $questions array
166
-				if ($row['type'] != 'pagebreak') {
167
-					$questions[$row['sort']]['question_id'] = $row['question_id'];
168
-					$questions[$row['sort']]['survey_id'] = $row['survey_id'];
169
-					$questions[$row['sort']]['survey_question'] = $row['survey_question'];
170
-					$questions[$row['sort']]['display'] = $row['display'];
171
-					$questions[$row['sort']]['type'] = $row['type'];
172
-					$questions[$row['sort']]['options'][intval($row['option_sort'])] = $row['option_text'];
173
-					$questions[$row['sort']]['maximum_score'] = $row['max_value'];
174
-				} else {
175
-					// If the type is a pagebreak we are finished loading the questions for this page
176
-					break;
177
-				}
178
-				$counter_question++;
179
-			}
180
-		}
181
-	}
182
-
183
-	// Selecting the maximum number of pages
184
-	$sql = "SELECT * FROM $table_survey_question
161
+            $result = Database::query($sql);
162
+            $question_counter_max = Database::num_rows($result);
163
+            $limit = 0;
164
+            while ($row = Database::fetch_array($result)) {
165
+                // If the type is not a pagebreak we store it in the $questions array
166
+                if ($row['type'] != 'pagebreak') {
167
+                    $questions[$row['sort']]['question_id'] = $row['question_id'];
168
+                    $questions[$row['sort']]['survey_id'] = $row['survey_id'];
169
+                    $questions[$row['sort']]['survey_question'] = $row['survey_question'];
170
+                    $questions[$row['sort']]['display'] = $row['display'];
171
+                    $questions[$row['sort']]['type'] = $row['type'];
172
+                    $questions[$row['sort']]['options'][intval($row['option_sort'])] = $row['option_text'];
173
+                    $questions[$row['sort']]['maximum_score'] = $row['max_value'];
174
+                } else {
175
+                    // If the type is a pagebreak we are finished loading the questions for this page
176
+                    break;
177
+                }
178
+                $counter_question++;
179
+            }
180
+        }
181
+    }
182
+
183
+    // Selecting the maximum number of pages
184
+    $sql = "SELECT * FROM $table_survey_question
185 185
 	        WHERE
186 186
 	            c_id = $course_id AND
187 187
 	            type='".Database::escape_string('pagebreak')."' AND
188 188
 	            survey_id='".intval($survey_id)."'";
189
-	$result = Database::query($sql);
190
-	$numberofpages = Database::num_rows($result) + 1;
191
-
192
-	// Displaying the form with the questions
193
-	if (isset($_GET['show'])) {
194
-		$show = (int)$_GET['show'] + 1;
195
-	} else {
196
-		$show = 0;
197
-	}
198
-
199
-	$url = api_get_self().'?survey_id='.Security::remove_XSS($survey_id).'&show='.$show;
200
-	$form = new FormValidator('question', 'post', $url);
201
-
202
-	if (is_array($questions) && count($questions) > 0) {
203
-		foreach ($questions as $key => & $question) {
204
-			$ch_type = 'ch_'.$question['type'];
205
-			/** @var survey_question $display */
206
-			$display = new $ch_type;
207
-			$form->addHtml('<div class="survey_question_wrapper"><div class="survey_question">');
208
-			$form->addHtml($question['survey_question']);
209
-			$display->render($form, $question);
210
-			$form->addHtml('</div></div>');
211
-		}
212
-	}
213
-
214
-	if (($show < $numberofpages) || (!$_GET['show'] && count($questions) > 0)) {
189
+    $result = Database::query($sql);
190
+    $numberofpages = Database::num_rows($result) + 1;
191
+
192
+    // Displaying the form with the questions
193
+    if (isset($_GET['show'])) {
194
+        $show = (int)$_GET['show'] + 1;
195
+    } else {
196
+        $show = 0;
197
+    }
198
+
199
+    $url = api_get_self().'?survey_id='.Security::remove_XSS($survey_id).'&show='.$show;
200
+    $form = new FormValidator('question', 'post', $url);
201
+
202
+    if (is_array($questions) && count($questions) > 0) {
203
+        foreach ($questions as $key => & $question) {
204
+            $ch_type = 'ch_'.$question['type'];
205
+            /** @var survey_question $display */
206
+            $display = new $ch_type;
207
+            $form->addHtml('<div class="survey_question_wrapper"><div class="survey_question">');
208
+            $form->addHtml($question['survey_question']);
209
+            $display->render($form, $question);
210
+            $form->addHtml('</div></div>');
211
+        }
212
+    }
213
+
214
+    if (($show < $numberofpages) || (!$_GET['show'] && count($questions) > 0)) {
215 215
         if ($show == 0) {
216
-			$form->addButton('next_survey_page', get_lang('StartSurvey'), 'arrow-right', 'success', 'large');
216
+            $form->addButton('next_survey_page', get_lang('StartSurvey'), 'arrow-right', 'success', 'large');
217 217
         } else {
218
-			$form->addButton('next_survey_page', get_lang('NextQuestion'), 'arrow-right');
218
+            $form->addButton('next_survey_page', get_lang('NextQuestion'), 'arrow-right');
219 219
         }
220
-	}
221
-	if ($show >= $numberofpages && $_GET['show'] || (isset($_GET['show']) && count($questions) == 0)) {
222
-		if ($questions_exists == false) {
223
-			echo '<p>'.get_lang('ThereAreNotQuestionsForthisSurvey').'</p>';
224
-		}
225
-		$form->addButton('finish_survey', get_lang('FinishSurvey'), 'arrow-right');
226
-	}
227
-	$form->display();
220
+    }
221
+    if ($show >= $numberofpages && $_GET['show'] || (isset($_GET['show']) && count($questions) == 0)) {
222
+        if ($questions_exists == false) {
223
+            echo '<p>'.get_lang('ThereAreNotQuestionsForthisSurvey').'</p>';
224
+        }
225
+        $form->addButton('finish_survey', get_lang('FinishSurvey'), 'arrow-right');
226
+    }
227
+    $form->display();
228 228
 } else {
229
-	Display :: display_error_message(get_lang('NotAllowed'), false);
229
+    Display :: display_error_message(get_lang('NotAllowed'), false);
230 230
 }
231 231
 
232 232
 Display :: display_footer();
Please login to merge, or discard this patch.
src/Chamilo/TicketBundle/Entity/Ticket.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -94,12 +94,12 @@
 block discarded – undo
94 94
      */
95 95
     protected $assignedLastUser;
96 96
 
97
-     /**
98
-     * @var Status
99
-     *
100
-     * @ORM\ManyToOne(targetEntity="Chamilo\TicketBundle\Entity\Status")
101
-     * @ORM\JoinColumn(name="status_id", referencedColumnName="id")
102
-     **/
97
+        /**
98
+         * @var Status
99
+         *
100
+         * @ORM\ManyToOne(targetEntity="Chamilo\TicketBundle\Entity\Status")
101
+         * @ORM\JoinColumn(name="status_id", referencedColumnName="id")
102
+         **/
103 103
     protected $status;
104 104
 
105 105
     /**
Please login to merge, or discard this patch.
src/Chamilo/TicketBundle/Entity/MessageAttachment.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
      */
57 57
     protected $filename;
58 58
 
59
-   /**
59
+    /**
60 60
      * @var integer
61 61
      *
62 62
      * @ORM\Column(name="size", type="integer", nullable=false, unique=false)
Please login to merge, or discard this patch.
plugin/courseblock/CourseBlockPlugin.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
     // When creating a new course this settings are added to the course
12 12
     public $course_settings = array(
13
-         array(
13
+            array(
14 14
             'name' => 'course_block_pre_footer',
15 15
             'type' => 'textarea'
16 16
         ),
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
     }
67 67
 
68 68
         /**
69
-     * @param string $region
70
-     * @return string
71
-     */
69
+         * @param string $region
70
+         * @return string
71
+         */
72 72
     public function renderRegion($region)
73 73
     {
74 74
         $content = '';
Please login to merge, or discard this patch.
src/Chamilo/TicketBundle/Entity/Message.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -53,12 +53,12 @@
 block discarded – undo
53 53
      */
54 54
     protected $ipAddress;
55 55
 
56
-     /**
57
-     * @var Ticket
58
-     *
59
-     * @ORM\ManyToOne(targetEntity="Chamilo\TicketBundle\Entity\Ticket")
60
-     * @ORM\JoinColumn(name="ticket_id", referencedColumnName="id")
61
-     **/
56
+        /**
57
+         * @var Ticket
58
+         *
59
+         * @ORM\ManyToOne(targetEntity="Chamilo\TicketBundle\Entity\Ticket")
60
+         * @ORM\JoinColumn(name="ticket_id", referencedColumnName="id")
61
+         **/
62 62
     protected $ticket;
63 63
 
64 64
     /**
Please login to merge, or discard this patch.
main/ticket/assign_tickets.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 
11 11
 api_protect_course_script();
12 12
 if (!api_is_allowed_to_edit()) {
13
-	api_not_allowed();
13
+    api_not_allowed();
14 14
 }
15 15
 $course_info = api_get_course_info();
16 16
 $course_code = $course_info['code'];
Please login to merge, or discard this patch.
main/ticket/new_ticket.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -563,7 +563,7 @@
 block discarded – undo
563 563
         $photo = '<img src="' . $userPicture. '" alt="' . api_get_person_name($user[2], $user[3]) . '" title="' . api_get_person_name($user[2], $user[3]) . '" />';
564 564
         $button = '<a  href="javascript:void(0)" onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ', \'' . $user[5] . '\')">'
565 565
                     . Display::return_icon('view_more_stats.gif', get_lang('Info')) .
566
-                   '</a>&nbsp;&nbsp;';
566
+                    '</a>&nbsp;&nbsp;';
567 567
         $users[] = array(
568 568
             $photo,
569 569
             $user_id,
Please login to merge, or discard this patch.
main/ticket/ticket_details.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 
353 353
     foreach ($admins as $admin) {
354 354
         $select_admins.= "<option value = '" . $admin['user_id'] . "' " . (($user_id == $admin['user_id']) ? ("selected='selected'") : '') . ">" .
355
-           $admin['complete_name'] . "</option>";
355
+            $admin['complete_name'] . "</option>";
356 356
     }
357 357
     $select_admins .= "</select>";
358 358
     echo '<div id="dialog-form" title="' . $plugin->get_lang('AssignTicket') . '" >';
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
         $form->addElement(
549 549
             'checkbox',
550 550
             'confirmation',
551
-             null,
551
+                null,
552 552
             $plugin->get_lang('RequestConfirmation')
553 553
         );
554 554
     }
Please login to merge, or discard this patch.