Passed
Push — 1.10.x ( f64eef...04397c )
by Angel Fernando Quiroz
132:38 queued 79:40
created
main/inc/lib/geometry.lib.php 3 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 /**
4
- * @author Arnaud Ligot (CBlue SPRL) <[email protected]>
5
- * @package chamilo.include.geometry
6
- */
4
+     * @author Arnaud Ligot (CBlue SPRL) <[email protected]>
5
+     * @package chamilo.include.geometry
6
+     */
7 7
 
8 8
 define('DEBUG', false);
9 9
 /**
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
      *        for all j in [O..max[y][ : for all i in bords[$j] :
57 57
      *            (i,j) is a point inside an edge of the polygone
58 58
      */
59
-	$bord_lenght = $max['x'];
59
+    $bord_lenght = $max['x'];
60 60
     if ($max['y'] > $bord_lenght) {
61
-     	$bord_lenght = $max['y'];
61
+            $bord_lenght = $max['y'];
62 62
     }
63 63
 
64 64
     //$bords = array_fill(0, $bord_lenght-1, array()); // building this array
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 
67 67
     /* adding the first point of the polygone */
68 68
     if (is_array($bords[$poly[0]['y']])) //avoid warning
69
-    	array_push($bords[$poly[0]['y']], $poly[0]['x']);
69
+        array_push($bords[$poly[0]['y']], $poly[0]['x']);
70 70
 
71 71
     $i = 1; // we re-use $i and $old_pente bellow the loop
72 72
     $old_pente=0;
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
             if ($poly[$i-1]['x'] == $poly[$i]['x'])
79 79
                 continue; // twice the same point
80 80
             else {    //  infinite elevation of the edge
81
-            	if (is_array($bords[$poly[$i]['y']]))
82
-                	array_push($bords[$poly[$i]['y']],$poly[$i]['x']);
81
+                if (is_array($bords[$poly[$i]['y']]))
82
+                    array_push($bords[$poly[$i]['y']],$poly[$i]['x']);
83 83
                 $old_pente=0;
84 84
                 continue;
85 85
             }
86 86
         }
87 87
 
88
-		//echo 'point:'.$poly[$i]['y']; bug here
88
+        //echo 'point:'.$poly[$i]['y']; bug here
89 89
         // adding the point as a part of an edge
90 90
         if (is_array($bords[$poly[$i]['y']])) //avoid warning
91 91
         array_push($bords[$poly[$i]['y']], $poly[$i]['x']);
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
         if ($i>1)
103 103
             if (($old_pente<0 && $pente>0)
104 104
                     || ($old_pente>0 && $pente<0)) {
105
-				if (is_array($bords[$poly[$i]['y']])) //avoid warning
106
-                	array_push($bords[$poly[$i]['y']],$poly[$i]['x']);
105
+                if (is_array($bords[$poly[$i]['y']])) //avoid warning
106
+                    array_push($bords[$poly[$i]['y']],$poly[$i]['x']);
107 107
 
108 108
                 if (DEBUG)
109 109
                     echo '*('.$poly[$i]['x'].
110 110
                         ';'.$poly[$i]['y'].')   ';
111
-        	}
111
+            }
112 112
 
113 113
         /* detect the direction of the elevation in Y */
114 114
         $dy_inc = ($poly[$i]['y']-$poly[$i-1]['y']) > 0 ? 1 : -1;
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
         // elevation between $poly[0]['x'] and $poly[1]['x'])
138 138
         $rest = $poly[0]['y']-$poly[1]['y'];
139 139
         if ($rest!=0)
140
-        	$pente1 = ($poly[0]['x']-$poly[1]['x'])/($rest);
140
+            $pente1 = ($poly[0]['x']-$poly[1]['x'])/($rest);
141 141
         else
142
-			$pente1 = 0;
142
+            $pente1 = 0;
143 143
 
144 144
         // elevation between $poly[$i-1]['x'] and $poly[0]['x'])
145 145
         $pente = ($poly[$i-1]['x']-$poly[0]['x'])/
@@ -151,14 +151,14 @@  discard block
 block discarded – undo
151 151
 
152 152
         // doubling the first point if needed (see above)
153 153
         if (($pente1<0 && $pente>0) || ($pente1>0 && $pente<0)) {
154
-        	if (is_array($bords[$poly[$i - 1]['y']]))
155
-            	array_push($bords[$poly[$i - 1]['y']],  round($poly[$i - 1]['x']));
154
+            if (is_array($bords[$poly[$i - 1]['y']]))
155
+                array_push($bords[$poly[$i - 1]['y']],  round($poly[$i - 1]['x']));
156 156
             //if (DEBUG) echo '('.$poly[$i-1]['x'].';'.$poly[$i-1]['y'].')   ';
157 157
         }
158 158
         //  doubling the last point if neededd
159 159
         if (($old_pente<0 && $pente>0) || ($old_pente>0 && $pente<0)) {
160
-        	if (is_array($bords[$poly[$i-1]['y']])) //avoid warning
161
-            	array_push($bords[$poly[$i-1]['y']], round($poly[$i-1]['x']));
160
+            if (is_array($bords[$poly[$i-1]['y']])) //avoid warning
161
+                array_push($bords[$poly[$i-1]['y']], round($poly[$i-1]['x']));
162 162
             //if (DEBUG) echo '*('.$poly[$i-1]['x'].';'.$poly[$i-1]['y'].')   ';
163 163
         }
164 164
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
     for ($i = 0; $i<$n; $i++) {  // Y
186 186
         //error_log(__FILE__.' - Border Num '.$i,0);
187 187
         if (is_array($bords[$i])) {
188
-       		sort($bords[$i]);
188
+                sort($bords[$i]);
189 189
         }
190 190
 
191 191
         for ($j = 0; $j<sizeof($bords[$i]);$j+=2) { // bords
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
             for ($k = round($bords[$i][$j]); $k<=$bords[$i][$j+1];$k++) {
197 197
                 $res[$k][$i] = true; //filling the array with trues
198 198
                 if ($test == 1)  {
199
-                	/*how to draw the polygon in a human way:
199
+                    /*how to draw the polygon in a human way:
200 200
                 	In ubuntu : sudo apt-get install gnuplot
201 201
                 	Create an empty file with all points with the result of this echos (No commas, no point, no headers)
202 202
                 	In gnuplot:
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
                 	For 2 polygons:  plot "/home/jmontoya/test", "/home/jmontoya/test2"
205 205
                 	A new window will appear with the plot
206 206
                 	*/
207
-                	echo $k.'  '.$i; echo '<br />';
207
+                    echo $k.'  '.$i; echo '<br />';
208 208
                 }
209 209
             }
210 210
         }
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
         list($x,$y) = explode(';',$pcoord);
309 309
         $points[] = array('x'=>$x,'y'=>$y);
310 310
     }
311
-	return $points;
311
+    return $points;
312 312
 }
313 313
 
314 314
 /**
@@ -321,11 +321,11 @@  discard block
 block discarded – undo
321 321
     $mx = 0;
322 322
     $my = 0;
323 323
     foreach ($coords1 as $coord) {
324
-    	if ($coord['x'] > $mx) {
324
+        if ($coord['x'] > $mx) {
325 325
             $mx = $coord['x'];
326
-    	}
326
+        }
327 327
         if ($coord['y'] > $my) {
328
-        	$my = $coord['y'];
328
+            $my = $coord['y'];
329 329
         }
330 330
     }
331 331
     foreach ($coords2 as $coord) {
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@  discard block
 block discarded – undo
13 13
  * @returns an array such as: for all i in [0..max[x][ : for all j in [0..max[y][ : array[i][j] = FALSE
14 14
  */
15 15
 function poly_init($max) {
16
-    return array_fill(0, $max["x"]-1,
17
-            array_fill(0, $max["y"]-1, FALSE));
16
+    return array_fill(0, $max["x"] - 1,
17
+            array_fill(0, $max["y"] - 1, FALSE));
18 18
 }
19 19
 
20 20
 
@@ -69,18 +69,18 @@  discard block
 block discarded – undo
69 69
     	array_push($bords[$poly[0]['y']], $poly[0]['x']);
70 70
 
71 71
     $i = 1; // we re-use $i and $old_pente bellow the loop
72
-    $old_pente=0;
73
-    for (    ;    // for each points of the polygon but the first
74
-        $i<sizeof($poly) && (!empty($poly[$i]['x']) && !empty($poly[$i]['y'])); $i++) {
72
+    $old_pente = 0;
73
+    for (;    // for each points of the polygon but the first
74
+        $i < sizeof($poly) && (!empty($poly[$i]['x']) && !empty($poly[$i]['y'])); $i++) {
75 75
 
76 76
         /* special cases */
77
-        if ($poly[$i-1]['y'] == $poly[$i]['y']) {
78
-            if ($poly[$i-1]['x'] == $poly[$i]['x'])
77
+        if ($poly[$i - 1]['y'] == $poly[$i]['y']) {
78
+            if ($poly[$i - 1]['x'] == $poly[$i]['x'])
79 79
                 continue; // twice the same point
80 80
             else {    //  infinite elevation of the edge
81 81
             	if (is_array($bords[$poly[$i]['y']]))
82
-                	array_push($bords[$poly[$i]['y']],$poly[$i]['x']);
83
-                $old_pente=0;
82
+                	array_push($bords[$poly[$i]['y']], $poly[$i]['x']);
83
+                $old_pente = 0;
84 84
                 continue;
85 85
             }
86 86
         }
@@ -93,17 +93,17 @@  discard block
 block discarded – undo
93 93
 
94 94
         /* computing the elevation of the edge going */
95 95
         //        from $poly[$i-1] to $poly[$i]
96
-        $pente = ($poly[$i-1]['x']-$poly[$i]['x'])/
97
-                 ($poly[$i-1]['y']-$poly[$i]['y']);
96
+        $pente = ($poly[$i - 1]['x'] - $poly[$i]['x']) /
97
+                 ($poly[$i - 1]['y'] - $poly[$i]['y']);
98 98
 
99 99
         // if the sign of the elevation change from the one of the
100 100
         // previous edge, the point must be added a second time inside
101 101
         // $bords
102
-        if ($i>1)
103
-            if (($old_pente<0 && $pente>0)
104
-                    || ($old_pente>0 && $pente<0)) {
102
+        if ($i > 1)
103
+            if (($old_pente < 0 && $pente > 0)
104
+                    || ($old_pente > 0 && $pente < 0)) {
105 105
 				if (is_array($bords[$poly[$i]['y']])) //avoid warning
106
-                	array_push($bords[$poly[$i]['y']],$poly[$i]['x']);
106
+                	array_push($bords[$poly[$i]['y']], $poly[$i]['x']);
107 107
 
108 108
                 if (DEBUG)
109 109
                     echo '*('.$poly[$i]['x'].
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
         	}
112 112
 
113 113
         /* detect the direction of the elevation in Y */
114
-        $dy_inc = ($poly[$i]['y']-$poly[$i-1]['y']) > 0 ? 1 : -1;
115
-        $x = $poly[$i-1]['x'];
114
+        $dy_inc = ($poly[$i]['y'] - $poly[$i - 1]['y']) > 0 ? 1 : -1;
115
+        $x = $poly[$i - 1]['x'];
116 116
 //        if (DEBUG) echo "init: ".$poly[$i-1]['y']."  dy_inc: ".$dy_inc.
117 117
 //            "   end: ".$poly[$i]['y']."   pente:".$pente;
118 118
 
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
 
122 122
         // we iterate w/ $dy in ]$poly[$i-1]['y'],$poly[$i-1]['y'][
123 123
         //    w/ $dy_inc as increment
124
-        for ($dy = $poly[$i-1]['y']+$dy_inc;
124
+        for ($dy = $poly[$i - 1]['y'] + $dy_inc;
125 125
             $dy != $poly[$i]['y'];
126 126
             $dy += $dy_inc) {
127
-            $x += $pente*$dy_inc;
127
+            $x += $pente * $dy_inc;
128 128
             array_push($bords[$dy], $x);
129 129
 //            if (DEBUG) echo '/('.$x.';'.$dy.')   ';
130 130
         }
@@ -132,47 +132,47 @@  discard block
 block discarded – undo
132 132
     }
133 133
 
134 134
     // closing the polygone (the edge between $poly[$i-1] and $poly[0])
135
-    if ($poly[$i-1]['y']!=$poly[0]['y']) {// droite--> rien à faire
135
+    if ($poly[$i - 1]['y'] != $poly[0]['y']) {// droite--> rien à faire
136 136
 
137 137
         // elevation between $poly[0]['x'] and $poly[1]['x'])
138
-        $rest = $poly[0]['y']-$poly[1]['y'];
139
-        if ($rest!=0)
140
-        	$pente1 = ($poly[0]['x']-$poly[1]['x'])/($rest);
138
+        $rest = $poly[0]['y'] - $poly[1]['y'];
139
+        if ($rest != 0)
140
+        	$pente1 = ($poly[0]['x'] - $poly[1]['x']) / ($rest);
141 141
         else
142 142
 			$pente1 = 0;
143 143
 
144 144
         // elevation between $poly[$i-1]['x'] and $poly[0]['x'])
145
-        $pente = ($poly[$i-1]['x']-$poly[0]['x'])/
146
-            ($poly[$i-1]['y']-$poly[0]['y']);
145
+        $pente = ($poly[$i - 1]['x'] - $poly[0]['x']) /
146
+            ($poly[$i - 1]['y'] - $poly[0]['y']);
147 147
 
148 148
 //        if (DEBUG) echo 'start('.$poly[$i-1]['x'].','.$poly[$i-1]['y'].
149 149
 //                ')-end('.$poly[0]['x'].','.$poly[0]['y'].
150 150
 //                ')-pente'.$pente;
151 151
 
152 152
         // doubling the first point if needed (see above)
153
-        if (($pente1<0 && $pente>0) || ($pente1>0 && $pente<0)) {
153
+        if (($pente1 < 0 && $pente > 0) || ($pente1 > 0 && $pente < 0)) {
154 154
         	if (is_array($bords[$poly[$i - 1]['y']]))
155
-            	array_push($bords[$poly[$i - 1]['y']],  round($poly[$i - 1]['x']));
155
+            	array_push($bords[$poly[$i - 1]['y']], round($poly[$i - 1]['x']));
156 156
             //if (DEBUG) echo '('.$poly[$i-1]['x'].';'.$poly[$i-1]['y'].')   ';
157 157
         }
158 158
         //  doubling the last point if neededd
159
-        if (($old_pente<0 && $pente>0) || ($old_pente>0 && $pente<0)) {
160
-        	if (is_array($bords[$poly[$i-1]['y']])) //avoid warning
161
-            	array_push($bords[$poly[$i-1]['y']], round($poly[$i-1]['x']));
159
+        if (($old_pente < 0 && $pente > 0) || ($old_pente > 0 && $pente < 0)) {
160
+        	if (is_array($bords[$poly[$i - 1]['y']])) //avoid warning
161
+            	array_push($bords[$poly[$i - 1]['y']], round($poly[$i - 1]['x']));
162 162
             //if (DEBUG) echo '*('.$poly[$i-1]['x'].';'.$poly[$i-1]['y'].')   ';
163 163
         }
164 164
 
165 165
 
166
-        $dy_inc = ($poly[0]['y']-$poly[$i-1]['y']) > 0 ? 1 : -1;
167
-        $x = $poly[$i-1]['x'];
166
+        $dy_inc = ($poly[0]['y'] - $poly[$i - 1]['y']) > 0 ? 1 : -1;
167
+        $x = $poly[$i - 1]['x'];
168 168
 //        if (DEBUG) echo "init: ".$poly[$i-1]['y']."  dy_inc: ".$dy_inc.
169 169
 //            "   end: ".$poly[0]['y'];
170 170
 
171
-        for ($dy = $poly[$i-1]['y']+$dy_inc;
171
+        for ($dy = $poly[$i - 1]['y'] + $dy_inc;
172 172
             $dy != $poly[0]['y'];
173 173
             $dy += $dy_inc)
174 174
         {
175
-            $x += $pente*$dy_inc;
175
+            $x += $pente * $dy_inc;
176 176
             array_push($bords[$dy], round($x));
177 177
 //            if (DEBUG) echo '/('.$x.';'.$dy.')   ';
178 178
         }
@@ -182,20 +182,20 @@  discard block
 block discarded – undo
182 182
     /* basic idea: we sort a column of edges.
183 183
         For each pair of point, we color the points in between */
184 184
     $n = count($bords);
185
-    for ($i = 0; $i<$n; $i++) {  // Y
185
+    for ($i = 0; $i < $n; $i++) {  // Y
186 186
         //error_log(__FILE__.' - Border Num '.$i,0);
187 187
         if (is_array($bords[$i])) {
188 188
        		sort($bords[$i]);
189 189
         }
190 190
 
191
-        for ($j = 0; $j<sizeof($bords[$i]);$j+=2) { // bords
191
+        for ($j = 0; $j < sizeof($bords[$i]); $j += 2) { // bords
192 192
             if (!isset($bords[$i][$j + 1])) {
193 193
                 break;
194 194
             }
195 195
 
196
-            for ($k = round($bords[$i][$j]); $k<=$bords[$i][$j+1];$k++) {
196
+            for ($k = round($bords[$i][$j]); $k <= $bords[$i][$j + 1]; $k++) {
197 197
                 $res[$k][$i] = true; //filling the array with trues
198
-                if ($test == 1)  {
198
+                if ($test == 1) {
199 199
                 	/*how to draw the polygon in a human way:
200 200
                 	In ubuntu : sudo apt-get install gnuplot
201 201
                 	Create an empty file with all points with the result of this echos (No commas, no point, no headers)
@@ -222,19 +222,19 @@  discard block
 block discarded – undo
222 222
  *
223 223
  * @return string     html code of the representation of the polygone image
224 224
  */
225
-function poly_dump(&$poly, $max, $format='raw') {
225
+function poly_dump(&$poly, $max, $format = 'raw') {
226 226
     if ($format == 'html') {
227 227
         $s = "<div style='font-size: 8px; line-height:3px'><pre>\n";
228 228
     }
229
-    for ($i=0; $i<$max['y']; $i++) {
230
-        for($j=0; $j<$max['x']; $j++)
231
-            if($poly[$j][$i] == TRUE)
232
-                $s .= ($format=='html'?"<b>1</b>":'1');
229
+    for ($i = 0; $i < $max['y']; $i++) {
230
+        for ($j = 0; $j < $max['x']; $j++)
231
+            if ($poly[$j][$i] == TRUE)
232
+                $s .= ($format == 'html' ? "<b>1</b>" : '1');
233 233
             else
234 234
                 $s .= "0";
235
-        $s .= ($format=='html'?"<br />\n":"\n");
235
+        $s .= ($format == 'html' ? "<br />\n" : "\n");
236 236
     }
237
-    $s .= ($format=='html'?"</pre></div>\n":"\n");
237
+    $s .= ($format == 'html' ? "</pre></div>\n" : "\n");
238 238
     return $s;
239 239
 }
240 240
 
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
     $surfaceOf1 = 0;
253 253
     $surfaceOf2 = 0;
254 254
 
255
-    for ($i=0; $i<$max['x']; $i++)
256
-        for($j=0; $j<$max['y']; $j++) {
255
+    for ($i = 0; $i < $max['x']; $i++)
256
+        for ($j = 0; $j < $max['y']; $j++) {
257 257
             if (isset($poly1[$i][$j]) && ($poly1[$i][$j] == TRUE)) {
258 258
                 $surfaceOf1++;
259 259
                 if (isset($poly2[$i][$j]) && ($poly2[$i][$j] == FALSE))
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
                 $surfaceOf2++;
264 264
         }
265 265
 
266
-    return array (
266
+    return array(
267 267
         "s1" => $surfaceOf1,
268 268
         "s2" => $surfaceOf2,
269 269
         "both" => $surfaceOf1 - $onlyIn1,
@@ -282,8 +282,8 @@  discard block
 block discarded – undo
282 282
  */
283 283
 function poly_touch(&$poly1, &$poly2, $max) {
284 284
 
285
-    for ($i=0; $i<$max['x']; $i++) {
286
-        for($j=0; $j<$max['y']; $j++) {
285
+    for ($i = 0; $i < $max['x']; $i++) {
286
+        for ($j = 0; $j < $max['y']; $j++) {
287 287
             if (isset($poly1[$i][$j]) && ($poly1[$i][$j] == true)
288 288
                 && isset($poly2[$i][$j]) && ($poly2[$i][$j] == true)) {
289 289
                     return true;
@@ -301,12 +301,12 @@  discard block
 block discarded – undo
301 301
  * @return  array   An array of points in the right format to use with the
302 302
  *                  local functions
303 303
  */
304
-function convert_coordinates($coords,$sep='|') {
304
+function convert_coordinates($coords, $sep = '|') {
305 305
     $points = array();
306
-    $pairs = explode($sep,$coords);
306
+    $pairs = explode($sep, $coords);
307 307
     foreach ($pairs as $idx => $pcoord) {
308
-        list($x,$y) = explode(';',$pcoord);
309
-        $points[] = array('x'=>$x,'y'=>$y);
308
+        list($x, $y) = explode(';', $pcoord);
309
+        $points[] = array('x'=>$x, 'y'=>$y);
310 310
     }
311 311
 	return $points;
312 312
 }
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
             $my = $coord['y'];
337 337
         }
338 338
     }
339
-    return array('x'=>$mx,'y'=>$my);
339
+    return array('x'=>$mx, 'y'=>$my);
340 340
 }
341 341
 
342 342
 /**
Please login to merge, or discard this patch.
Braces   +49 added lines, -28 removed lines patch added patch discarded remove patch
@@ -65,8 +65,10 @@  discard block
 block discarded – undo
65 65
     $bords = array_fill(0, $bord_lenght, array()); // building this array
66 66
 
67 67
     /* adding the first point of the polygone */
68
-    if (is_array($bords[$poly[0]['y']])) //avoid warning
68
+    if (is_array($bords[$poly[0]['y']])) {
69
+        //avoid warning
69 70
     	array_push($bords[$poly[0]['y']], $poly[0]['x']);
71
+    }
70 72
 
71 73
     $i = 1; // we re-use $i and $old_pente bellow the loop
72 74
     $old_pente=0;
@@ -75,11 +77,14 @@  discard block
 block discarded – undo
75 77
 
76 78
         /* special cases */
77 79
         if ($poly[$i-1]['y'] == $poly[$i]['y']) {
78
-            if ($poly[$i-1]['x'] == $poly[$i]['x'])
79
-                continue; // twice the same point
80
+            if ($poly[$i-1]['x'] == $poly[$i]['x']) {
81
+                            continue;
82
+            }
83
+            // twice the same point
80 84
             else {    //  infinite elevation of the edge
81
-            	if (is_array($bords[$poly[$i]['y']]))
82
-                	array_push($bords[$poly[$i]['y']],$poly[$i]['x']);
85
+            	if (is_array($bords[$poly[$i]['y']])) {
86
+            	                	array_push($bords[$poly[$i]['y']],$poly[$i]['x']);
87
+            	}
83 88
                 $old_pente=0;
84 89
                 continue;
85 90
             }
@@ -87,9 +92,13 @@  discard block
 block discarded – undo
87 92
 
88 93
 		//echo 'point:'.$poly[$i]['y']; bug here
89 94
         // adding the point as a part of an edge
90
-        if (is_array($bords[$poly[$i]['y']])) //avoid warning
95
+        if (is_array($bords[$poly[$i]['y']])) {
96
+            //avoid warning
91 97
         array_push($bords[$poly[$i]['y']], $poly[$i]['x']);
92
-        if (DEBUG) echo '('.$poly[$i]['x'].';'.$poly[$i]['y'].')   ';
98
+        }
99
+        if (DEBUG) {
100
+            echo '('.$poly[$i]['x'].';'.$poly[$i]['y'].')   ';
101
+        }
93 102
 
94 103
         /* computing the elevation of the edge going */
95 104
         //        from $poly[$i-1] to $poly[$i]
@@ -99,15 +108,17 @@  discard block
 block discarded – undo
99 108
         // if the sign of the elevation change from the one of the
100 109
         // previous edge, the point must be added a second time inside
101 110
         // $bords
102
-        if ($i>1)
103
-            if (($old_pente<0 && $pente>0)
111
+        if ($i>1) {
112
+                    if (($old_pente<0 && $pente>0)
104 113
                     || ($old_pente>0 && $pente<0)) {
105 114
 				if (is_array($bords[$poly[$i]['y']])) //avoid warning
106 115
                 	array_push($bords[$poly[$i]['y']],$poly[$i]['x']);
116
+        }
107 117
 
108
-                if (DEBUG)
109
-                    echo '*('.$poly[$i]['x'].
118
+                if (DEBUG) {
119
+                                    echo '*('.$poly[$i]['x'].
110 120
                         ';'.$poly[$i]['y'].')   ';
121
+                }
111 122
         	}
112 123
 
113 124
         /* detect the direction of the elevation in Y */
@@ -136,10 +147,11 @@  discard block
 block discarded – undo
136 147
 
137 148
         // elevation between $poly[0]['x'] and $poly[1]['x'])
138 149
         $rest = $poly[0]['y']-$poly[1]['y'];
139
-        if ($rest!=0)
140
-        	$pente1 = ($poly[0]['x']-$poly[1]['x'])/($rest);
141
-        else
142
-			$pente1 = 0;
150
+        if ($rest!=0) {
151
+                	$pente1 = ($poly[0]['x']-$poly[1]['x'])/($rest);
152
+        } else {
153
+        			$pente1 = 0;
154
+        }
143 155
 
144 156
         // elevation between $poly[$i-1]['x'] and $poly[0]['x'])
145 157
         $pente = ($poly[$i-1]['x']-$poly[0]['x'])/
@@ -151,14 +163,17 @@  discard block
 block discarded – undo
151 163
 
152 164
         // doubling the first point if needed (see above)
153 165
         if (($pente1<0 && $pente>0) || ($pente1>0 && $pente<0)) {
154
-        	if (is_array($bords[$poly[$i - 1]['y']]))
155
-            	array_push($bords[$poly[$i - 1]['y']],  round($poly[$i - 1]['x']));
166
+        	if (is_array($bords[$poly[$i - 1]['y']])) {
167
+        	            	array_push($bords[$poly[$i - 1]['y']],  round($poly[$i - 1]['x']));
168
+        	}
156 169
             //if (DEBUG) echo '('.$poly[$i-1]['x'].';'.$poly[$i-1]['y'].')   ';
157 170
         }
158 171
         //  doubling the last point if neededd
159 172
         if (($old_pente<0 && $pente>0) || ($old_pente>0 && $pente<0)) {
160
-        	if (is_array($bords[$poly[$i-1]['y']])) //avoid warning
173
+        	if (is_array($bords[$poly[$i-1]['y']])) {
174
+        	    //avoid warning
161 175
             	array_push($bords[$poly[$i-1]['y']], round($poly[$i-1]['x']));
176
+        	}
162 177
             //if (DEBUG) echo '*('.$poly[$i-1]['x'].';'.$poly[$i-1]['y'].')   ';
163 178
         }
164 179
 
@@ -227,11 +242,13 @@  discard block
 block discarded – undo
227 242
         $s = "<div style='font-size: 8px; line-height:3px'><pre>\n";
228 243
     }
229 244
     for ($i=0; $i<$max['y']; $i++) {
230
-        for($j=0; $j<$max['x']; $j++)
231
-            if($poly[$j][$i] == TRUE)
245
+        for($j=0; $j<$max['x']; $j++) {
246
+                    if($poly[$j][$i] == TRUE)
232 247
                 $s .= ($format=='html'?"<b>1</b>":'1');
233
-            else
234
-                $s .= "0";
248
+        }
249
+            else {
250
+                            $s .= "0";
251
+            }
235 252
         $s .= ($format=='html'?"<br />\n":"\n");
236 253
     }
237 254
     $s .= ($format=='html'?"</pre></div>\n":"\n");
@@ -252,15 +269,19 @@  discard block
 block discarded – undo
252 269
     $surfaceOf1 = 0;
253 270
     $surfaceOf2 = 0;
254 271
 
255
-    for ($i=0; $i<$max['x']; $i++)
256
-        for($j=0; $j<$max['y']; $j++) {
272
+    for ($i=0; $i<$max['x']; $i++) {
273
+            for($j=0;
274
+    }
275
+    $j<$max['y']; $j++) {
257 276
             if (isset($poly1[$i][$j]) && ($poly1[$i][$j] == TRUE)) {
258 277
                 $surfaceOf1++;
259
-                if (isset($poly2[$i][$j]) && ($poly2[$i][$j] == FALSE))
260
-                    $onlyIn1++;
278
+                if (isset($poly2[$i][$j]) && ($poly2[$i][$j] == FALSE)) {
279
+                                    $onlyIn1++;
280
+                }
281
+            }
282
+            if (isset($poly2[$i][$j]) && ($poly2[$i][$j] == TRUE)) {
283
+                            $surfaceOf2++;
261 284
             }
262
-            if (isset($poly2[$i][$j]) && ($poly2[$i][$j] == TRUE))
263
-                $surfaceOf2++;
264 285
         }
265 286
 
266 287
     return array (
Please login to merge, or discard this patch.
main/exercice/exercise_submit_modal.php 2 patches
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
 $learnpath_id = 0;
44 44
 
45 45
 if (isset($_REQUEST['learnpath_id'])) {
46
-	$learnpath_id = intval($_REQUEST['learnpath_id']);
46
+    $learnpath_id = intval($_REQUEST['learnpath_id']);
47 47
 }
48 48
 
49 49
 $learnpath_item_id = 0;
50 50
 
51 51
 if (isset($_REQUEST['learnpath_item_id'])) {
52
-	$learnpath_item_id = intval($_REQUEST['learnpath_item_id']);
52
+    $learnpath_item_id = intval($_REQUEST['learnpath_item_id']);
53 53
 }
54 54
 
55 55
 $_SESSION['hotspot_coord']=array();
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 // Getting the options by js
94 94
 if (empty($choice_value)) {
95 95
 
96
-	echo "<script>
96
+    echo "<script>
97 97
 		// this works for only radio buttons
98 98
 		var f = self.parent.window.document.frm_exercise;
99 99
 		var choice_js='';
@@ -122,12 +122,12 @@  discard block
 block discarded – undo
122 122
 		}
123 123
 
124 124
 	";
125
-	// IMPORTANT
126
-	//this is the real redirect function
127
-	//echo 'window.location.href = "exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&hotspotcoord="+ hotspotcoord + "&hotspot="+ hotspot + "&choice="+ choice_js + "&exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'&gradebook='.$gradebook.'";';
125
+    // IMPORTANT
126
+    //this is the real redirect function
127
+    //echo 'window.location.href = "exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&hotspotcoord="+ hotspotcoord + "&hotspot="+ hotspot + "&choice="+ choice_js + "&exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'&gradebook='.$gradebook.'";';
128 128
     echo ' url = "exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&hotspotcoord="+ hotspotcoord + "&hotspot="+ hotspot + "&choice="+ choice_js + "&exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'&gradebook='.$gradebook.'";';
129 129
     echo "$('#global-modal .modal-body').load(url);";
130
-	echo '</script>';
130
+    echo '</script>';
131 131
 
132 132
     exit;
133 133
 }
@@ -180,12 +180,12 @@  discard block
 block discarded – undo
180 180
 
181 181
 // creates a temporary Question object
182 182
 if (in_array($questionid, $questionList)) {
183
-	$objQuestionTmp 	= Question :: read($questionid);
184
-	$questionName		=$objQuestionTmp->selectTitle();
185
-	$questionDescription=$objQuestionTmp->selectDescription();
186
-	$questionWeighting	=$objQuestionTmp->selectWeighting();
187
-	$answerType			=$objQuestionTmp->selectType();
188
-	$quesId				=$objQuestionTmp->selectId(); //added by priya saini
183
+    $objQuestionTmp 	= Question :: read($questionid);
184
+    $questionName		=$objQuestionTmp->selectTitle();
185
+    $questionDescription=$objQuestionTmp->selectDescription();
186
+    $questionWeighting	=$objQuestionTmp->selectWeighting();
187
+    $answerType			=$objQuestionTmp->selectType();
188
+    $quesId				=$objQuestionTmp->selectId(); //added by priya saini
189 189
 }
190 190
 
191 191
 $objAnswerTmp=new Answer($questionid);
@@ -208,43 +208,43 @@  discard block
 block discarded – undo
208 208
 $totalScore = 0;
209 209
 
210 210
 if (!empty($choice_value)) {
211
-	for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
212
-		$answer            = $objAnswerTmp->selectAnswer($answerId);
213
-		$answerComment     = $objAnswerTmp->selectComment($answerId);
214
-		$answerDestination = $objAnswerTmp->selectDestination($answerId);
215
-
216
-		$answerCorrect     = $objAnswerTmp->isCorrect($answerId);
217
-		$answerWeighting   = $objAnswerTmp->selectWeighting($answerId);
218
-		$numAnswer         = $objAnswerTmp->selectAutoId($answerId);
219
-
220
-		//delineation
221
-		$delineation_cord  = $objAnswerTmp->selectHotspotCoordinates(1);
222
-		$answer_delineation_destination=$objAnswerTmp->selectDestination(1);
211
+    for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
212
+        $answer            = $objAnswerTmp->selectAnswer($answerId);
213
+        $answerComment     = $objAnswerTmp->selectComment($answerId);
214
+        $answerDestination = $objAnswerTmp->selectDestination($answerId);
215
+
216
+        $answerCorrect     = $objAnswerTmp->isCorrect($answerId);
217
+        $answerWeighting   = $objAnswerTmp->selectWeighting($answerId);
218
+        $numAnswer         = $objAnswerTmp->selectAutoId($answerId);
219
+
220
+        //delineation
221
+        $delineation_cord  = $objAnswerTmp->selectHotspotCoordinates(1);
222
+        $answer_delineation_destination=$objAnswerTmp->selectDestination(1);
223 223
         if ($dbg_local>0) { error_log(__LINE__.' answerId: '.$answerId.'('.$answerType.') - user delineation_cord: '.$delineation_cord.' - $answer_delineation_destination: '.$answer_delineation_destination,0);}
224 224
 
225
-		switch($answerType) {
226
-			// for unique answer
227
-			case UNIQUE_ANSWER :
228
-				$studentChoice = ($choice_value == $numAnswer)?1:0;
229
-				if ($studentChoice) {
230
-					$questionScore	+=$answerWeighting;
231
-					$totalScore		+=$answerWeighting;
232
-					$newquestionList[]=$questionid;
233
-				}
234
-				break;
235
-			case HOT_SPOT_DELINEATION :
236
-			    $studentChoice=$choice[$answerId];
237
-				if ($studentChoice) {
238
-					$newquestionList[]=$questionid;
239
-				}
240
-				if ($answerId===1) {
241
-					$questionScore	+=$answerWeighting;
242
-					$totalScore		+=$answerWeighting;
243
-					$_SESSION['hotspot_coord'][1]	=$delineation_cord;
244
-					$_SESSION['hotspot_dest'][1]	=$answer_delineation_destination;
245
-				}
246
-				break;
247
-		}
225
+        switch($answerType) {
226
+            // for unique answer
227
+            case UNIQUE_ANSWER :
228
+                $studentChoice = ($choice_value == $numAnswer)?1:0;
229
+                if ($studentChoice) {
230
+                    $questionScore	+=$answerWeighting;
231
+                    $totalScore		+=$answerWeighting;
232
+                    $newquestionList[]=$questionid;
233
+                }
234
+                break;
235
+            case HOT_SPOT_DELINEATION :
236
+                $studentChoice=$choice[$answerId];
237
+                if ($studentChoice) {
238
+                    $newquestionList[]=$questionid;
239
+                }
240
+                if ($answerId===1) {
241
+                    $questionScore	+=$answerWeighting;
242
+                    $totalScore		+=$answerWeighting;
243
+                    $_SESSION['hotspot_coord'][1]	=$delineation_cord;
244
+                    $_SESSION['hotspot_dest'][1]	=$answer_delineation_destination;
245
+                }
246
+                break;
247
+        }
248 248
 
249 249
 
250 250
         if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER) {
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
                         $lp_hotspot=$destination_items[2];
342 342
                         $select_question_hotspot=$destination_items[3];
343 343
                         $url_hotspot=$destination_items[4];
344
-                         //echo 'show the feedback';
344
+                            //echo 'show the feedback';
345 345
                     }
346 346
                 } elseif($answerId>1) {
347 347
                     if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
@@ -398,41 +398,41 @@  discard block
 block discarded – undo
398 398
                 //we send the error
399 399
             }
400 400
         }
401
-	}
401
+    }
402 402
 
403
-	if ($overlap_color) {
404
-		$overlap_color='green';
403
+    if ($overlap_color) {
404
+        $overlap_color='green';
405 405
     } else {
406
-		$overlap_color='red';
406
+        $overlap_color='red';
407 407
     }
408
-	if ($missing_color) {
409
-		$missing_color='green';
408
+    if ($missing_color) {
409
+        $missing_color='green';
410 410
     } else {
411
-		$missing_color='red';
411
+        $missing_color='red';
412 412
     }
413
-	if ($excess_color) {
414
-		$excess_color='green';
413
+    if ($excess_color) {
414
+        $excess_color='green';
415 415
     } else {
416
-		$excess_color='red';
416
+        $excess_color='red';
417 417
     }
418 418
 
419 419
     if (!is_numeric($final_overlap)) {
420
-    	$final_overlap = 0;
420
+        $final_overlap = 0;
421 421
     }
422 422
 
423 423
     if (!is_numeric($final_missing)) {
424
-    	$final_missing = 0;
424
+        $final_missing = 0;
425 425
     }
426 426
     if (!is_numeric($final_excess)) {
427
-    	$final_excess = 0;
427
+        $final_excess = 0;
428 428
     }
429 429
 
430 430
     if ($final_excess>100) {
431
-    	$final_excess = 100;
431
+        $final_excess = 100;
432 432
     }
433 433
 
434 434
 
435
-	$table_resume = '<table class="data_table" >
435
+    $table_resume = '<table class="data_table" >
436 436
 	<tr class="row_odd" >
437 437
 		<td></td>
438 438
 		<td ><b>'.get_lang('Requirements').'</b></td>
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 		<td><div style="color:'.$missing_color.'">'.(($final_missing < 0)?0:intval($final_missing)).'</div></td>
458 458
 	</tr>
459 459
 	</table>';
460
-	//var_dump($final_overlap, $threadhold1 , $final_missing, $threadhold2 , $final_excess, $threadhold3);
460
+    //var_dump($final_overlap, $threadhold1 , $final_missing, $threadhold2 , $final_excess, $threadhold3);
461 461
 }
462 462
 $_SESSION['newquestionList'] = $newquestionList;
463 463
 
@@ -474,68 +474,68 @@  discard block
 block discarded – undo
474 474
 if ($answerType != HOT_SPOT_DELINEATION) {
475 475
     if (!empty($destination)) {
476 476
         $item_list = explode('@@',$destination);
477
-    	//print_R($item_list);
478
-    	$try = $item_list[0];
479
-    	$lp = $item_list[1];
480
-    	$destinationid= $item_list[2];
481
-    	$url=$item_list[3];
477
+        //print_R($item_list);
478
+        $try = $item_list[0];
479
+        $lp = $item_list[1];
480
+        $destinationid= $item_list[2];
481
+        $url=$item_list[3];
482 482
     }
483
-	$table_resume='';
483
+    $table_resume='';
484 484
 } else {
485
-		$try = $try_hotspot;
486
-		$lp = $lp_hotspot;
487
-		$destinationid= $select_question_hotspot;
488
-		$url=$url_hotspot;
489
-	if ($organs_at_risk_hit==0 && $wrong_results==false ) {
490
-		// no error = no oar and no wrong result for delineation
491
-		//show if no error
492
-		//echo 'no error';
493
-		$comment= $answerComment = $objAnswerTmp->selectComment($nbrAnswers);
494
-		$answerDestination		 = $objAnswerTmp->selectDestination($nbrAnswers);
495
-
496
-		//we send the error
497
-		$destination_items= explode('@@', $answerDestination);
498
-		$try=$destination_items[1];
499
-		$lp=$destination_items[2];
500
-		$destinationid=$destination_items[3];
501
-		$url=$destination_items[4];
502
-		$exerciseResult[$questionid] = 1;
503
-	} else {
504
-		$exerciseResult[$questionid] = 0;
505
-	}
485
+        $try = $try_hotspot;
486
+        $lp = $lp_hotspot;
487
+        $destinationid= $select_question_hotspot;
488
+        $url=$url_hotspot;
489
+    if ($organs_at_risk_hit==0 && $wrong_results==false ) {
490
+        // no error = no oar and no wrong result for delineation
491
+        //show if no error
492
+        //echo 'no error';
493
+        $comment= $answerComment = $objAnswerTmp->selectComment($nbrAnswers);
494
+        $answerDestination		 = $objAnswerTmp->selectDestination($nbrAnswers);
495
+
496
+        //we send the error
497
+        $destination_items= explode('@@', $answerDestination);
498
+        $try=$destination_items[1];
499
+        $lp=$destination_items[2];
500
+        $destinationid=$destination_items[3];
501
+        $url=$destination_items[4];
502
+        $exerciseResult[$questionid] = 1;
503
+    } else {
504
+        $exerciseResult[$questionid] = 0;
505
+    }
506 506
 }
507 507
 
508 508
 // the link to retry the question
509 509
 if (isset($try) && $try==1) {
510
-	$num_value_array= (array_keys($questionList, $questionid));
511
-	$links.= Display :: return_icon('reload.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('TryAgain').'</a><br /><br />';
510
+    $num_value_array= (array_keys($questionList, $questionid));
511
+    $links.= Display :: return_icon('reload.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('TryAgain').'</a><br /><br />';
512 512
 }
513 513
 
514 514
 // the link to theory (a learning path)
515 515
 if (!empty($lp)) {
516
-	$lp_url= api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$lp;
517
-	$list = new LearnpathList(api_get_user_id());
518
-	$flat_list = $list->get_flat_list();
519
-	$links.= Display :: return_icon('theory.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a target="_blank" href="'.$lp_url.'">'.get_lang('SeeTheory').'</a><br />';
516
+    $lp_url= api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$lp;
517
+    $list = new LearnpathList(api_get_user_id());
518
+    $flat_list = $list->get_flat_list();
519
+    $links.= Display :: return_icon('theory.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a target="_blank" href="'.$lp_url.'">'.get_lang('SeeTheory').'</a><br />';
520 520
 }
521 521
 $links.='<br />';
522 522
 
523 523
 // the link to an external website or link
524 524
 if (!empty($url)) {
525
-	$links.= Display :: return_icon('link.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a target="_blank" href="'.$url.'">'.get_lang('VisitUrl').'</a><br /><br />';
525
+    $links.= Display :: return_icon('link.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a target="_blank" href="'.$url.'">'.get_lang('VisitUrl').'</a><br /><br />';
526 526
 }
527 527
 
528 528
 // the link to finish the test
529 529
 if ($destinationid==-1) {
530
-	$links.= Display :: return_icon('finish.gif', '', array ('style' => 'width:22px; height:22px; padding-left:0px;padding-right:5px;')).'<a onclick="SendEx(-1);" href="#">'.get_lang('EndActivity').'</a><br /><br />';
530
+    $links.= Display :: return_icon('finish.gif', '', array ('style' => 'width:22px; height:22px; padding-left:0px;padding-right:5px;')).'<a onclick="SendEx(-1);" href="#">'.get_lang('EndActivity').'</a><br /><br />';
531 531
 } else {
532
-	// the link to other question
533
-	if (in_array($destinationid,$questionList)) {
534
-		$objQuestionTmp = Question :: read($destinationid);
535
-		$questionName=$objQuestionTmp->selectTitle();
536
-		$num_value_array= (array_keys($questionList, $destinationid));
537
-		$links.= Display :: return_icon('quiz.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('GoToQuestion').' '.$num_value_array[0].'</a><br /><br />';
538
-	}
532
+    // the link to other question
533
+    if (in_array($destinationid,$questionList)) {
534
+        $objQuestionTmp = Question :: read($destinationid);
535
+        $questionName=$objQuestionTmp->selectTitle();
536
+        $num_value_array= (array_keys($questionList, $destinationid));
537
+        $links.= Display :: return_icon('quiz.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('GoToQuestion').' '.$num_value_array[0].'</a><br /><br />';
538
+    }
539 539
 }
540 540
 
541 541
 echo '<script>
@@ -552,43 +552,43 @@  discard block
 block discarded – undo
552 552
 </script>';
553 553
 
554 554
 if ($links!='') {
555
-	/*echo '<div id="ModalContent" style="padding-bottom:30px;padding-top:10px;padding-left:20px;padding-right:20px;">
555
+    /*echo '<div id="ModalContent" style="padding-bottom:30px;padding-top:10px;padding-left:20px;padding-right:20px;">
556 556
     <a onclick="self.parent.tb_remove();" href="#" style="float:right; margin-top:-10px;">'.api_ucfirst(get_lang('Close')).'</a>';*/
557
-	echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>';
558
-
559
-	if ($answerType == HOT_SPOT_DELINEATION) {
560
-		if ($organs_at_risk_hit > 0) {
561
-			//$message='<p>'.get_lang('YourDelineation').'</p>';
562
-			//$message.=$table_resume;
563
-			$message.='<br />'.get_lang('ResultIs').' <b>'.get_lang('Unacceptable').'</b><br />';
564
-			//if ($wrong_results) { }
565
-			$message.='<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>';
566
-			$message.='<p>'.$comment.'</p>';
567
-		} else {
568
-			$message='<p>'.get_lang('YourDelineation').'</p>';
569
-			$message.=$table_resume;
570
-			$message.='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
571
-			$message.='<p>'.$comment.'</p>';
572
-		}
573
-		echo $message;
574
-	} else {
575
-		echo '<p>'.$comment.'</p>';
576
-	}
577
-	echo '<h3>'.$links.'</h3>';
578
-	echo '</div>';
579
-
580
-	$_SESSION['hot_spot_result']=$message;
581
-	$_SESSION['hotspot_delineation_result'][$exerciseId][$questionid] = array($message, $exerciseResult[$questionid]);
582
-	//reseting the exerciseResult variable
583
-	Session::write('exerciseResult',$exerciseResult);
584
-
585
-	//save this variables just in case the exercise loads an LP with other exercise
586
-	$_SESSION['objExerciseExtra'.$exerciseId] 	 = $_SESSION['objExercise'];
587
-	$_SESSION['exerciseResultExtra'.$exerciseId] = $_SESSION['exerciseResult'];
588
-	$_SESSION['questionListExtra'.$exerciseId]	 = $_SESSION['questionList'];
557
+    echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>';
558
+
559
+    if ($answerType == HOT_SPOT_DELINEATION) {
560
+        if ($organs_at_risk_hit > 0) {
561
+            //$message='<p>'.get_lang('YourDelineation').'</p>';
562
+            //$message.=$table_resume;
563
+            $message.='<br />'.get_lang('ResultIs').' <b>'.get_lang('Unacceptable').'</b><br />';
564
+            //if ($wrong_results) { }
565
+            $message.='<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>';
566
+            $message.='<p>'.$comment.'</p>';
567
+        } else {
568
+            $message='<p>'.get_lang('YourDelineation').'</p>';
569
+            $message.=$table_resume;
570
+            $message.='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
571
+            $message.='<p>'.$comment.'</p>';
572
+        }
573
+        echo $message;
574
+    } else {
575
+        echo '<p>'.$comment.'</p>';
576
+    }
577
+    echo '<h3>'.$links.'</h3>';
578
+    echo '</div>';
579
+
580
+    $_SESSION['hot_spot_result']=$message;
581
+    $_SESSION['hotspot_delineation_result'][$exerciseId][$questionid] = array($message, $exerciseResult[$questionid]);
582
+    //reseting the exerciseResult variable
583
+    Session::write('exerciseResult',$exerciseResult);
584
+
585
+    //save this variables just in case the exercise loads an LP with other exercise
586
+    $_SESSION['objExerciseExtra'.$exerciseId] 	 = $_SESSION['objExercise'];
587
+    $_SESSION['exerciseResultExtra'.$exerciseId] = $_SESSION['exerciseResult'];
588
+    $_SESSION['questionListExtra'.$exerciseId]	 = $_SESSION['questionList'];
589 589
 } else {
590
-	$questionNum++;
591
-	echo '<script>
590
+    $questionNum++;
591
+    echo '<script>
592 592
 			self.parent.window.location.href = "exercise_submit.php?exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'";
593 593
    			//self.parent.tb_remove();
594 594
  	 	</script>';
Please login to merge, or discard this patch.
Spacing   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 	$learnpath_item_id = intval($_REQUEST['learnpath_item_id']);
53 53
 }
54 54
 
55
-$_SESSION['hotspot_coord']=array();
56
-$newquestionList= isset($_SESSION['newquestionList']) ? $_SESSION['newquestionList'] : [];
57
-$questionList 	= $_SESSION['questionList'];
55
+$_SESSION['hotspot_coord'] = array();
56
+$newquestionList = isset($_SESSION['newquestionList']) ? $_SESSION['newquestionList'] : [];
57
+$questionList = $_SESSION['questionList'];
58 58
 
59 59
 $exerciseId		= intval($_GET['exerciseId']);
60 60
 $exerciseType	= intval($_GET['exerciseType']);
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 
85 85
 $choice_value = '';
86 86
 
87
-$user_array = substr($user_array,0,-1);
87
+$user_array = substr($user_array, 0, -1);
88 88
 
89
-if (isset($_GET['choice'])){
89
+if (isset($_GET['choice'])) {
90 90
     $choice_value = intval($_GET['choice']);
91 91
 }
92 92
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 }
134 134
 
135 135
 $choice = array();
136
-$questionid= $questionList[$questionNum];
136
+$questionid = $questionList[$questionNum];
137 137
 // $choice_value => value of the user selection
138 138
 $choice[$questionid] = isset($choice_value) ? $choice_value : null;
139 139
 
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
         $exerciseResult = $choice;
151 151
     } else {
152 152
         // gets the question ID from $choice. It is the key of the array
153
-        list($key)=array_keys($choice);
153
+        list($key) = array_keys($choice);
154 154
         // if the user didn't already answer this question
155
-        if(!isset($exerciseResult[$key])) {
155
+        if (!isset($exerciseResult[$key])) {
156 156
             // stores the user answer into the array
157
-            $exerciseResult[$key]=$choice[$key];
157
+            $exerciseResult[$key] = $choice[$key];
158 158
         }
159 159
     }
160 160
 }
@@ -180,26 +180,26 @@  discard block
 block discarded – undo
180 180
 
181 181
 // creates a temporary Question object
182 182
 if (in_array($questionid, $questionList)) {
183
-	$objQuestionTmp 	= Question :: read($questionid);
184
-	$questionName		=$objQuestionTmp->selectTitle();
185
-	$questionDescription=$objQuestionTmp->selectDescription();
186
-	$questionWeighting	=$objQuestionTmp->selectWeighting();
187
-	$answerType			=$objQuestionTmp->selectType();
188
-	$quesId				=$objQuestionTmp->selectId(); //added by priya saini
183
+	$objQuestionTmp = Question :: read($questionid);
184
+	$questionName = $objQuestionTmp->selectTitle();
185
+	$questionDescription = $objQuestionTmp->selectDescription();
186
+	$questionWeighting = $objQuestionTmp->selectWeighting();
187
+	$answerType = $objQuestionTmp->selectType();
188
+	$quesId = $objQuestionTmp->selectId(); //added by priya saini
189 189
 }
190 190
 
191
-$objAnswerTmp=new Answer($questionid);
192
-$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
191
+$objAnswerTmp = new Answer($questionid);
192
+$nbrAnswers = $objAnswerTmp->selectNbrAnswers();
193 193
 //echo 'answe_type '.$answerType;echo '<br />';
194 194
 
195 195
 $choice = $exerciseResult[$questionid];
196
-$destination=array();
197
-$comment='';
198
-$next=1;
196
+$destination = array();
197
+$comment = '';
198
+$next = 1;
199 199
 $_SESSION['hotspot_coord'] = array();
200 200
 $_SESSION['hotspot_dest'] = array();
201 201
 
202
-$overlap_color = $missing_color = $excess_color=false;
202
+$overlap_color = $missing_color = $excess_color = false;
203 203
 $organs_at_risk_hit = 0;
204 204
 $wrong_results = false;
205 205
 $hot_spot_load = false;
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 $totalScore = 0;
209 209
 
210 210
 if (!empty($choice_value)) {
211
-	for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
211
+	for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
212 212
 		$answer            = $objAnswerTmp->selectAnswer($answerId);
213 213
 		$answerComment     = $objAnswerTmp->selectComment($answerId);
214 214
 		$answerDestination = $objAnswerTmp->selectDestination($answerId);
@@ -219,29 +219,29 @@  discard block
 block discarded – undo
219 219
 
220 220
 		//delineation
221 221
 		$delineation_cord  = $objAnswerTmp->selectHotspotCoordinates(1);
222
-		$answer_delineation_destination=$objAnswerTmp->selectDestination(1);
223
-        if ($dbg_local>0) { error_log(__LINE__.' answerId: '.$answerId.'('.$answerType.') - user delineation_cord: '.$delineation_cord.' - $answer_delineation_destination: '.$answer_delineation_destination,0);}
222
+		$answer_delineation_destination = $objAnswerTmp->selectDestination(1);
223
+        if ($dbg_local > 0) { error_log(__LINE__.' answerId: '.$answerId.'('.$answerType.') - user delineation_cord: '.$delineation_cord.' - $answer_delineation_destination: '.$answer_delineation_destination, 0); }
224 224
 
225
-		switch($answerType) {
225
+		switch ($answerType) {
226 226
 			// for unique answer
227 227
 			case UNIQUE_ANSWER :
228
-				$studentChoice = ($choice_value == $numAnswer)?1:0;
228
+				$studentChoice = ($choice_value == $numAnswer) ? 1 : 0;
229 229
 				if ($studentChoice) {
230
-					$questionScore	+=$answerWeighting;
231
-					$totalScore		+=$answerWeighting;
232
-					$newquestionList[]=$questionid;
230
+					$questionScore += $answerWeighting;
231
+					$totalScore		+= $answerWeighting;
232
+					$newquestionList[] = $questionid;
233 233
 				}
234 234
 				break;
235 235
 			case HOT_SPOT_DELINEATION :
236
-			    $studentChoice=$choice[$answerId];
236
+			    $studentChoice = $choice[$answerId];
237 237
 				if ($studentChoice) {
238
-					$newquestionList[]=$questionid;
238
+					$newquestionList[] = $questionid;
239 239
 				}
240
-				if ($answerId===1) {
241
-					$questionScore	+=$answerWeighting;
242
-					$totalScore		+=$answerWeighting;
243
-					$_SESSION['hotspot_coord'][1]	=$delineation_cord;
244
-					$_SESSION['hotspot_dest'][1]	=$answer_delineation_destination;
240
+				if ($answerId === 1) {
241
+					$questionScore += $answerWeighting;
242
+					$totalScore += $answerWeighting;
243
+					$_SESSION['hotspot_coord'][1] = $delineation_cord;
244
+					$_SESSION['hotspot_dest'][1] = $answer_delineation_destination;
245 245
 				}
246 246
 				break;
247 247
 		}
@@ -253,27 +253,27 @@  discard block
 block discarded – undo
253 253
                 $destination = $answerDestination;
254 254
                 $comment = $answerComment;
255 255
             }
256
-        } elseif($answerType == HOT_SPOT_DELINEATION) {
256
+        } elseif ($answerType == HOT_SPOT_DELINEATION) {
257 257
             if ($next) {
258
-                if ($dbg_local>0) { error_log(__LINE__.' - next',0);}
258
+                if ($dbg_local > 0) { error_log(__LINE__.' - next', 0); }
259 259
                 $hot_spot_load = true; //apparently the script is called twice
260 260
                 $user_answer = $user_array;
261
-                $_SESSION['exerciseResultCoordinates'][$questionid]=$user_answer; //needed for exercise_result.php
261
+                $_SESSION['exerciseResultCoordinates'][$questionid] = $user_answer; //needed for exercise_result.php
262 262
 
263 263
                 // we compare only the delineation not the other points
264
-                $answer_question	= $_SESSION['hotspot_coord'][1];
265
-                $answerDestination	= $_SESSION['hotspot_dest'][1];
264
+                $answer_question = $_SESSION['hotspot_coord'][1];
265
+                $answerDestination = $_SESSION['hotspot_dest'][1];
266 266
 
267
-                $poly_user 				= convert_coordinates($user_answer,'/');
268
-                $poly_answer 			= convert_coordinates($answer_question,'|');
269
-                $max_coord 				= poly_get_max($poly_user,$poly_answer);
267
+                $poly_user 				= convert_coordinates($user_answer, '/');
268
+                $poly_answer = convert_coordinates($answer_question, '|');
269
+                $max_coord 				= poly_get_max($poly_user, $poly_answer);
270 270
 
271 271
                 if (empty($_GET['hotspot'])) { //no user response
272 272
                     $overlap = -2;
273 273
                 } else {
274
-                    $poly_user_compiled 	= poly_compile($poly_user,$max_coord);
275
-                    $poly_answer_compiled 	= poly_compile($poly_answer,$max_coord);
276
-                    $poly_results 			= poly_result($poly_answer_compiled,$poly_user_compiled,$max_coord);
274
+                    $poly_user_compiled = poly_compile($poly_user, $max_coord);
275
+                    $poly_answer_compiled = poly_compile($poly_answer, $max_coord);
276
+                    $poly_results = poly_result($poly_answer_compiled, $poly_user_compiled, $max_coord);
277 277
 
278 278
                     $overlap = $poly_results['both'];
279 279
                     $poly_answer_area = $poly_results['s1'];
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
                 }
284 284
 
285 285
                 //$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels
286
-                if ($dbg_local>0) { error_log(__LINE__.' - Polygons results are '.print_r($poly_results,1),0);}
286
+                if ($dbg_local > 0) { error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0); }
287 287
                 if ($overlap < 1) {
288 288
                     //shortcut to avoid complicated calculations
289 289
                     $final_overlap = 0;
@@ -291,27 +291,27 @@  discard block
 block discarded – undo
291 291
                     $final_excess  = 100;
292 292
                 } else {
293 293
                     // the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon
294
-                    $final_overlap = round(((float)$overlap / (float)$poly_answer_area)*100);
295
-                    if ($dbg_local>1) { error_log(__LINE__.' - Final overlap is '.$final_overlap,0);}
294
+                    $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100);
295
+                    if ($dbg_local > 1) { error_log(__LINE__.' - Final overlap is '.$final_overlap, 0); }
296 296
                     // the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon
297 297
                     $final_missing = 100 - $final_overlap;
298
-                    if ($dbg_local>1) { error_log(__LINE__.' - Final missing is '.$final_missing,0);}
298
+                    if ($dbg_local > 1) { error_log(__LINE__.' - Final missing is '.$final_missing, 0); }
299 299
                     // the final excess area is the percentage of the initial polygon's size that is covered by the user's polygon outside of the initial polygon
300
-                    $final_excess = round((((float)$poly_user_area-(float)$overlap)/(float)$poly_answer_area)*100);
301
-                    if ($dbg_local>1) { error_log(__LINE__.' - Final excess is '.$final_excess,0);}
300
+                    $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100);
301
+                    if ($dbg_local > 1) { error_log(__LINE__.' - Final excess is '.$final_excess, 0); }
302 302
                 }
303 303
 
304
-                $destination_items= explode('@@', $answerDestination);
304
+                $destination_items = explode('@@', $answerDestination);
305 305
                 $threadhold_total = $destination_items[0];
306
-                $threadhold_items=explode(';',$threadhold_total);
306
+                $threadhold_items = explode(';', $threadhold_total);
307 307
                 $threadhold1 = $threadhold_items[0]; // overlap
308 308
                 $threadhold2 = $threadhold_items[1]; // excess
309
-                $threadhold3 = $threadhold_items[2];	 //missing
309
+                $threadhold3 = $threadhold_items[2]; //missing
310 310
 
311 311
                 // echo $final_overlap.'  '.$threadhold1 .' - '. $final_missing.' '. $threadhold2 .' - '. $final_excess.'  '. $threadhold3;
312 312
 
313 313
                 // if is delineation
314
-                if ($answerId===1) {
314
+                if ($answerId === 1) {
315 315
                     //setting colors
316 316
                     if ($final_overlap >= $threadhold1) {
317 317
                         $overlap_color = true; //echo 'a';
@@ -327,40 +327,40 @@  discard block
 block discarded – undo
327 327
 
328 328
                     // if pass
329 329
                     //if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold2 && $final_excess<=$threadhold3) {
330
-                    if ($final_overlap>=$threadhold1 && $final_missing<=$threadhold3 && $final_excess<=$threadhold2) {
331
-                        $next=1; //go to the oars
332
-                        $result_comment=get_lang('Acceptable');
330
+                    if ($final_overlap >= $threadhold1 && $final_missing <= $threadhold3 && $final_excess <= $threadhold2) {
331
+                        $next = 1; //go to the oars
332
+                        $result_comment = get_lang('Acceptable');
333 333
                     } else {
334
-                        $next=1; //Go to the oars. If $next =  0 we will show this message: "One (or more) area at risk has been hit" instead of the table resume with the results
334
+                        $next = 1; //Go to the oars. If $next =  0 we will show this message: "One (or more) area at risk has been hit" instead of the table resume with the results
335 335
                         $wrong_results = true;
336
-                        $result_comment=get_lang('Unacceptable');
337
-                        $special_comment = $comment=$answerDestination=$objAnswerTmp->selectComment(1);
338
-                        $answerDestination=$objAnswerTmp->selectDestination(1);
339
-                        $destination_items= explode('@@', $answerDestination);
340
-                        $try_hotspot=$destination_items[1];
341
-                        $lp_hotspot=$destination_items[2];
342
-                        $select_question_hotspot=$destination_items[3];
343
-                        $url_hotspot=$destination_items[4];
336
+                        $result_comment = get_lang('Unacceptable');
337
+                        $special_comment = $comment = $answerDestination = $objAnswerTmp->selectComment(1);
338
+                        $answerDestination = $objAnswerTmp->selectDestination(1);
339
+                        $destination_items = explode('@@', $answerDestination);
340
+                        $try_hotspot = $destination_items[1];
341
+                        $lp_hotspot = $destination_items[2];
342
+                        $select_question_hotspot = $destination_items[3];
343
+                        $url_hotspot = $destination_items[4];
344 344
                          //echo 'show the feedback';
345 345
                     }
346
-                } elseif($answerId>1) {
346
+                } elseif ($answerId > 1) {
347 347
                     if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
348
-                        if ($dbg_local>0) { error_log(__LINE__.' - answerId is of type noerror',0);}
348
+                        if ($dbg_local > 0) { error_log(__LINE__.' - answerId is of type noerror', 0); }
349 349
                         //type no error shouldn't be treated
350 350
                         $next = 1;
351 351
                         continue;
352 352
                     }
353
-                    if ($dbg_local>0) { error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR',0);}
353
+                    if ($dbg_local > 0) { error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0); }
354 354
                     //check the intersection between the oar and the user
355 355
                     //echo 'user';	print_r($x_user_list);		print_r($y_user_list);
356 356
                     //echo 'official';print_r($x_list);print_r($y_list);
357 357
                     //$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list);
358 358
 
359 359
                     //$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
360
-                    $delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId); //getting the oars coordinates
360
+                    $delineation_cord = $objAnswerTmp->selectHotspotCoordinates($answerId); //getting the oars coordinates
361 361
 
362
-                    $poly_answer 			= convert_coordinates($delineation_cord,'|');
363
-                    $max_coord 				= poly_get_max($poly_user,$poly_answer); //getting max coordinates
362
+                    $poly_answer = convert_coordinates($delineation_cord, '|');
363
+                    $max_coord = poly_get_max($poly_user, $poly_answer); //getting max coordinates
364 364
                     $test = false;
365 365
                     // if ($answerId == 2 ){$test = true;} for test oars
366 366
 
@@ -368,9 +368,9 @@  discard block
 block discarded – undo
368 368
                         $overlap = false;
369 369
                     } else {
370 370
                         //	poly_compile really works tested with gnuplot
371
-                        $poly_user_compiled	  	= poly_compile($poly_user,$max_coord,$test);//$poly_user is already set when answerid = 1
372
-                        $poly_answer_compiled 	= poly_compile($poly_answer,$max_coord,$test);
373
-                        $overlap 			  	= poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord);
371
+                        $poly_user_compiled	  	= poly_compile($poly_user, $max_coord, $test); //$poly_user is already set when answerid = 1
372
+                        $poly_answer_compiled 	= poly_compile($poly_answer, $max_coord, $test);
373
+                        $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord);
374 374
                     }
375 375
 
376 376
                     if ($overlap == false) {
@@ -378,42 +378,42 @@  discard block
 block discarded – undo
378 378
                         $next = 1;
379 379
                         continue;
380 380
                     } else {
381
-                        if ($dbg_local>0) { error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0);}
381
+                        if ($dbg_local > 0) { error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit', 0); }
382 382
 
383 383
                         $organs_at_risk_hit++;
384 384
                         //show the feedback
385
-                        $next=1;
386
-                        $comment=$answerDestination=$objAnswerTmp->selectComment($answerId);
387
-                        $answerDestination=$objAnswerTmp->selectDestination($answerId);
388
-                        $destination_items= explode('@@', $answerDestination);
389
-                        $try_hotspot=$destination_items[1];
390
-                        $lp_hotspot=$destination_items[2];
391
-                        $select_question_hotspot=$destination_items[3];
392
-                        $url_hotspot=$destination_items[4];
385
+                        $next = 1;
386
+                        $comment = $answerDestination = $objAnswerTmp->selectComment($answerId);
387
+                        $answerDestination = $objAnswerTmp->selectDestination($answerId);
388
+                        $destination_items = explode('@@', $answerDestination);
389
+                        $try_hotspot = $destination_items[1];
390
+                        $lp_hotspot = $destination_items[2];
391
+                        $select_question_hotspot = $destination_items[3];
392
+                        $url_hotspot = $destination_items[4];
393 393
                     }
394 394
                 }
395 395
             } else {
396 396
                 // the first delineation feedback
397
-                if ($dbg_local>0) { error_log(__LINE__.' first',0);}
397
+                if ($dbg_local > 0) { error_log(__LINE__.' first', 0); }
398 398
                 //we send the error
399 399
             }
400 400
         }
401 401
 	}
402 402
 
403 403
 	if ($overlap_color) {
404
-		$overlap_color='green';
404
+		$overlap_color = 'green';
405 405
     } else {
406
-		$overlap_color='red';
406
+		$overlap_color = 'red';
407 407
     }
408 408
 	if ($missing_color) {
409
-		$missing_color='green';
409
+		$missing_color = 'green';
410 410
     } else {
411
-		$missing_color='red';
411
+		$missing_color = 'red';
412 412
     }
413 413
 	if ($excess_color) {
414
-		$excess_color='green';
414
+		$excess_color = 'green';
415 415
     } else {
416
-		$excess_color='red';
416
+		$excess_color = 'red';
417 417
     }
418 418
 
419 419
     if (!is_numeric($final_overlap)) {
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
     	$final_excess = 0;
428 428
     }
429 429
 
430
-    if ($final_excess>100) {
430
+    if ($final_excess > 100) {
431 431
     	$final_excess = 100;
432 432
     }
433 433
 
@@ -442,26 +442,26 @@  discard block
 block discarded – undo
442 442
 	<tr class="row_even">
443 443
 		<td><b>'.get_lang('Overlap').'</b></td>
444 444
 		<td>'.get_lang('Min').' '.$threadhold1.'</td>
445
-		<td><div style="color:'.$overlap_color.'">'.(($final_overlap < 0)?0:intval($final_overlap)).'</div></td>
445
+		<td><div style="color:'.$overlap_color.'">'.(($final_overlap < 0) ? 0 : intval($final_overlap)).'</div></td>
446 446
 	</tr>
447 447
 
448 448
 	<tr>
449 449
 		<td><b>'.get_lang('Excess').'</b></td>
450 450
 		<td>'.get_lang('Max').' '.$threadhold2.'</td>
451
-		<td><div style="color:'.$excess_color.'">'.(($final_excess < 0)?0:intval($final_excess)).'</div></td>
451
+		<td><div style="color:'.$excess_color.'">'.(($final_excess < 0) ? 0 : intval($final_excess)).'</div></td>
452 452
 	</tr>
453 453
 
454 454
 	<tr class="row_even">
455 455
 		<td><b>'.get_lang('Missing').'</b></td>
456 456
 		<td>'.get_lang('Max').' '.$threadhold3.'</td>
457
-		<td><div style="color:'.$missing_color.'">'.(($final_missing < 0)?0:intval($final_missing)).'</div></td>
457
+		<td><div style="color:'.$missing_color.'">'.(($final_missing < 0) ? 0 : intval($final_missing)).'</div></td>
458 458
 	</tr>
459 459
 	</table>';
460 460
 	//var_dump($final_overlap, $threadhold1 , $final_missing, $threadhold2 , $final_excess, $threadhold3);
461 461
 }
462 462
 $_SESSION['newquestionList'] = $newquestionList;
463 463
 
464
-$links='';
464
+$links = '';
465 465
 
466 466
 if (isset($choice_value) && $choice_value == -1) {
467 467
     if ($answerType != HOT_SPOT_DELINEATION) {
@@ -473,32 +473,32 @@  discard block
 block discarded – undo
473 473
 
474 474
 if ($answerType != HOT_SPOT_DELINEATION) {
475 475
     if (!empty($destination)) {
476
-        $item_list = explode('@@',$destination);
476
+        $item_list = explode('@@', $destination);
477 477
     	//print_R($item_list);
478 478
     	$try = $item_list[0];
479 479
     	$lp = $item_list[1];
480
-    	$destinationid= $item_list[2];
481
-    	$url=$item_list[3];
480
+    	$destinationid = $item_list[2];
481
+    	$url = $item_list[3];
482 482
     }
483
-	$table_resume='';
483
+	$table_resume = '';
484 484
 } else {
485 485
 		$try = $try_hotspot;
486 486
 		$lp = $lp_hotspot;
487
-		$destinationid= $select_question_hotspot;
488
-		$url=$url_hotspot;
489
-	if ($organs_at_risk_hit==0 && $wrong_results==false ) {
487
+		$destinationid = $select_question_hotspot;
488
+		$url = $url_hotspot;
489
+	if ($organs_at_risk_hit == 0 && $wrong_results == false) {
490 490
 		// no error = no oar and no wrong result for delineation
491 491
 		//show if no error
492 492
 		//echo 'no error';
493
-		$comment= $answerComment = $objAnswerTmp->selectComment($nbrAnswers);
494
-		$answerDestination		 = $objAnswerTmp->selectDestination($nbrAnswers);
493
+		$comment = $answerComment = $objAnswerTmp->selectComment($nbrAnswers);
494
+		$answerDestination = $objAnswerTmp->selectDestination($nbrAnswers);
495 495
 
496 496
 		//we send the error
497
-		$destination_items= explode('@@', $answerDestination);
498
-		$try=$destination_items[1];
499
-		$lp=$destination_items[2];
500
-		$destinationid=$destination_items[3];
501
-		$url=$destination_items[4];
497
+		$destination_items = explode('@@', $answerDestination);
498
+		$try = $destination_items[1];
499
+		$lp = $destination_items[2];
500
+		$destinationid = $destination_items[3];
501
+		$url = $destination_items[4];
502 502
 		$exerciseResult[$questionid] = 1;
503 503
 	} else {
504 504
 		$exerciseResult[$questionid] = 0;
@@ -506,35 +506,35 @@  discard block
 block discarded – undo
506 506
 }
507 507
 
508 508
 // the link to retry the question
509
-if (isset($try) && $try==1) {
510
-	$num_value_array= (array_keys($questionList, $questionid));
511
-	$links.= Display :: return_icon('reload.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('TryAgain').'</a><br /><br />';
509
+if (isset($try) && $try == 1) {
510
+	$num_value_array = (array_keys($questionList, $questionid));
511
+	$links .= Display :: return_icon('reload.gif', '', array('style' => 'padding-left:0px;padding-right:5px;')).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('TryAgain').'</a><br /><br />';
512 512
 }
513 513
 
514 514
 // the link to theory (a learning path)
515 515
 if (!empty($lp)) {
516
-	$lp_url= api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$lp;
516
+	$lp_url = api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$lp;
517 517
 	$list = new LearnpathList(api_get_user_id());
518 518
 	$flat_list = $list->get_flat_list();
519
-	$links.= Display :: return_icon('theory.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a target="_blank" href="'.$lp_url.'">'.get_lang('SeeTheory').'</a><br />';
519
+	$links .= Display :: return_icon('theory.gif', '', array('style' => 'padding-left:0px;padding-right:5px;')).'<a target="_blank" href="'.$lp_url.'">'.get_lang('SeeTheory').'</a><br />';
520 520
 }
521
-$links.='<br />';
521
+$links .= '<br />';
522 522
 
523 523
 // the link to an external website or link
524 524
 if (!empty($url)) {
525
-	$links.= Display :: return_icon('link.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a target="_blank" href="'.$url.'">'.get_lang('VisitUrl').'</a><br /><br />';
525
+	$links .= Display :: return_icon('link.gif', '', array('style' => 'padding-left:0px;padding-right:5px;')).'<a target="_blank" href="'.$url.'">'.get_lang('VisitUrl').'</a><br /><br />';
526 526
 }
527 527
 
528 528
 // the link to finish the test
529
-if ($destinationid==-1) {
530
-	$links.= Display :: return_icon('finish.gif', '', array ('style' => 'width:22px; height:22px; padding-left:0px;padding-right:5px;')).'<a onclick="SendEx(-1);" href="#">'.get_lang('EndActivity').'</a><br /><br />';
529
+if ($destinationid == -1) {
530
+	$links .= Display :: return_icon('finish.gif', '', array('style' => 'width:22px; height:22px; padding-left:0px;padding-right:5px;')).'<a onclick="SendEx(-1);" href="#">'.get_lang('EndActivity').'</a><br /><br />';
531 531
 } else {
532 532
 	// the link to other question
533
-	if (in_array($destinationid,$questionList)) {
533
+	if (in_array($destinationid, $questionList)) {
534 534
 		$objQuestionTmp = Question :: read($destinationid);
535
-		$questionName=$objQuestionTmp->selectTitle();
536
-		$num_value_array= (array_keys($questionList, $destinationid));
537
-		$links.= Display :: return_icon('quiz.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('GoToQuestion').' '.$num_value_array[0].'</a><br /><br />';
535
+		$questionName = $objQuestionTmp->selectTitle();
536
+		$num_value_array = (array_keys($questionList, $destinationid));
537
+		$links .= Display :: return_icon('quiz.gif', '', array('style' => 'padding-left:0px;padding-right:5px;')).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('GoToQuestion').' '.$num_value_array[0].'</a><br /><br />';
538 538
 	}
539 539
 }
540 540
 
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
 }
552 552
 </script>';
553 553
 
554
-if ($links!='') {
554
+if ($links != '') {
555 555
 	/*echo '<div id="ModalContent" style="padding-bottom:30px;padding-top:10px;padding-left:20px;padding-right:20px;">
556 556
     <a onclick="self.parent.tb_remove();" href="#" style="float:right; margin-top:-10px;">'.api_ucfirst(get_lang('Close')).'</a>';*/
557 557
 	echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>';
@@ -560,15 +560,15 @@  discard block
 block discarded – undo
560 560
 		if ($organs_at_risk_hit > 0) {
561 561
 			//$message='<p>'.get_lang('YourDelineation').'</p>';
562 562
 			//$message.=$table_resume;
563
-			$message.='<br />'.get_lang('ResultIs').' <b>'.get_lang('Unacceptable').'</b><br />';
563
+			$message .= '<br />'.get_lang('ResultIs').' <b>'.get_lang('Unacceptable').'</b><br />';
564 564
 			//if ($wrong_results) { }
565
-			$message.='<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>';
566
-			$message.='<p>'.$comment.'</p>';
565
+			$message .= '<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>';
566
+			$message .= '<p>'.$comment.'</p>';
567 567
 		} else {
568
-			$message='<p>'.get_lang('YourDelineation').'</p>';
569
-			$message.=$table_resume;
570
-			$message.='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
571
-			$message.='<p>'.$comment.'</p>';
568
+			$message = '<p>'.get_lang('YourDelineation').'</p>';
569
+			$message .= $table_resume;
570
+			$message .= '<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
571
+			$message .= '<p>'.$comment.'</p>';
572 572
 		}
573 573
 		echo $message;
574 574
 	} else {
@@ -577,10 +577,10 @@  discard block
 block discarded – undo
577 577
 	echo '<h3>'.$links.'</h3>';
578 578
 	echo '</div>';
579 579
 
580
-	$_SESSION['hot_spot_result']=$message;
580
+	$_SESSION['hot_spot_result'] = $message;
581 581
 	$_SESSION['hotspot_delineation_result'][$exerciseId][$questionid] = array($message, $exerciseResult[$questionid]);
582 582
 	//reseting the exerciseResult variable
583
-	Session::write('exerciseResult',$exerciseResult);
583
+	Session::write('exerciseResult', $exerciseResult);
584 584
 
585 585
 	//save this variables just in case the exercise loads an LP with other exercise
586 586
 	$_SESSION['objExerciseExtra'.$exerciseId] 	 = $_SESSION['objExercise'];
Please login to merge, or discard this patch.