Completed
Push — 1.10.x ( 812a9a...914b0e )
by Angel Fernando Quiroz
43:28
created
main/exercice/hotspot_updatescore.inc.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -17,25 +17,25 @@
 block discarded – undo
17 17
 $hotspotId	  = $_GET['hotspotId'];
18 18
 $exerciseId   = $objExcercise->selectId();
19 19
 if ($_GET['answerId'] == "0") { // click is NOT on a hotspot
20
-	$hit = 0;
21
-	$answerId = $hotspotId;
20
+    $hit = 0;
21
+    $answerId = $hotspotId;
22 22
 
23
-	// remove from session
24
-	unset($_SESSION['exerciseResult'][$questionId][$answerId]);
23
+    // remove from session
24
+    unset($_SESSION['exerciseResult'][$questionId][$answerId]);
25 25
 
26
-	// Save clicking order
27
-	//$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1;
28
-	//$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId;
26
+    // Save clicking order
27
+    //$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1;
28
+    //$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId;
29 29
 } else { // user clicked ON a hotspot
30
-	$hit = 1;
31
-	$answerId = $hotspotId;
30
+    $hit = 1;
31
+    $answerId = $hotspotId;
32 32
 
33
-	// Save into session
34
-	$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
33
+    // Save into session
34
+    $_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
35 35
 
36
-	// Save clicking order
37
-	//$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1;
38
-	//$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId;
36
+    // Save clicking order
37
+    //$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1;
38
+    //$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId;
39 39
 }
40 40
 
41 41
 //round-up the coordinates
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 $questionId   = $_GET['questionId'];
15 15
 $coordinates  = $_GET['coord'];
16 16
 $objExcercise = $_SESSION['objExercise'];
17
-$hotspotId	  = $_GET['hotspotId'];
17
+$hotspotId = $_GET['hotspotId'];
18 18
 $exerciseId   = $objExcercise->selectId();
19 19
 if ($_GET['answerId'] == "0") { // click is NOT on a hotspot
20 20
 	$hit = 0;
@@ -39,15 +39,15 @@  discard block
 block discarded – undo
39 39
 }
40 40
 
41 41
 //round-up the coordinates
42
-$coords = explode('/',$coordinates);
42
+$coords = explode('/', $coordinates);
43 43
 $coordinates = '';
44 44
 foreach ($coords as $coord) {
45
-    list($x,$y) = explode(';',$coord);
45
+    list($x, $y) = explode(';', $coord);
46 46
     $coordinates .= round($x).';'.round($y).'/';
47 47
 }
48
-$coordinates = substr($coordinates,0,-1);
48
+$coordinates = substr($coordinates, 0, -1);
49 49
 
50
-$TBL_TRACK_E_HOTSPOT   = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
50
+$TBL_TRACK_E_HOTSPOT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
51 51
 
52 52
 // update db
53 53
 $update_id = $_SESSION['exerciseResult'][$questionId]['ids'][$answerId];
Please login to merge, or discard this patch.
main/exercice/hotspot_admin.inc.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -907,10 +907,10 @@
 block discarded – undo
907 907
                                         <?php } else { ?>
908 908
                                             <input class="form-control" type="text" name="weighting[<?php echo $i; ?>]" value="<?php echo (isset($weighting[$i]) ? $weighting[$i] : 10); ?>" />
909 909
                                                    <?php
910
-                                               }
911
-                                           }
912
-                                           if ($answerType == HOT_SPOT) {
913
-                                               ?>
910
+                                                }
911
+                                            }
912
+                                            if ($answerType == HOT_SPOT) {
913
+                                                ?>
914 914
                                         <input class="form-control" type="text" name="weighting[<?php echo $i; ?>]" value="<?php echo (isset($weighting[$i]) ? $weighting[$i] : 10); ?>" />
915 915
                                         <input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]); ?>" />
916 916
                                         <input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_type[$i]) ? 'square' : $hotspot_type[$i]); ?>" />
Please login to merge, or discard this patch.
Braces   +32 added lines, -13 removed lines patch added patch discarded remove patch
@@ -366,8 +366,9 @@  discard block
 block discarded – undo
366 366
         if ($answerType == HOT_SPOT_DELINEATION) {
367 367
             // the magic happens here ...
368 368
             // we do this to not count the if no error section
369
-            if ($nbrAnswers >= 2)
370
-                $nbrAnswers--;
369
+            if ($nbrAnswers >= 2) {
370
+                            $nbrAnswers--;
371
+            }
371 372
         }
372 373
 
373 374
         $reponse = array();
@@ -679,12 +680,15 @@  discard block
 block discarded – undo
679 680
 
680 681
                                     for ($k = 1; $k <= 100; $k++) {
681 682
                                         $selected1 = $selected2 = $selected3 = '';
682
-                                        if ($k == $threadhold1[$i])
683
-                                            $selected1 = 'selected="selected"';
684
-                                        if ($k == $threadhold2[$i])
685
-                                            $selected2 = 'selected="selected"';
686
-                                        if ($k == $threadhold3[$i])
687
-                                            $selected3 = 'selected="selected"';
683
+                                        if ($k == $threadhold1[$i]) {
684
+                                                                                    $selected1 = 'selected="selected"';
685
+                                        }
686
+                                        if ($k == $threadhold2[$i]) {
687
+                                                                                    $selected2 = 'selected="selected"';
688
+                                        }
689
+                                        if ($k == $threadhold3[$i]) {
690
+                                                                                    $selected3 = 'selected="selected"';
691
+                                        }
688 692
                                         $option1.='<option ' . $selected1 . ' >' . $k . ' % </option>';
689 693
                                         $option2.='<option ' . $selected2 . ' >' . $k . ' % </option>';
690 694
                                         $option3.='<option ' . $selected3 . '>' . $k . ' %</option>';
@@ -731,7 +735,10 @@  discard block
 block discarded – undo
731 735
                                                 <div class="checkbox">
732 736
                                                     <p>
733 737
                                                         <label>
734
-                                                            <input type="checkbox" class="checkbox" name="<?php echo 'try[' . $i; ?>]"  <?php if ($try[$i] == 1) echo'checked'; ?> />
738
+                                                            <input type="checkbox" class="checkbox" name="<?php echo 'try[' . $i; ?>]"  <?php if ($try[$i] == 1) {
739
+    echo'checked';
740
+}
741
+?> />
735 742
                                                             <?php echo get_lang('TryAgain'); ?>
736 743
                                                         </label>
737 744
                                                     </p>
@@ -784,7 +791,10 @@  discard block
 block discarded – undo
784 791
                                                             <div class="checkbox">
785 792
                                                                 <p>
786 793
                                                                     <label>
787
-                                                                        <input type="checkbox" class="checkbox" name="<?php echo 'try[' . $i; ?>]" <?php if ($try[$i] == 1) echo'checked'; ?> />
794
+                                                                        <input type="checkbox" class="checkbox" name="<?php echo 'try[' . $i; ?>]" <?php if ($try[$i] == 1) {
795
+    echo'checked';
796
+}
797
+?> />
788 798
                                                                         <?php echo get_lang('TryAgain'); ?>
789 799
                                                                     </label>
790 800
                                                                 </p>
@@ -823,7 +833,10 @@  discard block
 block discarded – undo
823 833
                                             <th ><?php echo get_lang('OAR'); ?>*</th>
824 834
                                             <?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?>
825 835
                                                 <th colspan="2" ><?php echo get_lang('Comment'); ?></th>
826
-                                                <th ><?php if ($answerType == HOT_SPOT_DELINEATION) echo get_lang('Scenario'); ?></th>
836
+                                                <th ><?php if ($answerType == HOT_SPOT_DELINEATION) {
837
+    echo get_lang('Scenario');
838
+}
839
+?></th>
827 840
                                             <?php } else { ?>
828 841
                                                 <th colspan="3" ><?php echo get_lang('Comment'); ?></th>
829 842
                                             <?php } ?>
@@ -849,7 +862,10 @@  discard block
 block discarded – undo
849 862
                                                 <div class="checkbox">
850 863
                                                     <p>
851 864
                                                         <label>
852
-                                                            <input type="checkbox" class="checkbox" name="<?php echo 'try[' . $i; ?>]" <?php if (isset($try[$i]) && $try[$i] == 1) echo'checked'; ?> />
865
+                                                            <input type="checkbox" class="checkbox" name="<?php echo 'try[' . $i; ?>]" <?php if (isset($try[$i]) && $try[$i] == 1) {
866
+    echo'checked';
867
+}
868
+?> />
853 869
                                                             <?php echo get_lang('TryAgain'); ?>
854 870
                                                         </label>
855 871
                                                     </p>
@@ -998,7 +1014,10 @@  discard block
 block discarded – undo
998 1014
                                         <div class="checkbox">
999 1015
                                             <p>
1000 1016
                                                 <label>
1001
-                                                    <input type="checkbox" class="checkbox" name="try_noerror" <?php if ($try_noerror == 1) echo'checked'; ?> />
1017
+                                                    <input type="checkbox" class="checkbox" name="try_noerror" <?php if ($try_noerror == 1) {
1018
+    echo'checked';
1019
+}
1020
+?> />
1002 1021
                                                     <?php echo get_lang('TryAgain'); ?>
1003 1022
                                                 </label>
1004 1023
                                             </p>
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 if ($modifyIn) {
27 27
     if ($debug > 0) {
28
-        echo '$modifyIn was set' . "<br />\n";
28
+        echo '$modifyIn was set'."<br />\n";
29 29
     }
30 30
     // if the user has chosen to modify the question only in the current exercise
31 31
     if ($modifyIn == 'thisExercise') {
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     unset($buttonBack);
65 65
 }
66 66
 
67
-$hotspot_admin_url = api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?' . api_get_cidreq() . '&exerciseId=' . $exerciseId;
67
+$hotspot_admin_url = api_get_path(WEB_CODE_PATH).'exercice/admin.php?'.api_get_cidreq().'&exerciseId='.$exerciseId;
68 68
 
69 69
 // the answer form has been submitted
70 70
 $submitAnswers = isset($_POST['submitAnswers']) ? true : false;
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
 if ($submitAnswers || $buttonBack) {
75 75
     if ($answerType == HOT_SPOT) {
76 76
         if ($debug > 0) {
77
-            echo '$submitAnswers or $buttonBack was set' . "<br />\n";
77
+            echo '$submitAnswers or $buttonBack was set'."<br />\n";
78 78
         }
79 79
 
80 80
         $questionWeighting = $nbrGoodAnswers = 0;
81 81
         for ($i = 1; $i <= $nbrAnswers; $i++) {
82 82
             if ($debug > 0) {
83
-                echo str_repeat('&nbsp;', 4) . '$answerType is HOT_SPOT' . "<br />\n";
83
+                echo str_repeat('&nbsp;', 4).'$answerType is HOT_SPOT'."<br />\n";
84 84
             }
85 85
 
86 86
             $reponse[$i] = trim($reponse[$i]);
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
         if (empty($msgErr)) {
115 115
             for ($i = 1; $i <= $nbrAnswers; $i++) {
116 116
                 if ($debug > 0) {
117
-                    echo str_repeat('&nbsp;', 4) . '$answerType is HOT_SPOT' . "<br />\n";
117
+                    echo str_repeat('&nbsp;', 4).'$answerType is HOT_SPOT'."<br />\n";
118 118
                 }
119 119
 
120 120
                 $reponse[$i] = trim($reponse[$i]);
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
                 $weighting[$i] = ($weighting[$i]); //it can be float
123 123
 
124 124
                 if ($weighting[$i]) {
125
-                    $questionWeighting+=$weighting[$i];
125
+                    $questionWeighting += $weighting[$i];
126 126
                 }
127 127
 
128 128
                 // creates answer
@@ -145,15 +145,15 @@  discard block
 block discarded – undo
145 145
 
146 146
             $editQuestion = $questionId;
147 147
             unset($modifyAnswers);
148
-            echo '<script type="text/javascript">window.location.href="' . $hotspot_admin_url . '&message=ItemUpdated"</script>';
148
+            echo '<script type="text/javascript">window.location.href="'.$hotspot_admin_url.'&message=ItemUpdated"</script>';
149 149
         }
150 150
 
151 151
         if ($debug > 0) {
152
-            echo '$modifyIn was set - end' . "<br />\n";
152
+            echo '$modifyIn was set - end'."<br />\n";
153 153
         }
154 154
     } else {
155 155
         if ($debug > 0) {
156
-            echo '$submitAnswers or $buttonBack was set' . "<br />\n";
156
+            echo '$submitAnswers or $buttonBack was set'."<br />\n";
157 157
         }
158 158
 
159 159
         $questionWeighting = $nbrGoodAnswers = 0;
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 
169 169
         for ($i = 1; $i <= $nbrAnswers; $i++) {
170 170
             if ($debug > 0) {
171
-                echo str_repeat('&nbsp;', 4) . '$answerType is HOT_SPOT' . "<br />\n";
171
+                echo str_repeat('&nbsp;', 4).'$answerType is HOT_SPOT'."<br />\n";
172 172
             }
173 173
 
174 174
             $reponse[$i] = trim($reponse[$i]);
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
                 $threadhold3_str = intval($threadhold3[$i]);
194 194
             }
195 195
 
196
-            $threadhold_total = $threadhold1_str . ';' . $threadhold2_str . ';' . $threadhold3_str;
196
+            $threadhold_total = $threadhold1_str.';'.$threadhold2_str.';'.$threadhold3_str;
197 197
 
198 198
             if (isset($try[$i]) && $try[$i] == 'on') {
199 199
                 $try_str = 1;
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
                 $question_str = $select_question[$i];
220 220
             }
221 221
 
222
-            $destination[$i] = $threadhold_total . '@@' . $try_str . '@@' . $lp_str . '@@' . $question_str . '@@' . $url_str;
222
+            $destination[$i] = $threadhold_total.'@@'.$try_str.'@@'.$lp_str.'@@'.$question_str.'@@'.$url_str;
223 223
 
224 224
             // checks if field is empty
225 225
             if (empty($reponse[$i]) && $reponse[$i] != '0') {
@@ -277,12 +277,12 @@  discard block
 block discarded – undo
277 277
             $question_str = $selectQuestionNoError;
278 278
         }
279 279
 
280
-        $destination_noerror = $threadhold_total . '@@' . $try_str . '@@' . $lp_str . '@@' . $question_str . '@@' . $url_str;
280
+        $destination_noerror = $threadhold_total.'@@'.$try_str.'@@'.$lp_str.'@@'.$question_str.'@@'.$url_str;
281 281
 
282 282
         if (empty($msgErr)) {
283 283
             for ($i = 1; $i <= $nbrAnswers; $i++) {
284 284
                 if ($debug > 0) {
285
-                    echo str_repeat('&nbsp;', 4) . '$answerType is HOT_SPOT' . "<br />\n";
285
+                    echo str_repeat('&nbsp;', 4).'$answerType is HOT_SPOT'."<br />\n";
286 286
                 }
287 287
 
288 288
                 $reponse[$i] = trim($reponse[$i]);
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
                 $weighting[$i] = ($weighting[$i]); //it can be float
291 291
 
292 292
                 if ($weighting[$i]) {
293
-                    $questionWeighting+=$weighting[$i];
293
+                    $questionWeighting += $weighting[$i];
294 294
                 }
295 295
                 // creates answer
296 296
                 $objAnswer->createAnswer(
@@ -325,14 +325,14 @@  discard block
 block discarded – undo
325 325
             $editQuestion = $questionId;
326 326
             unset($modifyAnswers);
327 327
 
328
-            echo '<script type="text/javascript">window.location.href="' . $hotspot_admin_url . '&message=ItemUpdated"</script>';
328
+            echo '<script type="text/javascript">window.location.href="'.$hotspot_admin_url.'&message=ItemUpdated"</script>';
329 329
         }
330 330
     }
331 331
 }
332 332
 
333 333
 if ($modifyAnswers) {
334 334
     if ($debug > 0) {
335
-        echo str_repeat('&nbsp;', 0) . '$modifyAnswers is set' . "<br />\n";
335
+        echo str_repeat('&nbsp;', 0).'$modifyAnswers is set'."<br />\n";
336 336
     }
337 337
 
338 338
     // construction of the Answer object
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
     Session::write('objAnswer', $objAnswer);
341 341
 
342 342
     if ($debug > 0) {
343
-        echo str_repeat('&nbsp;', 2) . '$answerType is HOT_SPOT' . "<br />\n";
343
+        echo str_repeat('&nbsp;', 2).'$answerType is HOT_SPOT'."<br />\n";
344 344
     }
345 345
 
346 346
     if ($answerType == HOT_SPOT_DELINEATION) {
@@ -521,11 +521,11 @@  discard block
 block discarded – undo
521 521
     }
522 522
 
523 523
     if ($debug > 0) {
524
-        echo str_repeat('&nbsp;', 2) . '$usedInSeveralExercises is untrue' . "<br />\n";
524
+        echo str_repeat('&nbsp;', 2).'$usedInSeveralExercises is untrue'."<br />\n";
525 525
     }
526 526
 
527 527
     if ($debug > 0) {
528
-        echo str_repeat('&nbsp;', 4) . '$answerType is HOT_SPOT' . "<br />\n";
528
+        echo str_repeat('&nbsp;', 4).'$answerType is HOT_SPOT'."<br />\n";
529 529
     }
530 530
 
531 531
     if ($answerType == HOT_SPOT_DELINEATION) {
@@ -565,14 +565,14 @@  discard block
 block discarded – undo
565 565
 
566 566
     Display::tag(
567 567
         'h3',
568
-        get_lang('Question') . ": " . $questionName . Display::return_icon('info3.gif', strip_tags(get_lang('HotspotChoose')))
568
+        get_lang('Question').": ".$questionName.Display::return_icon('info3.gif', strip_tags(get_lang('HotspotChoose')))
569 569
     );
570 570
 
571 571
     if (!empty($msgErr)) {
572 572
         Display::display_normal_message($msgErr); //main API
573 573
     }
574 574
 
575
-    $hotspot_admin_url = api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?' . api_get_cidreq() . '&hotspotadmin=' . $modifyAnswers . '&exerciseId=' . $exerciseId . '&' . api_get_cidreq();
575
+    $hotspot_admin_url = api_get_path(WEB_CODE_PATH).'exercice/admin.php?'.api_get_cidreq().'&hotspotadmin='.$modifyAnswers.'&exerciseId='.$exerciseId.'&'.api_get_cidreq();
576 576
     ?>
577 577
     <form method="post" action="<?php echo $hotspot_admin_url; ?>" class="form-horizontal" id="frm_exercise" name="frm_exercise">
578 578
         <div class="form-group">
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
                                 <th><?php echo get_lang('Comment'); ?></th>
612 612
                                 <?php
613 613
                                 if ($answerType == HOT_SPOT_DELINEATION) {
614
-                                    echo '<th >' . get_lang('Scenario') . '</th>';
614
+                                    echo '<th >'.get_lang('Scenario').'</th>';
615 615
                                 }
616 616
                                 ?>
617 617
                                 <?php
@@ -643,36 +643,36 @@  discard block
 block discarded – undo
643 643
                                         $isSelected = true;
644 644
                                         $selected = 'selected="selected"';
645 645
                                     }
646
-                                    $option_lp.='<option value="' . $id . '" ' . $selected . '>' . $details['lp_name'] . '</option>';
646
+                                    $option_lp .= '<option value="'.$id.'" '.$selected.'>'.$details['lp_name'].'</option>';
647 647
                                 }
648 648
 
649 649
                                 if ($isSelected) {
650
-                                    $option_lp = '<option value="0">' . get_lang('SelectTargetLP') . '</option>' . $option_lp;
650
+                                    $option_lp = '<option value="0">'.get_lang('SelectTargetLP').'</option>'.$option_lp;
651 651
                                 } else {
652
-                                    $option_lp = '<option value="0" selected="selected" >' . get_lang('SelectTargetLP') . '</option>' . $option_lp;
652
+                                    $option_lp = '<option value="0" selected="selected" >'.get_lang('SelectTargetLP').'</option>'.$option_lp;
653 653
                                 }
654 654
 
655 655
                                 // Feedback SELECT
656 656
                                 $question_list = $objExercise->selectQuestionList();
657 657
                                 $option_feed = '';
658
-                                $option_feed.='<option value="0">' . get_lang('SelectTargetQuestion') . '</option>';
658
+                                $option_feed .= '<option value="0">'.get_lang('SelectTargetQuestion').'</option>';
659 659
 
660 660
                                 foreach ($question_list as $key => $questionid) {
661 661
                                     $selected = '';
662 662
                                     $question = Question::read($questionid);
663
-                                    $val = 'Q' . $key . ' :' . substrwords($question->selectTitle(), ICON_SIZE_SMALL);
663
+                                    $val = 'Q'.$key.' :'.substrwords($question->selectTitle(), ICON_SIZE_SMALL);
664 664
 
665 665
                                     if (isset($select_question[$i]) && $questionid == $select_question[$i]) {
666 666
                                         $selected = 'selected="selected"';
667 667
                                     }
668 668
 
669
-                                    $option_feed.='<option value="' . $questionid . '" ' . $selected . ' >' . $val . '</option>';
669
+                                    $option_feed .= '<option value="'.$questionid.'" '.$selected.' >'.$val.'</option>';
670 670
                                 }
671 671
 
672 672
                                 if (isset($select_question[$i]) && $select_question[$i] == -1) {
673
-                                    $option_feed .= '<option value="-1" selected="selected" >' . get_lang('ExitTest') . '</option>';
673
+                                    $option_feed .= '<option value="-1" selected="selected" >'.get_lang('ExitTest').'</option>';
674 674
                                 } else {
675
-                                    $option_feed .= '<option value="-1">' . get_lang('ExitTest') . '</option>';
675
+                                    $option_feed .= '<option value="-1">'.get_lang('ExitTest').'</option>';
676 676
                                 }
677 677
 
678 678
                                 //-------- IF it is a delineation
@@ -688,9 +688,9 @@  discard block
 block discarded – undo
688 688
                                             $selected2 = 'selected="selected"';
689 689
                                         if ($k == $threadhold3[$i])
690 690
                                             $selected3 = 'selected="selected"';
691
-                                        $option1.='<option ' . $selected1 . ' >' . $k . ' % </option>';
692
-                                        $option2.='<option ' . $selected2 . ' >' . $k . ' % </option>';
693
-                                        $option3.='<option ' . $selected3 . '>' . $k . ' %</option>';
691
+                                        $option1 .= '<option '.$selected1.' >'.$k.' % </option>';
692
+                                        $option2 .= '<option '.$selected2.' >'.$k.' % </option>';
693
+                                        $option3 .= '<option '.$selected3.'>'.$k.' %</option>';
694 694
                                     }
695 695
                                     ?>
696 696
                                     <tr>
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
                                                 <div class="checkbox">
735 735
                                                     <p>
736 736
                                                         <label>
737
-                                                            <input type="checkbox" class="checkbox" name="<?php echo 'try[' . $i; ?>]"  <?php if ($try[$i] == 1) echo'checked'; ?> />
737
+                                                            <input type="checkbox" class="checkbox" name="<?php echo 'try['.$i; ?>]"  <?php if ($try[$i] == 1) echo'checked'; ?> />
738 738
                                                             <?php echo get_lang('TryAgain'); ?>
739 739
                                                         </label>
740 740
                                                     </p>
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
                                                             <div class="checkbox">
788 788
                                                                 <p>
789 789
                                                                     <label>
790
-                                                                        <input type="checkbox" class="checkbox" name="<?php echo 'try[' . $i; ?>]" <?php if ($try[$i] == 1) echo'checked'; ?> />
790
+                                                                        <input type="checkbox" class="checkbox" name="<?php echo 'try['.$i; ?>]" <?php if ($try[$i] == 1) echo'checked'; ?> />
791 791
                                                                         <?php echo get_lang('TryAgain'); ?>
792 792
                                                                     </label>
793 793
                                                                 </p>
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
                                                 <div class="checkbox">
853 853
                                                     <p>
854 854
                                                         <label>
855
-                                                            <input type="checkbox" class="checkbox" name="<?php echo 'try[' . $i; ?>]" <?php if (isset($try[$i]) && $try[$i] == 1) echo'checked'; ?> />
855
+                                                            <input type="checkbox" class="checkbox" name="<?php echo 'try['.$i; ?>]" <?php if (isset($try[$i]) && $try[$i] == 1) echo'checked'; ?> />
856 856
                                                             <?php echo get_lang('TryAgain'); ?>
857 857
                                                         </label>
858 858
                                                     </p>
@@ -892,12 +892,12 @@  discard block
 block discarded – undo
892 892
                                         <input class="form-control" type="text" name="reponse[<?php echo $i; ?>]" value="<?php echo Security::remove_XSS($responseValue); ?>" />
893 893
                                     </td>
894 894
                                     <?php
895
-                                    $form = new FormValidator('form_' . $i);
895
+                                    $form = new FormValidator('form_'.$i);
896 896
                                     $config = array(
897 897
                                         'ToolbarSet' => 'TestProposedAnswer',
898 898
                                         'cols-size' => [0, 12, 0]
899 899
                                     );
900
-                                    $form->addHtmlEditor('comment[' . $i . ']', null, false, false, $config);
900
+                                    $form->addHtmlEditor('comment['.$i.']', null, false, false, $config);
901 901
                                     $renderer = $form->defaultRenderer();
902 902
                                     $form_template = '{content}';
903 903
                                     $renderer->setFormTemplate($form_template);
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
                                         {element}';
907 907
                                     $renderer->setElementTemplate($element_template);
908 908
 
909
-                                    $form->setDefaults(array('comment[' . $i . ']' => $commentValue));
909
+                                    $form->setDefaults(array('comment['.$i.']' => $commentValue));
910 910
                                     $return = $form->return_form();
911 911
                                     ?>
912 912
                                     <td colspan="2" align="left" ><?php echo $return; ?></td>
@@ -945,36 +945,36 @@  discard block
 block discarded – undo
945 945
                                 $selected = 'selected="selected"';
946 946
                                 $isSelected = true;
947 947
                             }
948
-                            $option_lp.='<option value="' . $id . '" ' . $selected . '>' . $details['lp_name'] . '</option>';
948
+                            $option_lp .= '<option value="'.$id.'" '.$selected.'>'.$details['lp_name'].'</option>';
949 949
                         }
950 950
 
951 951
                         if ($isSelected) {
952
-                            $option_lp = '<option value="0">' . get_lang('SelectTargetLP') . '</option>' . $option_lp;
952
+                            $option_lp = '<option value="0">'.get_lang('SelectTargetLP').'</option>'.$option_lp;
953 953
                         } else {
954
-                            $option_lp = '<option value="0" selected="selected" >' . get_lang('SelectTargetLP') . '</option>' . $option_lp;
954
+                            $option_lp = '<option value="0" selected="selected" >'.get_lang('SelectTargetLP').'</option>'.$option_lp;
955 955
                         }
956 956
 
957 957
                         // Feedback SELECT
958 958
                         $question_list = $objExercise->selectQuestionList();
959 959
                         $option_feed = '';
960
-                        $option_feed.='<option value="0">' . get_lang('SelectTargetQuestion') . '</option>';
960
+                        $option_feed .= '<option value="0">'.get_lang('SelectTargetQuestion').'</option>';
961 961
                         $details = isset($details) ? $details : null;
962 962
                         $id = isset($id) ? $id : 0;
963 963
                         $selectQuestionNoError = isset($selectQuestionNoError) ? $selectQuestionNoError : null;
964 964
                         foreach ($question_list as $key => $questionid) {
965 965
                             $selected = '';
966 966
                             $question = Question::read($questionid);
967
-                            $val = 'Q' . $key . ' :' . substrwords($question->selectTitle(), ICON_SIZE_SMALL);
967
+                            $val = 'Q'.$key.' :'.substrwords($question->selectTitle(), ICON_SIZE_SMALL);
968 968
                             $select_lp_id[$id] = $details['lp_name'];
969 969
                             if ($questionid == $selectQuestionNoError) {
970 970
                                 $selected = 'selected="selected"';
971 971
                             }
972
-                            $option_feed.='<option value="' . $questionid . '" ' . $selected . ' >' . $val . '</option>';
972
+                            $option_feed .= '<option value="'.$questionid.'" '.$selected.' >'.$val.'</option>';
973 973
                         }
974 974
                         if ($selectQuestionNoError == -1) {
975
-                            $option_feed.='<option value="-1" selected="selected" >' . get_lang('ExitTest') . '</option>';
975
+                            $option_feed .= '<option value="-1" selected="selected" >'.get_lang('ExitTest').'</option>';
976 976
                         } else {
977
-                            $option_feed.='<option value="-1">' . get_lang('ExitTest') . '</option>';
977
+                            $option_feed .= '<option value="-1">'.get_lang('ExitTest').'</option>';
978 978
                         }
979 979
 
980 980
                         if ($answerType == HOT_SPOT_DELINEATION) {
@@ -1065,6 +1065,6 @@  discard block
 block discarded – undo
1065 1065
     </script>
1066 1066
     <?php
1067 1067
     if ($debug > 0) {
1068
-        echo str_repeat('&nbsp;', 0) . '$modifyAnswers was set - end' . "<br />\n";
1068
+        echo str_repeat('&nbsp;', 0).'$modifyAnswers was set - end'."<br />\n";
1069 1069
     }
1070 1070
 }
Please login to merge, or discard this patch.
main/exercice/hotspot_savescore.inc.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,15 +17,15 @@
 block discarded – undo
17 17
 $answerOrderId = count($_SESSION['exerciseResult'][$questionId]['ids'])+1;
18 18
 if ($_GET['answerId'] == "0") // click is NOT on a hotspot
19 19
 {
20
-	$hit = 0;
21
-	$answerId = NULL;
20
+    $hit = 0;
21
+    $answerId = NULL;
22 22
 }
23 23
 else // user clicked ON a hotspot
24 24
 {
25
-	$hit = 1;
26
-	$answerId = api_substr($_GET['answerId'],22,2);
27
-	// Save into session
28
-	$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
25
+    $hit = 1;
26
+    $answerId = api_substr($_GET['answerId'],22,2);
27
+    // Save into session
28
+    $_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
29 29
 }
30 30
 //round-up the coordinates
31 31
 $coords = explode('/',$coordinates);
Please login to merge, or discard this 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
 $objExcercise = $_SESSION['objExercise'];
15 15
 $exerciseId   = $objExcercise->selectId();
16 16
 // Save clicking order
17
-$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['ids'])+1;
17
+$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['ids']) + 1;
18 18
 if ($_GET['answerId'] == "0") // click is NOT on a hotspot
19 19
 {
20 20
 	$hit = 0;
@@ -23,18 +23,18 @@  discard block
 block discarded – undo
23 23
 else // user clicked ON a hotspot
24 24
 {
25 25
 	$hit = 1;
26
-	$answerId = api_substr($_GET['answerId'],22,2);
26
+	$answerId = api_substr($_GET['answerId'], 22, 2);
27 27
 	// Save into session
28 28
 	$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
29 29
 }
30 30
 //round-up the coordinates
31
-$coords = explode('/',$coordinates);
31
+$coords = explode('/', $coordinates);
32 32
 $coordinates = '';
33 33
 foreach ($coords as $coord) {
34
-    list($x,$y) = explode(';',$coord);
34
+    list($x, $y) = explode(';', $coord);
35 35
     $coordinates .= round($x).';'.round($y).'/';
36 36
 }
37
-$coordinates = substr($coordinates,0,-1);
37
+$coordinates = substr($coordinates, 0, -1);
38 38
 
39 39
 $TBL_TRACK_E_HOTSPOT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
40 40
 // Save into db
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     'quiz_id' => $exerciseId,
45 45
     'question_id' => $questionId,
46 46
     'answer_id' =>  $answerId,
47
-    'correct' => $hit ,
47
+    'correct' => $hit,
48 48
     'coordinate' => $coordinates
49 49
 ];
50 50
 // Save insert id into session if users changes answer.
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,12 +15,13 @@
 block discarded – undo
15 15
 $exerciseId   = $objExcercise->selectId();
16 16
 // Save clicking order
17 17
 $answerOrderId = count($_SESSION['exerciseResult'][$questionId]['ids'])+1;
18
-if ($_GET['answerId'] == "0") // click is NOT on a hotspot
18
+if ($_GET['answerId'] == "0") {
19
+    // click is NOT on a hotspot
19 20
 {
20 21
 	$hit = 0;
21
-	$answerId = NULL;
22 22
 }
23
-else // user clicked ON a hotspot
23
+	$answerId = NULL;
24
+} else // user clicked ON a hotspot
24 25
 {
25 26
 	$hit = 1;
26 27
 	$answerId = api_substr($_GET['answerId'],22,2);
Please login to merge, or discard this patch.
main/exercice/answer.class.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         $objExercise->read($exerciseId);
74 74
 
75 75
         if ($objExercise->random_answers == '1') {
76
-            $this->readOrderedBy('rand()', '');// randomize answers
76
+            $this->readOrderedBy('rand()', ''); // randomize answers
77 77
         } else {
78 78
             $this->read(); // natural order
79 79
         }
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
                 ORDER BY position";
115 115
 
116 116
         $result = Database::query($sql);
117
-        $i=1;
117
+        $i = 1;
118 118
 
119 119
         // while a record is found
120 120
         while ($object = Database::fetch_object($result)) {
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             $this->autoId[$i] = $object->id_auto;
131 131
             $i++;
132 132
         }
133
-        $this->nbrAnswers = $i-1;
133
+        $this->nbrAnswers = $i - 1;
134 134
     }
135 135
 
136 136
     /**
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
     {
143 143
         foreach ($this->autoId as $key => $autoId) {
144 144
             if ($autoId == $id) {
145
-                $result =  [
145
+                $result = [
146 146
                     'answer' => $this->answer[$key],
147 147
                     'correct' => $this->correct[$key],
148 148
                     'comment' => $this->comment[$key],
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
         $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
167 167
         $questionId = $this->questionId;
168 168
 
169
-        $sql="SELECT id FROM
169
+        $sql = "SELECT id FROM
170 170
               $TBL_ANSWER
171 171
               WHERE c_id = {$this->course_id} AND question_id ='".$questionId."'";
172 172
 
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
      * @param	string	DESC or ASC
189 189
      * @author 	Frederic Vauthier
190 190
      */
191
-    public function readOrderedBy($field, $order='ASC')
191
+    public function readOrderedBy($field, $order = 'ASC')
192 192
     {
193 193
 		$field = Database::escape_string($field);
194 194
 		if (empty($field)) {
195 195
 			$field = 'position';
196 196
 		}
197 197
 
198
-		if ($order != 'ASC' && $order!='DESC') {
198
+		if ($order != 'ASC' && $order != 'DESC') {
199 199
 			$order = 'ASC';
200 200
 		}
201 201
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
                     c_id = {$this->course_id} AND
231 231
                     question_id='".$questionId."'
232 232
                 ORDER BY $field $order";
233
-		$result=Database::query($sql);
233
+		$result = Database::query($sql);
234 234
 
235 235
 		$i = 1;
236 236
 		// while a record is found
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
             $this->autoId[$i] = $doubt_data->id_auto;
261 261
             $i++;
262 262
 	    }
263
-        $this->nbrAnswers = $i-1;
263
+        $this->nbrAnswers = $i - 1;
264 264
 	}
265 265
 
266 266
 	/**
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
     public function getGradesList()
403 403
      {
404 404
 	 	$list = array();
405
-	 	for ($i = 0; $i<$this->nbrAnswers;$i++){
406
-	 		if(!empty($this->answer[$i])){
405
+	 	for ($i = 0; $i < $this->nbrAnswers; $i++) {
406
+	 		if (!empty($this->answer[$i])) {
407 407
 	 			$list[$i] = $this->weighting[$i];
408 408
 	 		}
409 409
 	 	}
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 	 	$sql = "SELECT type FROM $TBL_QUESTIONS
422 422
 	 	        WHERE c_id = {$this->course_id} AND id = '".$this->questionId."'";
423 423
 	 	$res = Database::query($sql);
424
-	 	if (Database::num_rows($res)<=0){
424
+	 	if (Database::num_rows($res) <= 0) {
425 425
 	 		return null;
426 426
 	 	}
427 427
 	 	$row = Database::fetch_array($res);
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
         $correctList = [];
594 594
         $answerList = [];
595 595
 
596
-		for ($i=1; $i <= $this->new_nbrAnswers; $i++) {
596
+		for ($i = 1; $i <= $this->new_nbrAnswers; $i++) {
597 597
 			$answer = $this->new_answer[$i];
598 598
 			$correct = $this->new_correct[$i];
599 599
 			$comment = $this->new_comment[$i];
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
             $destination_options = Question::readQuestionOption($newQuestionId, $course_info['real_id']);
749 749
             $i = 0;
750 750
             if (!empty($destination_options)) {
751
-                foreach($destination_options as $item) {
751
+                foreach ($destination_options as $item) {
752 752
                     $fixed_list[$new_option_list[$i]] = $item['id'];
753 753
                     $i++;
754 754
                 }
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 			// inserts new answers into data base
761 761
 			$c_id = $course_info['real_id'];
762 762
 
763
-			for ($i=1;$i <= $this->nbrAnswers;$i++) {
763
+			for ($i = 1; $i <= $this->nbrAnswers; $i++) {
764 764
                 if ($this->course['id'] != $course_info['id']) {
765 765
                     $this->answer[$i] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
766 766
                         $this->answer[$i],
Please login to merge, or discard this patch.
Indentation   +301 added lines, -301 removed lines patch added patch discarded remove patch
@@ -157,12 +157,12 @@  discard block
 block discarded – undo
157 157
         return [];
158 158
     }
159 159
 
160
-     /**
161
-     * returns all answer ids from this question Id
162
-     *
163
-     * @author Yoselyn Castillo
164
-     * @return array - $id (answer ids)
165
-     */
160
+        /**
161
+         * returns all answer ids from this question Id
162
+         *
163
+         * @author Yoselyn Castillo
164
+         * @return array - $id (answer ids)
165
+         */
166 166
     public function selectAnswerId()
167 167
     {
168 168
         $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         }
183 183
 
184 184
         return $id;
185
-	}
185
+    }
186 186
 
187 187
     /**
188 188
      * Reads answer information from the data base ordered by parameter
@@ -193,23 +193,23 @@  discard block
 block discarded – undo
193 193
      */
194 194
     public function readOrderedBy($field, $order='ASC')
195 195
     {
196
-		$field = Database::escape_string($field);
197
-		if (empty($field)) {
198
-			$field = 'position';
199
-		}
196
+        $field = Database::escape_string($field);
197
+        if (empty($field)) {
198
+            $field = 'position';
199
+        }
200 200
 
201
-		if ($order != 'ASC' && $order!='DESC') {
202
-			$order = 'ASC';
203
-		}
201
+        if ($order != 'ASC' && $order!='DESC') {
202
+            $order = 'ASC';
203
+        }
204 204
 
205
-		$TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
206
-		$TBL_QUIZ = Database::get_course_table(TABLE_QUIZ_QUESTION);
207
-		$questionId = intval($this->questionId);
205
+        $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
206
+        $TBL_QUIZ = Database::get_course_table(TABLE_QUIZ_QUESTION);
207
+        $questionId = intval($this->questionId);
208 208
 
209
-		$sql = "SELECT type FROM $TBL_QUIZ
209
+        $sql = "SELECT type FROM $TBL_QUIZ
210 210
 		        WHERE c_id = {$this->course_id} AND id = $questionId";
211
-		$result_question = Database::query($sql);
212
-		$questionType = Database::fetch_array($result_question);
211
+        $result_question = Database::query($sql);
212
+        $questionType = Database::fetch_array($result_question);
213 213
 
214 214
         if ($questionType['type'] == DRAGGABLE) {
215 215
             // Random is done by submit.js.tpl
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
             return true;
219 219
         }
220 220
 
221
-		$sql = "SELECT
221
+        $sql = "SELECT
222 222
 		            answer,
223 223
 		            correct,
224 224
 		            comment,
@@ -234,16 +234,16 @@  discard block
 block discarded – undo
234 234
                     c_id = {$this->course_id} AND
235 235
                     question_id='".$questionId."'
236 236
                 ORDER BY $field $order";
237
-		$result=Database::query($sql);
238
-
239
-		$i = 1;
240
-		// while a record is found
241
-		$doubt_data = null;
242
-		while ($object = Database::fetch_object($result)) {
243
-		    if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && $object->position == 666) {
244
-		        $doubt_data = $object;
237
+        $result=Database::query($sql);
238
+
239
+        $i = 1;
240
+        // while a record is found
241
+        $doubt_data = null;
242
+        while ($object = Database::fetch_object($result)) {
243
+            if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && $object->position == 666) {
244
+                $doubt_data = $object;
245 245
                 continue;
246
-		    }
246
+            }
247 247
             $this->answer[$i] = $object->answer;
248 248
             $this->correct[$i] = $object->correct;
249 249
             $this->comment[$i] = $object->comment;
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
             $this->autoId[$i] = $object->id_auto;
256 256
             $this->iid[$i] = $object->iid;
257 257
             $i++;
258
-		}
258
+        }
259 259
 
260
-		if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && !empty($doubt_data)) {
260
+        if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && !empty($doubt_data)) {
261 261
             $this->answer[$i] = $doubt_data->answer;
262 262
             $this->correct[$i] = $doubt_data->correct;
263 263
             $this->comment[$i] = $doubt_data->comment;
@@ -269,88 +269,88 @@  discard block
 block discarded – undo
269 269
             $this->autoId[$i] = $doubt_data->id_auto;
270 270
             $this->iid[$i] = $doubt_data->iid;
271 271
             $i++;
272
-	    }
272
+        }
273 273
         $this->nbrAnswers = $i-1;
274
-	}
275
-
276
-	/**
277
-	 * returns the autoincrement id identificator
278
-	 *
279
-	 * @author Juan Carlos Ra�a
280
-	 * @return integer - answer num
281
-	 */
274
+    }
275
+
276
+    /**
277
+     * returns the autoincrement id identificator
278
+     *
279
+     * @author Juan Carlos Ra�a
280
+     * @return integer - answer num
281
+     */
282 282
     public function selectAutoId($id)
283 283
     {
284
-		return isset($this->autoId[$id]) ? $this->autoId[$id] : 0;
285
-	}
286
-
287
-	/**
288
-	 * returns the number of answers in this question
289
-	 *
290
-	 * @author Olivier Brouckaert
291
-	 * @return integer - number of answers
292
-	 */
293
-	public function selectNbrAnswers()
284
+        return isset($this->autoId[$id]) ? $this->autoId[$id] : 0;
285
+    }
286
+
287
+    /**
288
+     * returns the number of answers in this question
289
+     *
290
+     * @author Olivier Brouckaert
291
+     * @return integer - number of answers
292
+     */
293
+    public function selectNbrAnswers()
294 294
     {
295
-		return $this->nbrAnswers;
296
-	}
297
-
298
-	/**
299
-	 * returns the question ID which the answers belong to
300
-	 *
301
-	 * @author Olivier Brouckaert
302
-	 * @return integer - the question ID
303
-	 */
304
-	public function selectQuestionId()
295
+        return $this->nbrAnswers;
296
+    }
297
+
298
+    /**
299
+     * returns the question ID which the answers belong to
300
+     *
301
+     * @author Olivier Brouckaert
302
+     * @return integer - the question ID
303
+     */
304
+    public function selectQuestionId()
305 305
     {
306
-		return $this->questionId;
307
-	}
308
-
309
-	/**
310
-	 * returns the question ID of the destination question
311
-	 *
312
-	 * @author Julio Montoya
313
-	 * @param integer $id
314
-	 * @return integer - the question ID
315
-	 */
316
-	public function selectDestination($id)
306
+        return $this->questionId;
307
+    }
308
+
309
+    /**
310
+     * returns the question ID of the destination question
311
+     *
312
+     * @author Julio Montoya
313
+     * @param integer $id
314
+     * @return integer - the question ID
315
+     */
316
+    public function selectDestination($id)
317 317
     {
318
-		return isset($this->destination[$id]) ? $this->destination[$id] : null;
319
-	}
318
+        return isset($this->destination[$id]) ? $this->destination[$id] : null;
319
+    }
320 320
 
321 321
     /**
322
-	 * returns the answer title
323
-	 *
324
-	 * @author Olivier Brouckaert
325
-	 * @param - integer $id - answer ID
326
-	 * @return string - answer title
327
-	 */
328
-	public function selectAnswer($id)
329
-	{
330
-		return isset($this->answer[$id]) ? $this->answer[$id] : null;
331
-	}
332
-
333
-	/**
334
-	 * return array answer by id else return a bool
335
-	 * @param integer $auto_id
336
-	 */
337
-	public function selectAnswerByAutoId($auto_id)
338
-	{
339
-		$TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
340
-
341
-		$auto_id = intval($auto_id);
342
-		$sql = "SELECT id, answer, id_auto FROM $TBL_ANSWER
322
+     * returns the answer title
323
+     *
324
+     * @author Olivier Brouckaert
325
+     * @param - integer $id - answer ID
326
+     * @return string - answer title
327
+     */
328
+    public function selectAnswer($id)
329
+    {
330
+        return isset($this->answer[$id]) ? $this->answer[$id] : null;
331
+    }
332
+
333
+    /**
334
+     * return array answer by id else return a bool
335
+     * @param integer $auto_id
336
+     */
337
+    public function selectAnswerByAutoId($auto_id)
338
+    {
339
+        $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
340
+
341
+        $auto_id = intval($auto_id);
342
+        $sql = "SELECT id, answer, id_auto FROM $TBL_ANSWER
343 343
 				WHERE c_id = {$this->course_id} AND id_auto='$auto_id'";
344
-		$rs = Database::query($sql);
344
+        $rs = Database::query($sql);
345 345
 
346
-		if (Database::num_rows($rs) > 0) {
347
-			$row = Database::fetch_array($rs, 'ASSOC');
346
+        if (Database::num_rows($rs) > 0) {
347
+            $row = Database::fetch_array($rs, 'ASSOC');
348 348
 
349
-			return $row;
350
-		}
349
+            return $row;
350
+        }
351 351
 
352
-		return false;
353
-	}
352
+        return false;
353
+    }
354 354
 
355 355
     /**
356 356
      * returns the answer title from an answer's position
@@ -359,18 +359,18 @@  discard block
 block discarded – undo
359 359
      * @param - integer $id - answer ID
360 360
      * @return bool - answer title
361 361
      */
362
-	public function selectAnswerIdByPosition($pos)
363
-	{
364
-		foreach ($this->position as $k => $v) {
365
-			if ($v != $pos) {
366
-				continue;
367
-			}
362
+    public function selectAnswerIdByPosition($pos)
363
+    {
364
+        foreach ($this->position as $k => $v) {
365
+            if ($v != $pos) {
366
+                continue;
367
+            }
368 368
 
369
-			return $k;
370
-		}
369
+            return $k;
370
+        }
371 371
 
372
-		return false;
373
-	}
372
+        return false;
373
+    }
374 374
 
375 375
     /**
376 376
      * Returns a list of answers
@@ -379,18 +379,18 @@  discard block
 block discarded – undo
379 379
      * of (id, answer, comment, grade) and grade=weighting
380 380
      */
381 381
     public function getAnswersList($decode = false)
382
-     {
383
-	 	$list = array();
384
-         for ($i = 1; $i <= $this->nbrAnswers; $i++) {
385
-             if (!empty($this->answer[$i])) {
386
-
387
-	 			//Avoid problems when parsing elements with accents
388
-	 			if ($decode) {
389
-	        		$this->answer[$i] 	= api_html_entity_decode($this->answer[$i], ENT_QUOTES, api_get_system_encoding());
390
-	        		$this->comment[$i]	= api_html_entity_decode($this->comment[$i], ENT_QUOTES, api_get_system_encoding());
391
-	 			}
392
-
393
-	 			$list[] = array(
382
+        {
383
+            $list = array();
384
+            for ($i = 1; $i <= $this->nbrAnswers; $i++) {
385
+                if (!empty($this->answer[$i])) {
386
+
387
+                    //Avoid problems when parsing elements with accents
388
+                    if ($decode) {
389
+                    $this->answer[$i] 	= api_html_entity_decode($this->answer[$i], ENT_QUOTES, api_get_system_encoding());
390
+                    $this->comment[$i]	= api_html_entity_decode($this->comment[$i], ENT_QUOTES, api_get_system_encoding());
391
+                    }
392
+
393
+                    $list[] = array(
394 394
                     'id' => $i,
395 395
                     'answer' => $this->answer[$i],
396 396
                     'comment' => $this->comment[$i],
@@ -399,137 +399,137 @@  discard block
 block discarded – undo
399 399
                     'hotspot_type' => $this->hotspot_type[$i],
400 400
                     'correct' => $this->correct[$i],
401 401
                     'destination' => $this->destination[$i]
402
-				);
402
+                );
403
+            }
403 404
             }
404
-	 	}
405 405
 
406
-	 	return $list;
407
-	 }
406
+            return $list;
407
+        }
408 408
 
409
-	/**
410
-	 * Returns a list of grades
411
-	 * @author Yannick Warnier <[email protected]>
412
-	 * @return array	List of grades where grade=weighting (?)
413
-	 */
409
+    /**
410
+     * Returns a list of grades
411
+     * @author Yannick Warnier <[email protected]>
412
+     * @return array	List of grades where grade=weighting (?)
413
+     */
414 414
     public function getGradesList()
415
-     {
416
-	 	$list = array();
417
-	 	for ($i = 0; $i<$this->nbrAnswers;$i++){
418
-	 		if(!empty($this->answer[$i])){
419
-	 			$list[$i] = $this->weighting[$i];
420
-	 		}
421
-	 	}
422
-	 	return $list;
423
-	 }
424
-
425
-	 /**
426
-	  * Returns the question type
427
-	  * @author	Yannick Warnier <[email protected]>
428
-	  * @return	integer	The type of the question this answer is bound to
429
-	  */
415
+        {
416
+            $list = array();
417
+            for ($i = 0; $i<$this->nbrAnswers;$i++){
418
+                if(!empty($this->answer[$i])){
419
+                    $list[$i] = $this->weighting[$i];
420
+                }
421
+            }
422
+            return $list;
423
+        }
424
+
425
+        /**
426
+         * Returns the question type
427
+         * @author	Yannick Warnier <[email protected]>
428
+         * @return	integer	The type of the question this answer is bound to
429
+         */
430 430
     public function getQuestionType()
431
-     {
432
-	 	$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
433
-	 	$sql = "SELECT type FROM $TBL_QUESTIONS
431
+        {
432
+            $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
433
+            $sql = "SELECT type FROM $TBL_QUESTIONS
434 434
 	 	        WHERE c_id = {$this->course_id} AND id = '".$this->questionId."'";
435
-	 	$res = Database::query($sql);
436
-	 	if (Database::num_rows($res)<=0){
437
-	 		return null;
438
-	 	}
439
-	 	$row = Database::fetch_array($res);
440
-
441
-	 	return $row['type'];
442
-	 }
443
-
444
-
445
-	/**
446
-	 * tells if answer is correct or not
447
-	 *
448
-	 * @author Olivier Brouckaert
449
-	 * @param - integer $id - answer ID
450
-	 * @return integer - 0 if bad answer, not 0 if good answer
451
-	 */
435
+            $res = Database::query($sql);
436
+            if (Database::num_rows($res)<=0){
437
+                return null;
438
+            }
439
+            $row = Database::fetch_array($res);
440
+
441
+            return $row['type'];
442
+        }
443
+
444
+
445
+    /**
446
+     * tells if answer is correct or not
447
+     *
448
+     * @author Olivier Brouckaert
449
+     * @param - integer $id - answer ID
450
+     * @return integer - 0 if bad answer, not 0 if good answer
451
+     */
452 452
     public function isCorrect($id)
453
-	{
454
-		return isset($this->correct[$id]) ? $this->correct[$id] : null;
455
-	}
456
-
457
-	/**
458
-	 * returns answer comment
459
-	 *
460
-	 * @author Olivier Brouckaert
461
-	 * @param - integer $id - answer ID
462
-	 * @return string - answer comment
463
-	 */
453
+    {
454
+        return isset($this->correct[$id]) ? $this->correct[$id] : null;
455
+    }
456
+
457
+    /**
458
+     * returns answer comment
459
+     *
460
+     * @author Olivier Brouckaert
461
+     * @param - integer $id - answer ID
462
+     * @return string - answer comment
463
+     */
464 464
     public function selectComment($id)
465
-	{
465
+    {
466 466
         return isset($this->comment[$id]) ? $this->comment[$id] : null;
467
-	}
468
-
469
-	/**
470
-	 * returns answer weighting
471
-	 *
472
-	 * @author Olivier Brouckaert
473
-	 * @param - integer $id - answer ID
474
-	 * @param integer $id
475
-	 * @return integer - answer weighting
476
-	 */
467
+    }
468
+
469
+    /**
470
+     * returns answer weighting
471
+     *
472
+     * @author Olivier Brouckaert
473
+     * @param - integer $id - answer ID
474
+     * @param integer $id
475
+     * @return integer - answer weighting
476
+     */
477 477
     public function selectWeighting($id)
478
-	{
479
-		return isset($this->weighting[$id]) ? $this->weighting[$id] : null;
480
-	}
481
-
482
-	/**
483
-	 * returns answer position
484
-	 *
485
-	 * @author Olivier Brouckaert
486
-	 * @param - integer $id - answer ID
487
-	 * @return integer - answer position
488
-	 */
489
-	function selectPosition($id)
490
-	{
491
-		return isset($this->position[$id]) ? $this->position[$id] : null;
492
-	}
493
-
494
-	/**
495
-	 * returns answer hotspot coordinates
496
-	 *
497
-	 * @author	Olivier Brouckaert
498
-	 * @param	integer	Answer ID
499
-	 * @param integer $id
500
-	 * @return	integer	Answer position
501
-	 */
478
+    {
479
+        return isset($this->weighting[$id]) ? $this->weighting[$id] : null;
480
+    }
481
+
482
+    /**
483
+     * returns answer position
484
+     *
485
+     * @author Olivier Brouckaert
486
+     * @param - integer $id - answer ID
487
+     * @return integer - answer position
488
+     */
489
+    function selectPosition($id)
490
+    {
491
+        return isset($this->position[$id]) ? $this->position[$id] : null;
492
+    }
493
+
494
+    /**
495
+     * returns answer hotspot coordinates
496
+     *
497
+     * @author	Olivier Brouckaert
498
+     * @param	integer	Answer ID
499
+     * @param integer $id
500
+     * @return	integer	Answer position
501
+     */
502 502
     public function selectHotspotCoordinates($id)
503
-	{
504
-		return isset($this->hotspot_coordinates[$id]) ? $this->hotspot_coordinates[$id] : null;
505
-	}
506
-
507
-	/**
508
-	 * returns answer hotspot type
509
-	 *
510
-	 * @author	Toon Keppens
511
-	 * @param	integer		Answer ID
512
-	 * @param integer $id
513
-	 * @return	integer		Answer position
514
-	 */
503
+    {
504
+        return isset($this->hotspot_coordinates[$id]) ? $this->hotspot_coordinates[$id] : null;
505
+    }
506
+
507
+    /**
508
+     * returns answer hotspot type
509
+     *
510
+     * @author	Toon Keppens
511
+     * @param	integer		Answer ID
512
+     * @param integer $id
513
+     * @return	integer		Answer position
514
+     */
515 515
     public function selectHotspotType($id)
516
-	{
517
-		return isset($this->hotspot_type[$id]) ? $this->hotspot_type[$id] : null;
518
-	}
519
-
520
-	/**
521
-	 * Creates a new answer
522
-	 *
523
-	 * @author Olivier Brouckaert
524
-	 * @param string 	$answer answer title
525
-	 * @param integer 	$correct 0 if bad answer, not 0 if good answer
526
-	 * @param string 	$comment answer comment
527
-	 * @param integer 	$weighting answer weighting
528
-	 * @param integer 	$position answer position
529
-	 * @param array    $new_hotspot_coordinates Coordinates for hotspot exercises (optional)
530
-	 * @param integer	$new_hotspot_type Type for hotspot exercises (optional)
516
+    {
517
+        return isset($this->hotspot_type[$id]) ? $this->hotspot_type[$id] : null;
518
+    }
519
+
520
+    /**
521
+     * Creates a new answer
522
+     *
523
+     * @author Olivier Brouckaert
524
+     * @param string 	$answer answer title
525
+     * @param integer 	$correct 0 if bad answer, not 0 if good answer
526
+     * @param string 	$comment answer comment
527
+     * @param integer 	$weighting answer weighting
528
+     * @param integer 	$position answer position
529
+     * @param array    $new_hotspot_coordinates Coordinates for hotspot exercises (optional)
530
+     * @param integer	$new_hotspot_type Type for hotspot exercises (optional)
531 531
      * @param string   $destination
532
-	 */
532
+     */
533 533
     public function createAnswer(
534 534
         $answer,
535 535
         $correct,
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
         $new_hotspot_type = null,
541 541
         $destination = ''
542 542
     ) {
543
-		$this->new_nbrAnswers++;
543
+        $this->new_nbrAnswers++;
544 544
         $id = $this->new_nbrAnswers;
545 545
         $this->new_answer[$id] = $answer;
546 546
         $this->new_correct[$id] = $correct;
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
         $this->new_hotspot_coordinates[$id] = $new_hotspot_coordinates;
551 551
         $this->new_hotspot_type[$id] = $new_hotspot_type;
552 552
         $this->new_destination[$id] = $destination;
553
-	}
553
+    }
554 554
 
555 555
     /**
556 556
      * Updates an answer
@@ -591,31 +591,31 @@  discard block
 block discarded – undo
591 591
         ];
592 592
 
593 593
         Database::update($answerTable, $params, ['iid = ?' => intval($iid)]);
594
-	}
594
+    }
595 595
 
596
-	/**
597
-	 * Records answers into the data base
598
-	 *
599
-	 * @author Olivier Brouckaert
600
-	 */
596
+    /**
597
+     * Records answers into the data base
598
+     *
599
+     * @author Olivier Brouckaert
600
+     */
601 601
     public function save()
602 602
     {
603
-		$answerTable = Database::get_course_table(TABLE_QUIZ_ANSWER);
604
-		$questionId = intval($this->questionId);
603
+        $answerTable = Database::get_course_table(TABLE_QUIZ_ANSWER);
604
+        $questionId = intval($this->questionId);
605 605
 
606
-		$c_id = $this->course['real_id'];
606
+        $c_id = $this->course['real_id'];
607 607
         $correctList = [];
608 608
         $answerList = [];
609 609
 
610
-		for ($i=1; $i <= $this->new_nbrAnswers; $i++) {
611
-			$answer = $this->new_answer[$i];
612
-			$correct = $this->new_correct[$i];
613
-			$comment = $this->new_comment[$i];
614
-			$weighting = $this->new_weighting[$i];
615
-			$position = $this->new_position[$i];
616
-			$hotspot_coordinates = $this->new_hotspot_coordinates[$i];
617
-			$hotspot_type = $this->new_hotspot_type[$i];
618
-			$destination = $this->new_destination[$i];
610
+        for ($i=1; $i <= $this->new_nbrAnswers; $i++) {
611
+            $answer = $this->new_answer[$i];
612
+            $correct = $this->new_correct[$i];
613
+            $comment = $this->new_comment[$i];
614
+            $weighting = $this->new_weighting[$i];
615
+            $position = $this->new_position[$i];
616
+            $hotspot_coordinates = $this->new_hotspot_coordinates[$i];
617
+            $hotspot_type = $this->new_hotspot_type[$i];
618
+            $destination = $this->new_destination[$i];
619 619
             $autoId = $this->selectAutoId($i);
620 620
             $iid = isset($this->iid[$i]) ? $this->iid[$i] : 0;
621 621
 
@@ -714,37 +714,37 @@  discard block
 block discarded – undo
714 714
             }
715 715
         }
716 716
 
717
-		// moves $new_* arrays
718
-		$this->answer = $this->new_answer;
719
-		$this->correct = $this->new_correct;
720
-		$this->comment = $this->new_comment;
721
-		$this->weighting = $this->new_weighting;
722
-		$this->position = $this->new_position;
723
-		$this->hotspot_coordinates = $this->new_hotspot_coordinates;
724
-		$this->hotspot_type = $this->new_hotspot_type;
725
-
726
-		$this->nbrAnswers = $this->new_nbrAnswers;
727
-		$this->destination = $this->new_destination;
728
-		// clears $new_* arrays
729
-
730
-		$this->cancel();
731
-	}
732
-
733
-	/**
734
-	 * Duplicates answers by copying them into another question
735
-	 *
736
-	 * @author Olivier Brouckaert
737
-	 * @param  int question id
717
+        // moves $new_* arrays
718
+        $this->answer = $this->new_answer;
719
+        $this->correct = $this->new_correct;
720
+        $this->comment = $this->new_comment;
721
+        $this->weighting = $this->new_weighting;
722
+        $this->position = $this->new_position;
723
+        $this->hotspot_coordinates = $this->new_hotspot_coordinates;
724
+        $this->hotspot_type = $this->new_hotspot_type;
725
+
726
+        $this->nbrAnswers = $this->new_nbrAnswers;
727
+        $this->destination = $this->new_destination;
728
+        // clears $new_* arrays
729
+
730
+        $this->cancel();
731
+    }
732
+
733
+    /**
734
+     * Duplicates answers by copying them into another question
735
+     *
736
+     * @author Olivier Brouckaert
737
+     * @param  int question id
738 738
      * @param  array destination course info (result of the function api_get_course_info() )
739 739
      * @param string $newQuestionId
740
-	 */
740
+     */
741 741
     public function duplicate($newQuestionId, $course_info = null)
742 742
     {
743 743
         if (empty($course_info)) {
744 744
             $course_info = $this->course;
745 745
         }
746 746
 
747
-		$TBL_REPONSES = Database :: get_course_table(TABLE_QUIZ_ANSWER);
747
+        $TBL_REPONSES = Database :: get_course_table(TABLE_QUIZ_ANSWER);
748 748
         $fixed_list = array();
749 749
 
750 750
         if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE ||
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
 
759 759
             if (!empty($origin_options)) {
760 760
                 foreach ($origin_options as $item) {
761
-            	   $new_option_list[] = $item['id'];
761
+                    $new_option_list[] = $item['id'];
762 762
                 }
763 763
             }
764 764
 
@@ -772,12 +772,12 @@  discard block
 block discarded – undo
772 772
             }
773 773
         }
774 774
 
775
-		// if at least one answer
776
-		if ($this->nbrAnswers) {
777
-			// inserts new answers into data base
778
-			$c_id = $course_info['real_id'];
775
+        // if at least one answer
776
+        if ($this->nbrAnswers) {
777
+            // inserts new answers into data base
778
+            $c_id = $course_info['real_id'];
779 779
 
780
-			for ($i=1;$i <= $this->nbrAnswers;$i++) {
780
+            for ($i=1;$i <= $this->nbrAnswers;$i++) {
781 781
                 if ($this->course['id'] != $course_info['id']) {
782 782
                     $this->answer[$i] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
783 783
                         $this->answer[$i],
@@ -791,8 +791,8 @@  discard block
 block discarded – undo
791 791
                     );
792 792
                 }
793 793
 
794
-				$answer = $this->answer[$i];
795
-				$correct = $this->correct[$i];
794
+                $answer = $this->answer[$i];
795
+                $correct = $this->correct[$i];
796 796
 
797 797
                 if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE ||
798 798
                     self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE
@@ -800,12 +800,12 @@  discard block
 block discarded – undo
800 800
                     $correct = $fixed_list[intval($correct)];
801 801
                 }
802 802
 
803
-				$comment = $this->comment[$i];
804
-				$weighting = $this->weighting[$i];
805
-				$position = $this->position[$i];
806
-				$hotspot_coordinates = $this->hotspot_coordinates[$i];
807
-				$hotspot_type = $this->hotspot_type[$i];
808
-				$destination = $this->destination[$i];
803
+                $comment = $this->comment[$i];
804
+                $weighting = $this->weighting[$i];
805
+                $position = $this->position[$i];
806
+                $hotspot_coordinates = $this->hotspot_coordinates[$i];
807
+                $hotspot_type = $this->hotspot_type[$i];
808
+                $destination = $this->destination[$i];
809 809
 
810 810
                 $params = [
811 811
                     'c_id' => $c_id,
@@ -825,9 +825,9 @@  discard block
 block discarded – undo
825 825
                     $sql = "UPDATE $TBL_REPONSES SET id = iid, id_auto = iid WHERE iid = $id";
826 826
                     Database::query($sql);
827 827
                 }
828
-			}
828
+            }
829 829
         }
830
-	}
830
+    }
831 831
 
832 832
     /**
833 833
      * Get the necessary JavaScript for some answers
Please login to merge, or discard this patch.
main/exercice/exercise_history.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -11,40 +11,40 @@  discard block
 block discarded – undo
11 11
  * Code
12 12
  */
13 13
 require_once '../inc/global.inc.php';
14
-$this_section=SECTION_COURSES;
14
+$this_section = SECTION_COURSES;
15 15
 api_protect_course_script(true);
16 16
 
17
-$show=(isset($_GET['show']) && $_GET['show'] == 'result')?'result':'test'; // moved down to fix bug: http://www.dokeos.com/forum/viewtopic.php?p=18609#18609
17
+$show = (isset($_GET['show']) && $_GET['show'] == 'result') ? 'result' : 'test'; // moved down to fix bug: http://www.dokeos.com/forum/viewtopic.php?p=18609#18609
18 18
 
19 19
 /* 	Constants and variables */
20
-$is_allowedToEdit = api_is_allowed_to_edit(null,true);
20
+$is_allowedToEdit = api_is_allowed_to_edit(null, true);
21 21
 $is_tutor = api_is_allowed_to_edit(true);
22 22
 
23
-if (!$is_allowedToEdit){
23
+if (!$is_allowedToEdit) {
24 24
     header('Location: /main/exercice/exercise.php?cidReq='.Security::remove_XSS($_GET['cidReq']));
25 25
     exit;
26 26
 }
27 27
 
28
-$interbreadcrumb[]= array ('url' => 'exercise_report.php?'.api_get_cidreq(),'name' => get_lang('Exercises'));
29
-$interbreadcrumb[]= array ('url' => 'exercise_report.php?filter=2&'.api_get_cidreq(),'name' => get_lang('StudentScore'));
30
-$interbreadcrumb[]= array ('url' => 'exercise_history.php?exe_id='.intval($_GET['exe_id']).'&'.api_get_cidreq(), 'name' => get_lang('Details'));
28
+$interbreadcrumb[] = array('url' => 'exercise_report.php?'.api_get_cidreq(), 'name' => get_lang('Exercises'));
29
+$interbreadcrumb[] = array('url' => 'exercise_report.php?filter=2&'.api_get_cidreq(), 'name' => get_lang('StudentScore'));
30
+$interbreadcrumb[] = array('url' => 'exercise_history.php?exe_id='.intval($_GET['exe_id']).'&'.api_get_cidreq(), 'name' => get_lang('Details'));
31 31
 
32 32
 $TBL_USER          	    = Database::get_main_table(TABLE_MAIN_USER);
33
-$TBL_EXERCISES			= Database::get_course_table(TABLE_QUIZ_TEST);
33
+$TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
34 34
 $TBL_EXERCISES_QUESTION	= Database::get_course_table(TABLE_QUIZ_QUESTION);
35
-$TBL_TRACK_ATTEMPT_RECORDING= Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
36
-Display::display_header($nameTools,get_lang('Exercise'));
35
+$TBL_TRACK_ATTEMPT_RECORDING = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
36
+Display::display_header($nameTools, get_lang('Exercise'));
37 37
 
38 38
 if (isset($_GET['message'])) {
39 39
     if (in_array($_GET['message'], array('ExerciseEdited'))) {
40
-        $my_message_history=Security::remove_XSS($_GET['message']);
40
+        $my_message_history = Security::remove_XSS($_GET['message']);
41 41
         Display::display_confirmation_message(get_lang($my_message_history));
42 42
     }
43 43
 }
44 44
 
45 45
 echo '<div class="actions">';
46
-echo '<a href="exercise_report.php?' . api_get_cidreq() . '&filter=2">' .
47
-    Display :: return_icon('back.png', get_lang('BackToResultList'),'',ICON_SIZE_MEDIUM).'</a>';
46
+echo '<a href="exercise_report.php?'.api_get_cidreq().'&filter=2">'.
47
+    Display :: return_icon('back.png', get_lang('BackToResultList'), '', ICON_SIZE_MEDIUM).'</a>';
48 48
 echo '</div>';
49 49
 
50 50
 ?>
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 <?php
61 61
 
62 62
 $sql = "SELECT *, quiz_question.question, firstname, lastname FROM $TBL_TRACK_ATTEMPT_RECORDING t, $TBL_USER,$TBL_EXERCISES_QUESTION quiz_question
63
-      WHERE quiz_question.id = question_id AND user_id = author AND exe_id = '".(int)$_GET['exe_id']."' ORDER BY position";
63
+      WHERE quiz_question.id = question_id AND user_id = author AND exe_id = '".(int) $_GET['exe_id']."' ORDER BY position";
64 64
 $query = Database::query($sql);
65
-while($row = Database::fetch_array($query)){
65
+while ($row = Database::fetch_array($query)) {
66 66
     echo '<tr';
67
-    if ($i%2==0) {
67
+    if ($i % 2 == 0) {
68 68
         echo 'class="row_odd"';
69 69
     } else {
70 70
         echo 'class="row_even"';
Please login to merge, or discard this patch.
main/exercice/fill_blanks.class.php 2 patches
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
             ['id' => 'answer', 'onkeyup' => "javascript: updateBlanks(this);"],
261 261
             array('ToolbarSet' => 'TestQuestionDescription')
262 262
         );
263
-        $form->addRule('answer',get_lang('GiveText'),'required');
263
+        $form->addRule('answer', get_lang('GiveText'), 'required');
264 264
 
265 265
         //added multiple answers
266
-        $form->addElement('checkbox','multiple_answer','', get_lang('FillInBlankSwitchable'));
266
+        $form->addElement('checkbox', 'multiple_answer', '', get_lang('FillInBlankSwitchable'));
267 267
         $form->addElement(
268 268
             'select',
269 269
             'select_separator',
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
             null,
277 277
             '<input type="button" onclick="updateBlanks()" value="'.get_lang('RefreshBlanks').'" class="btn btn-default" />'
278 278
         );
279
-        $form->addElement('html','<div id="blanks_weighting"></div>');
279
+        $form->addElement('html', '<div id="blanks_weighting"></div>');
280 280
 
281 281
         global $text;
282 282
         // setting the save button here and not in the question class.php
283
-        $form->addElement('html','<div id="defineoneblank" style="color:#D04A66; margin-left:160px">'.get_lang('DefineBlanks').'</div>');
283
+        $form->addElement('html', '<div id="defineoneblank" style="color:#D04A66; margin-left:160px">'.get_lang('DefineBlanks').'</div>');
284 284
         $form->addButtonSave($text, 'submitQuestion');
285 285
 
286 286
         if (!empty($this->id)) {
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         // remove spaces at the beginning and the end of text in square brackets
321 321
         $answer = preg_replace_callback(
322 322
             "/".$blankStartSeparatorRegexp."[^]]+".$blankEndSeparatorRegexp."/",
323
-            function ($matches) use ($blankStartSeparator, $blankEndSeparator) {
323
+            function($matches) use ($blankStartSeparator, $blankEndSeparator) {
324 324
                 $matchingResult = $matches[0];
325 325
                 $matchingResult = trim($matchingResult, $blankStartSeparator);
326 326
                 $matchingResult = trim($matchingResult, $blankEndSeparator);
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
         if ($nb > 0) {
366 366
             $answer .= '::';
367 367
             // weighting
368
-            for ($i=0; $i < $nb; ++$i) {
368
+            for ($i = 0; $i < $nb; ++$i) {
369 369
                 // enter the weighting of word $i
370 370
                 $answer .= $form->getSubmitValue('weighting['.$i.']');
371 371
                 // not the last word, add ","
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 
379 379
             // input width
380 380
             $answer .= ":";
381
-            for ($i=0; $i < $nb; ++$i) {
381
+            for ($i = 0; $i < $nb; ++$i) {
382 382
                 // enter the width of input for word $i
383 383
                 $answer .= $form->getSubmitValue('sizeofinput['.$i.']');
384 384
                 // not the last word, add ","
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 
404 404
         // Allow answers order switches
405 405
         $is_multiple = $form -> getSubmitValue('multiple_answer');
406
-        $answer.= '@'.$is_multiple;
406
+        $answer .= '@'.$is_multiple;
407 407
 
408 408
         $this->save();
409 409
         $objAnswer = new Answer($this->id);
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
     public function return_header($feedback_type = null, $counter = null, $score = null)
421 421
     {
422 422
         $header = parent::return_header($feedback_type, $counter, $score);
423
-        $header .= '<table class="'.$this->question_table_class .'">
423
+        $header .= '<table class="'.$this->question_table_class.'">
424 424
             <tr>
425 425
                 <th>'.get_lang("Answer").'</th>
426 426
             </tr>';
@@ -464,13 +464,13 @@  discard block
 block discarded – undo
464 464
                 // if display for student, shuffle the correct answer menu
465 465
                 $listMenu = self::getFillTheBlankMenuAnswers($inTeacherSolution, $displayForStudent);
466 466
                 $result .= '<select name="choice['.$questionId.'][]">';
467
-                for ($k=0; $k < count($listMenu); $k++) {
467
+                for ($k = 0; $k < count($listMenu); $k++) {
468 468
                     $selected = "";
469 469
                     if ($correctItem == $listMenu[$k]) {
470 470
                         $selected = " selected=selected ";
471 471
                     }
472 472
                     // if in teacher view, display the first item by default, which is the right answer
473
-                    if ($k==0 && !$displayForStudent) {
473
+                    if ($k == 0 && !$displayForStudent) {
474 474
                         $selected = " selected=selected ";
475 475
                     }
476 476
                     $optionMenu .= '<option '.$selected.' value="'.$listMenu[$k].'">'.$listMenu[$k].'</option>';
@@ -642,10 +642,10 @@  discard block
 block discarded – undo
642 642
         if (count($listDetails) < 3) {
643 643
             $listWeightings = explode(',', $listDetails[0]);
644 644
             $listSizeOfInput = array();
645
-            for ($i=0; $i < count($listWeightings); $i++) {
645
+            for ($i = 0; $i < count($listWeightings); $i++) {
646 646
                 $listSizeOfInput[] = 200;
647 647
             }
648
-            $blankSeparatorNumber = 0;    // 0 is [...]
648
+            $blankSeparatorNumber = 0; // 0 is [...]
649 649
         } else {
650 650
             $listWeightings = explode(',', $listDetails[0]);
651 651
             $listSizeOfInput = explode(',', $listDetails[1]);
@@ -677,9 +677,9 @@  discard block
 block discarded – undo
677 677
             // remove [ and ] in string
678 678
             array_walk(
679 679
                 $listWords[0],
680
-                function (&$value, $key, $tabBlankChar) {
680
+                function(&$value, $key, $tabBlankChar) {
681 681
                     $trimChars = "";
682
-                    for ($i=0; $i < count($tabBlankChar); $i++) {
682
+                    for ($i = 0; $i < count($tabBlankChar); $i++) {
683 683
                         $trimChars .= $tabBlankChar[$i];
684 684
                     }
685 685
                     $value = trim($value, $trimChars);
@@ -699,18 +699,18 @@  discard block
 block discarded – undo
699 699
         // if student answer, the second [] is the student answer,
700 700
         // the third is if student scored or not
701 701
         $listBrackets = array();
702
-        $listWords =  array();
702
+        $listWords = array();
703 703
 
704 704
         if ($isStudentAnswer) {
705
-            for ($i=0; $i < count($listAnswerResults['tabwords']); $i++) {
705
+            for ($i = 0; $i < count($listAnswerResults['tabwords']); $i++) {
706 706
                 $listBrackets[] = $listAnswerResults['tabwordsbracket'][$i];
707 707
                 $listWords[] = $listAnswerResults['tabwords'][$i];
708
-                if ($i+1 < count($listAnswerResults['tabwords'])) {
708
+                if ($i + 1 < count($listAnswerResults['tabwords'])) {
709 709
                     // should always be
710 710
                     $i++;
711 711
                 }
712 712
                 $listAnswerResults['studentanswer'][] = $listAnswerResults['tabwords'][$i];
713
-                if ($i+1 < count($listAnswerResults['tabwords'])) {
713
+                if ($i + 1 < count($listAnswerResults['tabwords'])) {
714 714
                     // should always be
715 715
                     $i++;
716 716
                 }
@@ -802,9 +802,9 @@  discard block
 block discarded – undo
802 802
                            break;
803 803
                        default :
804 804
                            if (FillBlanks::isGoodStudentAnswer($tabAnswer['studentanswer'][$bracketNumber], $tabAnswer['tabwords'][$bracketNumber])) {
805
-                               $tabUserResult[$data['user_id']][$bracketNumber] = 0;   //  right answer
805
+                               $tabUserResult[$data['user_id']][$bracketNumber] = 0; //  right answer
806 806
                            } else {
807
-                               $tabUserResult[$data['user_id']][$bracketNumber] = -1;  // wrong answer
807
+                               $tabUserResult[$data['user_id']][$bracketNumber] = -1; // wrong answer
808 808
                            }
809 809
                    }
810 810
                } else {
@@ -812,11 +812,11 @@  discard block
 block discarded – undo
812 812
                    if ($useLastAnswerredAttempt) {
813 813
                        // if we take into account the last answered attempt
814 814
                        if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) {
815
-                           $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
815
+                           $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered
816 816
                        }
817 817
                    } else {
818 818
                        // we take the last attempt, even if the student answer the question before
819
-                       $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
819
+                       $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered
820 820
                    }
821 821
                }
822 822
            }
@@ -837,10 +837,10 @@  discard block
 block discarded – undo
837 837
     {
838 838
         $outRes = 0;
839 839
         // for each student in group
840
-        foreach($resultList as $userId => $tabValue) {
840
+        foreach ($resultList as $userId => $tabValue) {
841 841
             $trouve = false;
842 842
             // for each bracket, if student has at leat one answer ( choice > -2) then he pass the question
843
-            foreach($tabValue as $i => $choice) {
843
+            foreach ($tabValue as $i => $choice) {
844 844
                 if ($choice > -2 && !$trouve) {
845 845
                     $outRes++;
846 846
                     $trouve = true;
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
         $separatorEnd = $listWithStudentAnswer['blankseparatorend'];
863 863
         // lets rebuild the sentence with [correct answer][student answer][answer is correct]
864 864
         $result = "";
865
-        for ($i=0; $i < count($listWithStudentAnswer['commonwords']) - 1; $i++) {
865
+        for ($i = 0; $i < count($listWithStudentAnswer['commonwords']) - 1; $i++) {
866 866
             $result .= $listWithStudentAnswer['commonwords'][$i];
867 867
             $result .= $listWithStudentAnswer['tabwordsbracket'][$i];
868 868
             $result .= $separatorStart.$listWithStudentAnswer['studentanswer'][$i].$separatorEnd;
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
             ")",
945 945
         ];
946 946
         $result = $text;
947
-        for ($i=0; $i < count($listRegexpCharacters); $i++) {
947
+        for ($i = 0; $i < count($listRegexpCharacters); $i++) {
948 948
             $result = str_replace($listRegexpCharacters[$i], "\\".$listRegexpCharacters[$i], $result);
949 949
         }
950 950
 
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
     {
1007 1007
         $listResults = array();
1008 1008
         $fillBlanksAllowedSeparator = self::getAllowedSeparator();
1009
-        for ($i=0; $i < count($fillBlanksAllowedSeparator); $i++) {
1009
+        for ($i = 0; $i < count($fillBlanksAllowedSeparator); $i++) {
1010 1010
             $listResults[] = $fillBlanksAllowedSeparator[$i][0]."...".$fillBlanksAllowedSeparator[$i][1];
1011 1011
         }
1012 1012
 
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
     {
1025 1025
         $listSeparators = self::getAllowedSeparator();
1026 1026
         $result = 0;
1027
-        for ($i=0; $i < count($listSeparators); $i++) {
1027
+        for ($i = 0; $i < count($listSeparators); $i++) {
1028 1028
             if ($listSeparators[$i][0] == $startSeparator &&
1029 1029
                 $listSeparators[$i][1] == $endSeparator
1030 1030
             ) {
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 
1050 1050
         // rebuild the answer with good HTML style
1051 1051
         // this is the student answer, right or wrong
1052
-        for ($i=0; $i < count($listStudentAnswerInfo['studentanswer']); $i++) {
1052
+        for ($i = 0; $i < count($listStudentAnswerInfo['studentanswer']); $i++) {
1053 1053
             if ($listStudentAnswerInfo['studentscore'][$i] == 1) {
1054 1054
                 $listStudentAnswerInfo['studentanswer'][$i] = self::getHtmlRightAnswer(
1055 1055
                     $listStudentAnswerInfo['studentanswer'][$i],
@@ -1067,7 +1067,7 @@  discard block
 block discarded – undo
1067 1067
 
1068 1068
 
1069 1069
         // rebuild the sentence with student answer inserted
1070
-        for ($i=0; $i < count($listStudentAnswerInfo['commonwords']); $i++) {
1070
+        for ($i = 0; $i < count($listStudentAnswerInfo['commonwords']); $i++) {
1071 1071
             $result .= isset($listStudentAnswerInfo['commonwords'][$i]) ? $listStudentAnswerInfo['commonwords'][$i] : '';
1072 1072
             $result .= isset($listStudentAnswerInfo['studentanswer'][$i]) ? $listStudentAnswerInfo['studentanswer'][$i] : '';
1073 1073
         }
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
                 $listPossibleAnswers = FillBlanks::getFillTheBlankMenuAnswers($correct, false);
1101 1101
                 $correctAnswerHtml .= "<span style='color: green'>".$listPossibleAnswers[0]."</span>";
1102 1102
                 $correctAnswerHtml .= " <span style='font-weight:normal'>(";
1103
-                for ($i=1; $i < count($listPossibleAnswers); $i++) {
1103
+                for ($i = 1; $i < count($listPossibleAnswers); $i++) {
1104 1104
                     $correctAnswerHtml .= $listPossibleAnswers[$i];
1105 1105
                     if ($i != count($listPossibleAnswers) - 1) {
1106 1106
                         $correctAnswerHtml .= " | ";
Please login to merge, or discard this patch.
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -728,43 +728,43 @@  discard block
 block discarded – undo
728 728
     }
729 729
 
730 730
     /**
731
-    * Return an array of student state answers for fill the blank questions
732
-    * for each students that answered the question
733
-    * -2  : didn't answer
734
-    * -1  : student answer is wrong
735
-    *  0  : student answer is correct
736
-    * >0  : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0)
737
-    *
738
-    * @param integer $testId
739
-    * @param integer $questionId
740
-    * @param $studentsIdList
741
-    * @param string $startDate
742
-    * @param string $endDate
743
-    * @param bool $useLastAnswerredAttempt
744
-    * @return array
745
-    * (
746
-    *     [student_id] => Array
747
-    *         (
748
-    *             [first fill the blank for question] => -1
749
-    *             [second fill the blank for question] => 2
750
-    *             [third fill the blank for question] => -1
751
-    *         )
752
-    * )
753
-    */
731
+     * Return an array of student state answers for fill the blank questions
732
+     * for each students that answered the question
733
+     * -2  : didn't answer
734
+     * -1  : student answer is wrong
735
+     *  0  : student answer is correct
736
+     * >0  : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0)
737
+     *
738
+     * @param integer $testId
739
+     * @param integer $questionId
740
+     * @param $studentsIdList
741
+     * @param string $startDate
742
+     * @param string $endDate
743
+     * @param bool $useLastAnswerredAttempt
744
+     * @return array
745
+     * (
746
+     *     [student_id] => Array
747
+     *         (
748
+     *             [first fill the blank for question] => -1
749
+     *             [second fill the blank for question] => 2
750
+     *             [third fill the blank for question] => -1
751
+     *         )
752
+     * )
753
+     */
754 754
     public static function getFillTheBlankTabResult($testId, $questionId, $studentsIdList, $startDate, $endDate, $useLastAnswerredAttempt = true) {
755 755
 
756
-       $tblTrackEAttempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
757
-       $tblTrackEExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
758
-       $courseId = api_get_course_int_id();
756
+        $tblTrackEAttempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
757
+        $tblTrackEExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
758
+        $courseId = api_get_course_int_id();
759 759
 
760
-       require_once api_get_path(SYS_PATH).'main/exercice/fill_blanks.class.php';
760
+        require_once api_get_path(SYS_PATH).'main/exercice/fill_blanks.class.php';
761 761
 
762
-       // request to have all the answers of student for this question
763
-       // student may have doing it several time
764
-       // student may have not answered the bracket id, in this case, is result of the answer is empty
762
+        // request to have all the answers of student for this question
763
+        // student may have doing it several time
764
+        // student may have not answered the bracket id, in this case, is result of the answer is empty
765 765
 
766
-       // we got the less recent attempt first
767
-       $sql = '
766
+        // we got the less recent attempt first
767
+        $sql = '
768 768
            SELECT * FROM '.$tblTrackEAttempt.' tea
769 769
 
770 770
            LEFT JOIN '.$tblTrackEExercise.' tee
@@ -780,49 +780,49 @@  discard block
 block discarded – undo
780 780
            ORDER BY user_id, tea.exe_id;
781 781
        ';
782 782
 
783
-       $res = Database::query($sql);
784
-       $tabUserResult = array();
785
-       $bracketNumber = 0;
786
-       // foreach attempts for all students starting with his older attempt
787
-       while ($data = Database::fetch_array($res)) {
788
-           $tabAnswer = FillBlanks::getAnswerInfo($data['answer'], true);
783
+        $res = Database::query($sql);
784
+        $tabUserResult = array();
785
+        $bracketNumber = 0;
786
+        // foreach attempts for all students starting with his older attempt
787
+        while ($data = Database::fetch_array($res)) {
788
+            $tabAnswer = FillBlanks::getAnswerInfo($data['answer'], true);
789 789
 
790
-           // for each bracket to find in this question
791
-           foreach ($tabAnswer['studentanswer'] as $bracketNumber => $studentAnswer) {
790
+            // for each bracket to find in this question
791
+            foreach ($tabAnswer['studentanswer'] as $bracketNumber => $studentAnswer) {
792 792
 
793
-               if ($tabAnswer['studentanswer'][$bracketNumber] != '') {
794
-                   // student has answered this bracket, cool
795
-                   switch (FillBlanks::getFillTheBlankAnswerType($tabAnswer['tabwords'][$bracketNumber])) {
796
-                       case self::FILL_THE_BLANK_MENU :
793
+                if ($tabAnswer['studentanswer'][$bracketNumber] != '') {
794
+                    // student has answered this bracket, cool
795
+                    switch (FillBlanks::getFillTheBlankAnswerType($tabAnswer['tabwords'][$bracketNumber])) {
796
+                        case self::FILL_THE_BLANK_MENU :
797 797
                            // get the indice of the choosen answer in the menu
798 798
                            // we know that the right answer is the first entry of the menu, ie 0
799 799
                            // (remember, menu entries are shuffled when taking the test)
800 800
                            $tabUserResult[$data['user_id']][$bracketNumber] = FillBlanks::getFillTheBlankMenuAnswerNum($tabAnswer['tabwords'][$bracketNumber], $tabAnswer['studentanswer'][$bracketNumber]);
801
-                           break;
802
-                       default :
801
+                            break;
802
+                        default :
803 803
                            if (FillBlanks::isGoodStudentAnswer($tabAnswer['studentanswer'][$bracketNumber], $tabAnswer['tabwords'][$bracketNumber])) {
804
-                               $tabUserResult[$data['user_id']][$bracketNumber] = 0;   //  right answer
805
-                           } else {
806
-                               $tabUserResult[$data['user_id']][$bracketNumber] = -1;  // wrong answer
807
-                           }
808
-                   }
809
-               } else {
810
-                   // student didn't answer this bracket
811
-                   if ($useLastAnswerredAttempt) {
812
-                       // if we take into account the last answered attempt
813
-                       if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) {
814
-                           $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
815
-                       }
816
-                   } else {
817
-                       // we take the last attempt, even if the student answer the question before
818
-                       $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
819
-                   }
820
-               }
821
-           }
822
-
823
-
824
-       }
825
-       return $tabUserResult;
804
+                                $tabUserResult[$data['user_id']][$bracketNumber] = 0;   //  right answer
805
+                            } else {
806
+                                $tabUserResult[$data['user_id']][$bracketNumber] = -1;  // wrong answer
807
+                            }
808
+                    }
809
+                } else {
810
+                    // student didn't answer this bracket
811
+                    if ($useLastAnswerredAttempt) {
812
+                        // if we take into account the last answered attempt
813
+                        if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) {
814
+                            $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
815
+                        }
816
+                    } else {
817
+                        // we take the last attempt, even if the student answer the question before
818
+                        $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
819
+                    }
820
+                }
821
+            }
822
+
823
+
824
+        }
825
+        return $tabUserResult;
826 826
     }
827 827
 
828 828
 
Please login to merge, or discard this patch.
main/exercice/exercise.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 
109 109
 if (!empty($gradebook) && $gradebook == 'view') {
110 110
     $interbreadcrumb[] = array(
111
-        'url' => '../gradebook/' . $_SESSION['gradebook_dest'],
111
+        'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
112 112
         'name' => get_lang('ToolGradebook')
113 113
     );
114 114
 }
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
                     );
699 699
 
700 700
                     // Exercise results
701
-                    $actions .='<a href="exercise_report.php?'.api_get_cidreq().'&exerciseId='.$row['id'].'">'.
701
+                    $actions .= '<a href="exercise_report.php?'.api_get_cidreq().'&exerciseId='.$row['id'].'">'.
702 702
                         Display :: return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
703 703
 
704 704
                     // Export
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
                         }
763 763
                     }
764 764
 
765
-                    $actions .='<a href="exercise_report.php?'.api_get_cidreq().'&exerciseId='.$row['id'].'">'.
765
+                    $actions .= '<a href="exercise_report.php?'.api_get_cidreq().'&exerciseId='.$row['id'].'">'.
766 766
                         Display :: return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
767 767
                     $actions .= Display::url(Display::return_icon('cd.gif', get_lang('CopyExercise')), '', array('onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToCopy'), ENT_QUOTES, $charset))." ".addslashes($row['title'])."?"."')) return false;", 'href' => 'exercise.php?'.api_get_cidreq().'&choice=copy_exercise&sec_token='.$token.'&exerciseId='.$row['id']));
768 768
                 }
@@ -952,7 +952,7 @@  discard block
 block discarded – undo
952 952
                 $item .= Display::tag('td', $actions, array('class' => 'td_actions'));
953 953
             } else {
954 954
                 if ($isDrhOfCourse) {
955
-                    $actions ='<a href="exercise_report.php?'.api_get_cidreq().'&exerciseId='.$row['id'].'">'.
955
+                    $actions = '<a href="exercise_report.php?'.api_get_cidreq().'&exerciseId='.$row['id'].'">'.
956 956
                         Display :: return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
957 957
                     $item .= Display::tag('td', $actions, array('class' => 'td_actions'));
958 958
                 }
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
                 'tr',
963 963
                 $item,
964 964
                 array(
965
-                    'id' => 'exercise_list_' . $my_exercise_id,
965
+                    'id' => 'exercise_list_'.$my_exercise_id,
966 966
                 )
967 967
             );
968 968
 
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
                 'adminhp.php?'.api_get_cidreq().'&hotpotatoesName='.$path
1034 1034
             );
1035 1035
 
1036
-            $actions .='<a href="hotpotatoes_exercise_report.php?'.api_get_cidreq().'&path='.$path.'">'.
1036
+            $actions .= '<a href="hotpotatoes_exercise_report.php?'.api_get_cidreq().'&path='.$path.'">'.
1037 1037
                 Display :: return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
1038 1038
 
1039 1039
             // if active
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
                 $actions .= '      <a href="'.$exercisePath.'?'.api_get_cidreq().'&hpchoice=disable&page='.$page.'&file='.$path.'">'.
1043 1043
                     Display::return_icon('visible.png', get_lang('Deactivate'), '', ICON_SIZE_SMALL).'</a>';
1044 1044
             } else { // else if not active
1045
-                $actions .='    <a href="'.$exercisePath.'?'.api_get_cidreq().'&hpchoice=enable&page='.$page.'&file='.$path.'">'.
1045
+                $actions .= '    <a href="'.$exercisePath.'?'.api_get_cidreq().'&hpchoice=enable&page='.$page.'&file='.$path.'">'.
1046 1046
                     Display::return_icon('invisible.png', get_lang('Activate'), '', ICON_SIZE_SMALL).'</a>';
1047 1047
             }
1048 1048
             $actions .= '<a href="'.$exercisePath.'?'.api_get_cidreq().'&hpchoice=delete&file='.$path.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('AreYouSureToDeleteJS'), ENT_QUOTES, $charset).' '.$title."?").'\')) return false;">'.
@@ -1075,7 +1075,7 @@  discard block
 block discarded – undo
1075 1075
                 $item .= Display::tag('td', $attemptText);
1076 1076
 
1077 1077
                 if ($isDrhOfCourse) {
1078
-                    $actions ='<a href="hotpotatoes_exercise_report.php?'.api_get_cidreq().'&path='.$path.'">'.
1078
+                    $actions = '<a href="hotpotatoes_exercise_report.php?'.api_get_cidreq().'&path='.$path.'">'.
1079 1079
                         Display :: return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
1080 1080
 
1081 1081
                     $item .= Display::tag('td', $actions, array('class' => 'td_actions'));
Please login to merge, or discard this patch.
main/exercice/Draggable.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
                 for ($i = 1; $i <= $answer->nbrAnswers; $i++) {
64 64
                     if ($answer->isCorrect($i)) {
65 65
                         $nb_matches++;
66
-                        $defaults['answer[' . $nb_matches . ']'] = $answer->selectAnswer($i);
67
-                        $defaults['weighting[' . $nb_matches . ']'] = float_format($answer->selectWeighting($i), 1);
66
+                        $defaults['answer['.$nb_matches.']'] = $answer->selectAnswer($i);
67
+                        $defaults['weighting['.$nb_matches.']'] = float_format($answer->selectWeighting($i), 1);
68 68
                         $answerInfo = $answer->getAnswerByAutoId($answer->correct[$i]);
69
-                        $defaults['matches[' . $nb_matches . ']'] = isset($answerInfo['answer']) ? $answerInfo['answer'] : '';
69
+                        $defaults['matches['.$nb_matches.']'] = isset($answerInfo['answer']) ? $answerInfo['answer'] : '';
70 70
                     } else {
71 71
                         $nb_options++;
72
-                        $defaults['option[' . $nb_options . ']'] = $answer->selectAnswer($i);
72
+                        $defaults['option['.$nb_options.']'] = $answer->selectAnswer($i);
73 73
                     }
74 74
                 }
75 75
             }
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
         $html = '<table class="table table-striped table-hover">
93 93
             <thead>
94 94
                 <tr>
95
-                    <th width="85%">' . get_lang('Answer') . '</th>
96
-                    <th width="15%">' . get_lang('MatchesTo') . '</th>
97
-                    <th width="10">' . get_lang('Weighting') . '</th>
95
+                    <th width="85%">' . get_lang('Answer').'</th>
96
+                    <th width="15%">' . get_lang('MatchesTo').'</th>
97
+                    <th width="10">' . get_lang('Weighting').'</th>
98 98
                 </tr>
99 99
             </thead>
100 100
             <tbody>';
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
         for ($i = 1; $i <= $nb_matches; ++$i) {
190 190
             $position++;
191 191
 
192
-            $answer = $form->getSubmitValue('answer[' . $i . ']');
193
-            $matches = $form->getSubmitValue('matches[' . $i . ']');
194
-            $weighting = $form->getSubmitValue('weighting[' . $i . ']');
192
+            $answer = $form->getSubmitValue('answer['.$i.']');
193
+            $matches = $form->getSubmitValue('matches['.$i.']');
194
+            $weighting = $form->getSubmitValue('weighting['.$i.']');
195 195
             $this->weighting += $weighting;
196 196
             $objAnswer->createAnswer(
197 197
                 $answer,
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
     public function return_header($feedback_type = null, $counter = null, $score = null)
217 217
     {
218 218
         $header = parent::return_header($feedback_type, $counter, $score);
219
-        $header .= '<table class="' . $this->question_table_class . '">
219
+        $header .= '<table class="'.$this->question_table_class.'">
220 220
             <tr>
221
-                <th>' . get_lang('ElementList') . '</th>
222
-                <th>' . get_lang('Status') . '</th>
221
+                <th>' . get_lang('ElementList').'</th>
222
+                <th>' . get_lang('Status').'</th>
223 223
             </tr>';
224 224
 
225 225
         return $header;
Please login to merge, or discard this patch.
main/exercice/exercise_admin.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -171,10 +171,11 @@
 block discarded – undo
171 171
     }
172 172
     echo '</div>';
173 173
 
174
-    if ($objExercise->feedback_type == 1)
175
-        Display::display_normal_message(
174
+    if ($objExercise->feedback_type == 1) {
175
+            Display::display_normal_message(
176 176
             get_lang('DirectFeedbackCantModifyTypeQuestion')
177 177
         );
178
+    }
178 179
 
179 180
     if (api_get_setting('search_enabled')=='true' && !extension_loaded('xapian')) {
180 181
         Display::display_error_message(get_lang('SearchXapianModuleNotInstalled'));
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 require_once '../inc/global.inc.php';
14 14
 $this_section = SECTION_COURSES;
15 15
 
16
-if (!api_is_allowed_to_edit(null,true)) {
16
+if (!api_is_allowed_to_edit(null, true)) {
17 17
     api_not_allowed(true);
18 18
 }
19 19
 
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
         $gradebook = $_SESSION['gradebook'];
167 167
     }
168 168
 
169
-    if (!empty($gradebook) && $gradebook=='view') {
170
-        $interbreadcrumb[]= array (
169
+    if (!empty($gradebook) && $gradebook == 'view') {
170
+        $interbreadcrumb[] = array(
171 171
             'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
172 172
             'name' => get_lang('ToolGradebook')
173 173
         );
@@ -187,19 +187,19 @@  discard block
 block discarded – undo
187 187
     echo '<div class="actions">';
188 188
 
189 189
     if ($objExercise->id != 0) {
190
-        echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">' .
190
+        echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'.
191 191
             Display :: return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>';
192 192
     } else {
193
-        if (!empty($_GET['lp_id']) || !empty($_POST['lp_id'])){
194
-            if (!empty($_POST['lp_id'])){
193
+        if (!empty($_GET['lp_id']) || !empty($_POST['lp_id'])) {
194
+            if (!empty($_POST['lp_id'])) {
195 195
                 $lp_id = intval($_POST['lp_id']);
196 196
                 //TODO:this remains to be implemented after press the first post
197 197
             } else {
198 198
                 $lp_id = intval($_GET['lp_id']);
199 199
             }
200
-            echo "<a href=\"../newscorm/lp_controller.php?".api_get_cidreq()."&gradebook=&action=add_item&type=step&lp_id=".$lp_id."#resource_tab-2\">".Display::return_icon('back.png', get_lang("BackTo").' '.get_lang("LearningPaths"),'',ICON_SIZE_MEDIUM)."</a>";
200
+            echo "<a href=\"../newscorm/lp_controller.php?".api_get_cidreq()."&gradebook=&action=add_item&type=step&lp_id=".$lp_id."#resource_tab-2\">".Display::return_icon('back.png', get_lang("BackTo").' '.get_lang("LearningPaths"), '', ICON_SIZE_MEDIUM)."</a>";
201 201
         } else {
202
-            echo '<a href="exercise.php?'.api_get_cidreq().'">' .
202
+            echo '<a href="exercise.php?'.api_get_cidreq().'">'.
203 203
                 Display :: return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM).
204 204
                 '</a>';
205 205
         }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
             get_lang('DirectFeedbackCantModifyTypeQuestion')
212 212
         );
213 213
 
214
-    if (api_get_setting('search_enabled')=='true' && !extension_loaded('xapian')) {
214
+    if (api_get_setting('search_enabled') == 'true' && !extension_loaded('xapian')) {
215 215
         Display::display_error_message(get_lang('SearchXapianModuleNotInstalled'));
216 216
     }
217 217
 
Please login to merge, or discard this patch.