Passed
Push — 1.10.x ( aae6b1...e5a590 )
by Yannick
131:05 queued 81:36
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/index.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 /**
4
- * @package chamilo.exercise
5
- * @author Claro Team <[email protected]>
6
- */
4
+     * @package chamilo.exercise
5
+     * @author Claro Team <[email protected]>
6
+     */
7 7
 /**
8
- * Redirection
9
- */
8
+     * Redirection
9
+     */
10 10
 header("Location: ../../../");
11 11
 exit();
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_classes.php 3 patches
Indentation   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -55,18 +55,18 @@  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
 /**
67
- * Class
68
- * @package chamilo.exercise
69
- */
67
+     * Class
68
+     * @package chamilo.exercise
69
+     */
70 70
 class ImsAnswerMultipleChoice extends Answer
71 71
 {
72 72
     /**
@@ -76,21 +76,21 @@  discard block
 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.
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.
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.
main/exercice/Hpdownload.php 2 patches
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
 session_cache_limiter('public');
13 13
 
14 14
 require_once '../inc/global.inc.php';
15
-$this_section=SECTION_COURSES;
15
+$this_section = SECTION_COURSES;
16 16
 
17 17
 $tbl_document = Database::get_course_table(TABLE_DOCUMENT);
18 18
 
19
-$doc_url=str_replace(array('../','\\..','\\0','..\\'),array('','','',''),urldecode($_GET['doc_url']));
20
-$filename=basename($doc_url);
19
+$doc_url = str_replace(array('../', '\\..', '\\0', '..\\'), array('', '', '', ''), urldecode($_GET['doc_url']));
20
+$filename = basename($doc_url);
21 21
 
22 22
 // launch event
23 23
 //Event::event_download($doc_url);
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	$full_file_name = $course_path.Security::remove_XSS($doc_url);
30 30
 }
31 31
 
32
-if(!is_file($full_file_name)) {
32
+if (!is_file($full_file_name)) {
33 33
 	exit;
34 34
 }
35 35
 
@@ -37,26 +37,26 @@  discard block
 block discarded – undo
37 37
     exit;
38 38
 }
39 39
 
40
-$extension=explode('.',$filename);
41
-$extension=strtolower($extension[sizeof($extension)-1]);
42
-
43
-switch($extension) {
44
-	case 'gz':		$content_type='application/x-gzip';			break;
45
-	case 'zip':		$content_type='application/zip';			break;
46
-	case 'pdf':		$content_type='application/pdf';			break;
47
-	case 'png':		$content_type='image/png';					break;
48
-	case 'gif':		$content_type='image/gif';					break;
49
-	case 'jpg':		$content_type='image/jpeg';					break;
50
-	case 'txt':		$content_type='text/plain';					break;
51
-	case 'htm':		$content_type='text/html';					break;
52
-	case 'html':	$content_type='text/html';					break;
53
-	default:		$content_type='application/octet-stream';	break;
40
+$extension = explode('.', $filename);
41
+$extension = strtolower($extension[sizeof($extension) - 1]);
42
+
43
+switch ($extension) {
44
+	case 'gz':		$content_type = 'application/x-gzip'; break;
45
+	case 'zip':		$content_type = 'application/zip'; break;
46
+	case 'pdf':		$content_type = 'application/pdf'; break;
47
+	case 'png':		$content_type = 'image/png'; break;
48
+	case 'gif':		$content_type = 'image/gif'; break;
49
+	case 'jpg':		$content_type = 'image/jpeg'; break;
50
+	case 'txt':		$content_type = 'text/plain'; break;
51
+	case 'htm':		$content_type = 'text/html'; break;
52
+	case 'html':	$content_type = 'text/html'; break;
53
+	default:		$content_type = 'application/octet-stream'; break;
54 54
 }
55 55
 
56 56
 header('Content-disposition: filename='.$filename);
57 57
 header('Content-Type: '.$content_type);
58
-header('Expires: '.gmdate('D, d M Y H:i:s',time()+10).' GMT');
59
-header('Last-Modified: '.gmdate('D, d M Y H:i:s',time()+10).' GMT');
58
+header('Expires: '.gmdate('D, d M Y H:i:s', time() + 10).' GMT');
59
+header('Last-Modified: '.gmdate('D, d M Y H:i:s', time() + 10).' GMT');
60 60
 
61 61
 /*
62 62
 	Dynamic parsing section
@@ -70,16 +70,16 @@  discard block
 block discarded – undo
70 70
 if ($content_type == 'text/html') {
71 71
 	$directory_name = dirname($full_file_name);
72 72
 
73
-	$dir=str_replace(array('\\',$_configuration['root_sys']."courses/".$_course['path'].'/document'),array('/',''),$directory_name);
73
+	$dir = str_replace(array('\\', $_configuration['root_sys']."courses/".$_course['path'].'/document'), array('/', ''), $directory_name);
74 74
 
75
-	if($dir[strlen($dir)-1] != '/') {
76
-		$dir.='/';
75
+	if ($dir[strlen($dir) - 1] != '/') {
76
+		$dir .= '/';
77 77
 	}
78 78
 
79 79
 
80 80
 	//Parse whole file at one
81 81
 	$fp = fopen($full_file_name, "r");
82
-	$file_content = fread ($fp, filesize ($full_file_name));
82
+	$file_content = fread($fp, filesize($full_file_name));
83 83
 	fclose($fp);
84 84
 	//$file_content = api_replace_parameter($dir, $file_content, "src");
85 85
 	//$file_content = api_replace_parameter($dir, $file_content, "href");
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 
99 99
 
100 100
     $exercisePath = api_get_self();
101
-  	$exfile = explode('/',$exercisePath);
102
-  	$exfile = $exfile[sizeof($exfile)-1];
103
-  	$exercisePath = substr($exercisePath,0,strpos($exercisePath,$exfile));
101
+  	$exfile = explode('/', $exercisePath);
102
+  	$exfile = $exfile[sizeof($exfile) - 1];
103
+  	$exercisePath = substr($exercisePath, 0, strpos($exercisePath, $exfile));
104 104
   	$exercisePath = $exercisePath;
105 105
 
106 106
 		$content = $file_content;
@@ -125,16 +125,16 @@  discard block
 block discarded – undo
125 125
 "// Must be included \n".
126 126
 "function Finish(){\n".
127 127
 " mySaveScore();";
128
-		$newcontent = str_replace($mit,$js_content,$content);
128
+		$newcontent = str_replace($mit, $js_content, $content);
129 129
 
130
-		$prehref="javascript:void(0);";
131
-		$posthref=$_configuration['root_web']."main/exercice/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid;
132
-		$newcontent = str_replace($prehref,$posthref,$newcontent);
130
+		$prehref = "javascript:void(0);";
131
+		$posthref = $_configuration['root_web']."main/exercice/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid;
132
+		$newcontent = str_replace($prehref, $posthref, $newcontent);
133 133
 
134 134
 
135
-		$prehref="class=\"GridNum\" onclick=";
136
-		$posthref="class=\"GridNum\" onMouseover=";
137
-		$newcontent = str_replace($prehref,$posthref,$newcontent);
135
+		$prehref = "class=\"GridNum\" onclick=";
136
+		$posthref = "class=\"GridNum\" onMouseover=";
137
+		$newcontent = str_replace($prehref, $posthref, $newcontent);
138 138
 
139 139
 
140 140
 		header('Content-length: '.strlen($newcontent));
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
 //normal case, all non-html files
148 148
 //header('Content-length: '.filesize($full_file_name));
149
-$fp=fopen($full_file_name,'rb');
149
+$fp = fopen($full_file_name, 'rb');
150 150
 fpassthru($fp);
151 151
 fclose($fp);
152 152
 ?>
Please login to merge, or discard this patch.
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
 * 	@version $Id: Hpdownload.php 22201 2009-07-17 19:57:03Z cfasanando $
8 8
 */
9 9
 /**
10
- * Code
11
- */
10
+     * Code
11
+     */
12 12
 session_cache_limiter('public');
13 13
 
14 14
 require_once '../inc/global.inc.php';
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 //Event::event_download($doc_url);
24 24
 if (isset($_course['path'])) {
25 25
     $course_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
26
-	$full_file_name = $course_path.Security::remove_XSS($doc_url);
26
+    $full_file_name = $course_path.Security::remove_XSS($doc_url);
27 27
 } else {
28 28
     $course_path = api_get_path(SYS_COURSE_PATH).$cid.'/document';
29
-	$full_file_name = $course_path.Security::remove_XSS($doc_url);
29
+    $full_file_name = $course_path.Security::remove_XSS($doc_url);
30 30
 }
31 31
 
32 32
 if(!is_file($full_file_name)) {
33
-	exit;
33
+    exit;
34 34
 }
35 35
 
36 36
 if (!Security::check_abs_path($full_file_name, $course_path.'/')) {
@@ -41,16 +41,16 @@  discard block
 block discarded – undo
41 41
 $extension=strtolower($extension[sizeof($extension)-1]);
42 42
 
43 43
 switch($extension) {
44
-	case 'gz':		$content_type='application/x-gzip';			break;
45
-	case 'zip':		$content_type='application/zip';			break;
46
-	case 'pdf':		$content_type='application/pdf';			break;
47
-	case 'png':		$content_type='image/png';					break;
48
-	case 'gif':		$content_type='image/gif';					break;
49
-	case 'jpg':		$content_type='image/jpeg';					break;
50
-	case 'txt':		$content_type='text/plain';					break;
51
-	case 'htm':		$content_type='text/html';					break;
52
-	case 'html':	$content_type='text/html';					break;
53
-	default:		$content_type='application/octet-stream';	break;
44
+    case 'gz':		$content_type='application/x-gzip';			break;
45
+    case 'zip':		$content_type='application/zip';			break;
46
+    case 'pdf':		$content_type='application/pdf';			break;
47
+    case 'png':		$content_type='image/png';					break;
48
+    case 'gif':		$content_type='image/gif';					break;
49
+    case 'jpg':		$content_type='image/jpeg';					break;
50
+    case 'txt':		$content_type='text/plain';					break;
51
+    case 'htm':		$content_type='text/html';					break;
52
+    case 'html':	$content_type='text/html';					break;
53
+    default:		$content_type='application/octet-stream';	break;
54 54
 }
55 55
 
56 56
 header('Content-disposition: filename='.$filename);
@@ -68,23 +68,23 @@  discard block
 block discarded – undo
68 68
 */
69 69
 
70 70
 if ($content_type == 'text/html') {
71
-	$directory_name = dirname($full_file_name);
71
+    $directory_name = dirname($full_file_name);
72 72
 
73
-	$dir=str_replace(array('\\',$_configuration['root_sys']."courses/".$_course['path'].'/document'),array('/',''),$directory_name);
73
+    $dir=str_replace(array('\\',$_configuration['root_sys']."courses/".$_course['path'].'/document'),array('/',''),$directory_name);
74 74
 
75
-	if($dir[strlen($dir)-1] != '/') {
76
-		$dir.='/';
77
-	}
75
+    if($dir[strlen($dir)-1] != '/') {
76
+        $dir.='/';
77
+    }
78 78
 
79 79
 
80
-	//Parse whole file at one
81
-	$fp = fopen($full_file_name, "r");
82
-	$file_content = fread ($fp, filesize ($full_file_name));
83
-	fclose($fp);
84
-	//$file_content = api_replace_parameter($dir, $file_content, "src");
85
-	//$file_content = api_replace_parameter($dir, $file_content, "href");
80
+    //Parse whole file at one
81
+    $fp = fopen($full_file_name, "r");
82
+    $file_content = fread ($fp, filesize ($full_file_name));
83
+    fclose($fp);
84
+    //$file_content = api_replace_parameter($dir, $file_content, "src");
85
+    //$file_content = api_replace_parameter($dir, $file_content, "href");
86 86
 
87
-	/*
87
+    /*
88 88
 	//parse line per line
89 89
 	$file_content_array = file($full_file_name);
90 90
 
@@ -98,16 +98,16 @@  discard block
 block discarded – undo
98 98
 
99 99
 
100 100
     $exercisePath = api_get_self();
101
-  	$exfile = explode('/',$exercisePath);
102
-  	$exfile = $exfile[sizeof($exfile)-1];
103
-  	$exercisePath = substr($exercisePath,0,strpos($exercisePath,$exfile));
104
-  	$exercisePath = $exercisePath;
101
+        $exfile = explode('/',$exercisePath);
102
+        $exfile = $exfile[sizeof($exfile)-1];
103
+        $exercisePath = substr($exercisePath,0,strpos($exercisePath,$exfile));
104
+        $exercisePath = $exercisePath;
105 105
 
106
-		$content = $file_content;
107
-		$mit = "function Finish(){";
106
+        $content = $file_content;
107
+        $mit = "function Finish(){";
108 108
 
109
-		$js_content = "var SaveScoreVariable = 0; // This variable included by Dokeos System\n".
110
-		"function mySaveScore() // This function included by Dokeos System\n".
109
+        $js_content = "var SaveScoreVariable = 0; // This variable included by Dokeos System\n".
110
+        "function mySaveScore() // This function included by Dokeos System\n".
111 111
 "{\n".
112 112
 "   if (SaveScoreVariable==0)\n".
113 113
 "		{\n".
@@ -125,23 +125,23 @@  discard block
 block discarded – undo
125 125
 "// Must be included \n".
126 126
 "function Finish(){\n".
127 127
 " mySaveScore();";
128
-		$newcontent = str_replace($mit,$js_content,$content);
128
+        $newcontent = str_replace($mit,$js_content,$content);
129 129
 
130
-		$prehref="javascript:void(0);";
131
-		$posthref=$_configuration['root_web']."main/exercice/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid;
132
-		$newcontent = str_replace($prehref,$posthref,$newcontent);
130
+        $prehref="javascript:void(0);";
131
+        $posthref=$_configuration['root_web']."main/exercice/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid;
132
+        $newcontent = str_replace($prehref,$posthref,$newcontent);
133 133
 
134 134
 
135
-		$prehref="class=\"GridNum\" onclick=";
136
-		$posthref="class=\"GridNum\" onMouseover=";
137
-		$newcontent = str_replace($prehref,$posthref,$newcontent);
135
+        $prehref="class=\"GridNum\" onclick=";
136
+        $posthref="class=\"GridNum\" onMouseover=";
137
+        $newcontent = str_replace($prehref,$posthref,$newcontent);
138 138
 
139 139
 
140
-		header('Content-length: '.strlen($newcontent));
141
-		// Dipsp.
142
-		echo $newcontent;
140
+        header('Content-length: '.strlen($newcontent));
141
+        // Dipsp.
142
+        echo $newcontent;
143 143
 
144
-	exit();
144
+    exit();
145 145
 }
146 146
 
147 147
 //normal case, all non-html files
Please login to merge, or discard this patch.
main/exercice/hotspot_actionscript_admin.as.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -98,10 +98,10 @@
 block discarded – undo
98 98
         }*/
99 99
     }
100 100
 
101
-	// This is a good answer, count + 1 for nmbr of clicks
102
-	if ($answers['weighting'][$i] > 0) {
103
-		$nmbrTries++;
104
-	}
101
+    // This is a good answer, count + 1 for nmbr of clicks
102
+    if ($answers['weighting'][$i] > 0) {
103
+        $nmbrTries++;
104
+    }
105 105
 
106 106
     $hotSpot['coord'] = $answers['hotspot_coordinates'][$i];
107 107
     $data['hotspots'][] = $hotSpot;
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
 api_protect_course_script(false);
12 12
 
13
-$isAllowedToEdit = api_is_allowed_to_edit(null,true);
13
+$isAllowedToEdit = api_is_allowed_to_edit(null, true);
14 14
 
15 15
 if (!$isAllowedToEdit) {
16 16
     api_not_allowed(true);
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 $objQuestion = Question::read($questionId);
23 23
 $_course = api_get_course_info();
24 24
 
25
-$documentPath  = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
25
+$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
26 26
 
27 27
 $picturePath = $documentPath.'/images';
28 28
 $pictureName = $objQuestion->selectPicture();
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
 $answers = $_SESSION['tmp_answers'];
66 66
 $nbrAnswers = count($answers['answer']);
67 67
 
68
-for ($i=1;$i <= $nbrAnswers; $i++) {
68
+for ($i = 1; $i <= $nbrAnswers; $i++) {
69 69
     $hotSpot = [];
70 70
     $hotSpot['id'] = null;
71
-    $hotSpot['answer']= $answers['answer'][$i];
71
+    $hotSpot['answer'] = $answers['answer'][$i];
72 72
 
73 73
     if ($answer_type == HOT_SPOT_DELINEATION) {
74
-        if ($i==1) {
74
+        if ($i == 1) {
75 75
             $hotSpot['type'] = 'delineation';
76 76
         } else {
77 77
             $hotSpot['type'] = 'oar';
Please login to merge, or discard this patch.
main/exercice/exercice.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,4 +7,4 @@
 block discarded – undo
7 7
 // directly to exercise.php. This redirection is enabled for 1.10.x (2015-04-21)
8 8
 // The final goal of this file is to be removed in a few years time, if
9 9
 // considered realistically not harmful
10
-require __DIR__ . '/exercise.php';
10
+require __DIR__.'/exercise.php';
Please login to merge, or discard this patch.
main/exercice/result.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
 $show_headers = isset($_REQUEST['show_headers']) ? intval($_REQUEST['show_headers']) : null; //exe id
18 18
 
19 19
 if ($origin == 'learnpath') {
20
-	$show_headers = false;
20
+    $show_headers = false;
21 21
 }
22 22
 
23 23
 api_protect_course_script($show_headers);
24 24
 
25 25
 if (empty($id)) {
26
-	api_not_allowed($show_headers);
26
+    api_not_allowed($show_headers);
27 27
 }
28 28
 
29 29
 $is_allowedToEdit = api_is_allowed_to_edit(null,true) || $is_courseTutor;
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 // Only users can see their own results
50 50
 if (!$is_allowedToEdit) {
51 51
     if ($student_id != $current_user_id) {
52
-    	api_not_allowed($show_headers);
52
+        api_not_allowed($show_headers);
53 53
     }
54 54
 }
55 55
 
@@ -62,19 +62,19 @@  discard block
 block discarded – undo
62 62
         "name" => get_lang('Exercises'),
63 63
     );
64 64
     $interbreadcrumb[] = array("url" => "#", "name" => get_lang('Result'));
65
-	$this_section = SECTION_COURSES;
66
-	Display::display_header();
65
+    $this_section = SECTION_COURSES;
66
+    Display::display_header();
67 67
 } else {
68 68
     $htmlHeadXtra[] = "
69 69
     <style>
70 70
     body { background: none;}
71 71
     </style>
72 72
     ";
73
-	Display::display_reduced_header();
73
+    Display::display_reduced_header();
74 74
 }
75 75
 
76 76
 ExerciseLib::display_question_list_by_attempt($objExercise, $id, false);
77 77
 
78 78
 if ($show_headers) {
79
-	Display::display_footer();
79
+    Display::display_footer();
80 80
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	api_not_allowed($show_headers);
27 27
 }
28 28
 
29
-$is_allowedToEdit = api_is_allowed_to_edit(null,true) || $is_courseTutor;
29
+$is_allowedToEdit = api_is_allowed_to_edit(null, true) || $is_courseTutor;
30 30
 
31 31
 //Getting results from the exe_id. This variable also contain all the information about the exercise
32 32
 $track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($id);
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
     }
54 54
 }
55 55
 
56
-$htmlHeadXtra[] = '<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/css/hotspot.css">';
57
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/js/hotspot.js"></script>';
56
+$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
57
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>';
58 58
 
59 59
 if ($show_headers) {
60 60
     $interbreadcrumb[] = array(
Please login to merge, or discard this patch.