@@ -55,18 +55,18 @@ discard block |
||
55 | 55 | |
56 | 56 | function createAnswersForm($form) |
57 | 57 | { |
58 | - return true; |
|
58 | + return true; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | function processAnswersCreation($form) |
62 | 62 | { |
63 | - return true; |
|
63 | + return true; |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | /** |
67 | - * Class |
|
68 | - * @package chamilo.exercise |
|
69 | - */ |
|
67 | + * Class |
|
68 | + * @package chamilo.exercise |
|
69 | + */ |
|
70 | 70 | class ImsAnswerMultipleChoice extends Answer |
71 | 71 | { |
72 | 72 | /** |
@@ -76,21 +76,21 @@ discard block |
||
76 | 76 | public function imsExportResponses($questionIdent, $questionStatment) |
77 | 77 | { |
78 | 78 | // @todo getAnswersList() converts the answers using api_html_entity_decode() |
79 | - $this->answerList = $this->getAnswersList(true); |
|
79 | + $this->answerList = $this->getAnswersList(true); |
|
80 | 80 | $out = ' <choiceInteraction responseIdentifier="' . $questionIdent . '" >' . "\n"; |
81 | 81 | $out .= ' <prompt><![CDATA['.formatExerciseQtiTitle($questionStatment) . ']]></prompt>'. "\n"; |
82 | - if (is_array($this->answerList)) { |
|
83 | - foreach ($this->answerList as $current_answer) { |
|
84 | - $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false"> |
|
82 | + if (is_array($this->answerList)) { |
|
83 | + foreach ($this->answerList as $current_answer) { |
|
84 | + $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false"> |
|
85 | 85 | <![CDATA['.formatExerciseQtiTitle($current_answer['answer']).']]>'; |
86 | - if (isset($current_answer['comment']) && $current_answer['comment'] != '') { |
|
87 | - $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '"> |
|
86 | + if (isset($current_answer['comment']) && $current_answer['comment'] != '') { |
|
87 | + $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '"> |
|
88 | 88 | <![CDATA['.formatExerciseQtiTitle($current_answer['comment']).']]> |
89 | 89 | </feedbackInline>'; |
90 | - } |
|
91 | - $out .= '</simpleChoice>'. "\n"; |
|
92 | - } |
|
93 | - } |
|
90 | + } |
|
91 | + $out .= '</simpleChoice>'. "\n"; |
|
92 | + } |
|
93 | + } |
|
94 | 94 | $out .= ' </choiceInteraction>'. "\n"; |
95 | 95 | |
96 | 96 | return $out; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function imsExportResponsesDeclaration($questionIdent) |
104 | 104 | { |
105 | - $this->answerList = $this->getAnswersList(true); |
|
106 | - $type = $this->getQuestionType(); |
|
105 | + $this->answerList = $this->getAnswersList(true); |
|
106 | + $type = $this->getQuestionType(); |
|
107 | 107 | if ($type == MCMA) $cardinality = 'multiple'; else $cardinality = 'single'; |
108 | 108 | |
109 | 109 | $out = ' <responseDeclaration identifier="' . $questionIdent . '" cardinality="' . $cardinality . '" baseType="identifier">' . "\n"; |
@@ -111,25 +111,25 @@ discard block |
||
111 | 111 | // Match the correct answers. |
112 | 112 | |
113 | 113 | $out .= ' <correctResponse>'. "\n"; |
114 | - if (is_array($this->answerList)) { |
|
115 | - foreach($this->answerList as $current_answer) { |
|
116 | - if ($current_answer['correct']) { |
|
117 | - $out .= ' <value>answer_'. $current_answer['id'] .'</value>'. "\n"; |
|
118 | - } |
|
119 | - } |
|
120 | - } |
|
114 | + if (is_array($this->answerList)) { |
|
115 | + foreach($this->answerList as $current_answer) { |
|
116 | + if ($current_answer['correct']) { |
|
117 | + $out .= ' <value>answer_'. $current_answer['id'] .'</value>'. "\n"; |
|
118 | + } |
|
119 | + } |
|
120 | + } |
|
121 | 121 | $out .= ' </correctResponse>'. "\n"; |
122 | 122 | |
123 | 123 | //Add the grading |
124 | 124 | |
125 | 125 | $out .= ' <mapping>'. "\n"; |
126 | - if (is_array($this->answerList)) { |
|
127 | - foreach($this->answerList as $current_answer) { |
|
128 | - if (isset($current_answer['grade'])) { |
|
129 | - $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n"; |
|
130 | - } |
|
131 | - } |
|
132 | - } |
|
126 | + if (is_array($this->answerList)) { |
|
127 | + foreach($this->answerList as $current_answer) { |
|
128 | + if (isset($current_answer['grade'])) { |
|
129 | + $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n"; |
|
130 | + } |
|
131 | + } |
|
132 | + } |
|
133 | 133 | $out .= ' </mapping>'. "\n"; |
134 | 134 | $out .= ' </responseDeclaration>'. "\n"; |
135 | 135 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function imsExportResponses($questionIdent, $questionStatment) |
152 | 152 | { |
153 | - $this->answerList = $this->getAnswersList(true); |
|
153 | + $this->answerList = $this->getAnswersList(true); |
|
154 | 154 | $text = ''; |
155 | 155 | $text .= $this->answerText; |
156 | 156 | if (is_array($this->answerList)) { |
@@ -171,28 +171,28 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function imsExportResponsesDeclaration($questionIdent) |
173 | 173 | { |
174 | - $this->answerList = $this->getAnswersList(true); |
|
175 | - $this->gradeList = $this->getGradesList(); |
|
174 | + $this->answerList = $this->getAnswersList(true); |
|
175 | + $this->gradeList = $this->getGradesList(); |
|
176 | 176 | $out = ''; |
177 | - if (is_array($this->answerList)) { |
|
178 | - foreach ($this->answerList as $answer) { |
|
179 | - $answerKey = $answer['id']; |
|
180 | - $answer = $answer['answer']; |
|
181 | - $out .= ' <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n"; |
|
182 | - $out .= ' <correctResponse>'. "\n"; |
|
177 | + if (is_array($this->answerList)) { |
|
178 | + foreach ($this->answerList as $answer) { |
|
179 | + $answerKey = $answer['id']; |
|
180 | + $answer = $answer['answer']; |
|
181 | + $out .= ' <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n"; |
|
182 | + $out .= ' <correctResponse>'. "\n"; |
|
183 | 183 | $out .= ' <value><![CDATA['.formatExerciseQtiTitle($answer).']]></value>'. "\n"; |
184 | - $out .= ' </correctResponse>'. "\n"; |
|
185 | - if (isset($this->gradeList[$answerKey])) { |
|
186 | - $out .= ' <mapping>'. "\n"; |
|
187 | - $out .= ' <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n"; |
|
188 | - $out .= ' </mapping>'. "\n"; |
|
189 | - } |
|
190 | - |
|
191 | - $out .= ' </responseDeclaration>'. "\n"; |
|
192 | - } |
|
193 | - } |
|
194 | - |
|
195 | - return $out; |
|
184 | + $out .= ' </correctResponse>'. "\n"; |
|
185 | + if (isset($this->gradeList[$answerKey])) { |
|
186 | + $out .= ' <mapping>'. "\n"; |
|
187 | + $out .= ' <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n"; |
|
188 | + $out .= ' </mapping>'. "\n"; |
|
189 | + } |
|
190 | + |
|
191 | + $out .= ' </responseDeclaration>'. "\n"; |
|
192 | + } |
|
193 | + } |
|
194 | + |
|
195 | + return $out; |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function imsExportResponses($questionIdent, $questionStatment) |
209 | 209 | { |
210 | - $this->answerList = $this->getAnswersList(true); |
|
211 | - $maxAssociation = max(count($this->leftList), count($this->rightList)); |
|
210 | + $this->answerList = $this->getAnswersList(true); |
|
211 | + $maxAssociation = max(count($this->leftList), count($this->rightList)); |
|
212 | 212 | |
213 | 213 | $out = ""; |
214 | 214 | |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | //add left column |
219 | 219 | |
220 | 220 | $out .= ' <simpleMatchSet>'. "\n"; |
221 | - if (is_array($this->leftList)) { |
|
222 | - foreach ($this->leftList as $leftKey=>$leftElement) { |
|
223 | - $out .= ' |
|
221 | + if (is_array($this->leftList)) { |
|
222 | + foreach ($this->leftList as $leftKey=>$leftElement) { |
|
223 | + $out .= ' |
|
224 | 224 | <simpleAssociableChoice identifier="left_'.$leftKey.'" > |
225 | 225 | <![CDATA['.formatExerciseQtiTitle($leftElement['answer']).']]> |
226 | 226 | </simpleAssociableChoice>'. "\n"; |
227 | - } |
|
228 | - } |
|
227 | + } |
|
228 | + } |
|
229 | 229 | |
230 | 230 | $out .= ' </simpleMatchSet>'. "\n"; |
231 | 231 | |
@@ -235,14 +235,14 @@ discard block |
||
235 | 235 | |
236 | 236 | $i = 0; |
237 | 237 | |
238 | - if (is_array($this->rightList)) { |
|
239 | - foreach($this->rightList as $rightKey=>$rightElement) { |
|
240 | - $out .= '<simpleAssociableChoice identifier="right_'.$i.'" > |
|
238 | + if (is_array($this->rightList)) { |
|
239 | + foreach($this->rightList as $rightKey=>$rightElement) { |
|
240 | + $out .= '<simpleAssociableChoice identifier="right_'.$i.'" > |
|
241 | 241 | <![CDATA['.formatExerciseQtiTitle($rightElement['answer']).']]> |
242 | 242 | </simpleAssociableChoice>'. "\n"; |
243 | - $i++; |
|
244 | - } |
|
245 | - } |
|
243 | + $i++; |
|
244 | + } |
|
245 | + } |
|
246 | 246 | $out .= ' </simpleMatchSet>'. "\n"; |
247 | 247 | $out .= '</matchInteraction>'. "\n"; |
248 | 248 | |
@@ -254,30 +254,30 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public function imsExportResponsesDeclaration($questionIdent) |
256 | 256 | { |
257 | - $this->answerList = $this->getAnswersList(true); |
|
257 | + $this->answerList = $this->getAnswersList(true); |
|
258 | 258 | $out = ' <responseDeclaration identifier="' . $questionIdent . '" cardinality="single" baseType="identifier">' . "\n"; |
259 | 259 | $out .= ' <correctResponse>' . "\n"; |
260 | 260 | |
261 | 261 | $gradeArray = array(); |
262 | - if (is_array($this->leftList)) { |
|
263 | - foreach ($this->leftList as $leftKey=>$leftElement) { |
|
264 | - $i=0; |
|
265 | - foreach ($this->rightList as $rightKey=>$rightElement) { |
|
266 | - if (($leftElement['match'] == $rightElement['code'])) { |
|
267 | - $out .= ' <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n"; |
|
268 | - |
|
269 | - $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade']; |
|
270 | - } |
|
271 | - $i++; |
|
272 | - } |
|
273 | - } |
|
274 | - } |
|
262 | + if (is_array($this->leftList)) { |
|
263 | + foreach ($this->leftList as $leftKey=>$leftElement) { |
|
264 | + $i=0; |
|
265 | + foreach ($this->rightList as $rightKey=>$rightElement) { |
|
266 | + if (($leftElement['match'] == $rightElement['code'])) { |
|
267 | + $out .= ' <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n"; |
|
268 | + |
|
269 | + $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade']; |
|
270 | + } |
|
271 | + $i++; |
|
272 | + } |
|
273 | + } |
|
274 | + } |
|
275 | 275 | $out .= ' </correctResponse>'. "\n"; |
276 | 276 | $out .= ' <mapping>' . "\n"; |
277 | 277 | if (is_array($gradeArray)) { |
278 | - foreach ($gradeArray as $gradeKey=>$grade) { |
|
279 | - $out .= ' <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n"; |
|
280 | - } |
|
278 | + foreach ($gradeArray as $gradeKey=>$grade) { |
|
279 | + $out .= ' <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n"; |
|
280 | + } |
|
281 | 281 | } |
282 | 282 | $out .= ' </mapping>' . "\n"; |
283 | 283 | $out .= ' </responseDeclaration>'. "\n"; |
@@ -298,49 +298,49 @@ discard block |
||
298 | 298 | */ |
299 | 299 | public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='') |
300 | 300 | { |
301 | - $this->answerList = $this->getAnswersList(true); |
|
302 | - $questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia; |
|
303 | - $mimetype = mime_content_type($questionMedia); |
|
304 | - if(empty($mimetype)){ |
|
305 | - $mimetype = 'image/jpeg'; |
|
306 | - } |
|
307 | - |
|
308 | - $text = ' <p>'.$questionStatment.'</p>'."\n"; |
|
309 | - $text .= ' <graphicOrderInteraction responseIdentifier="hotspot_'.$questionIdent.'">'."\n"; |
|
310 | - $text .= ' <prompt>'.$questionDesc.'</prompt>'."\n"; |
|
311 | - $text .= ' <object type="'.$mimetype.'" width="250" height="230" data="'.$questionMedia.'">-</object>'."\n"; |
|
301 | + $this->answerList = $this->getAnswersList(true); |
|
302 | + $questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia; |
|
303 | + $mimetype = mime_content_type($questionMedia); |
|
304 | + if(empty($mimetype)){ |
|
305 | + $mimetype = 'image/jpeg'; |
|
306 | + } |
|
307 | + |
|
308 | + $text = ' <p>'.$questionStatment.'</p>'."\n"; |
|
309 | + $text .= ' <graphicOrderInteraction responseIdentifier="hotspot_'.$questionIdent.'">'."\n"; |
|
310 | + $text .= ' <prompt>'.$questionDesc.'</prompt>'."\n"; |
|
311 | + $text .= ' <object type="'.$mimetype.'" width="250" height="230" data="'.$questionMedia.'">-</object>'."\n"; |
|
312 | 312 | if (is_array($this->answerList)) { |
313 | - foreach ($this->answerList as $key=>$answer) { |
|
314 | - $key = $answer['id']; |
|
315 | - $answerTxt = $answer['answer']; |
|
316 | - $len = api_strlen($answerTxt); |
|
317 | - //coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663 |
|
318 | - $coords = ''; |
|
319 | - $type = 'default'; |
|
320 | - switch($answer['hotspot_type']){ |
|
321 | - case 'square': |
|
322 | - $type = 'rect'; |
|
323 | - $res = array(); |
|
324 | - $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
325 | - $coords = $res[1].','.$res[2].','.((int)$res[1]+(int)$res[3]).",".((int)$res[2]+(int)$res[4]); |
|
326 | - break; |
|
327 | - case 'circle': |
|
328 | - $type = 'circle'; |
|
329 | - $res = array(); |
|
330 | - $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
331 | - $coords = $res[1].','.$res[2].','.sqrt(pow(($res[1]-$res[3]),2)+pow(($res[2]-$res[4]))); |
|
332 | - break; |
|
333 | - case 'poly': |
|
334 | - $type = 'poly'; |
|
335 | - $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
336 | - break; |
|
337 | - case 'delineation' : |
|
338 | - $type = 'delineation'; |
|
339 | - $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
340 | - break; |
|
341 | - } |
|
342 | - $text .= ' <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n"; |
|
343 | - } |
|
313 | + foreach ($this->answerList as $key=>$answer) { |
|
314 | + $key = $answer['id']; |
|
315 | + $answerTxt = $answer['answer']; |
|
316 | + $len = api_strlen($answerTxt); |
|
317 | + //coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663 |
|
318 | + $coords = ''; |
|
319 | + $type = 'default'; |
|
320 | + switch($answer['hotspot_type']){ |
|
321 | + case 'square': |
|
322 | + $type = 'rect'; |
|
323 | + $res = array(); |
|
324 | + $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
325 | + $coords = $res[1].','.$res[2].','.((int)$res[1]+(int)$res[3]).",".((int)$res[2]+(int)$res[4]); |
|
326 | + break; |
|
327 | + case 'circle': |
|
328 | + $type = 'circle'; |
|
329 | + $res = array(); |
|
330 | + $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
331 | + $coords = $res[1].','.$res[2].','.sqrt(pow(($res[1]-$res[3]),2)+pow(($res[2]-$res[4]))); |
|
332 | + break; |
|
333 | + case 'poly': |
|
334 | + $type = 'poly'; |
|
335 | + $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
336 | + break; |
|
337 | + case 'delineation' : |
|
338 | + $type = 'delineation'; |
|
339 | + $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
340 | + break; |
|
341 | + } |
|
342 | + $text .= ' <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n"; |
|
343 | + } |
|
344 | 344 | } |
345 | 345 | $text .= ' </graphicOrderInteraction>'."\n"; |
346 | 346 | $out = $text; |
@@ -353,23 +353,23 @@ discard block |
||
353 | 353 | */ |
354 | 354 | public function imsExportResponsesDeclaration($questionIdent) |
355 | 355 | { |
356 | - $this->answerList = $this->getAnswersList(true); |
|
357 | - $this->gradeList = $this->getGradesList(); |
|
356 | + $this->answerList = $this->getAnswersList(true); |
|
357 | + $this->gradeList = $this->getGradesList(); |
|
358 | 358 | $out = ''; |
359 | 359 | $out .= ' <responseDeclaration identifier="hotspot_'.$questionIdent.'" cardinality="ordered" baseType="identifier">' . "\n"; |
360 | 360 | $out .= ' <correctResponse>'. "\n"; |
361 | 361 | |
362 | - if (is_array($this->answerList)) { |
|
363 | - foreach ($this->answerList as $answerKey=>$answer) { |
|
364 | - $answerKey = $answer['id']; |
|
365 | - $answer = $answer['answer']; |
|
366 | - $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>'; |
|
367 | - } |
|
368 | - } |
|
362 | + if (is_array($this->answerList)) { |
|
363 | + foreach ($this->answerList as $answerKey=>$answer) { |
|
364 | + $answerKey = $answer['id']; |
|
365 | + $answer = $answer['answer']; |
|
366 | + $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>'; |
|
367 | + } |
|
368 | + } |
|
369 | 369 | $out .= ' </correctResponse>'. "\n"; |
370 | 370 | $out .= ' </responseDeclaration>'. "\n"; |
371 | 371 | |
372 | - return $out; |
|
372 | + return $out; |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | |
@@ -384,14 +384,14 @@ discard block |
||
384 | 384 | * Export the question part as a matrix-choice, with only one possible answer per line. |
385 | 385 | */ |
386 | 386 | public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='') |
387 | - { |
|
388 | - return ''; |
|
389 | - } |
|
387 | + { |
|
388 | + return ''; |
|
389 | + } |
|
390 | 390 | /** |
391 | 391 | * |
392 | 392 | */ |
393 | 393 | public function imsExportResponsesDeclaration($questionIdent) |
394 | 394 | { |
395 | - return ''; |
|
395 | + return ''; |
|
396 | 396 | } |
397 | 397 | } |
@@ -1,15 +1,15 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /* For licensing terms, see /license.txt */ |
3 | 3 | /** |
4 | - * Library for the import of Aiken format |
|
5 | - * @author claro team <[email protected]> |
|
6 | - * @author Guillaume Lederer <[email protected]> |
|
7 | - * @author César Perales <[email protected]> Parse function for Aiken format |
|
8 | - * @package chamilo.exercise |
|
9 | - */ |
|
4 | + * Library for the import of Aiken format |
|
5 | + * @author claro team <[email protected]> |
|
6 | + * @author Guillaume Lederer <[email protected]> |
|
7 | + * @author César Perales <[email protected]> Parse function for Aiken format |
|
8 | + * @package chamilo.exercise |
|
9 | + */ |
|
10 | 10 | /** |
11 | - * Security check |
|
12 | - */ |
|
11 | + * Security check |
|
12 | + */ |
|
13 | 13 | if (count(get_included_files()) == 1) |
14 | 14 | die('---'); |
15 | 15 | |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | } |
79 | 79 | } |
80 | 80 | /** |
81 | - * Main function to import the Aiken exercise |
|
82 | - * @return mixed True on success, error message on failure |
|
83 | - */ |
|
81 | + * Main function to import the Aiken exercise |
|
82 | + * @return mixed True on success, error message on failure |
|
83 | + */ |
|
84 | 84 | function aiken_import_exercise($file) |
85 | 85 | { |
86 | 86 | global $exercise_info; |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $correct_answer_index = array_search($matches[1], $answers_array); |
282 | 282 | $exercise_info['question'][$question_index]['title'] = $matches[1]; |
283 | 283 | } elseif (preg_match('/^TAGS:\s?([A-Z])\s?/', $info, $matches)) { |
284 | - //TAGS for chamilo >= 1.10 |
|
284 | + //TAGS for chamilo >= 1.10 |
|
285 | 285 | $exercise_info['question'][$question_index]['answer_tags'] = explode(',', $matches[1]); |
286 | 286 | } elseif (preg_match('/^ETIQUETAS:\s?([A-Z])\s?/', $info, $matches)) { |
287 | 287 | //TAGS for chamilo >= 1.10 (Spanish e-ducativa format) |
@@ -1,18 +1,18 @@ 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]> - updated ImsAnswerHotspot to match QTI norms |
|
6 | - * @author César Perales <[email protected]> Updated function names and import files for Aiken format support |
|
7 | - * @package chamilo.exercise |
|
8 | - */ |
|
4 | + * @author Claro Team <[email protected]> |
|
5 | + * @author Yannick Warnier <[email protected]> - updated ImsAnswerHotspot to match QTI norms |
|
6 | + * @author César Perales <[email protected]> Updated function names and import files for Aiken format support |
|
7 | + * @package chamilo.exercise |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | if ( count( get_included_files() ) == 1 ) die( '---' ); |
11 | 11 | |
12 | 12 | if (!function_exists('mime_content_type')) { |
13 | - function mime_content_type($filename) { |
|
14 | - return DocumentManager::file_get_mime_type((string)$filename); |
|
15 | - } |
|
13 | + function mime_content_type($filename) { |
|
14 | + return DocumentManager::file_get_mime_type((string)$filename); |
|
15 | + } |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | case MCUA : |
31 | 31 | $answer = new AikenAnswerMultipleChoice($this->id); |
32 | - return $answer; |
|
32 | + return $answer; |
|
33 | 33 | default : |
34 | 34 | $answer = null; |
35 | 35 | break; |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | } |
39 | 39 | function createAnswersForm($form) |
40 | 40 | { |
41 | - return true; |
|
41 | + return true; |
|
42 | 42 | } |
43 | 43 | function processAnswersCreation($form) |
44 | 44 | { |
45 | - return true; |
|
45 | + return true; |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 |
@@ -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 | } |
@@ -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, |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | |
31 | 31 | // Query db for answers |
32 | 32 | if ($answer_type==HOT_SPOT_DELINEATION) { |
33 | - $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS |
|
33 | + $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS |
|
34 | 34 | WHERE c_id = $course_id AND question_id = ".intval($questionId)." AND hotspot_type = 'delineation' ORDER BY id"; |
35 | 35 | } else { |
36 | - $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS |
|
36 | + $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS |
|
37 | 37 | WHERE c_id = $course_id AND question_id = ".intval($questionId)." ORDER BY id"; |
38 | 38 | } |
39 | 39 | $result = Database::query($sql); |
@@ -74,37 +74,37 @@ discard block |
||
74 | 74 | $hotSpot['id'] = $hotspot['id']; |
75 | 75 | $hotSpot['answer'] = $hotspot['answer']; |
76 | 76 | |
77 | - // Square or rectancle |
|
78 | - if ($hotspot['hotspot_type'] == 'square' ) |
|
79 | - { |
|
77 | + // Square or rectancle |
|
78 | + if ($hotspot['hotspot_type'] == 'square' ) |
|
79 | + { |
|
80 | 80 | $hotSpot['type'] = 'square'; |
81 | - } |
|
82 | - // Circle or ovale |
|
83 | - if ($hotspot['hotspot_type'] == 'circle') |
|
84 | - { |
|
81 | + } |
|
82 | + // Circle or ovale |
|
83 | + if ($hotspot['hotspot_type'] == 'circle') |
|
84 | + { |
|
85 | 85 | $hotSpot['type'] = 'circle'; |
86 | - } |
|
87 | - // Polygon |
|
88 | - if ($hotspot['hotspot_type'] == 'poly') |
|
89 | - { |
|
86 | + } |
|
87 | + // Polygon |
|
88 | + if ($hotspot['hotspot_type'] == 'poly') |
|
89 | + { |
|
90 | 90 | $hotSpot['type'] = 'poly'; |
91 | - } |
|
92 | - // Delineation |
|
93 | - if ($hotspot['hotspot_type'] == 'delineation') |
|
94 | - { |
|
91 | + } |
|
92 | + // Delineation |
|
93 | + if ($hotspot['hotspot_type'] == 'delineation') |
|
94 | + { |
|
95 | 95 | $hotSpot['type'] = 'delineation'; |
96 | - } |
|
97 | - // No error |
|
98 | - if ($hotspot['hotspot_type'] == 'noerror') |
|
99 | - { |
|
96 | + } |
|
97 | + // No error |
|
98 | + if ($hotspot['hotspot_type'] == 'noerror') |
|
99 | + { |
|
100 | 100 | $hotSpot['type'] = 'noerror'; |
101 | - } |
|
101 | + } |
|
102 | 102 | |
103 | - // This is a good answer, count + 1 for nmbr of clicks |
|
104 | - if ($hotspot['hotspot_type'] > 0) |
|
105 | - { |
|
106 | - $nmbrTries++; |
|
107 | - } |
|
103 | + // This is a good answer, count + 1 for nmbr of clicks |
|
104 | + if ($hotspot['hotspot_type'] > 0) |
|
105 | + { |
|
106 | + $nmbrTries++; |
|
107 | + } |
|
108 | 108 | |
109 | 109 | $hotSpot['coord'] = $hotspot['hotspot_coordinates']; |
110 | 110 |
@@ -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 | } |
@@ -98,10 +98,10 @@ |
||
98 | 98 | }*/ |
99 | 99 | } |
100 | 100 | |
101 | - // This is a good answer, count + 1 for nmbr of clicks |
|
102 | - if ($answers['weighting'][$i] > 0) { |
|
103 | - $nmbrTries++; |
|
104 | - } |
|
101 | + // This is a good answer, count + 1 for nmbr of clicks |
|
102 | + if ($answers['weighting'][$i] > 0) { |
|
103 | + $nmbrTries++; |
|
104 | + } |
|
105 | 105 | |
106 | 106 | $hotSpot['coord'] = $answers['hotspot_coordinates'][$i]; |
107 | 107 | $data['hotspots'][] = $hotSpot; |
@@ -17,13 +17,13 @@ discard block |
||
17 | 17 | $show_headers = isset($_REQUEST['show_headers']) ? intval($_REQUEST['show_headers']) : null; //exe id |
18 | 18 | |
19 | 19 | if ($origin == 'learnpath') { |
20 | - $show_headers = false; |
|
20 | + $show_headers = false; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | api_protect_course_script($show_headers); |
24 | 24 | |
25 | 25 | if (empty($id)) { |
26 | - api_not_allowed($show_headers); |
|
26 | + api_not_allowed($show_headers); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | $is_allowedToEdit = api_is_allowed_to_edit(null,true) || $is_courseTutor; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | // Only users can see their own results |
50 | 50 | if (!$is_allowedToEdit) { |
51 | 51 | if ($student_id != $current_user_id) { |
52 | - api_not_allowed($show_headers); |
|
52 | + api_not_allowed($show_headers); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
@@ -62,19 +62,19 @@ discard block |
||
62 | 62 | "name" => get_lang('Exercises'), |
63 | 63 | ); |
64 | 64 | $interbreadcrumb[] = array("url" => "#", "name" => get_lang('Result')); |
65 | - $this_section = SECTION_COURSES; |
|
66 | - Display::display_header(); |
|
65 | + $this_section = SECTION_COURSES; |
|
66 | + Display::display_header(); |
|
67 | 67 | } else { |
68 | 68 | $htmlHeadXtra[] = " |
69 | 69 | <style> |
70 | 70 | body { background: none;} |
71 | 71 | </style> |
72 | 72 | "; |
73 | - Display::display_reduced_header(); |
|
73 | + Display::display_reduced_header(); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | ExerciseLib::display_question_list_by_attempt($objExercise, $id, false); |
77 | 77 | |
78 | 78 | if ($show_headers) { |
79 | - Display::display_footer(); |
|
79 | + Display::display_footer(); |
|
80 | 80 | } |