@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | |
14 | 14 | /** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/ |
15 | 15 | if (!api_is_allowed_to_edit(false, true)) { |
16 | - Display :: display_header(get_lang('ToolSurvey')); |
|
17 | - Display :: display_error_message(get_lang('NotAllowed'), false); |
|
18 | - Display :: display_footer(); |
|
19 | - exit; |
|
16 | + Display :: display_header(get_lang('ToolSurvey')); |
|
17 | + Display :: display_error_message(get_lang('NotAllowed'), false); |
|
18 | + Display :: display_footer(); |
|
19 | + exit; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | // Database table definitions |
@@ -33,25 +33,25 @@ discard block |
||
33 | 33 | // Getting the survey information |
34 | 34 | // We exit here if ther is no valid $_GET parameter |
35 | 35 | if (!isset($_GET['survey_id']) OR !is_numeric($_GET['survey_id'])) { |
36 | - Display :: display_header($tool_name); |
|
37 | - Display :: display_error_message(get_lang('InvallidSurvey'), false); |
|
38 | - Display :: display_footer(); |
|
39 | - exit; |
|
36 | + Display :: display_header($tool_name); |
|
37 | + Display :: display_error_message(get_lang('InvallidSurvey'), false); |
|
38 | + Display :: display_footer(); |
|
39 | + exit; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | $survey_id = Security::remove_XSS($_GET['survey_id']); |
43 | 43 | $survey_data = SurveyManager::get_survey($survey_id); |
44 | 44 | |
45 | 45 | if (empty($survey_data)) { |
46 | - Display :: display_header($tool_name); |
|
47 | - Display :: display_error_message(get_lang('InvallidSurvey'), false); |
|
48 | - Display :: display_footer(); |
|
49 | - exit; |
|
46 | + Display :: display_header($tool_name); |
|
47 | + Display :: display_error_message(get_lang('InvallidSurvey'), false); |
|
48 | + Display :: display_footer(); |
|
49 | + exit; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $urlname = strip_tags(api_substr(api_html_entity_decode($survey_data['title'], ENT_QUOTES), 0, 40)); |
53 | 53 | if (api_strlen(strip_tags($survey_data['title'])) > 40) { |
54 | - $urlname .= '...'; |
|
54 | + $urlname .= '...'; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | // Breadcrumbs |
@@ -64,32 +64,32 @@ discard block |
||
64 | 64 | |
65 | 65 | // Checking the parameters |
66 | 66 | if (!is_numeric($survey_id)) { |
67 | - Display::display_error_message(get_lang('Error'), false); |
|
68 | - Display::display_footer(); |
|
69 | - exit; |
|
67 | + Display::display_error_message(get_lang('Error'), false); |
|
68 | + Display::display_footer(); |
|
69 | + exit; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | // Getting all the people who have filled this survey |
73 | 73 | $answered_data = SurveyManager::get_people_who_filled_survey($survey_id); |
74 | 74 | if ($survey_data['anonymous'] == 1) { |
75 | - Display::display_normal_message(get_lang('AnonymousSurveyCannotKnowWhoAnswered').' '.count($answered_data).' '.get_lang('PeopleAnswered')); |
|
76 | - $answered_data = array(); |
|
75 | + Display::display_normal_message(get_lang('AnonymousSurveyCannotKnowWhoAnswered').' '.count($answered_data).' '.get_lang('PeopleAnswered')); |
|
76 | + $answered_data = array(); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | if (!isset($_GET['view']) OR $_GET['view'] == 'invited') { |
80 | - echo get_lang('ViewInvited'). ' | '; |
|
80 | + echo get_lang('ViewInvited'). ' | '; |
|
81 | 81 | } else { |
82 | - echo ' <a href="'.api_get_self().'?survey_id='.$survey_id.'&view=invited">'.get_lang('ViewInvited').'</a> |'; |
|
82 | + echo ' <a href="'.api_get_self().'?survey_id='.$survey_id.'&view=invited">'.get_lang('ViewInvited').'</a> |'; |
|
83 | 83 | } |
84 | 84 | if ($_GET['view'] == 'answered') { |
85 | - echo get_lang('ViewAnswered').' | '; |
|
85 | + echo get_lang('ViewAnswered').' | '; |
|
86 | 86 | } else { |
87 | - echo ' <a href="'.api_get_self().'?survey_id='.$survey_id.'&view=answered">'.get_lang('ViewAnswered').'</a> |'; |
|
87 | + echo ' <a href="'.api_get_self().'?survey_id='.$survey_id.'&view=answered">'.get_lang('ViewAnswered').'</a> |'; |
|
88 | 88 | } |
89 | 89 | if ($_GET['view'] == 'unanswered') { |
90 | - echo get_lang('ViewUnanswered'); |
|
90 | + echo get_lang('ViewUnanswered'); |
|
91 | 91 | } else { |
92 | - echo ' <a href="'.api_get_self().'?survey_id='.$survey_id.'&view=unanswered">'.get_lang('ViewUnanswered').'</a>'; |
|
92 | + echo ' <a href="'.api_get_self().'?survey_id='.$survey_id.'&view=unanswered">'.get_lang('ViewUnanswered').'</a>'; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | // Table header |
@@ -111,32 +111,32 @@ discard block |
||
111 | 111 | |
112 | 112 | $res = Database::query($sql); |
113 | 113 | while ($row = Database::fetch_assoc($res)) { |
114 | - if (!$_GET['view'] || |
|
115 | - $_GET['view'] == 'invited' || |
|
114 | + if (!$_GET['view'] || |
|
115 | + $_GET['view'] == 'invited' || |
|
116 | 116 | ($_GET['view'] == 'answered' && in_array($row['user'], $answered_data)) || |
117 | 117 | ($_GET['view'] == 'unanswered' && !in_array($row['user'], $answered_data)) |
118 | 118 | ) { |
119 | - echo '<tr>'; |
|
120 | - if (is_numeric($row['user'])) { |
|
119 | + echo '<tr>'; |
|
120 | + if (is_numeric($row['user'])) { |
|
121 | 121 | $userInfo = api_get_user_info($row['user']); |
122 | - echo '<td>'; |
|
122 | + echo '<td>'; |
|
123 | 123 | echo UserManager::getUserProfileLink($userInfo); |
124 | 124 | echo '</td>'; |
125 | - } else { |
|
125 | + } else { |
|
126 | 126 | echo '<td>'.$row['user'].'</td>'; |
127 | - } |
|
128 | - echo ' <td>'.$row['invitation_date'].'</td>'; |
|
129 | - echo ' <td>'; |
|
130 | - |
|
131 | - if (in_array($row['user'], $answered_data)) { |
|
132 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=userreport&survey_id='.$survey_id.'&user='.$row['user'].'">'.get_lang('ViewAnswers').'</a>'; |
|
133 | - } else { |
|
134 | - echo '-'; |
|
135 | - } |
|
136 | - |
|
137 | - echo ' </td>'; |
|
138 | - echo '</tr>'; |
|
139 | - } |
|
127 | + } |
|
128 | + echo ' <td>'.$row['invitation_date'].'</td>'; |
|
129 | + echo ' <td>'; |
|
130 | + |
|
131 | + if (in_array($row['user'], $answered_data)) { |
|
132 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=userreport&survey_id='.$survey_id.'&user='.$row['user'].'">'.get_lang('ViewAnswers').'</a>'; |
|
133 | + } else { |
|
134 | + echo '-'; |
|
135 | + } |
|
136 | + |
|
137 | + echo ' </td>'; |
|
138 | + echo '</tr>'; |
|
139 | + } |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | // Closing the table |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | |
22 | 22 | // Database table definitions |
23 | 23 | $table_survey = Database :: get_course_table(TABLE_SURVEY); |
24 | -$table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
25 | -$table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
24 | +$table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
25 | +$table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
26 | 26 | $table_course = Database :: get_main_table(TABLE_MAIN_COURSE); |
27 | -$table_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
28 | -$table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION); |
|
27 | +$table_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
28 | +$table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION); |
|
29 | 29 | |
30 | 30 | $tool_name = get_lang('SurveyInvitations'); |
31 | 31 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | if (!isset($_GET['view']) OR $_GET['view'] == 'invited') { |
80 | - echo get_lang('ViewInvited'). ' | '; |
|
80 | + echo get_lang('ViewInvited').' | '; |
|
81 | 81 | } else { |
82 | 82 | echo ' <a href="'.api_get_self().'?survey_id='.$survey_id.'&view=invited">'.get_lang('ViewInvited').'</a> |'; |
83 | 83 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | require_once '../inc/global.inc.php'; |
13 | 13 | |
14 | 14 | $this_section = SECTION_COURSES; |
15 | -$current_course_tool = TOOL_SURVEY; |
|
15 | +$current_course_tool = TOOL_SURVEY; |
|
16 | 16 | |
17 | 17 | api_protect_course_script(true); |
18 | 18 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | // Getting the survey information |
59 | 59 | if (!empty($_GET['survey_id'])) { |
60 | 60 | $course_code = api_get_course_id(); |
61 | - if ($course_code!=-1) { |
|
61 | + if ($course_code != -1) { |
|
62 | 62 | $survey_data = SurveyManager::get_survey($survey_id); |
63 | 63 | } else { |
64 | 64 | Display :: display_header(get_lang('ToolSurvey')); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | Database::query('UPDATE '.$table_survey_question_group.' SET description = \''.Database::escape_string($_POST['description']).'\' |
89 | 89 | WHERE c_id = '.$course_id.' AND id = \''.Database::escape_string($_POST['group_id']).'\''); |
90 | 90 | $sendmsg = 'GroupUpdatedSuccessfully'; |
91 | - } elseif(!empty($_POST['name'])) { |
|
91 | + } elseif (!empty($_POST['name'])) { |
|
92 | 92 | 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).'\') '); |
93 | 93 | $sendmsg = 'GroupCreatedSuccessfully'; |
94 | 94 | } else { |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | if (isset($action)) { |
118 | 118 | if (($action == 'moveup' || $action == 'movedown') && isset($_GET['question_id'])) { |
119 | - SurveyManager::move_survey_question($my_action_survey,$my_question_id_survey,$my_survey_id_survey); |
|
119 | + SurveyManager::move_survey_question($my_action_survey, $my_question_id_survey, $my_survey_id_survey); |
|
120 | 120 | Display::display_confirmation_message(get_lang('SurveyQuestionMoved')); |
121 | 121 | } |
122 | 122 | if ($action == 'delete' AND is_numeric($_GET['question_id'])) { |
@@ -130,12 +130,12 @@ discard block |
||
130 | 130 | SurveyUtil::check_first_last_question($_GET['survey_id']); |
131 | 131 | |
132 | 132 | // Action links |
133 | -$survey_actions = '<a href="'.api_get_path(WEB_CODE_PATH).'survey/create_new_survey.php?'.api_get_cidreq().'&action=edit&survey_id='.$survey_id.'">'.Display::return_icon('edit.png', get_lang('EditSurvey'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
134 | -$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq().'&action=delete&survey_id='.$survey_id.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('DeleteSurvey').'?', ENT_QUOTES)).'\')) return false;">'.Display::return_icon('delete.png', get_lang('DeleteSurvey'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
133 | +$survey_actions = '<a href="'.api_get_path(WEB_CODE_PATH).'survey/create_new_survey.php?'.api_get_cidreq().'&action=edit&survey_id='.$survey_id.'">'.Display::return_icon('edit.png', get_lang('EditSurvey'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
134 | +$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq().'&action=delete&survey_id='.$survey_id.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('DeleteSurvey').'?', ENT_QUOTES)).'\')) return false;">'.Display::return_icon('delete.png', get_lang('DeleteSurvey'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
135 | 135 | //$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/create_survey_in_another_language.php?id_survey='.$survey_id.'">'.Display::return_icon('copy.gif', get_lang('Copy')).'</a>'; |
136 | -$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/preview.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.Display::return_icon('preview_view.png', get_lang('Preview'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
137 | -$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invite.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.Display::return_icon('mail_send.png', get_lang('Publish'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
138 | -$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.Display::return_icon('stats.png', get_lang('Reporting'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
136 | +$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/preview.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.Display::return_icon('preview_view.png', get_lang('Preview'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
137 | +$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invite.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.Display::return_icon('mail_send.png', get_lang('Publish'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
138 | +$survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.Display::return_icon('stats.png', get_lang('Reporting'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
139 | 139 | echo '<div class="actions">'.$survey_actions.'</div>'; |
140 | 140 | |
141 | 141 | if ($survey_data['survey_type'] == 0) { |
@@ -217,24 +217,24 @@ discard block |
||
217 | 217 | echo ' <td>'.$tool_name.'</td>'; |
218 | 218 | echo ' <td>'.$row['number_of_options'].'</td>'; |
219 | 219 | echo ' <td>'; |
220 | - echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=edit&type='.$row['type'].'&survey_id='.$survey_id.'&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().'&action=delete&survey_id='.$survey_id.'&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>'; |
|
220 | + echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=edit&type='.$row['type'].'&survey_id='.$survey_id.'&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().'&action=delete&survey_id='.$survey_id.'&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 | 222 | if ($question_counter > 1) { |
223 | - echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=moveup&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('up.png', get_lang('MoveUp'),'',ICON_SIZE_SMALL).'</a>'; |
|
223 | + echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=moveup&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('up.png', get_lang('MoveUp'), '', ICON_SIZE_SMALL).'</a>'; |
|
224 | 224 | } else { |
225 | - Display::display_icon('up_na.png',' ','',ICON_SIZE_SMALL); |
|
225 | + Display::display_icon('up_na.png', ' ', '', ICON_SIZE_SMALL); |
|
226 | 226 | } |
227 | 227 | if ($question_counter < $question_counter_max) { |
228 | - echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=movedown&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('down.png', get_lang('MoveDown'),'',ICON_SIZE_SMALL).'</a>'; |
|
228 | + echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=movedown&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('down.png', get_lang('MoveDown'), '', ICON_SIZE_SMALL).'</a>'; |
|
229 | 229 | } else { |
230 | - Display::display_icon('down_na.png',' ','',ICON_SIZE_SMALL); |
|
230 | + Display::display_icon('down_na.png', ' ', '', ICON_SIZE_SMALL); |
|
231 | 231 | } |
232 | 232 | echo ' </td>'; |
233 | 233 | $question_counter++; |
234 | 234 | |
235 | 235 | if ($is_survey_type_1) { |
236 | - echo '<td>'.(($row['survey_group_pri']==0)?get_lang('Secondary'):get_lang('Primary')).'</td>'; |
|
237 | - echo '<td>'.(($row['survey_group_pri']==0)?$groups[$row['survey_group_sec1']].'-'.$groups[$row['survey_group_sec2']]:$groups[$row['survey_group_pri']]).'</td>'; |
|
236 | + echo '<td>'.(($row['survey_group_pri'] == 0) ? get_lang('Secondary') : get_lang('Primary')).'</td>'; |
|
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 | 239 | echo '</tr>'; |
240 | 240 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | echo Display::display_confirmation_message(get_lang($_GET['sendmsg']), false); |
249 | 249 | } |
250 | 250 | |
251 | - if (in_array($_GET['sendmsg'], array('GroupNeedName'))){ |
|
251 | + if (in_array($_GET['sendmsg'], array('GroupNeedName'))) { |
|
252 | 252 | echo Display::display_warning_message(get_lang($_GET['sendmsg']), false); |
253 | 253 | } |
254 | 254 | echo '<table border="0"><tr><td width="100">'.get_lang('Name').'</td><td>'.get_lang('Description').'</td></tr></table>'; |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | if ($_GET['action'] == 'editgroup') { |
257 | 257 | $sql = 'SELECT name,description FROM '.$table_survey_question_group.' WHERE id = '.intval($_GET['gid']).' AND survey_id = '.intval($survey_id).' limit 1'; |
258 | 258 | $rs = Database::query($sql); |
259 | - $editedrow = Database::fetch_array($rs,'ASSOC'); |
|
259 | + $editedrow = Database::fetch_array($rs, 'ASSOC'); |
|
260 | 260 | echo '<input type="text" maxlength="20" name="name" value="'.$editedrow['name'].'" size="10" disabled>'; |
261 | 261 | echo '<input type="text" maxlength="150" name="description" value="'.$editedrow['description'].'" size="40">'; |
262 | 262 | echo '<input type="hidden" name="group_id" value="'.Security::remove_XSS($_GET['gid']).'">'; |
@@ -278,12 +278,12 @@ discard block |
||
278 | 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 | 279 | |
280 | 280 | $rs = Database::query($sql); |
281 | - while($row = Database::fetch_array($rs,ASSOC)){ |
|
281 | + while ($row = Database::fetch_array($rs, ASSOC)) { |
|
282 | 282 | $grouplist .= '<tr><td>'.$row['name'].'</td><td>'.$row['description'].'</td><td>'. |
283 | 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>'. |
|
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 | 287 | '</td></tr>'; |
288 | 288 | } |
289 | 289 | echo $grouplist.'</table>'; |
@@ -124,7 +124,9 @@ |
||
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
127 | -if (!empty($survey_data['survey_version'])) echo '<b>'.get_lang('Version').': '.$survey_data['survey_version'].'</b>'; |
|
127 | +if (!empty($survey_data['survey_version'])) { |
|
128 | + echo '<b>'.get_lang('Version').': '.$survey_data['survey_version'].'</b>'; |
|
129 | +} |
|
128 | 130 | |
129 | 131 | // We exit here is the first or last question is a pagebreak (which causes errors) |
130 | 132 | SurveyUtil::check_first_last_question($_GET['survey_id']); |
@@ -20,8 +20,8 @@ discard block |
||
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) { |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | if (!api_is_allowed_to_edit(false, true) || |
32 | 32 | (api_is_course_coach() && $extend_rights_for_coachs == 'false') |
33 | 33 | ) { |
34 | - Display :: display_header(get_lang('ToolSurvey')); |
|
35 | - Display :: display_error_message(get_lang('NotAllowed'), false); |
|
36 | - Display :: display_footer(); |
|
37 | - exit; |
|
34 | + Display :: display_header(get_lang('ToolSurvey')); |
|
35 | + Display :: display_error_message(get_lang('NotAllowed'), false); |
|
36 | + Display :: display_footer(); |
|
37 | + exit; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | // Database table definitions |
@@ -51,21 +51,21 @@ discard block |
||
51 | 51 | |
52 | 52 | // Breadcrumbs |
53 | 53 | $interbreadcrumb[] = array( |
54 | - 'url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php', |
|
55 | - 'name' => get_lang('SurveyList'), |
|
54 | + 'url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php', |
|
55 | + 'name' => get_lang('SurveyList'), |
|
56 | 56 | ); |
57 | 57 | |
58 | 58 | // Getting the survey information |
59 | 59 | if (!empty($_GET['survey_id'])) { |
60 | - $course_code = api_get_course_id(); |
|
61 | - if ($course_code!=-1) { |
|
62 | - $survey_data = SurveyManager::get_survey($survey_id); |
|
63 | - } else { |
|
64 | - Display :: display_header(get_lang('ToolSurvey')); |
|
65 | - Display :: display_error_message(get_lang('NotAllowed'), false); |
|
66 | - Display :: display_footer(); |
|
67 | - exit; |
|
68 | - } |
|
60 | + $course_code = api_get_course_id(); |
|
61 | + if ($course_code!=-1) { |
|
62 | + $survey_data = SurveyManager::get_survey($survey_id); |
|
63 | + } else { |
|
64 | + Display :: display_header(get_lang('ToolSurvey')); |
|
65 | + Display :: display_error_message(get_lang('NotAllowed'), false); |
|
66 | + Display :: display_footer(); |
|
67 | + exit; |
|
68 | + } |
|
69 | 69 | } else { |
70 | 70 | Display :: display_header(get_lang('ToolSurvey')); |
71 | 71 | Display :: display_error_message(get_lang('NotAllowed'), false); |
@@ -78,30 +78,30 @@ discard block |
||
78 | 78 | $is_survey_type_1 = $survey_data['survey_type'] == 1; |
79 | 79 | |
80 | 80 | if (api_strlen(strip_tags($survey_data['title'])) > 40) { |
81 | - $tool_name .= '...'; |
|
81 | + $tool_name .= '...'; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | if ($is_survey_type_1 && ($action == 'addgroup' || $action == 'deletegroup')) { |
85 | - $_POST['name'] = trim($_POST['name']); |
|
86 | - if ($action == 'addgroup') { |
|
87 | - if (!empty($_POST['group_id'])) { |
|
88 | - Database::query('UPDATE '.$table_survey_question_group.' SET description = \''.Database::escape_string($_POST['description']).'\' |
|
85 | + $_POST['name'] = trim($_POST['name']); |
|
86 | + if ($action == 'addgroup') { |
|
87 | + if (!empty($_POST['group_id'])) { |
|
88 | + Database::query('UPDATE '.$table_survey_question_group.' SET description = \''.Database::escape_string($_POST['description']).'\' |
|
89 | 89 | WHERE c_id = '.$course_id.' AND id = \''.Database::escape_string($_POST['group_id']).'\''); |
90 | - $sendmsg = 'GroupUpdatedSuccessfully'; |
|
91 | - } elseif(!empty($_POST['name'])) { |
|
92 | - 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).'\') '); |
|
93 | - $sendmsg = 'GroupCreatedSuccessfully'; |
|
94 | - } else { |
|
95 | - $sendmsg = 'GroupNeedName'; |
|
96 | - } |
|
97 | - } |
|
98 | - |
|
99 | - if ($action == 'deletegroup') { |
|
100 | - Database::query('DELETE FROM '.$table_survey_question_group.' WHERE c_id = '.$course_id.' AND id = '.intval($_GET['gid']).' and survey_id = '.intval($survey_id)); |
|
101 | - $sendmsg = 'GroupDeletedSuccessfully'; |
|
102 | - } |
|
103 | - header('Location: '.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&sendmsg='.$sendmsg); |
|
104 | - exit; |
|
90 | + $sendmsg = 'GroupUpdatedSuccessfully'; |
|
91 | + } elseif(!empty($_POST['name'])) { |
|
92 | + 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).'\') '); |
|
93 | + $sendmsg = 'GroupCreatedSuccessfully'; |
|
94 | + } else { |
|
95 | + $sendmsg = 'GroupNeedName'; |
|
96 | + } |
|
97 | + } |
|
98 | + |
|
99 | + if ($action == 'deletegroup') { |
|
100 | + Database::query('DELETE FROM '.$table_survey_question_group.' WHERE c_id = '.$course_id.' AND id = '.intval($_GET['gid']).' and survey_id = '.intval($survey_id)); |
|
101 | + $sendmsg = 'GroupDeletedSuccessfully'; |
|
102 | + } |
|
103 | + header('Location: '.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&sendmsg='.$sendmsg); |
|
104 | + exit; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | // Displaying the header |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | $message_information = isset($_GET['message']) ? Security::remove_XSS($_GET['message']) : null; |
116 | 116 | |
117 | 117 | if (isset($action)) { |
118 | - if (($action == 'moveup' || $action == 'movedown') && isset($_GET['question_id'])) { |
|
119 | - SurveyManager::move_survey_question($my_action_survey,$my_question_id_survey,$my_survey_id_survey); |
|
120 | - Display::display_confirmation_message(get_lang('SurveyQuestionMoved')); |
|
121 | - } |
|
122 | - if ($action == 'delete' AND is_numeric($_GET['question_id'])) { |
|
123 | - SurveyManager::delete_survey_question($my_survey_id_survey, $my_question_id_survey, $survey_data['is_shared']); |
|
124 | - } |
|
118 | + if (($action == 'moveup' || $action == 'movedown') && isset($_GET['question_id'])) { |
|
119 | + SurveyManager::move_survey_question($my_action_survey,$my_question_id_survey,$my_survey_id_survey); |
|
120 | + Display::display_confirmation_message(get_lang('SurveyQuestionMoved')); |
|
121 | + } |
|
122 | + if ($action == 'delete' AND is_numeric($_GET['question_id'])) { |
|
123 | + SurveyManager::delete_survey_question($my_survey_id_survey, $my_question_id_survey, $survey_data['is_shared']); |
|
124 | + } |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | if (!empty($survey_data['survey_version'])) echo '<b>'.get_lang('Version').': '.$survey_data['survey_version'].'</b>'; |
@@ -139,26 +139,26 @@ discard block |
||
139 | 139 | echo '<div class="actions">'.$survey_actions.'</div>'; |
140 | 140 | |
141 | 141 | if ($survey_data['survey_type'] == 0) { |
142 | - echo '<div class="panel panel-default">'; |
|
142 | + echo '<div class="panel panel-default">'; |
|
143 | 143 | echo '<div class="panel-body">'; |
144 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=yesno&survey_id='.$survey_id.'">'.Display::return_icon('yesno.png', get_lang('YesNo'), null, ICON_SIZE_BIG).'</a>'; |
|
145 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=multiplechoice&survey_id='.$survey_id.'">'.Display::return_icon('mcua.png', get_lang('UniqueSelect'), null, ICON_SIZE_BIG).'</a>'; |
|
146 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=multipleresponse&survey_id='.$survey_id.'">'.Display::return_icon('mcma.png', get_lang('MultipleResponse'), null, ICON_SIZE_BIG).'</a>'; |
|
147 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=open&survey_id='.$survey_id.'">'.Display::return_icon('open_answer.png', get_lang('Open'), null, ICON_SIZE_BIG).'</a>'; |
|
148 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=dropdown&survey_id='.$survey_id.'">'.Display::return_icon('dropdown.png', get_lang('Dropdown'), null, ICON_SIZE_BIG).'</a>'; |
|
149 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=percentage&survey_id='.$survey_id.'">'.Display::return_icon('percentagequestion.png', get_lang('Percentage'), null, ICON_SIZE_BIG).'</a>'; |
|
150 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=score&survey_id='.$survey_id.'">'.Display::return_icon('scorequestion.png', get_lang('Score'), null, ICON_SIZE_BIG).'</a>'; |
|
151 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=comment&survey_id='.$survey_id.'">'.Display::return_icon('commentquestion.png', get_lang('Comment'), null, ICON_SIZE_BIG).'</a>'; |
|
152 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=pagebreak&survey_id='.$survey_id.'">'.Display::return_icon('page_end.png', get_lang('Pagebreak'), null, ICON_SIZE_BIG).'</a>'; |
|
153 | - echo '</div>'; |
|
144 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=yesno&survey_id='.$survey_id.'">'.Display::return_icon('yesno.png', get_lang('YesNo'), null, ICON_SIZE_BIG).'</a>'; |
|
145 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=multiplechoice&survey_id='.$survey_id.'">'.Display::return_icon('mcua.png', get_lang('UniqueSelect'), null, ICON_SIZE_BIG).'</a>'; |
|
146 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=multipleresponse&survey_id='.$survey_id.'">'.Display::return_icon('mcma.png', get_lang('MultipleResponse'), null, ICON_SIZE_BIG).'</a>'; |
|
147 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=open&survey_id='.$survey_id.'">'.Display::return_icon('open_answer.png', get_lang('Open'), null, ICON_SIZE_BIG).'</a>'; |
|
148 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=dropdown&survey_id='.$survey_id.'">'.Display::return_icon('dropdown.png', get_lang('Dropdown'), null, ICON_SIZE_BIG).'</a>'; |
|
149 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=percentage&survey_id='.$survey_id.'">'.Display::return_icon('percentagequestion.png', get_lang('Percentage'), null, ICON_SIZE_BIG).'</a>'; |
|
150 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=score&survey_id='.$survey_id.'">'.Display::return_icon('scorequestion.png', get_lang('Score'), null, ICON_SIZE_BIG).'</a>'; |
|
151 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=comment&survey_id='.$survey_id.'">'.Display::return_icon('commentquestion.png', get_lang('Comment'), null, ICON_SIZE_BIG).'</a>'; |
|
152 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=pagebreak&survey_id='.$survey_id.'">'.Display::return_icon('page_end.png', get_lang('Pagebreak'), null, ICON_SIZE_BIG).'</a>'; |
|
153 | + echo '</div>'; |
|
154 | 154 | echo '</div>'; |
155 | 155 | } else { |
156 | - echo '<div class="panel panel-default">'; |
|
156 | + echo '<div class="panel panel-default">'; |
|
157 | 157 | echo '<div class="panel-body">'; |
158 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=personality&survey_id='.$survey_id.'">'; |
|
159 | - echo Display::return_icon("yesno.png"); |
|
160 | - echo '</a></div>'; |
|
161 | - echo '</div>'; |
|
158 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=personality&survey_id='.$survey_id.'">'; |
|
159 | + echo Display::return_icon("yesno.png"); |
|
160 | + echo '</a></div>'; |
|
161 | + echo '</div>'; |
|
162 | 162 | echo '</div>'; |
163 | 163 | } |
164 | 164 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | echo ' <th width="50" >'.get_lang('NumberOfOptions').'</th>'; |
172 | 172 | echo ' <th width="100">'.get_lang('Modify').'</th>'; |
173 | 173 | if ($is_survey_type_1) { |
174 | - echo '<th width="100">'.get_lang('Condition').'</th>'; |
|
174 | + echo '<th width="100">'.get_lang('Condition').'</th>'; |
|
175 | 175 | echo '<th width="40">'.get_lang('Group').'</th>'; |
176 | 176 | } |
177 | 177 | echo ' </tr>'; |
@@ -198,97 +198,97 @@ discard block |
||
198 | 198 | $result = Database::query($sql); |
199 | 199 | $question_counter_max = Database::num_rows($result); |
200 | 200 | while ($row = Database::fetch_array($result, 'ASSOC')) { |
201 | - echo '<tr>'; |
|
202 | - echo ' <td>'.$question_counter.'</td>'; |
|
203 | - echo ' <td>'; |
|
204 | - if (api_strlen($row['survey_question']) > 100) { |
|
205 | - echo api_substr(strip_tags($row['survey_question']), 0, 100).' ... '; |
|
206 | - } else { |
|
207 | - echo $row['survey_question']; |
|
208 | - } |
|
209 | - |
|
210 | - if ($row['type'] == 'yesno') { |
|
211 | - $tool_name = get_lang('YesNo'); |
|
212 | - } else if ($row['type'] == 'multiplechoice') { |
|
213 | - $tool_name = get_lang('UniqueSelect'); |
|
214 | - } else { |
|
215 | - $tool_name = get_lang(api_ucfirst(Security::remove_XSS($row['type']))); |
|
216 | - } |
|
217 | - |
|
218 | - echo '</td>'; |
|
219 | - echo ' <td>'.$tool_name.'</td>'; |
|
220 | - echo ' <td>'.$row['number_of_options'].'</td>'; |
|
221 | - echo ' <td>'; |
|
222 | - echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=edit&type='.$row['type'].'&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'; |
|
223 | - echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=delete&survey_id='.$survey_id.'&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>'; |
|
224 | - if ($question_counter > 1) { |
|
225 | - echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=moveup&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('up.png', get_lang('MoveUp'),'',ICON_SIZE_SMALL).'</a>'; |
|
226 | - } else { |
|
227 | - Display::display_icon('up_na.png',' ','',ICON_SIZE_SMALL); |
|
228 | - } |
|
229 | - if ($question_counter < $question_counter_max) { |
|
230 | - echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=movedown&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('down.png', get_lang('MoveDown'),'',ICON_SIZE_SMALL).'</a>'; |
|
231 | - } else { |
|
232 | - Display::display_icon('down_na.png',' ','',ICON_SIZE_SMALL); |
|
233 | - } |
|
234 | - echo ' </td>'; |
|
235 | - $question_counter++; |
|
236 | - |
|
237 | - if ($is_survey_type_1) { |
|
238 | - echo '<td>'.(($row['survey_group_pri']==0)?get_lang('Secondary'):get_lang('Primary')).'</td>'; |
|
201 | + echo '<tr>'; |
|
202 | + echo ' <td>'.$question_counter.'</td>'; |
|
203 | + echo ' <td>'; |
|
204 | + if (api_strlen($row['survey_question']) > 100) { |
|
205 | + echo api_substr(strip_tags($row['survey_question']), 0, 100).' ... '; |
|
206 | + } else { |
|
207 | + echo $row['survey_question']; |
|
208 | + } |
|
209 | + |
|
210 | + if ($row['type'] == 'yesno') { |
|
211 | + $tool_name = get_lang('YesNo'); |
|
212 | + } else if ($row['type'] == 'multiplechoice') { |
|
213 | + $tool_name = get_lang('UniqueSelect'); |
|
214 | + } else { |
|
215 | + $tool_name = get_lang(api_ucfirst(Security::remove_XSS($row['type']))); |
|
216 | + } |
|
217 | + |
|
218 | + echo '</td>'; |
|
219 | + echo ' <td>'.$tool_name.'</td>'; |
|
220 | + echo ' <td>'.$row['number_of_options'].'</td>'; |
|
221 | + echo ' <td>'; |
|
222 | + echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=edit&type='.$row['type'].'&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'; |
|
223 | + echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=delete&survey_id='.$survey_id.'&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>'; |
|
224 | + if ($question_counter > 1) { |
|
225 | + echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=moveup&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('up.png', get_lang('MoveUp'),'',ICON_SIZE_SMALL).'</a>'; |
|
226 | + } else { |
|
227 | + Display::display_icon('up_na.png',' ','',ICON_SIZE_SMALL); |
|
228 | + } |
|
229 | + if ($question_counter < $question_counter_max) { |
|
230 | + echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=movedown&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('down.png', get_lang('MoveDown'),'',ICON_SIZE_SMALL).'</a>'; |
|
231 | + } else { |
|
232 | + Display::display_icon('down_na.png',' ','',ICON_SIZE_SMALL); |
|
233 | + } |
|
234 | + echo ' </td>'; |
|
235 | + $question_counter++; |
|
236 | + |
|
237 | + if ($is_survey_type_1) { |
|
238 | + echo '<td>'.(($row['survey_group_pri']==0)?get_lang('Secondary'):get_lang('Primary')).'</td>'; |
|
239 | 239 | echo '<td>'.(($row['survey_group_pri']==0)?$groups[$row['survey_group_sec1']].'-'.$groups[$row['survey_group_sec2']]:$groups[$row['survey_group_pri']]).'</td>'; |
240 | 240 | } |
241 | - echo '</tr>'; |
|
241 | + echo '</tr>'; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | echo '</table>'; |
245 | 245 | |
246 | 246 | if ($is_survey_type_1) { |
247 | - echo '<br /><br /><b>'.get_lang('ManageGroups').'</b><br /><br />'; |
|
248 | - |
|
249 | - if (in_array($_GET['sendmsg'], array('GroupUpdatedSuccessfully', 'GroupDeletedSuccessfully', 'GroupCreatedSuccessfully'))) { |
|
250 | - echo Display::display_confirmation_message(get_lang($_GET['sendmsg']), false); |
|
251 | - } |
|
252 | - |
|
253 | - if (in_array($_GET['sendmsg'], array('GroupNeedName'))){ |
|
254 | - echo Display::display_warning_message(get_lang($_GET['sendmsg']), false); |
|
255 | - } |
|
256 | - echo '<table border="0"><tr><td width="100">'.get_lang('Name').'</td><td>'.get_lang('Description').'</td></tr></table>'; |
|
257 | - echo '<form action="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?action=addgroup&survey_id='.$survey_id.'" method="post">'; |
|
258 | - if ($_GET['action'] == 'editgroup') { |
|
259 | - $sql = 'SELECT name,description FROM '.$table_survey_question_group.' WHERE id = '.intval($_GET['gid']).' AND survey_id = '.intval($survey_id).' limit 1'; |
|
260 | - $rs = Database::query($sql); |
|
261 | - $editedrow = Database::fetch_array($rs,'ASSOC'); |
|
262 | - echo '<input type="text" maxlength="20" name="name" value="'.$editedrow['name'].'" size="10" disabled>'; |
|
263 | - echo '<input type="text" maxlength="150" name="description" value="'.$editedrow['description'].'" size="40">'; |
|
264 | - echo '<input type="hidden" name="group_id" value="'.Security::remove_XSS($_GET['gid']).'">'; |
|
265 | - 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).'\';" />'; |
|
266 | - } else { |
|
267 | - echo '<input type="text" maxlength="20" name="name" value="" size="10">'; |
|
268 | - echo '<input type="text" maxlength="250" name="description" value="" size="80">'; |
|
269 | - echo '<input type="submit" value="'.get_lang('Create').'"'; |
|
270 | - } |
|
271 | - echo '</form><br />'; |
|
272 | - |
|
273 | - echo '<table class="data_table">'; |
|
274 | - echo ' <tr class="row_odd">'; |
|
275 | - echo ' <th width="200">'.get_lang('Name').'</th>'; |
|
276 | - echo ' <th>'.get_lang('Description').'</th>'; |
|
277 | - echo ' <th width="100">'.get_lang('Modify').'</th>'; |
|
278 | - echo ' </tr>'; |
|
279 | - |
|
280 | - $sql = 'SELECT id,name,description FROM '.$table_survey_question_group.' WHERE c_id = '.$course_id.' AND survey_id = '.intval($survey_id).' ORDER BY name'; |
|
281 | - |
|
282 | - $rs = Database::query($sql); |
|
283 | - while($row = Database::fetch_array($rs,ASSOC)){ |
|
284 | - $grouplist .= '<tr><td>'.$row['name'].'</td><td>'.$row['description'].'</td><td>'. |
|
285 | - '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=editgroup">'. |
|
286 | - Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a> '. |
|
287 | - '<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;">'. |
|
288 | - Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'. |
|
289 | - '</td></tr>'; |
|
290 | - } |
|
291 | - echo $grouplist.'</table>'; |
|
247 | + echo '<br /><br /><b>'.get_lang('ManageGroups').'</b><br /><br />'; |
|
248 | + |
|
249 | + if (in_array($_GET['sendmsg'], array('GroupUpdatedSuccessfully', 'GroupDeletedSuccessfully', 'GroupCreatedSuccessfully'))) { |
|
250 | + echo Display::display_confirmation_message(get_lang($_GET['sendmsg']), false); |
|
251 | + } |
|
252 | + |
|
253 | + if (in_array($_GET['sendmsg'], array('GroupNeedName'))){ |
|
254 | + echo Display::display_warning_message(get_lang($_GET['sendmsg']), false); |
|
255 | + } |
|
256 | + echo '<table border="0"><tr><td width="100">'.get_lang('Name').'</td><td>'.get_lang('Description').'</td></tr></table>'; |
|
257 | + echo '<form action="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?action=addgroup&survey_id='.$survey_id.'" method="post">'; |
|
258 | + if ($_GET['action'] == 'editgroup') { |
|
259 | + $sql = 'SELECT name,description FROM '.$table_survey_question_group.' WHERE id = '.intval($_GET['gid']).' AND survey_id = '.intval($survey_id).' limit 1'; |
|
260 | + $rs = Database::query($sql); |
|
261 | + $editedrow = Database::fetch_array($rs,'ASSOC'); |
|
262 | + echo '<input type="text" maxlength="20" name="name" value="'.$editedrow['name'].'" size="10" disabled>'; |
|
263 | + echo '<input type="text" maxlength="150" name="description" value="'.$editedrow['description'].'" size="40">'; |
|
264 | + echo '<input type="hidden" name="group_id" value="'.Security::remove_XSS($_GET['gid']).'">'; |
|
265 | + 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).'\';" />'; |
|
266 | + } else { |
|
267 | + echo '<input type="text" maxlength="20" name="name" value="" size="10">'; |
|
268 | + echo '<input type="text" maxlength="250" name="description" value="" size="80">'; |
|
269 | + echo '<input type="submit" value="'.get_lang('Create').'"'; |
|
270 | + } |
|
271 | + echo '</form><br />'; |
|
272 | + |
|
273 | + echo '<table class="data_table">'; |
|
274 | + echo ' <tr class="row_odd">'; |
|
275 | + echo ' <th width="200">'.get_lang('Name').'</th>'; |
|
276 | + echo ' <th>'.get_lang('Description').'</th>'; |
|
277 | + echo ' <th width="100">'.get_lang('Modify').'</th>'; |
|
278 | + echo ' </tr>'; |
|
279 | + |
|
280 | + $sql = 'SELECT id,name,description FROM '.$table_survey_question_group.' WHERE c_id = '.$course_id.' AND survey_id = '.intval($survey_id).' ORDER BY name'; |
|
281 | + |
|
282 | + $rs = Database::query($sql); |
|
283 | + while($row = Database::fetch_array($rs,ASSOC)){ |
|
284 | + $grouplist .= '<tr><td>'.$row['name'].'</td><td>'.$row['description'].'</td><td>'. |
|
285 | + '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=editgroup">'. |
|
286 | + Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a> '. |
|
287 | + '<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;">'. |
|
288 | + Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'. |
|
289 | + '</td></tr>'; |
|
290 | + } |
|
291 | + echo $grouplist.'</table>'; |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | Session::erase('answer_count'); |
@@ -11,7 +11,7 @@ |
||
11 | 11 | if (!SurveyManager::survey_generation_hash_available()) { |
12 | 12 | api_not_allowed(true); |
13 | 13 | } |
14 | -$course_info = api_get_course_info_by_id($_REQUEST['c']); |
|
14 | +$course_info = api_get_course_info_by_id($_REQUEST['c']); |
|
15 | 15 | |
16 | 16 | $hash_is_valid = SurveyManager::validate_survey_hash( |
17 | 17 | $survey_id, |
@@ -21,7 +21,7 @@ |
||
21 | 21 | $options[$key] = $value; |
22 | 22 | } |
23 | 23 | |
24 | - $name = 'question' . $questionData['question_id']; |
|
24 | + $name = 'question'.$questionData['question_id']; |
|
25 | 25 | |
26 | 26 | $form->addSelect( |
27 | 27 | $name, null, $options |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | if ($surveyData['survey_type'] == 1) { |
65 | 65 | $table_survey_question_group = Database::get_course_table(TABLE_SURVEY_QUESTION_GROUP); |
66 | 66 | $sql = 'SELECT id,name FROM '.$table_survey_question_group.' |
67 | - WHERE survey_id = '.(int)$_GET['survey_id'].' |
|
67 | + WHERE survey_id = '.(int) $_GET['survey_id'].' |
|
68 | 68 | ORDER BY name'; |
69 | 69 | $rs = Database::query($sql); |
70 | 70 | $glist = null; |
@@ -75,15 +75,15 @@ discard block |
||
75 | 75 | $grouplist = $grouplist1 = $grouplist2 = $glist; |
76 | 76 | |
77 | 77 | if (!empty($formData['assigned'])) { |
78 | - $grouplist = str_replace('<option value="'.$formData['assigned'].'"','<option value="'.$formData['assigned'].'" selected',$glist); |
|
78 | + $grouplist = str_replace('<option value="'.$formData['assigned'].'"', '<option value="'.$formData['assigned'].'" selected', $glist); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | if (!empty($formData['assigned1'])) { |
82 | - $grouplist1 = str_replace('<option value="'.$formData['assigned1'].'"','<option value="'.$formData['assigned1'].'" selected',$glist); |
|
82 | + $grouplist1 = str_replace('<option value="'.$formData['assigned1'].'"', '<option value="'.$formData['assigned1'].'" selected', $glist); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | if (!empty($formData['assigned2'])) { |
86 | - $grouplist2 = str_replace('<option value="'.$formData['assigned2'].'"','<option value="'.$formData['assigned2'].'" selected',$glist); |
|
86 | + $grouplist2 = str_replace('<option value="'.$formData['assigned2'].'"', '<option value="'.$formData['assigned2'].'" selected', $glist); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | $this->html .= ' <tr><td colspan=""> |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | $this->html .= ' |
97 | 97 | <b>'.get_lang('Secondary').'</b><br /> |
98 | - '.'<input type="radio" name="choose" value="2" '.(($formData['choose']==2)?'checked':''). |
|
98 | + '.'<input type="radio" name="choose" value="2" '.(($formData['choose'] == 2) ? 'checked' : ''). |
|
99 | 99 | '><select name="assigned1">'.$grouplist1.'</select> '. |
100 | 100 | '<select name="assigned2">'.$grouplist2.'</select>' |
101 | 101 | .'</fieldset><br />'; |
@@ -6,7 +6,7 @@ |
||
6 | 6 | |
7 | 7 | // Setting the global file that gets the general configuration, the databases, the languages, ... |
8 | 8 | require_once '../inc/global.inc.php'; |
9 | -$current_course_tool = TOOL_COURSE_MAINTENANCE; |
|
9 | +$current_course_tool = TOOL_COURSE_MAINTENANCE; |
|
10 | 10 | api_protect_course_script(true); |
11 | 11 | |
12 | 12 | // Notice for unauthorized people. |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | |
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 | - Display::display_header(get_lang('SurveyPreview')); |
|
47 | - Display::display_error_message(get_lang('InvallidSurvey'), false); |
|
48 | - Display::display_footer(); |
|
49 | - exit; |
|
46 | + Display::display_header(get_lang('SurveyPreview')); |
|
47 | + Display::display_error_message(get_lang('InvallidSurvey'), false); |
|
48 | + Display::display_footer(); |
|
49 | + exit; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | // Getting the survey information |
@@ -54,17 +54,17 @@ discard block |
||
54 | 54 | $survey_data = SurveyManager::get_survey($survey_id); |
55 | 55 | |
56 | 56 | if (empty($survey_data)) { |
57 | - Display::display_header(get_lang('SurveyPreview')); |
|
58 | - Display::display_error_message(get_lang('InvallidSurvey'), false); |
|
59 | - Display::display_footer(); |
|
60 | - exit; |
|
57 | + Display::display_header(get_lang('SurveyPreview')); |
|
58 | + Display::display_error_message(get_lang('InvallidSurvey'), false); |
|
59 | + Display::display_footer(); |
|
60 | + exit; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | $urlname = strip_tags($survey_data['title']); |
64 | 64 | if (api_is_allowed_to_edit()) { |
65 | - // Breadcrumbs |
|
66 | - $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php', 'name' => get_lang('SurveyList')); |
|
67 | - $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id, 'name' => $urlname); |
|
65 | + // Breadcrumbs |
|
66 | + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php', 'name' => get_lang('SurveyList')); |
|
67 | + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id, 'name' => $urlname); |
|
68 | 68 | } |
69 | 69 | $courseCode = isset($_GET['cidReq']) ? $_GET['cidReq'] : null; |
70 | 70 | $surveyAnonymous = SurveyManager::get_survey($survey_id, 0, $courseCode); |
@@ -92,57 +92,57 @@ discard block |
||
92 | 92 | $counter_question = 0; |
93 | 93 | // Only a course admin is allowed to preview a survey: you are a course admin |
94 | 94 | if (api_is_course_admin() || |
95 | - (api_is_course_admin() && $_GET['isStudentView'] == 'true') || |
|
96 | - api_is_allowed_to_session_edit(false, true) |
|
95 | + (api_is_course_admin() && $_GET['isStudentView'] == 'true') || |
|
96 | + api_is_allowed_to_session_edit(false, true) |
|
97 | 97 | ) { |
98 | - // Survey information |
|
99 | - echo '<div id="survey_title">'.$survey_data['survey_title'].'</div>'; |
|
100 | - echo '<div id="survey_subtitle">'.$survey_data['survey_subtitle'].'</div>'; |
|
98 | + // Survey information |
|
99 | + echo '<div id="survey_title">'.$survey_data['survey_title'].'</div>'; |
|
100 | + echo '<div id="survey_subtitle">'.$survey_data['survey_subtitle'].'</div>'; |
|
101 | 101 | |
102 | - // Displaying the survey introduction |
|
103 | - if (!isset($_GET['show'])) { |
|
102 | + // Displaying the survey introduction |
|
103 | + if (!isset($_GET['show'])) { |
|
104 | 104 | if (!empty($survey_data['survey_introduction'])) { |
105 | 105 | echo '<div id="survey_content" class="survey_content">'.$survey_data['survey_introduction'].'</div>'; |
106 | 106 | } |
107 | - $limit = 0; |
|
108 | - } |
|
107 | + $limit = 0; |
|
108 | + } |
|
109 | 109 | |
110 | - // Displaying the survey thanks message |
|
111 | - if (isset($_POST['finish_survey'])) { |
|
112 | - Display::display_confirmation_message(get_lang('SurveyFinished')); |
|
110 | + // Displaying the survey thanks message |
|
111 | + if (isset($_POST['finish_survey'])) { |
|
112 | + Display::display_confirmation_message(get_lang('SurveyFinished')); |
|
113 | 113 | echo $survey_data['survey_thanks']; |
114 | - Display :: display_footer(); |
|
115 | - exit; |
|
116 | - } |
|
114 | + Display :: display_footer(); |
|
115 | + exit; |
|
116 | + } |
|
117 | 117 | |
118 | 118 | $questions = array(); |
119 | 119 | |
120 | - if (isset($_GET['show'])) { |
|
121 | - // Getting all the questions for this page and add them to a |
|
122 | - // multidimensional array where the first index is the page. |
|
123 | - // as long as there is no pagebreak fount we keep adding questions to the page |
|
124 | - $questions_displayed = array(); |
|
125 | - $paged_questions = array(); |
|
126 | - $counter = 0; |
|
127 | - $sql = "SELECT * FROM $table_survey_question |
|
120 | + if (isset($_GET['show'])) { |
|
121 | + // Getting all the questions for this page and add them to a |
|
122 | + // multidimensional array where the first index is the page. |
|
123 | + // as long as there is no pagebreak fount we keep adding questions to the page |
|
124 | + $questions_displayed = array(); |
|
125 | + $paged_questions = array(); |
|
126 | + $counter = 0; |
|
127 | + $sql = "SELECT * FROM $table_survey_question |
|
128 | 128 | WHERE c_id = $course_id AND survey_id = '".intval($survey_id)."' |
129 | 129 | ORDER BY sort ASC"; |
130 | - $result = Database::query($sql); |
|
130 | + $result = Database::query($sql); |
|
131 | 131 | $questions_exists = true; |
132 | 132 | if (Database::num_rows($result)) { |
133 | - while ($row = Database::fetch_array($result)) { |
|
134 | - if ($row['type'] == 'pagebreak') { |
|
135 | - $counter++; |
|
136 | - } else { |
|
137 | - $paged_questions[$counter][] = $row['question_id']; |
|
138 | - } |
|
139 | - } |
|
133 | + while ($row = Database::fetch_array($result)) { |
|
134 | + if ($row['type'] == 'pagebreak') { |
|
135 | + $counter++; |
|
136 | + } else { |
|
137 | + $paged_questions[$counter][] = $row['question_id']; |
|
138 | + } |
|
139 | + } |
|
140 | 140 | } else { |
141 | 141 | $questions_exists = false; |
142 | 142 | } |
143 | 143 | |
144 | - if (array_key_exists($_GET['show'], $paged_questions)) { |
|
145 | - $sql = "SELECT |
|
144 | + if (array_key_exists($_GET['show'], $paged_questions)) { |
|
145 | + $sql = "SELECT |
|
146 | 146 | survey_question.question_id, |
147 | 147 | survey_question.survey_id, |
148 | 148 | survey_question.survey_question, |
@@ -164,75 +164,75 @@ discard block |
||
164 | 164 | survey_question.c_id = $course_id |
165 | 165 | ORDER BY survey_question.sort, survey_question_option.sort ASC"; |
166 | 166 | |
167 | - $result = Database::query($sql); |
|
168 | - $question_counter_max = Database::num_rows($result); |
|
169 | - $limit = 0; |
|
170 | - while ($row = Database::fetch_array($result)) { |
|
171 | - // If the type is not a pagebreak we store it in the $questions array |
|
172 | - if ($row['type'] != 'pagebreak') { |
|
173 | - $questions[$row['sort']]['question_id'] = $row['question_id']; |
|
174 | - $questions[$row['sort']]['survey_id'] = $row['survey_id']; |
|
175 | - $questions[$row['sort']]['survey_question'] = $row['survey_question']; |
|
176 | - $questions[$row['sort']]['display'] = $row['display']; |
|
177 | - $questions[$row['sort']]['type'] = $row['type']; |
|
178 | - $questions[$row['sort']]['options'][intval($row['option_sort'])] = $row['option_text']; |
|
179 | - $questions[$row['sort']]['maximum_score'] = $row['max_value']; |
|
180 | - } else { |
|
181 | - // If the type is a pagebreak we are finished loading the questions for this page |
|
182 | - break; |
|
183 | - } |
|
184 | - $counter_question++; |
|
185 | - } |
|
186 | - } |
|
187 | - } |
|
188 | - |
|
189 | - // Selecting the maximum number of pages |
|
190 | - $sql = "SELECT * FROM $table_survey_question |
|
167 | + $result = Database::query($sql); |
|
168 | + $question_counter_max = Database::num_rows($result); |
|
169 | + $limit = 0; |
|
170 | + while ($row = Database::fetch_array($result)) { |
|
171 | + // If the type is not a pagebreak we store it in the $questions array |
|
172 | + if ($row['type'] != 'pagebreak') { |
|
173 | + $questions[$row['sort']]['question_id'] = $row['question_id']; |
|
174 | + $questions[$row['sort']]['survey_id'] = $row['survey_id']; |
|
175 | + $questions[$row['sort']]['survey_question'] = $row['survey_question']; |
|
176 | + $questions[$row['sort']]['display'] = $row['display']; |
|
177 | + $questions[$row['sort']]['type'] = $row['type']; |
|
178 | + $questions[$row['sort']]['options'][intval($row['option_sort'])] = $row['option_text']; |
|
179 | + $questions[$row['sort']]['maximum_score'] = $row['max_value']; |
|
180 | + } else { |
|
181 | + // If the type is a pagebreak we are finished loading the questions for this page |
|
182 | + break; |
|
183 | + } |
|
184 | + $counter_question++; |
|
185 | + } |
|
186 | + } |
|
187 | + } |
|
188 | + |
|
189 | + // Selecting the maximum number of pages |
|
190 | + $sql = "SELECT * FROM $table_survey_question |
|
191 | 191 | WHERE |
192 | 192 | c_id = $course_id AND |
193 | 193 | type='".Database::escape_string('pagebreak')."' AND |
194 | 194 | survey_id='".intval($survey_id)."'"; |
195 | - $result = Database::query($sql); |
|
196 | - $numberofpages = Database::num_rows($result) + 1; |
|
197 | - |
|
198 | - // Displaying the form with the questions |
|
199 | - if (isset($_GET['show'])) { |
|
200 | - $show = (int)$_GET['show'] + 1; |
|
201 | - } else { |
|
202 | - $show = 0; |
|
203 | - } |
|
204 | - |
|
205 | - $url = api_get_self().'?survey_id='.Security::remove_XSS($survey_id).'&show='.$show; |
|
206 | - $form = new FormValidator('question', 'post', $url); |
|
207 | - |
|
208 | - if (is_array($questions) && count($questions) > 0) { |
|
209 | - foreach ($questions as $key => & $question) { |
|
210 | - $ch_type = 'ch_'.$question['type']; |
|
211 | - /** @var survey_question $display */ |
|
212 | - $display = new $ch_type; |
|
213 | - $form->addHtml('<div class="survey_question_wrapper"><div class="survey_question">'); |
|
214 | - $form->addHtml($question['survey_question']); |
|
215 | - $display->render($form, $question); |
|
216 | - $form->addHtml('</div></div>'); |
|
217 | - } |
|
218 | - } |
|
219 | - |
|
220 | - if (($show < $numberofpages) || (!$_GET['show'] && count($questions) > 0)) { |
|
195 | + $result = Database::query($sql); |
|
196 | + $numberofpages = Database::num_rows($result) + 1; |
|
197 | + |
|
198 | + // Displaying the form with the questions |
|
199 | + if (isset($_GET['show'])) { |
|
200 | + $show = (int)$_GET['show'] + 1; |
|
201 | + } else { |
|
202 | + $show = 0; |
|
203 | + } |
|
204 | + |
|
205 | + $url = api_get_self().'?survey_id='.Security::remove_XSS($survey_id).'&show='.$show; |
|
206 | + $form = new FormValidator('question', 'post', $url); |
|
207 | + |
|
208 | + if (is_array($questions) && count($questions) > 0) { |
|
209 | + foreach ($questions as $key => & $question) { |
|
210 | + $ch_type = 'ch_'.$question['type']; |
|
211 | + /** @var survey_question $display */ |
|
212 | + $display = new $ch_type; |
|
213 | + $form->addHtml('<div class="survey_question_wrapper"><div class="survey_question">'); |
|
214 | + $form->addHtml($question['survey_question']); |
|
215 | + $display->render($form, $question); |
|
216 | + $form->addHtml('</div></div>'); |
|
217 | + } |
|
218 | + } |
|
219 | + |
|
220 | + if (($show < $numberofpages) || (!$_GET['show'] && count($questions) > 0)) { |
|
221 | 221 | if ($show == 0) { |
222 | - $form->addButton('next_survey_page', get_lang('StartSurvey'), 'arrow-right', 'success', 'large'); |
|
222 | + $form->addButton('next_survey_page', get_lang('StartSurvey'), 'arrow-right', 'success', 'large'); |
|
223 | 223 | } else { |
224 | - $form->addButton('next_survey_page', get_lang('NextQuestion'), 'arrow-right'); |
|
224 | + $form->addButton('next_survey_page', get_lang('NextQuestion'), 'arrow-right'); |
|
225 | 225 | } |
226 | - } |
|
227 | - if ($show >= $numberofpages && $_GET['show'] || (isset($_GET['show']) && count($questions) == 0)) { |
|
228 | - if ($questions_exists == false) { |
|
229 | - echo '<p>'.get_lang('ThereAreNotQuestionsForthisSurvey').'</p>'; |
|
230 | - } |
|
231 | - $form->addButton('finish_survey', get_lang('FinishSurvey'), 'arrow-right'); |
|
232 | - } |
|
233 | - $form->display(); |
|
226 | + } |
|
227 | + if ($show >= $numberofpages && $_GET['show'] || (isset($_GET['show']) && count($questions) == 0)) { |
|
228 | + if ($questions_exists == false) { |
|
229 | + echo '<p>'.get_lang('ThereAreNotQuestionsForthisSurvey').'</p>'; |
|
230 | + } |
|
231 | + $form->addButton('finish_survey', get_lang('FinishSurvey'), 'arrow-right'); |
|
232 | + } |
|
233 | + $form->display(); |
|
234 | 234 | } else { |
235 | - Display :: display_error_message(get_lang('NotAllowed'), false); |
|
235 | + Display :: display_error_message(get_lang('NotAllowed'), false); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | // Footer |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | // We exit here if there is no valid $_GET parameter |
45 | -if (!isset($_GET['survey_id']) || !is_numeric($_GET['survey_id'])){ |
|
45 | +if (!isset($_GET['survey_id']) || !is_numeric($_GET['survey_id'])) { |
|
46 | 46 | Display::display_header(get_lang('SurveyPreview')); |
47 | 47 | Display::display_error_message(get_lang('InvallidSurvey'), false); |
48 | 48 | Display::display_footer(); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | survey_question_option.c_id = $course_id |
161 | 161 | WHERE |
162 | 162 | survey_question.survey_id = '".intval($survey_id)."' AND |
163 | - survey_question.question_id IN (".Database::escape_string(implode(',',$paged_questions[$_GET['show']]), null, false).") AND |
|
163 | + survey_question.question_id IN (".Database::escape_string(implode(',', $paged_questions[$_GET['show']]), null, false).") AND |
|
164 | 164 | survey_question.c_id = $course_id |
165 | 165 | ORDER BY survey_question.sort, survey_question_option.sort ASC"; |
166 | 166 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | |
198 | 198 | // Displaying the form with the questions |
199 | 199 | if (isset($_GET['show'])) { |
200 | - $show = (int)$_GET['show'] + 1; |
|
200 | + $show = (int) $_GET['show'] + 1; |
|
201 | 201 | } else { |
202 | 202 | $show = 0; |
203 | 203 | } |
@@ -38,7 +38,7 @@ |
||
38 | 38 | $options = array( |
39 | 39 | '--' => '--' |
40 | 40 | ); |
41 | - for ($i=1; $i <= $questionData['maximum_score']; $i++) { |
|
41 | + for ($i = 1; $i <= $questionData['maximum_score']; $i++) { |
|
42 | 42 | $options[$i] = $i; |
43 | 43 | } |
44 | 44 |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | if (api_is_allowed_to_edit()) { |
76 | 76 | SurveyManager::copy_survey($_GET['survey_id']); |
77 | 77 | $message = get_lang('SurveyCopied'); |
78 | - header('Location: ' . api_get_path(WEB_CODE_PATH) . 'survey/survey_list.php?' . api_get_cidreq()); |
|
78 | + header('Location: '.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq()); |
|
79 | 79 | exit; |
80 | 80 | } |
81 | 81 | } |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | if (!api_is_course_coach() || $extend_rights_for_coachs == 'true') { |
163 | 163 | // Action links |
164 | 164 | echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/create_new_survey.php?'.api_get_cidreq().'&action=add">'. |
165 | - Display::return_icon('new_survey.png', get_lang('CreateNewSurvey'),'',ICON_SIZE_MEDIUM).'</a> '; |
|
165 | + Display::return_icon('new_survey.png', get_lang('CreateNewSurvey'), '', ICON_SIZE_MEDIUM).'</a> '; |
|
166 | 166 | } |
167 | 167 | echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&search=advanced">'. |
168 | - Display::return_icon('search.png', get_lang('Search'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
168 | + Display::return_icon('search.png', get_lang('Search'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
169 | 169 | echo '</div>'; |
170 | 170 | |
171 | 171 | // Load main content |