@@ -7,7 +7,7 @@ |
||
7 | 7 | get_lang('MultiplicationStar')."\n". |
8 | 8 | get_lang('DivisionSlash')."\n". |
9 | 9 | get_lang('ExponentiationCircumflex')."\n". |
10 | -get_lang('ModuloPercentage') . "\n" . |
|
10 | +get_lang('ModuloPercentage')."\n". |
|
11 | 11 | "\n". |
12 | 12 | get_lang('SquareRootSqrt')."\n". |
13 | 13 | get_lang('AbsoluteValueAbs')."\n". |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | ), |
134 | 134 | array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '350')); |
135 | 135 | |
136 | - $form->addRule('answer', get_lang('GiveText'),'required'); |
|
137 | - $form->addRule('answer', get_lang('DefineBlanks'),'regex','/\[.*\]/'); |
|
136 | + $form->addRule('answer', get_lang('GiveText'), 'required'); |
|
137 | + $form->addRule('answer', get_lang('DefineBlanks'), 'regex', '/\[.*\]/'); |
|
138 | 138 | |
139 | 139 | $form->addElement('label', null, get_lang('IfYouWantOnlyIntegerValuesWriteBothLimitsWithoutDecimals')); |
140 | 140 | $form->addElement('html', '<div id="blanks_weighting"></div>'); |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $form->setDefaults(array('weighting' => '10')); |
162 | 162 | |
163 | 163 | $form->addElement('text', 'answerVariations', get_lang('AnswerVariations')); |
164 | - $form->addRule('answerVariations', get_lang('GiveAnswerVariations'),'required'); |
|
164 | + $form->addRule('answerVariations', get_lang('GiveAnswerVariations'), 'required'); |
|
165 | 165 | $form->setDefaults(array('answerVariations' => '1')); |
166 | 166 | |
167 | 167 | global $text; |
@@ -201,22 +201,21 @@ discard block |
||
201 | 201 | $answerVariations = $form->getSubmitValue('answerVariations'); |
202 | 202 | $this->weighting = $form->getSubmitValue('weighting'); |
203 | 203 | // Create as many answers as $answerVariations |
204 | - for ($j=0 ; $j < $answerVariations; $j++) { |
|
204 | + for ($j = 0; $j < $answerVariations; $j++) { |
|
205 | 205 | $auxAnswer = $answer; |
206 | 206 | $auxFormula = $formula; |
207 | 207 | $nb = preg_match_all('/\[[^\]]*\]/', $auxAnswer, $blanks); |
208 | 208 | if ($nb > 0) { |
209 | - for ($i=0 ; $i < $nb; ++$i) { |
|
209 | + for ($i = 0; $i < $nb; ++$i) { |
|
210 | 210 | $blankItem = $blanks[0][$i]; |
211 | 211 | $replace = array("[", "]"); |
212 | 212 | $newBlankItem = str_replace($replace, "", $blankItem); |
213 | 213 | $newBlankItem = "[".trim($newBlankItem)."]"; |
214 | 214 | // take random float values when one or both edge values have a decimal point |
215 | 215 | $randomValue = |
216 | - (strpos($lowestValues[$i],'.') !== false || |
|
217 | - strpos($highestValues[$i],'.') !== false) ? |
|
218 | - mt_rand($lowestValues[$i]*100,$highestValues[$i]*100)/100 : |
|
219 | - mt_rand($lowestValues[$i],$highestValues[$i]); |
|
216 | + (strpos($lowestValues[$i], '.') !== false || |
|
217 | + strpos($highestValues[$i], '.') !== false) ? |
|
218 | + mt_rand($lowestValues[$i] * 100, $highestValues[$i] * 100) / 100 : mt_rand($lowestValues[$i], $highestValues[$i]); |
|
220 | 219 | $auxAnswer = str_replace($blankItem, $randomValue, $auxAnswer); |
221 | 220 | $auxFormula = str_replace($blankItem, $randomValue, $auxFormula); |
222 | 221 | } |
@@ -250,7 +249,7 @@ discard block |
||
250 | 249 | function return_header($feedback_type = null, $counter = null, $score = null) |
251 | 250 | { |
252 | 251 | $header = parent::return_header($feedback_type, $counter, $score); |
253 | - $header .= '<table class="'.$this->question_table_class .'"> |
|
252 | + $header .= '<table class="'.$this->question_table_class.'"> |
|
254 | 253 | <tr> |
255 | 254 | <th>'.get_lang("Answer").'</th> |
256 | 255 | </tr>'; |
@@ -18,10 +18,10 @@ |
||
18 | 18 | $file = file(api_get_path(SYS_LANG_PATH).'english/hotspot.inc.php'); |
19 | 19 | |
20 | 20 | foreach ($file as &$value) { |
21 | - $variable = explode('=', $value , 2); |
|
22 | - if (count($variable) > 1) { |
|
23 | - $variable = substr(trim($variable[0]), 1); |
|
24 | - $variable = '&'.$variable.'='.api_utf8_encode(get_lang($variable)).' '; |
|
25 | - echo $variable; |
|
26 | - } |
|
21 | + $variable = explode('=', $value , 2); |
|
22 | + if (count($variable) > 1) { |
|
23 | + $variable = substr(trim($variable[0]), 1); |
|
24 | + $variable = '&'.$variable.'='.api_utf8_encode(get_lang($variable)).' '; |
|
25 | + echo $variable; |
|
26 | + } |
|
27 | 27 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | $file = file(api_get_path(SYS_LANG_PATH).'english/hotspot.inc.php'); |
19 | 19 | |
20 | 20 | foreach ($file as &$value) { |
21 | - $variable = explode('=', $value , 2); |
|
21 | + $variable = explode('=', $value, 2); |
|
22 | 22 | if (count($variable) > 1) { |
23 | 23 | $variable = substr(trim($variable[0]), 1); |
24 | 24 | $variable = '&'.$variable.'='.api_utf8_encode(get_lang($variable)).' '; |
@@ -249,7 +249,7 @@ |
||
249 | 249 | break; |
250 | 250 | case RESULT_DISABLE_SHOW_SCORE_ONLY: |
251 | 251 | if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_END) { |
252 | - $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score')); |
|
252 | + $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score')); |
|
253 | 253 | } |
254 | 254 | else { |
255 | 255 | $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score'), get_lang('Details')); |
@@ -250,8 +250,7 @@ |
||
250 | 250 | case RESULT_DISABLE_SHOW_SCORE_ONLY: |
251 | 251 | if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_END) { |
252 | 252 | $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score')); |
253 | - } |
|
254 | - else { |
|
253 | + } else { |
|
255 | 254 | $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score'), get_lang('Details')); |
256 | 255 | } |
257 | 256 | break; |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | require_once '../inc/global.inc.php'; |
14 | 14 | |
15 | -$current_course_tool = TOOL_QUIZ; |
|
15 | +$current_course_tool = TOOL_QUIZ; |
|
16 | 16 | |
17 | 17 | // Clear the exercise session just in case |
18 | 18 | Session::erase('objExercise'); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | $html = ''; |
72 | 72 | $message = ''; |
73 | -$html.= '<div class="exercise">'; |
|
73 | +$html .= '<div class="exercise">'; |
|
74 | 74 | $is_allowed_to_edit = api_is_allowed_to_edit(null, true); |
75 | 75 | $edit_link = ''; |
76 | 76 | if ($is_allowed_to_edit && $objExercise->sessionId == $sessionId) { |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | // 2. Exercise button |
118 | 118 | // Notice we not add there the lp_item_view_id because is not already generated |
119 | -$exercise_url = api_get_path(WEB_CODE_PATH) . 'exercise/exercise_submit.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&origin='.$origin.'&learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&learnpath_item_view_id='.$learnpathItemViewId.$extra_params; |
|
119 | +$exercise_url = api_get_path(WEB_CODE_PATH).'exercise/exercise_submit.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&origin='.$origin.'&learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&learnpath_item_view_id='.$learnpathItemViewId.$extra_params; |
|
120 | 120 | $exercise_url_button = Display::url( |
121 | 121 | $label, |
122 | 122 | $exercise_url, |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | $attempt_result['exe_result'], |
182 | 182 | $attempt_result['exe_weighting'] |
183 | 183 | ); |
184 | - $attempt_url = api_get_path(WEB_CODE_PATH) . 'exercise/result.php?'; |
|
185 | - $attempt_url .= api_get_cidreq() . '&show_headers=1&'; |
|
184 | + $attempt_url = api_get_path(WEB_CODE_PATH).'exercise/result.php?'; |
|
185 | + $attempt_url .= api_get_cidreq().'&show_headers=1&'; |
|
186 | 186 | $attempt_url .= http_build_query([ |
187 | 187 | 'id' => $attempt_result['exe_id'] |
188 | 188 | ]); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | get_lang('Show'), |
193 | 193 | $attempt_url, |
194 | 194 | [ |
195 | - 'class' => $btn_class . 'btn btn-default', |
|
195 | + 'class' => $btn_class.'btn btn-default', |
|
196 | 196 | 'data-title' => get_lang('Show'), |
197 | 197 | 'data-size' => 'lg' |
198 | 198 | ] |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | ), |
211 | 211 | 'userIp' => $attempt_result['user_ip'] |
212 | 212 | ); |
213 | - $attempt_link .= " " . $teacher_revised; |
|
213 | + $attempt_link .= " ".$teacher_revised; |
|
214 | 214 | |
215 | 215 | if (in_array( |
216 | 216 | $objExercise->results_disabled, |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | } |
307 | 307 | |
308 | 308 | if ($time_control) { |
309 | - $html.= $objExercise->return_time_left_div(); |
|
309 | + $html .= $objExercise->return_time_left_div(); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | $html .= $message; |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | $table_content, |
327 | 327 | ['class' => 'table-responsive'] |
328 | 328 | ); |
329 | -$html.= '</div>'; |
|
329 | +$html .= '</div>'; |
|
330 | 330 | echo $html; |
331 | 331 | |
332 | 332 | Display::display_footer(); |
@@ -72,12 +72,12 @@ discard block |
||
72 | 72 | for ($i = 1; $i <= $answer->nbrAnswers; $i++) { |
73 | 73 | if ($answer->isCorrect($i)) { |
74 | 74 | $nb_matches++; |
75 | - $defaults['answer[' . $nb_matches . ']'] = $answer->selectAnswer($i); |
|
76 | - $defaults['weighting[' . $nb_matches . ']'] = float_format($answer->selectWeighting($i), 1); |
|
77 | - $defaults['matches[' . $nb_matches . ']'] = $answer->correct[$i]; |
|
75 | + $defaults['answer['.$nb_matches.']'] = $answer->selectAnswer($i); |
|
76 | + $defaults['weighting['.$nb_matches.']'] = float_format($answer->selectWeighting($i), 1); |
|
77 | + $defaults['matches['.$nb_matches.']'] = $answer->correct[$i]; |
|
78 | 78 | } else { |
79 | 79 | $nb_options++; |
80 | - $defaults['option[' . $nb_options . ']'] = $answer->selectAnswer($i); |
|
80 | + $defaults['option['.$nb_options.']'] = $answer->selectAnswer($i); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | } |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | $html = '<table class="table table-striped table-hover"> |
109 | 109 | <thead> |
110 | 110 | <tr> |
111 | - <th width="5%">' . get_lang('Number') . '</th> |
|
112 | - <th width="70%">' . get_lang('Answer') . '</th> |
|
113 | - <th width="15%">' . get_lang('MatchesTo') . '</th> |
|
114 | - <th width="10%">' . get_lang('Weighting') . '</th> |
|
111 | + <th width="5%">' . get_lang('Number').'</th> |
|
112 | + <th width="70%">' . get_lang('Answer').'</th> |
|
113 | + <th width="15%">' . get_lang('MatchesTo').'</th> |
|
114 | + <th width="10%">' . get_lang('Weighting').'</th> |
|
115 | 115 | </tr> |
116 | 116 | </thead> |
117 | 117 | <tbody>'; |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | $html = '<table class="table table-striped table-hover"> |
163 | 163 | <thead> |
164 | 164 | <tr> |
165 | - <th width="15%">' . get_lang('Number') . '</th> |
|
166 | - <th width="85%">' . get_lang('Answer') . '</th> |
|
165 | + <th width="15%">' . get_lang('Number').'</th> |
|
166 | + <th width="85%">' . get_lang('Answer').'</th> |
|
167 | 167 | </tr> |
168 | 168 | </thead> |
169 | 169 | <tbody>'; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | |
186 | 186 | $form->addHtml('<tr>'); |
187 | 187 | |
188 | - $form->addHtml('<td>' . chr(64 + $i) . '</td>'); |
|
188 | + $form->addHtml('<td>'.chr(64 + $i).'</td>'); |
|
189 | 189 | $form->addText("option[$i]", null); |
190 | 190 | |
191 | 191 | $form->addHtml('</tr>'); |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | public function return_header($feedback_type = null, $counter = null, $score = null) |
268 | 268 | { |
269 | 269 | $header = parent::return_header($feedback_type, $counter, $score); |
270 | - $header .= '<table class="'.$this->question_table_class .'">'; |
|
270 | + $header .= '<table class="'.$this->question_table_class.'">'; |
|
271 | 271 | $header .= '<tr> |
272 | 272 | <th>'.get_lang('ElementList').'</th> |
273 | 273 | <th>'.get_lang('CorrespondsTo').'</th> |
@@ -223,10 +223,10 @@ |
||
223 | 223 | |
224 | 224 | $counter++; |
225 | 225 | if ($objExercise->type == ONE_PER_PAGE) { |
226 | - $question_title = Display::url($counter.'. '.cut($objQuestionTmp->selectTitle(), 40), $url); |
|
227 | - $question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40); |
|
226 | + $question_title = Display::url($counter.'. '.cut($objQuestionTmp->selectTitle(), 40), $url); |
|
227 | + $question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40); |
|
228 | 228 | } else { |
229 | - $question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40); |
|
229 | + $question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40); |
|
230 | 230 | } |
231 | 231 | //Check if the question doesn't have an answer |
232 | 232 | if (!in_array($questionId, $exercise_result)) { |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | // notice for unauthorized people. |
18 | 18 | api_protect_course_script(true); |
19 | 19 | |
20 | -if ($debug>0) { |
|
20 | +if ($debug > 0) { |
|
21 | 21 | error_log('Entered exercise_result.php: '.print_r($_POST, 1)); |
22 | 22 | } |
23 | 23 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | if (isset($_SESSION['exe_id'])) { |
98 | 98 | $exe_id = intval($_SESSION['exe_id']); |
99 | 99 | } |
100 | -$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id); |
|
100 | +$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id); |
|
101 | 101 | if (!empty($exercise_stat_info['data_tracking'])) { |
102 | 102 | $question_list = explode(',', $exercise_stat_info['data_tracking']); |
103 | 103 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | Display::url( |
250 | 250 | get_lang('ReviewQuestions'), |
251 | 251 | 'javascript://', |
252 | - array('onclick'=>'review_questions();','class'=>'btn btn-success') |
|
252 | + array('onclick'=>'review_questions();', 'class'=>'btn btn-success') |
|
253 | 253 | ); |
254 | 254 | |
255 | 255 | echo Display::div('', array('class'=>'clear')); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $objExercise->read($exerciseId); |
74 | 74 | |
75 | 75 | if ($objExercise->random_answers == '1') { |
76 | - $this->readOrderedBy('rand()', '');// randomize answers |
|
76 | + $this->readOrderedBy('rand()', ''); // randomize answers |
|
77 | 77 | } else { |
78 | 78 | $this->read(); // natural order |
79 | 79 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | ORDER BY position"; |
115 | 115 | |
116 | 116 | $result = Database::query($sql); |
117 | - $i=1; |
|
117 | + $i = 1; |
|
118 | 118 | |
119 | 119 | // while a record is found |
120 | 120 | while ($object = Database::fetch_object($result)) { |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $this->autoId[$i] = $object->id_auto; |
131 | 131 | $i++; |
132 | 132 | } |
133 | - $this->nbrAnswers = $i-1; |
|
133 | + $this->nbrAnswers = $i - 1; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | { |
143 | 143 | foreach ($this->autoId as $key => $autoId) { |
144 | 144 | if ($autoId == $id) { |
145 | - $result = [ |
|
145 | + $result = [ |
|
146 | 146 | 'answer' => $this->answer[$key], |
147 | 147 | 'correct' => $this->correct[$key], |
148 | 148 | 'comment' => $this->comment[$key], |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER); |
167 | 167 | $questionId = $this->questionId; |
168 | 168 | |
169 | - $sql="SELECT id FROM |
|
169 | + $sql = "SELECT id FROM |
|
170 | 170 | $TBL_ANSWER |
171 | 171 | WHERE c_id = {$this->course_id} AND question_id ='".$questionId."'"; |
172 | 172 | |
@@ -188,14 +188,14 @@ discard block |
||
188 | 188 | * @param string DESC or ASC |
189 | 189 | * @author Frederic Vauthier |
190 | 190 | */ |
191 | - public function readOrderedBy($field, $order='ASC') |
|
191 | + public function readOrderedBy($field, $order = 'ASC') |
|
192 | 192 | { |
193 | 193 | $field = Database::escape_string($field); |
194 | 194 | if (empty($field)) { |
195 | 195 | $field = 'position'; |
196 | 196 | } |
197 | 197 | |
198 | - if ($order != 'ASC' && $order!='DESC') { |
|
198 | + if ($order != 'ASC' && $order != 'DESC') { |
|
199 | 199 | $order = 'ASC'; |
200 | 200 | } |
201 | 201 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | c_id = {$this->course_id} AND |
231 | 231 | question_id='".$questionId."' |
232 | 232 | ORDER BY $field $order"; |
233 | - $result=Database::query($sql); |
|
233 | + $result = Database::query($sql); |
|
234 | 234 | |
235 | 235 | $i = 1; |
236 | 236 | // while a record is found |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | $this->autoId[$i] = $doubt_data->id_auto; |
261 | 261 | $i++; |
262 | 262 | } |
263 | - $this->nbrAnswers = $i-1; |
|
263 | + $this->nbrAnswers = $i - 1; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -402,8 +402,8 @@ discard block |
||
402 | 402 | public function getGradesList() |
403 | 403 | { |
404 | 404 | $list = array(); |
405 | - for ($i = 0; $i<$this->nbrAnswers;$i++){ |
|
406 | - if(!empty($this->answer[$i])){ |
|
405 | + for ($i = 0; $i < $this->nbrAnswers; $i++) { |
|
406 | + if (!empty($this->answer[$i])) { |
|
407 | 407 | $list[$i] = $this->weighting[$i]; |
408 | 408 | } |
409 | 409 | } |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | $sql = "SELECT type FROM $TBL_QUESTIONS |
422 | 422 | WHERE c_id = {$this->course_id} AND id = '".$this->questionId."'"; |
423 | 423 | $res = Database::query($sql); |
424 | - if (Database::num_rows($res)<=0){ |
|
424 | + if (Database::num_rows($res) <= 0) { |
|
425 | 425 | return null; |
426 | 426 | } |
427 | 427 | $row = Database::fetch_array($res); |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | $correctList = []; |
594 | 594 | $answerList = []; |
595 | 595 | |
596 | - for ($i=1; $i <= $this->new_nbrAnswers; $i++) { |
|
596 | + for ($i = 1; $i <= $this->new_nbrAnswers; $i++) { |
|
597 | 597 | $answer = $this->new_answer[$i]; |
598 | 598 | $correct = $this->new_correct[$i]; |
599 | 599 | $comment = $this->new_comment[$i]; |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | $destination_options = Question::readQuestionOption($newQuestionId, $course_info['real_id']); |
749 | 749 | $i = 0; |
750 | 750 | if (!empty($destination_options)) { |
751 | - foreach($destination_options as $item) { |
|
751 | + foreach ($destination_options as $item) { |
|
752 | 752 | $fixed_list[$new_option_list[$i]] = $item['id']; |
753 | 753 | $i++; |
754 | 754 | } |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | // inserts new answers into data base |
761 | 761 | $c_id = $course_info['real_id']; |
762 | 762 | |
763 | - for ($i=1;$i <= $this->nbrAnswers;$i++) { |
|
763 | + for ($i = 1; $i <= $this->nbrAnswers; $i++) { |
|
764 | 764 | if ($this->course['id'] != $course_info['id']) { |
765 | 765 | $this->answer[$i] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
766 | 766 | $this->answer[$i], |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | public $new_destination; // id of the next question if feedback option is set to Directfeedback |
38 | 38 | public $course; //Course information |
39 | 39 | public $iid; |
40 | - public $questionJSId; |
|
41 | - public $standalone; |
|
40 | + public $questionJSId; |
|
41 | + public $standalone; |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * constructor of the class |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | return []; |
160 | 160 | } |
161 | 161 | |
162 | - /** |
|
163 | - * returns all answer ids from this question Id |
|
164 | - * |
|
165 | - * @author Yoselyn Castillo |
|
166 | - * @return array - $id (answer ids) |
|
167 | - */ |
|
162 | + /** |
|
163 | + * returns all answer ids from this question Id |
|
164 | + * |
|
165 | + * @author Yoselyn Castillo |
|
166 | + * @return array - $id (answer ids) |
|
167 | + */ |
|
168 | 168 | public function selectAnswerId() |
169 | 169 | { |
170 | 170 | $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER); |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | } |
185 | 185 | |
186 | 186 | return $id; |
187 | - } |
|
187 | + } |
|
188 | 188 | |
189 | 189 | /** |
190 | 190 | * Reads answer information from the data base ordered by parameter |
@@ -195,23 +195,23 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function readOrderedBy($field, $order='ASC') |
197 | 197 | { |
198 | - $field = Database::escape_string($field); |
|
199 | - if (empty($field)) { |
|
200 | - $field = 'position'; |
|
201 | - } |
|
198 | + $field = Database::escape_string($field); |
|
199 | + if (empty($field)) { |
|
200 | + $field = 'position'; |
|
201 | + } |
|
202 | 202 | |
203 | - if ($order != 'ASC' && $order!='DESC') { |
|
204 | - $order = 'ASC'; |
|
205 | - } |
|
203 | + if ($order != 'ASC' && $order!='DESC') { |
|
204 | + $order = 'ASC'; |
|
205 | + } |
|
206 | 206 | |
207 | - $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
208 | - $TBL_QUIZ = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
209 | - $questionId = intval($this->questionId); |
|
207 | + $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
208 | + $TBL_QUIZ = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
209 | + $questionId = intval($this->questionId); |
|
210 | 210 | |
211 | - $sql = "SELECT type FROM $TBL_QUIZ |
|
211 | + $sql = "SELECT type FROM $TBL_QUIZ |
|
212 | 212 | WHERE c_id = {$this->course_id} AND id = $questionId"; |
213 | - $result_question = Database::query($sql); |
|
214 | - $questionType = Database::fetch_array($result_question); |
|
213 | + $result_question = Database::query($sql); |
|
214 | + $questionType = Database::fetch_array($result_question); |
|
215 | 215 | |
216 | 216 | if ($questionType['type'] == DRAGGABLE) { |
217 | 217 | // Random is done by submit.js.tpl |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | return true; |
221 | 221 | } |
222 | 222 | |
223 | - $sql = "SELECT |
|
223 | + $sql = "SELECT |
|
224 | 224 | answer, |
225 | 225 | correct, |
226 | 226 | comment, |
@@ -236,16 +236,16 @@ discard block |
||
236 | 236 | c_id = {$this->course_id} AND |
237 | 237 | question_id='".$questionId."' |
238 | 238 | ORDER BY $field $order"; |
239 | - $result=Database::query($sql); |
|
240 | - |
|
241 | - $i = 1; |
|
242 | - // while a record is found |
|
243 | - $doubt_data = null; |
|
244 | - while ($object = Database::fetch_object($result)) { |
|
245 | - if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && $object->position == 666) { |
|
246 | - $doubt_data = $object; |
|
239 | + $result=Database::query($sql); |
|
240 | + |
|
241 | + $i = 1; |
|
242 | + // while a record is found |
|
243 | + $doubt_data = null; |
|
244 | + while ($object = Database::fetch_object($result)) { |
|
245 | + if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && $object->position == 666) { |
|
246 | + $doubt_data = $object; |
|
247 | 247 | continue; |
248 | - } |
|
248 | + } |
|
249 | 249 | $this->answer[$i] = $object->answer; |
250 | 250 | $this->correct[$i] = $object->correct; |
251 | 251 | $this->comment[$i] = $object->comment; |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | $this->autoId[$i] = $object->id_auto; |
258 | 258 | $this->iid[$i] = $object->iid; |
259 | 259 | $i++; |
260 | - } |
|
260 | + } |
|
261 | 261 | |
262 | - if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && !empty($doubt_data)) { |
|
262 | + if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && !empty($doubt_data)) { |
|
263 | 263 | $this->answer[$i] = $doubt_data->answer; |
264 | 264 | $this->correct[$i] = $doubt_data->correct; |
265 | 265 | $this->comment[$i] = $doubt_data->comment; |
@@ -271,88 +271,88 @@ discard block |
||
271 | 271 | $this->autoId[$i] = $doubt_data->id_auto; |
272 | 272 | $this->iid[$i] = $doubt_data->iid; |
273 | 273 | $i++; |
274 | - } |
|
274 | + } |
|
275 | 275 | $this->nbrAnswers = $i-1; |
276 | - } |
|
277 | - |
|
278 | - /** |
|
279 | - * returns the autoincrement id identificator |
|
280 | - * |
|
281 | - * @author Juan Carlos Ra�a |
|
282 | - * @return integer - answer num |
|
283 | - */ |
|
276 | + } |
|
277 | + |
|
278 | + /** |
|
279 | + * returns the autoincrement id identificator |
|
280 | + * |
|
281 | + * @author Juan Carlos Ra�a |
|
282 | + * @return integer - answer num |
|
283 | + */ |
|
284 | 284 | public function selectAutoId($id) |
285 | 285 | { |
286 | - return isset($this->autoId[$id]) ? $this->autoId[$id] : 0; |
|
287 | - } |
|
288 | - |
|
289 | - /** |
|
290 | - * returns the number of answers in this question |
|
291 | - * |
|
292 | - * @author Olivier Brouckaert |
|
293 | - * @return integer - number of answers |
|
294 | - */ |
|
295 | - public function selectNbrAnswers() |
|
286 | + return isset($this->autoId[$id]) ? $this->autoId[$id] : 0; |
|
287 | + } |
|
288 | + |
|
289 | + /** |
|
290 | + * returns the number of answers in this question |
|
291 | + * |
|
292 | + * @author Olivier Brouckaert |
|
293 | + * @return integer - number of answers |
|
294 | + */ |
|
295 | + public function selectNbrAnswers() |
|
296 | 296 | { |
297 | - return $this->nbrAnswers; |
|
298 | - } |
|
299 | - |
|
300 | - /** |
|
301 | - * returns the question ID which the answers belong to |
|
302 | - * |
|
303 | - * @author Olivier Brouckaert |
|
304 | - * @return integer - the question ID |
|
305 | - */ |
|
306 | - public function selectQuestionId() |
|
297 | + return $this->nbrAnswers; |
|
298 | + } |
|
299 | + |
|
300 | + /** |
|
301 | + * returns the question ID which the answers belong to |
|
302 | + * |
|
303 | + * @author Olivier Brouckaert |
|
304 | + * @return integer - the question ID |
|
305 | + */ |
|
306 | + public function selectQuestionId() |
|
307 | 307 | { |
308 | - return $this->questionId; |
|
309 | - } |
|
310 | - |
|
311 | - /** |
|
312 | - * returns the question ID of the destination question |
|
313 | - * |
|
314 | - * @author Julio Montoya |
|
315 | - * @param integer $id |
|
316 | - * @return integer - the question ID |
|
317 | - */ |
|
318 | - public function selectDestination($id) |
|
308 | + return $this->questionId; |
|
309 | + } |
|
310 | + |
|
311 | + /** |
|
312 | + * returns the question ID of the destination question |
|
313 | + * |
|
314 | + * @author Julio Montoya |
|
315 | + * @param integer $id |
|
316 | + * @return integer - the question ID |
|
317 | + */ |
|
318 | + public function selectDestination($id) |
|
319 | 319 | { |
320 | - return isset($this->destination[$id]) ? $this->destination[$id] : null; |
|
321 | - } |
|
320 | + return isset($this->destination[$id]) ? $this->destination[$id] : null; |
|
321 | + } |
|
322 | 322 | |
323 | 323 | /** |
324 | - * returns the answer title |
|
325 | - * |
|
326 | - * @author Olivier Brouckaert |
|
327 | - * @param - integer $id - answer ID |
|
328 | - * @return string - answer title |
|
329 | - */ |
|
330 | - public function selectAnswer($id) |
|
331 | - { |
|
332 | - return isset($this->answer[$id]) ? $this->answer[$id] : null; |
|
333 | - } |
|
334 | - |
|
335 | - /** |
|
336 | - * return array answer by id else return a bool |
|
337 | - * @param integer $auto_id |
|
338 | - */ |
|
339 | - public function selectAnswerByAutoId($auto_id) |
|
340 | - { |
|
341 | - $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
342 | - |
|
343 | - $auto_id = intval($auto_id); |
|
344 | - $sql = "SELECT id, answer, id_auto FROM $TBL_ANSWER |
|
324 | + * returns the answer title |
|
325 | + * |
|
326 | + * @author Olivier Brouckaert |
|
327 | + * @param - integer $id - answer ID |
|
328 | + * @return string - answer title |
|
329 | + */ |
|
330 | + public function selectAnswer($id) |
|
331 | + { |
|
332 | + return isset($this->answer[$id]) ? $this->answer[$id] : null; |
|
333 | + } |
|
334 | + |
|
335 | + /** |
|
336 | + * return array answer by id else return a bool |
|
337 | + * @param integer $auto_id |
|
338 | + */ |
|
339 | + public function selectAnswerByAutoId($auto_id) |
|
340 | + { |
|
341 | + $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
342 | + |
|
343 | + $auto_id = intval($auto_id); |
|
344 | + $sql = "SELECT id, answer, id_auto FROM $TBL_ANSWER |
|
345 | 345 | WHERE c_id = {$this->course_id} AND id_auto='$auto_id'"; |
346 | - $rs = Database::query($sql); |
|
346 | + $rs = Database::query($sql); |
|
347 | 347 | |
348 | - if (Database::num_rows($rs) > 0) { |
|
349 | - $row = Database::fetch_array($rs, 'ASSOC'); |
|
348 | + if (Database::num_rows($rs) > 0) { |
|
349 | + $row = Database::fetch_array($rs, 'ASSOC'); |
|
350 | 350 | |
351 | - return $row; |
|
352 | - } |
|
351 | + return $row; |
|
352 | + } |
|
353 | 353 | |
354 | - return false; |
|
355 | - } |
|
354 | + return false; |
|
355 | + } |
|
356 | 356 | |
357 | 357 | /** |
358 | 358 | * returns the answer title from an answer's position |
@@ -361,18 +361,18 @@ discard block |
||
361 | 361 | * @param - integer $id - answer ID |
362 | 362 | * @return bool - answer title |
363 | 363 | */ |
364 | - public function selectAnswerIdByPosition($pos) |
|
365 | - { |
|
366 | - foreach ($this->position as $k => $v) { |
|
367 | - if ($v != $pos) { |
|
368 | - continue; |
|
369 | - } |
|
364 | + public function selectAnswerIdByPosition($pos) |
|
365 | + { |
|
366 | + foreach ($this->position as $k => $v) { |
|
367 | + if ($v != $pos) { |
|
368 | + continue; |
|
369 | + } |
|
370 | 370 | |
371 | - return $k; |
|
372 | - } |
|
371 | + return $k; |
|
372 | + } |
|
373 | 373 | |
374 | - return false; |
|
375 | - } |
|
374 | + return false; |
|
375 | + } |
|
376 | 376 | |
377 | 377 | /** |
378 | 378 | * Returns a list of answers |
@@ -381,18 +381,18 @@ discard block |
||
381 | 381 | * of (id, answer, comment, grade) and grade=weighting |
382 | 382 | */ |
383 | 383 | public function getAnswersList($decode = false) |
384 | - { |
|
385 | - $list = array(); |
|
386 | - for ($i = 1; $i <= $this->nbrAnswers; $i++) { |
|
387 | - if (!empty($this->answer[$i])) { |
|
388 | - |
|
389 | - //Avoid problems when parsing elements with accents |
|
390 | - if ($decode) { |
|
391 | - $this->answer[$i] = api_html_entity_decode($this->answer[$i], ENT_QUOTES, api_get_system_encoding()); |
|
392 | - $this->comment[$i] = api_html_entity_decode($this->comment[$i], ENT_QUOTES, api_get_system_encoding()); |
|
393 | - } |
|
394 | - |
|
395 | - $list[] = array( |
|
384 | + { |
|
385 | + $list = array(); |
|
386 | + for ($i = 1; $i <= $this->nbrAnswers; $i++) { |
|
387 | + if (!empty($this->answer[$i])) { |
|
388 | + |
|
389 | + //Avoid problems when parsing elements with accents |
|
390 | + if ($decode) { |
|
391 | + $this->answer[$i] = api_html_entity_decode($this->answer[$i], ENT_QUOTES, api_get_system_encoding()); |
|
392 | + $this->comment[$i] = api_html_entity_decode($this->comment[$i], ENT_QUOTES, api_get_system_encoding()); |
|
393 | + } |
|
394 | + |
|
395 | + $list[] = array( |
|
396 | 396 | 'id' => $i, |
397 | 397 | 'answer' => $this->answer[$i], |
398 | 398 | 'comment' => $this->comment[$i], |
@@ -401,137 +401,137 @@ discard block |
||
401 | 401 | 'hotspot_type' => $this->hotspot_type[$i], |
402 | 402 | 'correct' => $this->correct[$i], |
403 | 403 | 'destination' => $this->destination[$i] |
404 | - ); |
|
404 | + ); |
|
405 | + } |
|
405 | 406 | } |
406 | - } |
|
407 | 407 | |
408 | - return $list; |
|
409 | - } |
|
408 | + return $list; |
|
409 | + } |
|
410 | 410 | |
411 | - /** |
|
412 | - * Returns a list of grades |
|
413 | - * @author Yannick Warnier <[email protected]> |
|
414 | - * @return array List of grades where grade=weighting (?) |
|
415 | - */ |
|
411 | + /** |
|
412 | + * Returns a list of grades |
|
413 | + * @author Yannick Warnier <[email protected]> |
|
414 | + * @return array List of grades where grade=weighting (?) |
|
415 | + */ |
|
416 | 416 | public function getGradesList() |
417 | - { |
|
418 | - $list = array(); |
|
419 | - for ($i = 0; $i<$this->nbrAnswers;$i++){ |
|
420 | - if(!empty($this->answer[$i])){ |
|
421 | - $list[$i] = $this->weighting[$i]; |
|
422 | - } |
|
423 | - } |
|
424 | - return $list; |
|
425 | - } |
|
426 | - |
|
427 | - /** |
|
428 | - * Returns the question type |
|
429 | - * @author Yannick Warnier <[email protected]> |
|
430 | - * @return integer The type of the question this answer is bound to |
|
431 | - */ |
|
417 | + { |
|
418 | + $list = array(); |
|
419 | + for ($i = 0; $i<$this->nbrAnswers;$i++){ |
|
420 | + if(!empty($this->answer[$i])){ |
|
421 | + $list[$i] = $this->weighting[$i]; |
|
422 | + } |
|
423 | + } |
|
424 | + return $list; |
|
425 | + } |
|
426 | + |
|
427 | + /** |
|
428 | + * Returns the question type |
|
429 | + * @author Yannick Warnier <[email protected]> |
|
430 | + * @return integer The type of the question this answer is bound to |
|
431 | + */ |
|
432 | 432 | public function getQuestionType() |
433 | - { |
|
434 | - $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
435 | - $sql = "SELECT type FROM $TBL_QUESTIONS |
|
433 | + { |
|
434 | + $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
435 | + $sql = "SELECT type FROM $TBL_QUESTIONS |
|
436 | 436 | WHERE c_id = {$this->course_id} AND id = '".$this->questionId."'"; |
437 | - $res = Database::query($sql); |
|
438 | - if (Database::num_rows($res)<=0){ |
|
439 | - return null; |
|
440 | - } |
|
441 | - $row = Database::fetch_array($res); |
|
442 | - |
|
443 | - return $row['type']; |
|
444 | - } |
|
445 | - |
|
446 | - |
|
447 | - /** |
|
448 | - * tells if answer is correct or not |
|
449 | - * |
|
450 | - * @author Olivier Brouckaert |
|
451 | - * @param - integer $id - answer ID |
|
452 | - * @return integer - 0 if bad answer, not 0 if good answer |
|
453 | - */ |
|
437 | + $res = Database::query($sql); |
|
438 | + if (Database::num_rows($res)<=0){ |
|
439 | + return null; |
|
440 | + } |
|
441 | + $row = Database::fetch_array($res); |
|
442 | + |
|
443 | + return $row['type']; |
|
444 | + } |
|
445 | + |
|
446 | + |
|
447 | + /** |
|
448 | + * tells if answer is correct or not |
|
449 | + * |
|
450 | + * @author Olivier Brouckaert |
|
451 | + * @param - integer $id - answer ID |
|
452 | + * @return integer - 0 if bad answer, not 0 if good answer |
|
453 | + */ |
|
454 | 454 | public function isCorrect($id) |
455 | - { |
|
456 | - return isset($this->correct[$id]) ? $this->correct[$id] : null; |
|
457 | - } |
|
458 | - |
|
459 | - /** |
|
460 | - * returns answer comment |
|
461 | - * |
|
462 | - * @author Olivier Brouckaert |
|
463 | - * @param - integer $id - answer ID |
|
464 | - * @return string - answer comment |
|
465 | - */ |
|
455 | + { |
|
456 | + return isset($this->correct[$id]) ? $this->correct[$id] : null; |
|
457 | + } |
|
458 | + |
|
459 | + /** |
|
460 | + * returns answer comment |
|
461 | + * |
|
462 | + * @author Olivier Brouckaert |
|
463 | + * @param - integer $id - answer ID |
|
464 | + * @return string - answer comment |
|
465 | + */ |
|
466 | 466 | public function selectComment($id) |
467 | - { |
|
467 | + { |
|
468 | 468 | return isset($this->comment[$id]) ? $this->comment[$id] : null; |
469 | - } |
|
470 | - |
|
471 | - /** |
|
472 | - * returns answer weighting |
|
473 | - * |
|
474 | - * @author Olivier Brouckaert |
|
475 | - * @param - integer $id - answer ID |
|
476 | - * @param integer $id |
|
477 | - * @return integer - answer weighting |
|
478 | - */ |
|
469 | + } |
|
470 | + |
|
471 | + /** |
|
472 | + * returns answer weighting |
|
473 | + * |
|
474 | + * @author Olivier Brouckaert |
|
475 | + * @param - integer $id - answer ID |
|
476 | + * @param integer $id |
|
477 | + * @return integer - answer weighting |
|
478 | + */ |
|
479 | 479 | public function selectWeighting($id) |
480 | - { |
|
481 | - return isset($this->weighting[$id]) ? $this->weighting[$id] : null; |
|
482 | - } |
|
483 | - |
|
484 | - /** |
|
485 | - * returns answer position |
|
486 | - * |
|
487 | - * @author Olivier Brouckaert |
|
488 | - * @param - integer $id - answer ID |
|
489 | - * @return integer - answer position |
|
490 | - */ |
|
491 | - function selectPosition($id) |
|
492 | - { |
|
493 | - return isset($this->position[$id]) ? $this->position[$id] : null; |
|
494 | - } |
|
495 | - |
|
496 | - /** |
|
497 | - * returns answer hotspot coordinates |
|
498 | - * |
|
499 | - * @author Olivier Brouckaert |
|
500 | - * @param integer Answer ID |
|
501 | - * @param integer $id |
|
502 | - * @return integer Answer position |
|
503 | - */ |
|
480 | + { |
|
481 | + return isset($this->weighting[$id]) ? $this->weighting[$id] : null; |
|
482 | + } |
|
483 | + |
|
484 | + /** |
|
485 | + * returns answer position |
|
486 | + * |
|
487 | + * @author Olivier Brouckaert |
|
488 | + * @param - integer $id - answer ID |
|
489 | + * @return integer - answer position |
|
490 | + */ |
|
491 | + function selectPosition($id) |
|
492 | + { |
|
493 | + return isset($this->position[$id]) ? $this->position[$id] : null; |
|
494 | + } |
|
495 | + |
|
496 | + /** |
|
497 | + * returns answer hotspot coordinates |
|
498 | + * |
|
499 | + * @author Olivier Brouckaert |
|
500 | + * @param integer Answer ID |
|
501 | + * @param integer $id |
|
502 | + * @return integer Answer position |
|
503 | + */ |
|
504 | 504 | public function selectHotspotCoordinates($id) |
505 | - { |
|
506 | - return isset($this->hotspot_coordinates[$id]) ? $this->hotspot_coordinates[$id] : null; |
|
507 | - } |
|
508 | - |
|
509 | - /** |
|
510 | - * returns answer hotspot type |
|
511 | - * |
|
512 | - * @author Toon Keppens |
|
513 | - * @param integer Answer ID |
|
514 | - * @param integer $id |
|
515 | - * @return integer Answer position |
|
516 | - */ |
|
505 | + { |
|
506 | + return isset($this->hotspot_coordinates[$id]) ? $this->hotspot_coordinates[$id] : null; |
|
507 | + } |
|
508 | + |
|
509 | + /** |
|
510 | + * returns answer hotspot type |
|
511 | + * |
|
512 | + * @author Toon Keppens |
|
513 | + * @param integer Answer ID |
|
514 | + * @param integer $id |
|
515 | + * @return integer Answer position |
|
516 | + */ |
|
517 | 517 | public function selectHotspotType($id) |
518 | - { |
|
519 | - return isset($this->hotspot_type[$id]) ? $this->hotspot_type[$id] : null; |
|
520 | - } |
|
521 | - |
|
522 | - /** |
|
523 | - * Creates a new answer |
|
524 | - * |
|
525 | - * @author Olivier Brouckaert |
|
526 | - * @param string $answer answer title |
|
527 | - * @param integer $correct 0 if bad answer, not 0 if good answer |
|
528 | - * @param string $comment answer comment |
|
529 | - * @param integer $weighting answer weighting |
|
530 | - * @param integer $position answer position |
|
531 | - * @param array $new_hotspot_coordinates Coordinates for hotspot exercises (optional) |
|
532 | - * @param integer $new_hotspot_type Type for hotspot exercises (optional) |
|
518 | + { |
|
519 | + return isset($this->hotspot_type[$id]) ? $this->hotspot_type[$id] : null; |
|
520 | + } |
|
521 | + |
|
522 | + /** |
|
523 | + * Creates a new answer |
|
524 | + * |
|
525 | + * @author Olivier Brouckaert |
|
526 | + * @param string $answer answer title |
|
527 | + * @param integer $correct 0 if bad answer, not 0 if good answer |
|
528 | + * @param string $comment answer comment |
|
529 | + * @param integer $weighting answer weighting |
|
530 | + * @param integer $position answer position |
|
531 | + * @param array $new_hotspot_coordinates Coordinates for hotspot exercises (optional) |
|
532 | + * @param integer $new_hotspot_type Type for hotspot exercises (optional) |
|
533 | 533 | * @param string $destination |
534 | - */ |
|
534 | + */ |
|
535 | 535 | public function createAnswer( |
536 | 536 | $answer, |
537 | 537 | $correct, |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | $new_hotspot_type = null, |
543 | 543 | $destination = '' |
544 | 544 | ) { |
545 | - $this->new_nbrAnswers++; |
|
545 | + $this->new_nbrAnswers++; |
|
546 | 546 | $id = $this->new_nbrAnswers; |
547 | 547 | $this->new_answer[$id] = $answer; |
548 | 548 | $this->new_correct[$id] = $correct; |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | $this->new_hotspot_coordinates[$id] = $new_hotspot_coordinates; |
553 | 553 | $this->new_hotspot_type[$id] = $new_hotspot_type; |
554 | 554 | $this->new_destination[$id] = $destination; |
555 | - } |
|
555 | + } |
|
556 | 556 | |
557 | 557 | /** |
558 | 558 | * Updates an answer |
@@ -595,32 +595,32 @@ discard block |
||
595 | 595 | |
596 | 596 | $em->merge($quizAnswer); |
597 | 597 | $em->flush(); |
598 | - } |
|
598 | + } |
|
599 | 599 | |
600 | - /** |
|
601 | - * Records answers into the data base |
|
602 | - * |
|
603 | - * @author Olivier Brouckaert |
|
604 | - */ |
|
600 | + /** |
|
601 | + * Records answers into the data base |
|
602 | + * |
|
603 | + * @author Olivier Brouckaert |
|
604 | + */ |
|
605 | 605 | public function save() |
606 | 606 | { |
607 | - $answerTable = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
607 | + $answerTable = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
608 | 608 | $em = Database::getManager(); |
609 | - $questionId = intval($this->questionId); |
|
609 | + $questionId = intval($this->questionId); |
|
610 | 610 | |
611 | - $c_id = $this->course['real_id']; |
|
611 | + $c_id = $this->course['real_id']; |
|
612 | 612 | $correctList = []; |
613 | 613 | $answerList = []; |
614 | 614 | |
615 | - for ($i=1; $i <= $this->new_nbrAnswers; $i++) { |
|
616 | - $answer = $this->new_answer[$i]; |
|
617 | - $correct = isset($this->new_correct[$i]) ? $this->new_correct[$i] : ''; |
|
618 | - $comment = isset($this->new_comment[$i]) ? $this->new_comment[$i] : ''; |
|
619 | - $weighting = isset($this->new_weighting[$i]) ? $this->new_weighting[$i] : ''; |
|
620 | - $position = isset($this->new_position[$i]) ? $this->new_position[$i] : ''; |
|
621 | - $hotspot_coordinates = isset($this->new_hotspot_coordinates[$i]) ? $this->new_hotspot_coordinates[$i] : ''; |
|
622 | - $hotspot_type = isset($this->new_hotspot_type[$i]) ? $this->new_hotspot_type[$i] : ''; |
|
623 | - $destination = isset($this->new_destination[$i]) ? $this->new_destination[$i] : ''; |
|
615 | + for ($i=1; $i <= $this->new_nbrAnswers; $i++) { |
|
616 | + $answer = $this->new_answer[$i]; |
|
617 | + $correct = isset($this->new_correct[$i]) ? $this->new_correct[$i] : ''; |
|
618 | + $comment = isset($this->new_comment[$i]) ? $this->new_comment[$i] : ''; |
|
619 | + $weighting = isset($this->new_weighting[$i]) ? $this->new_weighting[$i] : ''; |
|
620 | + $position = isset($this->new_position[$i]) ? $this->new_position[$i] : ''; |
|
621 | + $hotspot_coordinates = isset($this->new_hotspot_coordinates[$i]) ? $this->new_hotspot_coordinates[$i] : ''; |
|
622 | + $hotspot_type = isset($this->new_hotspot_type[$i]) ? $this->new_hotspot_type[$i] : ''; |
|
623 | + $destination = isset($this->new_destination[$i]) ? $this->new_destination[$i] : ''; |
|
624 | 624 | $autoId = $this->selectAutoId($i); |
625 | 625 | $iid = isset($this->iid[$i]) ? $this->iid[$i] : 0; |
626 | 626 | |
@@ -663,11 +663,11 @@ discard block |
||
663 | 663 | |
664 | 664 | $correctAnswerId = $answer->selectAnswerIdByPosition($correct); |
665 | 665 | |
666 | - // Continue to avoid matching question bug if $correctAnswerId returns false |
|
667 | - // See : https://support.chamilo.org/issues/8334 |
|
668 | - if ($questionType == MATCHING && !$correctAnswerId) { |
|
669 | - continue; |
|
670 | - } |
|
666 | + // Continue to avoid matching question bug if $correctAnswerId returns false |
|
667 | + // See : https://support.chamilo.org/issues/8334 |
|
668 | + if ($questionType == MATCHING && !$correctAnswerId) { |
|
669 | + continue; |
|
670 | + } |
|
671 | 671 | |
672 | 672 | $correctAnswerAutoId = $answer->selectAutoId($correct); |
673 | 673 | |
@@ -734,28 +734,28 @@ discard block |
||
734 | 734 | } |
735 | 735 | } |
736 | 736 | |
737 | - // moves $new_* arrays |
|
738 | - $this->answer = $this->new_answer; |
|
739 | - $this->correct = $this->new_correct; |
|
740 | - $this->comment = $this->new_comment; |
|
741 | - $this->weighting = $this->new_weighting; |
|
742 | - $this->position = $this->new_position; |
|
743 | - $this->hotspot_coordinates = $this->new_hotspot_coordinates; |
|
744 | - $this->hotspot_type = $this->new_hotspot_type; |
|
745 | - $this->nbrAnswers = $this->new_nbrAnswers; |
|
746 | - $this->destination = $this->new_destination; |
|
747 | - |
|
748 | - $this->cancel(); |
|
749 | - } |
|
750 | - |
|
751 | - /** |
|
752 | - * Duplicates answers by copying them into another question |
|
753 | - * |
|
754 | - * @author Olivier Brouckaert |
|
755 | - * @param int question id |
|
737 | + // moves $new_* arrays |
|
738 | + $this->answer = $this->new_answer; |
|
739 | + $this->correct = $this->new_correct; |
|
740 | + $this->comment = $this->new_comment; |
|
741 | + $this->weighting = $this->new_weighting; |
|
742 | + $this->position = $this->new_position; |
|
743 | + $this->hotspot_coordinates = $this->new_hotspot_coordinates; |
|
744 | + $this->hotspot_type = $this->new_hotspot_type; |
|
745 | + $this->nbrAnswers = $this->new_nbrAnswers; |
|
746 | + $this->destination = $this->new_destination; |
|
747 | + |
|
748 | + $this->cancel(); |
|
749 | + } |
|
750 | + |
|
751 | + /** |
|
752 | + * Duplicates answers by copying them into another question |
|
753 | + * |
|
754 | + * @author Olivier Brouckaert |
|
755 | + * @param int question id |
|
756 | 756 | * @param array destination course info (result of the function api_get_course_info() ) |
757 | 757 | * @param string $newQuestionId |
758 | - */ |
|
758 | + */ |
|
759 | 759 | public function duplicate($newQuestionId, $course_info = null) |
760 | 760 | { |
761 | 761 | if (empty($course_info)) { |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | |
776 | 776 | if (!empty($origin_options)) { |
777 | 777 | foreach ($origin_options as $item) { |
778 | - $new_option_list[] = $item['id']; |
|
778 | + $new_option_list[] = $item['id']; |
|
779 | 779 | } |
780 | 780 | } |
781 | 781 | |
@@ -789,12 +789,12 @@ discard block |
||
789 | 789 | } |
790 | 790 | } |
791 | 791 | |
792 | - // if at least one answer |
|
793 | - if ($this->nbrAnswers) { |
|
794 | - // inserts new answers into data base |
|
795 | - $c_id = $course_info['real_id']; |
|
792 | + // if at least one answer |
|
793 | + if ($this->nbrAnswers) { |
|
794 | + // inserts new answers into data base |
|
795 | + $c_id = $course_info['real_id']; |
|
796 | 796 | |
797 | - for ($i=1;$i <= $this->nbrAnswers;$i++) { |
|
797 | + for ($i=1;$i <= $this->nbrAnswers;$i++) { |
|
798 | 798 | if ($this->course['id'] != $course_info['id']) { |
799 | 799 | $this->answer[$i] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
800 | 800 | $this->answer[$i], |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | ); |
809 | 809 | } |
810 | 810 | |
811 | - $correct = $this->correct[$i]; |
|
811 | + $correct = $this->correct[$i]; |
|
812 | 812 | |
813 | 813 | if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE || |
814 | 814 | self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE |
@@ -840,9 +840,9 @@ discard block |
||
840 | 840 | |
841 | 841 | $em->merge($quizAnswer); |
842 | 842 | $em->flush(); |
843 | - } |
|
843 | + } |
|
844 | 844 | } |
845 | - } |
|
845 | + } |
|
846 | 846 | |
847 | 847 | /** |
848 | 848 | * Get the necessary JavaScript for some answers |
@@ -860,25 +860,25 @@ discard block |
||
860 | 860 | </script>"; |
861 | 861 | } |
862 | 862 | |
863 | - /** |
|
864 | - * Check if a answer is correct by an answer auto id |
|
865 | - * @param $needle int The answer auto id |
|
866 | - * @return bool |
|
867 | - */ |
|
868 | - public function isCorrectByAutoId($needle) |
|
869 | - { |
|
870 | - $key = 0; |
|
871 | - |
|
872 | - foreach ($this->autoId as $autoIdKey => $autoId) { |
|
873 | - if ($autoId == $needle) { |
|
874 | - $key = $autoIdKey; |
|
875 | - } |
|
876 | - } |
|
877 | - |
|
878 | - if (!$key) { |
|
879 | - return false; |
|
880 | - } |
|
881 | - |
|
882 | - return $this->isCorrect($key) ? true : false; |
|
883 | - } |
|
863 | + /** |
|
864 | + * Check if a answer is correct by an answer auto id |
|
865 | + * @param $needle int The answer auto id |
|
866 | + * @return bool |
|
867 | + */ |
|
868 | + public function isCorrectByAutoId($needle) |
|
869 | + { |
|
870 | + $key = 0; |
|
871 | + |
|
872 | + foreach ($this->autoId as $autoIdKey => $autoId) { |
|
873 | + if ($autoId == $needle) { |
|
874 | + $key = $autoIdKey; |
|
875 | + } |
|
876 | + } |
|
877 | + |
|
878 | + if (!$key) { |
|
879 | + return false; |
|
880 | + } |
|
881 | + |
|
882 | + return $this->isCorrect($key) ? true : false; |
|
883 | + } |
|
884 | 884 | } |
@@ -362,9 +362,10 @@ |
||
362 | 362 | |
363 | 363 | if ($inATest) { |
364 | 364 | echo '<div class="actions">'; |
365 | - if (isset($_GET['hotspotadmin']) || isset($_GET['newQuestion']) || isset($_GET['myid'])) |
|
366 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/admin.php?exerciseId='.$exerciseId.'&'.api_get_cidreq().'">'. |
|
365 | + if (isset($_GET['hotspotadmin']) || isset($_GET['newQuestion']) || isset($_GET['myid'])) { |
|
366 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/admin.php?exerciseId='.$exerciseId.'&'.api_get_cidreq().'">'. |
|
367 | 367 | Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>'; |
368 | + } |
|
368 | 369 | |
369 | 370 | if (!isset($_GET['hotspotadmin']) && !isset($_GET['newQuestion']) && !isset($_GET['myid']) && !isset($_GET['editQuestion'])) { |
370 | 371 | echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/exercise.php?'.api_get_cidreq().'">'. |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | |
50 | 50 | require_once '../inc/global.inc.php'; |
51 | -$current_course_tool = TOOL_QUIZ; |
|
51 | +$current_course_tool = TOOL_QUIZ; |
|
52 | 52 | $this_section = SECTION_COURSES; |
53 | 53 | |
54 | 54 | // Access control |
@@ -64,20 +64,20 @@ discard block |
||
64 | 64 | |
65 | 65 | /* stripslashes POST data */ |
66 | 66 | if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
67 | - foreach($_POST as $key=>$val) { |
|
68 | - if(is_string($val)) { |
|
69 | - $_POST[$key]=stripslashes($val); |
|
70 | - } elseif(is_array($val)) { |
|
71 | - foreach($val as $key2=>$val2) { |
|
72 | - $_POST[$key][$key2]=stripslashes($val2); |
|
67 | + foreach ($_POST as $key=>$val) { |
|
68 | + if (is_string($val)) { |
|
69 | + $_POST[$key] = stripslashes($val); |
|
70 | + } elseif (is_array($val)) { |
|
71 | + foreach ($val as $key2=>$val2) { |
|
72 | + $_POST[$key][$key2] = stripslashes($val2); |
|
73 | 73 | } |
74 | 74 | } |
75 | - $GLOBALS[$key]=$_POST[$key]; |
|
75 | + $GLOBALS[$key] = $_POST[$key]; |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | 79 | if (empty($exerciseId)) { |
80 | - $exerciseId = isset($_GET['exerciseId']) ? intval($_GET['exerciseId']):'0'; |
|
80 | + $exerciseId = isset($_GET['exerciseId']) ? intval($_GET['exerciseId']) : '0'; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | $newQuestion = isset($_GET['newQuestion']) ? $_GET['newQuestion'] : 0; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | if (!empty($_GET['action']) && $_GET['action'] == 'exportqti2' && !empty($_GET['questionId'])) { |
152 | 152 | require_once 'export/qti2/qti2_export.php'; |
153 | 153 | $export = export_question_qti($_GET['questionId'], true); |
154 | - $qid = (int)$_GET['questionId']; |
|
154 | + $qid = (int) $_GET['questionId']; |
|
155 | 155 | $archive_path = api_get_path(SYS_ARCHIVE_PATH); |
156 | 156 | $temp_dir_short = uniqid(); |
157 | 157 | $temp_zip_dir = $archive_path."/".$temp_dir_short; |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | if (!$fromExercise) { |
196 | 196 | // gets the right exercise ID, and if 0 creates a new exercise |
197 | 197 | if (!$exerciseId = $objExercise->selectId()) { |
198 | - $modifyExercise='yes'; |
|
198 | + $modifyExercise = 'yes'; |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | } else { |
246 | 246 | // goes back to the question viewing |
247 | 247 | $editQuestion = $modifyQuestion; |
248 | - unset($newQuestion,$modifyQuestion); |
|
248 | + unset($newQuestion, $modifyQuestion); |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
@@ -281,27 +281,27 @@ discard block |
||
281 | 281 | $nameTools = get_lang('QuestionManagement'); |
282 | 282 | } |
283 | 283 | |
284 | -if (isset($_SESSION['gradebook'])){ |
|
285 | - $gradebook= $_SESSION['gradebook']; |
|
284 | +if (isset($_SESSION['gradebook'])) { |
|
285 | + $gradebook = $_SESSION['gradebook']; |
|
286 | 286 | } |
287 | 287 | |
288 | -if (!empty($gradebook) && $gradebook=='view') { |
|
289 | - $interbreadcrumb[]= array( |
|
288 | +if (!empty($gradebook) && $gradebook == 'view') { |
|
289 | + $interbreadcrumb[] = array( |
|
290 | 290 | 'url' => '../gradebook/'.$_SESSION['gradebook_dest'], |
291 | 291 | 'name' => get_lang('ToolGradebook') |
292 | 292 | ); |
293 | 293 | } |
294 | 294 | |
295 | -$interbreadcrumb[] = array("url" => "exercise.php","name" => get_lang('Exercises')); |
|
296 | -if (isset($_GET['newQuestion']) || isset($_GET['editQuestion']) ) { |
|
295 | +$interbreadcrumb[] = array("url" => "exercise.php", "name" => get_lang('Exercises')); |
|
296 | +if (isset($_GET['newQuestion']) || isset($_GET['editQuestion'])) { |
|
297 | 297 | $interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$objExercise->id, "name" => $objExercise->name); |
298 | 298 | } else { |
299 | 299 | $interbreadcrumb[] = array("url" => "#", "name" => $objExercise->name); |
300 | 300 | } |
301 | 301 | |
302 | 302 | // shows a link to go back to the question pool |
303 | -if (!$exerciseId && $nameTools != get_lang('ExerciseManagement')){ |
|
304 | - $interbreadcrumb[]=array( |
|
303 | +if (!$exerciseId && $nameTools != get_lang('ExerciseManagement')) { |
|
304 | + $interbreadcrumb[] = array( |
|
305 | 305 | "url" => api_get_path(WEB_CODE_PATH)."exercise/question_pool.php?fromExercise=$fromExercise&".api_get_cidreq(), |
306 | 306 | "name" => get_lang('QuestionPool') |
307 | 307 | ); |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | |
310 | 310 | // if the question is duplicated, disable the link of tool name |
311 | 311 | if ($modifyIn == 'thisExercise') { |
312 | - if($buttonBack) { |
|
313 | - $modifyIn='allExercises'; |
|
312 | + if ($buttonBack) { |
|
313 | + $modifyIn = 'allExercises'; |
|
314 | 314 | } else { |
315 | - $noPHP_SELF=true; |
|
315 | + $noPHP_SELF = true; |
|
316 | 316 | } |
317 | 317 | } |
318 | 318 | $htmlHeadXtra[] = '<script> |
@@ -344,10 +344,10 @@ discard block |
||
344 | 344 | $htmlHeadXtra[] = $template->fetch('default/exercise/submit.js.tpl'); |
345 | 345 | $htmlHeadXtra[] = api_get_js('d3/jquery.xcolor.js'); |
346 | 346 | |
347 | -$htmlHeadXtra[] = '<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/css/hotspot.css">'; |
|
348 | -$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/js/hotspot.js"></script>'; |
|
347 | +$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">'; |
|
348 | +$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>'; |
|
349 | 349 | |
350 | -Display::display_header($nameTools,'Exercise'); |
|
350 | +Display::display_header($nameTools, 'Exercise'); |
|
351 | 351 | /* |
352 | 352 | if ($objExercise->exercise_was_added_in_lp) { |
353 | 353 | if ($objExercise->force_edit_exercise_in_lp == true) { |
@@ -364,22 +364,22 @@ discard block |
||
364 | 364 | echo '<div class="actions">'; |
365 | 365 | if (isset($_GET['hotspotadmin']) || isset($_GET['newQuestion']) || isset($_GET['myid'])) |
366 | 366 | echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/admin.php?exerciseId='.$exerciseId.'&'.api_get_cidreq().'">'. |
367 | - Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
367 | + Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
368 | 368 | |
369 | - if (!isset($_GET['hotspotadmin']) && !isset($_GET['newQuestion']) && !isset($_GET['myid']) && !isset($_GET['editQuestion'])) { |
|
369 | + if (!isset($_GET['hotspotadmin']) && !isset($_GET['newQuestion']) && !isset($_GET['myid']) && !isset($_GET['editQuestion'])) { |
|
370 | 370 | echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/exercise.php?'.api_get_cidreq().'">'. |
371 | - Display::return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
371 | + Display::return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
372 | 372 | } |
373 | 373 | echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/overview.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&preview=1">'. |
374 | - Display::return_icon('preview_view.png', get_lang('Preview'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
374 | + Display::return_icon('preview_view.png', get_lang('Preview'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
375 | 375 | |
376 | 376 | echo Display::url( |
377 | - Display::return_icon('test_results.png', get_lang('Results'),'',ICON_SIZE_MEDIUM), |
|
377 | + Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_MEDIUM), |
|
378 | 378 | api_get_path(WEB_CODE_PATH).'exercise/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id |
379 | 379 | ); |
380 | 380 | |
381 | 381 | echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'. |
382 | - Display::return_icon('settings.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
382 | + Display::return_icon('settings.png', get_lang('ModifyExercise'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
383 | 383 | |
384 | 384 | $maxScoreAllQuestions = 0; |
385 | 385 | if (!empty($objExercise->questionList)) { |
@@ -397,13 +397,13 @@ discard block |
||
397 | 397 | // we are in create a new question from question pool not in a test |
398 | 398 | echo '<div class="actions">'; |
399 | 399 | echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/admin.php?'.api_get_cidreq().'">'. |
400 | - Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
400 | + Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
401 | 401 | echo '</div>'; |
402 | 402 | } else { |
403 | 403 | // If we are in question_pool but not in an test, go back to question create in pool |
404 | 404 | echo '<div class="actions">'; |
405 | 405 | echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/question_pool.php?'.api_get_cidreq().'">'. |
406 | - Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM). |
|
406 | + Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM). |
|
407 | 407 | '</a>'; |
408 | 408 | echo '</div>'; |
409 | 409 | } |
@@ -7,4 +7,4 @@ |
||
7 | 7 | // directly to exercise.php. This redirection is enabled for 1.10.x (2015-04-21) |
8 | 8 | // The final goal of this file is to be removed in a few years time, if |
9 | 9 | // considered realistically not harmful |
10 | -require __DIR__ . '/exercise.php'; |
|
10 | +require __DIR__.'/exercise.php'; |