Passed
Pull Request — 1.10.x (#1065)
by
unknown
100:42 queued 54:05
created
main/exercice/hotspot_answers.as.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@  discard block
 block discarded – undo
28 28
 $course_id     = api_get_course_int_id();
29 29
 
30 30
 if ($answer_type == HOT_SPOT_DELINEATION) {
31
-	// Query db for answers
32
-	$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM $TBL_ANSWERS
31
+    // Query db for answers
32
+    $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM $TBL_ANSWERS
33 33
 	        WHERE c_id = $course_id AND question_id = ".intval($questionId)." AND hotspot_type <> 'noerror' ORDER BY id";
34 34
 } else {
35
-	$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM $TBL_ANSWERS
35
+    $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM $TBL_ANSWERS
36 36
 	        WHERE c_id = $course_id AND question_id = ".intval($questionId)." ORDER BY id";
37 37
 }
38 38
 $result = Database::query($sql);
@@ -69,29 +69,29 @@  discard block
 block discarded – undo
69 69
     $hotSpot['id'] = $hotspot['id'];
70 70
     $hotSpot['answer'] = $hotspot['answer'];
71 71
 
72
-	// Square or rectancle
73
-	if ($hotspot['hotspot_type'] == 'square' ) {
72
+    // Square or rectancle
73
+    if ($hotspot['hotspot_type'] == 'square' ) {
74 74
         $hotSpot['type'] = 'square';
75
-	}
75
+    }
76 76
 
77
-	// Circle or ovale
78
-	if ($hotspot['hotspot_type'] == 'circle') {
77
+    // Circle or ovale
78
+    if ($hotspot['hotspot_type'] == 'circle') {
79 79
         $hotSpot['type'] = 'circle';
80
-	}
80
+    }
81 81
 
82
-	// Polygon
83
-	if ($hotspot['hotspot_type'] == 'poly') {
82
+    // Polygon
83
+    if ($hotspot['hotspot_type'] == 'poly') {
84 84
         $hotSpot['type'] = 'poly';
85
-	}
85
+    }
86 86
 
87
-	// Delineation
88
-	if ($hotspot['hotspot_type'] == 'delineation') {
87
+    // Delineation
88
+    if ($hotspot['hotspot_type'] == 'delineation') {
89 89
         $hotSpot['type'] = 'delineation';
90
-	}
91
-	// oar
92
-	if ($hotspot['hotspot_type'] == 'oar') {
90
+    }
91
+    // oar
92
+    if ($hotspot['hotspot_type'] == 'oar') {
93 93
         $hotSpot['type'] = 'delineation';
94
-	}
94
+    }
95 95
 
96 96
     $hotSpot['coord'] = $hotspot['hotspot_coordinates'];
97 97
 
Please login to merge, or discard this patch.
main/exercice/exercise_reminder.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -223,10 +223,10 @@
 block discarded – undo
223 223
 
224 224
     $counter++;
225 225
     if ($objExercise->type == ONE_PER_PAGE) {
226
-       $question_title = Display::url($counter.'. '.cut($objQuestionTmp->selectTitle(), 40), $url);
227
-       $question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40);
226
+        $question_title = Display::url($counter.'. '.cut($objQuestionTmp->selectTitle(), 40), $url);
227
+        $question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40);
228 228
     } else {
229
-       $question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40);
229
+        $question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40);
230 230
     }
231 231
     //Check if the question doesn't have an answer
232 232
     if (!in_array($questionId, $exercise_result)) {
Please login to merge, or discard this patch.
main/exercice/exercise_result.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
 $gradebook = '';
61 61
 if (isset($_SESSION['gradebook'])) {
62
-	$gradebook=	$_SESSION['gradebook'];
62
+    $gradebook=	$_SESSION['gradebook'];
63 63
 }
64 64
 if (!empty($gradebook) && $gradebook=='view') {
65 65
     $interbreadcrumb[] = array(
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 $htmlHeadXtra[] = '<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/css/hotspot.css">';
80 80
 
81 81
 if ($origin != 'learnpath') {
82
-	// So we are not in learnpath tool
83
-	Display::display_header($nameTools, get_lang('Exercise'));
82
+    // So we are not in learnpath tool
83
+    Display::display_header($nameTools, get_lang('Exercise'));
84 84
 } else {
85 85
     $htmlHeadXtra[] = "
86 86
     <style>
@@ -94,19 +94,19 @@  discard block
 block discarded – undo
94 94
 
95 95
 // I'm in a preview mode as course admin. Display the action menu.
96 96
 if (api_is_course_admin() && $origin != 'learnpath') {
97
-	echo '<div class="actions">';
98
-	echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'.
97
+    echo '<div class="actions">';
98
+    echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'.
99 99
         Display::return_icon('back.png', get_lang('GoBackToQuestionList'), array(), 32).'</a>';
100
-	echo '<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.
100
+    echo '<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.
101 101
         Display::return_icon('edit.png', get_lang('ModifyExercise'), array(), 32).'</a>';
102
-	echo '</div>';
102
+    echo '</div>';
103 103
 }
104 104
 
105 105
 $feedback_type = $objExercise->feedback_type;
106 106
 $exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
107 107
 
108 108
 if (!empty($exercise_stat_info['data_tracking'])) {
109
-	$question_list = explode(',', $exercise_stat_info['data_tracking']);
109
+    $question_list = explode(',', $exercise_stat_info['data_tracking']);
110 110
 }
111 111
 
112 112
 $learnpath_id = $exercise_stat_info['orig_lp_id'];
@@ -180,19 +180,19 @@  discard block
 block discarded – undo
180 180
         Session::erase('exe_id');
181 181
     }
182 182
 
183
-	Display::display_footer();
183
+    Display::display_footer();
184 184
 } else {
185
-	$lp_mode = isset($_SESSION['lp_mode']) ? $_SESSION['lp_mode'] : null;
186
-	$url = '../newscorm/lp_controller.php?cidReq='.api_get_course_id().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exercise_stat_info['exe_id'].'&fb_type='.$objExercise->feedback_type;
187
-	$href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'"';
185
+    $lp_mode = isset($_SESSION['lp_mode']) ? $_SESSION['lp_mode'] : null;
186
+    $url = '../newscorm/lp_controller.php?cidReq='.api_get_course_id().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exercise_stat_info['exe_id'].'&fb_type='.$objExercise->feedback_type;
187
+    $href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'"';
188 188
 
189 189
     if (api_is_allowed_to_session_edit()) {
190 190
         Session::erase('objExercise');
191 191
         Session::erase('exe_id');
192 192
     }
193 193
 
194
-	// Record the results in the learning path, using the SCORM interface (API)
195
-	echo "<script>window.parent.API.void_save_asset('$total_score', '$max_score', 0, 'completed');</script>";
194
+    // Record the results in the learning path, using the SCORM interface (API)
195
+    echo "<script>window.parent.API.void_save_asset('$total_score', '$max_score', 0, 'completed');</script>";
196 196
     echo '<script type="text/javascript">'.$href.'</script>';
197
-	echo '</body></html>';
197
+    echo '</body></html>';
198 198
 }
Please login to merge, or discard this patch.
main/exercice/exercise_result.class.php 1 patch
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 */
10 10
 class ExerciseResult
11 11
 {
12
-	private $results = array();
12
+    private $results = array();
13 13
     public $includeAllUsers = false;
14 14
     public $onlyBestAttempts = false;
15 15
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
         $exercise_id = 0,
47 47
         $hotpotato_name = null
48 48
     ) {
49
-		$return = array();
49
+        $return = array();
50 50
 
51 51
         $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
52 52
         $TBL_TABLE_LP_MAIN = Database::get_course_table(TABLE_LP_MAIN);
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
             $session_id_and .= " AND exe_exo_id = $exercise_id ";
67 67
         }
68 68
 
69
-		if (empty($user_id)) {
69
+        if (empty($user_id)) {
70 70
             $user_id_and = null;
71
-			$sql = "SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").",
71
+            $sql = "SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").",
72 72
 			            official_code,
73 73
                         ce.title as extitle,
74 74
                         te.exe_result as exresult ,
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
                     te.status != 'incomplete' AND
92 92
                     te.c_id = ce.c_id $user_id_and  $session_id_and AND
93 93
                     ce.active <>-1";
94
-		} else {
94
+        } else {
95 95
             $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' ';
96
-			// get only this user's results
96
+            // get only this user's results
97 97
             $sql="SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").",
98 98
                     official_code,
99 99
                     ce.title as extitle,
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
                         te.c_id = ce.c_id $user_id_and $session_id_and AND
120 120
                         ce.active <>-1 AND
121 121
                     ORDER BY userpart2, te.c_id ASC, ce.title ASC, te.exe_date DESC";
122
-		}
122
+        }
123 123
 
124
-		$results = array();
125
-		$resx = Database::query($sql);
124
+        $results = array();
125
+        $resx = Database::query($sql);
126 126
         $bestAttemptPerUser = array();
127
-		while ($rowx = Database::fetch_array($resx,'ASSOC')) {
127
+        while ($rowx = Database::fetch_array($resx,'ASSOC')) {
128 128
             if ($this->onlyBestAttempts) {
129 129
                 if (!isset($bestAttemptPerUser[$rowx['excruid']])) {
130 130
                     $bestAttemptPerUser[$rowx['excruid']] = $rowx;
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
             } else {
137 137
                 $results[] = $rowx;
138 138
             }
139
-		}
139
+        }
140 140
 
141 141
         if ($this->onlyBestAttempts) {
142 142
             $results = $bestAttemptPerUser;
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
                     continue;
191 191
                 }
192 192
 
193
-				$return[$i] = array();
194
-				if (empty($user_id)) {
193
+                $return[$i] = array();
194
+                if (empty($user_id)) {
195 195
                     $return[$i]['official_code']   = $result['official_code'];
196 196
                     if (api_is_western_name_order()) {
197 197
                         $return[$i]['first_name']   = $results[$i]['userpart1'];
@@ -200,15 +200,15 @@  discard block
 block discarded – undo
200 200
                         $return[$i]['first_name']   = $results[$i]['userpart2'];
201 201
                         $return[$i]['last_name']    = $results[$i]['userpart1'];
202 202
                     }
203
-					$return[$i]['user_id']      = $results[$i]['excruid'];
204
-					$return[$i]['email']        = $results[$i]['exemail'];
205
-				}
206
-				$return[$i]['title'] = $result['extitle'];
207
-				$return[$i]['start_date'] = api_get_local_time($result['exstart']);
203
+                    $return[$i]['user_id']      = $results[$i]['excruid'];
204
+                    $return[$i]['email']        = $results[$i]['exemail'];
205
+                }
206
+                $return[$i]['title'] = $result['extitle'];
207
+                $return[$i]['start_date'] = api_get_local_time($result['exstart']);
208 208
                 $return[$i]['end_date'] = api_get_local_time($result['exdate']);
209 209
                 $return[$i]['duration'] = $result['duration'];
210
-				$return[$i]['result'] = $result['exresult'];
211
-				$return[$i]['max'] = $result['exweight'];
210
+                $return[$i]['result'] = $result['exresult'];
211
+                $return[$i]['max'] = $result['exweight'];
212 212
                 $return[$i]['status'] = $revised ? get_lang('Validated') : get_lang('NotValidated');
213 213
                 $return[$i]['lp_id'] = $result['orig_lp_id'];
214 214
                 $return[$i]['lp_name'] = $result['lp_name'];
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 
222 222
                 $userWithResults[$result['excruid']] = 1;
223 223
                 $i++;
224
-			}
225
-		}
224
+            }
225
+        }
226 226
 
227 227
         if ($this->includeAllUsers) {
228 228
             $latestId = count($return);
@@ -265,18 +265,18 @@  discard block
 block discarded – undo
265 265
             }
266 266
         }
267 267
 
268
-		$this->results = $return;
268
+        $this->results = $return;
269 269
 
270
-		return true;
271
-	}
270
+        return true;
271
+    }
272 272
 
273
-	/**
274
-	 * Exports the complete report as a CSV file
275
-	 * @param	string		Document path inside the document tool
276
-	 * @param	integer		Optional user ID
277
-	 * @param	boolean		Whether to include user fields or not
278
-	 * @return	boolean		False on error
279
-	 */
273
+    /**
274
+     * Exports the complete report as a CSV file
275
+     * @param	string		Document path inside the document tool
276
+     * @param	integer		Optional user ID
277
+     * @param	boolean		Whether to include user fields or not
278
+     * @return	boolean		False on error
279
+     */
280 280
     public function exportCompleteReportCSV(
281 281
         $document_path = '',
282 282
         $user_id = null,
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
         $exercise_id = 0,
286 286
         $hotpotato_name = null
287 287
     ) {
288
-		global $charset;
289
-		$this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
290
-
291
-		$filename = 'exercise_results_'.date('YmdGis').'.csv';
292
-		if(!empty($user_id)) {
293
-			$filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
294
-		}
295
-		$data = '';
288
+        global $charset;
289
+        $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
290
+
291
+        $filename = 'exercise_results_'.date('YmdGis').'.csv';
292
+        if(!empty($user_id)) {
293
+            $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
294
+        }
295
+        $data = '';
296 296
         if (api_is_western_name_order()) {
297 297
             if(!empty($this->results[0]['first_name'])) {
298 298
                 $data .= get_lang('FirstName').';';
@@ -316,28 +316,28 @@  discard block
 block discarded – undo
316 316
         $data .= get_lang('Email').';';
317 317
         $data .= get_lang('Groups').';';
318 318
 
319
-		if ($export_user_fields) {
320
-			//show user fields section with a big th colspan that spans over all fields
321
-			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
322
-			$num = count($extra_user_fields);
323
-			foreach($extra_user_fields as $field) {
324
-				$data .= '"'.str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)).'";';
325
-			}
326
-		}
327
-
328
-		$data .= get_lang('Title').';';
329
-		$data .= get_lang('StartDate').';';
319
+        if ($export_user_fields) {
320
+            //show user fields section with a big th colspan that spans over all fields
321
+            $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
322
+            $num = count($extra_user_fields);
323
+            foreach($extra_user_fields as $field) {
324
+                $data .= '"'.str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)).'";';
325
+            }
326
+        }
327
+
328
+        $data .= get_lang('Title').';';
329
+        $data .= get_lang('StartDate').';';
330 330
         $data .= get_lang('EndDate').';';
331 331
         $data .= get_lang('Duration'). ' ('.get_lang('MinMinutes').') ;';
332
-		$data .= get_lang('Score').';';
333
-		$data .= get_lang('Total').';';
332
+        $data .= get_lang('Score').';';
333
+        $data .= get_lang('Total').';';
334 334
         $data .= get_lang('Status').';';
335 335
         $data .= get_lang('ToolLearnpath').';';
336 336
         $data .= get_lang('UserIsCurrentlySubscribed').';';
337
-		$data .= "\n";
337
+        $data .= "\n";
338 338
 
339
-		//results
340
-		foreach ($this->results as $row) {
339
+        //results
340
+        foreach ($this->results as $row) {
341 341
 
342 342
             if (api_is_western_name_order()) {
343 343
                 $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
@@ -354,51 +354,51 @@  discard block
 block discarded – undo
354 354
             $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
355 355
             $data .= str_replace("\r\n",'  ',implode(", ", GroupManager :: get_user_group_name($row['user_id']))).';';
356 356
 
357
-			if ($export_user_fields) {
358
-				//show user fields data, if any, for this user
359
-				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
360
-				foreach($user_fields_values as $value) {
361
-					$data .= '"'.str_replace('"','""',api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)).'";';
362
-				}
363
-			}
357
+            if ($export_user_fields) {
358
+                //show user fields data, if any, for this user
359
+                $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
360
+                foreach($user_fields_values as $value) {
361
+                    $data .= '"'.str_replace('"','""',api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)).'";';
362
+                }
363
+            }
364 364
 
365
-			$data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
366
-			$data .= str_replace("\r\n",'  ',$row['start_date']).';';
365
+            $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
366
+            $data .= str_replace("\r\n",'  ',$row['start_date']).';';
367 367
             $data .= str_replace("\r\n",'  ',$row['end_date']).';';
368 368
             $data .= str_replace("\r\n",'  ',$row['duration']).';';
369
-			$data .= str_replace("\r\n",'  ',$row['result']).';';
370
-			$data .= str_replace("\r\n",'  ',$row['max']).';';
369
+            $data .= str_replace("\r\n",'  ',$row['result']).';';
370
+            $data .= str_replace("\r\n",'  ',$row['max']).';';
371 371
             $data .= str_replace("\r\n",'  ',$row['status']).';';
372 372
             $data .= str_replace("\r\n",'  ',$row['lp_name']).';';
373 373
             $data .= str_replace("\r\n",'  ',$row['is_user_subscribed']).';';
374
-			$data .= "\n";
375
-		}
376
-
377
-		//output the results
378
-		$len = strlen($data);
379
-		header('Content-type: application/octet-stream');
380
-		header('Content-Type: application/force-download');
381
-		header('Content-length: '.$len);
382
-		if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
383
-			header('Content-Disposition: filename= '.$filename);
384
-		} else {
385
-			header('Content-Disposition: attachment; filename= '.$filename);
386
-		}
387
-		if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
388
-			header('Pragma: ');
389
-			header('Cache-Control: ');
390
-			header('Cache-Control: public'); // IE cannot download from sessions without a cache
391
-		}
392
-		header('Content-Description: '.$filename);
393
-		header('Content-transfer-encoding: binary');
394
-		echo $data;
395
-		return true;
396
-	}
397
-
398
-	/**
399
-	 * Exports the complete report as an XLS file
400
-	 * @return	boolean		False on error
401
-	 */
374
+            $data .= "\n";
375
+        }
376
+
377
+        //output the results
378
+        $len = strlen($data);
379
+        header('Content-type: application/octet-stream');
380
+        header('Content-Type: application/force-download');
381
+        header('Content-length: '.$len);
382
+        if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
383
+            header('Content-Disposition: filename= '.$filename);
384
+        } else {
385
+            header('Content-Disposition: attachment; filename= '.$filename);
386
+        }
387
+        if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
388
+            header('Pragma: ');
389
+            header('Cache-Control: ');
390
+            header('Cache-Control: public'); // IE cannot download from sessions without a cache
391
+        }
392
+        header('Content-Description: '.$filename);
393
+        header('Content-transfer-encoding: binary');
394
+        echo $data;
395
+        return true;
396
+    }
397
+
398
+    /**
399
+     * Exports the complete report as an XLS file
400
+     * @return	boolean		False on error
401
+     */
402 402
     public function exportCompleteReportXLS(
403 403
         $document_path = '',
404 404
         $user_id = null,
@@ -407,35 +407,35 @@  discard block
 block discarded – undo
407 407
         $exercise_id = 0,
408 408
         $hotpotato_name = null
409 409
     ) {
410
-		global $charset;
411
-		$this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
412
-		$filename = 'exercise_results_'.api_get_local_time().'.xls';
413
-		if (!empty($user_id)) {
414
-			$filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
415
-		}
410
+        global $charset;
411
+        $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
412
+        $filename = 'exercise_results_'.api_get_local_time().'.xls';
413
+        if (!empty($user_id)) {
414
+            $filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
415
+        }
416 416
 
417 417
         $spreadsheet = new PHPExcel();
418 418
         $spreadsheet->setActiveSheetIndex(0);
419 419
         $worksheet = $spreadsheet->getActiveSheet();
420 420
 
421
-		$line = 0;
422
-		$column = 0; //skip the first column (row titles)
421
+        $line = 0;
422
+        $column = 0; //skip the first column (row titles)
423 423
 
424
-		// check if exists column 'user'
425
-		$with_column_user = false;
426
-		foreach ($this->results as $result) {
427
-			if (!empty($result['last_name']) && !empty($result['first_name'])) {
428
-				$with_column_user = true;
429
-				break;
430
-			}
431
-		}
424
+        // check if exists column 'user'
425
+        $with_column_user = false;
426
+        foreach ($this->results as $result) {
427
+            if (!empty($result['last_name']) && !empty($result['first_name'])) {
428
+                $with_column_user = true;
429
+                break;
430
+            }
431
+        }
432 432
 
433 433
         $officialCodeInList = api_get_setting('show_official_code_exercise_result_list');
434 434
 
435
-		if ($with_column_user) {
435
+        if ($with_column_user) {
436 436
             if (api_is_western_name_order()) {
437
-    			$worksheet->SetCellValueByColumnAndRow($line, $column,get_lang('FirstName'));
438
-    			$column++;
437
+                $worksheet->SetCellValueByColumnAndRow($line, $column,get_lang('FirstName'));
438
+                $column++;
439 439
                 $worksheet->SetCellValueByColumnAndRow($line, $column,get_lang('LastName'));
440 440
                 $column++;
441 441
             } else {
@@ -451,43 +451,43 @@  discard block
 block discarded – undo
451 451
             }
452 452
 
453 453
             $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Email'));
454
-		    $column++;
455
-		}
454
+            $column++;
455
+        }
456 456
         $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Groups'));
457
-	    $column++;
458
-
459
-		if ($export_user_fields) {
460
-			//show user fields section with a big th colspan that spans over all fields
461
-			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
462
-
463
-			//show the fields names for user fields
464
-			foreach ($extra_user_fields as $field) {
465
-				$worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset));
466
-				$column++;
467
-			}
468
-		}
469
-
470
-		$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Title'));
471
-		$column++;
472
-		$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('StartDate'));
457
+        $column++;
458
+
459
+        if ($export_user_fields) {
460
+            //show user fields section with a big th colspan that spans over all fields
461
+            $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
462
+
463
+            //show the fields names for user fields
464
+            foreach ($extra_user_fields as $field) {
465
+                $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset));
466
+                $column++;
467
+            }
468
+        }
469
+
470
+        $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Title'));
471
+        $column++;
472
+        $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('StartDate'));
473 473
         $column++;
474 474
         $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('EndDate'));
475 475
         $column++;
476 476
         $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Duration').' ('.get_lang('MinMinutes').')');
477
-		$column++;
478
-		$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Score'));
479
-		$column++;
480
-		$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Total'));
481
-		$column++;
477
+        $column++;
478
+        $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Score'));
479
+        $column++;
480
+        $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Total'));
481
+        $column++;
482 482
         $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Status'));
483
-		$column++;
483
+        $column++;
484 484
         $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('ToolLearnpath'));
485 485
         $column++;
486 486
         $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('UserIsCurrentlySubscribed'));
487
-		$line++;
487
+        $line++;
488 488
 
489
-		foreach ($this->results as $row) {
490
-			$column = 0;
489
+        foreach ($this->results as $row) {
490
+            $column = 0;
491 491
 
492 492
             if ($with_column_user) {
493 493
                 if (api_is_western_name_order()) {
@@ -509,22 +509,22 @@  discard block
 block discarded – undo
509 509
 
510 510
                 $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset));
511 511
                 $column++;
512
-			}
512
+            }
513 513
 
514 514
             $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags(implode(", ", GroupManager :: get_user_group_name($row['user_id']))), ENT_QUOTES, $charset));
515 515
             $column++;
516 516
 
517
-			if ($export_user_fields) {
518
-				//show user fields data, if any, for this user
519
-				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
520
-				foreach($user_fields_values as $value) {
521
-					$worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
522
-					$column++;
523
-				}
524
-			}
525
-
526
-			$worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
527
-			$column++;
517
+            if ($export_user_fields) {
518
+                //show user fields data, if any, for this user
519
+                $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
520
+                foreach($user_fields_values as $value) {
521
+                    $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
522
+                    $column++;
523
+                }
524
+            }
525
+
526
+            $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
527
+            $column++;
528 528
             $worksheet->SetCellValueByColumnAndRow($line, $column, $row['start_date']);
529 529
             $column++;
530 530
             $worksheet->SetCellValueByColumnAndRow($line, $column, $row['end_date']);
@@ -540,14 +540,14 @@  discard block
 block discarded – undo
540 540
             $worksheet->SetCellValueByColumnAndRow($line, $column, $row['lp_name']);
541 541
             $column++;
542 542
             $worksheet->SetCellValueByColumnAndRow($line, $column, $row['is_user_subscribed']);
543
-			$line++;
544
-		}
543
+            $line++;
544
+        }
545 545
 
546 546
         $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename);
547 547
         $writer = new PHPExcel_Writer_Excel2007($spreadsheet);
548 548
         $writer->save($file);
549 549
         DocumentManager::file_send_for_download($file, true, $filename);
550 550
 
551
-		return true;
552
-	}
551
+        return true;
552
+    }
553 553
 }
Please login to merge, or discard this patch.
main/exercice/addlimits.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 /**
4
- * Adding limits
5
- * @package chamilo.exercise
6
- * @deprecated ?
7
- */
4
+     * Adding limits
5
+     * @package chamilo.exercise
6
+     * @deprecated ?
7
+     */
8 8
 require_once '../inc/global.inc.php';
9 9
 
10 10
 $this_section = SECTION_COURSES;
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
 $is_allowedToEdit=$is_courseAdmin;
55 55
 
56 56
 if (isset($_SESSION['gradebook'])){
57
-	$gradebook=	$_SESSION['gradebook'];
57
+    $gradebook=	$_SESSION['gradebook'];
58 58
 }
59 59
 
60 60
 if (!empty($gradebook) && $gradebook=='view') {
61
-	$interbreadcrumb[]= array (
62
-			'url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']),
63
-			'name' => get_lang('ToolGradebook')
64
-		);
61
+    $interbreadcrumb[]= array (
62
+            'url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']),
63
+            'name' => get_lang('ToolGradebook')
64
+        );
65 65
 }
66 66
 $nameTools=get_lang('Exercises');
67 67
 $interbreadcrumb[] = array(
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 Display::display_header($nameTools,"Exercises");
72 72
 
73 73
 if (isset($_POST['ok'])) {
74
-	$message = get_lang('TestLimitsAdded');
75
-	Display::display_normal_message($message);
74
+    $message = get_lang('TestLimitsAdded');
75
+    Display::display_normal_message($message);
76 76
 }
77 77
 ?>
78 78
 <script type="text/javascript">
@@ -136,25 +136,25 @@  discard block
 block discarded – undo
136 136
 </form>
137 137
 <?php
138 138
 /**
139
- * @todo shouldn't this be moved to the part above (around line 111: action handling)
140
- */
139
+     * @todo shouldn't this be moved to the part above (around line 111: action handling)
140
+     */
141 141
 if (isset($_POST['ok'])) {
142
-	$exercise_id = intval($_POST['exe_id']);
143
-	if ($_POST['limit']==1) {
144
-		$minutes = intval($_POST['minutes']);
145
-		$query = "UPDATE ".$TBL_EXERCISES." SET ques_time_limit= $minutes WHERE id= $exercise_id";
146
-		Database::query($query);
147
-	} else {
148
-		$query = "UPDATE ".$TBL_EXERCISES." SET ques_time_limit= 0 WHERE id= $exercise_id";
149
-		Database::query($query);
150
-	}
142
+    $exercise_id = intval($_POST['exe_id']);
143
+    if ($_POST['limit']==1) {
144
+        $minutes = intval($_POST['minutes']);
145
+        $query = "UPDATE ".$TBL_EXERCISES." SET ques_time_limit= $minutes WHERE id= $exercise_id";
146
+        Database::query($query);
147
+    } else {
148
+        $query = "UPDATE ".$TBL_EXERCISES." SET ques_time_limit= 0 WHERE id= $exercise_id";
149
+        Database::query($query);
150
+    }
151 151
 
152
-	if ($_POST['attempt']==1) {
153
-		$attempts = intval($_POST['attempts']);
154
-		$query = "UPDATE ".$TBL_EXERCISES." SET num_attempts = $attempts WHERE id= $exercise_id";
155
-		Database::query($query);
156
-	} else {
157
-		$query = "UPDATE ".$TBL_EXERCISES." SET num_attempts = 0 WHERE id= $exercise_id";
158
-		Database::query($query);
159
-	}
152
+    if ($_POST['attempt']==1) {
153
+        $attempts = intval($_POST['attempts']);
154
+        $query = "UPDATE ".$TBL_EXERCISES." SET num_attempts = $attempts WHERE id= $exercise_id";
155
+        Database::query($query);
156
+    } else {
157
+        $query = "UPDATE ".$TBL_EXERCISES." SET num_attempts = 0 WHERE id= $exercise_id";
158
+        Database::query($query);
159
+    }
160 160
 }
Please login to merge, or discard this patch.
main/exercice/export/qti2/qti2_classes.php 1 patch
Indentation   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -55,18 +55,18 @@  discard block
 block discarded – undo
55 55
 
56 56
     function createAnswersForm($form)
57 57
     {
58
-    	return true;
58
+        return true;
59 59
     }
60 60
 
61 61
     function processAnswersCreation($form)
62 62
     {
63
-    	return true;
63
+        return true;
64 64
     }
65 65
 }
66 66
 /**
67
- * Class
68
- * @package chamilo.exercise
69
- */
67
+     * Class
68
+     * @package chamilo.exercise
69
+     */
70 70
 class ImsAnswerMultipleChoice extends Answer
71 71
 {
72 72
     /**
@@ -76,21 +76,21 @@  discard block
 block discarded – undo
76 76
     public function imsExportResponses($questionIdent, $questionStatment)
77 77
     {
78 78
         // @todo getAnswersList() converts the answers using api_html_entity_decode()
79
-		$this->answerList = $this->getAnswersList(true);
79
+        $this->answerList = $this->getAnswersList(true);
80 80
         $out  = '    <choiceInteraction responseIdentifier="' . $questionIdent . '" >' . "\n";
81 81
         $out .= '      <prompt><![CDATA['.formatExerciseQtiTitle($questionStatment) . ']]></prompt>'. "\n";
82
-		if (is_array($this->answerList)) {
83
-	        foreach ($this->answerList as $current_answer) {
84
-	            $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false">
82
+        if (is_array($this->answerList)) {
83
+            foreach ($this->answerList as $current_answer) {
84
+                $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false">
85 85
                          <![CDATA['.formatExerciseQtiTitle($current_answer['answer']).']]>';
86
-	            if (isset($current_answer['comment']) && $current_answer['comment'] != '') {
87
-	                $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '">
86
+                if (isset($current_answer['comment']) && $current_answer['comment'] != '') {
87
+                    $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '">
88 88
 	                         <![CDATA['.formatExerciseQtiTitle($current_answer['comment']).']]>
89 89
 	                         </feedbackInline>';
90
-	            }
91
-	            $out .= '</simpleChoice>'. "\n";
92
-	        }
93
-		}
90
+                }
91
+                $out .= '</simpleChoice>'. "\n";
92
+            }
93
+        }
94 94
         $out .= '    </choiceInteraction>'. "\n";
95 95
 
96 96
         return $out;
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
      */
103 103
     public function imsExportResponsesDeclaration($questionIdent)
104 104
     {
105
-		$this->answerList = $this->getAnswersList(true);
106
-		$type = $this->getQuestionType();
105
+        $this->answerList = $this->getAnswersList(true);
106
+        $type = $this->getQuestionType();
107 107
         if ($type == MCMA)  $cardinality = 'multiple'; else $cardinality = 'single';
108 108
 
109 109
         $out = '  <responseDeclaration identifier="' . $questionIdent . '" cardinality="' . $cardinality . '" baseType="identifier">' . "\n";
@@ -111,25 +111,25 @@  discard block
 block discarded – undo
111 111
         // Match the correct answers.
112 112
 
113 113
         $out .= '    <correctResponse>'. "\n";
114
-		if (is_array($this->answerList)) {
115
-	        foreach($this->answerList as $current_answer) {
116
-	            if ($current_answer['correct']) {
117
-	                $out .= '      <value>answer_'. $current_answer['id'] .'</value>'. "\n";
118
-	            }
119
-	        }
120
-		}
114
+        if (is_array($this->answerList)) {
115
+            foreach($this->answerList as $current_answer) {
116
+                if ($current_answer['correct']) {
117
+                    $out .= '      <value>answer_'. $current_answer['id'] .'</value>'. "\n";
118
+                }
119
+            }
120
+        }
121 121
         $out .= '    </correctResponse>'. "\n";
122 122
 
123 123
         //Add the grading
124 124
 
125 125
         $out .= '    <mapping>'. "\n";
126
-		if (is_array($this->answerList)) {
127
-	        foreach($this->answerList as $current_answer) {
128
-	            if (isset($current_answer['grade'])) {
129
-	                $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n";
130
-	            }
131
-	        }
132
-		}
126
+        if (is_array($this->answerList)) {
127
+            foreach($this->answerList as $current_answer) {
128
+                if (isset($current_answer['grade'])) {
129
+                    $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n";
130
+                }
131
+            }
132
+        }
133 133
         $out .= '    </mapping>'. "\n";
134 134
         $out .= '  </responseDeclaration>'. "\n";
135 135
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      */
151 151
     public function imsExportResponses($questionIdent, $questionStatment)
152 152
     {
153
-		$this->answerList = $this->getAnswersList(true);
153
+        $this->answerList = $this->getAnswersList(true);
154 154
         $text = '';
155 155
         $text .= $this->answerText;
156 156
         if (is_array($this->answerList)) {
@@ -171,28 +171,28 @@  discard block
 block discarded – undo
171 171
      */
172 172
     public function imsExportResponsesDeclaration($questionIdent)
173 173
     {
174
-		$this->answerList = $this->getAnswersList(true);
175
-		$this->gradeList = $this->getGradesList();
174
+        $this->answerList = $this->getAnswersList(true);
175
+        $this->gradeList = $this->getGradesList();
176 176
         $out = '';
177
-		if (is_array($this->answerList)) {
178
-	        foreach ($this->answerList as $answer) {
179
-	        	$answerKey = $answer['id'];
180
-	        	$answer = $answer['answer'];
181
-	            $out .= '  <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n";
182
-	            $out .= '    <correctResponse>'. "\n";
177
+        if (is_array($this->answerList)) {
178
+            foreach ($this->answerList as $answer) {
179
+                $answerKey = $answer['id'];
180
+                $answer = $answer['answer'];
181
+                $out .= '  <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n";
182
+                $out .= '    <correctResponse>'. "\n";
183 183
                 $out .= '      <value><![CDATA['.formatExerciseQtiTitle($answer).']]></value>'. "\n";
184
-	            $out .= '    </correctResponse>'. "\n";
185
-	            if (isset($this->gradeList[$answerKey])) {
186
-	                $out .= '    <mapping>'. "\n";
187
-	                $out .= '      <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n";
188
-	                $out .= '    </mapping>'. "\n";
189
-	            }
190
-
191
-	            $out .= '  </responseDeclaration>'. "\n";
192
-	        }
193
-		}
194
-
195
-       return $out;
184
+                $out .= '    </correctResponse>'. "\n";
185
+                if (isset($this->gradeList[$answerKey])) {
186
+                    $out .= '    <mapping>'. "\n";
187
+                    $out .= '      <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n";
188
+                    $out .= '    </mapping>'. "\n";
189
+                }
190
+
191
+                $out .= '  </responseDeclaration>'. "\n";
192
+            }
193
+        }
194
+
195
+        return $out;
196 196
     }
197 197
 }
198 198
 
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
      */
208 208
     public function imsExportResponses($questionIdent, $questionStatment)
209 209
     {
210
-		$this->answerList = $this->getAnswersList(true);
211
-		$maxAssociation = max(count($this->leftList), count($this->rightList));
210
+        $this->answerList = $this->getAnswersList(true);
211
+        $maxAssociation = max(count($this->leftList), count($this->rightList));
212 212
 
213 213
         $out = "";
214 214
 
@@ -218,14 +218,14 @@  discard block
 block discarded – undo
218 218
         //add left column
219 219
 
220 220
         $out .= '  <simpleMatchSet>'. "\n";
221
-		if (is_array($this->leftList)) {
222
-	        foreach ($this->leftList as $leftKey=>$leftElement) {
223
-	            $out .= '
221
+        if (is_array($this->leftList)) {
222
+            foreach ($this->leftList as $leftKey=>$leftElement) {
223
+                $out .= '
224 224
 	            <simpleAssociableChoice identifier="left_'.$leftKey.'" >
225 225
 	                <![CDATA['.formatExerciseQtiTitle($leftElement['answer']).']]>
226 226
 	            </simpleAssociableChoice>'. "\n";
227
-	        }
228
-    	}
227
+            }
228
+        }
229 229
 
230 230
         $out .= '  </simpleMatchSet>'. "\n";
231 231
 
@@ -235,14 +235,14 @@  discard block
 block discarded – undo
235 235
 
236 236
         $i = 0;
237 237
 
238
-		if (is_array($this->rightList)) {
239
-	        foreach($this->rightList as $rightKey=>$rightElement) {
240
-	            $out .= '<simpleAssociableChoice identifier="right_'.$i.'" >
238
+        if (is_array($this->rightList)) {
239
+            foreach($this->rightList as $rightKey=>$rightElement) {
240
+                $out .= '<simpleAssociableChoice identifier="right_'.$i.'" >
241 241
 	                    <![CDATA['.formatExerciseQtiTitle($rightElement['answer']).']]>
242 242
 	                    </simpleAssociableChoice>'. "\n";
243
-	            $i++;
244
-	        }
245
-		}
243
+                $i++;
244
+            }
245
+        }
246 246
         $out .= '  </simpleMatchSet>'. "\n";
247 247
         $out .= '</matchInteraction>'. "\n";
248 248
 
@@ -254,30 +254,30 @@  discard block
 block discarded – undo
254 254
      */
255 255
     public function imsExportResponsesDeclaration($questionIdent)
256 256
     {
257
-		$this->answerList = $this->getAnswersList(true);
257
+        $this->answerList = $this->getAnswersList(true);
258 258
         $out =  '  <responseDeclaration identifier="' . $questionIdent . '" cardinality="single" baseType="identifier">' . "\n";
259 259
         $out .= '    <correctResponse>' . "\n";
260 260
 
261 261
         $gradeArray = array();
262
-		if (is_array($this->leftList)) {
263
-	        foreach ($this->leftList as $leftKey=>$leftElement) {
264
-	            $i=0;
265
-	            foreach ($this->rightList as $rightKey=>$rightElement) {
266
-	                if (($leftElement['match'] == $rightElement['code'])) {
267
-	                    $out .= '      <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n";
268
-
269
-	                    $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade'];
270
-	                }
271
-	                $i++;
272
-	            }
273
-	        }
274
-		}
262
+        if (is_array($this->leftList)) {
263
+            foreach ($this->leftList as $leftKey=>$leftElement) {
264
+                $i=0;
265
+                foreach ($this->rightList as $rightKey=>$rightElement) {
266
+                    if (($leftElement['match'] == $rightElement['code'])) {
267
+                        $out .= '      <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n";
268
+
269
+                        $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade'];
270
+                    }
271
+                    $i++;
272
+                }
273
+            }
274
+        }
275 275
         $out .= '    </correctResponse>'. "\n";
276 276
         $out .= '    <mapping>' . "\n";
277 277
         if (is_array($gradeArray)) {
278
-	        foreach ($gradeArray as $gradeKey=>$grade) {
279
-	            $out .= '          <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n";
280
-	        }
278
+            foreach ($gradeArray as $gradeKey=>$grade) {
279
+                $out .= '          <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n";
280
+            }
281 281
         }
282 282
         $out .= '    </mapping>' . "\n";
283 283
         $out .= '  </responseDeclaration>'. "\n";
@@ -298,49 +298,49 @@  discard block
 block discarded – undo
298 298
      */
299 299
     public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='')
300 300
     {
301
-		$this->answerList = $this->getAnswersList(true);
302
-		$questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia;
303
-		$mimetype = mime_content_type($questionMedia);
304
-		if(empty($mimetype)){
305
-			$mimetype = 'image/jpeg';
306
-		}
307
-
308
-		$text = '      <p>'.$questionStatment.'</p>'."\n";
309
-		$text .= '      <graphicOrderInteraction responseIdentifier="hotspot_'.$questionIdent.'">'."\n";
310
-		$text .= '        <prompt>'.$questionDesc.'</prompt>'."\n";
311
-		$text .= '        <object type="'.$mimetype.'" width="250" height="230" data="'.$questionMedia.'">-</object>'."\n";
301
+        $this->answerList = $this->getAnswersList(true);
302
+        $questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia;
303
+        $mimetype = mime_content_type($questionMedia);
304
+        if(empty($mimetype)){
305
+            $mimetype = 'image/jpeg';
306
+        }
307
+
308
+        $text = '      <p>'.$questionStatment.'</p>'."\n";
309
+        $text .= '      <graphicOrderInteraction responseIdentifier="hotspot_'.$questionIdent.'">'."\n";
310
+        $text .= '        <prompt>'.$questionDesc.'</prompt>'."\n";
311
+        $text .= '        <object type="'.$mimetype.'" width="250" height="230" data="'.$questionMedia.'">-</object>'."\n";
312 312
         if (is_array($this->answerList)) {
313
-	        foreach ($this->answerList as $key=>$answer) {
314
-	        	$key = $answer['id'];
315
-	        	$answerTxt = $answer['answer'];
316
-	        	$len = api_strlen($answerTxt);
317
-	        	//coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663
318
-	        	$coords = '';
319
-	        	$type = 'default';
320
-	        	switch($answer['hotspot_type']){
321
-	        		case 'square':
322
-	        			$type = 'rect';
323
-						$res = array();
324
-						$coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res);
325
-						$coords = $res[1].','.$res[2].','.((int)$res[1]+(int)$res[3]).",".((int)$res[2]+(int)$res[4]);
326
-	        			break;
327
-	        		case 'circle':
328
-	        			$type = 'circle';
329
-			 			$res = array();
330
-						$coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res);
331
-						$coords = $res[1].','.$res[2].','.sqrt(pow(($res[1]-$res[3]),2)+pow(($res[2]-$res[4])));
332
-	        			break;
333
-	        		case 'poly':
334
-	        			$type = 'poly';
335
-						$coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']);
336
-	        			break;
337
-	        		 case 'delineation' :
338
-	        			$type = 'delineation';
339
-						$coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']);
340
-	        			break;
341
-	        	}
342
-	            $text .= '        <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n";
343
-	        }
313
+            foreach ($this->answerList as $key=>$answer) {
314
+                $key = $answer['id'];
315
+                $answerTxt = $answer['answer'];
316
+                $len = api_strlen($answerTxt);
317
+                //coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663
318
+                $coords = '';
319
+                $type = 'default';
320
+                switch($answer['hotspot_type']){
321
+                    case 'square':
322
+                        $type = 'rect';
323
+                        $res = array();
324
+                        $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res);
325
+                        $coords = $res[1].','.$res[2].','.((int)$res[1]+(int)$res[3]).",".((int)$res[2]+(int)$res[4]);
326
+                        break;
327
+                    case 'circle':
328
+                        $type = 'circle';
329
+                            $res = array();
330
+                        $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res);
331
+                        $coords = $res[1].','.$res[2].','.sqrt(pow(($res[1]-$res[3]),2)+pow(($res[2]-$res[4])));
332
+                        break;
333
+                    case 'poly':
334
+                        $type = 'poly';
335
+                        $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']);
336
+                        break;
337
+                        case 'delineation' :
338
+                        $type = 'delineation';
339
+                        $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']);
340
+                        break;
341
+                }
342
+                $text .= '        <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n";
343
+            }
344 344
         }
345 345
         $text .= '      </graphicOrderInteraction>'."\n";
346 346
         $out = $text;
@@ -353,23 +353,23 @@  discard block
 block discarded – undo
353 353
      */
354 354
     public function imsExportResponsesDeclaration($questionIdent)
355 355
     {
356
-		$this->answerList = $this->getAnswersList(true);
357
-		$this->gradeList = $this->getGradesList();
356
+        $this->answerList = $this->getAnswersList(true);
357
+        $this->gradeList = $this->getGradesList();
358 358
         $out = '';
359 359
         $out .= '  <responseDeclaration identifier="hotspot_'.$questionIdent.'" cardinality="ordered" baseType="identifier">' . "\n";
360 360
         $out .= '    <correctResponse>'. "\n";
361 361
 
362
-		if (is_array($this->answerList)) {
363
-	        foreach ($this->answerList as $answerKey=>$answer)  {
364
-	        	$answerKey = $answer['id'];
365
-	        	$answer = $answer['answer'];
366
-	            $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>';
367
-	        }
368
-		}
362
+        if (is_array($this->answerList)) {
363
+            foreach ($this->answerList as $answerKey=>$answer)  {
364
+                $answerKey = $answer['id'];
365
+                $answer = $answer['answer'];
366
+                $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>';
367
+            }
368
+        }
369 369
         $out .= '    </correctResponse>'. "\n";
370 370
         $out .= '  </responseDeclaration>'. "\n";
371 371
 
372
-       return $out;
372
+        return $out;
373 373
     }
374 374
 }
375 375
 
@@ -384,14 +384,14 @@  discard block
 block discarded – undo
384 384
      * Export the question part as a matrix-choice, with only one possible answer per line.
385 385
      */
386 386
     public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='')
387
-	{
388
-		return '';
389
-	}
387
+    {
388
+        return '';
389
+    }
390 390
     /**
391 391
      *
392 392
      */
393 393
     public function imsExportResponsesDeclaration($questionIdent)
394 394
     {
395
-    	return '';
395
+        return '';
396 396
     }
397 397
 }
Please login to merge, or discard this patch.
main/exercice/export/aiken/aiken_import.inc.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 /**
4
- * Library for the import of Aiken format
5
- * @author claro team <[email protected]>
6
- * @author Guillaume Lederer <[email protected]>
7
- * @author César Perales <[email protected]> Parse function for Aiken format
8
- * @package chamilo.exercise
9
- */
4
+     * Library for the import of Aiken format
5
+     * @author claro team <[email protected]>
6
+     * @author Guillaume Lederer <[email protected]>
7
+     * @author César Perales <[email protected]> Parse function for Aiken format
8
+     * @package chamilo.exercise
9
+     */
10 10
 /**
11
- * Security check
12
- */
11
+     * Security check
12
+     */
13 13
 if (count(get_included_files()) == 1)
14 14
     die('---');
15 15
 
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
     }
79 79
 }
80 80
 /**
81
- * Main function to import the Aiken exercise
82
- * @return mixed True on success, error message on failure
83
- */
81
+     * Main function to import the Aiken exercise
82
+     * @return mixed True on success, error message on failure
83
+     */
84 84
 function aiken_import_exercise($file)
85 85
 {
86 86
     global $exercise_info;
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
             $correct_answer_index = array_search($matches[1], $answers_array);
282 282
             $exercise_info['question'][$question_index]['title'] = $matches[1];
283 283
         } elseif (preg_match('/^TAGS:\s?([A-Z])\s?/', $info, $matches)) {
284
-             //TAGS for chamilo >= 1.10
284
+                //TAGS for chamilo >= 1.10
285 285
             $exercise_info['question'][$question_index]['answer_tags'] = explode(',', $matches[1]);
286 286
         } elseif (preg_match('/^ETIQUETAS:\s?([A-Z])\s?/', $info, $matches)) {
287 287
             //TAGS for chamilo >= 1.10 (Spanish e-ducativa format)
Please login to merge, or discard this patch.
main/exercice/export/aiken/aiken_classes.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 /**
4
- * @author Claro Team <[email protected]>
5
- * @author Yannick Warnier <[email protected]> - updated ImsAnswerHotspot to match QTI norms
6
- * @author César Perales <[email protected]> Updated function names and import files for Aiken format support
7
- * @package chamilo.exercise
8
- */
4
+     * @author Claro Team <[email protected]>
5
+     * @author Yannick Warnier <[email protected]> - updated ImsAnswerHotspot to match QTI norms
6
+     * @author César Perales <[email protected]> Updated function names and import files for Aiken format support
7
+     * @package chamilo.exercise
8
+     */
9 9
 
10 10
 if ( count( get_included_files() ) == 1 ) die( '---' );
11 11
 
12 12
 if (!function_exists('mime_content_type')) {
13
-	function mime_content_type($filename) {
14
-		return DocumentManager::file_get_mime_type((string)$filename);
15
-	}
13
+    function mime_content_type($filename) {
14
+        return DocumentManager::file_get_mime_type((string)$filename);
15
+    }
16 16
 }
17 17
 
18 18
 /**
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         {
30 30
             case MCUA :
31 31
                 $answer = new AikenAnswerMultipleChoice($this->id);
32
-            	return $answer;
32
+                return $answer;
33 33
             default :
34 34
                 $answer = null;
35 35
                 break;
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
     }
39 39
     function createAnswersForm($form)
40 40
     {
41
-    	return true;
41
+        return true;
42 42
     }
43 43
     function processAnswersCreation($form)
44 44
     {
45
-    	return true;
45
+        return true;
46 46
     }
47 47
 }
48 48
 
Please login to merge, or discard this patch.
main/exercice/export/scorm/scorm_classes.php 1 patch
Indentation   +424 added lines, -424 removed lines patch added patch discarded remove patch
@@ -49,86 +49,86 @@  discard block
 block discarded – undo
49 49
     }
50 50
 
51 51
     /**
52
-	 * Include the correct answer class and create answer
53
-	 */
54
-	public function setAnswer()
55
-	{
56
-		switch ($this->type) {
57
-			case MCUA:
58
-				$this->answer = new ScormAnswerMultipleChoice($this->id);
52
+     * Include the correct answer class and create answer
53
+     */
54
+    public function setAnswer()
55
+    {
56
+        switch ($this->type) {
57
+            case MCUA:
58
+                $this->answer = new ScormAnswerMultipleChoice($this->id);
59 59
                 $this->answer->questionJSId = $this->js_id;
60
-				break;
61
-			case MCMA:
60
+                break;
61
+            case MCMA:
62 62
             case GLOBAL_MULTIPLE_ANSWER:
63
-				$this->answer = new ScormAnswerMultipleChoice($this->id);
63
+                $this->answer = new ScormAnswerMultipleChoice($this->id);
64 64
                 $this->answer->questionJSId = $this->js_id;
65
-				break;
66
-			case TF:
67
-				$this->answer = new ScormAnswerTrueFalse($this->id);
65
+                break;
66
+            case TF:
67
+                $this->answer = new ScormAnswerTrueFalse($this->id);
68 68
                 $this->answer->questionJSId = $this->js_id;
69
-				break;
70
-			case FIB:
71
-				$this->answer = new ScormAnswerFillInBlanks($this->id);
69
+                break;
70
+            case FIB:
71
+                $this->answer = new ScormAnswerFillInBlanks($this->id);
72 72
                 $this->answer->questionJSId = $this->js_id;
73
-				break;
74
-			case MATCHING:
73
+                break;
74
+            case MATCHING:
75 75
             case MATCHING_DRAGGABLE:
76
-				$this->answer = new ScormAnswerMatching($this->id);
76
+                $this->answer = new ScormAnswerMatching($this->id);
77 77
                 $this->answer->questionJSId = $this->js_id;
78
-				break;
78
+                break;
79 79
             case ORAL_EXPRESSION:
80
-			case FREE_ANSWER:
81
-				$this->answer = new ScormAnswerFree($this->id);
80
+            case FREE_ANSWER:
81
+                $this->answer = new ScormAnswerFree($this->id);
82 82
                 $this->answer->questionJSId = $this->js_id;
83
-				break;
84
-			case HOT_SPOT:
85
-				$this->answer = new ScormAnswerHotspot($this->id);
83
+                break;
84
+            case HOT_SPOT:
85
+                $this->answer = new ScormAnswerHotspot($this->id);
86 86
                 $this->answer->questionJSId = $this->js_id;
87
-				break;
88
-			case MULTIPLE_ANSWER_COMBINATION:
89
-				$this->answer = new ScormAnswerMultipleChoice($this->id);
87
+                break;
88
+            case MULTIPLE_ANSWER_COMBINATION:
89
+                $this->answer = new ScormAnswerMultipleChoice($this->id);
90 90
                 $this->answer->questionJSId = $this->js_id;
91
-				break;
91
+                break;
92 92
             case HOT_SPOT_ORDER:
93
-				$this->answer = new ScormAnswerHotspot($this->id);
93
+                $this->answer = new ScormAnswerHotspot($this->id);
94 94
                 $this->answer->questionJSId = $this->js_id;
95
-				break;
96
-			case HOT_SPOT_DELINEATION:
97
-				$this->answer = new ScormAnswerHotspot($this->id);
95
+                break;
96
+            case HOT_SPOT_DELINEATION:
97
+                $this->answer = new ScormAnswerHotspot($this->id);
98 98
                 $this->answer->questionJSId = $this->js_id;
99
-				break;
100
-			default :
101
-				$this->answer = null;
99
+                break;
100
+            default :
101
+                $this->answer = null;
102 102
                 $this->answer->questionJSId = $this->js_id;
103
-				break;
104
-		}
103
+                break;
104
+        }
105 105
 
106
-		return true;
107
-	}
106
+        return true;
107
+    }
108 108
 
109
-	function export()
110
-	{
111
-		$html = $this->getQuestionHTML();
112
-		$js   = $this->getQuestionJS();
109
+    function export()
110
+    {
111
+        $html = $this->getQuestionHTML();
112
+        $js   = $this->getQuestionJS();
113 113
 
114
-		if( is_object($this->answer) )
115
-		{
116
-			list($js2,$html2) = $this->answer->export();
117
-			$js .= $js2;
118
-			$html .= $html2;
119
-		}
114
+        if( is_object($this->answer) )
115
+        {
116
+            list($js2,$html2) = $this->answer->export();
117
+            $js .= $js2;
118
+            $html .= $html2;
119
+        }
120 120
 
121
-		return array($js,$html);
122
-	}
121
+        return array($js,$html);
122
+    }
123 123
 
124 124
     function createAnswersForm($form)
125 125
     {
126
-    	return true;
126
+        return true;
127 127
     }
128 128
 
129 129
     function processAnswersCreation($form)
130 130
     {
131
-    	return true;
131
+        return true;
132 132
     }
133 133
 
134 134
     /**
@@ -136,20 +136,20 @@  discard block
 block discarded – undo
136 136
      */
137 137
     function getQuestionHTML()
138 138
     {
139
-    	$title			= $this->selectTitle();
140
-		$description	= $this->selectDescription();
141
-		$cols = 2;
142
-		$s='<tr>' .
143
-			'<td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;">' . "\n" .
144
-		   	$title.
145
-		   	'</td>' . "\n" .
146
-		   	'</tr>' . "\n" .
147
-		   	'<tr>' . "\n" .
148
-		   	'<td valign="top" colspan="'.$cols.'">' . "\n" .
149
-		   	'<i>'.$description.'</i>' . "\n" .
150
-		   	'</td>' . "\n" .
151
-		   	'</tr>' . "\n";
152
-		return $s;
139
+        $title			= $this->selectTitle();
140
+        $description	= $this->selectDescription();
141
+        $cols = 2;
142
+        $s='<tr>' .
143
+            '<td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;">' . "\n" .
144
+                $title.
145
+                '</td>' . "\n" .
146
+                '</tr>' . "\n" .
147
+                '<tr>' . "\n" .
148
+                '<td valign="top" colspan="'.$cols.'">' . "\n" .
149
+                '<i>'.$description.'</i>' . "\n" .
150
+                '</td>' . "\n" .
151
+                '</tr>' . "\n";
152
+        return $s;
153 153
     }
154 154
 
155 155
     /**
@@ -157,16 +157,16 @@  discard block
 block discarded – undo
157 157
      */
158 158
     function getQuestionJS()
159 159
     {
160
-    	//$id = $this->id;
161
-    	$w = $this->selectWeighting();
162
-    	$s = 'questions.push('.$this->js_id.');'."\n";
163
-    	if($this->type == FREE_ANSWER or $this->type == HOT_SPOT)
164
-    	{ //put the max score to 0 to avoid discounting the points of
165
-    	  //non-exported quiz types in the SCORM
166
-    		$w=0;
167
-    	}
168
-    	$s .= 'questions_score_max['.$this->js_id.'] = '.$w.";\n";
169
-    	return $s;
160
+        //$id = $this->id;
161
+        $w = $this->selectWeighting();
162
+        $s = 'questions.push('.$this->js_id.');'."\n";
163
+        if($this->type == FREE_ANSWER or $this->type == HOT_SPOT)
164
+        { //put the max score to 0 to avoid discounting the points of
165
+            //non-exported quiz types in the SCORM
166
+            $w=0;
167
+        }
168
+        $s .= 'questions_score_max['.$this->js_id.'] = '.$w.";\n";
169
+        return $s;
170 170
     }
171 171
 }
172 172
 
@@ -177,107 +177,107 @@  discard block
 block discarded – undo
177 177
  */
178 178
 class ScormAnswerMultipleChoice extends Answer
179 179
 {
180
-	/**
181
-	 * Return HTML code for possible answers
180
+    /**
181
+     * Return HTML code for possible answers
182 182
      */
183
-	function export()
184
-	{
185
-		$html = '';
186
-    	$js   = '';
187
-    	$html = '<tr><td colspan="2"><table width="100%">' . "\n";
188
-		$type = $this->getQuestionType();
189
-		$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
190
-		$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
191
-
192
-		//not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM
183
+    function export()
184
+    {
185
+        $html = '';
186
+        $js   = '';
187
+        $html = '<tr><td colspan="2"><table width="100%">' . "\n";
188
+        $type = $this->getQuestionType();
189
+        $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
190
+        $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
191
+
192
+        //not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM
193 193
         //if ($type == MCMA  || $type == MULTIPLE_ANSWER_COMBINATION ) {
194
-		if ($type == MCMA ) {
195
-        	//$questionTypeLang = get_lang('MultipleChoiceMultipleAnswers');
196
-        	$id = 1;
197
-        	$jstmp = '';
198
-        	$jstmpc = '';
199
-			foreach( $this->answer as $i => $answer )
200
-			{
201
-				$identifier = 'question_'.$this->questionJSId.'_multiple_'.$i;
202
-				$html .=
203
-		    		'<tr>' . "\n"
204
-				.	'<td align="center" width="5%">' . "\n"
205
-		    	.	'<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />' . "\n"
206
-		    	.	'</td>' . "\n"
207
-		    	.	'<td width="95%">' . "\n"
208
-		    	.	'<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n"
209
-		    	.	'</td>' . "\n"
210
-		    	.	'</tr>' . "\n\n";
211
-		    	$jstmp .= $i.',';
212
-		    	if($this->correct[$i])
213
-		    	{
214
-		    		$jstmpc .= $i.',';
215
-		    	}
216
-		    	$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n";
217
-		    	$id++;
218
-			}
219
-			$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n";
220
-	    	$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n";
221
-	    	if ($type == MCMA) {
222
-	    		$js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n";
223
-	    	} else {
224
-	    		$js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n";
225
-	    	}
226
-	    	$js .= $jstmpw;
194
+        if ($type == MCMA ) {
195
+            //$questionTypeLang = get_lang('MultipleChoiceMultipleAnswers');
196
+            $id = 1;
197
+            $jstmp = '';
198
+            $jstmpc = '';
199
+            foreach( $this->answer as $i => $answer )
200
+            {
201
+                $identifier = 'question_'.$this->questionJSId.'_multiple_'.$i;
202
+                $html .=
203
+                    '<tr>' . "\n"
204
+                .	'<td align="center" width="5%">' . "\n"
205
+                .	'<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />' . "\n"
206
+                .	'</td>' . "\n"
207
+                .	'<td width="95%">' . "\n"
208
+                .	'<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n"
209
+                .	'</td>' . "\n"
210
+                .	'</tr>' . "\n\n";
211
+                $jstmp .= $i.',';
212
+                if($this->correct[$i])
213
+                {
214
+                    $jstmpc .= $i.',';
215
+                }
216
+                $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n";
217
+                $id++;
218
+            }
219
+            $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n";
220
+            $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n";
221
+            if ($type == MCMA) {
222
+                $js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n";
223
+            } else {
224
+                $js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n";
225
+            }
226
+            $js .= $jstmpw;
227 227
         } elseif ($type == MULTIPLE_ANSWER_COMBINATION) {
228
-        		//To this items we show the ThisItemIsNotExportable
229
-        	    $qId = $this->questionJSId;
230
-		    	$js = '';
231
-		    	$html = '<tr><td colspan="2"><table width="100%">' . "\n";
232
-				// some javascript must be added for that kind of questions
233
-				$html .= '<tr>' . "\n"
234
-						.	'<td>' . "\n"
235
-				    	. '<textarea name="question_'.$qId.'_free" id="question_'.$qId.'_exact" rows="20" cols="100"></textarea>' . "\n"
236
-				    	.	'</td>' . "\n"
237
-				    	.	'</tr>' . "\n";
238
-				$html .= '</table></td></tr>' . "\n";
239
-				// currently the exact answers cannot be displayed, so ignore the textarea
240
-				$html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>';
241
-				$js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n";
242
-		    	$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n";
243
-		    	$js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n";
244
-				$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
245
-				$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
246
-		    	$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n";
247
-		    	$js .= $jstmpw;
248
-		        return array($js,$html);
228
+                //To this items we show the ThisItemIsNotExportable
229
+                $qId = $this->questionJSId;
230
+                $js = '';
231
+                $html = '<tr><td colspan="2"><table width="100%">' . "\n";
232
+                // some javascript must be added for that kind of questions
233
+                $html .= '<tr>' . "\n"
234
+                        .	'<td>' . "\n"
235
+                        . '<textarea name="question_'.$qId.'_free" id="question_'.$qId.'_exact" rows="20" cols="100"></textarea>' . "\n"
236
+                        .	'</td>' . "\n"
237
+                        .	'</tr>' . "\n";
238
+                $html .= '</table></td></tr>' . "\n";
239
+                // currently the exact answers cannot be displayed, so ignore the textarea
240
+                $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>';
241
+                $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n";
242
+                $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n";
243
+                $js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n";
244
+                $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
245
+                $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
246
+                $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n";
247
+                $js .= $jstmpw;
248
+                return array($js,$html);
249 249
         } else {
250
-        	//$questionTypeLang = get_lang('MultipleChoiceUniqueAnswer');
251
-        	$id = 1;
252
-        	$jstmp = '';
253
-        	$jstmpc = '';
254
-			foreach( $this->answer as $i => $answer )
255
-			{
256
-	        	$identifier = 'question_'.$this->questionJSId.'_unique_'.$i;
257
-	        	$identifier_name = 'question_'.$this->questionJSId.'_unique_answer';
258
-				$html .=
259
-		    		'<tr>' . "\n"
260
-				.	'<td align="center" width="5%">' . "\n"
261
-		    	.	'<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="radio"/>' . "\n"
262
-		    	.	'</td>' . "\n"
263
-		    	.	'<td width="95%">' . "\n"
264
-		    	.	'<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n"
265
-		    	.	'</td>' . "\n"
266
-		    	.	'</tr>' . "\n\n";
267
-		    	$jstmp .= $i.',';
268
-		    	if($this->correct[$i])
269
-		    	{
270
-		    		$jstmpc .= $i;
271
-		    	}
272
-		    	$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n";
273
-		    	$id++;
274
-			}
275
-			$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n";
276
-	    	$js .= 'questions_answers_correct['.$this->questionJSId.'] = '.$jstmpc.';'."\n";
277
-	    	$js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';'."\n";
278
-			$js .= $jstmpw;
250
+            //$questionTypeLang = get_lang('MultipleChoiceUniqueAnswer');
251
+            $id = 1;
252
+            $jstmp = '';
253
+            $jstmpc = '';
254
+            foreach( $this->answer as $i => $answer )
255
+            {
256
+                $identifier = 'question_'.$this->questionJSId.'_unique_'.$i;
257
+                $identifier_name = 'question_'.$this->questionJSId.'_unique_answer';
258
+                $html .=
259
+                    '<tr>' . "\n"
260
+                .	'<td align="center" width="5%">' . "\n"
261
+                .	'<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="radio"/>' . "\n"
262
+                .	'</td>' . "\n"
263
+                .	'<td width="95%">' . "\n"
264
+                .	'<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n"
265
+                .	'</td>' . "\n"
266
+                .	'</tr>' . "\n\n";
267
+                $jstmp .= $i.',';
268
+                if($this->correct[$i])
269
+                {
270
+                    $jstmpc .= $i;
271
+                }
272
+                $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n";
273
+                $id++;
274
+            }
275
+            $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n";
276
+            $js .= 'questions_answers_correct['.$this->questionJSId.'] = '.$jstmpc.';'."\n";
277
+            $js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';'."\n";
278
+            $js .= $jstmpw;
279 279
         }
280
-		$html .= '</table></td></tr>' . "\n";
280
+        $html .= '</table></td></tr>' . "\n";
281 281
         return array($js,$html);
282 282
     }
283 283
 }
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
  */
289 289
 class ScormAnswerTrueFalse extends Answer
290 290
 {
291
-	/**
291
+    /**
292 292
      * Return the XML flow for the possible answers.
293 293
      * That's one <response_lid>, containing several <flow_label>
294 294
      *
@@ -296,46 +296,46 @@  discard block
 block discarded – undo
296 296
      */
297 297
     function export()
298 298
     {
299
-    	$js = '';
300
-    	$html = '<tr><td colspan="2"><table width="100%">';
301
-		$identifier = 'question_'.$this->questionJSId.'_tf';
302
-		$identifier_true  = $identifier.'_true';
303
-		$identifier_false = $identifier.'_false';
304
-		$html .=
305
-    		'<tr>' . "\n"
306
-		.	'<td align="center" width="5%">' . "\n"
307
-    	.	'<input name="'.$identifier_true.'" id="'.$identifier_true.'" value="'.$this->trueGrade.'" type="radio" '
308
-		.		'/>' . "\n"
309
-    	.	'</td>' . "\n"
310
-    	.	'<td width="95%">' . "\n"
311
-    	.	'<label for="'.$identifier_true.'">' . get_lang('True') . '</label>' . "\n"
312
-    	.	'</td>' . "\n"
313
-    	.	'</tr>' . "\n\n";
314
-    	$html .=
315
-			'<tr>' . "\n"
316
-		.	'<td align="center" width="5%">' . "\n"
317
-		.	'<input name="'.$identifier_false.'" id="'.$identifier_false.'" value="'.$this->falseGrade.'" type="radio" '
318
-		.		'/>' . "\n"
319
-		.	'</td>' . "\n"
320
-		.	'<td width="95%">' . "\n"
321
-		.	'<label for="'.$identifier_false.'">' . get_lang('False') . '</label>' . "\n"
322
-		.	'</td>' . "\n"
323
-		.	'</tr>' . "\n\n";
324
-		$html .= '</table></td></tr>' . "\n";
325
-		$js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n";
326
-    	$js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n";
327
-		if($this->response == 'TRUE')
328
-		{
329
-	    	$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n";
330
-		}
331
-		else
332
-		{
333
-	    	$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n";
334
-		}
335
-		$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
336
-		$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
337
-    	$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n";
338
-    	$js .= $jstmpw;
299
+        $js = '';
300
+        $html = '<tr><td colspan="2"><table width="100%">';
301
+        $identifier = 'question_'.$this->questionJSId.'_tf';
302
+        $identifier_true  = $identifier.'_true';
303
+        $identifier_false = $identifier.'_false';
304
+        $html .=
305
+            '<tr>' . "\n"
306
+        .	'<td align="center" width="5%">' . "\n"
307
+        .	'<input name="'.$identifier_true.'" id="'.$identifier_true.'" value="'.$this->trueGrade.'" type="radio" '
308
+        .		'/>' . "\n"
309
+        .	'</td>' . "\n"
310
+        .	'<td width="95%">' . "\n"
311
+        .	'<label for="'.$identifier_true.'">' . get_lang('True') . '</label>' . "\n"
312
+        .	'</td>' . "\n"
313
+        .	'</tr>' . "\n\n";
314
+        $html .=
315
+            '<tr>' . "\n"
316
+        .	'<td align="center" width="5%">' . "\n"
317
+        .	'<input name="'.$identifier_false.'" id="'.$identifier_false.'" value="'.$this->falseGrade.'" type="radio" '
318
+        .		'/>' . "\n"
319
+        .	'</td>' . "\n"
320
+        .	'<td width="95%">' . "\n"
321
+        .	'<label for="'.$identifier_false.'">' . get_lang('False') . '</label>' . "\n"
322
+        .	'</td>' . "\n"
323
+        .	'</tr>' . "\n\n";
324
+        $html .= '</table></td></tr>' . "\n";
325
+        $js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n";
326
+        $js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n";
327
+        if($this->response == 'TRUE')
328
+        {
329
+            $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n";
330
+        }
331
+        else
332
+        {
333
+            $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n";
334
+        }
335
+        $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
336
+        $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
337
+        $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n";
338
+        $js .= $jstmpw;
339 339
 
340 340
         return array($js,$html);
341 341
     }
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
  */
348 348
 class ScormAnswerFillInBlanks extends Answer
349 349
 {
350
-	/**
350
+    /**
351 351
      * Export the text with missing words.
352 352
      *
353 353
      * As a side effect, it stores two lists in the class :
@@ -355,57 +355,57 @@  discard block
 block discarded – undo
355 355
      */
356 356
     function export()
357 357
     {
358
-    	global $charset;
359
-    	$js = '';
360
-    	$html = '<tr><td colspan="2"><table width="100%">' . "\n";
361
-		// get all enclosed answers
362
-		$blankList = array();
363
-		// build replacement
364
-		$replacementList = array();
365
-		foreach( $this->answer as $i => $answer) {
366
-			$blankList[] = '['.$answer.']';
367
-		}
368
-		$answerCount = count($blankList);
369
-
370
-		// splits text and weightings that are joined with the character '::'
371
-		list($answer,$weight)=explode('::',$answer);
372
-		$weights = explode(',',$weight);
373
-		// because [] is parsed here we follow this procedure:
374
-		// 1. find everything between the [ and ] tags
375
-		$i=1;
376
-		$jstmp = '';
377
-		$jstmpc = '';
378
-		$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
379
-		$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
380
-		$startlocations=api_strpos($answer,'[');
381
-		$endlocations=api_strpos($answer,']');
382
-		while($startlocations !== false && $endlocations !== false) {
383
-			$texstring=api_substr($answer,$startlocations,($endlocations-$startlocations)+1);
384
-			$answer = api_substr_replace($answer,'<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />',$startlocations,($endlocations-$startlocations)+1);
385
-			$jstmp .= $i.',';
386
-			$jstmpc .= "'".api_htmlentities(api_substr($texstring,1,-1),ENT_QUOTES,$charset)."',";
387
-				$my_weight=explode('@',$weights[$i-1]);
388
-				if (count($my_weight)==2) {
389
-					$weight_db=$my_weight[0];
390
-				} else {
391
-					$weight_db=$my_weight[0];
392
-				}
393
-	    	$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n";
394
-			$i++;
395
-			$startlocations=api_strpos($answer,'[');
396
-			$endlocations=api_strpos($answer,']');
397
-		}
358
+        global $charset;
359
+        $js = '';
360
+        $html = '<tr><td colspan="2"><table width="100%">' . "\n";
361
+        // get all enclosed answers
362
+        $blankList = array();
363
+        // build replacement
364
+        $replacementList = array();
365
+        foreach( $this->answer as $i => $answer) {
366
+            $blankList[] = '['.$answer.']';
367
+        }
368
+        $answerCount = count($blankList);
369
+
370
+        // splits text and weightings that are joined with the character '::'
371
+        list($answer,$weight)=explode('::',$answer);
372
+        $weights = explode(',',$weight);
373
+        // because [] is parsed here we follow this procedure:
374
+        // 1. find everything between the [ and ] tags
375
+        $i=1;
376
+        $jstmp = '';
377
+        $jstmpc = '';
378
+        $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
379
+        $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
380
+        $startlocations=api_strpos($answer,'[');
381
+        $endlocations=api_strpos($answer,']');
382
+        while($startlocations !== false && $endlocations !== false) {
383
+            $texstring=api_substr($answer,$startlocations,($endlocations-$startlocations)+1);
384
+            $answer = api_substr_replace($answer,'<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />',$startlocations,($endlocations-$startlocations)+1);
385
+            $jstmp .= $i.',';
386
+            $jstmpc .= "'".api_htmlentities(api_substr($texstring,1,-1),ENT_QUOTES,$charset)."',";
387
+                $my_weight=explode('@',$weights[$i-1]);
388
+                if (count($my_weight)==2) {
389
+                    $weight_db=$my_weight[0];
390
+                } else {
391
+                    $weight_db=$my_weight[0];
392
+                }
393
+            $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n";
394
+            $i++;
395
+            $startlocations=api_strpos($answer,'[');
396
+            $endlocations=api_strpos($answer,']');
397
+        }
398 398
 
399
-		$html .= 	'<tr>' . "\n"
400
-				.	'<td>' . "\n"
401
-		    	.	$answer  . "\n"
402
-	    		.	'</td>' . "\n"
403
-	    		.	'</tr>' . "\n";
404
-		$html .= '</table></td></tr>' . "\n";
405
-		$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n";
406
-    	$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n";
407
-    	$js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n";
408
-    	$js .= $jstmpw;
399
+        $html .= 	'<tr>' . "\n"
400
+                .	'<td>' . "\n"
401
+                .	$answer  . "\n"
402
+                .	'</td>' . "\n"
403
+                .	'</tr>' . "\n";
404
+        $html .= '</table></td></tr>' . "\n";
405
+        $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n";
406
+        $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n";
407
+        $js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n";
408
+        $js .= $jstmpw;
409 409
         return array($js,$html);
410 410
     }
411 411
 }
@@ -416,101 +416,101 @@  discard block
 block discarded – undo
416 416
  */
417 417
 class ScormAnswerMatching extends Answer
418 418
 {
419
-	/**
419
+    /**
420 420
      * Export the question part as a matrix-choice, with only one possible answer per line.
421 421
      * @author Amand Tihon <[email protected]>
422 422
      */
423 423
     function export()
424 424
     {
425
-    	$js = '';
426
-    	$html = '<tr><td colspan="2"><table width="100%">' . "\n";
427
-  		// prepare list of right proposition to allow
428
-		// - easiest display
429
-		// - easiest randomisation if needed one day
430
-		// (here I use array_values to change array keys from $code1 $code2 ... to 0 1 ...)
431
-		if (is_array($this->rightList)) {
432
-			$displayedRightList = array_values($this->rightList);
433
-		}
434
-		// get max length of displayed array
435
-		$arrayLength = max( count($this->leftList), count($this->rightList) );
436
-
437
-		$nbrAnswers=$this->selectNbrAnswers();
438
-		$cpt1='A';
439
-		$cpt2=1;
440
-		$Select=array();
441
-		$qId = $this->questionJSId;
442
-		$s = '';
443
-		$jstmp = '';
444
-		$jstmpc = '';
425
+        $js = '';
426
+        $html = '<tr><td colspan="2"><table width="100%">' . "\n";
427
+            // prepare list of right proposition to allow
428
+        // - easiest display
429
+        // - easiest randomisation if needed one day
430
+        // (here I use array_values to change array keys from $code1 $code2 ... to 0 1 ...)
431
+        if (is_array($this->rightList)) {
432
+            $displayedRightList = array_values($this->rightList);
433
+        }
434
+        // get max length of displayed array
435
+        $arrayLength = max( count($this->leftList), count($this->rightList) );
436
+
437
+        $nbrAnswers=$this->selectNbrAnswers();
438
+        $cpt1='A';
439
+        $cpt2=1;
440
+        $Select=array();
441
+        $qId = $this->questionJSId;
442
+        $s = '';
443
+        $jstmp = '';
444
+        $jstmpc = '';
445 445
         $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
446 446
         $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
447 447
 
448
-		for($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
449
-			$identifier = 'question_'.$qId.'_matching_';
450
-			$answer=$this->selectAnswer($answerId);
451
-			$answerCorrect=$this->isCorrect($answerId);
452
-			$weight=$this->selectWeighting($answerId);
453
-			$jstmp .= $answerId.',';
454
-
455
-			if (!$answerCorrect) {
456
-				// options (A, B, C, ...) that will be put into the list-box
457
-				$Select[$answerId]['Lettre']=$cpt1;
458
-				// answers that will be shown at the right side
459
-				$Select[$answerId]['Reponse'] = $answer;
460
-				$cpt1++;
461
-			} else {
462
-				$s.='<tr>'."\n";
463
-				$s.='<td width="40%" valign="top">'."\n".'<b>'.$cpt2.'</b>.&nbsp;'.$answer."\n</td>\n";
464
-				$s.='<td width="20%" align="center">&nbsp;&nbsp;<select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">';
465
-				$s.=' <option value="0">--</option>';
466
-	            // fills the list-box
467
-	            foreach($Select as $key=>$val)
468
-	            {
469
-					$s.='<option value="'.$key.'">'.$val['Lettre'].'</option>';
470
-				}  // end foreach()
471
-
472
-				$s.='</select>&nbsp;&nbsp;</td>'."\n";
473
-				$s.='<td width="40%" valign="top">';
474
-				if(isset($Select[$cpt2])) $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse'];
475
-					else $s.='&nbsp;';
476
-				$s.="</td>\n</tr>\n";
477
-
478
-				$jstmpc .= '['.$answerCorrect.','.$cpt2.'],';
479
-
480
-				$my_weight=explode('@',$weight);
481
-				if (count($my_weight)==2) {
482
-					$weight=$my_weight[0];
483
-				} else {
484
-					$weight=$my_weight[0];
485
-				}
486
-		    	$jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n";
487
-				$cpt2++;
488
-
489
-				// if the left side of the "matching" has been completely shown
490
-				if($answerId == $nbrAnswers)
491
-				{
492
-					// if there remain answers to be shown on the right side
493
-					while(isset($Select[$cpt2]))
494
-					{
495
-						//$s.='<tr>'."\n";
496
-						//$s.='<td colspan="2">'."\n";
497
-						//$s.='<table border="0" cellpadding="0" cellspacing="0" width="100%">'."\n";
498
-						$s.='<tr>'."\n";
499
-						$s.='<td width="60%" colspan="2">&nbsp;</td>'."\n";
500
-						$s.='<td width="40%" valign="top">';
501
-						$s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse'];
502
-						$s.="</td>\n</tr>\n";
503
-						$cpt2++;
504
-					}	// end while()
505
-				}  // end if()
506
-			}
507
-		}
508
-		$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n";
509
-    	$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n";
510
-    	$js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n";
511
-    	$js .= $jstmpw;
512
-		$html .= $s;
513
-		$html .= '</table></td></tr>' . "\n";
448
+        for($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
449
+            $identifier = 'question_'.$qId.'_matching_';
450
+            $answer=$this->selectAnswer($answerId);
451
+            $answerCorrect=$this->isCorrect($answerId);
452
+            $weight=$this->selectWeighting($answerId);
453
+            $jstmp .= $answerId.',';
454
+
455
+            if (!$answerCorrect) {
456
+                // options (A, B, C, ...) that will be put into the list-box
457
+                $Select[$answerId]['Lettre']=$cpt1;
458
+                // answers that will be shown at the right side
459
+                $Select[$answerId]['Reponse'] = $answer;
460
+                $cpt1++;
461
+            } else {
462
+                $s.='<tr>'."\n";
463
+                $s.='<td width="40%" valign="top">'."\n".'<b>'.$cpt2.'</b>.&nbsp;'.$answer."\n</td>\n";
464
+                $s.='<td width="20%" align="center">&nbsp;&nbsp;<select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">';
465
+                $s.=' <option value="0">--</option>';
466
+                // fills the list-box
467
+                foreach($Select as $key=>$val)
468
+                {
469
+                    $s.='<option value="'.$key.'">'.$val['Lettre'].'</option>';
470
+                }  // end foreach()
471
+
472
+                $s.='</select>&nbsp;&nbsp;</td>'."\n";
473
+                $s.='<td width="40%" valign="top">';
474
+                if(isset($Select[$cpt2])) $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse'];
475
+                    else $s.='&nbsp;';
476
+                $s.="</td>\n</tr>\n";
477
+
478
+                $jstmpc .= '['.$answerCorrect.','.$cpt2.'],';
479
+
480
+                $my_weight=explode('@',$weight);
481
+                if (count($my_weight)==2) {
482
+                    $weight=$my_weight[0];
483
+                } else {
484
+                    $weight=$my_weight[0];
485
+                }
486
+                $jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n";
487
+                $cpt2++;
488
+
489
+                // if the left side of the "matching" has been completely shown
490
+                if($answerId == $nbrAnswers)
491
+                {
492
+                    // if there remain answers to be shown on the right side
493
+                    while(isset($Select[$cpt2]))
494
+                    {
495
+                        //$s.='<tr>'."\n";
496
+                        //$s.='<td colspan="2">'."\n";
497
+                        //$s.='<table border="0" cellpadding="0" cellspacing="0" width="100%">'."\n";
498
+                        $s.='<tr>'."\n";
499
+                        $s.='<td width="60%" colspan="2">&nbsp;</td>'."\n";
500
+                        $s.='<td width="40%" valign="top">';
501
+                        $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse'];
502
+                        $s.="</td>\n</tr>\n";
503
+                        $cpt2++;
504
+                    }	// end while()
505
+                }  // end if()
506
+            }
507
+        }
508
+        $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n";
509
+        $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n";
510
+        $js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n";
511
+        $js .= $jstmpw;
512
+        $html .= $s;
513
+        $html .= '</table></td></tr>' . "\n";
514 514
 
515 515
         return array($js,$html);
516 516
     }
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
  */
523 523
 class ScormAnswerFree extends Answer
524 524
 {
525
-	/**
525
+    /**
526 526
      * Export the text with missing words.
527 527
      *
528 528
      * As a side effect, it stores two lists in the class :
@@ -531,67 +531,67 @@  discard block
 block discarded – undo
531 531
      */
532 532
     function export()
533 533
     {
534
-    	//$qId = $this->questionJSId;
535
-    	$js = '';
536
-    	/*$html = '<tr><td colspan="2"><table width="100%">' . "\n";
534
+        //$qId = $this->questionJSId;
535
+        $js = '';
536
+        /*$html = '<tr><td colspan="2"><table width="100%">' . "\n";
537 537
 		// some javascript must be added for that kind of questions
538 538
 		$html .= '<tr><td>
539 539
 		    	<textarea name="question_'.$qId.'_free" id="question_'.$qId.'_free" rows="20" cols="100"></textarea>
540 540
 		    	</td>
541 541
                 </tr>';
542 542
 		$html .= '</table></td></tr>';*/
543
-		// currently the free answers cannot be displayed, so ignore the textarea
544
-		$html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>';
545
-		$js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n";
546
-    	$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n";
547
-    	$js .= 'questions_types['.$this->questionJSId.'] = \'free\';'."\n";
548
-		$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
549
-		$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
550
-    	$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n";
551
-    	$js .= $jstmpw;
543
+        // currently the free answers cannot be displayed, so ignore the textarea
544
+        $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>';
545
+        $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n";
546
+        $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n";
547
+        $js .= 'questions_types['.$this->questionJSId.'] = \'free\';'."\n";
548
+        $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
549
+        $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
550
+        $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n";
551
+        $js .= $jstmpw;
552 552
         return array($js,$html);
553 553
     }
554 554
 }
555 555
 /**
556
- * This class handles the SCORM export of hotpot questions
557
- * @package chamilo.exercise.scorm
558
- */
556
+     * This class handles the SCORM export of hotpot questions
557
+     * @package chamilo.exercise.scorm
558
+     */
559 559
 class ScormAnswerHotspot extends Answer
560 560
 {
561
-	/**
562
-	 * Returns the javascript code that goes with HotSpot exercises
563
-	 * @return string	The JavaScript code
564
-	 */
565
-	function get_js_header()
566
-	{
567
-		if ($this->standalone) {
568
-			$header = '<script type="text/javascript" language="javascript">';
569
-			$header .= file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js');
570
-			$header .= '</script>';
571
-			//because this header closes so many times the <script> tag, we have to reopen our own
572
-			$header .= '<script type="text/javascript" language="javascript">'."\n";
573
-			$header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n";
574
-    		$header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n";
575
-    		$header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n";
576
-			$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
577
-			$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
578
-	    	$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n";
579
-	    	$header .= $jstmpw;
580
-		}
581
-		else
582
-		{
583
-			$header = '';
584
-			$header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n";
585
-    		$header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n";
586
-    		$header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n";
587
-			$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
588
-			$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
589
-	    	$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'."\n";
590
-	    	$header .= $jstmpw;
591
-		}
592
-		return $header;
593
-	}
594
-	/**
561
+    /**
562
+     * Returns the javascript code that goes with HotSpot exercises
563
+     * @return string	The JavaScript code
564
+     */
565
+    function get_js_header()
566
+    {
567
+        if ($this->standalone) {
568
+            $header = '<script type="text/javascript" language="javascript">';
569
+            $header .= file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js');
570
+            $header .= '</script>';
571
+            //because this header closes so many times the <script> tag, we have to reopen our own
572
+            $header .= '<script type="text/javascript" language="javascript">'."\n";
573
+            $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n";
574
+            $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n";
575
+            $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n";
576
+            $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
577
+            $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
578
+            $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n";
579
+            $header .= $jstmpw;
580
+        }
581
+        else
582
+        {
583
+            $header = '';
584
+            $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n";
585
+            $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n";
586
+            $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n";
587
+            $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
588
+            $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
589
+            $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'."\n";
590
+            $header .= $jstmpw;
591
+        }
592
+        return $header;
593
+    }
594
+    /**
595 595
      * Export the text with missing words.
596 596
      *
597 597
      * As a side effect, it stores two lists in the class :
@@ -600,22 +600,22 @@  discard block
 block discarded – undo
600 600
      */
601 601
     function export()
602 602
     {
603
-    	$js = $this->get_js_header();
604
-    	$html = '<tr><td colspan="2"><table width="100%">' . "\n";
605
-		// some javascript must be added for that kind of questions
606
-		$html .= '';
603
+        $js = $this->get_js_header();
604
+        $html = '<tr><td colspan="2"><table width="100%">' . "\n";
605
+        // some javascript must be added for that kind of questions
606
+        $html .= '';
607 607
 
608
-		// Get the answers, make a list
609
-		$nbrAnswers=$this->selectNbrAnswers();
608
+        // Get the answers, make a list
609
+        $nbrAnswers=$this->selectNbrAnswers();
610 610
 
611
-		$answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>';
612
-		for($answerId=1;$answerId <= $nbrAnswers;$answerId++)
613
-		{
614
-			$answer_list .= '<li>'.$this->selectAnswer($answerId).'</li>';
615
-		}
616
-		$answer_list .= '</ol></div>';
611
+        $answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>';
612
+        for($answerId=1;$answerId <= $nbrAnswers;$answerId++)
613
+        {
614
+            $answer_list .= '<li>'.$this->selectAnswer($answerId).'</li>';
615
+        }
616
+        $answer_list .= '</ol></div>';
617 617
 
618
-		/*
618
+        /*
619 619
 		if(!$onlyAnswers)
620 620
 		{
621 621
 			$s="<tr>
@@ -633,11 +633,11 @@  discard block
 block discarded – undo
633 633
 		}
634 634
 		*/
635 635
 
636
-		//$canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1');
637
-		$canClick = true;
638
-		//$tes = isset($_GET['modifyAnswers']) ? '0' : '1';
639
-		//echo $tes;
640
-		$relPath = api_get_path(REL_PATH);
636
+        //$canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1');
637
+        $canClick = true;
638
+        //$tes = isset($_GET['modifyAnswers']) ? '0' : '1';
639
+        //echo $tes;
640
+        $relPath = api_get_path(REL_PATH);
641 641
         $html .= <<<HTML
642 642
             <tr>
643 643
                 <td>
@@ -658,10 +658,10 @@  discard block
 block discarded – undo
658 658
                 </td>
659 659
             <tr>
660 660
 HTML;
661
-		$html .= '</table></td></tr>' . "\n";
661
+        $html .= '</table></td></tr>' . "\n";
662 662
 
663
-		// currently the free answers cannot be displayed, so ignore the textarea
664
-		$html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>';
663
+        // currently the free answers cannot be displayed, so ignore the textarea
664
+        $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>';
665 665
         return array($js,$html);
666 666
     }
667 667
 }
Please login to merge, or discard this patch.