@@ -27,6 +27,7 @@ discard block |
||
| 27 | 27 | * @param int The JavaScript ID for this question. |
| 28 | 28 | * Due to the nature of interactions, we must have a natural sequence for |
| 29 | 29 | * questions in the generated JavaScript. |
| 30 | + * @param integer $js_id |
|
| 30 | 31 | */ |
| 31 | 32 | public static function export_question($questionId, $standalone = true, $js_id) |
| 32 | 33 | { |
@@ -687,7 +688,7 @@ discard block |
||
| 687 | 688 | /** |
| 688 | 689 | * Constructor. |
| 689 | 690 | * |
| 690 | - * @param $question The Question object we want to export. |
|
| 691 | + * @param ScormQuestion $question The Question object we want to export. |
|
| 691 | 692 | */ |
| 692 | 693 | public function ScormAssessmentItem($question, $standalone = false) |
| 693 | 694 | { |
@@ -915,7 +916,7 @@ discard block |
||
| 915 | 916 | * |
| 916 | 917 | * @param int $exerciseId The exercise to exporte |
| 917 | 918 | * @param boolean $standalone Wether it should include XML tag and DTD line. |
| 918 | - * @return The XML as a string, or an empty string if there's no exercise with given ID. |
|
| 919 | + * @return string XML as a string, or an empty string if there's no exercise with given ID. |
|
| 919 | 920 | */ |
| 920 | 921 | public static function export_exercise_to_scorm($exerciseId, $standalone=true) { |
| 921 | 922 | $exercise = new Exercise(); |
@@ -930,7 +931,7 @@ discard block |
||
| 930 | 931 | |
| 931 | 932 | /** |
| 932 | 933 | * Constructor. |
| 933 | - * @param $exe The Exercise instance to export |
|
| 934 | + * @param Exercise $exe The Exercise instance to export |
|
| 934 | 935 | * @author Amand Tihon <[email protected]> |
| 935 | 936 | */ |
| 936 | 937 | function ScormSection($exe) { |
@@ -1091,7 +1092,7 @@ discard block |
||
| 1091 | 1092 | * This is a default behaviour, some classes may want to override this. |
| 1092 | 1093 | * |
| 1093 | 1094 | * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
| 1094 | - * @return A string, the XML flow for an Item. |
|
| 1095 | + * @return string string, the XML flow for an Item. |
|
| 1095 | 1096 | */ |
| 1096 | 1097 | function export() |
| 1097 | 1098 | { |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | $question = new ScormQuestion(); |
| 34 | 34 | $qst = $question->read($questionId); |
| 35 | - if( !$qst ) { |
|
| 35 | + if (!$qst) { |
|
| 36 | 36 | return ''; |
| 37 | 37 | } |
| 38 | 38 | $question->id = $qst->id; |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | $question->type = $qst->type; |
| 41 | 41 | $question->question = $qst->question; |
| 42 | 42 | $question->description = $qst->description; |
| 43 | - $question->weighting=$qst->weighting; |
|
| 44 | - $question->position=$qst->position; |
|
| 45 | - $question->picture=$qst->picture; |
|
| 43 | + $question->weighting = $qst->weighting; |
|
| 44 | + $question->position = $qst->position; |
|
| 45 | + $question->picture = $qst->picture; |
|
| 46 | 46 | $assessmentItem = new ScormAssessmentItem($question, $standalone); |
| 47 | 47 | //echo "<pre>".print_r($scorm,1)."</pre>";exit; |
| 48 | 48 | return $assessmentItem->export(); |
@@ -111,14 +111,14 @@ discard block |
||
| 111 | 111 | $html = $this->getQuestionHTML(); |
| 112 | 112 | $js = $this->getQuestionJS(); |
| 113 | 113 | |
| 114 | - if( is_object($this->answer) ) |
|
| 114 | + if (is_object($this->answer)) |
|
| 115 | 115 | { |
| 116 | - list($js2,$html2) = $this->answer->export(); |
|
| 116 | + list($js2, $html2) = $this->answer->export(); |
|
| 117 | 117 | $js .= $js2; |
| 118 | 118 | $html .= $html2; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - return array($js,$html); |
|
| 121 | + return array($js, $html); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | function createAnswersForm($form) |
@@ -136,19 +136,19 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | function getQuestionHTML() |
| 138 | 138 | { |
| 139 | - $title = $this->selectTitle(); |
|
| 140 | - $description = $this->selectDescription(); |
|
| 139 | + $title = $this->selectTitle(); |
|
| 140 | + $description = $this->selectDescription(); |
|
| 141 | 141 | $cols = 2; |
| 142 | - $s='<tr>' . |
|
| 143 | - '<td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;">' . "\n" . |
|
| 142 | + $s = '<tr>'. |
|
| 143 | + '<td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;">'."\n". |
|
| 144 | 144 | $title. |
| 145 | - '</td>' . "\n" . |
|
| 146 | - '</tr>' . "\n" . |
|
| 147 | - '<tr>' . "\n" . |
|
| 148 | - '<td valign="top" colspan="'.$cols.'">' . "\n" . |
|
| 149 | - '<i>'.$description.'</i>' . "\n" . |
|
| 150 | - '</td>' . "\n" . |
|
| 151 | - '</tr>' . "\n"; |
|
| 145 | + '</td>'."\n". |
|
| 146 | + '</tr>'."\n". |
|
| 147 | + '<tr>'."\n". |
|
| 148 | + '<td valign="top" colspan="'.$cols.'">'."\n". |
|
| 149 | + '<i>'.$description.'</i>'."\n". |
|
| 150 | + '</td>'."\n". |
|
| 151 | + '</tr>'."\n"; |
|
| 152 | 152 | return $s; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -160,10 +160,10 @@ discard block |
||
| 160 | 160 | //$id = $this->id; |
| 161 | 161 | $w = $this->selectWeighting(); |
| 162 | 162 | $s = 'questions.push('.$this->js_id.');'."\n"; |
| 163 | - if($this->type == FREE_ANSWER or $this->type == HOT_SPOT) |
|
| 163 | + if ($this->type == FREE_ANSWER or $this->type == HOT_SPOT) |
|
| 164 | 164 | { //put the max score to 0 to avoid discounting the points of |
| 165 | 165 | //non-exported quiz types in the SCORM |
| 166 | - $w=0; |
|
| 166 | + $w = 0; |
|
| 167 | 167 | } |
| 168 | 168 | $s .= 'questions_score_max['.$this->js_id.'] = '.$w.";\n"; |
| 169 | 169 | return $s; |
@@ -184,40 +184,40 @@ discard block |
||
| 184 | 184 | { |
| 185 | 185 | $html = ''; |
| 186 | 186 | $js = ''; |
| 187 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
| 187 | + $html = '<tr><td colspan="2"><table width="100%">'."\n"; |
|
| 188 | 188 | $type = $this->getQuestionType(); |
| 189 | 189 | $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
| 190 | 190 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
| 191 | 191 | |
| 192 | 192 | //not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM |
| 193 | 193 | //if ($type == MCMA || $type == MULTIPLE_ANSWER_COMBINATION ) { |
| 194 | - if ($type == MCMA ) { |
|
| 194 | + if ($type == MCMA) { |
|
| 195 | 195 | //$questionTypeLang = get_lang('MultipleChoiceMultipleAnswers'); |
| 196 | 196 | $id = 1; |
| 197 | 197 | $jstmp = ''; |
| 198 | 198 | $jstmpc = ''; |
| 199 | - foreach( $this->answer as $i => $answer ) |
|
| 199 | + foreach ($this->answer as $i => $answer) |
|
| 200 | 200 | { |
| 201 | 201 | $identifier = 'question_'.$this->questionJSId.'_multiple_'.$i; |
| 202 | 202 | $html .= |
| 203 | - '<tr>' . "\n" |
|
| 204 | - . '<td align="center" width="5%">' . "\n" |
|
| 205 | - . '<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />' . "\n" |
|
| 206 | - . '</td>' . "\n" |
|
| 207 | - . '<td width="95%">' . "\n" |
|
| 208 | - . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
| 209 | - . '</td>' . "\n" |
|
| 210 | - . '</tr>' . "\n\n"; |
|
| 203 | + '<tr>'."\n" |
|
| 204 | + . '<td align="center" width="5%">'."\n" |
|
| 205 | + . '<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />'."\n" |
|
| 206 | + . '</td>'."\n" |
|
| 207 | + . '<td width="95%">'."\n" |
|
| 208 | + . '<label for="'.$identifier.'">'.$this->answer[$i].'</label>'."\n" |
|
| 209 | + . '</td>'."\n" |
|
| 210 | + . '</tr>'."\n\n"; |
|
| 211 | 211 | $jstmp .= $i.','; |
| 212 | - if($this->correct[$i]) |
|
| 212 | + if ($this->correct[$i]) |
|
| 213 | 213 | { |
| 214 | 214 | $jstmpc .= $i.','; |
| 215 | 215 | } |
| 216 | 216 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
| 217 | 217 | $id++; |
| 218 | 218 | } |
| 219 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
| 220 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
| 219 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp, 0, -1).');'."\n"; |
|
| 220 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc, 0, -1).');'."\n"; |
|
| 221 | 221 | if ($type == MCMA) { |
| 222 | 222 | $js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n"; |
| 223 | 223 | } else { |
@@ -228,14 +228,14 @@ discard block |
||
| 228 | 228 | //To this items we show the ThisItemIsNotExportable |
| 229 | 229 | $qId = $this->questionJSId; |
| 230 | 230 | $js = ''; |
| 231 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
| 231 | + $html = '<tr><td colspan="2"><table width="100%">'."\n"; |
|
| 232 | 232 | // some javascript must be added for that kind of questions |
| 233 | - $html .= '<tr>' . "\n" |
|
| 234 | - . '<td>' . "\n" |
|
| 235 | - . '<textarea name="question_'.$qId.'_free" id="question_'.$qId.'_exact" rows="20" cols="100"></textarea>' . "\n" |
|
| 236 | - . '</td>' . "\n" |
|
| 237 | - . '</tr>' . "\n"; |
|
| 238 | - $html .= '</table></td></tr>' . "\n"; |
|
| 233 | + $html .= '<tr>'."\n" |
|
| 234 | + . '<td>'."\n" |
|
| 235 | + . '<textarea name="question_'.$qId.'_free" id="question_'.$qId.'_exact" rows="20" cols="100"></textarea>'."\n" |
|
| 236 | + . '</td>'."\n" |
|
| 237 | + . '</tr>'."\n"; |
|
| 238 | + $html .= '</table></td></tr>'."\n"; |
|
| 239 | 239 | // currently the exact answers cannot be displayed, so ignore the textarea |
| 240 | 240 | $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
| 241 | 241 | $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
@@ -245,40 +245,40 @@ discard block |
||
| 245 | 245 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
| 246 | 246 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
| 247 | 247 | $js .= $jstmpw; |
| 248 | - return array($js,$html); |
|
| 248 | + return array($js, $html); |
|
| 249 | 249 | } else { |
| 250 | 250 | //$questionTypeLang = get_lang('MultipleChoiceUniqueAnswer'); |
| 251 | 251 | $id = 1; |
| 252 | 252 | $jstmp = ''; |
| 253 | 253 | $jstmpc = ''; |
| 254 | - foreach( $this->answer as $i => $answer ) |
|
| 254 | + foreach ($this->answer as $i => $answer) |
|
| 255 | 255 | { |
| 256 | 256 | $identifier = 'question_'.$this->questionJSId.'_unique_'.$i; |
| 257 | 257 | $identifier_name = 'question_'.$this->questionJSId.'_unique_answer'; |
| 258 | 258 | $html .= |
| 259 | - '<tr>' . "\n" |
|
| 260 | - . '<td align="center" width="5%">' . "\n" |
|
| 261 | - . '<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="radio"/>' . "\n" |
|
| 262 | - . '</td>' . "\n" |
|
| 263 | - . '<td width="95%">' . "\n" |
|
| 264 | - . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
| 265 | - . '</td>' . "\n" |
|
| 266 | - . '</tr>' . "\n\n"; |
|
| 259 | + '<tr>'."\n" |
|
| 260 | + . '<td align="center" width="5%">'."\n" |
|
| 261 | + . '<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="radio"/>'."\n" |
|
| 262 | + . '</td>'."\n" |
|
| 263 | + . '<td width="95%">'."\n" |
|
| 264 | + . '<label for="'.$identifier.'">'.$this->answer[$i].'</label>'."\n" |
|
| 265 | + . '</td>'."\n" |
|
| 266 | + . '</tr>'."\n\n"; |
|
| 267 | 267 | $jstmp .= $i.','; |
| 268 | - if($this->correct[$i]) |
|
| 268 | + if ($this->correct[$i]) |
|
| 269 | 269 | { |
| 270 | 270 | $jstmpc .= $i; |
| 271 | 271 | } |
| 272 | 272 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
| 273 | 273 | $id++; |
| 274 | 274 | } |
| 275 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
| 275 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp, 0, -1).');'."\n"; |
|
| 276 | 276 | $js .= 'questions_answers_correct['.$this->questionJSId.'] = '.$jstmpc.';'."\n"; |
| 277 | 277 | $js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';'."\n"; |
| 278 | 278 | $js .= $jstmpw; |
| 279 | 279 | } |
| 280 | - $html .= '</table></td></tr>' . "\n"; |
|
| 281 | - return array($js,$html); |
|
| 280 | + $html .= '</table></td></tr>'."\n"; |
|
| 281 | + return array($js, $html); |
|
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | |
@@ -302,29 +302,29 @@ discard block |
||
| 302 | 302 | $identifier_true = $identifier.'_true'; |
| 303 | 303 | $identifier_false = $identifier.'_false'; |
| 304 | 304 | $html .= |
| 305 | - '<tr>' . "\n" |
|
| 306 | - . '<td align="center" width="5%">' . "\n" |
|
| 305 | + '<tr>'."\n" |
|
| 306 | + . '<td align="center" width="5%">'."\n" |
|
| 307 | 307 | . '<input name="'.$identifier_true.'" id="'.$identifier_true.'" value="'.$this->trueGrade.'" type="radio" ' |
| 308 | - . '/>' . "\n" |
|
| 309 | - . '</td>' . "\n" |
|
| 310 | - . '<td width="95%">' . "\n" |
|
| 311 | - . '<label for="'.$identifier_true.'">' . get_lang('True') . '</label>' . "\n" |
|
| 312 | - . '</td>' . "\n" |
|
| 313 | - . '</tr>' . "\n\n"; |
|
| 308 | + . '/>'."\n" |
|
| 309 | + . '</td>'."\n" |
|
| 310 | + . '<td width="95%">'."\n" |
|
| 311 | + . '<label for="'.$identifier_true.'">'.get_lang('True').'</label>'."\n" |
|
| 312 | + . '</td>'."\n" |
|
| 313 | + . '</tr>'."\n\n"; |
|
| 314 | 314 | $html .= |
| 315 | - '<tr>' . "\n" |
|
| 316 | - . '<td align="center" width="5%">' . "\n" |
|
| 315 | + '<tr>'."\n" |
|
| 316 | + . '<td align="center" width="5%">'."\n" |
|
| 317 | 317 | . '<input name="'.$identifier_false.'" id="'.$identifier_false.'" value="'.$this->falseGrade.'" type="radio" ' |
| 318 | - . '/>' . "\n" |
|
| 319 | - . '</td>' . "\n" |
|
| 320 | - . '<td width="95%">' . "\n" |
|
| 321 | - . '<label for="'.$identifier_false.'">' . get_lang('False') . '</label>' . "\n" |
|
| 322 | - . '</td>' . "\n" |
|
| 323 | - . '</tr>' . "\n\n"; |
|
| 324 | - $html .= '</table></td></tr>' . "\n"; |
|
| 318 | + . '/>'."\n" |
|
| 319 | + . '</td>'."\n" |
|
| 320 | + . '<td width="95%">'."\n" |
|
| 321 | + . '<label for="'.$identifier_false.'">'.get_lang('False').'</label>'."\n" |
|
| 322 | + . '</td>'."\n" |
|
| 323 | + . '</tr>'."\n\n"; |
|
| 324 | + $html .= '</table></td></tr>'."\n"; |
|
| 325 | 325 | $js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n"; |
| 326 | 326 | $js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n"; |
| 327 | - if($this->response == 'TRUE') |
|
| 327 | + if ($this->response == 'TRUE') |
|
| 328 | 328 | { |
| 329 | 329 | $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n"; |
| 330 | 330 | } |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n"; |
| 338 | 338 | $js .= $jstmpw; |
| 339 | 339 | |
| 340 | - return array($js,$html); |
|
| 340 | + return array($js, $html); |
|
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | |
@@ -357,56 +357,56 @@ discard block |
||
| 357 | 357 | { |
| 358 | 358 | global $charset; |
| 359 | 359 | $js = ''; |
| 360 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
| 360 | + $html = '<tr><td colspan="2"><table width="100%">'."\n"; |
|
| 361 | 361 | // get all enclosed answers |
| 362 | 362 | $blankList = array(); |
| 363 | 363 | // build replacement |
| 364 | 364 | $replacementList = array(); |
| 365 | - foreach( $this->answer as $i => $answer) { |
|
| 365 | + foreach ($this->answer as $i => $answer) { |
|
| 366 | 366 | $blankList[] = '['.$answer.']'; |
| 367 | 367 | } |
| 368 | 368 | $answerCount = count($blankList); |
| 369 | 369 | |
| 370 | 370 | // splits text and weightings that are joined with the character '::' |
| 371 | - list($answer,$weight)=explode('::',$answer); |
|
| 372 | - $weights = explode(',',$weight); |
|
| 371 | + list($answer, $weight) = explode('::', $answer); |
|
| 372 | + $weights = explode(',', $weight); |
|
| 373 | 373 | // because [] is parsed here we follow this procedure: |
| 374 | 374 | // 1. find everything between the [ and ] tags |
| 375 | - $i=1; |
|
| 375 | + $i = 1; |
|
| 376 | 376 | $jstmp = ''; |
| 377 | 377 | $jstmpc = ''; |
| 378 | 378 | $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
| 379 | 379 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
| 380 | - $startlocations=api_strpos($answer,'['); |
|
| 381 | - $endlocations=api_strpos($answer,']'); |
|
| 382 | - while($startlocations !== false && $endlocations !== false) { |
|
| 383 | - $texstring=api_substr($answer,$startlocations,($endlocations-$startlocations)+1); |
|
| 384 | - $answer = api_substr_replace($answer,'<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />',$startlocations,($endlocations-$startlocations)+1); |
|
| 380 | + $startlocations = api_strpos($answer, '['); |
|
| 381 | + $endlocations = api_strpos($answer, ']'); |
|
| 382 | + while ($startlocations !== false && $endlocations !== false) { |
|
| 383 | + $texstring = api_substr($answer, $startlocations, ($endlocations - $startlocations) + 1); |
|
| 384 | + $answer = api_substr_replace($answer, '<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />', $startlocations, ($endlocations - $startlocations) + 1); |
|
| 385 | 385 | $jstmp .= $i.','; |
| 386 | - $jstmpc .= "'".api_htmlentities(api_substr($texstring,1,-1),ENT_QUOTES,$charset)."',"; |
|
| 387 | - $my_weight=explode('@',$weights[$i-1]); |
|
| 388 | - if (count($my_weight)==2) { |
|
| 389 | - $weight_db=$my_weight[0]; |
|
| 386 | + $jstmpc .= "'".api_htmlentities(api_substr($texstring, 1, -1), ENT_QUOTES, $charset)."',"; |
|
| 387 | + $my_weight = explode('@', $weights[$i - 1]); |
|
| 388 | + if (count($my_weight) == 2) { |
|
| 389 | + $weight_db = $my_weight[0]; |
|
| 390 | 390 | } else { |
| 391 | - $weight_db=$my_weight[0]; |
|
| 391 | + $weight_db = $my_weight[0]; |
|
| 392 | 392 | } |
| 393 | 393 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n"; |
| 394 | 394 | $i++; |
| 395 | - $startlocations=api_strpos($answer,'['); |
|
| 396 | - $endlocations=api_strpos($answer,']'); |
|
| 395 | + $startlocations = api_strpos($answer, '['); |
|
| 396 | + $endlocations = api_strpos($answer, ']'); |
|
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - $html .= '<tr>' . "\n" |
|
| 400 | - . '<td>' . "\n" |
|
| 401 | - . $answer . "\n" |
|
| 402 | - . '</td>' . "\n" |
|
| 403 | - . '</tr>' . "\n"; |
|
| 404 | - $html .= '</table></td></tr>' . "\n"; |
|
| 405 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n"; |
|
| 406 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n"; |
|
| 399 | + $html .= '<tr>'."\n" |
|
| 400 | + . '<td>'."\n" |
|
| 401 | + . $answer."\n" |
|
| 402 | + . '</td>'."\n" |
|
| 403 | + . '</tr>'."\n"; |
|
| 404 | + $html .= '</table></td></tr>'."\n"; |
|
| 405 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp, 0, -1).');'."\n"; |
|
| 406 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc, 0, -1).');'."\n"; |
|
| 407 | 407 | $js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n"; |
| 408 | 408 | $js .= $jstmpw; |
| 409 | - return array($js,$html); |
|
| 409 | + return array($js, $html); |
|
| 410 | 410 | } |
| 411 | 411 | } |
| 412 | 412 | |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | function export() |
| 424 | 424 | { |
| 425 | 425 | $js = ''; |
| 426 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
| 426 | + $html = '<tr><td colspan="2"><table width="100%">'."\n"; |
|
| 427 | 427 | // prepare list of right proposition to allow |
| 428 | 428 | // - easiest display |
| 429 | 429 | // - easiest randomisation if needed one day |
@@ -432,12 +432,12 @@ discard block |
||
| 432 | 432 | $displayedRightList = array_values($this->rightList); |
| 433 | 433 | } |
| 434 | 434 | // get max length of displayed array |
| 435 | - $arrayLength = max( count($this->leftList), count($this->rightList) ); |
|
| 435 | + $arrayLength = max(count($this->leftList), count($this->rightList)); |
|
| 436 | 436 | |
| 437 | - $nbrAnswers=$this->selectNbrAnswers(); |
|
| 438 | - $cpt1='A'; |
|
| 439 | - $cpt2=1; |
|
| 440 | - $Select=array(); |
|
| 437 | + $nbrAnswers = $this->selectNbrAnswers(); |
|
| 438 | + $cpt1 = 'A'; |
|
| 439 | + $cpt2 = 1; |
|
| 440 | + $Select = array(); |
|
| 441 | 441 | $qId = $this->questionJSId; |
| 442 | 442 | $s = ''; |
| 443 | 443 | $jstmp = ''; |
@@ -445,74 +445,74 @@ discard block |
||
| 445 | 445 | $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
| 446 | 446 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
| 447 | 447 | |
| 448 | - for($answerId=1;$answerId <= $nbrAnswers;$answerId++) { |
|
| 448 | + for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) { |
|
| 449 | 449 | $identifier = 'question_'.$qId.'_matching_'; |
| 450 | - $answer=$this->selectAnswer($answerId); |
|
| 451 | - $answerCorrect=$this->isCorrect($answerId); |
|
| 452 | - $weight=$this->selectWeighting($answerId); |
|
| 450 | + $answer = $this->selectAnswer($answerId); |
|
| 451 | + $answerCorrect = $this->isCorrect($answerId); |
|
| 452 | + $weight = $this->selectWeighting($answerId); |
|
| 453 | 453 | $jstmp .= $answerId.','; |
| 454 | 454 | |
| 455 | 455 | if (!$answerCorrect) { |
| 456 | 456 | // options (A, B, C, ...) that will be put into the list-box |
| 457 | - $Select[$answerId]['Lettre']=$cpt1; |
|
| 457 | + $Select[$answerId]['Lettre'] = $cpt1; |
|
| 458 | 458 | // answers that will be shown at the right side |
| 459 | 459 | $Select[$answerId]['Reponse'] = $answer; |
| 460 | 460 | $cpt1++; |
| 461 | 461 | } else { |
| 462 | - $s.='<tr>'."\n"; |
|
| 463 | - $s.='<td width="40%" valign="top">'."\n".'<b>'.$cpt2.'</b>. '.$answer."\n</td>\n"; |
|
| 464 | - $s.='<td width="20%" align="center"> <select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">'; |
|
| 465 | - $s.=' <option value="0">--</option>'; |
|
| 462 | + $s .= '<tr>'."\n"; |
|
| 463 | + $s .= '<td width="40%" valign="top">'."\n".'<b>'.$cpt2.'</b>. '.$answer."\n</td>\n"; |
|
| 464 | + $s .= '<td width="20%" align="center"> <select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">'; |
|
| 465 | + $s .= ' <option value="0">--</option>'; |
|
| 466 | 466 | // fills the list-box |
| 467 | - foreach($Select as $key=>$val) |
|
| 467 | + foreach ($Select as $key=>$val) |
|
| 468 | 468 | { |
| 469 | - $s.='<option value="'.$key.'">'.$val['Lettre'].'</option>'; |
|
| 469 | + $s .= '<option value="'.$key.'">'.$val['Lettre'].'</option>'; |
|
| 470 | 470 | } // end foreach() |
| 471 | 471 | |
| 472 | - $s.='</select> </td>'."\n"; |
|
| 473 | - $s.='<td width="40%" valign="top">'; |
|
| 474 | - if(isset($Select[$cpt2])) $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
| 475 | - else $s.=' '; |
|
| 476 | - $s.="</td>\n</tr>\n"; |
|
| 472 | + $s .= '</select> </td>'."\n"; |
|
| 473 | + $s .= '<td width="40%" valign="top">'; |
|
| 474 | + if (isset($Select[$cpt2])) $s .= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
| 475 | + else $s .= ' '; |
|
| 476 | + $s .= "</td>\n</tr>\n"; |
|
| 477 | 477 | |
| 478 | 478 | $jstmpc .= '['.$answerCorrect.','.$cpt2.'],'; |
| 479 | 479 | |
| 480 | - $my_weight=explode('@',$weight); |
|
| 481 | - if (count($my_weight)==2) { |
|
| 482 | - $weight=$my_weight[0]; |
|
| 480 | + $my_weight = explode('@', $weight); |
|
| 481 | + if (count($my_weight) == 2) { |
|
| 482 | + $weight = $my_weight[0]; |
|
| 483 | 483 | } else { |
| 484 | - $weight=$my_weight[0]; |
|
| 484 | + $weight = $my_weight[0]; |
|
| 485 | 485 | } |
| 486 | 486 | $jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n"; |
| 487 | 487 | $cpt2++; |
| 488 | 488 | |
| 489 | 489 | // if the left side of the "matching" has been completely shown |
| 490 | - if($answerId == $nbrAnswers) |
|
| 490 | + if ($answerId == $nbrAnswers) |
|
| 491 | 491 | { |
| 492 | 492 | // if there remain answers to be shown on the right side |
| 493 | - while(isset($Select[$cpt2])) |
|
| 493 | + while (isset($Select[$cpt2])) |
|
| 494 | 494 | { |
| 495 | 495 | //$s.='<tr>'."\n"; |
| 496 | 496 | //$s.='<td colspan="2">'."\n"; |
| 497 | 497 | //$s.='<table border="0" cellpadding="0" cellspacing="0" width="100%">'."\n"; |
| 498 | - $s.='<tr>'."\n"; |
|
| 499 | - $s.='<td width="60%" colspan="2"> </td>'."\n"; |
|
| 500 | - $s.='<td width="40%" valign="top">'; |
|
| 501 | - $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
| 502 | - $s.="</td>\n</tr>\n"; |
|
| 498 | + $s .= '<tr>'."\n"; |
|
| 499 | + $s .= '<td width="60%" colspan="2"> </td>'."\n"; |
|
| 500 | + $s .= '<td width="40%" valign="top">'; |
|
| 501 | + $s .= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
| 502 | + $s .= "</td>\n</tr>\n"; |
|
| 503 | 503 | $cpt2++; |
| 504 | 504 | } // end while() |
| 505 | 505 | } // end if() |
| 506 | 506 | } |
| 507 | 507 | } |
| 508 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
| 509 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
| 508 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp, 0, -1).');'."\n"; |
|
| 509 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc, 0, -1).');'."\n"; |
|
| 510 | 510 | $js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n"; |
| 511 | 511 | $js .= $jstmpw; |
| 512 | 512 | $html .= $s; |
| 513 | - $html .= '</table></td></tr>' . "\n"; |
|
| 513 | + $html .= '</table></td></tr>'."\n"; |
|
| 514 | 514 | |
| 515 | - return array($js,$html); |
|
| 515 | + return array($js, $html); |
|
| 516 | 516 | } |
| 517 | 517 | } |
| 518 | 518 | |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
| 550 | 550 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
| 551 | 551 | $js .= $jstmpw; |
| 552 | - return array($js,$html); |
|
| 552 | + return array($js, $html); |
|
| 553 | 553 | } |
| 554 | 554 | } |
| 555 | 555 | /** |
@@ -601,15 +601,15 @@ discard block |
||
| 601 | 601 | function export() |
| 602 | 602 | { |
| 603 | 603 | $js = $this->get_js_header(); |
| 604 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
| 604 | + $html = '<tr><td colspan="2"><table width="100%">'."\n"; |
|
| 605 | 605 | // some javascript must be added for that kind of questions |
| 606 | 606 | $html .= ''; |
| 607 | 607 | |
| 608 | 608 | // Get the answers, make a list |
| 609 | - $nbrAnswers=$this->selectNbrAnswers(); |
|
| 609 | + $nbrAnswers = $this->selectNbrAnswers(); |
|
| 610 | 610 | |
| 611 | 611 | $answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>'; |
| 612 | - for($answerId=1;$answerId <= $nbrAnswers;$answerId++) |
|
| 612 | + for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) |
|
| 613 | 613 | { |
| 614 | 614 | $answer_list .= '<li>'.$this->selectAnswer($answerId).'</li>'; |
| 615 | 615 | } |
@@ -658,11 +658,11 @@ discard block |
||
| 658 | 658 | </td> |
| 659 | 659 | <tr> |
| 660 | 660 | HTML; |
| 661 | - $html .= '</table></td></tr>' . "\n"; |
|
| 661 | + $html .= '</table></td></tr>'."\n"; |
|
| 662 | 662 | |
| 663 | 663 | // currently the free answers cannot be displayed, so ignore the textarea |
| 664 | 664 | $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
| 665 | - return array($js,$html); |
|
| 665 | + return array($js, $html); |
|
| 666 | 666 | } |
| 667 | 667 | } |
| 668 | 668 | |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | { |
| 694 | 694 | $this->question = $question; |
| 695 | 695 | $this->question->setAnswer(); |
| 696 | - $this->questionIdent = "QST_" . $question->id ; |
|
| 696 | + $this->questionIdent = "QST_".$question->id; |
|
| 697 | 697 | $this->standalone = $standalone; |
| 698 | 698 | } |
| 699 | 699 | |
@@ -707,9 +707,9 @@ discard block |
||
| 707 | 707 | { |
| 708 | 708 | global $charset; |
| 709 | 709 | $head = ""; |
| 710 | - if( $this->standalone) |
|
| 710 | + if ($this->standalone) |
|
| 711 | 711 | { |
| 712 | - $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?>' . "\n"; |
|
| 712 | + $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?>'."\n"; |
|
| 713 | 713 | $head .= '<html>'."\n"; |
| 714 | 714 | } |
| 715 | 715 | return $head; |
@@ -720,7 +720,7 @@ discard block |
||
| 720 | 720 | * |
| 721 | 721 | */ |
| 722 | 722 | function end_page() { |
| 723 | - if($this->standalone){return '</html>';} |
|
| 723 | + if ($this->standalone) {return '</html>'; } |
|
| 724 | 724 | return ''; |
| 725 | 725 | } |
| 726 | 726 | |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | * Start document header |
| 729 | 729 | */ |
| 730 | 730 | function start_header() { |
| 731 | - if($this->standalone){return '<head>'. "\n";} |
|
| 731 | + if ($this->standalone) {return '<head>'."\n"; } |
|
| 732 | 732 | return ''; |
| 733 | 733 | } |
| 734 | 734 | |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | */ |
| 756 | 756 | function end_header() |
| 757 | 757 | { |
| 758 | - if($this->standalone){return '</head>'. "\n";} |
|
| 758 | + if ($this->standalone) {return '</head>'."\n"; } |
|
| 759 | 759 | return ''; |
| 760 | 760 | } |
| 761 | 761 | /** |
@@ -775,11 +775,11 @@ discard block |
||
| 775 | 775 | function common_js() |
| 776 | 776 | { |
| 777 | 777 | $js = file_get_contents('../newscorm/js/api_wrapper.js'); |
| 778 | - $js .= 'var questions = new Array();' . "\n"; |
|
| 779 | - $js .= 'var questions_answers = new Array();' . "\n"; |
|
| 780 | - $js .= 'var questions_answers_correct = new Array();' . "\n"; |
|
| 781 | - $js .= 'var questions_types = new Array();' . "\n"; |
|
| 782 | - $js .= "\n" . |
|
| 778 | + $js .= 'var questions = new Array();'."\n"; |
|
| 779 | + $js .= 'var questions_answers = new Array();'."\n"; |
|
| 780 | + $js .= 'var questions_answers_correct = new Array();'."\n"; |
|
| 781 | + $js .= 'var questions_types = new Array();'."\n"; |
|
| 782 | + $js .= "\n". |
|
| 783 | 783 | '/** |
| 784 | 784 | * Assigns any event handler to any element |
| 785 | 785 | * @param object Element on which the event is added |
@@ -819,7 +819,7 @@ discard block |
||
| 819 | 819 | //$js .= 'addEvent(window,\'load\',loadPage,false);'."\n"; |
| 820 | 820 | //$js .= 'addEvent(window,\'unload\',unloadPage,false);'."\n"; |
| 821 | 821 | $js .= 'addEvent(window,\'load\',addListeners,false);'."\n"; |
| 822 | - if($this->standalone){return $js. "\n";} |
|
| 822 | + if ($this->standalone) {return $js."\n"; } |
|
| 823 | 823 | return ''; |
| 824 | 824 | } |
| 825 | 825 | |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | */ |
| 830 | 830 | function end_js() |
| 831 | 831 | { |
| 832 | - if($this->standalone){return '</script>'. "\n";} |
|
| 832 | + if ($this->standalone) {return '</script>'."\n"; } |
|
| 833 | 833 | return ''; |
| 834 | 834 | } |
| 835 | 835 | |
@@ -839,7 +839,7 @@ discard block |
||
| 839 | 839 | */ |
| 840 | 840 | function start_body() |
| 841 | 841 | { |
| 842 | - if($this->standalone){return '<body>'. "\n".'<form id="dokeos_scorm_form" method="post" action="">'."\n";} |
|
| 842 | + if ($this->standalone) {return '<body>'."\n".'<form id="dokeos_scorm_form" method="post" action="">'."\n"; } |
|
| 843 | 843 | return ''; |
| 844 | 844 | } |
| 845 | 845 | |
@@ -849,7 +849,7 @@ discard block |
||
| 849 | 849 | */ |
| 850 | 850 | function end_body() |
| 851 | 851 | { |
| 852 | - if($this->standalone){return '<br /><input type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form>'."\n".'</body>'. "\n";} |
|
| 852 | + if ($this->standalone) {return '<br /><input type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form>'."\n".'</body>'."\n"; } |
|
| 853 | 853 | return ''; |
| 854 | 854 | } |
| 855 | 855 | |
@@ -864,9 +864,9 @@ discard block |
||
| 864 | 864 | function export() |
| 865 | 865 | { |
| 866 | 866 | $js = $html = ''; |
| 867 | - list($js,$html) = $this->question->export(); |
|
| 867 | + list($js, $html) = $this->question->export(); |
|
| 868 | 868 | //list($js,$html) = $this->question->answer->export(); |
| 869 | - if($this->standalone) |
|
| 869 | + if ($this->standalone) |
|
| 870 | 870 | { |
| 871 | 871 | $res = $this->start_page() |
| 872 | 872 | . $this->start_header() |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | } |
| 889 | 889 | else |
| 890 | 890 | { |
| 891 | - return array($js,$html); |
|
| 891 | + return array($js, $html); |
|
| 892 | 892 | } |
| 893 | 893 | } |
| 894 | 894 | } |
@@ -917,9 +917,9 @@ discard block |
||
| 917 | 917 | * @param boolean $standalone Wether it should include XML tag and DTD line. |
| 918 | 918 | * @return The XML as a string, or an empty string if there's no exercise with given ID. |
| 919 | 919 | */ |
| 920 | - public static function export_exercise_to_scorm($exerciseId, $standalone=true) { |
|
| 920 | + public static function export_exercise_to_scorm($exerciseId, $standalone = true) { |
|
| 921 | 921 | $exercise = new Exercise(); |
| 922 | - if (! $exercise->read($exerciseId)) { |
|
| 922 | + if (!$exercise->read($exerciseId)) { |
|
| 923 | 923 | return ''; |
| 924 | 924 | } |
| 925 | 925 | $ims = new ScormSection($exercise); |
@@ -946,7 +946,7 @@ discard block |
||
| 946 | 946 | function start_page() { |
| 947 | 947 | global $charset; |
| 948 | 948 | $head = $foot = ""; |
| 949 | - $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?>' . "\n".'<html>'."\n"; |
|
| 949 | + $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?>'."\n".'<html>'."\n"; |
|
| 950 | 950 | return $head; |
| 951 | 951 | } |
| 952 | 952 | |
@@ -962,7 +962,7 @@ discard block |
||
| 962 | 962 | * Start document header |
| 963 | 963 | */ |
| 964 | 964 | function start_header() { |
| 965 | - return '<head>'. "\n"; |
|
| 965 | + return '<head>'."\n"; |
|
| 966 | 966 | } |
| 967 | 967 | |
| 968 | 968 | /** |
@@ -984,7 +984,7 @@ discard block |
||
| 984 | 984 | * End document header |
| 985 | 985 | */ |
| 986 | 986 | function end_header() { |
| 987 | - return '</head>'. "\n"; |
|
| 987 | + return '</head>'."\n"; |
|
| 988 | 988 | } |
| 989 | 989 | |
| 990 | 990 | /** |
@@ -992,7 +992,7 @@ discard block |
||
| 992 | 992 | * |
| 993 | 993 | */ |
| 994 | 994 | function start_js() { |
| 995 | - return '<script type="text/javascript" language="javascript">'. "\n"; |
|
| 995 | + return '<script type="text/javascript" language="javascript">'."\n"; |
|
| 996 | 996 | } |
| 997 | 997 | |
| 998 | 998 | /** |
@@ -1002,11 +1002,11 @@ discard block |
||
| 1002 | 1002 | $js = "\n"; |
| 1003 | 1003 | $js .= file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js'); |
| 1004 | 1004 | $js .= file_get_contents('../newscorm/js/api_wrapper.js'); |
| 1005 | - $js .= 'var questions = new Array();' . "\n"; |
|
| 1006 | - $js .= 'var questions_answers = new Array();' . "\n"; |
|
| 1007 | - $js .= 'var questions_answers_correct = new Array();' . "\n"; |
|
| 1008 | - $js .= 'var questions_types = new Array();' . "\n"; |
|
| 1009 | - $js .= "\n" . |
|
| 1005 | + $js .= 'var questions = new Array();'."\n"; |
|
| 1006 | + $js .= 'var questions_answers = new Array();'."\n"; |
|
| 1007 | + $js .= 'var questions_answers_correct = new Array();'."\n"; |
|
| 1008 | + $js .= 'var questions_types = new Array();'."\n"; |
|
| 1009 | + $js .= "\n". |
|
| 1010 | 1010 | '/** |
| 1011 | 1011 | * Assigns any event handler to any element |
| 1012 | 1012 | * @param object Element on which the event is added |
@@ -1053,7 +1053,7 @@ discard block |
||
| 1053 | 1053 | //$js .= 'addEvent(window,\'load\',loadPage,false);'."\n"; |
| 1054 | 1054 | //$js .= 'addEvent(window,\'unload\',unloadPage,false);'."\n"; |
| 1055 | 1055 | $js .= 'addEvent(window,\'load\',addListeners,false);'."\n"; |
| 1056 | - return $js. "\n"; |
|
| 1056 | + return $js."\n"; |
|
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | 1059 | /** |
@@ -1061,7 +1061,7 @@ discard block |
||
| 1061 | 1061 | * |
| 1062 | 1062 | */ |
| 1063 | 1063 | function end_js() { |
| 1064 | - return '</script>'. "\n"; |
|
| 1064 | + return '</script>'."\n"; |
|
| 1065 | 1065 | } |
| 1066 | 1066 | |
| 1067 | 1067 | /** |
@@ -1070,7 +1070,7 @@ discard block |
||
| 1070 | 1070 | */ |
| 1071 | 1071 | function start_body() |
| 1072 | 1072 | { |
| 1073 | - return '<body>'. "\n". |
|
| 1073 | + return '<body>'."\n". |
|
| 1074 | 1074 | '<h1>'.$this->exercise->selectTitle().'</h1><p>'.$this->exercise->selectDescription()."</p>\n". |
| 1075 | 1075 | '<form id="dokeos_scorm_form" method="post" action="">'."\n". |
| 1076 | 1076 | '<table width="100%">'."\n"; |
@@ -1082,7 +1082,7 @@ discard block |
||
| 1082 | 1082 | */ |
| 1083 | 1083 | function end_body() |
| 1084 | 1084 | { |
| 1085 | - return '</table><br /><input type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form>'."\n".'</body>'. "\n"; |
|
| 1085 | + return '</table><br /><input type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form>'."\n".'</body>'."\n"; |
|
| 1086 | 1086 | } |
| 1087 | 1087 | |
| 1088 | 1088 | /** |
@@ -1099,11 +1099,11 @@ discard block |
||
| 1099 | 1099 | |
| 1100 | 1100 | $head = ""; |
| 1101 | 1101 | if ($this->standalone) { |
| 1102 | - $head = '<?xml version = "1.0" encoding = "' . $charset . '" standalone = "no"?>' . "\n" |
|
| 1103 | - . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"; |
|
| 1102 | + $head = '<?xml version = "1.0" encoding = "'.$charset.'" standalone = "no"?>'."\n" |
|
| 1103 | + . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">'."\n"; |
|
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | - list($js,$html) = $this->export_questions(); |
|
| 1106 | + list($js, $html) = $this->export_questions(); |
|
| 1107 | 1107 | //list($js,$html) = $this->question->answer->export(); |
| 1108 | 1108 | $res = $this->start_page() |
| 1109 | 1109 | . $this->start_header() |
@@ -1134,12 +1134,12 @@ discard block |
||
| 1134 | 1134 | $js = $html = ""; |
| 1135 | 1135 | $js_id = 0; |
| 1136 | 1136 | foreach ($this->exercise->selectQuestionList() as $q) { |
| 1137 | - list($jstmp,$htmltmp)= ScormQuestion::export_question($q, false, $js_id); |
|
| 1137 | + list($jstmp, $htmltmp) = ScormQuestion::export_question($q, false, $js_id); |
|
| 1138 | 1138 | $js .= $jstmp."\n"; |
| 1139 | 1139 | $html .= $htmltmp."\n"; |
| 1140 | 1140 | ++$js_id; |
| 1141 | 1141 | } |
| 1142 | - return array($js,$html); |
|
| 1142 | + return array($js, $html); |
|
| 1143 | 1143 | } |
| 1144 | 1144 | } |
| 1145 | 1145 | |
@@ -327,8 +327,7 @@ discard block |
||
| 327 | 327 | if($this->response == 'TRUE') |
| 328 | 328 | { |
| 329 | 329 | $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n"; |
| 330 | - } |
|
| 331 | - else |
|
| 330 | + } else |
|
| 332 | 331 | { |
| 333 | 332 | $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n"; |
| 334 | 333 | } |
@@ -471,8 +470,11 @@ discard block |
||
| 471 | 470 | |
| 472 | 471 | $s.='</select> </td>'."\n"; |
| 473 | 472 | $s.='<td width="40%" valign="top">'; |
| 474 | - if(isset($Select[$cpt2])) $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
| 475 | - else $s.=' '; |
|
| 473 | + if(isset($Select[$cpt2])) { |
|
| 474 | + $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
| 475 | + } else { |
|
| 476 | + $s.=' '; |
|
| 477 | + } |
|
| 476 | 478 | $s.="</td>\n</tr>\n"; |
| 477 | 479 | |
| 478 | 480 | $jstmpc .= '['.$answerCorrect.','.$cpt2.'],'; |
@@ -577,8 +579,7 @@ discard block |
||
| 577 | 579 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
| 578 | 580 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
| 579 | 581 | $header .= $jstmpw; |
| 580 | - } |
|
| 581 | - else |
|
| 582 | + } else |
|
| 582 | 583 | { |
| 583 | 584 | $header = ''; |
| 584 | 585 | $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
@@ -885,8 +886,7 @@ discard block |
||
| 885 | 886 | . $this->end_body() |
| 886 | 887 | . $this->end_page(); |
| 887 | 888 | return $res; |
| 888 | - } |
|
| 889 | - else |
|
| 889 | + } else |
|
| 890 | 890 | { |
| 891 | 891 | return array($js,$html); |
| 892 | 892 | } |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /* For licensing terms, see /license.txt */ |
| 3 | 3 | /** |
| 4 | - * @author Claro Team <[email protected]> |
|
| 5 | - * @author Yannick Warnier <[email protected]> |
|
| 6 | - * @package chamilo.exercise.scorm |
|
| 7 | - */ |
|
| 4 | + * @author Claro Team <[email protected]> |
|
| 5 | + * @author Yannick Warnier <[email protected]> |
|
| 6 | + * @package chamilo.exercise.scorm |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * The ScormQuestion class is a gateway to getting the answers exported |
@@ -49,86 +49,86 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | - * Include the correct answer class and create answer |
|
| 53 | - */ |
|
| 54 | - public function setAnswer() |
|
| 55 | - { |
|
| 56 | - switch ($this->type) { |
|
| 57 | - case MCUA: |
|
| 58 | - $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
| 52 | + * Include the correct answer class and create answer |
|
| 53 | + */ |
|
| 54 | + public function setAnswer() |
|
| 55 | + { |
|
| 56 | + switch ($this->type) { |
|
| 57 | + case MCUA: |
|
| 58 | + $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
| 59 | 59 | $this->answer->questionJSId = $this->js_id; |
| 60 | - break; |
|
| 61 | - case MCMA: |
|
| 60 | + break; |
|
| 61 | + case MCMA: |
|
| 62 | 62 | case GLOBAL_MULTIPLE_ANSWER: |
| 63 | - $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
| 63 | + $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
| 64 | 64 | $this->answer->questionJSId = $this->js_id; |
| 65 | - break; |
|
| 66 | - case TF: |
|
| 67 | - $this->answer = new ScormAnswerTrueFalse($this->id); |
|
| 65 | + break; |
|
| 66 | + case TF: |
|
| 67 | + $this->answer = new ScormAnswerTrueFalse($this->id); |
|
| 68 | 68 | $this->answer->questionJSId = $this->js_id; |
| 69 | - break; |
|
| 70 | - case FIB: |
|
| 71 | - $this->answer = new ScormAnswerFillInBlanks($this->id); |
|
| 69 | + break; |
|
| 70 | + case FIB: |
|
| 71 | + $this->answer = new ScormAnswerFillInBlanks($this->id); |
|
| 72 | 72 | $this->answer->questionJSId = $this->js_id; |
| 73 | - break; |
|
| 74 | - case MATCHING: |
|
| 73 | + break; |
|
| 74 | + case MATCHING: |
|
| 75 | 75 | case MATCHING_DRAGGABLE: |
| 76 | - $this->answer = new ScormAnswerMatching($this->id); |
|
| 76 | + $this->answer = new ScormAnswerMatching($this->id); |
|
| 77 | 77 | $this->answer->questionJSId = $this->js_id; |
| 78 | - break; |
|
| 78 | + break; |
|
| 79 | 79 | case ORAL_EXPRESSION: |
| 80 | - case FREE_ANSWER: |
|
| 81 | - $this->answer = new ScormAnswerFree($this->id); |
|
| 80 | + case FREE_ANSWER: |
|
| 81 | + $this->answer = new ScormAnswerFree($this->id); |
|
| 82 | 82 | $this->answer->questionJSId = $this->js_id; |
| 83 | - break; |
|
| 84 | - case HOT_SPOT: |
|
| 85 | - $this->answer = new ScormAnswerHotspot($this->id); |
|
| 83 | + break; |
|
| 84 | + case HOT_SPOT: |
|
| 85 | + $this->answer = new ScormAnswerHotspot($this->id); |
|
| 86 | 86 | $this->answer->questionJSId = $this->js_id; |
| 87 | - break; |
|
| 88 | - case MULTIPLE_ANSWER_COMBINATION: |
|
| 89 | - $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
| 87 | + break; |
|
| 88 | + case MULTIPLE_ANSWER_COMBINATION: |
|
| 89 | + $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
| 90 | 90 | $this->answer->questionJSId = $this->js_id; |
| 91 | - break; |
|
| 91 | + break; |
|
| 92 | 92 | case HOT_SPOT_ORDER: |
| 93 | - $this->answer = new ScormAnswerHotspot($this->id); |
|
| 93 | + $this->answer = new ScormAnswerHotspot($this->id); |
|
| 94 | 94 | $this->answer->questionJSId = $this->js_id; |
| 95 | - break; |
|
| 96 | - case HOT_SPOT_DELINEATION: |
|
| 97 | - $this->answer = new ScormAnswerHotspot($this->id); |
|
| 95 | + break; |
|
| 96 | + case HOT_SPOT_DELINEATION: |
|
| 97 | + $this->answer = new ScormAnswerHotspot($this->id); |
|
| 98 | 98 | $this->answer->questionJSId = $this->js_id; |
| 99 | - break; |
|
| 100 | - default : |
|
| 101 | - $this->answer = null; |
|
| 99 | + break; |
|
| 100 | + default : |
|
| 101 | + $this->answer = null; |
|
| 102 | 102 | $this->answer->questionJSId = $this->js_id; |
| 103 | - break; |
|
| 104 | - } |
|
| 103 | + break; |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - return true; |
|
| 107 | - } |
|
| 106 | + return true; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - function export() |
|
| 110 | - { |
|
| 111 | - $html = $this->getQuestionHTML(); |
|
| 112 | - $js = $this->getQuestionJS(); |
|
| 109 | + function export() |
|
| 110 | + { |
|
| 111 | + $html = $this->getQuestionHTML(); |
|
| 112 | + $js = $this->getQuestionJS(); |
|
| 113 | 113 | |
| 114 | - if( is_object($this->answer) ) |
|
| 115 | - { |
|
| 116 | - list($js2,$html2) = $this->answer->export(); |
|
| 117 | - $js .= $js2; |
|
| 118 | - $html .= $html2; |
|
| 119 | - } |
|
| 114 | + if( is_object($this->answer) ) |
|
| 115 | + { |
|
| 116 | + list($js2,$html2) = $this->answer->export(); |
|
| 117 | + $js .= $js2; |
|
| 118 | + $html .= $html2; |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - return array($js,$html); |
|
| 122 | - } |
|
| 121 | + return array($js,$html); |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | 124 | function createAnswersForm($form) |
| 125 | 125 | { |
| 126 | - return true; |
|
| 126 | + return true; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | function processAnswersCreation($form) |
| 130 | 130 | { |
| 131 | - return true; |
|
| 131 | + return true; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -136,20 +136,20 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | function getQuestionHTML() |
| 138 | 138 | { |
| 139 | - $title = $this->selectTitle(); |
|
| 140 | - $description = $this->selectDescription(); |
|
| 141 | - $cols = 2; |
|
| 142 | - $s='<tr>' . |
|
| 143 | - '<td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;">' . "\n" . |
|
| 144 | - $title. |
|
| 145 | - '</td>' . "\n" . |
|
| 146 | - '</tr>' . "\n" . |
|
| 147 | - '<tr>' . "\n" . |
|
| 148 | - '<td valign="top" colspan="'.$cols.'">' . "\n" . |
|
| 149 | - '<i>'.$description.'</i>' . "\n" . |
|
| 150 | - '</td>' . "\n" . |
|
| 151 | - '</tr>' . "\n"; |
|
| 152 | - return $s; |
|
| 139 | + $title = $this->selectTitle(); |
|
| 140 | + $description = $this->selectDescription(); |
|
| 141 | + $cols = 2; |
|
| 142 | + $s='<tr>' . |
|
| 143 | + '<td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;">' . "\n" . |
|
| 144 | + $title. |
|
| 145 | + '</td>' . "\n" . |
|
| 146 | + '</tr>' . "\n" . |
|
| 147 | + '<tr>' . "\n" . |
|
| 148 | + '<td valign="top" colspan="'.$cols.'">' . "\n" . |
|
| 149 | + '<i>'.$description.'</i>' . "\n" . |
|
| 150 | + '</td>' . "\n" . |
|
| 151 | + '</tr>' . "\n"; |
|
| 152 | + return $s; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -157,16 +157,16 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | function getQuestionJS() |
| 159 | 159 | { |
| 160 | - //$id = $this->id; |
|
| 161 | - $w = $this->selectWeighting(); |
|
| 162 | - $s = 'questions.push('.$this->js_id.');'."\n"; |
|
| 163 | - if($this->type == FREE_ANSWER or $this->type == HOT_SPOT) |
|
| 164 | - { //put the max score to 0 to avoid discounting the points of |
|
| 165 | - //non-exported quiz types in the SCORM |
|
| 166 | - $w=0; |
|
| 167 | - } |
|
| 168 | - $s .= 'questions_score_max['.$this->js_id.'] = '.$w.";\n"; |
|
| 169 | - return $s; |
|
| 160 | + //$id = $this->id; |
|
| 161 | + $w = $this->selectWeighting(); |
|
| 162 | + $s = 'questions.push('.$this->js_id.');'."\n"; |
|
| 163 | + if($this->type == FREE_ANSWER or $this->type == HOT_SPOT) |
|
| 164 | + { //put the max score to 0 to avoid discounting the points of |
|
| 165 | + //non-exported quiz types in the SCORM |
|
| 166 | + $w=0; |
|
| 167 | + } |
|
| 168 | + $s .= 'questions_score_max['.$this->js_id.'] = '.$w.";\n"; |
|
| 169 | + return $s; |
|
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | |
@@ -177,107 +177,107 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | class ScormAnswerMultipleChoice extends Answer |
| 179 | 179 | { |
| 180 | - /** |
|
| 181 | - * Return HTML code for possible answers |
|
| 180 | + /** |
|
| 181 | + * Return HTML code for possible answers |
|
| 182 | 182 | */ |
| 183 | - function export() |
|
| 184 | - { |
|
| 185 | - $html = ''; |
|
| 186 | - $js = ''; |
|
| 187 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
| 188 | - $type = $this->getQuestionType(); |
|
| 189 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 190 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
| 191 | - |
|
| 192 | - //not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM |
|
| 183 | + function export() |
|
| 184 | + { |
|
| 185 | + $html = ''; |
|
| 186 | + $js = ''; |
|
| 187 | + $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
| 188 | + $type = $this->getQuestionType(); |
|
| 189 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 190 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
| 191 | + |
|
| 192 | + //not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM |
|
| 193 | 193 | //if ($type == MCMA || $type == MULTIPLE_ANSWER_COMBINATION ) { |
| 194 | - if ($type == MCMA ) { |
|
| 195 | - //$questionTypeLang = get_lang('MultipleChoiceMultipleAnswers'); |
|
| 196 | - $id = 1; |
|
| 197 | - $jstmp = ''; |
|
| 198 | - $jstmpc = ''; |
|
| 199 | - foreach( $this->answer as $i => $answer ) |
|
| 200 | - { |
|
| 201 | - $identifier = 'question_'.$this->questionJSId.'_multiple_'.$i; |
|
| 202 | - $html .= |
|
| 203 | - '<tr>' . "\n" |
|
| 204 | - . '<td align="center" width="5%">' . "\n" |
|
| 205 | - . '<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />' . "\n" |
|
| 206 | - . '</td>' . "\n" |
|
| 207 | - . '<td width="95%">' . "\n" |
|
| 208 | - . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
| 209 | - . '</td>' . "\n" |
|
| 210 | - . '</tr>' . "\n\n"; |
|
| 211 | - $jstmp .= $i.','; |
|
| 212 | - if($this->correct[$i]) |
|
| 213 | - { |
|
| 214 | - $jstmpc .= $i.','; |
|
| 215 | - } |
|
| 216 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
|
| 217 | - $id++; |
|
| 218 | - } |
|
| 219 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
| 220 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
| 221 | - if ($type == MCMA) { |
|
| 222 | - $js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n"; |
|
| 223 | - } else { |
|
| 224 | - $js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n"; |
|
| 225 | - } |
|
| 226 | - $js .= $jstmpw; |
|
| 194 | + if ($type == MCMA ) { |
|
| 195 | + //$questionTypeLang = get_lang('MultipleChoiceMultipleAnswers'); |
|
| 196 | + $id = 1; |
|
| 197 | + $jstmp = ''; |
|
| 198 | + $jstmpc = ''; |
|
| 199 | + foreach( $this->answer as $i => $answer ) |
|
| 200 | + { |
|
| 201 | + $identifier = 'question_'.$this->questionJSId.'_multiple_'.$i; |
|
| 202 | + $html .= |
|
| 203 | + '<tr>' . "\n" |
|
| 204 | + . '<td align="center" width="5%">' . "\n" |
|
| 205 | + . '<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />' . "\n" |
|
| 206 | + . '</td>' . "\n" |
|
| 207 | + . '<td width="95%">' . "\n" |
|
| 208 | + . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
| 209 | + . '</td>' . "\n" |
|
| 210 | + . '</tr>' . "\n\n"; |
|
| 211 | + $jstmp .= $i.','; |
|
| 212 | + if($this->correct[$i]) |
|
| 213 | + { |
|
| 214 | + $jstmpc .= $i.','; |
|
| 215 | + } |
|
| 216 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
|
| 217 | + $id++; |
|
| 218 | + } |
|
| 219 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
| 220 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
| 221 | + if ($type == MCMA) { |
|
| 222 | + $js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n"; |
|
| 223 | + } else { |
|
| 224 | + $js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n"; |
|
| 225 | + } |
|
| 226 | + $js .= $jstmpw; |
|
| 227 | 227 | } elseif ($type == MULTIPLE_ANSWER_COMBINATION) { |
| 228 | - //To this items we show the ThisItemIsNotExportable |
|
| 229 | - $qId = $this->questionJSId; |
|
| 230 | - $js = ''; |
|
| 231 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
| 232 | - // some javascript must be added for that kind of questions |
|
| 233 | - $html .= '<tr>' . "\n" |
|
| 234 | - . '<td>' . "\n" |
|
| 235 | - . '<textarea name="question_'.$qId.'_free" id="question_'.$qId.'_exact" rows="20" cols="100"></textarea>' . "\n" |
|
| 236 | - . '</td>' . "\n" |
|
| 237 | - . '</tr>' . "\n"; |
|
| 238 | - $html .= '</table></td></tr>' . "\n"; |
|
| 239 | - // currently the exact answers cannot be displayed, so ignore the textarea |
|
| 240 | - $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
| 241 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 242 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 243 | - $js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n"; |
|
| 244 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 245 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
| 246 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
| 247 | - $js .= $jstmpw; |
|
| 248 | - return array($js,$html); |
|
| 228 | + //To this items we show the ThisItemIsNotExportable |
|
| 229 | + $qId = $this->questionJSId; |
|
| 230 | + $js = ''; |
|
| 231 | + $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
| 232 | + // some javascript must be added for that kind of questions |
|
| 233 | + $html .= '<tr>' . "\n" |
|
| 234 | + . '<td>' . "\n" |
|
| 235 | + . '<textarea name="question_'.$qId.'_free" id="question_'.$qId.'_exact" rows="20" cols="100"></textarea>' . "\n" |
|
| 236 | + . '</td>' . "\n" |
|
| 237 | + . '</tr>' . "\n"; |
|
| 238 | + $html .= '</table></td></tr>' . "\n"; |
|
| 239 | + // currently the exact answers cannot be displayed, so ignore the textarea |
|
| 240 | + $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
| 241 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 242 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 243 | + $js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n"; |
|
| 244 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 245 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
| 246 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
| 247 | + $js .= $jstmpw; |
|
| 248 | + return array($js,$html); |
|
| 249 | 249 | } else { |
| 250 | - //$questionTypeLang = get_lang('MultipleChoiceUniqueAnswer'); |
|
| 251 | - $id = 1; |
|
| 252 | - $jstmp = ''; |
|
| 253 | - $jstmpc = ''; |
|
| 254 | - foreach( $this->answer as $i => $answer ) |
|
| 255 | - { |
|
| 256 | - $identifier = 'question_'.$this->questionJSId.'_unique_'.$i; |
|
| 257 | - $identifier_name = 'question_'.$this->questionJSId.'_unique_answer'; |
|
| 258 | - $html .= |
|
| 259 | - '<tr>' . "\n" |
|
| 260 | - . '<td align="center" width="5%">' . "\n" |
|
| 261 | - . '<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="radio"/>' . "\n" |
|
| 262 | - . '</td>' . "\n" |
|
| 263 | - . '<td width="95%">' . "\n" |
|
| 264 | - . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
| 265 | - . '</td>' . "\n" |
|
| 266 | - . '</tr>' . "\n\n"; |
|
| 267 | - $jstmp .= $i.','; |
|
| 268 | - if($this->correct[$i]) |
|
| 269 | - { |
|
| 270 | - $jstmpc .= $i; |
|
| 271 | - } |
|
| 272 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
|
| 273 | - $id++; |
|
| 274 | - } |
|
| 275 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
| 276 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = '.$jstmpc.';'."\n"; |
|
| 277 | - $js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';'."\n"; |
|
| 278 | - $js .= $jstmpw; |
|
| 250 | + //$questionTypeLang = get_lang('MultipleChoiceUniqueAnswer'); |
|
| 251 | + $id = 1; |
|
| 252 | + $jstmp = ''; |
|
| 253 | + $jstmpc = ''; |
|
| 254 | + foreach( $this->answer as $i => $answer ) |
|
| 255 | + { |
|
| 256 | + $identifier = 'question_'.$this->questionJSId.'_unique_'.$i; |
|
| 257 | + $identifier_name = 'question_'.$this->questionJSId.'_unique_answer'; |
|
| 258 | + $html .= |
|
| 259 | + '<tr>' . "\n" |
|
| 260 | + . '<td align="center" width="5%">' . "\n" |
|
| 261 | + . '<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="radio"/>' . "\n" |
|
| 262 | + . '</td>' . "\n" |
|
| 263 | + . '<td width="95%">' . "\n" |
|
| 264 | + . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
| 265 | + . '</td>' . "\n" |
|
| 266 | + . '</tr>' . "\n\n"; |
|
| 267 | + $jstmp .= $i.','; |
|
| 268 | + if($this->correct[$i]) |
|
| 269 | + { |
|
| 270 | + $jstmpc .= $i; |
|
| 271 | + } |
|
| 272 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
|
| 273 | + $id++; |
|
| 274 | + } |
|
| 275 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
| 276 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = '.$jstmpc.';'."\n"; |
|
| 277 | + $js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';'."\n"; |
|
| 278 | + $js .= $jstmpw; |
|
| 279 | 279 | } |
| 280 | - $html .= '</table></td></tr>' . "\n"; |
|
| 280 | + $html .= '</table></td></tr>' . "\n"; |
|
| 281 | 281 | return array($js,$html); |
| 282 | 282 | } |
| 283 | 283 | } |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | */ |
| 289 | 289 | class ScormAnswerTrueFalse extends Answer |
| 290 | 290 | { |
| 291 | - /** |
|
| 291 | + /** |
|
| 292 | 292 | * Return the XML flow for the possible answers. |
| 293 | 293 | * That's one <response_lid>, containing several <flow_label> |
| 294 | 294 | * |
@@ -296,46 +296,46 @@ discard block |
||
| 296 | 296 | */ |
| 297 | 297 | function export() |
| 298 | 298 | { |
| 299 | - $js = ''; |
|
| 300 | - $html = '<tr><td colspan="2"><table width="100%">'; |
|
| 301 | - $identifier = 'question_'.$this->questionJSId.'_tf'; |
|
| 302 | - $identifier_true = $identifier.'_true'; |
|
| 303 | - $identifier_false = $identifier.'_false'; |
|
| 304 | - $html .= |
|
| 305 | - '<tr>' . "\n" |
|
| 306 | - . '<td align="center" width="5%">' . "\n" |
|
| 307 | - . '<input name="'.$identifier_true.'" id="'.$identifier_true.'" value="'.$this->trueGrade.'" type="radio" ' |
|
| 308 | - . '/>' . "\n" |
|
| 309 | - . '</td>' . "\n" |
|
| 310 | - . '<td width="95%">' . "\n" |
|
| 311 | - . '<label for="'.$identifier_true.'">' . get_lang('True') . '</label>' . "\n" |
|
| 312 | - . '</td>' . "\n" |
|
| 313 | - . '</tr>' . "\n\n"; |
|
| 314 | - $html .= |
|
| 315 | - '<tr>' . "\n" |
|
| 316 | - . '<td align="center" width="5%">' . "\n" |
|
| 317 | - . '<input name="'.$identifier_false.'" id="'.$identifier_false.'" value="'.$this->falseGrade.'" type="radio" ' |
|
| 318 | - . '/>' . "\n" |
|
| 319 | - . '</td>' . "\n" |
|
| 320 | - . '<td width="95%">' . "\n" |
|
| 321 | - . '<label for="'.$identifier_false.'">' . get_lang('False') . '</label>' . "\n" |
|
| 322 | - . '</td>' . "\n" |
|
| 323 | - . '</tr>' . "\n\n"; |
|
| 324 | - $html .= '</table></td></tr>' . "\n"; |
|
| 325 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n"; |
|
| 326 | - $js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n"; |
|
| 327 | - if($this->response == 'TRUE') |
|
| 328 | - { |
|
| 329 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n"; |
|
| 330 | - } |
|
| 331 | - else |
|
| 332 | - { |
|
| 333 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n"; |
|
| 334 | - } |
|
| 335 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 336 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
| 337 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n"; |
|
| 338 | - $js .= $jstmpw; |
|
| 299 | + $js = ''; |
|
| 300 | + $html = '<tr><td colspan="2"><table width="100%">'; |
|
| 301 | + $identifier = 'question_'.$this->questionJSId.'_tf'; |
|
| 302 | + $identifier_true = $identifier.'_true'; |
|
| 303 | + $identifier_false = $identifier.'_false'; |
|
| 304 | + $html .= |
|
| 305 | + '<tr>' . "\n" |
|
| 306 | + . '<td align="center" width="5%">' . "\n" |
|
| 307 | + . '<input name="'.$identifier_true.'" id="'.$identifier_true.'" value="'.$this->trueGrade.'" type="radio" ' |
|
| 308 | + . '/>' . "\n" |
|
| 309 | + . '</td>' . "\n" |
|
| 310 | + . '<td width="95%">' . "\n" |
|
| 311 | + . '<label for="'.$identifier_true.'">' . get_lang('True') . '</label>' . "\n" |
|
| 312 | + . '</td>' . "\n" |
|
| 313 | + . '</tr>' . "\n\n"; |
|
| 314 | + $html .= |
|
| 315 | + '<tr>' . "\n" |
|
| 316 | + . '<td align="center" width="5%">' . "\n" |
|
| 317 | + . '<input name="'.$identifier_false.'" id="'.$identifier_false.'" value="'.$this->falseGrade.'" type="radio" ' |
|
| 318 | + . '/>' . "\n" |
|
| 319 | + . '</td>' . "\n" |
|
| 320 | + . '<td width="95%">' . "\n" |
|
| 321 | + . '<label for="'.$identifier_false.'">' . get_lang('False') . '</label>' . "\n" |
|
| 322 | + . '</td>' . "\n" |
|
| 323 | + . '</tr>' . "\n\n"; |
|
| 324 | + $html .= '</table></td></tr>' . "\n"; |
|
| 325 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n"; |
|
| 326 | + $js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n"; |
|
| 327 | + if($this->response == 'TRUE') |
|
| 328 | + { |
|
| 329 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n"; |
|
| 330 | + } |
|
| 331 | + else |
|
| 332 | + { |
|
| 333 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n"; |
|
| 334 | + } |
|
| 335 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 336 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
| 337 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n"; |
|
| 338 | + $js .= $jstmpw; |
|
| 339 | 339 | |
| 340 | 340 | return array($js,$html); |
| 341 | 341 | } |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | */ |
| 348 | 348 | class ScormAnswerFillInBlanks extends Answer |
| 349 | 349 | { |
| 350 | - /** |
|
| 350 | + /** |
|
| 351 | 351 | * Export the text with missing words. |
| 352 | 352 | * |
| 353 | 353 | * As a side effect, it stores two lists in the class : |
@@ -355,57 +355,57 @@ discard block |
||
| 355 | 355 | */ |
| 356 | 356 | function export() |
| 357 | 357 | { |
| 358 | - global $charset; |
|
| 359 | - $js = ''; |
|
| 360 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
| 361 | - // get all enclosed answers |
|
| 362 | - $blankList = array(); |
|
| 363 | - // build replacement |
|
| 364 | - $replacementList = array(); |
|
| 365 | - foreach( $this->answer as $i => $answer) { |
|
| 366 | - $blankList[] = '['.$answer.']'; |
|
| 367 | - } |
|
| 368 | - $answerCount = count($blankList); |
|
| 369 | - |
|
| 370 | - // splits text and weightings that are joined with the character '::' |
|
| 371 | - list($answer,$weight)=explode('::',$answer); |
|
| 372 | - $weights = explode(',',$weight); |
|
| 373 | - // because [] is parsed here we follow this procedure: |
|
| 374 | - // 1. find everything between the [ and ] tags |
|
| 375 | - $i=1; |
|
| 376 | - $jstmp = ''; |
|
| 377 | - $jstmpc = ''; |
|
| 378 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 379 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
| 380 | - $startlocations=api_strpos($answer,'['); |
|
| 381 | - $endlocations=api_strpos($answer,']'); |
|
| 382 | - while($startlocations !== false && $endlocations !== false) { |
|
| 383 | - $texstring=api_substr($answer,$startlocations,($endlocations-$startlocations)+1); |
|
| 384 | - $answer = api_substr_replace($answer,'<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />',$startlocations,($endlocations-$startlocations)+1); |
|
| 385 | - $jstmp .= $i.','; |
|
| 386 | - $jstmpc .= "'".api_htmlentities(api_substr($texstring,1,-1),ENT_QUOTES,$charset)."',"; |
|
| 387 | - $my_weight=explode('@',$weights[$i-1]); |
|
| 388 | - if (count($my_weight)==2) { |
|
| 389 | - $weight_db=$my_weight[0]; |
|
| 390 | - } else { |
|
| 391 | - $weight_db=$my_weight[0]; |
|
| 392 | - } |
|
| 393 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n"; |
|
| 394 | - $i++; |
|
| 395 | - $startlocations=api_strpos($answer,'['); |
|
| 396 | - $endlocations=api_strpos($answer,']'); |
|
| 397 | - } |
|
| 358 | + global $charset; |
|
| 359 | + $js = ''; |
|
| 360 | + $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
| 361 | + // get all enclosed answers |
|
| 362 | + $blankList = array(); |
|
| 363 | + // build replacement |
|
| 364 | + $replacementList = array(); |
|
| 365 | + foreach( $this->answer as $i => $answer) { |
|
| 366 | + $blankList[] = '['.$answer.']'; |
|
| 367 | + } |
|
| 368 | + $answerCount = count($blankList); |
|
| 369 | + |
|
| 370 | + // splits text and weightings that are joined with the character '::' |
|
| 371 | + list($answer,$weight)=explode('::',$answer); |
|
| 372 | + $weights = explode(',',$weight); |
|
| 373 | + // because [] is parsed here we follow this procedure: |
|
| 374 | + // 1. find everything between the [ and ] tags |
|
| 375 | + $i=1; |
|
| 376 | + $jstmp = ''; |
|
| 377 | + $jstmpc = ''; |
|
| 378 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 379 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
| 380 | + $startlocations=api_strpos($answer,'['); |
|
| 381 | + $endlocations=api_strpos($answer,']'); |
|
| 382 | + while($startlocations !== false && $endlocations !== false) { |
|
| 383 | + $texstring=api_substr($answer,$startlocations,($endlocations-$startlocations)+1); |
|
| 384 | + $answer = api_substr_replace($answer,'<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />',$startlocations,($endlocations-$startlocations)+1); |
|
| 385 | + $jstmp .= $i.','; |
|
| 386 | + $jstmpc .= "'".api_htmlentities(api_substr($texstring,1,-1),ENT_QUOTES,$charset)."',"; |
|
| 387 | + $my_weight=explode('@',$weights[$i-1]); |
|
| 388 | + if (count($my_weight)==2) { |
|
| 389 | + $weight_db=$my_weight[0]; |
|
| 390 | + } else { |
|
| 391 | + $weight_db=$my_weight[0]; |
|
| 392 | + } |
|
| 393 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n"; |
|
| 394 | + $i++; |
|
| 395 | + $startlocations=api_strpos($answer,'['); |
|
| 396 | + $endlocations=api_strpos($answer,']'); |
|
| 397 | + } |
|
| 398 | 398 | |
| 399 | - $html .= '<tr>' . "\n" |
|
| 400 | - . '<td>' . "\n" |
|
| 401 | - . $answer . "\n" |
|
| 402 | - . '</td>' . "\n" |
|
| 403 | - . '</tr>' . "\n"; |
|
| 404 | - $html .= '</table></td></tr>' . "\n"; |
|
| 405 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n"; |
|
| 406 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n"; |
|
| 407 | - $js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n"; |
|
| 408 | - $js .= $jstmpw; |
|
| 399 | + $html .= '<tr>' . "\n" |
|
| 400 | + . '<td>' . "\n" |
|
| 401 | + . $answer . "\n" |
|
| 402 | + . '</td>' . "\n" |
|
| 403 | + . '</tr>' . "\n"; |
|
| 404 | + $html .= '</table></td></tr>' . "\n"; |
|
| 405 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n"; |
|
| 406 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n"; |
|
| 407 | + $js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n"; |
|
| 408 | + $js .= $jstmpw; |
|
| 409 | 409 | return array($js,$html); |
| 410 | 410 | } |
| 411 | 411 | } |
@@ -416,101 +416,101 @@ discard block |
||
| 416 | 416 | */ |
| 417 | 417 | class ScormAnswerMatching extends Answer |
| 418 | 418 | { |
| 419 | - /** |
|
| 419 | + /** |
|
| 420 | 420 | * Export the question part as a matrix-choice, with only one possible answer per line. |
| 421 | 421 | * @author Amand Tihon <[email protected]> |
| 422 | 422 | */ |
| 423 | 423 | function export() |
| 424 | 424 | { |
| 425 | - $js = ''; |
|
| 426 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
| 427 | - // prepare list of right proposition to allow |
|
| 428 | - // - easiest display |
|
| 429 | - // - easiest randomisation if needed one day |
|
| 430 | - // (here I use array_values to change array keys from $code1 $code2 ... to 0 1 ...) |
|
| 431 | - if (is_array($this->rightList)) { |
|
| 432 | - $displayedRightList = array_values($this->rightList); |
|
| 433 | - } |
|
| 434 | - // get max length of displayed array |
|
| 435 | - $arrayLength = max( count($this->leftList), count($this->rightList) ); |
|
| 436 | - |
|
| 437 | - $nbrAnswers=$this->selectNbrAnswers(); |
|
| 438 | - $cpt1='A'; |
|
| 439 | - $cpt2=1; |
|
| 440 | - $Select=array(); |
|
| 441 | - $qId = $this->questionJSId; |
|
| 442 | - $s = ''; |
|
| 443 | - $jstmp = ''; |
|
| 444 | - $jstmpc = ''; |
|
| 425 | + $js = ''; |
|
| 426 | + $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
| 427 | + // prepare list of right proposition to allow |
|
| 428 | + // - easiest display |
|
| 429 | + // - easiest randomisation if needed one day |
|
| 430 | + // (here I use array_values to change array keys from $code1 $code2 ... to 0 1 ...) |
|
| 431 | + if (is_array($this->rightList)) { |
|
| 432 | + $displayedRightList = array_values($this->rightList); |
|
| 433 | + } |
|
| 434 | + // get max length of displayed array |
|
| 435 | + $arrayLength = max( count($this->leftList), count($this->rightList) ); |
|
| 436 | + |
|
| 437 | + $nbrAnswers=$this->selectNbrAnswers(); |
|
| 438 | + $cpt1='A'; |
|
| 439 | + $cpt2=1; |
|
| 440 | + $Select=array(); |
|
| 441 | + $qId = $this->questionJSId; |
|
| 442 | + $s = ''; |
|
| 443 | + $jstmp = ''; |
|
| 444 | + $jstmpc = ''; |
|
| 445 | 445 | $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
| 446 | 446 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
| 447 | 447 | |
| 448 | - for($answerId=1;$answerId <= $nbrAnswers;$answerId++) { |
|
| 449 | - $identifier = 'question_'.$qId.'_matching_'; |
|
| 450 | - $answer=$this->selectAnswer($answerId); |
|
| 451 | - $answerCorrect=$this->isCorrect($answerId); |
|
| 452 | - $weight=$this->selectWeighting($answerId); |
|
| 453 | - $jstmp .= $answerId.','; |
|
| 454 | - |
|
| 455 | - if (!$answerCorrect) { |
|
| 456 | - // options (A, B, C, ...) that will be put into the list-box |
|
| 457 | - $Select[$answerId]['Lettre']=$cpt1; |
|
| 458 | - // answers that will be shown at the right side |
|
| 459 | - $Select[$answerId]['Reponse'] = $answer; |
|
| 460 | - $cpt1++; |
|
| 461 | - } else { |
|
| 462 | - $s.='<tr>'."\n"; |
|
| 463 | - $s.='<td width="40%" valign="top">'."\n".'<b>'.$cpt2.'</b>. '.$answer."\n</td>\n"; |
|
| 464 | - $s.='<td width="20%" align="center"> <select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">'; |
|
| 465 | - $s.=' <option value="0">--</option>'; |
|
| 466 | - // fills the list-box |
|
| 467 | - foreach($Select as $key=>$val) |
|
| 468 | - { |
|
| 469 | - $s.='<option value="'.$key.'">'.$val['Lettre'].'</option>'; |
|
| 470 | - } // end foreach() |
|
| 471 | - |
|
| 472 | - $s.='</select> </td>'."\n"; |
|
| 473 | - $s.='<td width="40%" valign="top">'; |
|
| 474 | - if(isset($Select[$cpt2])) $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
| 475 | - else $s.=' '; |
|
| 476 | - $s.="</td>\n</tr>\n"; |
|
| 477 | - |
|
| 478 | - $jstmpc .= '['.$answerCorrect.','.$cpt2.'],'; |
|
| 479 | - |
|
| 480 | - $my_weight=explode('@',$weight); |
|
| 481 | - if (count($my_weight)==2) { |
|
| 482 | - $weight=$my_weight[0]; |
|
| 483 | - } else { |
|
| 484 | - $weight=$my_weight[0]; |
|
| 485 | - } |
|
| 486 | - $jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n"; |
|
| 487 | - $cpt2++; |
|
| 488 | - |
|
| 489 | - // if the left side of the "matching" has been completely shown |
|
| 490 | - if($answerId == $nbrAnswers) |
|
| 491 | - { |
|
| 492 | - // if there remain answers to be shown on the right side |
|
| 493 | - while(isset($Select[$cpt2])) |
|
| 494 | - { |
|
| 495 | - //$s.='<tr>'."\n"; |
|
| 496 | - //$s.='<td colspan="2">'."\n"; |
|
| 497 | - //$s.='<table border="0" cellpadding="0" cellspacing="0" width="100%">'."\n"; |
|
| 498 | - $s.='<tr>'."\n"; |
|
| 499 | - $s.='<td width="60%" colspan="2"> </td>'."\n"; |
|
| 500 | - $s.='<td width="40%" valign="top">'; |
|
| 501 | - $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
| 502 | - $s.="</td>\n</tr>\n"; |
|
| 503 | - $cpt2++; |
|
| 504 | - } // end while() |
|
| 505 | - } // end if() |
|
| 506 | - } |
|
| 507 | - } |
|
| 508 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
| 509 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
| 510 | - $js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n"; |
|
| 511 | - $js .= $jstmpw; |
|
| 512 | - $html .= $s; |
|
| 513 | - $html .= '</table></td></tr>' . "\n"; |
|
| 448 | + for($answerId=1;$answerId <= $nbrAnswers;$answerId++) { |
|
| 449 | + $identifier = 'question_'.$qId.'_matching_'; |
|
| 450 | + $answer=$this->selectAnswer($answerId); |
|
| 451 | + $answerCorrect=$this->isCorrect($answerId); |
|
| 452 | + $weight=$this->selectWeighting($answerId); |
|
| 453 | + $jstmp .= $answerId.','; |
|
| 454 | + |
|
| 455 | + if (!$answerCorrect) { |
|
| 456 | + // options (A, B, C, ...) that will be put into the list-box |
|
| 457 | + $Select[$answerId]['Lettre']=$cpt1; |
|
| 458 | + // answers that will be shown at the right side |
|
| 459 | + $Select[$answerId]['Reponse'] = $answer; |
|
| 460 | + $cpt1++; |
|
| 461 | + } else { |
|
| 462 | + $s.='<tr>'."\n"; |
|
| 463 | + $s.='<td width="40%" valign="top">'."\n".'<b>'.$cpt2.'</b>. '.$answer."\n</td>\n"; |
|
| 464 | + $s.='<td width="20%" align="center"> <select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">'; |
|
| 465 | + $s.=' <option value="0">--</option>'; |
|
| 466 | + // fills the list-box |
|
| 467 | + foreach($Select as $key=>$val) |
|
| 468 | + { |
|
| 469 | + $s.='<option value="'.$key.'">'.$val['Lettre'].'</option>'; |
|
| 470 | + } // end foreach() |
|
| 471 | + |
|
| 472 | + $s.='</select> </td>'."\n"; |
|
| 473 | + $s.='<td width="40%" valign="top">'; |
|
| 474 | + if(isset($Select[$cpt2])) $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
| 475 | + else $s.=' '; |
|
| 476 | + $s.="</td>\n</tr>\n"; |
|
| 477 | + |
|
| 478 | + $jstmpc .= '['.$answerCorrect.','.$cpt2.'],'; |
|
| 479 | + |
|
| 480 | + $my_weight=explode('@',$weight); |
|
| 481 | + if (count($my_weight)==2) { |
|
| 482 | + $weight=$my_weight[0]; |
|
| 483 | + } else { |
|
| 484 | + $weight=$my_weight[0]; |
|
| 485 | + } |
|
| 486 | + $jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n"; |
|
| 487 | + $cpt2++; |
|
| 488 | + |
|
| 489 | + // if the left side of the "matching" has been completely shown |
|
| 490 | + if($answerId == $nbrAnswers) |
|
| 491 | + { |
|
| 492 | + // if there remain answers to be shown on the right side |
|
| 493 | + while(isset($Select[$cpt2])) |
|
| 494 | + { |
|
| 495 | + //$s.='<tr>'."\n"; |
|
| 496 | + //$s.='<td colspan="2">'."\n"; |
|
| 497 | + //$s.='<table border="0" cellpadding="0" cellspacing="0" width="100%">'."\n"; |
|
| 498 | + $s.='<tr>'."\n"; |
|
| 499 | + $s.='<td width="60%" colspan="2"> </td>'."\n"; |
|
| 500 | + $s.='<td width="40%" valign="top">'; |
|
| 501 | + $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
| 502 | + $s.="</td>\n</tr>\n"; |
|
| 503 | + $cpt2++; |
|
| 504 | + } // end while() |
|
| 505 | + } // end if() |
|
| 506 | + } |
|
| 507 | + } |
|
| 508 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
| 509 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
| 510 | + $js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n"; |
|
| 511 | + $js .= $jstmpw; |
|
| 512 | + $html .= $s; |
|
| 513 | + $html .= '</table></td></tr>' . "\n"; |
|
| 514 | 514 | |
| 515 | 515 | return array($js,$html); |
| 516 | 516 | } |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | */ |
| 523 | 523 | class ScormAnswerFree extends Answer |
| 524 | 524 | { |
| 525 | - /** |
|
| 525 | + /** |
|
| 526 | 526 | * Export the text with missing words. |
| 527 | 527 | * |
| 528 | 528 | * As a side effect, it stores two lists in the class : |
@@ -531,67 +531,67 @@ discard block |
||
| 531 | 531 | */ |
| 532 | 532 | function export() |
| 533 | 533 | { |
| 534 | - //$qId = $this->questionJSId; |
|
| 535 | - $js = ''; |
|
| 536 | - /*$html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
| 534 | + //$qId = $this->questionJSId; |
|
| 535 | + $js = ''; |
|
| 536 | + /*$html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
| 537 | 537 | // some javascript must be added for that kind of questions |
| 538 | 538 | $html .= '<tr><td> |
| 539 | 539 | <textarea name="question_'.$qId.'_free" id="question_'.$qId.'_free" rows="20" cols="100"></textarea> |
| 540 | 540 | </td> |
| 541 | 541 | </tr>'; |
| 542 | 542 | $html .= '</table></td></tr>';*/ |
| 543 | - // currently the free answers cannot be displayed, so ignore the textarea |
|
| 544 | - $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
| 545 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 546 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 547 | - $js .= 'questions_types['.$this->questionJSId.'] = \'free\';'."\n"; |
|
| 548 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 549 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
| 550 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
| 551 | - $js .= $jstmpw; |
|
| 543 | + // currently the free answers cannot be displayed, so ignore the textarea |
|
| 544 | + $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
| 545 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 546 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 547 | + $js .= 'questions_types['.$this->questionJSId.'] = \'free\';'."\n"; |
|
| 548 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 549 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
| 550 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
| 551 | + $js .= $jstmpw; |
|
| 552 | 552 | return array($js,$html); |
| 553 | 553 | } |
| 554 | 554 | } |
| 555 | 555 | /** |
| 556 | - * This class handles the SCORM export of hotpot questions |
|
| 557 | - * @package chamilo.exercise.scorm |
|
| 558 | - */ |
|
| 556 | + * This class handles the SCORM export of hotpot questions |
|
| 557 | + * @package chamilo.exercise.scorm |
|
| 558 | + */ |
|
| 559 | 559 | class ScormAnswerHotspot extends Answer |
| 560 | 560 | { |
| 561 | - /** |
|
| 562 | - * Returns the javascript code that goes with HotSpot exercises |
|
| 563 | - * @return string The JavaScript code |
|
| 564 | - */ |
|
| 565 | - function get_js_header() |
|
| 566 | - { |
|
| 567 | - if ($this->standalone) { |
|
| 568 | - $header = '<script type="text/javascript" language="javascript">'; |
|
| 569 | - $header .= file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js'); |
|
| 570 | - $header .= '</script>'; |
|
| 571 | - //because this header closes so many times the <script> tag, we have to reopen our own |
|
| 572 | - $header .= '<script type="text/javascript" language="javascript">'."\n"; |
|
| 573 | - $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 574 | - $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 575 | - $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
| 576 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 577 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
| 578 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
| 579 | - $header .= $jstmpw; |
|
| 580 | - } |
|
| 581 | - else |
|
| 582 | - { |
|
| 583 | - $header = ''; |
|
| 584 | - $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 585 | - $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 586 | - $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
| 587 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 588 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
| 589 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'."\n"; |
|
| 590 | - $header .= $jstmpw; |
|
| 591 | - } |
|
| 592 | - return $header; |
|
| 593 | - } |
|
| 594 | - /** |
|
| 561 | + /** |
|
| 562 | + * Returns the javascript code that goes with HotSpot exercises |
|
| 563 | + * @return string The JavaScript code |
|
| 564 | + */ |
|
| 565 | + function get_js_header() |
|
| 566 | + { |
|
| 567 | + if ($this->standalone) { |
|
| 568 | + $header = '<script type="text/javascript" language="javascript">'; |
|
| 569 | + $header .= file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js'); |
|
| 570 | + $header .= '</script>'; |
|
| 571 | + //because this header closes so many times the <script> tag, we have to reopen our own |
|
| 572 | + $header .= '<script type="text/javascript" language="javascript">'."\n"; |
|
| 573 | + $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 574 | + $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 575 | + $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
| 576 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 577 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
| 578 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
| 579 | + $header .= $jstmpw; |
|
| 580 | + } |
|
| 581 | + else |
|
| 582 | + { |
|
| 583 | + $header = ''; |
|
| 584 | + $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 585 | + $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 586 | + $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
| 587 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
| 588 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
| 589 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'."\n"; |
|
| 590 | + $header .= $jstmpw; |
|
| 591 | + } |
|
| 592 | + return $header; |
|
| 593 | + } |
|
| 594 | + /** |
|
| 595 | 595 | * Export the text with missing words. |
| 596 | 596 | * |
| 597 | 597 | * As a side effect, it stores two lists in the class : |
@@ -600,22 +600,22 @@ discard block |
||
| 600 | 600 | */ |
| 601 | 601 | function export() |
| 602 | 602 | { |
| 603 | - $js = $this->get_js_header(); |
|
| 604 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
| 605 | - // some javascript must be added for that kind of questions |
|
| 606 | - $html .= ''; |
|
| 603 | + $js = $this->get_js_header(); |
|
| 604 | + $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
| 605 | + // some javascript must be added for that kind of questions |
|
| 606 | + $html .= ''; |
|
| 607 | 607 | |
| 608 | - // Get the answers, make a list |
|
| 609 | - $nbrAnswers=$this->selectNbrAnswers(); |
|
| 608 | + // Get the answers, make a list |
|
| 609 | + $nbrAnswers=$this->selectNbrAnswers(); |
|
| 610 | 610 | |
| 611 | - $answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>'; |
|
| 612 | - for($answerId=1;$answerId <= $nbrAnswers;$answerId++) |
|
| 613 | - { |
|
| 614 | - $answer_list .= '<li>'.$this->selectAnswer($answerId).'</li>'; |
|
| 615 | - } |
|
| 616 | - $answer_list .= '</ol></div>'; |
|
| 611 | + $answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>'; |
|
| 612 | + for($answerId=1;$answerId <= $nbrAnswers;$answerId++) |
|
| 613 | + { |
|
| 614 | + $answer_list .= '<li>'.$this->selectAnswer($answerId).'</li>'; |
|
| 615 | + } |
|
| 616 | + $answer_list .= '</ol></div>'; |
|
| 617 | 617 | |
| 618 | - /* |
|
| 618 | + /* |
|
| 619 | 619 | if(!$onlyAnswers) |
| 620 | 620 | { |
| 621 | 621 | $s="<tr> |
@@ -633,11 +633,11 @@ discard block |
||
| 633 | 633 | } |
| 634 | 634 | */ |
| 635 | 635 | |
| 636 | - //$canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1'); |
|
| 637 | - $canClick = true; |
|
| 638 | - //$tes = isset($_GET['modifyAnswers']) ? '0' : '1'; |
|
| 639 | - //echo $tes; |
|
| 640 | - $relPath = api_get_path(REL_PATH); |
|
| 636 | + //$canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1'); |
|
| 637 | + $canClick = true; |
|
| 638 | + //$tes = isset($_GET['modifyAnswers']) ? '0' : '1'; |
|
| 639 | + //echo $tes; |
|
| 640 | + $relPath = api_get_path(REL_PATH); |
|
| 641 | 641 | $html .= <<<HTML |
| 642 | 642 | <tr> |
| 643 | 643 | <td> |
@@ -658,10 +658,10 @@ discard block |
||
| 658 | 658 | </td> |
| 659 | 659 | <tr> |
| 660 | 660 | HTML; |
| 661 | - $html .= '</table></td></tr>' . "\n"; |
|
| 661 | + $html .= '</table></td></tr>' . "\n"; |
|
| 662 | 662 | |
| 663 | - // currently the free answers cannot be displayed, so ignore the textarea |
|
| 664 | - $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
| 663 | + // currently the free answers cannot be displayed, so ignore the textarea |
|
| 664 | + $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
| 665 | 665 | return array($js,$html); |
| 666 | 666 | } |
| 667 | 667 | } |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | * @param null $feedback_type |
| 416 | 416 | * @param null $counter |
| 417 | 417 | * @param null $score |
| 418 | - * @return null|string |
|
| 418 | + * @return string |
|
| 419 | 419 | */ |
| 420 | 420 | public function return_header($feedback_type = null, $counter = null, $score = null) |
| 421 | 421 | { |
@@ -429,15 +429,16 @@ discard block |
||
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | /** |
| 432 | - * @param $separatorStartRegexp |
|
| 433 | - * @param $separatorEndRegexp |
|
| 434 | - * @param $correctItemRegexp |
|
| 435 | - * @param $questionId |
|
| 432 | + * @param string $separatorStartRegexp |
|
| 433 | + * @param string $separatorEndRegexp |
|
| 434 | + * @param string $correctItemRegexp |
|
| 435 | + * @param integer $questionId |
|
| 436 | 436 | * @param $correctItem |
| 437 | 437 | * @param $attributes |
| 438 | - * @param $answer |
|
| 438 | + * @param string $answer |
|
| 439 | 439 | * @param $listAnswersInfo |
| 440 | - * @param $displayForStudent |
|
| 440 | + * @param boolean $displayForStudent |
|
| 441 | + * @param integer $inBlankNumber |
|
| 441 | 442 | * @return string |
| 442 | 443 | */ |
| 443 | 444 | public static function getFillTheBlankHtml( |
@@ -736,11 +737,11 @@ discard block |
||
| 736 | 737 | * 0 : student answer is correct |
| 737 | 738 | * >0 : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0) |
| 738 | 739 | * |
| 739 | - * @param $testId |
|
| 740 | - * @param $questionId |
|
| 740 | + * @param integer $testId |
|
| 741 | + * @param integer $questionId |
|
| 741 | 742 | * @param $studentsIdList |
| 742 | - * @param $startDate |
|
| 743 | - * @param $endDate |
|
| 743 | + * @param string $startDate |
|
| 744 | + * @param string $endDate |
|
| 744 | 745 | * @param bool $useLastAnswerredAttempt |
| 745 | 746 | * @return array |
| 746 | 747 | * ( |
@@ -917,7 +918,7 @@ discard block |
||
| 917 | 918 | * return $text protected for use in regexp |
| 918 | 919 | * @param string $text |
| 919 | 920 | * |
| 920 | - * @return mixed |
|
| 921 | + * @return string |
|
| 921 | 922 | */ |
| 922 | 923 | public static function getRegexpProtected($text) |
| 923 | 924 | { |
@@ -975,7 +976,7 @@ discard block |
||
| 975 | 976 | * return the start separator for answer |
| 976 | 977 | * @param string $number |
| 977 | 978 | * |
| 978 | - * @return mixed |
|
| 979 | + * @return string |
|
| 979 | 980 | */ |
| 980 | 981 | public static function getStartSeparator($number) |
| 981 | 982 | { |
@@ -988,7 +989,7 @@ discard block |
||
| 988 | 989 | * return the end separator for answer |
| 989 | 990 | * @param string $number |
| 990 | 991 | * |
| 991 | - * @return mixed |
|
| 992 | + * @return string |
|
| 992 | 993 | */ |
| 993 | 994 | public static function getEndSeparator($number) |
| 994 | 995 | { |
@@ -729,43 +729,43 @@ discard block |
||
| 729 | 729 | } |
| 730 | 730 | |
| 731 | 731 | /** |
| 732 | - * Return an array of student state answers for fill the blank questions |
|
| 733 | - * for each students that answered the question |
|
| 734 | - * -2 : didn't answer |
|
| 735 | - * -1 : student answer is wrong |
|
| 736 | - * 0 : student answer is correct |
|
| 737 | - * >0 : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0) |
|
| 738 | - * |
|
| 739 | - * @param $testId |
|
| 740 | - * @param $questionId |
|
| 741 | - * @param $studentsIdList |
|
| 742 | - * @param $startDate |
|
| 743 | - * @param $endDate |
|
| 744 | - * @param bool $useLastAnswerredAttempt |
|
| 745 | - * @return array |
|
| 746 | - * ( |
|
| 747 | - * [student_id] => Array |
|
| 748 | - * ( |
|
| 749 | - * [first fill the blank for question] => -1 |
|
| 750 | - * [second fill the blank for question] => 2 |
|
| 751 | - * [third fill the blank for question] => -1 |
|
| 752 | - * ) |
|
| 753 | - * ) |
|
| 754 | - */ |
|
| 732 | + * Return an array of student state answers for fill the blank questions |
|
| 733 | + * for each students that answered the question |
|
| 734 | + * -2 : didn't answer |
|
| 735 | + * -1 : student answer is wrong |
|
| 736 | + * 0 : student answer is correct |
|
| 737 | + * >0 : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0) |
|
| 738 | + * |
|
| 739 | + * @param $testId |
|
| 740 | + * @param $questionId |
|
| 741 | + * @param $studentsIdList |
|
| 742 | + * @param $startDate |
|
| 743 | + * @param $endDate |
|
| 744 | + * @param bool $useLastAnswerredAttempt |
|
| 745 | + * @return array |
|
| 746 | + * ( |
|
| 747 | + * [student_id] => Array |
|
| 748 | + * ( |
|
| 749 | + * [first fill the blank for question] => -1 |
|
| 750 | + * [second fill the blank for question] => 2 |
|
| 751 | + * [third fill the blank for question] => -1 |
|
| 752 | + * ) |
|
| 753 | + * ) |
|
| 754 | + */ |
|
| 755 | 755 | public static function getFillTheBlankTabResult($testId, $questionId, $studentsIdList, $startDate, $endDate, $useLastAnswerredAttempt = true) { |
| 756 | 756 | |
| 757 | - $tblTrackEAttempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); |
|
| 758 | - $tblTrackEExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); |
|
| 759 | - $courseId = api_get_course_int_id(); |
|
| 757 | + $tblTrackEAttempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); |
|
| 758 | + $tblTrackEExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); |
|
| 759 | + $courseId = api_get_course_int_id(); |
|
| 760 | 760 | |
| 761 | - require_once api_get_path(SYS_PATH).'main/exercice/fill_blanks.class.php'; |
|
| 761 | + require_once api_get_path(SYS_PATH).'main/exercice/fill_blanks.class.php'; |
|
| 762 | 762 | |
| 763 | - // request to have all the answers of student for this question |
|
| 764 | - // student may have doing it several time |
|
| 765 | - // student may have not answered the bracket id, in this case, is result of the answer is empty |
|
| 763 | + // request to have all the answers of student for this question |
|
| 764 | + // student may have doing it several time |
|
| 765 | + // student may have not answered the bracket id, in this case, is result of the answer is empty |
|
| 766 | 766 | |
| 767 | - // we got the less recent attempt first |
|
| 768 | - $sql = ' |
|
| 767 | + // we got the less recent attempt first |
|
| 768 | + $sql = ' |
|
| 769 | 769 | SELECT * FROM '.$tblTrackEAttempt.' tea |
| 770 | 770 | |
| 771 | 771 | LEFT JOIN '.$tblTrackEExercise.' tee |
@@ -781,49 +781,49 @@ discard block |
||
| 781 | 781 | ORDER BY user_id, tea.exe_id; |
| 782 | 782 | '; |
| 783 | 783 | |
| 784 | - $res = Database::query($sql); |
|
| 785 | - $tabUserResult = array(); |
|
| 786 | - $bracketNumber = 0; |
|
| 787 | - // foreach attempts for all students starting with his older attempt |
|
| 788 | - while ($data = Database::fetch_array($res)) { |
|
| 789 | - $tabAnswer = FillBlanks::getAnswerInfo($data['answer'], true); |
|
| 784 | + $res = Database::query($sql); |
|
| 785 | + $tabUserResult = array(); |
|
| 786 | + $bracketNumber = 0; |
|
| 787 | + // foreach attempts for all students starting with his older attempt |
|
| 788 | + while ($data = Database::fetch_array($res)) { |
|
| 789 | + $tabAnswer = FillBlanks::getAnswerInfo($data['answer'], true); |
|
| 790 | 790 | |
| 791 | - // for each bracket to find in this question |
|
| 792 | - foreach ($tabAnswer['studentanswer'] as $bracketNumber => $studentAnswer) { |
|
| 791 | + // for each bracket to find in this question |
|
| 792 | + foreach ($tabAnswer['studentanswer'] as $bracketNumber => $studentAnswer) { |
|
| 793 | 793 | |
| 794 | - if ($tabAnswer['studentanswer'][$bracketNumber] != '') { |
|
| 795 | - // student has answered this bracket, cool |
|
| 796 | - switch (FillBlanks::getFillTheBlankAnswerType($tabAnswer['tabwords'][$bracketNumber])) { |
|
| 797 | - case self::FILL_THE_BLANK_MENU : |
|
| 794 | + if ($tabAnswer['studentanswer'][$bracketNumber] != '') { |
|
| 795 | + // student has answered this bracket, cool |
|
| 796 | + switch (FillBlanks::getFillTheBlankAnswerType($tabAnswer['tabwords'][$bracketNumber])) { |
|
| 797 | + case self::FILL_THE_BLANK_MENU : |
|
| 798 | 798 | // get the indice of the choosen answer in the menu |
| 799 | 799 | // we know that the right answer is the first entry of the menu, ie 0 |
| 800 | 800 | // (remember, menu entries are shuffled when taking the test) |
| 801 | 801 | $tabUserResult[$data['user_id']][$bracketNumber] = FillBlanks::getFillTheBlankMenuAnswerNum($tabAnswer['tabwords'][$bracketNumber], $tabAnswer['studentanswer'][$bracketNumber]); |
| 802 | - break; |
|
| 803 | - default : |
|
| 802 | + break; |
|
| 803 | + default : |
|
| 804 | 804 | if (FillBlanks::isGoodStudentAnswer($tabAnswer['studentanswer'][$bracketNumber], $tabAnswer['tabwords'][$bracketNumber])) { |
| 805 | - $tabUserResult[$data['user_id']][$bracketNumber] = 0; // right answer |
|
| 806 | - } else { |
|
| 807 | - $tabUserResult[$data['user_id']][$bracketNumber] = -1; // wrong answer |
|
| 808 | - } |
|
| 809 | - } |
|
| 810 | - } else { |
|
| 811 | - // student didn't answer this bracket |
|
| 812 | - if ($useLastAnswerredAttempt) { |
|
| 813 | - // if we take into account the last answered attempt |
|
| 814 | - if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) { |
|
| 815 | - $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
| 816 | - } |
|
| 817 | - } else { |
|
| 818 | - // we take the last attempt, even if the student answer the question before |
|
| 819 | - $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
| 820 | - } |
|
| 821 | - } |
|
| 822 | - } |
|
| 823 | - |
|
| 824 | - |
|
| 825 | - } |
|
| 826 | - return $tabUserResult; |
|
| 805 | + $tabUserResult[$data['user_id']][$bracketNumber] = 0; // right answer |
|
| 806 | + } else { |
|
| 807 | + $tabUserResult[$data['user_id']][$bracketNumber] = -1; // wrong answer |
|
| 808 | + } |
|
| 809 | + } |
|
| 810 | + } else { |
|
| 811 | + // student didn't answer this bracket |
|
| 812 | + if ($useLastAnswerredAttempt) { |
|
| 813 | + // if we take into account the last answered attempt |
|
| 814 | + if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) { |
|
| 815 | + $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
| 816 | + } |
|
| 817 | + } else { |
|
| 818 | + // we take the last attempt, even if the student answer the question before |
|
| 819 | + $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
| 820 | + } |
|
| 821 | + } |
|
| 822 | + } |
|
| 823 | + |
|
| 824 | + |
|
| 825 | + } |
|
| 826 | + return $tabUserResult; |
|
| 827 | 827 | } |
| 828 | 828 | |
| 829 | 829 | |
@@ -260,10 +260,10 @@ discard block |
||
| 260 | 260 | ['id' => 'answer', 'onkeyup' => "javascript: updateBlanks(this);"], |
| 261 | 261 | array('ToolbarSet' => 'TestQuestionDescription') |
| 262 | 262 | ); |
| 263 | - $form->addRule('answer',get_lang('GiveText'),'required'); |
|
| 263 | + $form->addRule('answer', get_lang('GiveText'), 'required'); |
|
| 264 | 264 | |
| 265 | 265 | //added multiple answers |
| 266 | - $form->addElement('checkbox','multiple_answer','', get_lang('FillInBlankSwitchable')); |
|
| 266 | + $form->addElement('checkbox', 'multiple_answer', '', get_lang('FillInBlankSwitchable')); |
|
| 267 | 267 | $form->addElement( |
| 268 | 268 | 'select', |
| 269 | 269 | 'select_separator', |
@@ -276,11 +276,11 @@ discard block |
||
| 276 | 276 | null, |
| 277 | 277 | '<input type="button" onclick="updateBlanks()" value="'.get_lang('RefreshBlanks').'" class="btn btn-default" />' |
| 278 | 278 | ); |
| 279 | - $form->addElement('html','<div id="blanks_weighting"></div>'); |
|
| 279 | + $form->addElement('html', '<div id="blanks_weighting"></div>'); |
|
| 280 | 280 | |
| 281 | 281 | global $text; |
| 282 | 282 | // setting the save button here and not in the question class.php |
| 283 | - $form->addElement('html','<div id="defineoneblank" style="color:#D04A66; margin-left:160px">'.get_lang('DefineBlanks').'</div>'); |
|
| 283 | + $form->addElement('html', '<div id="defineoneblank" style="color:#D04A66; margin-left:160px">'.get_lang('DefineBlanks').'</div>'); |
|
| 284 | 284 | $form->addButtonSave($text, 'submitQuestion'); |
| 285 | 285 | |
| 286 | 286 | if (!empty($this->id)) { |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | // remove spaces at the beginning and the end of text in square brackets |
| 321 | 321 | $answer = preg_replace_callback( |
| 322 | 322 | "/".$blankStartSeparatorRegexp."[^]]+".$blankEndSeparatorRegexp."/", |
| 323 | - function ($matches) use ($blankStartSeparator, $blankEndSeparator) { |
|
| 323 | + function($matches) use ($blankStartSeparator, $blankEndSeparator) { |
|
| 324 | 324 | $matchingResult = $matches[0]; |
| 325 | 325 | $matchingResult = trim($matchingResult, $blankStartSeparator); |
| 326 | 326 | $matchingResult = trim($matchingResult, $blankEndSeparator); |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | if ($nb > 0) { |
| 366 | 366 | $answer .= '::'; |
| 367 | 367 | // weighting |
| 368 | - for ($i=0; $i < $nb; ++$i) { |
|
| 368 | + for ($i = 0; $i < $nb; ++$i) { |
|
| 369 | 369 | // enter the weighting of word $i |
| 370 | 370 | $answer .= $form->getSubmitValue('weighting['.$i.']'); |
| 371 | 371 | // not the last word, add "," |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | |
| 379 | 379 | // input width |
| 380 | 380 | $answer .= ":"; |
| 381 | - for ($i=0; $i < $nb; ++$i) { |
|
| 381 | + for ($i = 0; $i < $nb; ++$i) { |
|
| 382 | 382 | // enter the width of input for word $i |
| 383 | 383 | $answer .= $form->getSubmitValue('sizeofinput['.$i.']'); |
| 384 | 384 | // not the last word, add "," |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | |
| 404 | 404 | // Allow answers order switches |
| 405 | 405 | $is_multiple = $form -> getSubmitValue('multiple_answer'); |
| 406 | - $answer.= '@'.$is_multiple; |
|
| 406 | + $answer .= '@'.$is_multiple; |
|
| 407 | 407 | |
| 408 | 408 | $this->save(); |
| 409 | 409 | $objAnswer = new Answer($this->id); |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | public function return_header($feedback_type = null, $counter = null, $score = null) |
| 421 | 421 | { |
| 422 | 422 | $header = parent::return_header($feedback_type, $counter, $score); |
| 423 | - $header .= '<table class="'.$this->question_table_class .'"> |
|
| 423 | + $header .= '<table class="'.$this->question_table_class.'"> |
|
| 424 | 424 | <tr> |
| 425 | 425 | <th>'.get_lang("Answer").'</th> |
| 426 | 426 | </tr>'; |
@@ -464,13 +464,13 @@ discard block |
||
| 464 | 464 | // if display for student, shuffle the correct answer menu |
| 465 | 465 | $listMenu = self::getFillTheBlankMenuAnswers($inTeacherSolution, $displayForStudent); |
| 466 | 466 | $result .= '<select name="choice['.$questionId.'][]">'; |
| 467 | - for ($k=0; $k < count($listMenu); $k++) { |
|
| 467 | + for ($k = 0; $k < count($listMenu); $k++) { |
|
| 468 | 468 | $selected = ""; |
| 469 | 469 | if ($correctItem == $listMenu[$k]) { |
| 470 | 470 | $selected = " selected=selected "; |
| 471 | 471 | } |
| 472 | 472 | // if in teacher view, display the first item by default, which is the right answer |
| 473 | - if ($k==0 && !$displayForStudent) { |
|
| 473 | + if ($k == 0 && !$displayForStudent) { |
|
| 474 | 474 | $selected = " selected=selected "; |
| 475 | 475 | } |
| 476 | 476 | $optionMenu .= '<option '.$selected.' value="'.$listMenu[$k].'">'.$listMenu[$k].'</option>'; |
@@ -642,10 +642,10 @@ discard block |
||
| 642 | 642 | if (count($listDetails) < 3) { |
| 643 | 643 | $listWeightings = explode(',', $listDetails[0]); |
| 644 | 644 | $listSizeOfInput = array(); |
| 645 | - for ($i=0; $i < count($listWeightings); $i++) { |
|
| 645 | + for ($i = 0; $i < count($listWeightings); $i++) { |
|
| 646 | 646 | $listSizeOfInput[] = 200; |
| 647 | 647 | } |
| 648 | - $blankSeparatorNumber = 0; // 0 is [...] |
|
| 648 | + $blankSeparatorNumber = 0; // 0 is [...] |
|
| 649 | 649 | } else { |
| 650 | 650 | $listWeightings = explode(',', $listDetails[0]); |
| 651 | 651 | $listSizeOfInput = explode(',', $listDetails[1]); |
@@ -677,9 +677,9 @@ discard block |
||
| 677 | 677 | // remove [ and ] in string |
| 678 | 678 | array_walk( |
| 679 | 679 | $listWords[0], |
| 680 | - function (&$value, $key, $tabBlankChar) { |
|
| 680 | + function(&$value, $key, $tabBlankChar) { |
|
| 681 | 681 | $trimChars = ""; |
| 682 | - for ($i=0; $i < count($tabBlankChar); $i++) { |
|
| 682 | + for ($i = 0; $i < count($tabBlankChar); $i++) { |
|
| 683 | 683 | $trimChars .= $tabBlankChar[$i]; |
| 684 | 684 | } |
| 685 | 685 | $value = trim($value, $trimChars); |
@@ -699,18 +699,18 @@ discard block |
||
| 699 | 699 | // if student answer, the second [] is the student answer, |
| 700 | 700 | // the third is if student scored or not |
| 701 | 701 | $listBrackets = array(); |
| 702 | - $listWords = array(); |
|
| 702 | + $listWords = array(); |
|
| 703 | 703 | |
| 704 | 704 | if ($isStudentAnswer) { |
| 705 | - for ($i=0; $i < count($listAnswerResults['tabwords']); $i++) { |
|
| 705 | + for ($i = 0; $i < count($listAnswerResults['tabwords']); $i++) { |
|
| 706 | 706 | $listBrackets[] = $listAnswerResults['tabwordsbracket'][$i]; |
| 707 | 707 | $listWords[] = $listAnswerResults['tabwords'][$i]; |
| 708 | - if ($i+1 < count($listAnswerResults['tabwords'])) { |
|
| 708 | + if ($i + 1 < count($listAnswerResults['tabwords'])) { |
|
| 709 | 709 | // should always be |
| 710 | 710 | $i++; |
| 711 | 711 | } |
| 712 | 712 | $listAnswerResults['studentanswer'][] = $listAnswerResults['tabwords'][$i]; |
| 713 | - if ($i+1 < count($listAnswerResults['tabwords'])) { |
|
| 713 | + if ($i + 1 < count($listAnswerResults['tabwords'])) { |
|
| 714 | 714 | // should always be |
| 715 | 715 | $i++; |
| 716 | 716 | } |
@@ -802,9 +802,9 @@ discard block |
||
| 802 | 802 | break; |
| 803 | 803 | default : |
| 804 | 804 | if (FillBlanks::isGoodStudentAnswer($tabAnswer['studentanswer'][$bracketNumber], $tabAnswer['tabwords'][$bracketNumber])) { |
| 805 | - $tabUserResult[$data['user_id']][$bracketNumber] = 0; // right answer |
|
| 805 | + $tabUserResult[$data['user_id']][$bracketNumber] = 0; // right answer |
|
| 806 | 806 | } else { |
| 807 | - $tabUserResult[$data['user_id']][$bracketNumber] = -1; // wrong answer |
|
| 807 | + $tabUserResult[$data['user_id']][$bracketNumber] = -1; // wrong answer |
|
| 808 | 808 | } |
| 809 | 809 | } |
| 810 | 810 | } else { |
@@ -812,11 +812,11 @@ discard block |
||
| 812 | 812 | if ($useLastAnswerredAttempt) { |
| 813 | 813 | // if we take into account the last answered attempt |
| 814 | 814 | if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) { |
| 815 | - $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
| 815 | + $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
| 816 | 816 | } |
| 817 | 817 | } else { |
| 818 | 818 | // we take the last attempt, even if the student answer the question before |
| 819 | - $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
| 819 | + $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
| 820 | 820 | } |
| 821 | 821 | } |
| 822 | 822 | } |
@@ -837,10 +837,10 @@ discard block |
||
| 837 | 837 | { |
| 838 | 838 | $outRes = 0; |
| 839 | 839 | // for each student in group |
| 840 | - foreach($resultList as $userId => $tabValue) { |
|
| 840 | + foreach ($resultList as $userId => $tabValue) { |
|
| 841 | 841 | $trouve = false; |
| 842 | 842 | // for each bracket, if student has at leat one answer ( choice > -2) then he pass the question |
| 843 | - foreach($tabValue as $i => $choice) { |
|
| 843 | + foreach ($tabValue as $i => $choice) { |
|
| 844 | 844 | if ($choice > -2 && !$trouve) { |
| 845 | 845 | $outRes++; |
| 846 | 846 | $trouve = true; |
@@ -862,7 +862,7 @@ discard block |
||
| 862 | 862 | $separatorEnd = $listWithStudentAnswer['blankseparatorend']; |
| 863 | 863 | // lets rebuild the sentence with [correct answer][student answer][answer is correct] |
| 864 | 864 | $result = ""; |
| 865 | - for ($i=0; $i < count($listWithStudentAnswer['commonwords']) - 1; $i++) { |
|
| 865 | + for ($i = 0; $i < count($listWithStudentAnswer['commonwords']) - 1; $i++) { |
|
| 866 | 866 | $result .= $listWithStudentAnswer['commonwords'][$i]; |
| 867 | 867 | $result .= $listWithStudentAnswer['tabwordsbracket'][$i]; |
| 868 | 868 | $result .= $separatorStart.$listWithStudentAnswer['studentanswer'][$i].$separatorEnd; |
@@ -944,7 +944,7 @@ discard block |
||
| 944 | 944 | ")", |
| 945 | 945 | ]; |
| 946 | 946 | $result = $text; |
| 947 | - for ($i=0; $i < count($listRegexpCharacters); $i++) { |
|
| 947 | + for ($i = 0; $i < count($listRegexpCharacters); $i++) { |
|
| 948 | 948 | $result = str_replace($listRegexpCharacters[$i], "\\".$listRegexpCharacters[$i], $result); |
| 949 | 949 | } |
| 950 | 950 | |
@@ -1006,7 +1006,7 @@ discard block |
||
| 1006 | 1006 | { |
| 1007 | 1007 | $listResults = array(); |
| 1008 | 1008 | $fillBlanksAllowedSeparator = self::getAllowedSeparator(); |
| 1009 | - for ($i=0; $i < count($fillBlanksAllowedSeparator); $i++) { |
|
| 1009 | + for ($i = 0; $i < count($fillBlanksAllowedSeparator); $i++) { |
|
| 1010 | 1010 | $listResults[] = $fillBlanksAllowedSeparator[$i][0]."...".$fillBlanksAllowedSeparator[$i][1]; |
| 1011 | 1011 | } |
| 1012 | 1012 | |
@@ -1024,7 +1024,7 @@ discard block |
||
| 1024 | 1024 | { |
| 1025 | 1025 | $listSeparators = self::getAllowedSeparator(); |
| 1026 | 1026 | $result = 0; |
| 1027 | - for ($i=0; $i < count($listSeparators); $i++) { |
|
| 1027 | + for ($i = 0; $i < count($listSeparators); $i++) { |
|
| 1028 | 1028 | if ($listSeparators[$i][0] == $startSeparator && |
| 1029 | 1029 | $listSeparators[$i][1] == $endSeparator |
| 1030 | 1030 | ) { |
@@ -1049,7 +1049,7 @@ discard block |
||
| 1049 | 1049 | |
| 1050 | 1050 | // rebuild the answer with good HTML style |
| 1051 | 1051 | // this is the student answer, right or wrong |
| 1052 | - for ($i=0; $i < count($listStudentAnswerInfo['studentanswer']); $i++) { |
|
| 1052 | + for ($i = 0; $i < count($listStudentAnswerInfo['studentanswer']); $i++) { |
|
| 1053 | 1053 | if ($listStudentAnswerInfo['studentscore'][$i] == 1) { |
| 1054 | 1054 | $listStudentAnswerInfo['studentanswer'][$i] = self::getHtmlRightAnswer( |
| 1055 | 1055 | $listStudentAnswerInfo['studentanswer'][$i], |
@@ -1067,7 +1067,7 @@ discard block |
||
| 1067 | 1067 | |
| 1068 | 1068 | |
| 1069 | 1069 | // rebuild the sentence with student answer inserted |
| 1070 | - for ($i=0; $i < count($listStudentAnswerInfo['commonwords']); $i++) { |
|
| 1070 | + for ($i = 0; $i < count($listStudentAnswerInfo['commonwords']); $i++) { |
|
| 1071 | 1071 | $result .= isset($listStudentAnswerInfo['commonwords'][$i]) ? $listStudentAnswerInfo['commonwords'][$i] : ''; |
| 1072 | 1072 | $result .= isset($listStudentAnswerInfo['studentanswer'][$i]) ? $listStudentAnswerInfo['studentanswer'][$i] : ''; |
| 1073 | 1073 | } |
@@ -1100,7 +1100,7 @@ discard block |
||
| 1100 | 1100 | $listPossibleAnswers = FillBlanks::getFillTheBlankMenuAnswers($correct, false); |
| 1101 | 1101 | $correctAnswerHtml .= "<span style='color: green'>".$listPossibleAnswers[0]."</span>"; |
| 1102 | 1102 | $correctAnswerHtml .= " <span style='font-weight:normal'>("; |
| 1103 | - for ($i=1; $i < count($listPossibleAnswers); $i++) { |
|
| 1103 | + for ($i = 1; $i < count($listPossibleAnswers); $i++) { |
|
| 1104 | 1104 | $correctAnswerHtml .= $listPossibleAnswers[$i]; |
| 1105 | 1105 | if ($i != count($listPossibleAnswers) - 1) { |
| 1106 | 1106 | $correctAnswerHtml .= " | "; |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * Sets the comment in the database for a particular path. |
| 95 | 95 | * @param string File path |
| 96 | 96 | * @param string Comment to set |
| 97 | - * @return string Result of the database operation (Database::query will output some message directly on error anyway) |
|
| 97 | + * @return Doctrine\DBAL\Driver\Statement|null Result of the database operation (Database::query will output some message directly on error anyway) |
|
| 98 | 98 | */ |
| 99 | 99 | function SetComment($path, $comment) |
| 100 | 100 | { |
@@ -112,6 +112,7 @@ discard block |
||
| 112 | 112 | /** |
| 113 | 113 | * Reads the file contents into a string. |
| 114 | 114 | * @param string Urlencoded path |
| 115 | + * @param string $full_file_path |
|
| 115 | 116 | * @return string The file contents or false on security error |
| 116 | 117 | */ |
| 117 | 118 | function ReadFileCont($full_file_path) |
@@ -257,6 +258,7 @@ discard block |
||
| 257 | 258 | * Searches for a node in the given array. |
| 258 | 259 | * @param reference Reference to the array to search |
| 259 | 260 | * @param string Node we are looking for in the array |
| 261 | + * @param string $node |
|
| 260 | 262 | * @return mixed Node name or false if not found |
| 261 | 263 | */ |
| 262 | 264 | function myarraysearch(&$array, $node) |
@@ -316,6 +318,8 @@ discard block |
||
| 316 | 318 | * Fills the folder name up to a certain length with "0". |
| 317 | 319 | * @param string Original folder name |
| 318 | 320 | * @param integer Length to reach |
| 321 | + * @param integer $name |
|
| 322 | + * @param integer $nsize |
|
| 319 | 323 | * @return string Modified folder name |
| 320 | 324 | */ |
| 321 | 325 | function FillFolderName($name, $nsize) |
@@ -344,7 +344,7 @@ |
||
| 344 | 344 | if (is_dir($full_name)) { |
| 345 | 345 | $filelist[] = $file; |
| 346 | 346 | } |
| 347 | - } |
|
| 347 | + } |
|
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | if ($title == '') { |
| 67 | 67 | $title = basename($fname); |
| 68 | 68 | } |
| 69 | - return (string)$title; |
|
| 69 | + return (string) $title; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | if ($src == '') { |
| 177 | 177 | return ''; |
| 178 | 178 | } else { |
| 179 | - $tmp_src = basename($src) ; |
|
| 179 | + $tmp_src = basename($src); |
|
| 180 | 180 | if ($tmp_src == '') { |
| 181 | 181 | return $src; |
| 182 | 182 | } else { |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | { |
| 199 | 199 | // Select src tag from img tag. |
| 200 | 200 | $match = array(); |
| 201 | - preg_match("|(src=\".*\" )|U", $imgtag, $match); //src |
|
| 201 | + preg_match("|(src=\".*\" )|U", $imgtag, $match); //src |
|
| 202 | 202 | list($key, $srctag) = each($match); |
| 203 | 203 | $src = substr($srctag, 5, (strlen($srctag) - 7)); |
| 204 | 204 | if (stristr($src, 'http') === false) { |
@@ -230,8 +230,8 @@ discard block |
||
| 230 | 230 | while (list($key, $imgtag) = each($match)) { |
| 231 | 231 | $imgname = GetImgName($imgtag); |
| 232 | 232 | if ($imgname != '' && !in_array($imgname, $imgparams)) { |
| 233 | - array_push($imgparams, $imgname); // name (+ type) of the images in the html test |
|
| 234 | - $imgcount = $imgcount + 1; // number of images in the html test |
|
| 233 | + array_push($imgparams, $imgname); // name (+ type) of the images in the html test |
|
| 234 | + $imgcount = $imgcount + 1; // number of images in the html test |
|
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | } |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | if ($file != '..') { |
| 405 | 405 | $full_name = $folder.'/'.$file; |
| 406 | 406 | if (is_dir($full_name)) { |
| 407 | - $dflag = 1; // first directory |
|
| 407 | + $dflag = 1; // first directory |
|
| 408 | 408 | } |
| 409 | 409 | } |
| 410 | 410 | } |
@@ -18,6 +18,7 @@ |
||
| 18 | 18 | * Gets the results of all students (or just one student if access is limited) |
| 19 | 19 | * @param string The document path (for HotPotatoes retrieval) |
| 20 | 20 | * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null |
| 21 | + * @param string $document_path |
|
| 21 | 22 | */ |
| 22 | 23 | public function getExercisesReporting($document_path, $hotpotato_name) |
| 23 | 24 | { |
@@ -14,14 +14,14 @@ discard block |
||
| 14 | 14 | //stores the results |
| 15 | 15 | private $results = array(); |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Gets the results of all students (or just one student if access is limited) |
|
| 19 | - * @param string The document path (for HotPotatoes retrieval) |
|
| 20 | - * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null |
|
| 21 | - */ |
|
| 22 | - public function getExercisesReporting($document_path, $hotpotato_name) |
|
| 17 | + /** |
|
| 18 | + * Gets the results of all students (or just one student if access is limited) |
|
| 19 | + * @param string The document path (for HotPotatoes retrieval) |
|
| 20 | + * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null |
|
| 21 | + */ |
|
| 22 | + public function getExercisesReporting($document_path, $hotpotato_name) |
|
| 23 | 23 | { |
| 24 | - $return = array(); |
|
| 24 | + $return = array(); |
|
| 25 | 25 | $TBL_USER = Database::get_main_table(TABLE_MAIN_USER); |
| 26 | 26 | $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); |
| 27 | 27 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $hotpotato_name = Database::escape_string($hotpotato_name); |
| 34 | 34 | |
| 35 | 35 | if (!empty($exercise_id)) { |
| 36 | - $session_id_and .= " AND exe_exo_id = $exercise_id "; |
|
| 36 | + $session_id_and .= " AND exe_exo_id = $exercise_id "; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | if (empty($user_id)) { |
@@ -110,25 +110,25 @@ discard block |
||
| 110 | 110 | $this->results = $return; |
| 111 | 111 | |
| 112 | 112 | return true; |
| 113 | - } |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | 115 | |
| 116 | - /** |
|
| 117 | - * Exports the complete report as a CSV file |
|
| 118 | - * @param string Document path inside the document tool |
|
| 119 | - * @param integer Optional user ID |
|
| 120 | - * @param boolean Whether to include user fields or not |
|
| 121 | - * @return boolean False on error |
|
| 122 | - */ |
|
| 123 | - public function exportCompleteReportCSV($document_path='', $hotpotato_name) |
|
| 116 | + /** |
|
| 117 | + * Exports the complete report as a CSV file |
|
| 118 | + * @param string Document path inside the document tool |
|
| 119 | + * @param integer Optional user ID |
|
| 120 | + * @param boolean Whether to include user fields or not |
|
| 121 | + * @return boolean False on error |
|
| 122 | + */ |
|
| 123 | + public function exportCompleteReportCSV($document_path='', $hotpotato_name) |
|
| 124 | 124 | { |
| 125 | - global $charset; |
|
| 126 | - $this->getExercisesReporting($document_path, $hotpotato_name); |
|
| 127 | - $filename = 'exercise_results_'.date('YmdGis').'.csv'; |
|
| 128 | - if (!empty($user_id)) { |
|
| 129 | - $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv'; |
|
| 130 | - } |
|
| 131 | - $data = ''; |
|
| 125 | + global $charset; |
|
| 126 | + $this->getExercisesReporting($document_path, $hotpotato_name); |
|
| 127 | + $filename = 'exercise_results_'.date('YmdGis').'.csv'; |
|
| 128 | + if (!empty($user_id)) { |
|
| 129 | + $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv'; |
|
| 130 | + } |
|
| 131 | + $data = ''; |
|
| 132 | 132 | |
| 133 | 133 | if (api_is_western_name_order()) { |
| 134 | 134 | if(!empty($this->results[0]['first_name'])) { |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | } |
| 148 | 148 | $data .= get_lang('Email').';'; |
| 149 | 149 | |
| 150 | - /*if ($export_user_fields) { |
|
| 150 | + /*if ($export_user_fields) { |
|
| 151 | 151 | //show user fields section with a big th colspan that spans over all fields |
| 152 | 152 | $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); |
| 153 | 153 | $num = count($extra_user_fields); |
@@ -156,25 +156,25 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | }*/ |
| 158 | 158 | |
| 159 | - $data .= get_lang('Title').';'; |
|
| 160 | - $data .= get_lang('StartDate').';'; |
|
| 161 | - $data .= get_lang('Score').';'; |
|
| 162 | - $data .= get_lang('Total').';'; |
|
| 163 | - $data .= "\n"; |
|
| 159 | + $data .= get_lang('Title').';'; |
|
| 160 | + $data .= get_lang('StartDate').';'; |
|
| 161 | + $data .= get_lang('Score').';'; |
|
| 162 | + $data .= get_lang('Total').';'; |
|
| 163 | + $data .= "\n"; |
|
| 164 | 164 | |
| 165 | - //results |
|
| 166 | - foreach($this->results as $row) { |
|
| 165 | + //results |
|
| 166 | + foreach($this->results as $row) { |
|
| 167 | 167 | if (api_is_western_name_order()) { |
| 168 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
| 169 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
| 168 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
| 169 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
| 170 | 170 | } else { |
| 171 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
| 172 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
| 171 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
| 172 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';'; |
| 176 | 176 | |
| 177 | - /*if ($export_user_fields) { |
|
| 177 | + /*if ($export_user_fields) { |
|
| 178 | 178 | //show user fields data, if any, for this user |
| 179 | 179 | $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
| 180 | 180 | foreach($user_fields_values as $value) { |
@@ -182,40 +182,40 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | }*/ |
| 184 | 184 | |
| 185 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';'; |
|
| 186 | - $data .= str_replace("\r\n",' ',$row['exe_date']).';'; |
|
| 187 | - $data .= str_replace("\r\n",' ',$row['result']).';'; |
|
| 188 | - $data .= str_replace("\r\n",' ',$row['max']).';'; |
|
| 189 | - $data .= "\n"; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - //output the results |
|
| 193 | - $len = strlen($data); |
|
| 194 | - header('Content-type: application/octet-stream'); |
|
| 195 | - header('Content-Type: application/force-download'); |
|
| 196 | - header('Content-length: '.$len); |
|
| 197 | - if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) { |
|
| 198 | - header('Content-Disposition: filename= '.$filename); |
|
| 199 | - } else { |
|
| 200 | - header('Content-Disposition: attachment; filename= '.$filename); |
|
| 201 | - } |
|
| 202 | - if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { |
|
| 203 | - header('Pragma: '); |
|
| 204 | - header('Cache-Control: '); |
|
| 205 | - header('Cache-Control: public'); // IE cannot download from sessions without a cache |
|
| 206 | - } |
|
| 207 | - header('Content-Description: '.$filename); |
|
| 208 | - header('Content-transfer-encoding: binary'); |
|
| 209 | - // @todo add this utf-8 header for all csv files |
|
| 210 | - echo "\xEF\xBB\xBF"; // force utf-8 header of csv file |
|
| 211 | - echo $data; |
|
| 212 | - return true; |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * Exports the complete report as an XLS file |
|
| 217 | - * @return boolean False on error |
|
| 218 | - */ |
|
| 185 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';'; |
|
| 186 | + $data .= str_replace("\r\n",' ',$row['exe_date']).';'; |
|
| 187 | + $data .= str_replace("\r\n",' ',$row['result']).';'; |
|
| 188 | + $data .= str_replace("\r\n",' ',$row['max']).';'; |
|
| 189 | + $data .= "\n"; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + //output the results |
|
| 193 | + $len = strlen($data); |
|
| 194 | + header('Content-type: application/octet-stream'); |
|
| 195 | + header('Content-Type: application/force-download'); |
|
| 196 | + header('Content-length: '.$len); |
|
| 197 | + if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) { |
|
| 198 | + header('Content-Disposition: filename= '.$filename); |
|
| 199 | + } else { |
|
| 200 | + header('Content-Disposition: attachment; filename= '.$filename); |
|
| 201 | + } |
|
| 202 | + if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { |
|
| 203 | + header('Pragma: '); |
|
| 204 | + header('Cache-Control: '); |
|
| 205 | + header('Cache-Control: public'); // IE cannot download from sessions without a cache |
|
| 206 | + } |
|
| 207 | + header('Content-Description: '.$filename); |
|
| 208 | + header('Content-transfer-encoding: binary'); |
|
| 209 | + // @todo add this utf-8 header for all csv files |
|
| 210 | + echo "\xEF\xBB\xBF"; // force utf-8 header of csv file |
|
| 211 | + echo $data; |
|
| 212 | + return true; |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * Exports the complete report as an XLS file |
|
| 217 | + * @return boolean False on error |
|
| 218 | + */ |
|
| 219 | 219 | public function exportCompleteReportXLS( |
| 220 | 220 | $document_path = '', |
| 221 | 221 | $user_id = null, |
@@ -224,37 +224,37 @@ discard block |
||
| 224 | 224 | $exercise_id = 0, |
| 225 | 225 | $hotpotato_name = null |
| 226 | 226 | ) { |
| 227 | - global $charset; |
|
| 228 | - $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name); |
|
| 229 | - $filename = 'exercise_results_'.api_get_local_time().'.xls'; |
|
| 230 | - if (!empty($user_id)) { |
|
| 231 | - $filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls'; |
|
| 232 | - } |
|
| 227 | + global $charset; |
|
| 228 | + $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name); |
|
| 229 | + $filename = 'exercise_results_'.api_get_local_time().'.xls'; |
|
| 230 | + if (!empty($user_id)) { |
|
| 231 | + $filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls'; |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | 234 | $spreadsheet = new PHPExcel(); |
| 235 | 235 | $spreadsheet->setActiveSheetIndex(0); |
| 236 | 236 | $worksheet = $spreadsheet->getActiveSheet(); |
| 237 | 237 | |
| 238 | 238 | |
| 239 | - $line = 0; |
|
| 240 | - $column = 0; //skip the first column (row titles) |
|
| 239 | + $line = 0; |
|
| 240 | + $column = 0; //skip the first column (row titles) |
|
| 241 | 241 | |
| 242 | - // check if exists column 'user' |
|
| 243 | - $with_column_user = false; |
|
| 244 | - foreach ($this->results as $result) { |
|
| 245 | - if (!empty($result['last_name']) && !empty($result['first_name'])) { |
|
| 246 | - $with_column_user = true; |
|
| 247 | - break; |
|
| 248 | - } |
|
| 249 | - } |
|
| 242 | + // check if exists column 'user' |
|
| 243 | + $with_column_user = false; |
|
| 244 | + foreach ($this->results as $result) { |
|
| 245 | + if (!empty($result['last_name']) && !empty($result['first_name'])) { |
|
| 246 | + $with_column_user = true; |
|
| 247 | + break; |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | 250 | |
| 251 | - if ($with_column_user) { |
|
| 252 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Email')); |
|
| 253 | - $column++; |
|
| 251 | + if ($with_column_user) { |
|
| 252 | + $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Email')); |
|
| 253 | + $column++; |
|
| 254 | 254 | |
| 255 | 255 | if (api_is_western_name_order()) { |
| 256 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
|
| 257 | - $column++; |
|
| 256 | + $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
|
| 257 | + $column++; |
|
| 258 | 258 | $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('LastName')); |
| 259 | 259 | $column++; |
| 260 | 260 | } else { |
@@ -263,36 +263,36 @@ discard block |
||
| 263 | 263 | $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
| 264 | 264 | $column++; |
| 265 | 265 | } |
| 266 | - } |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - if ($export_user_fields) { |
|
| 269 | - //show user fields section with a big th colspan that spans over all fields |
|
| 270 | - $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); |
|
| 268 | + if ($export_user_fields) { |
|
| 269 | + //show user fields section with a big th colspan that spans over all fields |
|
| 270 | + $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); |
|
| 271 | 271 | |
| 272 | - //show the fields names for user fields |
|
| 273 | - foreach ($extra_user_fields as $field) { |
|
| 274 | - $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)); |
|
| 275 | - $column++; |
|
| 276 | - } |
|
| 277 | - } |
|
| 272 | + //show the fields names for user fields |
|
| 273 | + foreach ($extra_user_fields as $field) { |
|
| 274 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)); |
|
| 275 | + $column++; |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Title')); |
|
| 280 | - $column++; |
|
| 281 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('StartDate')); |
|
| 279 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Title')); |
|
| 280 | + $column++; |
|
| 281 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('StartDate')); |
|
| 282 | 282 | $column++; |
| 283 | 283 | $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('EndDate')); |
| 284 | 284 | $column++; |
| 285 | 285 | $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Duration').' ('.get_lang('MinMinutes').')'); |
| 286 | - $column++; |
|
| 287 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Score')); |
|
| 288 | - $column++; |
|
| 289 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Total')); |
|
| 290 | - $column++; |
|
| 286 | + $column++; |
|
| 287 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Score')); |
|
| 288 | + $column++; |
|
| 289 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Total')); |
|
| 290 | + $column++; |
|
| 291 | 291 | $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Status')); |
| 292 | - $line++; |
|
| 292 | + $line++; |
|
| 293 | 293 | |
| 294 | - foreach ($this->results as $row) { |
|
| 295 | - $column = 0; |
|
| 294 | + foreach ($this->results as $row) { |
|
| 295 | + $column = 0; |
|
| 296 | 296 | |
| 297 | 297 | if ($with_column_user) { |
| 298 | 298 | $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)); |
@@ -309,38 +309,38 @@ discard block |
||
| 309 | 309 | $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); |
| 310 | 310 | $column++; |
| 311 | 311 | } |
| 312 | - } |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - if ($export_user_fields) { |
|
| 315 | - //show user fields data, if any, for this user |
|
| 316 | - $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
|
| 317 | - foreach($user_fields_values as $value) { |
|
| 318 | - $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); |
|
| 319 | - $column++; |
|
| 320 | - } |
|
| 321 | - } |
|
| 314 | + if ($export_user_fields) { |
|
| 315 | + //show user fields data, if any, for this user |
|
| 316 | + $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
|
| 317 | + foreach($user_fields_values as $value) { |
|
| 318 | + $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); |
|
| 319 | + $column++; |
|
| 320 | + } |
|
| 321 | + } |
|
| 322 | 322 | |
| 323 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
| 324 | - $column++; |
|
| 325 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['start_date']); |
|
| 323 | + $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
| 324 | + $column++; |
|
| 325 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['start_date']); |
|
| 326 | 326 | $column++; |
| 327 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['end_date']); |
|
| 327 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['end_date']); |
|
| 328 | + $column++; |
|
| 329 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['duration']); |
|
| 330 | + $column++; |
|
| 331 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['result']); |
|
| 332 | + $column++; |
|
| 333 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['max']); |
|
| 328 | 334 | $column++; |
| 329 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['duration']); |
|
| 330 | - $column++; |
|
| 331 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['result']); |
|
| 332 | - $column++; |
|
| 333 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['max']); |
|
| 334 | - $column++; |
|
| 335 | 335 | $worksheet->SetCellValueByColumnAndRow($line,$column,$row['status']); |
| 336 | - $line++; |
|
| 337 | - } |
|
| 336 | + $line++; |
|
| 337 | + } |
|
| 338 | 338 | |
| 339 | 339 | $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename); |
| 340 | 340 | $writer = new PHPExcel_Writer_Excel2007($spreadsheet); |
| 341 | 341 | $writer->save($file); |
| 342 | 342 | DocumentManager::file_send_for_download($file, true, $filename); |
| 343 | 343 | |
| 344 | - return true; |
|
| 345 | - } |
|
| 344 | + return true; |
|
| 345 | + } |
|
| 346 | 346 | } |
@@ -23,13 +23,13 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | $return = array(); |
| 25 | 25 | $TBL_USER = Database::get_main_table(TABLE_MAIN_USER); |
| 26 | - $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); |
|
| 26 | + $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); |
|
| 27 | 27 | |
| 28 | 28 | $cid = api_get_course_id(); |
| 29 | 29 | $course_id = api_get_course_int_id(); |
| 30 | 30 | //$user_id = intval($user_id); |
| 31 | 31 | $user_id = null; |
| 32 | - $session_id_and = ' AND te.session_id = ' . api_get_session_id() . ' '; |
|
| 32 | + $session_id_and = ' AND te.session_id = '.api_get_session_id().' '; |
|
| 33 | 33 | $hotpotato_name = Database::escape_string($hotpotato_name); |
| 34 | 34 | |
| 35 | 35 | if (!empty($exercise_id)) { |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | if (empty($user_id)) { |
| 40 | - $sql="SELECT firstname as userpart1, lastname as userpart2 , |
|
| 40 | + $sql = "SELECT firstname as userpart1, lastname as userpart2 , |
|
| 41 | 41 | email, |
| 42 | 42 | tth.exe_name, |
| 43 | 43 | tth.exe_result, |
@@ -49,13 +49,13 @@ discard block |
||
| 49 | 49 | tth.exe_name = '$hotpotato_name' |
| 50 | 50 | ORDER BY tth.c_id ASC, tth.exe_date ASC"; |
| 51 | 51 | } else { |
| 52 | - $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' '; |
|
| 52 | + $user_id_and = ' AND te.exe_user_id = '.api_get_user_id().' '; |
|
| 53 | 53 | // get only this user's results |
| 54 | 54 | |
| 55 | 55 | $sql = "SELECT '', exe_name, exe_result , exe_weighting, exe_date |
| 56 | 56 | FROM $TBL_TRACK_HOTPOTATOES |
| 57 | 57 | WHERE |
| 58 | - exe_user_id = '" . $user_id . "' AND |
|
| 58 | + exe_user_id = '".$user_id."' AND |
|
| 59 | 59 | c_id = $course_id AND |
| 60 | 60 | tth.exe_name = '$hotpotato_name' |
| 61 | 61 | ORDER BY c_id ASC, exe_date ASC"; |
@@ -64,13 +64,13 @@ discard block |
||
| 64 | 64 | $results = array(); |
| 65 | 65 | |
| 66 | 66 | $resx = Database::query($sql); |
| 67 | - while ($rowx = Database::fetch_array($resx,'ASSOC')) { |
|
| 67 | + while ($rowx = Database::fetch_array($resx, 'ASSOC')) { |
|
| 68 | 68 | $results[] = $rowx; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $hpresults = array(); |
| 72 | 72 | $resx = Database::query($sql); |
| 73 | - while ($rowx = Database::fetch_array($resx,'ASSOC')) { |
|
| 73 | + while ($rowx = Database::fetch_array($resx, 'ASSOC')) { |
|
| 74 | 74 | $hpresults[] = $rowx; |
| 75 | 75 | } |
| 76 | 76 | |
@@ -89,19 +89,19 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | // Print the Result of Hotpotatoes Tests |
| 91 | 91 | if (is_array($hpresults)) { |
| 92 | - for($i = 0; $i < sizeof($hpresults); $i++) { |
|
| 92 | + for ($i = 0; $i < sizeof($hpresults); $i++) { |
|
| 93 | 93 | $return[$i] = array(); |
| 94 | 94 | $title = GetQuizName($hpresults[$i]['exe_name'], $document_path); |
| 95 | - if ($title =='') { |
|
| 95 | + if ($title == '') { |
|
| 96 | 96 | $title = basename($hpresults[$i]['exe_name']); |
| 97 | 97 | } |
| 98 | - if(empty($user_id)) { |
|
| 98 | + if (empty($user_id)) { |
|
| 99 | 99 | $return[$i]['email'] = $hpresults[$i]['email']; |
| 100 | 100 | $return[$i]['first_name'] = $hpresults[$i]['userpart1']; |
| 101 | 101 | $return[$i]['last_name'] = $hpresults[$i]['userpart2']; |
| 102 | 102 | } |
| 103 | 103 | $return[$i]['title'] = $title; |
| 104 | - $return[$i]['exe_date'] = $hpresults[$i]['exe_date']; |
|
| 104 | + $return[$i]['exe_date'] = $hpresults[$i]['exe_date']; |
|
| 105 | 105 | |
| 106 | 106 | $return[$i]['result'] = $hpresults[$i]['exe_result']; |
| 107 | 107 | $return[$i]['max'] = $hpresults[$i]['exe_weighting']; |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | * @param boolean Whether to include user fields or not |
| 121 | 121 | * @return boolean False on error |
| 122 | 122 | */ |
| 123 | - public function exportCompleteReportCSV($document_path='', $hotpotato_name) |
|
| 123 | + public function exportCompleteReportCSV($document_path = '', $hotpotato_name) |
|
| 124 | 124 | { |
| 125 | 125 | global $charset; |
| 126 | 126 | $this->getExercisesReporting($document_path, $hotpotato_name); |
@@ -131,17 +131,17 @@ discard block |
||
| 131 | 131 | $data = ''; |
| 132 | 132 | |
| 133 | 133 | if (api_is_western_name_order()) { |
| 134 | - if(!empty($this->results[0]['first_name'])) { |
|
| 134 | + if (!empty($this->results[0]['first_name'])) { |
|
| 135 | 135 | $data .= get_lang('FirstName').';'; |
| 136 | 136 | } |
| 137 | - if(!empty($this->results[0]['last_name'])) { |
|
| 137 | + if (!empty($this->results[0]['last_name'])) { |
|
| 138 | 138 | $data .= get_lang('LastName').';'; |
| 139 | 139 | } |
| 140 | 140 | } else { |
| 141 | - if(!empty($this->results[0]['last_name'])) { |
|
| 141 | + if (!empty($this->results[0]['last_name'])) { |
|
| 142 | 142 | $data .= get_lang('LastName').';'; |
| 143 | 143 | } |
| 144 | - if(!empty($this->results[0]['first_name'])) { |
|
| 144 | + if (!empty($this->results[0]['first_name'])) { |
|
| 145 | 145 | $data .= get_lang('FirstName').';'; |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -163,16 +163,16 @@ discard block |
||
| 163 | 163 | $data .= "\n"; |
| 164 | 164 | |
| 165 | 165 | //results |
| 166 | - foreach($this->results as $row) { |
|
| 166 | + foreach ($this->results as $row) { |
|
| 167 | 167 | if (api_is_western_name_order()) { |
| 168 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
| 169 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
| 168 | + $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
| 169 | + $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
| 170 | 170 | } else { |
| 171 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
| 172 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
| 171 | + $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
| 172 | + $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';'; |
|
| 175 | + $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';'; |
|
| 176 | 176 | |
| 177 | 177 | /*if ($export_user_fields) { |
| 178 | 178 | //show user fields data, if any, for this user |
@@ -182,10 +182,10 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | }*/ |
| 184 | 184 | |
| 185 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';'; |
|
| 186 | - $data .= str_replace("\r\n",' ',$row['exe_date']).';'; |
|
| 187 | - $data .= str_replace("\r\n",' ',$row['result']).';'; |
|
| 188 | - $data .= str_replace("\r\n",' ',$row['max']).';'; |
|
| 185 | + $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';'; |
|
| 186 | + $data .= str_replace("\r\n", ' ', $row['exe_date']).';'; |
|
| 187 | + $data .= str_replace("\r\n", ' ', $row['result']).';'; |
|
| 188 | + $data .= str_replace("\r\n", ' ', $row['max']).';'; |
|
| 189 | 189 | $data .= "\n"; |
| 190 | 190 | } |
| 191 | 191 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | header('Content-Description: '.$filename); |
| 208 | 208 | header('Content-transfer-encoding: binary'); |
| 209 | 209 | // @todo add this utf-8 header for all csv files |
| 210 | - echo "\xEF\xBB\xBF"; // force utf-8 header of csv file |
|
| 210 | + echo "\xEF\xBB\xBF"; // force utf-8 header of csv file |
|
| 211 | 211 | echo $data; |
| 212 | 212 | return true; |
| 213 | 213 | } |
@@ -249,25 +249,25 @@ discard block |
||
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | if ($with_column_user) { |
| 252 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Email')); |
|
| 252 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Email')); |
|
| 253 | 253 | $column++; |
| 254 | 254 | |
| 255 | 255 | if (api_is_western_name_order()) { |
| 256 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
|
| 256 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('FirstName')); |
|
| 257 | 257 | $column++; |
| 258 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('LastName')); |
|
| 258 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('LastName')); |
|
| 259 | 259 | $column++; |
| 260 | 260 | } else { |
| 261 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('LastName')); |
|
| 261 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('LastName')); |
|
| 262 | 262 | $column++; |
| 263 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
|
| 263 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('FirstName')); |
|
| 264 | 264 | $column++; |
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | if ($export_user_fields) { |
| 269 | 269 | //show user fields section with a big th colspan that spans over all fields |
| 270 | - $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); |
|
| 270 | + $extra_user_fields = UserManager::get_extra_fields(0, 1000, 5, 'ASC', false, 1); |
|
| 271 | 271 | |
| 272 | 272 | //show the fields names for user fields |
| 273 | 273 | foreach ($extra_user_fields as $field) { |
@@ -276,63 +276,63 @@ discard block |
||
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Title')); |
|
| 279 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Title')); |
|
| 280 | 280 | $column++; |
| 281 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('StartDate')); |
|
| 281 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('StartDate')); |
|
| 282 | 282 | $column++; |
| 283 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('EndDate')); |
|
| 283 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('EndDate')); |
|
| 284 | 284 | $column++; |
| 285 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Duration').' ('.get_lang('MinMinutes').')'); |
|
| 285 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Duration').' ('.get_lang('MinMinutes').')'); |
|
| 286 | 286 | $column++; |
| 287 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Score')); |
|
| 287 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Score')); |
|
| 288 | 288 | $column++; |
| 289 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Total')); |
|
| 289 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Total')); |
|
| 290 | 290 | $column++; |
| 291 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Status')); |
|
| 291 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Status')); |
|
| 292 | 292 | $line++; |
| 293 | 293 | |
| 294 | 294 | foreach ($this->results as $row) { |
| 295 | 295 | $column = 0; |
| 296 | 296 | |
| 297 | 297 | if ($with_column_user) { |
| 298 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)); |
|
| 298 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)); |
|
| 299 | 299 | $column++; |
| 300 | 300 | |
| 301 | 301 | if (api_is_western_name_order()) { |
| 302 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); |
|
| 302 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); |
|
| 303 | 303 | $column++; |
| 304 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)); |
|
| 304 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)); |
|
| 305 | 305 | $column++; |
| 306 | 306 | } else { |
| 307 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)); |
|
| 307 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)); |
|
| 308 | 308 | $column++; |
| 309 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); |
|
| 309 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); |
|
| 310 | 310 | $column++; |
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | if ($export_user_fields) { |
| 315 | 315 | //show user fields data, if any, for this user |
| 316 | - $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
|
| 317 | - foreach($user_fields_values as $value) { |
|
| 318 | - $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); |
|
| 316 | + $user_fields_values = UserManager::get_extra_user_data($row['user_id'], false, false, false, true); |
|
| 317 | + foreach ($user_fields_values as $value) { |
|
| 318 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); |
|
| 319 | 319 | $column++; |
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
| 323 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
| 324 | 324 | $column++; |
| 325 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['start_date']); |
|
| 325 | + $worksheet->SetCellValueByColumnAndRow($line, $column, $row['start_date']); |
|
| 326 | 326 | $column++; |
| 327 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['end_date']); |
|
| 327 | + $worksheet->SetCellValueByColumnAndRow($line, $column, $row['end_date']); |
|
| 328 | 328 | $column++; |
| 329 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['duration']); |
|
| 329 | + $worksheet->SetCellValueByColumnAndRow($line, $column, $row['duration']); |
|
| 330 | 330 | $column++; |
| 331 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['result']); |
|
| 331 | + $worksheet->SetCellValueByColumnAndRow($line, $column, $row['result']); |
|
| 332 | 332 | $column++; |
| 333 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['max']); |
|
| 333 | + $worksheet->SetCellValueByColumnAndRow($line, $column, $row['max']); |
|
| 334 | 334 | $column++; |
| 335 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['status']); |
|
| 335 | + $worksheet->SetCellValueByColumnAndRow($line, $column, $row['status']); |
|
| 336 | 336 | $line++; |
| 337 | 337 | } |
| 338 | 338 | |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | /** |
| 53 | 53 | * @param FormValidator $form |
| 54 | 54 | * @param null $objExercise |
| 55 | - * @return bool |
|
| 55 | + * @return null|false |
|
| 56 | 56 | */ |
| 57 | 57 | public function processCreation($form, $objExercise = null) |
| 58 | 58 | { |
@@ -12,78 +12,78 @@ discard block |
||
| 12 | 12 | **/ |
| 13 | 13 | class HotSpot extends Question |
| 14 | 14 | { |
| 15 | - static $typePicture = 'hotspot.png'; |
|
| 16 | - static $explanationLangVar = 'HotSpot'; |
|
| 17 | - |
|
| 18 | - public function __construct() |
|
| 19 | - { |
|
| 20 | - parent::__construct(); |
|
| 21 | - $this -> type = HOT_SPOT; |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - public function display() |
|
| 25 | - { |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @param FormValidator $form |
|
| 30 | - * @param int $fck_config |
|
| 31 | - */ |
|
| 32 | - public function createForm (&$form, $fck_config=0) |
|
| 33 | - { |
|
| 34 | - parent::createForm($form, $fck_config); |
|
| 35 | - |
|
| 36 | - if (!isset($_GET['editQuestion'])) { |
|
| 37 | - $form->addElement('file','imageUpload',array('<img src="../img/icons/22/hotspots.png" />', get_lang('UploadJpgPicture')) ); |
|
| 38 | - |
|
| 39 | - // setting the save button here and not in the question class.php |
|
| 40 | - // Saving a question |
|
| 41 | - $form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion'); |
|
| 42 | - //$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion'); |
|
| 43 | - $form->addRule('imageUpload', get_lang('OnlyImagesAllowed'), 'filetype', array ('jpg', 'jpeg', 'png', 'gif')); |
|
| 44 | - $form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile'); |
|
| 45 | - } else { |
|
| 46 | - // setting the save button here and not in the question class.php |
|
| 47 | - // Editing a question |
|
| 48 | - $form->addButtonUpdate(get_lang('ModifyExercise'), 'submitQuestion'); |
|
| 49 | - } |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @param FormValidator $form |
|
| 54 | - * @param null $objExercise |
|
| 55 | - * @return bool |
|
| 56 | - */ |
|
| 57 | - public function processCreation($form, $objExercise = null) |
|
| 58 | - { |
|
| 59 | - $file_info = $form->getSubmitValue('imageUpload'); |
|
| 60 | - $_course = api_get_course_info(); |
|
| 61 | - parent::processCreation($form, $objExercise); |
|
| 62 | - |
|
| 63 | - if(!empty($file_info['tmp_name'])) { |
|
| 64 | - $this->uploadPicture($file_info['tmp_name'], $file_info['name']); |
|
| 65 | - $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
|
| 66 | - $picturePath = $documentPath.'/images'; |
|
| 67 | - |
|
| 68 | - // fixed width ang height |
|
| 69 | - if (file_exists($picturePath.'/'.$this->picture)) { |
|
| 70 | - $this->resizePicture('width', 800); |
|
| 71 | - $this->save(); |
|
| 72 | - } else { |
|
| 73 | - return false; |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - function createAnswersForm ($form) |
|
| 79 | - { |
|
| 80 | - // nothing |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - function processAnswersCreation ($form) |
|
| 84 | - { |
|
| 85 | - // nothing |
|
| 86 | - } |
|
| 15 | + static $typePicture = 'hotspot.png'; |
|
| 16 | + static $explanationLangVar = 'HotSpot'; |
|
| 17 | + |
|
| 18 | + public function __construct() |
|
| 19 | + { |
|
| 20 | + parent::__construct(); |
|
| 21 | + $this -> type = HOT_SPOT; |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + public function display() |
|
| 25 | + { |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @param FormValidator $form |
|
| 30 | + * @param int $fck_config |
|
| 31 | + */ |
|
| 32 | + public function createForm (&$form, $fck_config=0) |
|
| 33 | + { |
|
| 34 | + parent::createForm($form, $fck_config); |
|
| 35 | + |
|
| 36 | + if (!isset($_GET['editQuestion'])) { |
|
| 37 | + $form->addElement('file','imageUpload',array('<img src="../img/icons/22/hotspots.png" />', get_lang('UploadJpgPicture')) ); |
|
| 38 | + |
|
| 39 | + // setting the save button here and not in the question class.php |
|
| 40 | + // Saving a question |
|
| 41 | + $form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion'); |
|
| 42 | + //$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion'); |
|
| 43 | + $form->addRule('imageUpload', get_lang('OnlyImagesAllowed'), 'filetype', array ('jpg', 'jpeg', 'png', 'gif')); |
|
| 44 | + $form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile'); |
|
| 45 | + } else { |
|
| 46 | + // setting the save button here and not in the question class.php |
|
| 47 | + // Editing a question |
|
| 48 | + $form->addButtonUpdate(get_lang('ModifyExercise'), 'submitQuestion'); |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @param FormValidator $form |
|
| 54 | + * @param null $objExercise |
|
| 55 | + * @return bool |
|
| 56 | + */ |
|
| 57 | + public function processCreation($form, $objExercise = null) |
|
| 58 | + { |
|
| 59 | + $file_info = $form->getSubmitValue('imageUpload'); |
|
| 60 | + $_course = api_get_course_info(); |
|
| 61 | + parent::processCreation($form, $objExercise); |
|
| 62 | + |
|
| 63 | + if(!empty($file_info['tmp_name'])) { |
|
| 64 | + $this->uploadPicture($file_info['tmp_name'], $file_info['name']); |
|
| 65 | + $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
|
| 66 | + $picturePath = $documentPath.'/images'; |
|
| 67 | + |
|
| 68 | + // fixed width ang height |
|
| 69 | + if (file_exists($picturePath.'/'.$this->picture)) { |
|
| 70 | + $this->resizePicture('width', 800); |
|
| 71 | + $this->save(); |
|
| 72 | + } else { |
|
| 73 | + return false; |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + function createAnswersForm ($form) |
|
| 79 | + { |
|
| 80 | + // nothing |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + function processAnswersCreation ($form) |
|
| 84 | + { |
|
| 85 | + // nothing |
|
| 86 | + } |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -91,35 +91,35 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | class HotSpotDelineation extends HotSpot |
| 93 | 93 | { |
| 94 | - static $typePicture = 'hotspot-delineation.png'; |
|
| 95 | - static $explanationLangVar = 'HotspotDelineation'; |
|
| 96 | - |
|
| 97 | - function __construct() |
|
| 98 | - { |
|
| 99 | - parent::__construct(); |
|
| 100 | - $this -> type = HOT_SPOT_DELINEATION; |
|
| 101 | - |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - function createForm (&$form, $fck_config=0) |
|
| 105 | - { |
|
| 106 | - parent::createForm ($form, $fck_config); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - function processCreation ($form, $objExercise = null) |
|
| 110 | - { |
|
| 111 | - $file_info = $form -> getSubmitValue('imageUpload'); |
|
| 112 | - parent::processCreation ($form, $objExercise); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - function createAnswersForm ($form) |
|
| 116 | - { |
|
| 117 | - parent::createAnswersForm ($form); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - function processAnswersCreation ($form) |
|
| 121 | - { |
|
| 122 | - parent::processAnswersCreation ($form); |
|
| 123 | - } |
|
| 94 | + static $typePicture = 'hotspot-delineation.png'; |
|
| 95 | + static $explanationLangVar = 'HotspotDelineation'; |
|
| 96 | + |
|
| 97 | + function __construct() |
|
| 98 | + { |
|
| 99 | + parent::__construct(); |
|
| 100 | + $this -> type = HOT_SPOT_DELINEATION; |
|
| 101 | + |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + function createForm (&$form, $fck_config=0) |
|
| 105 | + { |
|
| 106 | + parent::createForm ($form, $fck_config); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + function processCreation ($form, $objExercise = null) |
|
| 110 | + { |
|
| 111 | + $file_info = $form -> getSubmitValue('imageUpload'); |
|
| 112 | + parent::processCreation ($form, $objExercise); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + function createAnswersForm ($form) |
|
| 116 | + { |
|
| 117 | + parent::createAnswersForm ($form); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + function processAnswersCreation ($form) |
|
| 121 | + { |
|
| 122 | + parent::processAnswersCreation ($form); |
|
| 123 | + } |
|
| 124 | 124 | } |
| 125 | 125 | |
@@ -29,18 +29,18 @@ discard block |
||
| 29 | 29 | * @param FormValidator $form |
| 30 | 30 | * @param int $fck_config |
| 31 | 31 | */ |
| 32 | - public function createForm (&$form, $fck_config=0) |
|
| 32 | + public function createForm(&$form, $fck_config = 0) |
|
| 33 | 33 | { |
| 34 | 34 | parent::createForm($form, $fck_config); |
| 35 | 35 | |
| 36 | 36 | if (!isset($_GET['editQuestion'])) { |
| 37 | - $form->addElement('file','imageUpload',array('<img src="../img/icons/22/hotspots.png" />', get_lang('UploadJpgPicture')) ); |
|
| 37 | + $form->addElement('file', 'imageUpload', array('<img src="../img/icons/22/hotspots.png" />', get_lang('UploadJpgPicture'))); |
|
| 38 | 38 | |
| 39 | 39 | // setting the save button here and not in the question class.php |
| 40 | 40 | // Saving a question |
| 41 | 41 | $form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion'); |
| 42 | 42 | //$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion'); |
| 43 | - $form->addRule('imageUpload', get_lang('OnlyImagesAllowed'), 'filetype', array ('jpg', 'jpeg', 'png', 'gif')); |
|
| 43 | + $form->addRule('imageUpload', get_lang('OnlyImagesAllowed'), 'filetype', array('jpg', 'jpeg', 'png', 'gif')); |
|
| 44 | 44 | $form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile'); |
| 45 | 45 | } else { |
| 46 | 46 | // setting the save button here and not in the question class.php |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $_course = api_get_course_info(); |
| 61 | 61 | parent::processCreation($form, $objExercise); |
| 62 | 62 | |
| 63 | - if(!empty($file_info['tmp_name'])) { |
|
| 63 | + if (!empty($file_info['tmp_name'])) { |
|
| 64 | 64 | $this->uploadPicture($file_info['tmp_name'], $file_info['name']); |
| 65 | 65 | $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
| 66 | 66 | $picturePath = $documentPath.'/images'; |
@@ -75,12 +75,12 @@ discard block |
||
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - function createAnswersForm ($form) |
|
| 78 | + function createAnswersForm($form) |
|
| 79 | 79 | { |
| 80 | 80 | // nothing |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - function processAnswersCreation ($form) |
|
| 83 | + function processAnswersCreation($form) |
|
| 84 | 84 | { |
| 85 | 85 | // nothing |
| 86 | 86 | } |
@@ -101,25 +101,25 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - function createForm (&$form, $fck_config=0) |
|
| 104 | + function createForm(&$form, $fck_config = 0) |
|
| 105 | 105 | { |
| 106 | - parent::createForm ($form, $fck_config); |
|
| 106 | + parent::createForm($form, $fck_config); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - function processCreation ($form, $objExercise = null) |
|
| 109 | + function processCreation($form, $objExercise = null) |
|
| 110 | 110 | { |
| 111 | 111 | $file_info = $form -> getSubmitValue('imageUpload'); |
| 112 | - parent::processCreation ($form, $objExercise); |
|
| 112 | + parent::processCreation($form, $objExercise); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - function createAnswersForm ($form) |
|
| 115 | + function createAnswersForm($form) |
|
| 116 | 116 | { |
| 117 | - parent::createAnswersForm ($form); |
|
| 117 | + parent::createAnswersForm($form); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - function processAnswersCreation ($form) |
|
| 120 | + function processAnswersCreation($form) |
|
| 121 | 121 | { |
| 122 | - parent::processAnswersCreation ($form); |
|
| 122 | + parent::processAnswersCreation($form); |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | * @param null $feedback_type |
| 59 | 59 | * @param null $counter |
| 60 | 60 | * @param null $score |
| 61 | - * @return null|string |
|
| 61 | + * @return string |
|
| 62 | 62 | */ |
| 63 | 63 | function return_header($feedback_type = null, $counter = null, $score = null) |
| 64 | 64 | { |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | function createAnswersForm($form) |
| 32 | 32 | { |
| 33 | 33 | |
| 34 | - $form -> addElement('text','weighting', get_lang('Weighting'), array('class' => 'span1')); |
|
| 34 | + $form -> addElement('text', 'weighting', get_lang('Weighting'), array('class' => 'span1')); |
|
| 35 | 35 | global $text, $class; |
| 36 | 36 | // setting the save button here and not in the question class.php |
| 37 | 37 | $form->addButtonSave($text, 'submitQuestion'); |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /** |
| 268 | - * @return bool|string |
|
| 268 | + * @return string|false |
|
| 269 | 269 | */ |
| 270 | 270 | public function selectPicturePath() |
| 271 | 271 | { |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | * @param string $Dimension - Resizing happens proportional according to given dimension: height|width|any |
| 591 | 591 | * @param integer $Max - Maximum size |
| 592 | 592 | * |
| 593 | - * @return boolean - true if success, false if failed |
|
| 593 | + * @return boolean|null - true if success, false if failed |
|
| 594 | 594 | * |
| 595 | 595 | * @author Toon Keppens |
| 596 | 596 | */ |
@@ -751,6 +751,7 @@ discard block |
||
| 751 | 751 | |
| 752 | 752 | /** |
| 753 | 753 | * Sets extra info |
| 754 | + * @param string $extra |
|
| 754 | 755 | */ |
| 755 | 756 | public function setExtra($extra) |
| 756 | 757 | { |
@@ -1261,7 +1262,7 @@ discard block |
||
| 1261 | 1262 | * |
| 1262 | 1263 | * @author Olivier Brouckaert |
| 1263 | 1264 | * @param array Course info of the destination course |
| 1264 | - * @return int ID of the new question |
|
| 1265 | + * @return false|string ID of the new question |
|
| 1265 | 1266 | */ |
| 1266 | 1267 | public function duplicate($course_info = null) |
| 1267 | 1268 | { |
@@ -1636,7 +1637,7 @@ discard block |
||
| 1636 | 1637 | * @param string $name |
| 1637 | 1638 | * @param int $course_id |
| 1638 | 1639 | * @param int $position |
| 1639 | - * @return bool|int |
|
| 1640 | + * @return false|string |
|
| 1640 | 1641 | */ |
| 1641 | 1642 | static function saveQuestionOption($question_id, $name, $course_id, $position = 0) |
| 1642 | 1643 | { |
@@ -1775,6 +1776,7 @@ discard block |
||
| 1775 | 1776 | * @param int Maximum result for the question |
| 1776 | 1777 | * @param int Type of question (see constants at beginning of question.class.php) |
| 1777 | 1778 | * @param int Question level/category |
| 1779 | + * @param string $quiz_id |
|
| 1778 | 1780 | */ |
| 1779 | 1781 | public function create_question( |
| 1780 | 1782 | $quiz_id, |
@@ -1857,6 +1859,7 @@ discard block |
||
| 1857 | 1859 | /** |
| 1858 | 1860 | * Get course medias |
| 1859 | 1861 | * @param int course id |
| 1862 | + * @param integer $course_id |
|
| 1860 | 1863 | */ |
| 1861 | 1864 | static function get_course_medias( |
| 1862 | 1865 | $course_id, |
@@ -1922,7 +1925,7 @@ discard block |
||
| 1922 | 1925 | } |
| 1923 | 1926 | |
| 1924 | 1927 | /** |
| 1925 | - * @return array |
|
| 1928 | + * @return integer[] |
|
| 1926 | 1929 | */ |
| 1927 | 1930 | public static function get_default_levels() |
| 1928 | 1931 | { |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | public $type; |
| 23 | 23 | public $level; |
| 24 | 24 | public $picture; |
| 25 | - public $exerciseList; // array with the list of exercises which this question is in |
|
| 25 | + public $exerciseList; // array with the list of exercises which this question is in |
|
| 26 | 26 | public $category_list; |
| 27 | 27 | public $parent_id; |
| 28 | 28 | public $category; |
@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | 'multiple_answer_combination_true_false.class.php', |
| 48 | 48 | 'MultipleAnswerCombinationTrueFalse' |
| 49 | 49 | ), |
| 50 | - GLOBAL_MULTIPLE_ANSWER => array('global_multiple_answer.class.php' , 'GlobalMultipleAnswer'), |
|
| 51 | - CALCULATED_ANSWER => array('calculated_answer.class.php' , 'CalculatedAnswer'), |
|
| 50 | + GLOBAL_MULTIPLE_ANSWER => array('global_multiple_answer.class.php', 'GlobalMultipleAnswer'), |
|
| 51 | + CALCULATED_ANSWER => array('calculated_answer.class.php', 'CalculatedAnswer'), |
|
| 52 | 52 | UNIQUE_ANSWER_IMAGE => ['UniqueAnswerImage.php', 'UniqueAnswerImage'], |
| 53 | 53 | DRAGGABLE => ['Draggable.php', 'Draggable'], |
| 54 | 54 | MATCHING_DRAGGABLE => ['MatchingDraggable.php', 'MatchingDraggable'] |
@@ -107,14 +107,14 @@ discard block |
||
| 107 | 107 | $id = intval($id); |
| 108 | 108 | |
| 109 | 109 | if (!empty($course_id)) { |
| 110 | - $course_info = api_get_course_info_by_id($course_id); |
|
| 110 | + $course_info = api_get_course_info_by_id($course_id); |
|
| 111 | 111 | } else { |
| 112 | 112 | $course_info = api_get_course_info(); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | $course_id = $course_info['real_id']; |
| 116 | 116 | |
| 117 | - if (empty($course_id) || $course_id == -1 ) { |
|
| 117 | + if (empty($course_id) || $course_id == -1) { |
|
| 118 | 118 | return false; |
| 119 | 119 | } |
| 120 | 120 | |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | public function selectPicturePath() |
| 271 | 271 | { |
| 272 | 272 | if (!empty($this->picture)) { |
| 273 | - return api_get_path(WEB_COURSE_PATH) . $this->course['path'] . '/document/images/' . $this->picture; |
|
| 273 | + return api_get_path(WEB_COURSE_PATH).$this->course['path'].'/document/images/'.$this->picture; |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | return false; |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | */ |
| 308 | 308 | public function updateTitle($title) |
| 309 | 309 | { |
| 310 | - $this->question=$title; |
|
| 310 | + $this->question = $title; |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | /** |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | // DO nothing |
| 407 | 407 | } else { |
| 408 | 408 | $sql = "INSERT INTO $TBL_QUESTION_REL_CATEGORY (c_id, question_id, category_id) |
| 409 | - VALUES (" . api_get_course_int_id() . ", $question_id, $category_id)"; |
|
| 409 | + VALUES (".api_get_course_int_id().", $question_id, $category_id)"; |
|
| 410 | 410 | Database::query($sql); |
| 411 | 411 | } |
| 412 | 412 | } |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | $sql = "SELECT count(*) AS nb FROM $table |
| 434 | 434 | WHERE |
| 435 | 435 | question_id = $question_id AND |
| 436 | - c_id=" . api_get_course_int_id(); |
|
| 436 | + c_id=".api_get_course_int_id(); |
|
| 437 | 437 | $res = Database::query($sql); |
| 438 | 438 | $row = Database::fetch_array($res); |
| 439 | 439 | if ($row['nb'] > 0) { |
@@ -441,11 +441,11 @@ discard block |
||
| 441 | 441 | SET category_id = $category_id |
| 442 | 442 | WHERE |
| 443 | 443 | question_id = $question_id AND |
| 444 | - c_id = " . api_get_course_int_id(); |
|
| 444 | + c_id = ".api_get_course_int_id(); |
|
| 445 | 445 | Database::query($sql); |
| 446 | 446 | } else { |
| 447 | 447 | $sql = "INSERT INTO $table (c_id, question_id, category_id) |
| 448 | - VALUES (" . api_get_course_int_id().", $question_id, $category_id)"; |
|
| 448 | + VALUES (".api_get_course_int_id().", $question_id, $category_id)"; |
|
| 449 | 449 | Database::query($sql); |
| 450 | 450 | } |
| 451 | 451 | } |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | $sql = "DELETE FROM $table |
| 464 | 464 | WHERE |
| 465 | 465 | question_id = $question_id AND |
| 466 | - c_id = " . api_get_course_int_id(); |
|
| 466 | + c_id = ".api_get_course_int_id(); |
|
| 467 | 467 | Database::query($sql); |
| 468 | 468 | } |
| 469 | 469 | |
@@ -516,11 +516,11 @@ discard block |
||
| 516 | 516 | ) { |
| 517 | 517 | // removes old answers |
| 518 | 518 | $sql = "DELETE FROM $TBL_REPONSES |
| 519 | - WHERE c_id = $course_id AND question_id = " . intval($this->id); |
|
| 519 | + WHERE c_id = $course_id AND question_id = ".intval($this->id); |
|
| 520 | 520 | Database::query($sql); |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | - $this->type=$type; |
|
| 523 | + $this->type = $type; |
|
| 524 | 524 | } |
| 525 | 525 | } |
| 526 | 526 | |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | if (!file_exists($picturePath)) { |
| 545 | 545 | if (mkdir($picturePath, api_get_permissions_for_new_directories())) { |
| 546 | 546 | // document path |
| 547 | - $documentPath = api_get_path(SYS_COURSE_PATH) . $this->course['path'] . "/document"; |
|
| 547 | + $documentPath = api_get_path(SYS_COURSE_PATH).$this->course['path']."/document"; |
|
| 548 | 548 | $path = str_replace($documentPath, '', $picturePath); |
| 549 | 549 | $title_path = basename($picturePath); |
| 550 | 550 | $doc_id = add_document($this->course, $path, 'folder', 0, $title_path); |
@@ -560,14 +560,14 @@ discard block |
||
| 560 | 560 | |
| 561 | 561 | // if the question has got an ID |
| 562 | 562 | if ($this->id) { |
| 563 | - $this->picture = 'quiz-' . $this->id . '.jpg'; |
|
| 563 | + $this->picture = 'quiz-'.$this->id.'.jpg'; |
|
| 564 | 564 | $o_img = new Image($Picture); |
| 565 | - $o_img->send_image($picturePath . '/' . $this->picture, -1, 'jpg'); |
|
| 565 | + $o_img->send_image($picturePath.'/'.$this->picture, -1, 'jpg'); |
|
| 566 | 566 | $document_id = add_document( |
| 567 | 567 | $this->course, |
| 568 | - '/images/' . $this->picture, |
|
| 568 | + '/images/'.$this->picture, |
|
| 569 | 569 | 'file', |
| 570 | - filesize($picturePath . '/' . $this->picture), |
|
| 570 | + filesize($picturePath.'/'.$this->picture), |
|
| 571 | 571 | $this->picture |
| 572 | 572 | ); |
| 573 | 573 | if ($document_id) { |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | // if the question has an ID |
| 602 | 602 | if ($this->id) { |
| 603 | 603 | // Get dimensions from current image. |
| 604 | - $my_image = new Image($picturePath . '/' . $this->picture); |
|
| 604 | + $my_image = new Image($picturePath.'/'.$this->picture); |
|
| 605 | 605 | |
| 606 | 606 | $current_image_size = $my_image->get_image_size(); |
| 607 | 607 | $current_width = $current_image_size['width']; |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | $my_image->resize($new_width, $new_height); |
| 644 | - $result = $my_image->send_image($picturePath . '/' . $this->picture); |
|
| 644 | + $result = $my_image->send_image($picturePath.'/'.$this->picture); |
|
| 645 | 645 | |
| 646 | 646 | if ($result) { |
| 647 | 647 | return true; |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | $picture = $this->picture; |
| 667 | 667 | $this->picture = ''; |
| 668 | 668 | |
| 669 | - return @unlink($picturePath . '/' . $picture) ? true : false; |
|
| 669 | + return @unlink($picturePath.'/'.$picture) ? true : false; |
|
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | return false; |
@@ -683,27 +683,27 @@ discard block |
||
| 683 | 683 | { |
| 684 | 684 | $course_id = $course_info['real_id']; |
| 685 | 685 | $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); |
| 686 | - $destination_path = api_get_path(SYS_COURSE_PATH) . $course_info['path'] . '/document/images'; |
|
| 687 | - $source_path = api_get_path(SYS_COURSE_PATH) . $this->course['path'] . '/document/images'; |
|
| 686 | + $destination_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document/images'; |
|
| 687 | + $source_path = api_get_path(SYS_COURSE_PATH).$this->course['path'].'/document/images'; |
|
| 688 | 688 | |
| 689 | 689 | // if the question has got an ID and if the picture exists |
| 690 | 690 | if ($this->id && !empty($this->picture)) { |
| 691 | 691 | $picture = explode('.', $this->picture); |
| 692 | 692 | $extension = $picture[sizeof($picture) - 1]; |
| 693 | - $picture = 'quiz-' . $questionId . '.' . $extension; |
|
| 694 | - $result = @copy($source_path . '/' . $this->picture, $destination_path . '/' . $picture) ? true : false; |
|
| 693 | + $picture = 'quiz-'.$questionId.'.'.$extension; |
|
| 694 | + $result = @copy($source_path.'/'.$this->picture, $destination_path.'/'.$picture) ? true : false; |
|
| 695 | 695 | // If copy was correct then add to the database |
| 696 | 696 | if ($result) { |
| 697 | 697 | $sql = "UPDATE $TBL_QUESTIONS SET |
| 698 | - picture = '" . Database::escape_string($picture) . "' |
|
| 699 | - WHERE c_id = $course_id AND id='" . intval($questionId) . "'"; |
|
| 698 | + picture = '".Database::escape_string($picture)."' |
|
| 699 | + WHERE c_id = $course_id AND id='".intval($questionId)."'"; |
|
| 700 | 700 | Database::query($sql); |
| 701 | 701 | |
| 702 | 702 | $document_id = add_document( |
| 703 | 703 | $course_info, |
| 704 | - '/images/' . $picture, |
|
| 704 | + '/images/'.$picture, |
|
| 705 | 705 | 'file', |
| 706 | - filesize($destination_path . '/' . $picture), |
|
| 706 | + filesize($destination_path.'/'.$picture), |
|
| 707 | 707 | $picture |
| 708 | 708 | ); |
| 709 | 709 | if ($document_id) { |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | $Extension = $PictureName[sizeof($PictureName) - 1]; |
| 739 | 739 | |
| 740 | 740 | // saves the picture into a temporary file |
| 741 | - @move_uploaded_file($Picture, $picturePath . '/tmp.' . $Extension); |
|
| 741 | + @move_uploaded_file($Picture, $picturePath.'/tmp.'.$Extension); |
|
| 742 | 742 | } |
| 743 | 743 | |
| 744 | 744 | /** |
@@ -771,15 +771,15 @@ discard block |
||
| 771 | 771 | |
| 772 | 772 | // if the question has got an ID and if the picture exists |
| 773 | 773 | if ($this->id) { |
| 774 | - if (file_exists($picturePath . '/tmp.jpg')) { |
|
| 774 | + if (file_exists($picturePath.'/tmp.jpg')) { |
|
| 775 | 775 | $Extension = 'jpg'; |
| 776 | - } elseif (file_exists($picturePath . '/tmp.gif')) { |
|
| 776 | + } elseif (file_exists($picturePath.'/tmp.gif')) { |
|
| 777 | 777 | $Extension = 'gif'; |
| 778 | - } elseif (file_exists($picturePath . '/tmp.png')) { |
|
| 778 | + } elseif (file_exists($picturePath.'/tmp.png')) { |
|
| 779 | 779 | $Extension = 'png'; |
| 780 | 780 | } |
| 781 | - $this->picture = 'quiz-' . $this->id . '.' . $Extension; |
|
| 782 | - return @rename($picturePath . '/tmp.' . $Extension, $picturePath . '/' . $this->picture) ? true : false; |
|
| 781 | + $this->picture = 'quiz-'.$this->id.'.'.$Extension; |
|
| 782 | + return @rename($picturePath.'/tmp.'.$Extension, $picturePath.'/'.$this->picture) ? true : false; |
|
| 783 | 783 | } |
| 784 | 784 | return false; |
| 785 | 785 | } |
@@ -809,7 +809,7 @@ discard block |
||
| 809 | 809 | $category = $this->category; |
| 810 | 810 | |
| 811 | 811 | // question already exists |
| 812 | - if(!empty($id)) { |
|
| 812 | + if (!empty($id)) { |
|
| 813 | 813 | |
| 814 | 814 | $params = [ |
| 815 | 815 | 'question' => $question, |
@@ -855,12 +855,12 @@ discard block |
||
| 855 | 855 | $TBL_EXERCISE_QUESTION as test_question |
| 856 | 856 | WHERE |
| 857 | 857 | question.id = test_question.question_id AND |
| 858 | - test_question.exercice_id = " . intval($exerciseId) . " AND |
|
| 858 | + test_question.exercice_id = ".intval($exerciseId)." AND |
|
| 859 | 859 | question.c_id = $c_id AND |
| 860 | 860 | test_question.c_id = $c_id "; |
| 861 | - $result = Database::query($sql); |
|
| 862 | - $current_position = Database::result($result,0,0); |
|
| 863 | - $this->updatePosition($current_position+1); |
|
| 861 | + $result = Database::query($sql); |
|
| 862 | + $current_position = Database::result($result, 0, 0); |
|
| 863 | + $this->updatePosition($current_position + 1); |
|
| 864 | 864 | $position = $this->position; |
| 865 | 865 | |
| 866 | 866 | $params = [ |
@@ -956,10 +956,10 @@ discard block |
||
| 956 | 956 | } |
| 957 | 957 | } |
| 958 | 958 | |
| 959 | - public function search_engine_edit($exerciseId, $addQs=false, $rmQs=false) |
|
| 959 | + public function search_engine_edit($exerciseId, $addQs = false, $rmQs = false) |
|
| 960 | 960 | { |
| 961 | 961 | // update search engine and its values table if enabled |
| 962 | - if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian')) { |
|
| 962 | + if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) { |
|
| 963 | 963 | $course_id = api_get_course_id(); |
| 964 | 964 | // get search_did |
| 965 | 965 | $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF); |
@@ -977,8 +977,8 @@ discard block |
||
| 977 | 977 | $res = Database::query($sql); |
| 978 | 978 | |
| 979 | 979 | if (Database::num_rows($res) > 0 || $addQs) { |
| 980 | - require_once(api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php'); |
|
| 981 | - require_once(api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php'); |
|
| 980 | + require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'); |
|
| 981 | + require_once(api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php'); |
|
| 982 | 982 | |
| 983 | 983 | $di = new ChamiloIndexer(); |
| 984 | 984 | if ($addQs) { |
@@ -991,7 +991,7 @@ discard block |
||
| 991 | 991 | |
| 992 | 992 | // retrieve others exercise ids |
| 993 | 993 | $se_ref = Database::fetch_array($res); |
| 994 | - $se_doc = $di->get_document((int)$se_ref['search_did']); |
|
| 994 | + $se_doc = $di->get_document((int) $se_ref['search_did']); |
|
| 995 | 995 | if ($se_doc !== FALSE) { |
| 996 | 996 | if (($se_doc_data = $di->get_document_data($se_doc)) !== FALSE) { |
| 997 | 997 | $se_doc_data = unserialize($se_doc_data); |
@@ -1029,16 +1029,16 @@ discard block |
||
| 1029 | 1029 | SE_DATA => array( |
| 1030 | 1030 | 'type' => SE_DOCTYPE_EXERCISE_QUESTION, |
| 1031 | 1031 | 'exercise_ids' => $question_exercises, |
| 1032 | - 'question_id' => (int)$this->id |
|
| 1032 | + 'question_id' => (int) $this->id |
|
| 1033 | 1033 | ), |
| 1034 | - SE_USER => (int)api_get_user_id(), |
|
| 1034 | + SE_USER => (int) api_get_user_id(), |
|
| 1035 | 1035 | ); |
| 1036 | 1036 | $ic_slide->xapian_data = serialize($xapian_data); |
| 1037 | 1037 | $ic_slide->addValue("content", $this->description); |
| 1038 | 1038 | |
| 1039 | 1039 | //TODO: index answers, see also form validation on question_admin.inc.php |
| 1040 | 1040 | |
| 1041 | - $di->remove_document((int)$se_ref['search_did']); |
|
| 1041 | + $di->remove_document((int) $se_ref['search_did']); |
|
| 1042 | 1042 | $di->addChunk($ic_slide); |
| 1043 | 1043 | |
| 1044 | 1044 | //index and return search engine document id |
@@ -1117,7 +1117,7 @@ discard block |
||
| 1117 | 1117 | $count = $new_exercise->selectNbrQuestions(); |
| 1118 | 1118 | $count++; |
| 1119 | 1119 | $sql = "INSERT INTO $exerciseRelQuestionTable (c_id, question_id, exercice_id, question_order) |
| 1120 | - VALUES ({$this->course['real_id']}, " . intval($id) . ", " . intval($exerciseId) . ", '$count')"; |
|
| 1120 | + VALUES ({$this->course['real_id']}, ".intval($id).", ".intval($exerciseId).", '$count')"; |
|
| 1121 | 1121 | Database::query($sql); |
| 1122 | 1122 | |
| 1123 | 1123 | // we do not want to reindex if we had just saved adnd indexed the question |
@@ -1146,7 +1146,7 @@ discard block |
||
| 1146 | 1146 | $course_id = api_get_course_int_id(); |
| 1147 | 1147 | |
| 1148 | 1148 | // exercise not found |
| 1149 | - if($pos === false) { |
|
| 1149 | + if ($pos === false) { |
|
| 1150 | 1150 | return false; |
| 1151 | 1151 | } else { |
| 1152 | 1152 | // deletes the position in the array containing the wanted exercise ID |
@@ -1156,17 +1156,17 @@ discard block |
||
| 1156 | 1156 | FROM $TBL_EXERCISE_QUESTION |
| 1157 | 1157 | WHERE |
| 1158 | 1158 | c_id = $course_id |
| 1159 | - AND question_id = " . intval($id) . " |
|
| 1159 | + AND question_id = ".intval($id)." |
|
| 1160 | 1160 | AND exercice_id = " . intval($exerciseId); |
| 1161 | 1161 | $res = Database::query($sql); |
| 1162 | - if (Database::num_rows($res)>0) { |
|
| 1162 | + if (Database::num_rows($res) > 0) { |
|
| 1163 | 1163 | $row = Database::fetch_array($res); |
| 1164 | 1164 | if (!empty($row['question_order'])) { |
| 1165 | 1165 | $sql = "UPDATE $TBL_EXERCISE_QUESTION |
| 1166 | 1166 | SET question_order = question_order-1 |
| 1167 | 1167 | WHERE |
| 1168 | 1168 | c_id = $course_id |
| 1169 | - AND exercice_id = " . intval($exerciseId) . " |
|
| 1169 | + AND exercice_id = ".intval($exerciseId)." |
|
| 1170 | 1170 | AND question_order > " . $row['question_order']; |
| 1171 | 1171 | Database::query($sql); |
| 1172 | 1172 | } |
@@ -1175,7 +1175,7 @@ discard block |
||
| 1175 | 1175 | $sql = "DELETE FROM $TBL_EXERCISE_QUESTION |
| 1176 | 1176 | WHERE |
| 1177 | 1177 | c_id = $course_id |
| 1178 | - AND question_id = " . intval($id) . " |
|
| 1178 | + AND question_id = ".intval($id)." |
|
| 1179 | 1179 | AND exercice_id = " . intval($exerciseId); |
| 1180 | 1180 | Database::query($sql); |
| 1181 | 1181 | |
@@ -1216,7 +1216,7 @@ discard block |
||
| 1216 | 1216 | SET question_order = question_order-1 |
| 1217 | 1217 | WHERE |
| 1218 | 1218 | c_id= $course_id |
| 1219 | - AND exercice_id = " . intval($row['exercice_id']) . " |
|
| 1219 | + AND exercice_id = ".intval($row['exercice_id'])." |
|
| 1220 | 1220 | AND question_order > " . $row['question_order']; |
| 1221 | 1221 | Database::query($sql); |
| 1222 | 1222 | } |
@@ -1224,20 +1224,20 @@ discard block |
||
| 1224 | 1224 | } |
| 1225 | 1225 | |
| 1226 | 1226 | $sql = "DELETE FROM $TBL_EXERCISE_QUESTION |
| 1227 | - WHERE c_id = $course_id AND question_id = " . intval($id) . ""; |
|
| 1227 | + WHERE c_id = $course_id AND question_id = ".intval($id).""; |
|
| 1228 | 1228 | Database::query($sql); |
| 1229 | 1229 | |
| 1230 | 1230 | $sql = "DELETE FROM $TBL_QUESTIONS |
| 1231 | - WHERE c_id = $course_id AND id = " . intval($id) . ""; |
|
| 1231 | + WHERE c_id = $course_id AND id = ".intval($id).""; |
|
| 1232 | 1232 | Database::query($sql); |
| 1233 | 1233 | |
| 1234 | 1234 | $sql = "DELETE FROM $TBL_REPONSES |
| 1235 | - WHERE c_id = $course_id AND question_id = " . intval($id) . ""; |
|
| 1235 | + WHERE c_id = $course_id AND question_id = ".intval($id).""; |
|
| 1236 | 1236 | Database::query($sql); |
| 1237 | 1237 | |
| 1238 | 1238 | // remove the category of this question in the question_rel_category table |
| 1239 | 1239 | $sql = "DELETE FROM $TBL_QUIZ_QUESTION_REL_CATEGORY |
| 1240 | - WHERE c_id = $course_id AND question_id = " . intval($id) . " AND c_id=" . api_get_course_int_id(); |
|
| 1240 | + WHERE c_id = $course_id AND question_id = ".intval($id)." AND c_id=".api_get_course_int_id(); |
|
| 1241 | 1241 | Database::query($sql); |
| 1242 | 1242 | |
| 1243 | 1243 | api_item_property_update($this->course, TOOL_QUIZ, $id, 'QuizQuestionDeleted', api_get_user_id()); |
@@ -1394,7 +1394,7 @@ discard block |
||
| 1394 | 1394 | if (class_exists($class_name)) { |
| 1395 | 1395 | return new $class_name(); |
| 1396 | 1396 | } else { |
| 1397 | - echo 'Can\'t instanciate class ' . $class_name . ' of type ' . $type; |
|
| 1397 | + echo 'Can\'t instanciate class '.$class_name.' of type '.$type; |
|
| 1398 | 1398 | } |
| 1399 | 1399 | } |
| 1400 | 1400 | } |
@@ -1436,7 +1436,7 @@ discard block |
||
| 1436 | 1436 | |
| 1437 | 1437 | // Question type |
| 1438 | 1438 | $answerType = isset($_REQUEST['answerType']) ? intval($_REQUEST['answerType']) : null; |
| 1439 | - $form->addElement('hidden','answerType', $answerType); |
|
| 1439 | + $form->addElement('hidden', 'answerType', $answerType); |
|
| 1440 | 1440 | |
| 1441 | 1441 | // html editor |
| 1442 | 1442 | $editorConfig = array( |
@@ -1444,7 +1444,7 @@ discard block |
||
| 1444 | 1444 | 'Height' => '150' |
| 1445 | 1445 | ); |
| 1446 | 1446 | |
| 1447 | - if (!api_is_allowed_to_edit(null,true)) { |
|
| 1447 | + if (!api_is_allowed_to_edit(null, true)) { |
|
| 1448 | 1448 | $editorConfig['UserStatus'] = 'student'; |
| 1449 | 1449 | } |
| 1450 | 1450 | |
@@ -1581,7 +1581,7 @@ discard block |
||
| 1581 | 1581 | |
| 1582 | 1582 | if ($feedback_type == 1) { |
| 1583 | 1583 | //2. but if it is a feedback DIRECT we only show the UNIQUE_ANSWER type that is currently available |
| 1584 | - $question_type_custom_list = array ( |
|
| 1584 | + $question_type_custom_list = array( |
|
| 1585 | 1585 | UNIQUE_ANSWER => self::$questionTypes[UNIQUE_ANSWER], |
| 1586 | 1586 | HOT_SPOT_DELINEATION => self::$questionTypes[HOT_SPOT_DELINEATION] |
| 1587 | 1587 | ); |
@@ -1597,17 +1597,17 @@ discard block |
||
| 1597 | 1597 | require_once $a_type[0]; |
| 1598 | 1598 | // get the picture of the type and the langvar which describes it |
| 1599 | 1599 | $img = $explanation = ''; |
| 1600 | - eval('$img = ' . $a_type[1] . '::$typePicture;'); |
|
| 1601 | - eval('$explanation = get_lang(' . $a_type[1] . '::$explanationLangVar);'); |
|
| 1600 | + eval('$img = '.$a_type[1].'::$typePicture;'); |
|
| 1601 | + eval('$explanation = get_lang('.$a_type[1].'::$explanationLangVar);'); |
|
| 1602 | 1602 | echo '<li>'; |
| 1603 | 1603 | echo '<div class="icon-image">'; |
| 1604 | 1604 | if ($objExercise->exercise_was_added_in_lp == true) { |
| 1605 | 1605 | $img = pathinfo($img); |
| 1606 | - $img = $img['filename'] . '_na.' . $img['extension']; |
|
| 1606 | + $img = $img['filename'].'_na.'.$img['extension']; |
|
| 1607 | 1607 | echo Display::return_icon($img, $explanation, null, ICON_SIZE_BIG); |
| 1608 | 1608 | } else { |
| 1609 | - echo '<a href="admin.php?' . api_get_cidreq() . '&newQuestion=yes&answerType=' . $i . '">' . |
|
| 1610 | - Display::return_icon($img, $explanation, null, ICON_SIZE_BIG) . '</a>'; |
|
| 1609 | + echo '<a href="admin.php?'.api_get_cidreq().'&newQuestion=yes&answerType='.$i.'">'. |
|
| 1610 | + Display::return_icon($img, $explanation, null, ICON_SIZE_BIG).'</a>'; |
|
| 1611 | 1611 | } |
| 1612 | 1612 | echo '</div>'; |
| 1613 | 1613 | echo '</li>'; |
@@ -1619,9 +1619,9 @@ discard block |
||
| 1619 | 1619 | echo Display::return_icon('database_na.png', get_lang('GetExistingQuestion'), null, ICON_SIZE_BIG); |
| 1620 | 1620 | } else { |
| 1621 | 1621 | if ($feedback_type == 1) { |
| 1622 | - echo $url = "<a href=\"question_pool.php?" . api_get_cidreq() . "&type=1&fromExercise=$exerciseId\">"; |
|
| 1622 | + echo $url = "<a href=\"question_pool.php?".api_get_cidreq()."&type=1&fromExercise=$exerciseId\">"; |
|
| 1623 | 1623 | } else { |
| 1624 | - echo $url = '<a href="question_pool.php?' . api_get_cidreq() . '&fromExercise=' . $exerciseId . '">'; |
|
| 1624 | + echo $url = '<a href="question_pool.php?'.api_get_cidreq().'&fromExercise='.$exerciseId.'">'; |
|
| 1625 | 1625 | } |
| 1626 | 1626 | echo Display::return_icon('database.png', get_lang('GetExistingQuestion'), null, ICON_SIZE_BIG); |
| 1627 | 1627 | } |
@@ -1758,7 +1758,7 @@ discard block |
||
| 1758 | 1758 | $header .= $this->show_media_content(); |
| 1759 | 1759 | } |
| 1760 | 1760 | |
| 1761 | - $header .= Display::page_subheader2($counter_label . ". " . $question_title); |
|
| 1761 | + $header .= Display::page_subheader2($counter_label.". ".$question_title); |
|
| 1762 | 1762 | $header .= Display::div( |
| 1763 | 1763 | "<div class=\"rib rib-$class\"><h3>$score_label</h3></div> <h4>{$score['result']}</h4>", |
| 1764 | 1764 | array('class' => 'ribbon') |
@@ -1779,7 +1779,7 @@ discard block |
||
| 1779 | 1779 | public function create_question( |
| 1780 | 1780 | $quiz_id, |
| 1781 | 1781 | $question_name, |
| 1782 | - $question_description = "" , |
|
| 1782 | + $question_description = "", |
|
| 1783 | 1783 | $max_score = 0, |
| 1784 | 1784 | $type = 1, |
| 1785 | 1785 | $level = 1 |
@@ -1849,8 +1849,8 @@ discard block |
||
| 1849 | 1849 | require_once $tabQuestionList[$type][0]; |
| 1850 | 1850 | |
| 1851 | 1851 | $img = $explanation = null; |
| 1852 | - eval('$img = ' . $tabQuestionList[$type][1] . '::$typePicture;'); |
|
| 1853 | - eval('$explanation = get_lang(' . $tabQuestionList[$type][1] . '::$explanationLangVar);'); |
|
| 1852 | + eval('$img = '.$tabQuestionList[$type][1].'::$typePicture;'); |
|
| 1853 | + eval('$explanation = get_lang('.$tabQuestionList[$type][1].'::$explanationLangVar);'); |
|
| 1854 | 1854 | return array($img, $explanation); |
| 1855 | 1855 | } |
| 1856 | 1856 | |
@@ -1914,7 +1914,7 @@ discard block |
||
| 1914 | 1914 | $media_list[0] = get_lang('NoMedia'); |
| 1915 | 1915 | |
| 1916 | 1916 | if (!empty($medias)) { |
| 1917 | - foreach($medias as $media) { |
|
| 1917 | + foreach ($medias as $media) { |
|
| 1918 | 1918 | $media_list[$media['id']] = empty($media['question']) ? get_lang('Untitled') : $media['question']; |
| 1919 | 1919 | } |
| 1920 | 1920 | } |
@@ -607,10 +607,11 @@ |
||
| 607 | 607 | $current_width = $current_image_size['width']; |
| 608 | 608 | $current_height = $current_image_size['height']; |
| 609 | 609 | |
| 610 | - if ($current_width < $Max && $current_height < $Max) |
|
| 611 | - return true; |
|
| 612 | - elseif ($current_height == "") |
|
| 613 | - return false; |
|
| 610 | + if ($current_width < $Max && $current_height < $Max) { |
|
| 611 | + return true; |
|
| 612 | + } elseif ($current_height == "") { |
|
| 613 | + return false; |
|
| 614 | + } |
|
| 614 | 615 | |
| 615 | 616 | // Resize according to height. |
| 616 | 617 | if ($Dimension == "height") { |
@@ -474,6 +474,7 @@ discard block |
||
| 474 | 474 | |
| 475 | 475 | /** |
| 476 | 476 | * return a tab of $in_number random elements of $in_tab |
| 477 | + * @param integer $in_number |
|
| 477 | 478 | */ |
| 478 | 479 | public static function getNElementsFromArray($in_tab, $in_number) |
| 479 | 480 | { |
@@ -650,7 +651,6 @@ discard block |
||
| 650 | 651 | /** |
| 651 | 652 | * Return the id of the test category with title = $in_title |
| 652 | 653 | * @param $in_title |
| 653 | - * @param int $in_c_id |
|
| 654 | 654 | * |
| 655 | 655 | * @return int is id of test category |
| 656 | 656 | */ |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | * @param int $questionId |
| 679 | 679 | * @param int $courseId |
| 680 | 680 | * |
| 681 | - * @return int |
|
| 681 | + * @return string|false |
|
| 682 | 682 | */ |
| 683 | 683 | public static function add_category_for_question_id($categoryId, $questionId, $courseId) |
| 684 | 684 | { |
@@ -13,11 +13,11 @@ discard block |
||
| 13 | 13 | public $name; |
| 14 | 14 | public $description; |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Constructor of the class Category |
|
| 18 | - * If you give an in_id and no in_name, you get info concerning the category of id=in_id |
|
| 19 | - * otherwise, you've got an category objet avec your in_id, in_name, in_descr |
|
| 20 | - * |
|
| 16 | + /** |
|
| 17 | + * Constructor of the class Category |
|
| 18 | + * If you give an in_id and no in_name, you get info concerning the category of id=in_id |
|
| 19 | + * otherwise, you've got an category objet avec your in_id, in_name, in_descr |
|
| 20 | + * |
|
| 21 | 21 | * @param int $id |
| 22 | 22 | * @param string $name |
| 23 | 23 | * @param string $description |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - /** |
|
| 64 | + /** |
|
| 65 | 65 | * add TestCategory in the database if name doesn't already exists |
| 66 | - */ |
|
| 66 | + */ |
|
| 67 | 67 | public function addCategoryInBDD() |
| 68 | 68 | { |
| 69 | 69 | $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
@@ -108,12 +108,12 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | return false; |
| 110 | 110 | } |
| 111 | - } |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - /** |
|
| 113 | + /** |
|
| 114 | 114 | * Removes the category from the database |
| 115 | 115 | * if there were question in this category, the link between question and category is removed |
| 116 | - */ |
|
| 116 | + */ |
|
| 117 | 117 | public function removeCategory() |
| 118 | 118 | { |
| 119 | 119 | $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
@@ -143,11 +143,11 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | return true; |
| 145 | 145 | } |
| 146 | - } |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - /** |
|
| 148 | + /** |
|
| 149 | 149 | * Modify category name or description of category with id=in_id |
| 150 | - */ |
|
| 150 | + */ |
|
| 151 | 151 | public function modifyCategory() |
| 152 | 152 | { |
| 153 | 153 | $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
@@ -175,40 +175,40 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | return true; |
| 177 | 177 | } |
| 178 | - } |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - /** |
|
| 180 | + /** |
|
| 181 | 181 | * Gets the number of question of category id=in_id |
| 182 | - */ |
|
| 182 | + */ |
|
| 183 | 183 | public function getCategoryQuestionsNumber() |
| 184 | 184 | { |
| 185 | - $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
| 186 | - $in_id = intval($this->id); |
|
| 187 | - $sql = "SELECT count(*) AS nb |
|
| 185 | + $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
| 186 | + $in_id = intval($this->id); |
|
| 187 | + $sql = "SELECT count(*) AS nb |
|
| 188 | 188 | FROM $table |
| 189 | 189 | WHERE category_id=$in_id AND c_id=".api_get_course_int_id(); |
| 190 | - $res = Database::query($sql); |
|
| 191 | - $row = Database::fetch_array($res); |
|
| 190 | + $res = Database::query($sql); |
|
| 191 | + $row = Database::fetch_array($res); |
|
| 192 | 192 | |
| 193 | - return $row['nb']; |
|
| 194 | - } |
|
| 193 | + return $row['nb']; |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | 196 | /** |
| 197 | 197 | * @param string $in_color |
| 198 | 198 | */ |
| 199 | 199 | public function display($in_color="#E0EBF5") |
| 200 | 200 | { |
| 201 | - echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>"; |
|
| 202 | - print_r($this); |
|
| 203 | - echo "</textarea>"; |
|
| 204 | - } |
|
| 201 | + echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>"; |
|
| 202 | + print_r($this); |
|
| 203 | + echo "</textarea>"; |
|
| 204 | + } |
|
| 205 | 205 | |
| 206 | - /** |
|
| 206 | + /** |
|
| 207 | 207 | * Return an array of all Category objects in the database |
| 208 | - * If in_field=="" Return an array of all category objects in the database |
|
| 209 | - * Otherwise, return an array of all in_field value |
|
| 210 | - * in the database (in_field = id or name or description) |
|
| 211 | - */ |
|
| 208 | + * If in_field=="" Return an array of all category objects in the database |
|
| 209 | + * Otherwise, return an array of all in_field value |
|
| 210 | + * in the database (in_field = id or name or description) |
|
| 211 | + */ |
|
| 212 | 212 | public static function getCategoryListInfo($in_field = "", $courseId = "") |
| 213 | 213 | { |
| 214 | 214 | if (empty($courseId) || $courseId=="") { |
@@ -239,8 +239,8 @@ discard block |
||
| 239 | 239 | } |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - return $tabres; |
|
| 243 | - } |
|
| 242 | + return $tabres; |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | 245 | /** |
| 246 | 246 | * Return the TestCategory id for question with question_id = $questionId |
@@ -251,196 +251,196 @@ discard block |
||
| 251 | 251 | * |
| 252 | 252 | * @return int |
| 253 | 253 | */ |
| 254 | - public static function getCategoryForQuestion($questionId, $courseId ="") |
|
| 254 | + public static function getCategoryForQuestion($questionId, $courseId ="") |
|
| 255 | 255 | { |
| 256 | - $result = 0; |
|
| 256 | + $result = 0; |
|
| 257 | 257 | if (empty($courseId) || $courseId == "") { |
| 258 | 258 | $courseId = api_get_course_int_id(); |
| 259 | 259 | } |
| 260 | - $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
| 260 | + $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
| 261 | 261 | $questionId = intval($questionId); |
| 262 | - $sql = "SELECT category_id |
|
| 262 | + $sql = "SELECT category_id |
|
| 263 | 263 | FROM $table |
| 264 | 264 | WHERE question_id = $questionId AND c_id = $courseId"; |
| 265 | - $res = Database::query($sql); |
|
| 266 | - if (Database::num_rows($res) > 0) { |
|
| 265 | + $res = Database::query($sql); |
|
| 266 | + if (Database::num_rows($res) > 0) { |
|
| 267 | 267 | $data = Database::fetch_array($res); |
| 268 | - $result = $data['category_id']; |
|
| 269 | - } |
|
| 268 | + $result = $data['category_id']; |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | - return $result; |
|
| 272 | - } |
|
| 271 | + return $result; |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - /** |
|
| 275 | - * true if question id has a category |
|
| 276 | - */ |
|
| 277 | - public static function isQuestionHasCategory($questionId) |
|
| 274 | + /** |
|
| 275 | + * true if question id has a category |
|
| 276 | + */ |
|
| 277 | + public static function isQuestionHasCategory($questionId) |
|
| 278 | 278 | { |
| 279 | - if (TestCategory::getCategoryForQuestion($questionId) > 0) { |
|
| 280 | - return true; |
|
| 281 | - } |
|
| 282 | - return false; |
|
| 283 | - } |
|
| 279 | + if (TestCategory::getCategoryForQuestion($questionId) > 0) { |
|
| 280 | + return true; |
|
| 281 | + } |
|
| 282 | + return false; |
|
| 283 | + } |
|
| 284 | 284 | |
| 285 | - /** |
|
| 285 | + /** |
|
| 286 | 286 | Return the category name for question with question_id = $questionId |
| 287 | 287 | In this version, a question has only 1 category. |
| 288 | 288 | Return the category id, "" if none |
| 289 | - */ |
|
| 289 | + */ |
|
| 290 | 290 | public static function getCategoryNameForQuestion( |
| 291 | 291 | $questionId, |
| 292 | 292 | $courseId = "" |
| 293 | 293 | ) { |
| 294 | - if (empty($courseId) || $courseId=="") { |
|
| 295 | - $courseId = api_get_course_int_id(); |
|
| 296 | - } |
|
| 297 | - $catid = TestCategory::getCategoryForQuestion($questionId, $courseId); |
|
| 298 | - $result = ""; // result |
|
| 299 | - $table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
|
| 300 | - $catid = intval($catid); |
|
| 301 | - $sql = "SELECT title FROM $table |
|
| 294 | + if (empty($courseId) || $courseId=="") { |
|
| 295 | + $courseId = api_get_course_int_id(); |
|
| 296 | + } |
|
| 297 | + $catid = TestCategory::getCategoryForQuestion($questionId, $courseId); |
|
| 298 | + $result = ""; // result |
|
| 299 | + $table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
|
| 300 | + $catid = intval($catid); |
|
| 301 | + $sql = "SELECT title FROM $table |
|
| 302 | 302 | WHERE id = $catid AND c_id = $courseId"; |
| 303 | - $res = Database::query($sql); |
|
| 304 | - $data = Database::fetch_array($res); |
|
| 305 | - if (Database::num_rows($res) > 0) { |
|
| 306 | - $result = $data['title']; |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - return $result; |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - /** |
|
| 313 | - * Return the list of differents categories ID for a test in the current course |
|
| 314 | - * input : test_id |
|
| 315 | - * return : array of category id (integer) |
|
| 316 | - * hubert.borderiou 07-04-2011 |
|
| 317 | - */ |
|
| 318 | - public static function getListOfCategoriesIDForTest($in_testid) |
|
| 303 | + $res = Database::query($sql); |
|
| 304 | + $data = Database::fetch_array($res); |
|
| 305 | + if (Database::num_rows($res) > 0) { |
|
| 306 | + $result = $data['title']; |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + return $result; |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + /** |
|
| 313 | + * Return the list of differents categories ID for a test in the current course |
|
| 314 | + * input : test_id |
|
| 315 | + * return : array of category id (integer) |
|
| 316 | + * hubert.borderiou 07-04-2011 |
|
| 317 | + */ |
|
| 318 | + public static function getListOfCategoriesIDForTest($in_testid) |
|
| 319 | 319 | { |
| 320 | - // parcourir les questions d'un test, recup les categories uniques dans un tableau |
|
| 321 | - $result = array(); |
|
| 322 | - $quiz = new Exercise(); |
|
| 323 | - $quiz->read($in_testid); |
|
| 324 | - $tabQuestionList = $quiz->selectQuestionList(); |
|
| 325 | - // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ??? |
|
| 326 | - for ($i=1; $i <= count($tabQuestionList); $i++) { |
|
| 327 | - if (!in_array(TestCategory::getCategoryForQuestion($tabQuestionList[$i]), $result)) { |
|
| 328 | - $result[] = TestCategory::getCategoryForQuestion($tabQuestionList[$i]); |
|
| 329 | - } |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - return $result; |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - /** |
|
| 336 | - * return the list of different categories NAME for a test |
|
| 337 | - * input : test_id |
|
| 338 | - * return : array of string |
|
| 339 | - * hubert.borderiou 07-04-2011 |
|
| 320 | + // parcourir les questions d'un test, recup les categories uniques dans un tableau |
|
| 321 | + $result = array(); |
|
| 322 | + $quiz = new Exercise(); |
|
| 323 | + $quiz->read($in_testid); |
|
| 324 | + $tabQuestionList = $quiz->selectQuestionList(); |
|
| 325 | + // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ??? |
|
| 326 | + for ($i=1; $i <= count($tabQuestionList); $i++) { |
|
| 327 | + if (!in_array(TestCategory::getCategoryForQuestion($tabQuestionList[$i]), $result)) { |
|
| 328 | + $result[] = TestCategory::getCategoryForQuestion($tabQuestionList[$i]); |
|
| 329 | + } |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + return $result; |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + /** |
|
| 336 | + * return the list of different categories NAME for a test |
|
| 337 | + * input : test_id |
|
| 338 | + * return : array of string |
|
| 339 | + * hubert.borderiou 07-04-2011 |
|
| 340 | 340 | * @author function rewrote by jmontoya |
| 341 | - */ |
|
| 342 | - public static function getListOfCategoriesNameForTest($in_testid) |
|
| 341 | + */ |
|
| 342 | + public static function getListOfCategoriesNameForTest($in_testid) |
|
| 343 | 343 | { |
| 344 | - $tabcatName = array(); |
|
| 345 | - $tabcatID = self::getListOfCategoriesIDForTest($in_testid); |
|
| 346 | - for ($i=0; $i < count($tabcatID); $i++) { |
|
| 347 | - $cat = new TestCategory($tabcatID[$i]); |
|
| 348 | - $tabcatName[$cat->id] = $cat->name; |
|
| 349 | - } |
|
| 350 | - return $tabcatName; |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - /** |
|
| 354 | - * return the number of differents categories for a test |
|
| 355 | - * input : test_id |
|
| 356 | - * return : integer |
|
| 357 | - * hubert.borderiou 07-04-2011 |
|
| 358 | - */ |
|
| 359 | - public static function getNumberOfCategoriesForTest($in_testid) |
|
| 344 | + $tabcatName = array(); |
|
| 345 | + $tabcatID = self::getListOfCategoriesIDForTest($in_testid); |
|
| 346 | + for ($i=0; $i < count($tabcatID); $i++) { |
|
| 347 | + $cat = new TestCategory($tabcatID[$i]); |
|
| 348 | + $tabcatName[$cat->id] = $cat->name; |
|
| 349 | + } |
|
| 350 | + return $tabcatName; |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + /** |
|
| 354 | + * return the number of differents categories for a test |
|
| 355 | + * input : test_id |
|
| 356 | + * return : integer |
|
| 357 | + * hubert.borderiou 07-04-2011 |
|
| 358 | + */ |
|
| 359 | + public static function getNumberOfCategoriesForTest($in_testid) |
|
| 360 | 360 | { |
| 361 | - return count(TestCategory::getListOfCategoriesIDForTest($in_testid)); |
|
| 362 | - } |
|
| 361 | + return count(TestCategory::getListOfCategoriesIDForTest($in_testid)); |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | - /** |
|
| 365 | - * return the number of question of a category id in a test |
|
| 366 | - * @param int $exerciseId |
|
| 364 | + /** |
|
| 365 | + * return the number of question of a category id in a test |
|
| 366 | + * @param int $exerciseId |
|
| 367 | 367 | * @param int $categoryId |
| 368 | 368 | * |
| 369 | - * @return integer |
|
| 369 | + * @return integer |
|
| 370 | 370 | * |
| 371 | - * @author hubert.borderiou 07-04-2011 |
|
| 372 | - */ |
|
| 373 | - public static function getNumberOfQuestionsInCategoryForTest($exerciseId, $categoryId) |
|
| 371 | + * @author hubert.borderiou 07-04-2011 |
|
| 372 | + */ |
|
| 373 | + public static function getNumberOfQuestionsInCategoryForTest($exerciseId, $categoryId) |
|
| 374 | 374 | { |
| 375 | - $nbCatResult = 0; |
|
| 376 | - $quiz = new Exercise(); |
|
| 377 | - $quiz->read($exerciseId); |
|
| 378 | - $tabQuestionList = $quiz->selectQuestionList(); |
|
| 379 | - // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ? |
|
| 380 | - for ($i=1; $i <= count($tabQuestionList); $i++) { |
|
| 381 | - if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) { |
|
| 382 | - $nbCatResult++; |
|
| 383 | - } |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - return $nbCatResult; |
|
| 387 | - } |
|
| 388 | - |
|
| 389 | - /** |
|
| 390 | - * return the number of question for a test using random by category |
|
| 391 | - * input : test_id, number of random question (min 1) |
|
| 392 | - * hubert.borderiou 07-04-2011 |
|
| 393 | - * question without categories are not counted |
|
| 394 | - */ |
|
| 395 | - public static function getNumberOfQuestionRandomByCategory($exerciseId, $in_nbrandom) |
|
| 375 | + $nbCatResult = 0; |
|
| 376 | + $quiz = new Exercise(); |
|
| 377 | + $quiz->read($exerciseId); |
|
| 378 | + $tabQuestionList = $quiz->selectQuestionList(); |
|
| 379 | + // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ? |
|
| 380 | + for ($i=1; $i <= count($tabQuestionList); $i++) { |
|
| 381 | + if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) { |
|
| 382 | + $nbCatResult++; |
|
| 383 | + } |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + return $nbCatResult; |
|
| 387 | + } |
|
| 388 | + |
|
| 389 | + /** |
|
| 390 | + * return the number of question for a test using random by category |
|
| 391 | + * input : test_id, number of random question (min 1) |
|
| 392 | + * hubert.borderiou 07-04-2011 |
|
| 393 | + * question without categories are not counted |
|
| 394 | + */ |
|
| 395 | + public static function getNumberOfQuestionRandomByCategory($exerciseId, $in_nbrandom) |
|
| 396 | 396 | { |
| 397 | - $nbquestionresult = 0; |
|
| 398 | - $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId); |
|
| 399 | - for ($i=0; $i < count($tabcatid); $i++) { |
|
| 400 | - if ($tabcatid[$i] > 0) { // 0 = no category for this questio |
|
| 401 | - $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]); |
|
| 402 | - if ($nbQuestionInThisCat > $in_nbrandom) { |
|
| 403 | - $nbquestionresult += $in_nbrandom; |
|
| 404 | - } |
|
| 405 | - else { |
|
| 406 | - $nbquestionresult += $nbQuestionInThisCat; |
|
| 407 | - } |
|
| 408 | - } |
|
| 409 | - } |
|
| 410 | - return $nbquestionresult; |
|
| 411 | - } |
|
| 412 | - |
|
| 413 | - /** |
|
| 414 | - * Return an array (id=>name) |
|
| 415 | - * tabresult[0] = get_lang('NoCategory'); |
|
| 397 | + $nbquestionresult = 0; |
|
| 398 | + $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId); |
|
| 399 | + for ($i=0; $i < count($tabcatid); $i++) { |
|
| 400 | + if ($tabcatid[$i] > 0) { // 0 = no category for this questio |
|
| 401 | + $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]); |
|
| 402 | + if ($nbQuestionInThisCat > $in_nbrandom) { |
|
| 403 | + $nbquestionresult += $in_nbrandom; |
|
| 404 | + } |
|
| 405 | + else { |
|
| 406 | + $nbquestionresult += $nbQuestionInThisCat; |
|
| 407 | + } |
|
| 408 | + } |
|
| 409 | + } |
|
| 410 | + return $nbquestionresult; |
|
| 411 | + } |
|
| 412 | + |
|
| 413 | + /** |
|
| 414 | + * Return an array (id=>name) |
|
| 415 | + * tabresult[0] = get_lang('NoCategory'); |
|
| 416 | 416 | * |
| 417 | 417 | * @param int $courseId |
| 418 | 418 | * |
| 419 | 419 | * @return array |
| 420 | - * |
|
| 421 | - */ |
|
| 420 | + * |
|
| 421 | + */ |
|
| 422 | 422 | public static function getCategoriesIdAndName($courseId = "") |
| 423 | 423 | { |
| 424 | - if (empty($courseId)) { |
|
| 425 | - $courseId = api_get_course_int_id(); |
|
| 426 | - } |
|
| 427 | - $tabcatobject = TestCategory::getCategoryListInfo("", $courseId); |
|
| 428 | - $tabresult = array("0"=>get_lang('NoCategorySelected')); |
|
| 429 | - for ($i=0; $i < count($tabcatobject); $i++) { |
|
| 430 | - $tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name; |
|
| 431 | - } |
|
| 432 | - return $tabresult; |
|
| 433 | - } |
|
| 424 | + if (empty($courseId)) { |
|
| 425 | + $courseId = api_get_course_int_id(); |
|
| 426 | + } |
|
| 427 | + $tabcatobject = TestCategory::getCategoryListInfo("", $courseId); |
|
| 428 | + $tabresult = array("0"=>get_lang('NoCategorySelected')); |
|
| 429 | + for ($i=0; $i < count($tabcatobject); $i++) { |
|
| 430 | + $tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name; |
|
| 431 | + } |
|
| 432 | + return $tabresult; |
|
| 433 | + } |
|
| 434 | 434 | |
| 435 | 435 | /** |
| 436 | - * return an array of question_id for each category |
|
| 437 | - * tabres[0] = array of question id with category id = 0 (i.e. no category) |
|
| 438 | - * tabres[24] = array of question id with category id = 24 |
|
| 439 | - * In this version, a question has 0 or 1 category |
|
| 440 | - * |
|
| 441 | - * @param int $exerciseId |
|
| 442 | - * @return array |
|
| 443 | - */ |
|
| 436 | + * return an array of question_id for each category |
|
| 437 | + * tabres[0] = array of question id with category id = 0 (i.e. no category) |
|
| 438 | + * tabres[24] = array of question id with category id = 24 |
|
| 439 | + * In this version, a question has 0 or 1 category |
|
| 440 | + * |
|
| 441 | + * @param int $exerciseId |
|
| 442 | + * @return array |
|
| 443 | + */ |
|
| 444 | 444 | public static function getQuestionsByCat($exerciseId) |
| 445 | 445 | { |
| 446 | 446 | $em = Database::getManager(); |
@@ -469,29 +469,29 @@ discard block |
||
| 469 | 469 | } |
| 470 | 470 | $list[$data['categoryId']][] = $data['questionId']; |
| 471 | 471 | } |
| 472 | - return $list; |
|
| 473 | - } |
|
| 472 | + return $list; |
|
| 473 | + } |
|
| 474 | 474 | |
| 475 | - /** |
|
| 476 | - * return a tab of $in_number random elements of $in_tab |
|
| 477 | - */ |
|
| 475 | + /** |
|
| 476 | + * return a tab of $in_number random elements of $in_tab |
|
| 477 | + */ |
|
| 478 | 478 | public static function getNElementsFromArray($in_tab, $in_number) |
| 479 | 479 | { |
| 480 | - $tabres = $in_tab; |
|
| 481 | - shuffle($tabres); |
|
| 482 | - if ($in_number < count($tabres)) { |
|
| 483 | - $tabres = array_slice($tabres, 0, $in_number); |
|
| 484 | - } |
|
| 485 | - return $tabres; |
|
| 486 | - } |
|
| 487 | - |
|
| 488 | - /** |
|
| 489 | - * display the category |
|
| 490 | - */ |
|
| 491 | - public static function displayCategoryAndTitle($questionId, $in_display_category_name = 1) |
|
| 480 | + $tabres = $in_tab; |
|
| 481 | + shuffle($tabres); |
|
| 482 | + if ($in_number < count($tabres)) { |
|
| 483 | + $tabres = array_slice($tabres, 0, $in_number); |
|
| 484 | + } |
|
| 485 | + return $tabres; |
|
| 486 | + } |
|
| 487 | + |
|
| 488 | + /** |
|
| 489 | + * display the category |
|
| 490 | + */ |
|
| 491 | + public static function displayCategoryAndTitle($questionId, $in_display_category_name = 1) |
|
| 492 | 492 | { |
| 493 | 493 | echo self::returnCategoryAndTitle($questionId, $in_display_category_name); |
| 494 | - } |
|
| 494 | + } |
|
| 495 | 495 | |
| 496 | 496 | /** |
| 497 | 497 | * @param int $questionId |
@@ -507,71 +507,71 @@ discard block |
||
| 507 | 507 | $in_display_category_name = $objExercise->display_category_name; |
| 508 | 508 | } |
| 509 | 509 | $content = null; |
| 510 | - if (TestCategory::getCategoryNameForQuestion($questionId) != "" && ($in_display_category_name == 1 || !$is_student)) { |
|
| 510 | + if (TestCategory::getCategoryNameForQuestion($questionId) != "" && ($in_display_category_name == 1 || !$is_student)) { |
|
| 511 | 511 | $content .= '<div class="page-header">'; |
| 512 | 512 | $content .= '<h4>'.get_lang('Category').": ".TestCategory::getCategoryNameForQuestion($questionId).'</h4>'; |
| 513 | 513 | $content .= "</div>"; |
| 514 | - } |
|
| 514 | + } |
|
| 515 | 515 | return $content; |
| 516 | - } |
|
| 516 | + } |
|
| 517 | 517 | |
| 518 | 518 | /** |
| 519 | - * Display signs [+] and/or (>0) after question title if question has options |
|
| 520 | - * scoreAlwaysPositive and/or uncheckedMayScore |
|
| 521 | - */ |
|
| 519 | + * Display signs [+] and/or (>0) after question title if question has options |
|
| 520 | + * scoreAlwaysPositive and/or uncheckedMayScore |
|
| 521 | + */ |
|
| 522 | 522 | public function displayQuestionOption($in_objQuestion) |
| 523 | 523 | { |
| 524 | - if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->scoreAlwaysPositive) { |
|
| 525 | - echo "<span style='font-size:75%'> (>0)</span>"; |
|
| 526 | - } |
|
| 527 | - if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->uncheckedMayScore) { |
|
| 528 | - echo "<span style='font-size:75%'> [+]</span>"; |
|
| 529 | - } |
|
| 530 | - } |
|
| 531 | - |
|
| 532 | - /** |
|
| 533 | - * sortTabByBracketLabel ($tabCategoryQuestions) |
|
| 534 | - * key of $tabCategoryQuestions are the category id (0 for not in a category) |
|
| 535 | - * value is the array of question id of this category |
|
| 536 | - * Sort question by Category |
|
| 537 | - */ |
|
| 524 | + if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->scoreAlwaysPositive) { |
|
| 525 | + echo "<span style='font-size:75%'> (>0)</span>"; |
|
| 526 | + } |
|
| 527 | + if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->uncheckedMayScore) { |
|
| 528 | + echo "<span style='font-size:75%'> [+]</span>"; |
|
| 529 | + } |
|
| 530 | + } |
|
| 531 | + |
|
| 532 | + /** |
|
| 533 | + * sortTabByBracketLabel ($tabCategoryQuestions) |
|
| 534 | + * key of $tabCategoryQuestions are the category id (0 for not in a category) |
|
| 535 | + * value is the array of question id of this category |
|
| 536 | + * Sort question by Category |
|
| 537 | + */ |
|
| 538 | 538 | public static function sortTabByBracketLabel($in_tab) |
| 539 | 539 | { |
| 540 | - $tabResult = array(); |
|
| 541 | - $tabCatName = array(); // tab of category name |
|
| 542 | - while (list($cat_id, $tabquestion) = each($in_tab)) { |
|
| 543 | - $catTitle = new TestCategory($cat_id); |
|
| 544 | - $tabCatName[$cat_id] = $catTitle->name; |
|
| 545 | - } |
|
| 546 | - reset($in_tab); |
|
| 547 | - // sort table by value, keeping keys as they are |
|
| 548 | - asort($tabCatName); |
|
| 549 | - // keys of $tabCatName are keys order for $in_tab |
|
| 550 | - while (list($key, $val) = each($tabCatName)) { |
|
| 551 | - $tabResult[$key] = $in_tab[$key]; |
|
| 552 | - } |
|
| 553 | - return $tabResult; |
|
| 554 | - } |
|
| 540 | + $tabResult = array(); |
|
| 541 | + $tabCatName = array(); // tab of category name |
|
| 542 | + while (list($cat_id, $tabquestion) = each($in_tab)) { |
|
| 543 | + $catTitle = new TestCategory($cat_id); |
|
| 544 | + $tabCatName[$cat_id] = $catTitle->name; |
|
| 545 | + } |
|
| 546 | + reset($in_tab); |
|
| 547 | + // sort table by value, keeping keys as they are |
|
| 548 | + asort($tabCatName); |
|
| 549 | + // keys of $tabCatName are keys order for $in_tab |
|
| 550 | + while (list($key, $val) = each($tabCatName)) { |
|
| 551 | + $tabResult[$key] = $in_tab[$key]; |
|
| 552 | + } |
|
| 553 | + return $tabResult; |
|
| 554 | + } |
|
| 555 | 555 | |
| 556 | 556 | /** |
| 557 | 557 | * return the number max of question in a category |
| 558 | 558 | * count the number of questions in all categories, and return the max |
| 559 | 559 | * @param int $exerciseId |
| 560 | 560 | * @author - hubert borderiou |
| 561 | - */ |
|
| 561 | + */ |
|
| 562 | 562 | public static function getNumberMaxQuestionByCat($exerciseId) |
| 563 | 563 | { |
| 564 | 564 | $res_num_max = 0; |
| 565 | 565 | // foreach question |
| 566 | - $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId); |
|
| 567 | - for ($i=0; $i < count($tabcatid); $i++) { |
|
| 568 | - if ($tabcatid[$i] > 0) { // 0 = no category for this question |
|
| 569 | - $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]); |
|
| 566 | + $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId); |
|
| 567 | + for ($i=0; $i < count($tabcatid); $i++) { |
|
| 568 | + if ($tabcatid[$i] > 0) { // 0 = no category for this question |
|
| 569 | + $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]); |
|
| 570 | 570 | if ($nbQuestionInThisCat > $res_num_max) { |
| 571 | 571 | $res_num_max = $nbQuestionInThisCat; |
| 572 | 572 | } |
| 573 | - } |
|
| 574 | - } |
|
| 573 | + } |
|
| 574 | + } |
|
| 575 | 575 | return $res_num_max; |
| 576 | 576 | } |
| 577 | 577 | |
@@ -677,8 +677,8 @@ discard block |
||
| 677 | 677 | * @param int $categoryId |
| 678 | 678 | * @param int $questionId |
| 679 | 679 | * @param int $courseId |
| 680 | - * |
|
| 681 | - * @return int |
|
| 680 | + * |
|
| 681 | + * @return int |
|
| 682 | 682 | */ |
| 683 | 683 | public static function add_category_for_question_id($categoryId, $questionId, $courseId) |
| 684 | 684 | { |
@@ -686,18 +686,18 @@ discard block |
||
| 686 | 686 | // if question doesn't have a category |
| 687 | 687 | // @todo change for 1.10 when a question can have several categories |
| 688 | 688 | if (TestCategory::getCategoryForQuestion($questionId, $courseId) == 0 && |
| 689 | - $questionId > 0 && |
|
| 690 | - $courseId > 0 |
|
| 689 | + $questionId > 0 && |
|
| 690 | + $courseId > 0 |
|
| 691 | 691 | ) { |
| 692 | 692 | $sql = "INSERT INTO $table (c_id, question_id, category_id) |
| 693 | 693 | VALUES (".intval($courseId).", ".intval($questionId).", ".intval($categoryId).")"; |
| 694 | 694 | Database::query($sql); |
| 695 | - $id = Database::insert_id(); |
|
| 695 | + $id = Database::insert_id(); |
|
| 696 | 696 | |
| 697 | - return $id; |
|
| 697 | + return $id; |
|
| 698 | 698 | } |
| 699 | 699 | |
| 700 | - return false; |
|
| 700 | + return false; |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | /** |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $row = Database::fetch_array($res); |
| 58 | 58 | $this->id = $row['id']; |
| 59 | 59 | $this->name = $row['title']; |
| 60 | - $this->description = $row['description']; |
|
| 60 | + $this->description = $row['description']; |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | /** |
| 197 | 197 | * @param string $in_color |
| 198 | 198 | */ |
| 199 | - public function display($in_color="#E0EBF5") |
|
| 199 | + public function display($in_color = "#E0EBF5") |
|
| 200 | 200 | { |
| 201 | 201 | echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>"; |
| 202 | 202 | print_r($this); |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | public static function getCategoryListInfo($in_field = "", $courseId = "") |
| 213 | 213 | { |
| 214 | - if (empty($courseId) || $courseId=="") { |
|
| 214 | + if (empty($courseId) || $courseId == "") { |
|
| 215 | 215 | $courseId = api_get_course_int_id(); |
| 216 | 216 | } |
| 217 | 217 | $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * |
| 252 | 252 | * @return int |
| 253 | 253 | */ |
| 254 | - public static function getCategoryForQuestion($questionId, $courseId ="") |
|
| 254 | + public static function getCategoryForQuestion($questionId, $courseId = "") |
|
| 255 | 255 | { |
| 256 | 256 | $result = 0; |
| 257 | 257 | if (empty($courseId) || $courseId == "") { |
@@ -291,11 +291,11 @@ discard block |
||
| 291 | 291 | $questionId, |
| 292 | 292 | $courseId = "" |
| 293 | 293 | ) { |
| 294 | - if (empty($courseId) || $courseId=="") { |
|
| 294 | + if (empty($courseId) || $courseId == "") { |
|
| 295 | 295 | $courseId = api_get_course_int_id(); |
| 296 | 296 | } |
| 297 | 297 | $catid = TestCategory::getCategoryForQuestion($questionId, $courseId); |
| 298 | - $result = ""; // result |
|
| 298 | + $result = ""; // result |
|
| 299 | 299 | $table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
| 300 | 300 | $catid = intval($catid); |
| 301 | 301 | $sql = "SELECT title FROM $table |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | $quiz->read($in_testid); |
| 324 | 324 | $tabQuestionList = $quiz->selectQuestionList(); |
| 325 | 325 | // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ??? |
| 326 | - for ($i=1; $i <= count($tabQuestionList); $i++) { |
|
| 326 | + for ($i = 1; $i <= count($tabQuestionList); $i++) { |
|
| 327 | 327 | if (!in_array(TestCategory::getCategoryForQuestion($tabQuestionList[$i]), $result)) { |
| 328 | 328 | $result[] = TestCategory::getCategoryForQuestion($tabQuestionList[$i]); |
| 329 | 329 | } |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | { |
| 344 | 344 | $tabcatName = array(); |
| 345 | 345 | $tabcatID = self::getListOfCategoriesIDForTest($in_testid); |
| 346 | - for ($i=0; $i < count($tabcatID); $i++) { |
|
| 346 | + for ($i = 0; $i < count($tabcatID); $i++) { |
|
| 347 | 347 | $cat = new TestCategory($tabcatID[$i]); |
| 348 | 348 | $tabcatName[$cat->id] = $cat->name; |
| 349 | 349 | } |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | $quiz->read($exerciseId); |
| 378 | 378 | $tabQuestionList = $quiz->selectQuestionList(); |
| 379 | 379 | // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ? |
| 380 | - for ($i=1; $i <= count($tabQuestionList); $i++) { |
|
| 380 | + for ($i = 1; $i <= count($tabQuestionList); $i++) { |
|
| 381 | 381 | if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) { |
| 382 | 382 | $nbCatResult++; |
| 383 | 383 | } |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | { |
| 397 | 397 | $nbquestionresult = 0; |
| 398 | 398 | $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId); |
| 399 | - for ($i=0; $i < count($tabcatid); $i++) { |
|
| 399 | + for ($i = 0; $i < count($tabcatid); $i++) { |
|
| 400 | 400 | if ($tabcatid[$i] > 0) { // 0 = no category for this questio |
| 401 | 401 | $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]); |
| 402 | 402 | if ($nbQuestionInThisCat > $in_nbrandom) { |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | } |
| 427 | 427 | $tabcatobject = TestCategory::getCategoryListInfo("", $courseId); |
| 428 | 428 | $tabresult = array("0"=>get_lang('NoCategorySelected')); |
| 429 | - for ($i=0; $i < count($tabcatobject); $i++) { |
|
| 429 | + for ($i = 0; $i < count($tabcatobject); $i++) { |
|
| 430 | 430 | $tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name; |
| 431 | 431 | } |
| 432 | 432 | return $tabresult; |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | */ |
| 501 | 501 | public static function returnCategoryAndTitle($questionId, $in_display_category_name = 1) |
| 502 | 502 | { |
| 503 | - $is_student = !(api_is_allowed_to_edit(null,true) || api_is_session_admin()); |
|
| 503 | + $is_student = !(api_is_allowed_to_edit(null, true) || api_is_session_admin()); |
|
| 504 | 504 | // @todo fix $_SESSION['objExercise'] |
| 505 | 505 | $objExercise = isset($_SESSION['objExercise']) ? $_SESSION['objExercise'] : null; |
| 506 | 506 | if (!empty($objExercise)) { |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | public static function sortTabByBracketLabel($in_tab) |
| 539 | 539 | { |
| 540 | 540 | $tabResult = array(); |
| 541 | - $tabCatName = array(); // tab of category name |
|
| 541 | + $tabCatName = array(); // tab of category name |
|
| 542 | 542 | while (list($cat_id, $tabquestion) = each($in_tab)) { |
| 543 | 543 | $catTitle = new TestCategory($cat_id); |
| 544 | 544 | $tabCatName[$cat_id] = $catTitle->name; |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | $res_num_max = 0; |
| 565 | 565 | // foreach question |
| 566 | 566 | $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId); |
| 567 | - for ($i=0; $i < count($tabcatid); $i++) { |
|
| 567 | + for ($i = 0; $i < count($tabcatid); $i++) { |
|
| 568 | 568 | if ($tabcatid[$i] > 0) { // 0 = no category for this question |
| 569 | 569 | $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]); |
| 570 | 570 | if ($nbQuestionInThisCat > $res_num_max) { |
@@ -750,20 +750,20 @@ discard block |
||
| 750 | 750 | $tmpobj = new TestCategory($category['id']); |
| 751 | 751 | $nb_question = $tmpobj->getCategoryQuestionsNumber(); |
| 752 | 752 | $rowname = self::protectJSDialogQuote($category['title']); |
| 753 | - $nb_question_label = $nb_question == 1 ? $nb_question . ' ' . get_lang('Question') : $nb_question . ' ' . get_lang('Questions'); |
|
| 753 | + $nb_question_label = $nb_question == 1 ? $nb_question.' '.get_lang('Question') : $nb_question.' '.get_lang('Questions'); |
|
| 754 | 754 | |
| 755 | 755 | //$html .= '<div class="sectiontitle" id="id_cat' . $category['id'] . '">'; |
| 756 | - $content = "<span style='float:right'>" . $nb_question_label . "</span>"; |
|
| 756 | + $content = "<span style='float:right'>".$nb_question_label."</span>"; |
|
| 757 | 757 | |
| 758 | 758 | $content .= '<div class="sectioncomment">'; |
| 759 | 759 | $content .= $category['description']; |
| 760 | 760 | $content .= '</div>'; |
| 761 | 761 | |
| 762 | - $links = '<a href="' . api_get_self() . '?action=editcategory&category_id=' . $category['id'] . '">' . |
|
| 763 | - Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>'; |
|
| 764 | - $links .= ' <a href="' . api_get_self() . '?action=deletecategory&category_id=' . $category['id'] . '" '; |
|
| 765 | - $links .= 'onclick="return confirmDelete(\'' . self::protectJSDialogQuote(get_lang('DeleteCategoryAreYouSure') . '[' . $rowname) . '] ?\', \'id_cat' . $category['id'] . '\');">'; |
|
| 766 | - $links .= Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; |
|
| 762 | + $links = '<a href="'.api_get_self().'?action=editcategory&category_id='.$category['id'].'">'. |
|
| 763 | + Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>'; |
|
| 764 | + $links .= ' <a href="'.api_get_self().'?action=deletecategory&category_id='.$category['id'].'" '; |
|
| 765 | + $links .= 'onclick="return confirmDelete(\''.self::protectJSDialogQuote(get_lang('DeleteCategoryAreYouSure').'['.$rowname).'] ?\', \'id_cat'.$category['id'].'\');">'; |
|
| 766 | + $links .= Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>'; |
|
| 767 | 767 | $html .= Display::panel($content, $category['title'].$links); |
| 768 | 768 | } |
| 769 | 769 | |
@@ -401,8 +401,7 @@ |
||
| 401 | 401 | $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]); |
| 402 | 402 | if ($nbQuestionInThisCat > $in_nbrandom) { |
| 403 | 403 | $nbquestionresult += $in_nbrandom; |
| 404 | - } |
|
| 405 | - else { |
|
| 404 | + } else { |
|
| 406 | 405 | $nbquestionresult += $nbQuestionInThisCat; |
| 407 | 406 | } |
| 408 | 407 | } |
@@ -417,8 +417,8 @@ |
||
| 417 | 417 | * @param int $question_id The question ID (to which the answer is attached) |
| 418 | 418 | * @param string $title The text of the answer |
| 419 | 419 | * @param string $comment The feedback for the answer |
| 420 | - * @param float|null $score The score you get when picking this answer |
|
| 421 | - * @param int|null $correct Whether this answer is considered *the* correct one (this is the unique answer type) |
|
| 420 | + * @param double $score The score you get when picking this answer |
|
| 421 | + * @param integer $correct Whether this answer is considered *the* correct one (this is the unique answer type) |
|
| 422 | 422 | */ |
| 423 | 423 | public function addAnswer( |
| 424 | 424 | $id, |
@@ -447,7 +447,7 @@ |
||
| 447 | 447 | $position = $row_max->max_position + 1; |
| 448 | 448 | |
| 449 | 449 | // Insert a new answer |
| 450 | - $params = [ |
|
| 450 | + $params = [ |
|
| 451 | 451 | 'c_id' => $course_id, |
| 452 | 452 | 'id' => $id, |
| 453 | 453 | 'question_id' => $question_id, |
@@ -59,21 +59,21 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { |
| 61 | 61 | //Scenario |
| 62 | - $comment_title = '<th width="20%">' . get_lang('Comment') . '</th>'; |
|
| 63 | - $feedback_title = '<th width="20%">' . get_lang('Scenario') . '</th>'; |
|
| 62 | + $comment_title = '<th width="20%">'.get_lang('Comment').'</th>'; |
|
| 63 | + $feedback_title = '<th width="20%">'.get_lang('Scenario').'</th>'; |
|
| 64 | 64 | } else { |
| 65 | - $comment_title = '<th width="40%">' . get_lang('Comment') . '</th>'; |
|
| 65 | + $comment_title = '<th width="40%">'.get_lang('Comment').'</th>'; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | $html = '<table class="table table-striped table-hover"> |
| 69 | 69 | <thead> |
| 70 | 70 | <tr style="text-align: center;"> |
| 71 | - <th width="5%">' . get_lang('Number') . '</th> |
|
| 72 | - <th width="5%"> ' . get_lang('True') . '</th> |
|
| 73 | - <th width="40%">' . get_lang('Answer') . '</th> |
|
| 74 | - ' . $comment_title . ' |
|
| 75 | - ' . $feedback_title . ' |
|
| 76 | - <th width="10%">' . get_lang('Weighting') . '</th> |
|
| 71 | + <th width="5%">' . get_lang('Number').'</th> |
|
| 72 | + <th width="5%"> ' . get_lang('True').'</th> |
|
| 73 | + <th width="40%">' . get_lang('Answer').'</th> |
|
| 74 | + ' . $comment_title.' |
|
| 75 | + ' . $feedback_title.' |
|
| 76 | + <th width="10%">' . get_lang('Weighting').'</th> |
|
| 77 | 77 | </tr> |
| 78 | 78 | </thead> |
| 79 | 79 | <tbody>'; |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | continue; |
| 104 | 104 | } |
| 105 | 105 | $question = Question::read($questionid); |
| 106 | - $select_question[$questionid] = 'Q' . $key . ' :' . cut( |
|
| 106 | + $select_question[$questionid] = 'Q'.$key.' :'.cut( |
|
| 107 | 107 | $question->selectTitle(), 20 |
| 108 | 108 | ); |
| 109 | 109 | } |
@@ -134,9 +134,9 @@ discard block |
||
| 134 | 134 | if ($answer->correct[$i]) { |
| 135 | 135 | $correct = $i; |
| 136 | 136 | } |
| 137 | - $defaults['answer[' . $i . ']'] = $answer->answer[$i]; |
|
| 138 | - $defaults['comment[' . $i . ']'] = $answer->comment[$i]; |
|
| 139 | - $defaults['weighting[' . $i . ']'] = float_format( |
|
| 137 | + $defaults['answer['.$i.']'] = $answer->answer[$i]; |
|
| 138 | + $defaults['comment['.$i.']'] = $answer->comment[$i]; |
|
| 139 | + $defaults['weighting['.$i.']'] = float_format( |
|
| 140 | 140 | $answer->weighting[$i], |
| 141 | 141 | 1 |
| 142 | 142 | ); |
@@ -159,18 +159,18 @@ discard block |
||
| 159 | 159 | $url_result = $url; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - $temp_scenario['url' . $i] = $url_result; |
|
| 163 | - $temp_scenario['try' . $i] = $try_result; |
|
| 164 | - $temp_scenario['lp' . $i] = $lp; |
|
| 165 | - $temp_scenario['destination' . $i] = $list_dest; |
|
| 162 | + $temp_scenario['url'.$i] = $url_result; |
|
| 163 | + $temp_scenario['try'.$i] = $try_result; |
|
| 164 | + $temp_scenario['lp'.$i] = $lp; |
|
| 165 | + $temp_scenario['destination'.$i] = $list_dest; |
|
| 166 | 166 | } else { |
| 167 | 167 | $defaults['answer[1]'] = get_lang('DefaultUniqueAnswer1'); |
| 168 | 168 | $defaults['weighting[1]'] = 10; |
| 169 | 169 | $defaults['answer[2]'] = get_lang('DefaultUniqueAnswer2'); |
| 170 | 170 | $defaults['weighting[2]'] = 0; |
| 171 | 171 | |
| 172 | - $temp_scenario['destination' . $i] = array('0'); |
|
| 173 | - $temp_scenario['lp' . $i] = array('0'); |
|
| 172 | + $temp_scenario['destination'.$i] = array('0'); |
|
| 173 | + $temp_scenario['lp'.$i] = array('0'); |
|
| 174 | 174 | } |
| 175 | 175 | $defaults['scenario'] = $temp_scenario; |
| 176 | 176 | |
@@ -182,62 +182,62 @@ discard block |
||
| 182 | 182 | ); |
| 183 | 183 | $renderer->setElementTemplate( |
| 184 | 184 | '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', |
| 185 | - 'counter[' . $i . ']' |
|
| 185 | + 'counter['.$i.']' |
|
| 186 | 186 | ); |
| 187 | 187 | $renderer->setElementTemplate( |
| 188 | 188 | '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', |
| 189 | - 'answer[' . $i . ']' |
|
| 189 | + 'answer['.$i.']' |
|
| 190 | 190 | ); |
| 191 | 191 | $renderer->setElementTemplate( |
| 192 | 192 | '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', |
| 193 | - 'comment[' . $i . ']' |
|
| 193 | + 'comment['.$i.']' |
|
| 194 | 194 | ); |
| 195 | 195 | $renderer->setElementTemplate( |
| 196 | 196 | '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', |
| 197 | - 'weighting[' . $i . ']' |
|
| 197 | + 'weighting['.$i.']' |
|
| 198 | 198 | ); |
| 199 | 199 | |
| 200 | 200 | $answer_number = $form->addElement( |
| 201 | - 'text', 'counter[' . $i . ']', null, ' value = "' . $i . '"' |
|
| 201 | + 'text', 'counter['.$i.']', null, ' value = "'.$i.'"' |
|
| 202 | 202 | ); |
| 203 | 203 | $answer_number->freeze(); |
| 204 | 204 | $form->addElement( |
| 205 | 205 | 'radio', 'correct', null, null, $i, 'class="checkbox"' |
| 206 | 206 | ); |
| 207 | 207 | |
| 208 | - $form->addHtmlEditor('answer[' . $i . ']', null, null, true, $editor_config); |
|
| 208 | + $form->addHtmlEditor('answer['.$i.']', null, null, true, $editor_config); |
|
| 209 | 209 | |
| 210 | 210 | $form->addRule( |
| 211 | - 'answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required' |
|
| 211 | + 'answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required' |
|
| 212 | 212 | ); |
| 213 | 213 | |
| 214 | 214 | if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { |
| 215 | - $form->addHtmlEditor('comment[' . $i . ']', null, null, false, $editor_config); |
|
| 215 | + $form->addHtmlEditor('comment['.$i.']', null, null, false, $editor_config); |
|
| 216 | 216 | // Direct feedback |
| 217 | 217 | //Adding extra feedback fields |
| 218 | 218 | $group = array(); |
| 219 | - $group['try' . $i] = $form->createElement( |
|
| 219 | + $group['try'.$i] = $form->createElement( |
|
| 220 | 220 | 'checkbox', |
| 221 | - 'try' . $i, |
|
| 221 | + 'try'.$i, |
|
| 222 | 222 | null, |
| 223 | 223 | get_lang('TryAgain') |
| 224 | 224 | ); |
| 225 | - $group['lp' . $i] = $form->createElement( |
|
| 225 | + $group['lp'.$i] = $form->createElement( |
|
| 226 | 226 | 'select', |
| 227 | - 'lp' . $i, |
|
| 228 | - get_lang('SeeTheory') . ': ', |
|
| 227 | + 'lp'.$i, |
|
| 228 | + get_lang('SeeTheory').': ', |
|
| 229 | 229 | $select_lp_id |
| 230 | 230 | ); |
| 231 | - $group['destination' . $i] = $form->createElement( |
|
| 231 | + $group['destination'.$i] = $form->createElement( |
|
| 232 | 232 | 'select', |
| 233 | - 'destination' . $i, |
|
| 234 | - get_lang('GoToQuestion') . ': ', |
|
| 233 | + 'destination'.$i, |
|
| 234 | + get_lang('GoToQuestion').': ', |
|
| 235 | 235 | $select_question |
| 236 | 236 | ); |
| 237 | - $group['url' . $i] = $form->createElement( |
|
| 237 | + $group['url'.$i] = $form->createElement( |
|
| 238 | 238 | 'text', |
| 239 | - 'url' . $i, |
|
| 240 | - get_lang('Other') . ': ', |
|
| 239 | + 'url'.$i, |
|
| 240 | + get_lang('Other').': ', |
|
| 241 | 241 | array( |
| 242 | 242 | 'class' => 'col-md-2', |
| 243 | 243 | 'placeholder' => get_lang('Other') |
@@ -250,9 +250,9 @@ discard block |
||
| 250 | 250 | 'scenario' |
| 251 | 251 | ); |
| 252 | 252 | } else { |
| 253 | - $form->addHtmlEditor('comment[' . $i . ']', null, null, false, $editor_config); |
|
| 253 | + $form->addHtmlEditor('comment['.$i.']', null, null, false, $editor_config); |
|
| 254 | 254 | } |
| 255 | - $form->addText('weighting[' . $i . ']', null, null, array('value' => '0')); |
|
| 255 | + $form->addText('weighting['.$i.']', null, null, array('value' => '0')); |
|
| 256 | 256 | $form->addHtml('</tr>'); |
| 257 | 257 | } |
| 258 | 258 | |
@@ -306,19 +306,19 @@ discard block |
||
| 306 | 306 | $nb_answers = $form->getSubmitValue('nb_answers'); |
| 307 | 307 | |
| 308 | 308 | for ($i = 1; $i <= $nb_answers; $i++) { |
| 309 | - $answer = trim($form->getSubmitValue('answer[' . $i . ']')); |
|
| 310 | - $comment = trim($form->getSubmitValue('comment[' . $i . ']')); |
|
| 311 | - $weighting = trim($form->getSubmitValue('weighting[' . $i . ']')); |
|
| 309 | + $answer = trim($form->getSubmitValue('answer['.$i.']')); |
|
| 310 | + $comment = trim($form->getSubmitValue('comment['.$i.']')); |
|
| 311 | + $weighting = trim($form->getSubmitValue('weighting['.$i.']')); |
|
| 312 | 312 | |
| 313 | 313 | $scenario = $form->getSubmitValue('scenario'); |
| 314 | 314 | |
| 315 | 315 | //$list_destination = $form -> getSubmitValue('destination'.$i); |
| 316 | 316 | //$destination_str = $form -> getSubmitValue('destination'.$i); |
| 317 | 317 | |
| 318 | - $try = $scenario['try' . $i]; |
|
| 319 | - $lp = $scenario['lp' . $i]; |
|
| 320 | - $destination = $scenario['destination' . $i]; |
|
| 321 | - $url = trim($scenario['url' . $i]); |
|
| 318 | + $try = $scenario['try'.$i]; |
|
| 319 | + $lp = $scenario['lp'.$i]; |
|
| 320 | + $destination = $scenario['destination'.$i]; |
|
| 321 | + $url = trim($scenario['url'.$i]); |
|
| 322 | 322 | |
| 323 | 323 | /* |
| 324 | 324 | How we are going to parse the destination value |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | //1@@1;2;@@2;4;4;@@http://www.chamilo.org |
| 369 | - $dest = $try . '@@' . $lp . '@@' . $destination . '@@' . $url; |
|
| 369 | + $dest = $try.'@@'.$lp.'@@'.$destination.'@@'.$url; |
|
| 370 | 370 | $objAnswer->createAnswer( |
| 371 | 371 | $answer, |
| 372 | 372 | $goodAnswer, |
@@ -400,12 +400,12 @@ discard block |
||
| 400 | 400 | $score = null |
| 401 | 401 | ) { |
| 402 | 402 | $header = parent::return_header($feedback_type, $counter, $score); |
| 403 | - $header .= '<table class="' . $this->question_table_class . '"> |
|
| 403 | + $header .= '<table class="'.$this->question_table_class.'"> |
|
| 404 | 404 | <tr> |
| 405 | - <th>' . get_lang("Choice") . '</th> |
|
| 406 | - <th>' . get_lang("ExpectedChoice") . '</th> |
|
| 407 | - <th>' . get_lang("Answer") . '</th>'; |
|
| 408 | - $header .= '<th>' . get_lang("Comment") . '</th>'; |
|
| 405 | + <th>' . get_lang("Choice").'</th> |
|
| 406 | + <th>' . get_lang("ExpectedChoice").'</th> |
|
| 407 | + <th>' . get_lang("Answer").'</th>'; |
|
| 408 | + $header .= '<th>'.get_lang("Comment").'</th>'; |
|
| 409 | 409 | $header .= '</tr>'; |
| 410 | 410 | |
| 411 | 411 | return $header; |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | if ($correct) { |
| 470 | 470 | $sql = "UPDATE $tbl_quiz_question |
| 471 | 471 | SET ponderation = (ponderation + $score) |
| 472 | - WHERE c_id = $course_id AND id = " . $question_id; |
|
| 472 | + WHERE c_id = $course_id AND id = ".$question_id; |
|
| 473 | 473 | Database::query($sql); |
| 474 | 474 | } |
| 475 | 475 | } |