Completed
Push — 1.10.x ( ba9367...ff0ff6 )
by Julito
118:58 queued 74:08
created
main/exercice/upload_exercise.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 require_once '../inc/global.inc.php';
16 16
 
17
-require_once api_get_path(LIBRARY_PATH) . 'pear/excelreader/reader.php';
17
+require_once api_get_path(LIBRARY_PATH).'pear/excelreader/reader.php';
18 18
 
19 19
 // Security check
20 20
 $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
@@ -59,14 +59,14 @@  discard block
 block discarded – undo
59 59
 function lp_upload_quiz_actions()
60 60
 {
61 61
     $return = '<a href="exercise.php?'.api_get_cidReq().'">'.
62
-        Display::return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).'</a>';
62
+        Display::return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM).'</a>';
63 63
     return $return;
64 64
 }
65 65
 
66 66
 function lp_upload_quiz_secondary_actions()
67 67
 {
68
-    $return = '<a href="exercise_report.php?' . api_get_cidreq() . '">' .
69
-        Display :: return_icon('reporting32.png', get_lang('Tracking')) . get_lang('Tracking') . '</a>';
68
+    $return = '<a href="exercise_report.php?'.api_get_cidreq().'">'.
69
+        Display :: return_icon('reporting32.png', get_lang('Tracking')).get_lang('Tracking').'</a>';
70 70
     return $return;
71 71
 }
72 72
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     $table->setHeaderContents(0, 1, '#');
105 105
 
106 106
     $row = 1;
107
-    foreach ($tableList as $key => $label ) {
107
+    foreach ($tableList as $key => $label) {
108 108
         $table->setCellContents($row, 0, $label);
109 109
         $table->setCellContents($row, 1, $key);
110 110
         $row++;
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
                                     $comment = $feedback_true_list[$i][2];
444 444
                                 } else {
445 445
                                     $comment = $feedback_false_list[$i][2];
446
-                                    $floatVal = (float)$answer_data[3];
446
+                                    $floatVal = (float) $answer_data[3];
447 447
                                     if (is_numeric($floatVal)) {
448 448
                                         $score = $answer_data[3];
449 449
                                     }
Please login to merge, or discard this patch.
main/exercice/export/exercise_import.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -39,22 +39,22 @@  discard block
 block discarded – undo
39 39
 // EXECUTE COMMAND
40 40
 //----------------------------------
41 41
 
42
-$cmd = (isset($_REQUEST['cmd'])? $_REQUEST['cmd'] : 'show_import');
42
+$cmd = (isset($_REQUEST['cmd']) ? $_REQUEST['cmd'] : 'show_import');
43 43
 
44 44
 switch ($cmd) {
45 45
     case 'show_import' :
46 46
     {
47 47
         $display = '<p>'
48
-        .            get_lang('Imported exercises must consist of a zip or an XML file (IMS-QTI) and be compatible with your Claroline version.') . '<br>'
48
+        .            get_lang('Imported exercises must consist of a zip or an XML file (IMS-QTI) and be compatible with your Claroline version.').'<br>'
49 49
         .            '</p>'
50 50
         .            '<form enctype="multipart/form-data" action="" method="post">'
51 51
         .            '<input name="cmd" type="hidden" value="import" />'
52 52
         .            '<input name="uploadedExercise" type="file" /><br><br>'
53
-        .            get_lang('Import exercise') . ' : '
54
-        .            '<input value="' . get_lang('Ok') . '" type="submit" /> '
55
-        .            claro_html_button( $_SERVER['PHP_SELF'], get_lang('Cancel'))
53
+        .            get_lang('Import exercise').' : '
54
+        .            '<input value="'.get_lang('Ok').'" type="submit" /> '
55
+        .            claro_html_button($_SERVER['PHP_SELF'], get_lang('Cancel'))
56 56
         .            '<br><br>'
57
-        .            '<small>' . get_lang('Max file size') . ' :  2&nbsp;MB</small>'
57
+        .            '<small>'.get_lang('Max file size').' :  2&nbsp;MB</small>'
58 58
         .            '</form>';
59 59
     }
60 60
     break;
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 // DISPLAY
86 86
 //----------------------------------
87 87
 
88
-include api_get_path(INCLUDE_PATH) . '/header.inc.php';
88
+include api_get_path(INCLUDE_PATH).'/header.inc.php';
89 89
 
90 90
 //display title
91 91
 
@@ -114,5 +114,5 @@  discard block
 block discarded – undo
114 114
 
115 115
 //footer display
116 116
 
117
-include api_get_path(INCLUDE_PATH) . '/footer.inc.php';
117
+include api_get_path(INCLUDE_PATH).'/footer.inc.php';
118 118
 ?>
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -93,10 +93,10 @@
 block discarded – undo
93 93
 // Tool introduction
94 94
 // TODO: These settings to be checked when it is possible.
95 95
 Display::display_introduction_section(TOOL_QUIZ, array(
96
-		'CreateDocumentWebDir' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/',
97
-		'CreateDocumentDir' => '../../../courses/'.api_get_course_path().'/document/',
98
-		'BaseHref' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/'
99
-	)
96
+        'CreateDocumentWebDir' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/',
97
+        'CreateDocumentDir' => '../../../courses/'.api_get_course_path().'/document/',
98
+        'BaseHref' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/'
99
+    )
100 100
 );
101 101
 
102 102
 
Please login to merge, or discard this patch.
main/exercice/export/qti2/qti2_export.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 /**
9 9
  * Code
10 10
  */
11
-require dirname(__FILE__) . '/qti2_classes.php';
11
+require dirname(__FILE__).'/qti2_classes.php';
12 12
 /**
13 13
  * Classes
14 14
 */
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      {
39 39
         $this->question = $question;
40 40
         $this->answer = $this->question->setAnswer();
41
-        $this->questionIdent = "QST_" . $question->id ;
41
+        $this->questionIdent = "QST_".$question->id;
42 42
      }
43 43
 
44 44
      /**
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
       */
74 74
      function start_item_body()
75 75
      {
76
-        return '  <itemBody>' . "\n";
76
+        return '  <itemBody>'."\n";
77 77
      }
78 78
 
79 79
      /**
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
       function add_response_processing()
94 94
       {
95
-          return '  <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>' . "\n";
95
+          return '  <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>'."\n";
96 96
       }
97 97
 
98 98
      /**
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         $head = $foot = "";
109 109
 
110 110
         if ($standalone) {
111
-            $head = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . "\n";
111
+            $head = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'."\n";
112 112
         }
113 113
         //TODO understand why answer might be a non-object sometimes
114 114
         if (!is_object($this->answer)) {
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 
165 165
     function start_section()
166 166
     {
167
-        $out = '<section ident="EXO_' . $this->exercise->selectId() . '" title="' .cleanAttribute(formatExerciseQtiDescription($this->exercise->selectTitle())) . '">' . "\n";
167
+        $out = '<section ident="EXO_'.$this->exercise->selectId().'" title="'.cleanAttribute(formatExerciseQtiDescription($this->exercise->selectTitle())).'">'."\n";
168 168
         return $out;
169 169
     }
170 170
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
             // return exercise duration in ISO8601 format.
181 181
             $minutes = floor($max_time / 60);
182 182
             $seconds = $max_time % 60;
183
-            return '<duration>PT' . $minutes . 'M' . $seconds . "S</duration>\n";
183
+            return '<duration>PT'.$minutes.'M'.$seconds."S</duration>\n";
184 184
         } else {
185 185
             return '';
186 186
         }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     function export_presentation()
194 194
     {
195 195
         $out = "<presentation_material><flow_mat><material>\n"
196
-             . "  <mattext><![CDATA[" . formatExerciseQtiDescription($this->exercise->selectDescription()) . "]]></mattext>\n"
196
+             . "  <mattext><![CDATA[".formatExerciseQtiDescription($this->exercise->selectDescription())."]]></mattext>\n"
197 197
              . "</material></flow_mat></presentation_material>\n";
198 198
         return $out;
199 199
     }
@@ -207,14 +207,14 @@  discard block
 block discarded – undo
207 207
     {
208 208
         $out = '';
209 209
         if ($n = $this->exercise->getShuffle()) {
210
-            $out.= "<selection_ordering>"
210
+            $out .= "<selection_ordering>"
211 211
                  . "  <selection>\n"
212
-                 . "    <selection_number>" . $n . "</selection_number>\n"
212
+                 . "    <selection_number>".$n."</selection_number>\n"
213 213
                  . "  </selection>\n"
214 214
                  . '  <order order_type="Random" />'
215 215
                  . "\n</selection_ordering>\n";
216 216
         } else {
217
-            $out.= '<selection_ordering sequence_type="Normal">' . "\n"
217
+            $out .= '<selection_ordering sequence_type="Normal">'."\n"
218 218
                  . "  <selection />\n"
219 219
                  . "</selection_ordering>\n";
220 220
         }
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
     {
247 247
         $head = $foot = "";
248 248
         if ($standalone) {
249
-            $head = '<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>' . "\n"
250
-                  . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"
249
+            $head = '<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>'."\n"
250
+                  . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">'."\n"
251 251
                   . "<questestinterop>\n";
252 252
             $foot = "</questestinterop>\n";
253 253
         }
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
      {
309 309
         $this->question = $question;
310 310
         $this->answer = $question->answer;
311
-        $this->questionIdent = "QST_" . $question->selectId() ;
311
+        $this->questionIdent = "QST_".$question->selectId();
312 312
      }
313 313
 
314 314
      /**
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
       */
321 321
       function start_item()
322 322
       {
323
-        return '<item title="' . cleanAttribute(formatExerciseQtiDescription($this->question->selectTitle())) . '" ident="' . $this->questionIdent . '">' . "\n";
323
+        return '<item title="'.cleanAttribute(formatExerciseQtiDescription($this->question->selectTitle())).'" ident="'.$this->questionIdent.'">'."\n";
324 324
       }
325 325
 
326 326
       /**
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
       */
344 344
      function start_presentation()
345 345
      {
346
-        return '<presentation label="' . $this->questionIdent . '"><flow>' . "\n"
347
-             . '<material><mattext>' . formatExerciseQtiDescription($this->question->selectDescription()) . "</mattext></material>\n";
346
+        return '<presentation label="'.$this->questionIdent.'"><flow>'."\n"
347
+             . '<material><mattext>'.formatExerciseQtiDescription($this->question->selectDescription())."</mattext></material>\n";
348 348
      }
349 349
 
350 350
      /**
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
       */
365 365
      function start_processing()
366 366
      {
367
-        return '<resprocessing><outcomes><decvar vartype="Integer" defaultval="0" /></outcomes>' . "\n";
367
+        return '<resprocessing><outcomes><decvar vartype="Integer" defaultval="0" /></outcomes>'."\n";
368 368
      }
369 369
 
370 370
      /**
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
         $head = $foot = "";
393 393
 
394 394
         if ($standalone) {
395
-            $head = '<?xml version = "1.0" encoding = "'.$charset.'" standalone = "no"?>' . "\n"
396
-                  . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"
395
+            $head = '<?xml version = "1.0" encoding = "'.$charset.'" standalone = "no"?>'."\n"
396
+                  . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">'."\n"
397 397
                   . "<questestinterop>\n";
398 398
             $foot = "</questestinterop>\n";
399 399
         }
@@ -447,9 +447,9 @@  discard block
 block discarded – undo
447 447
     $question->type = $qst->type;
448 448
     $question->question = $qst->question;
449 449
     $question->description = $qst->description;
450
-	$question->weighting=$qst->weighting;
451
-	$question->position=$qst->position;
452
-	$question->picture=$qst->picture;
450
+	$question->weighting = $qst->weighting;
451
+	$question->position = $qst->position;
452
+	$question->picture = $qst->picture;
453 453
     $ims = new ImsAssessmentItem($question);
454 454
 
455 455
     return $ims->export($standalone);
Please login to merge, or discard this patch.
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -34,21 +34,21 @@  discard block
 block discarded – undo
34 34
      *
35 35
      * @param Ims2Question $question Ims2Question object we want to export.
36 36
      */
37
-     function __construct($question)
38
-     {
37
+        function __construct($question)
38
+        {
39 39
         $this->question = $question;
40 40
         $this->answer = $this->question->setAnswer();
41 41
         $this->questionIdent = "QST_" . $question->id ;
42
-     }
43
-
44
-     /**
45
-      * Start the XML flow.
46
-      *
47
-      * This opens the <item> block, with correct attributes.
48
-      *
49
-      */
50
-      function start_item()
51
-      {
42
+        }
43
+
44
+        /**
45
+         * Start the XML flow.
46
+         *
47
+         * This opens the <item> block, with correct attributes.
48
+         *
49
+         */
50
+        function start_item()
51
+        {
52 52
         $string = '<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p1"
53 53
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
54 54
                     xsi:schemaLocation="http://www.imsglobal.org/xsd/imsqti_v2p1 imsqti_v2p1.xsd"
@@ -56,55 +56,55 @@  discard block
 block discarded – undo
56 56
                     title="'.htmlspecialchars(formatExerciseQtiTitle($this->question->selectTitle())).'">'."\n";
57 57
 
58 58
         return $string;
59
-      }
60
-
61
-      /**
62
-       * End the XML flow, closing the </item> tag.
63
-       *
64
-       */
65
-      function end_item()
66
-      {
59
+        }
60
+
61
+        /**
62
+         * End the XML flow, closing the </item> tag.
63
+         *
64
+         */
65
+        function end_item()
66
+        {
67 67
         return "</assessmentItem>\n";
68
-      }
69
-
70
-     /**
71
-      * Start the itemBody
72
-      *
73
-      */
74
-     function start_item_body()
75
-     {
68
+        }
69
+
70
+        /**
71
+         * Start the itemBody
72
+         *
73
+         */
74
+        function start_item_body()
75
+        {
76 76
         return '  <itemBody>' . "\n";
77
-     }
78
-
79
-     /**
80
-      * End the itemBody part.
81
-      *
82
-      */
83
-     function end_item_body()
84
-     {
77
+        }
78
+
79
+        /**
80
+         * End the itemBody part.
81
+         *
82
+         */
83
+        function end_item_body()
84
+        {
85 85
         return "  </itemBody>\n";
86
-     }
87
-
88
-     /**
89
-      * add the response processing template used.
90
-      *
91
-      */
92
-
93
-      function add_response_processing()
94
-      {
95
-          return '  <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>' . "\n";
96
-      }
97
-
98
-     /**
99
-      * Export the question as an IMS/QTI Item.
100
-      *
101
-      * This is a default behaviour, some classes may want to override this.
102
-      *
103
-      * @param $standalone: Boolean stating if it should be exported as a stand-alone question
104
-      * @return string string, the XML flow for an Item.
105
-      */
106
-     function export($standalone = false)
107
-     {
86
+        }
87
+
88
+        /**
89
+         * add the response processing template used.
90
+         *
91
+         */
92
+
93
+        function add_response_processing()
94
+        {
95
+            return '  <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>' . "\n";
96
+        }
97
+
98
+        /**
99
+         * Export the question as an IMS/QTI Item.
100
+         *
101
+         * This is a default behaviour, some classes may want to override this.
102
+         *
103
+         * @param $standalone: Boolean stating if it should be exported as a stand-alone question
104
+         * @return string string, the XML flow for an Item.
105
+         */
106
+        function export($standalone = false)
107
+        {
108 108
         $head = $foot = "";
109 109
 
110 110
         if ($standalone) {
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
             .$foot;
132 132
 
133 133
         return $res;
134
-     }
134
+        }
135 135
 }
136 136
 
137 137
 /**
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
     function export_presentation()
195 195
     {
196 196
         $out = "<presentation_material><flow_mat><material>\n"
197
-             . "  <mattext><![CDATA[" . formatExerciseQtiDescription($this->exercise->selectDescription()) . "]]></mattext>\n"
198
-             . "</material></flow_mat></presentation_material>\n";
197
+                . "  <mattext><![CDATA[" . formatExerciseQtiDescription($this->exercise->selectDescription()) . "]]></mattext>\n"
198
+                . "</material></flow_mat></presentation_material>\n";
199 199
         return $out;
200 200
     }
201 201
 
@@ -209,15 +209,15 @@  discard block
 block discarded – undo
209 209
         $out = '';
210 210
         if ($n = $this->exercise->getShuffle()) {
211 211
             $out.= "<selection_ordering>"
212
-                 . "  <selection>\n"
213
-                 . "    <selection_number>" . $n . "</selection_number>\n"
214
-                 . "  </selection>\n"
215
-                 . '  <order order_type="Random" />'
216
-                 . "\n</selection_ordering>\n";
212
+                    . "  <selection>\n"
213
+                    . "    <selection_number>" . $n . "</selection_number>\n"
214
+                    . "  </selection>\n"
215
+                    . '  <order order_type="Random" />'
216
+                    . "\n</selection_ordering>\n";
217 217
         } else {
218 218
             $out.= '<selection_ordering sequence_type="Normal">' . "\n"
219
-                 . "  <selection />\n"
220
-                 . "</selection_ordering>\n";
219
+                    . "  <selection />\n"
220
+                    . "</selection_ordering>\n";
221 221
         }
222 222
 
223 223
         return $out;
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
     {
232 232
         $out = "";
233 233
         foreach ($this->exercise->selectQuestionList() as $q) {
234
-        	$out .= export_question_qti($q, false);
234
+            $out .= export_question_qti($q, false);
235 235
         }
236 236
         return $out;
237 237
     }
@@ -248,18 +248,18 @@  discard block
 block discarded – undo
248 248
         $head = $foot = "";
249 249
         if ($standalone) {
250 250
             $head = '<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>' . "\n"
251
-                  . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"
252
-                  . "<questestinterop>\n";
251
+                    . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"
252
+                    . "<questestinterop>\n";
253 253
             $foot = "</questestinterop>\n";
254 254
         }
255 255
         $out = $head
256
-             . $this->start_section()
257
-             . $this->export_duration()
258
-             . $this->export_presentation()
259
-             . $this->export_ordering()
260
-             . $this->export_questions()
261
-             . $this->end_section()
262
-             . $foot;
256
+                . $this->start_section()
257
+                . $this->export_duration()
258
+                . $this->export_presentation()
259
+                . $this->export_ordering()
260
+                . $this->export_questions()
261
+                . $this->end_section()
262
+                . $foot;
263 263
 
264 264
         return $out;
265 265
     }
@@ -306,97 +306,97 @@  discard block
 block discarded – undo
306 306
      * @return ImsItem
307 307
      * @author Anamd Tihon
308 308
      */
309
-     function __construct($question)
310
-     {
309
+        function __construct($question)
310
+        {
311 311
         $this->question = $question;
312 312
         $this->answer = $question->answer;
313 313
         $this->questionIdent = "QST_" . $question->selectId() ;
314
-     }
315
-
316
-     /**
317
-      * Start the XML flow.
318
-      *
319
-      * This opens the <item> block, with correct attributes.
320
-      *
321
-      * @author Amand Tihon <[email protected]>
322
-      */
323
-      function start_item()
324
-      {
314
+        }
315
+
316
+        /**
317
+         * Start the XML flow.
318
+         *
319
+         * This opens the <item> block, with correct attributes.
320
+         *
321
+         * @author Amand Tihon <[email protected]>
322
+         */
323
+        function start_item()
324
+        {
325 325
         return '<item title="' . cleanAttribute(formatExerciseQtiDescription($this->question->selectTitle())) . '" ident="' . $this->questionIdent . '">' . "\n";
326
-      }
327
-
328
-      /**
329
-       * End the XML flow, closing the </item> tag.
330
-       *
331
-       * @author Amand Tihon <[email protected]>
332
-       */
333
-      function end_item()
334
-      {
326
+        }
327
+
328
+        /**
329
+         * End the XML flow, closing the </item> tag.
330
+         *
331
+         * @author Amand Tihon <[email protected]>
332
+         */
333
+        function end_item()
334
+        {
335 335
         return "</item>\n";
336
-      }
337
-
338
-     /**
339
-      * Create the opening, with the question itself.
340
-      *
341
-      * This means it opens the <presentation> but doesn't close it, as this is the role of end_presentation().
342
-      * In between, the export_responses from the subclass should have been called.
343
-      *
344
-      * @author Amand Tihon <[email protected]>
345
-      */
346
-     function start_presentation()
347
-     {
336
+        }
337
+
338
+        /**
339
+         * Create the opening, with the question itself.
340
+         *
341
+         * This means it opens the <presentation> but doesn't close it, as this is the role of end_presentation().
342
+         * In between, the export_responses from the subclass should have been called.
343
+         *
344
+         * @author Amand Tihon <[email protected]>
345
+         */
346
+        function start_presentation()
347
+        {
348 348
         return '<presentation label="' . $this->questionIdent . '"><flow>' . "\n"
349
-             . '<material><mattext>' . formatExerciseQtiDescription($this->question->selectDescription()) . "</mattext></material>\n";
350
-     }
351
-
352
-     /**
353
-      * End the </presentation> part, opened by export_header.
354
-      *
355
-      * @author Amand Tihon <[email protected]>
356
-      */
357
-     function end_presentation()
358
-     {
349
+                . '<material><mattext>' . formatExerciseQtiDescription($this->question->selectDescription()) . "</mattext></material>\n";
350
+        }
351
+
352
+        /**
353
+         * End the </presentation> part, opened by export_header.
354
+         *
355
+         * @author Amand Tihon <[email protected]>
356
+         */
357
+        function end_presentation()
358
+        {
359 359
         return "</flow></presentation>\n";
360
-     }
361
-
362
-     /**
363
-      * Start the response processing, and declare the default variable, SCORE, at 0 in the outcomes.
364
-      *
365
-      * @author Amand Tihon <[email protected]>
366
-      */
367
-     function start_processing()
368
-     {
360
+        }
361
+
362
+        /**
363
+         * Start the response processing, and declare the default variable, SCORE, at 0 in the outcomes.
364
+         *
365
+         * @author Amand Tihon <[email protected]>
366
+         */
367
+        function start_processing()
368
+        {
369 369
         return '<resprocessing><outcomes><decvar vartype="Integer" defaultval="0" /></outcomes>' . "\n";
370
-     }
371
-
372
-     /**
373
-      * End the response processing part.
374
-      *
375
-      * @author Amand Tihon <[email protected]>
376
-      */
377
-     function end_processing()
378
-     {
370
+        }
371
+
372
+        /**
373
+         * End the response processing part.
374
+         *
375
+         * @author Amand Tihon <[email protected]>
376
+         */
377
+        function end_processing()
378
+        {
379 379
         return "</resprocessing>\n";
380
-     }
381
-
382
-     /**
383
-      * Export the question as an IMS/QTI Item.
384
-      *
385
-      * This is a default behaviour, some classes may want to override this.
386
-      *
387
-      * @param $standalone: Boolean stating if it should be exported as a stand-alone question
388
-      * @return string string, the XML flow for an Item.
389
-      * @author Amand Tihon <[email protected]>
390
-      */
391
-     function export($standalone = False)
392
-     {
380
+        }
381
+
382
+        /**
383
+         * Export the question as an IMS/QTI Item.
384
+         *
385
+         * This is a default behaviour, some classes may want to override this.
386
+         *
387
+         * @param $standalone: Boolean stating if it should be exported as a stand-alone question
388
+         * @return string string, the XML flow for an Item.
389
+         * @author Amand Tihon <[email protected]>
390
+         */
391
+        function export($standalone = False)
392
+        {
393 393
         global $charset;
394 394
         $head = $foot = "";
395 395
 
396 396
         if ($standalone) {
397 397
             $head = '<?xml version = "1.0" encoding = "'.$charset.'" standalone = "no"?>' . "\n"
398
-                  . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"
399
-                  . "<questestinterop>\n";
398
+                    . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"
399
+                    . "<questestinterop>\n";
400 400
             $foot = "</questestinterop>\n";
401 401
         }
402 402
 
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
             . $this->answer->imsExportFeedback($this->questionIdent)
412 412
             . $this->end_item()
413 413
             . $foot;
414
-     }
414
+        }
415 415
 }
416 416
 
417 417
 /**
@@ -450,9 +450,9 @@  discard block
 block discarded – undo
450 450
     $question->type = $qst->type;
451 451
     $question->question = $qst->question;
452 452
     $question->description = $qst->description;
453
-	$question->weighting=$qst->weighting;
454
-	$question->position=$qst->position;
455
-	$question->picture=$qst->picture;
453
+    $question->weighting=$qst->weighting;
454
+    $question->position=$qst->position;
455
+    $question->picture=$qst->picture;
456 456
     $ims = new ImsAssessmentItem($question);
457 457
 
458 458
     return $ims->export($standalone);
Please login to merge, or discard this patch.
main/exercice/export/qti2/qti2_classes.php 4 patches
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
      */
15 15
     public function setAnswer()
16 16
     {
17
-        switch($this->type) {
17
+        switch ($this->type) {
18 18
             case MCUA:
19 19
                 $answer = new ImsAnswerMultipleChoice($this->id);
20 20
 
@@ -77,21 +77,21 @@  discard block
 block discarded – undo
77 77
     {
78 78
         // @todo getAnswersList() converts the answers using api_html_entity_decode()
79 79
 		$this->answerList = $this->getAnswersList(true);
80
-        $out  = '    <choiceInteraction responseIdentifier="' . $questionIdent . '" >' . "\n";
81
-        $out .= '      <prompt><![CDATA['.formatExerciseQtiTitle($questionStatment) . ']]></prompt>'. "\n";
80
+        $out  = '    <choiceInteraction responseIdentifier="'.$questionIdent.'" >'."\n";
81
+        $out .= '      <prompt><![CDATA['.formatExerciseQtiTitle($questionStatment).']]></prompt>'."\n";
82 82
 		if (is_array($this->answerList)) {
83 83
 	        foreach ($this->answerList as $current_answer) {
84
-	            $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false">
84
+	            $out .= '<simpleChoice identifier="answer_'.$current_answer['id'].'" fixed="false">
85 85
                          <![CDATA['.formatExerciseQtiTitle($current_answer['answer']).']]>';
86 86
 	            if (isset($current_answer['comment']) && $current_answer['comment'] != '') {
87
-	                $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '">
87
+	                $out .= '<feedbackInline identifier="answer_'.$current_answer['id'].'">
88 88
 	                         <![CDATA['.formatExerciseQtiTitle($current_answer['comment']).']]>
89 89
 	                         </feedbackInline>';
90 90
 	            }
91
-	            $out .= '</simpleChoice>'. "\n";
91
+	            $out .= '</simpleChoice>'."\n";
92 92
 	        }
93 93
 		}
94
-        $out .= '    </choiceInteraction>'. "\n";
94
+        $out .= '    </choiceInteraction>'."\n";
95 95
 
96 96
         return $out;
97 97
     }
@@ -106,32 +106,32 @@  discard block
 block discarded – undo
106 106
 		$type = $this->getQuestionType();
107 107
         if ($type == MCMA)  $cardinality = 'multiple'; else $cardinality = 'single';
108 108
 
109
-        $out = '  <responseDeclaration identifier="' . $questionIdent . '" cardinality="' . $cardinality . '" baseType="identifier">' . "\n";
109
+        $out = '  <responseDeclaration identifier="'.$questionIdent.'" cardinality="'.$cardinality.'" baseType="identifier">'."\n";
110 110
 
111 111
         // Match the correct answers.
112 112
 
113
-        $out .= '    <correctResponse>'. "\n";
113
+        $out .= '    <correctResponse>'."\n";
114 114
 		if (is_array($this->answerList)) {
115
-	        foreach($this->answerList as $current_answer) {
115
+	        foreach ($this->answerList as $current_answer) {
116 116
 	            if ($current_answer['correct']) {
117
-	                $out .= '      <value>answer_'. $current_answer['id'] .'</value>'. "\n";
117
+	                $out .= '      <value>answer_'.$current_answer['id'].'</value>'."\n";
118 118
 	            }
119 119
 	        }
120 120
 		}
121
-        $out .= '    </correctResponse>'. "\n";
121
+        $out .= '    </correctResponse>'."\n";
122 122
 
123 123
         //Add the grading
124 124
 
125
-        $out .= '    <mapping>'. "\n";
125
+        $out .= '    <mapping>'."\n";
126 126
 		if (is_array($this->answerList)) {
127
-	        foreach($this->answerList as $current_answer) {
127
+	        foreach ($this->answerList as $current_answer) {
128 128
 	            if (isset($current_answer['grade'])) {
129
-	                $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n";
129
+	                $out .= ' <mapEntry mapKey="answer_'.$current_answer['id'].'" mappedValue="'.$current_answer['grade'].'" />'."\n";
130 130
 	            }
131 131
 	        }
132 132
 		}
133
-        $out .= '    </mapping>'. "\n";
134
-        $out .= '  </responseDeclaration>'. "\n";
133
+        $out .= '    </mapping>'."\n";
134
+        $out .= '  </responseDeclaration>'."\n";
135 135
 
136 136
         return $out;
137 137
     }
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
                 $key = $answer['id'];
159 159
                 $answer = $answer['answer'];
160 160
                 $len = api_strlen($answer);
161
-                $text = str_replace('['.$answer.']','<textEntryInteraction responseIdentifier="fill_'.$key.'" expectedLength="'.api_strlen($answer).'"/>', $text);
161
+                $text = str_replace('['.$answer.']', '<textEntryInteraction responseIdentifier="fill_'.$key.'" expectedLength="'.api_strlen($answer).'"/>', $text);
162 162
             }
163 163
         }
164 164
         $out = $text;
@@ -178,17 +178,17 @@  discard block
 block discarded – undo
178 178
 	        foreach ($this->answerList as $answer) {
179 179
 	        	$answerKey = $answer['id'];
180 180
 	        	$answer = $answer['answer'];
181
-	            $out .= '  <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n";
182
-	            $out .= '    <correctResponse>'. "\n";
183
-                $out .= '      <value><![CDATA['.formatExerciseQtiTitle($answer).']]></value>'. "\n";
184
-	            $out .= '    </correctResponse>'. "\n";
181
+	            $out .= '  <responseDeclaration identifier="fill_'.$answerKey.'" cardinality="single" baseType="identifier">'."\n";
182
+	            $out .= '    <correctResponse>'."\n";
183
+                $out .= '      <value><![CDATA['.formatExerciseQtiTitle($answer).']]></value>'."\n";
184
+	            $out .= '    </correctResponse>'."\n";
185 185
 	            if (isset($this->gradeList[$answerKey])) {
186
-	                $out .= '    <mapping>'. "\n";
187
-	                $out .= '      <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n";
188
-	                $out .= '    </mapping>'. "\n";
186
+	                $out .= '    <mapping>'."\n";
187
+	                $out .= '      <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'."\n";
188
+	                $out .= '    </mapping>'."\n";
189 189
 	            }
190 190
 
191
-	            $out .= '  </responseDeclaration>'. "\n";
191
+	            $out .= '  </responseDeclaration>'."\n";
192 192
 	        }
193 193
 		}
194 194
 
@@ -212,12 +212,12 @@  discard block
 block discarded – undo
212 212
 
213 213
         $out = "";
214 214
 
215
-        $out .= '<matchInteraction responseIdentifier="' . $questionIdent . '" maxAssociations="'. $maxAssociation .'">'. "\n";
215
+        $out .= '<matchInteraction responseIdentifier="'.$questionIdent.'" maxAssociations="'.$maxAssociation.'">'."\n";
216 216
         $out .= $questionStatment;
217 217
 
218 218
         //add left column
219 219
 
220
-        $out .= '  <simpleMatchSet>'. "\n";
220
+        $out .= '  <simpleMatchSet>'."\n";
221 221
 		if (is_array($this->leftList)) {
222 222
 	        foreach ($this->leftList as $leftKey=>$leftElement) {
223 223
 	            $out .= '
@@ -227,24 +227,24 @@  discard block
 block discarded – undo
227 227
 	        }
228 228
     	}
229 229
 
230
-        $out .= '  </simpleMatchSet>'. "\n";
230
+        $out .= '  </simpleMatchSet>'."\n";
231 231
 
232 232
         //add right column
233 233
 
234
-        $out .= '  <simpleMatchSet>'. "\n";
234
+        $out .= '  <simpleMatchSet>'."\n";
235 235
 
236 236
         $i = 0;
237 237
 
238 238
 		if (is_array($this->rightList)) {
239
-	        foreach($this->rightList as $rightKey=>$rightElement) {
239
+	        foreach ($this->rightList as $rightKey=>$rightElement) {
240 240
 	            $out .= '<simpleAssociableChoice identifier="right_'.$i.'" >
241 241
 	                    <![CDATA['.formatExerciseQtiTitle($rightElement['answer']).']]>
242 242
 	                    </simpleAssociableChoice>'. "\n";
243 243
 	            $i++;
244 244
 	        }
245 245
 		}
246
-        $out .= '  </simpleMatchSet>'. "\n";
247
-        $out .= '</matchInteraction>'. "\n";
246
+        $out .= '  </simpleMatchSet>'."\n";
247
+        $out .= '</matchInteraction>'."\n";
248 248
 
249 249
         return $out;
250 250
     }
@@ -255,32 +255,32 @@  discard block
 block discarded – undo
255 255
     public function imsExportResponsesDeclaration($questionIdent)
256 256
     {
257 257
 		$this->answerList = $this->getAnswersList(true);
258
-        $out =  '  <responseDeclaration identifier="' . $questionIdent . '" cardinality="single" baseType="identifier">' . "\n";
259
-        $out .= '    <correctResponse>' . "\n";
258
+        $out = '  <responseDeclaration identifier="'.$questionIdent.'" cardinality="single" baseType="identifier">'."\n";
259
+        $out .= '    <correctResponse>'."\n";
260 260
 
261 261
         $gradeArray = array();
262 262
 		if (is_array($this->leftList)) {
263 263
 	        foreach ($this->leftList as $leftKey=>$leftElement) {
264
-	            $i=0;
264
+	            $i = 0;
265 265
 	            foreach ($this->rightList as $rightKey=>$rightElement) {
266 266
 	                if (($leftElement['match'] == $rightElement['code'])) {
267
-	                    $out .= '      <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n";
267
+	                    $out .= '      <value>left_'.$leftKey.' right_'.$i.'</value>'."\n";
268 268
 
269
-	                    $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade'];
269
+	                    $gradeArray['left_'.$leftKey.' right_'.$i] = $leftElement['grade'];
270 270
 	                }
271 271
 	                $i++;
272 272
 	            }
273 273
 	        }
274 274
 		}
275
-        $out .= '    </correctResponse>'. "\n";
276
-        $out .= '    <mapping>' . "\n";
275
+        $out .= '    </correctResponse>'."\n";
276
+        $out .= '    <mapping>'."\n";
277 277
         if (is_array($gradeArray)) {
278 278
 	        foreach ($gradeArray as $gradeKey=>$grade) {
279
-	            $out .= '          <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n";
279
+	            $out .= '          <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>'."\n";
280 280
 	        }
281 281
         }
282
-        $out .= '    </mapping>' . "\n";
283
-        $out .= '  </responseDeclaration>'. "\n";
282
+        $out .= '    </mapping>'."\n";
283
+        $out .= '  </responseDeclaration>'."\n";
284 284
 
285 285
         return $out;
286 286
     }
@@ -296,12 +296,12 @@  discard block
 block discarded – undo
296 296
      * TODO update this to match hot spots instead of copying matching
297 297
      * Export the question part as a matrix-choice, with only one possible answer per line.
298 298
      */
299
-    public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='')
299
+    public function imsExportResponses($questionIdent, $questionStatment, $questionDesc = '', $questionMedia = '')
300 300
     {
301 301
 		$this->answerList = $this->getAnswersList(true);
302 302
 		$questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia;
303 303
 		$mimetype = mime_content_type($questionMedia);
304
-		if(empty($mimetype)){
304
+		if (empty($mimetype)) {
305 305
 			$mimetype = 'image/jpeg';
306 306
 		}
307 307
 
@@ -317,26 +317,26 @@  discard block
 block discarded – undo
317 317
 	        	//coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663
318 318
 	        	$coords = '';
319 319
 	        	$type = 'default';
320
-	        	switch($answer['hotspot_type']){
320
+	        	switch ($answer['hotspot_type']) {
321 321
 	        		case 'square':
322 322
 	        			$type = 'rect';
323 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]);
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 326
 	        			break;
327 327
 	        		case 'circle':
328 328
 	        			$type = 'circle';
329 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])));
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 332
 	        			break;
333 333
 	        		case 'poly':
334 334
 	        			$type = 'poly';
335
-						$coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']);
335
+						$coords = str_replace(array(';', '|'), array(',', ','), $answer['hotspot_coord']);
336 336
 	        			break;
337 337
 	        		 case 'delineation' :
338 338
 	        			$type = 'delineation';
339
-						$coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']);
339
+						$coords = str_replace(array(';', '|'), array(',', ','), $answer['hotspot_coord']);
340 340
 	        			break;
341 341
 	        	}
342 342
 	            $text .= '        <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n";
@@ -356,18 +356,18 @@  discard block
 block discarded – undo
356 356
 		$this->answerList = $this->getAnswersList(true);
357 357
 		$this->gradeList = $this->getGradesList();
358 358
         $out = '';
359
-        $out .= '  <responseDeclaration identifier="hotspot_'.$questionIdent.'" cardinality="ordered" baseType="identifier">' . "\n";
360
-        $out .= '    <correctResponse>'. "\n";
359
+        $out .= '  <responseDeclaration identifier="hotspot_'.$questionIdent.'" cardinality="ordered" baseType="identifier">'."\n";
360
+        $out .= '    <correctResponse>'."\n";
361 361
 
362 362
 		if (is_array($this->answerList)) {
363
-	        foreach ($this->answerList as $answerKey=>$answer)  {
363
+	        foreach ($this->answerList as $answerKey=>$answer) {
364 364
 	        	$answerKey = $answer['id'];
365 365
 	        	$answer = $answer['answer'];
366 366
 	            $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>';
367 367
 	        }
368 368
 		}
369
-        $out .= '    </correctResponse>'. "\n";
370
-        $out .= '  </responseDeclaration>'. "\n";
369
+        $out .= '    </correctResponse>'."\n";
370
+        $out .= '  </responseDeclaration>'."\n";
371 371
 
372 372
        return $out;
373 373
     }
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
      * TODO implement
384 384
      * Export the question part as a matrix-choice, with only one possible answer per line.
385 385
      */
386
-    public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='')
386
+    public function imsExportResponses($questionIdent, $questionStatment, $questionDesc = '', $questionMedia = '')
387 387
 	{
388 388
 		return '';
389 389
 	}
Please login to merge, or discard this patch.
Braces   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -104,7 +104,11 @@
 block discarded – undo
104 104
     {
105 105
 		$this->answerList = $this->getAnswersList(true);
106 106
 		$type = $this->getQuestionType();
107
-        if ($type == MCMA)  $cardinality = 'multiple'; else $cardinality = 'single';
107
+        if ($type == MCMA) {
108
+            $cardinality = 'multiple';
109
+        } else {
110
+            $cardinality = 'single';
111
+        }
108 112
 
109 113
         $out = '  <responseDeclaration identifier="' . $questionIdent . '" cardinality="' . $cardinality . '" baseType="identifier">' . "\n";
110 114
 
Please login to merge, or discard this patch.
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
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
 /**
@@ -76,21 +76,21 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -72,6 +72,7 @@  discard block
 block discarded – undo
72 72
     /**
73 73
      * Return the XML flow for the possible answers.
74 74
      *
75
+     * @param string $questionStatment
75 76
      */
76 77
     public function imsExportResponses($questionIdent, $questionStatment)
77 78
     {
@@ -147,6 +148,7 @@  discard block
 block discarded – undo
147 148
      * Export the text with missing words.
148 149
      *
149 150
      *
151
+     * @param string $questionStatment
150 152
      */
151 153
     public function imsExportResponses($questionIdent, $questionStatment)
152 154
     {
@@ -204,6 +206,7 @@  discard block
 block discarded – undo
204 206
 {
205 207
     /**
206 208
      * Export the question part as a matrix-choice, with only one possible answer per line.
209
+     * @param string $questionStatment
207 210
      */
208 211
     public function imsExportResponses($questionIdent, $questionStatment)
209 212
     {
@@ -295,6 +298,7 @@  discard block
 block discarded – undo
295 298
     /**
296 299
      * TODO update this to match hot spots instead of copying matching
297 300
      * Export the question part as a matrix-choice, with only one possible answer per line.
301
+     * @param string $questionStatment
298 302
      */
299 303
     public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='')
300 304
     {
@@ -382,6 +386,7 @@  discard block
 block discarded – undo
382 386
     /**
383 387
      * TODO implement
384 388
      * Export the question part as a matrix-choice, with only one possible answer per line.
389
+     * @param string $questionStatment
385 390
      */
386 391
     public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='')
387 392
 	{
Please login to merge, or discard this patch.
main/exercice/export/aiken/aiken_import.inc.php 3 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
         $dir .= '/';
26 26
 
27 27
     do {
28
-        $path = $dir . $prefix . mt_rand(0, 9999999);
28
+        $path = $dir.$prefix.mt_rand(0, 9999999);
29 29
     } while (!mkdir($path, $mode));
30 30
 
31 31
     return $path;
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
 function aiken_display_form($msg = '') {
39 39
     $name_tools = get_lang('ImportAikenQuiz');
40 40
     $form  = '<div class="actions">';
41
-    $form .= '<a href="exercise.php?show=test">' . Display :: return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).'</a>';
41
+    $form .= '<a href="exercise.php?show=test">'.Display :: return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM).'</a>';
42 42
     $form .= '</div>';
43 43
     $form .= $msg;
44
-    $form_validator  = new FormValidator('aiken_upload', 'post',api_get_self()."?".api_get_cidreq(), null, array('enctype' => 'multipart/form-data') );
44
+    $form_validator = new FormValidator('aiken_upload', 'post', api_get_self()."?".api_get_cidreq(), null, array('enctype' => 'multipart/form-data'));
45 45
     $form_validator->addElement('header', $name_tools);
46 46
     $form_validator->addElement('text', 'total_weight', get_lang('TotalWeight'));
47 47
     $form_validator->addElement('file', 'userFile', get_lang('DownloadFile'));
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     global $record_item_body;
90 90
     // used to specify the question directory where files could be found in relation in any question
91 91
     global $questionTempDir;
92
-    $archive_path = api_get_path(SYS_ARCHIVE_PATH) . 'aiken';
92
+    $archive_path = api_get_path(SYS_ARCHIVE_PATH).'aiken';
93 93
     $baseWorkDir = $archive_path;
94 94
 
95 95
     if (!is_dir($baseWorkDir)) {
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 
131 131
     // Parse every subdirectory to search txt question files
132 132
     while (false !== ($file = readdir($exerciseHandle))) {
133
-        if (is_dir($baseWorkDir . '/' . $file) && $file != "." && $file != "..") {
133
+        if (is_dir($baseWorkDir.'/'.$file) && $file != "." && $file != "..") {
134 134
             //find each manifest for each question repository found
135
-            $questionHandle = opendir($baseWorkDir . '/' . $file);
135
+            $questionHandle = opendir($baseWorkDir.'/'.$file);
136 136
             while (false !== ($questionFile = readdir($questionHandle))) {
137 137
                 if (preg_match('/.txt$/i', $questionFile)) {
138 138
                     $result = aiken_parse_file(
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
         $result = 'NoTxtFileFoundInTheZip';
155 155
     }
156 156
 
157
-    if ($result !== true ) {
157
+    if ($result !== true) {
158 158
         return $result;
159 159
     }
160 160
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
         }
216 216
 
217 217
         // Delete the temp dir where the exercise was unzipped
218
-        my_delete($baseWorkDir . $uploadPath);
218
+        my_delete($baseWorkDir.$uploadPath);
219 219
         $operation = $last_exercise_id;
220 220
     }
221 221
 
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile) {
236 236
     global $questionTempDir;
237 237
 
238
-    $questionTempDir = $exercisePath . '/' . $file . '/';
239
-    $questionFilePath = $questionTempDir . $questionFile;
238
+    $questionTempDir = $exercisePath.'/'.$file.'/';
239
+    $questionFilePath = $questionTempDir.$questionFile;
240 240
 
241 241
     if (!is_file($questionFilePath)) {
242 242
         return 'FileNotFound';
@@ -248,13 +248,13 @@  discard block
 block discarded – undo
248 248
     $answers_array = array();
249 249
     $new_question = true;
250 250
     foreach ($data as $line => $info) {
251
-        if ($question_index > 0 && $new_question == true && preg_match('/^(\r)?\n/',$info)) {
251
+        if ($question_index > 0 && $new_question == true && preg_match('/^(\r)?\n/', $info)) {
252 252
             // double empty line
253 253
             continue;
254 254
         }
255 255
         $new_question = false;
256 256
         //make sure it is transformed from iso-8859-1 to utf-8 if in that form
257
-        if (!mb_check_encoding($info,'utf-8') && mb_check_encoding($info,'iso-8859-1')) {
257
+        if (!mb_check_encoding($info, 'utf-8') && mb_check_encoding($info, 'iso-8859-1')) {
258 258
             $info = utf8_encode($info);
259 259
         }
260 260
         $exercise_info['question'][$question_index]['type'] = 'MCUA';
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
         } elseif (preg_match('/^ETIQUETAS:\s?([A-Z])\s?/', $info, $matches)) {
287 287
             //TAGS for chamilo >= 1.10 (Spanish e-ducativa format)
288 288
             $exercise_info['question'][$question_index]['answer_tags'] = explode(',', $matches[1]);
289
-        } elseif (preg_match('/^(\r)?\n/',$info)) {
289
+        } elseif (preg_match('/^(\r)?\n/', $info)) {
290 290
             //moving to next question (tolerate \r\n or just \n)
291 291
             if (empty($exercise_info['question'][$question_index]['correct_answers'])) {
292 292
                 error_log('Aiken: Error in question index '.$question_index.': no correct answer defined');
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
                     $exercise_info['question'][$question_index]['title'] = $info;
307 307
                 } else {
308 308
                     //Question itself (use a 100-chars long title and a larger description)
309
-                    $exercise_info['question'][$question_index]['title'] = trim(substr($info, 0, 100)) . '...';
309
+                    $exercise_info['question'][$question_index]['title'] = trim(substr($info, 0, 100)).'...';
310 310
                     $exercise_info['question'][$question_index]['description'] = $info;
311 311
                 }
312 312
             } else {
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
     }
317 317
     $total_questions = count($exercise_info['question']);
318 318
     $total_weight = (!empty($_POST['total_weight'])) ? intval($_POST['total_weight']) : 20;
319
-    foreach  ($exercise_info['question'] as $key => $question) {
319
+    foreach ($exercise_info['question'] as $key => $question) {
320 320
         $exercise_info['question'][$key]['weighting'][current(array_keys($exercise_info['question'][$key]['weighting']))] = $total_weight / $total_questions;
321 321
     }
322 322
     return true;
Please login to merge, or discard this patch.
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,8 +10,9 @@  discard block
 block discarded – undo
10 10
 /**
11 11
  * Security check
12 12
  */
13
-if (count(get_included_files()) == 1)
13
+if (count(get_included_files()) == 1) {
14 14
     die('---');
15
+}
15 16
 
16 17
 /**
17 18
  * Creates a temporary directory
@@ -21,8 +22,9 @@  discard block
 block discarded – undo
21 22
  * @return string
22 23
  */
23 24
 function tempdir($dir, $prefix = 'tmp', $mode = 0777) {
24
-    if (substr($dir, -1) != '/')
25
-        $dir .= '/';
25
+    if (substr($dir, -1) != '/') {
26
+            $dir .= '/';
27
+    }
26 28
 
27 29
     do {
28 30
         $path = $dir . $prefix . mt_rand(0, 9999999);
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -281,7 +281,7 @@
 block discarded – undo
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)
Please login to merge, or discard this patch.
main/exercice/export/aiken/aiken_classes.php 3 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@  discard block
 block discarded – undo
7 7
  * @package chamilo.exercise
8 8
  */
9 9
 
10
-if ( count( get_included_files() ) == 1 ) die( '---' );
10
+if (count(get_included_files()) == 1) die('---');
11 11
 
12 12
 if (!function_exists('mime_content_type')) {
13 13
 	function mime_content_type($filename) {
14
-		return DocumentManager::file_get_mime_type((string)$filename);
14
+		return DocumentManager::file_get_mime_type((string) $filename);
15 15
 	}
16 16
 }
17 17
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      */
26 26
     function setAnswer()
27 27
     {
28
-        switch($this->type)
28
+        switch ($this->type)
29 29
         {
30 30
             case MCUA :
31 31
                 $answer = new AikenAnswerMultipleChoice($this->id);
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,9 @@
 block discarded – undo
7 7
  * @package chamilo.exercise
8 8
  */
9 9
 
10
-if ( count( get_included_files() ) == 1 ) die( '---' );
10
+if ( count( get_included_files() ) == 1 ) {
11
+    die( '---' );
12
+}
11 13
 
12 14
 if (!function_exists('mime_content_type')) {
13 15
 	function mime_content_type($filename) {
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@  discard block
 block discarded – undo
11 11
 
12 12
 if (!function_exists('mime_content_type')) {
13 13
 
14
-	/**
15
-	 * @param string $filename
14
+    /**
15
+     * @param string $filename
16 16
      * @return string
17
-	 */
18
-	function mime_content_type($filename) {
19
-		return DocumentManager::file_get_mime_type((string)$filename);
20
-	}
17
+     */
18
+    function mime_content_type($filename) {
19
+        return DocumentManager::file_get_mime_type((string)$filename);
20
+    }
21 21
 }
22 22
 
23 23
 /**
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         {
35 35
             case MCUA :
36 36
                 $answer = new AikenAnswerMultipleChoice($this->id);
37
-            	return $answer;
37
+                return $answer;
38 38
             default :
39 39
                 $answer = null;
40 40
                 break;
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
     }
44 44
     function createAnswersForm($form)
45 45
     {
46
-    	return true;
46
+        return true;
47 47
     }
48 48
     function processAnswersCreation($form)
49 49
     {
50
-    	return true;
50
+        return true;
51 51
     }
52 52
 }
53 53
 
Please login to merge, or discard this patch.
main/exercice/export/scorm/scorm_classes.php 3 patches
Spacing   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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>.&nbsp;'.$answer."\n</td>\n";
464
-				$s.='<td width="20%" align="center">&nbsp;&nbsp;<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>.&nbsp;'.$answer."\n</td>\n";
464
+				$s .= '<td width="20%" align="center">&nbsp;&nbsp;<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>&nbsp;&nbsp;</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.='&nbsp;';
476
-				$s.="</td>\n</tr>\n";
472
+				$s .= '</select>&nbsp;&nbsp;</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 .= '&nbsp;';
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">&nbsp;</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">&nbsp;</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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -327,8 +327,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
471 470
 
472 471
 				$s.='</select>&nbsp;&nbsp;</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.='&nbsp;';
473
+				if(isset($Select[$cpt2])) {
474
+				    $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse'];
475
+				} else {
476
+					    $s.='&nbsp;';
477
+					}
476 478
 				$s.="</td>\n</tr>\n";
477 479
 
478 480
 				$jstmpc .= '['.$answerCorrect.','.$cpt2.'],';
@@ -577,8 +579,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
Indentation   +421 added lines, -421 removed lines patch added patch discarded remove patch
@@ -49,86 +49,86 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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>.&nbsp;'.$answer."\n</td>\n";
464
-				$s.='<td width="20%" align="center">&nbsp;&nbsp;<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>&nbsp;&nbsp;</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.='&nbsp;';
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">&nbsp;</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>.&nbsp;'.$answer."\n</td>\n";
464
+                $s.='<td width="20%" align="center">&nbsp;&nbsp;<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>&nbsp;&nbsp;</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.='&nbsp;';
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">&nbsp;</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
 block discarded – undo
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,24 +531,24 @@  discard block
 block discarded – undo
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
 }
@@ -558,40 +558,40 @@  discard block
 block discarded – undo
558 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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
main/exercice/unique_answer.class.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -447,7 +447,7 @@
 block discarded – undo
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,
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -59,21 +59,21 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
main/exercice/hotspot_actionscript.as.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 session_cache_limiter("none");
12 12
 
13 13
 require '../inc/global.inc.php';
14
-require api_get_path(LIBRARY_PATH) . 'geometry.lib.php';
14
+require api_get_path(LIBRARY_PATH).'geometry.lib.php';
15 15
 
16 16
 // set vars
17 17
 $questionId    = intval($_GET['modifyAnswers']);
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 $course_id = api_get_course_int_id();
30 30
 
31 31
 // Query db for answers
32
-if ($answer_type==HOT_SPOT_DELINEATION) {
32
+if ($answer_type == HOT_SPOT_DELINEATION) {
33 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 {
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     $hotSpot['answer'] = $hotspot['answer'];
76 76
 
77 77
 	// Square or rectancle
78
-	if ($hotspot['hotspot_type'] == 'square' )
78
+	if ($hotspot['hotspot_type'] == 'square')
79 79
 	{
80 80
         $hotSpot['type'] = 'square';
81 81
 	}
Please login to merge, or discard this patch.