Completed
Pull Request — 1.11.x (#1318)
by José
66:27 queued 30:05
created
main/document/record_audio.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
 
19 19
 $document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id(), true);
20 20
 if (empty($document_data)) {
21
-	if (api_is_in_group()) {
22
-		$group_properties   = GroupManager::get_group_properties(api_get_group_id());
23
-		$document_id        = DocumentManager::get_document_id(api_get_course_info(), $group_properties['directory']);
24
-		$document_data      = DocumentManager::get_document_data_by_id($document_id, api_get_course_id());
25
-	}
21
+    if (api_is_in_group()) {
22
+        $group_properties   = GroupManager::get_group_properties(api_get_group_id());
23
+        $document_id        = DocumentManager::get_document_id(api_get_course_info(), $group_properties['directory']);
24
+        $document_data      = DocumentManager::get_document_data_by_id($document_id, api_get_course_id());
25
+    }
26 26
 }
27 27
 
28 28
 $document_id = $document_data['id'];
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 //make some vars
32 32
 $wamidir = $dir;
33 33
 if ($wamidir == "/") {
34
-	$wamidir = "";
34
+    $wamidir = "";
35 35
 }
36 36
 $wamiurlplay = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$wamidir."/";
37 37
 $groupId = api_get_group_id();
@@ -41,48 +41,48 @@  discard block
 block discarded – undo
41 41
 // Please, do not modify this dirname formatting
42 42
 
43 43
 if (strstr($dir, '..')) {
44
-	$dir = '/';
44
+    $dir = '/';
45 45
 }
46 46
 
47 47
 if ($dir[0] == '.') {
48
-	$dir = substr($dir, 1);
48
+    $dir = substr($dir, 1);
49 49
 }
50 50
 
51 51
 if ($dir[0] != '/') {
52
-	$dir = '/'.$dir;
52
+    $dir = '/'.$dir;
53 53
 }
54 54
 
55 55
 if ($dir[strlen($dir) - 1] != '/') {
56
-	$dir .= '/';
56
+    $dir .= '/';
57 57
 }
58 58
 
59 59
 $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
60 60
 
61 61
 if (!is_dir($filepath)) {
62
-	$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
63
-	$dir = '/';
62
+    $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
63
+    $dir = '/';
64 64
 }
65 65
 
66 66
 //groups //TODO: clean
67 67
 if (!empty($groupId)) {
68
-	$interbreadcrumb[] = array ("url" => "../group/group_space.php?".api_get_cidreq(), "name" => get_lang('GroupSpace'));
69
-	$noPHP_SELF = true;
70
-	$group = GroupManager :: get_group_properties($groupId);
71
-	$path = explode('/', $dir);
72
-	if ('/'.$path[1] != $group['directory']) {
73
-		api_not_allowed(true);
74
-	}
68
+    $interbreadcrumb[] = array ("url" => "../group/group_space.php?".api_get_cidreq(), "name" => get_lang('GroupSpace'));
69
+    $noPHP_SELF = true;
70
+    $group = GroupManager :: get_group_properties($groupId);
71
+    $path = explode('/', $dir);
72
+    if ('/'.$path[1] != $group['directory']) {
73
+        api_not_allowed(true);
74
+    }
75 75
 }
76 76
 
77 77
 $interbreadcrumb[] = array("url" => "./document.php?id=".$document_id.'&'.api_get_cidreq(), "name" => get_lang('Documents'));
78 78
 
79 79
 if (!$is_allowed_in_course) {
80
-	api_not_allowed(true);
80
+    api_not_allowed(true);
81 81
 }
82 82
 
83 83
 if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] ||
84
-	DocumentManager::is_my_shared_folder(api_get_user_id(), Security::remove_XSS($dir),api_get_session_id()))) {
85
-	api_not_allowed(true);
84
+    DocumentManager::is_my_shared_folder(api_get_user_id(), Security::remove_XSS($dir),api_get_session_id()))) {
85
+    api_not_allowed(true);
86 86
 }
87 87
 
88 88
 /*	Header */
@@ -90,26 +90,26 @@  discard block
 block discarded – undo
90 90
 
91 91
 $display_dir = $dir;
92 92
 if (isset ($group)) {
93
-	$display_dir = explode('/', $dir);
94
-	unset ($display_dir[0]);
95
-	unset ($display_dir[1]);
96
-	$display_dir = implode('/', $display_dir);
93
+    $display_dir = explode('/', $dir);
94
+    unset ($display_dir[0]);
95
+    unset ($display_dir[1]);
96
+    $display_dir = implode('/', $display_dir);
97 97
 }
98 98
 
99 99
 // Interbreadcrumb for the current directory root path
100 100
 $counter = 0;
101 101
 if (isset($document_data['parents'])) {
102
-	foreach($document_data['parents'] as $document_sub_data) {
103
-		//fixing double group folder in breadcrumb
104
-		if (api_get_group_id()) {
105
-			if ($counter == 0) {
106
-				$counter++;
107
-				continue;
108
-			}
109
-		}
110
-		$interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
111
-		$counter++;
112
-	}
102
+    foreach($document_data['parents'] as $document_sub_data) {
103
+        //fixing double group folder in breadcrumb
104
+        if (api_get_group_id()) {
105
+            if ($counter == 0) {
106
+                $counter++;
107
+                continue;
108
+            }
109
+        }
110
+        $interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
111
+        $counter++;
112
+    }
113 113
 }
114 114
 
115 115
 //make some vars
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
 $htmlHeadXtra[] = '<script type="text/javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'swfobject/swfobject.js"></script>';
122 122
 
123 123
 $actions = Display::toolbarButton(
124
-	get_lang('BackTo') . ' ' . get_lang('DocumentsOverview'),
125
-	'document.php?' . api_get_cidreq() . "&id=$document_id",
126
-	'arrow-left',
127
-	'default',
128
-	[],
129
-	false
124
+    get_lang('BackTo') . ' ' . get_lang('DocumentsOverview'),
125
+    'document.php?' . api_get_cidreq() . "&id=$document_id",
126
+    'arrow-left',
127
+    'default',
128
+    [],
129
+    false
130 130
 );
131 131
 
132 132
 $template = new Template($nameTools);
Please login to merge, or discard this patch.
main/inc/lib/extra_field.lib.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
         'changeable',
20 20
         'filter',
21 21
         'extra_field_type',
22
-         /* Enable this when field_loggeable is introduced as a table field (2.0)
22
+            /* Enable this when field_loggeable is introduced as a table field (2.0)
23 23
         'field_loggeable',
24 24
          */
25 25
         'created_at'
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
                 foreach ($orderFields as $order) {
809 809
                     foreach ($extra as $field_details) {
810 810
                         if ($order == $field_details['variable']) {
811
-                           $newOrder[] = $field_details;
811
+                            $newOrder[] = $field_details;
812 812
                         }
813 813
                     }
814 814
                 }
Please login to merge, or discard this patch.
main/session/session_export.php 1 patch
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 set_time_limit(0);
38 38
 
39 39
 if (isset($_POST['formSent'])) {
40
-	$formSent = $_POST['formSent'];
41
-	$file_type = isset($_POST['file_type']) ? $_POST['file_type'] : 'csv';
42
-	$session_id = $_POST['session_id'];
43
-	if (empty($session_id)) {
44
-		$sql = "SELECT
40
+    $formSent = $_POST['formSent'];
41
+    $file_type = isset($_POST['file_type']) ? $_POST['file_type'] : 'csv';
42
+    $session_id = $_POST['session_id'];
43
+    if (empty($session_id)) {
44
+        $sql = "SELECT
45 45
 					s.id,
46 46
 					name,
47 47
 					id_coach,
@@ -55,84 +55,84 @@  discard block
 block discarded – undo
55 55
 				ON $tbl_user.user_id = s.id_coach
56 56
 				ORDER BY id";
57 57
 
58
-		if (api_is_multiple_url_enabled()) {
59
-			$tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
60
-			$access_url_id = api_get_current_access_url_id();
61
-			if ($access_url_id != -1){
62
-			$sql = "SELECT s.id, name,id_coach,username,access_start_date,access_end_date,visibility,session_category_id
58
+        if (api_is_multiple_url_enabled()) {
59
+            $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
60
+            $access_url_id = api_get_current_access_url_id();
61
+            if ($access_url_id != -1){
62
+            $sql = "SELECT s.id, name,id_coach,username,access_start_date,access_end_date,visibility,session_category_id
63 63
 					FROM $tbl_session s
64 64
 					INNER JOIN $tbl_session_rel_access_url as session_rel_url
65 65
 					ON (s.id= session_rel_url.session_id)
66 66
 					INNER JOIN $tbl_user u ON (u.user_id = s.id_coach)
67 67
 					WHERE access_url_id = $access_url_id
68 68
 					ORDER BY id";
69
-			}
70
-		}
69
+            }
70
+        }
71 71
 
72
-		$result = Database::query($sql);
73
-	} else {
74
-		$sql = "SELECT s.id,name,username,access_start_date,access_end_date,visibility,session_category_id
72
+        $result = Database::query($sql);
73
+    } else {
74
+        $sql = "SELECT s.id,name,username,access_start_date,access_end_date,visibility,session_category_id
75 75
 				FROM $tbl_session s
76 76
 				INNER JOIN $tbl_user
77 77
 					ON $tbl_user.user_id = s.id_coach
78 78
 				WHERE id='$session_id'";
79
-		$result = Database::query($sql);
80
-	}
79
+        $result = Database::query($sql);
80
+    }
81 81
 
82
-	if (Database::num_rows($result)) {
82
+    if (Database::num_rows($result)) {
83 83
 
84 84
 
85 85
 
86
-		$sessionListToExport = [];
86
+        $sessionListToExport = [];
87 87
 
88
-		if (in_array($file_type, ['csv', 'xls'])) {
88
+        if (in_array($file_type, ['csv', 'xls'])) {
89 89
 
90
-			$archiveFile = 'export_sessions_'.$session_id.'_'.api_get_local_time();
90
+            $archiveFile = 'export_sessions_'.$session_id.'_'.api_get_local_time();
91 91
 
92
-			$cvs = true;
93
-			$sessionListToExport[] = [
94
-				'SessionName',
95
-				'Coach',
96
-				'DateStart',
97
-				'DateEnd',
98
-				'Visibility',
99
-				'SessionCategory',
100
-				'Users',
101
-				'Courses'
102
-			];
103
-		} else {
104
-			if (!file_exists($archivePath)) {
105
-				mkdir($archivePath, api_get_permissions_for_new_directories(), true);
106
-			}
92
+            $cvs = true;
93
+            $sessionListToExport[] = [
94
+                'SessionName',
95
+                'Coach',
96
+                'DateStart',
97
+                'DateEnd',
98
+                'Visibility',
99
+                'SessionCategory',
100
+                'Users',
101
+                'Courses'
102
+            ];
103
+        } else {
104
+            if (!file_exists($archivePath)) {
105
+                mkdir($archivePath, api_get_permissions_for_new_directories(), true);
106
+            }
107 107
 
108
-			if (!file_exists($archivePath.'index.html')) {
109
-				$fp = fopen($archivePath.'index.html', 'w');
110
-				fputs($fp, '<html><head></head><body></body></html>');
111
-				fclose($fp);
112
-			}
108
+            if (!file_exists($archivePath.'index.html')) {
109
+                $fp = fopen($archivePath.'index.html', 'w');
110
+                fputs($fp, '<html><head></head><body></body></html>');
111
+                fclose($fp);
112
+            }
113 113
 
114
-			$archiveFile = 'export_sessions_'.$session_id.'_'.api_get_local_time().'.'.$file_type;
115
-			while (file_exists($archivePath.$archiveFile)) {
116
-				$archiveFile ='export_users_'.$session_id.'_'.api_get_local_time().'_'.uniqid('').'.'.$file_type;
117
-			}
114
+            $archiveFile = 'export_sessions_'.$session_id.'_'.api_get_local_time().'.'.$file_type;
115
+            while (file_exists($archivePath.$archiveFile)) {
116
+                $archiveFile ='export_users_'.$session_id.'_'.api_get_local_time().'_'.uniqid('').'.'.$file_type;
117
+            }
118 118
 
119
-			$cvs = false;
120
-			$fp = fopen($archivePath.$archiveFile, 'w');
121
-			fputs($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Sessions>\n");
122
-		}
119
+            $cvs = false;
120
+            $fp = fopen($archivePath.$archiveFile, 'w');
121
+            fputs($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Sessions>\n");
122
+        }
123 123
 
124 124
 
125
-		while ($row = Database::fetch_array($result)) {
126
-			$row['name'] = str_replace(';',',',$row['name']);
127
-			$row['username'] = str_replace(';',',',$row['username']);
128
-			$row['access_start_date'] = str_replace(';',',',$row['access_start_date']);
129
-			$row['access_end_date'] = str_replace(';',',',$row['access_end_date']);
130
-			$row['visibility'] = str_replace(';',',',$row['visibility']);
131
-			$row['session_category'] = str_replace(';',',',$row['session_category_id']);
125
+        while ($row = Database::fetch_array($result)) {
126
+            $row['name'] = str_replace(';',',',$row['name']);
127
+            $row['username'] = str_replace(';',',',$row['username']);
128
+            $row['access_start_date'] = str_replace(';',',',$row['access_start_date']);
129
+            $row['access_end_date'] = str_replace(';',',',$row['access_end_date']);
130
+            $row['visibility'] = str_replace(';',',',$row['visibility']);
131
+            $row['session_category'] = str_replace(';',',',$row['session_category_id']);
132 132
 
133 133
 
134
-			// users
135
-			$sql = "SELECT DISTINCT $tbl_user.username
134
+            // users
135
+            $sql = "SELECT DISTINCT $tbl_user.username
136 136
 					FROM $tbl_user
137 137
 					INNER JOIN $tbl_session_user
138 138
 					ON
@@ -140,33 +140,33 @@  discard block
 block discarded – undo
140 140
 						$tbl_session_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." AND
141 141
 						$tbl_session_user.session_id = '".$row['id']."'";
142 142
 
143
-			$rsUsers = Database::query($sql);
144
-			$users = '';
145
-			while ($rowUsers = Database::fetch_array($rsUsers)){
146
-				if($cvs){
147
-					$users .= str_replace(';',',',$rowUsers['username']).'|';
148
-				} else {
149
-					$users .= "\t\t<User>$rowUsers[username]</User>\n";
150
-				}
151
-			}
152
-
153
-			if (!empty($users) && $cvs) {
154
-				$users = api_substr($users, 0, api_strlen($users) - 1);
155
-			}
156
-
157
-			// Courses
158
-			$sql = "SELECT DISTINCT c.code, sc.id, c_id
143
+            $rsUsers = Database::query($sql);
144
+            $users = '';
145
+            while ($rowUsers = Database::fetch_array($rsUsers)){
146
+                if($cvs){
147
+                    $users .= str_replace(';',',',$rowUsers['username']).'|';
148
+                } else {
149
+                    $users .= "\t\t<User>$rowUsers[username]</User>\n";
150
+                }
151
+            }
152
+
153
+            if (!empty($users) && $cvs) {
154
+                $users = api_substr($users, 0, api_strlen($users) - 1);
155
+            }
156
+
157
+            // Courses
158
+            $sql = "SELECT DISTINCT c.code, sc.id, c_id
159 159
 					FROM $tbl_course c
160 160
 					INNER JOIN $tbl_session_course_user sc
161 161
 						ON c.id = sc.c_id
162 162
 						AND sc.session_id = '".$row['id']."'";
163 163
 
164
-			$rsCourses = Database::query($sql);
164
+            $rsCourses = Database::query($sql);
165 165
 
166
-			$courses = '';
167
-			while ($rowCourses = Database::fetch_array($rsCourses)) {
168
-				// get coachs from a course
169
-				$sql = "SELECT u.username
166
+            $courses = '';
167
+            while ($rowCourses = Database::fetch_array($rsCourses)) {
168
+                // get coachs from a course
169
+                $sql = "SELECT u.username
170 170
 						FROM $tbl_session_course_user scu
171 171
 						INNER JOIN $tbl_user u
172 172
 						ON u.user_id = scu.user_id
@@ -175,25 +175,25 @@  discard block
 block discarded – undo
175 175
 							scu.session_id = '".$row['id']."' AND
176 176
 							scu.status = 2 ";
177 177
 
178
-				$rs_coachs = Database::query($sql);
179
-				$coachs = array();
180
-				while ($row_coachs = Database::fetch_array($rs_coachs)) {
181
-					$coachs[] = $row_coachs['username'];
182
-				}
183
-
184
-				$coachs = implode(",", $coachs);
185
-
186
-				if ($cvs) {
187
-					$courses .= str_replace(';',',',$rowCourses['code']);
188
-					$courses .= '['.str_replace(';',',',$coachs).'][';
189
-				} else {
190
-					$courses .= "\t\t<Course>\n";
191
-					$courses .= "\t\t\t<CourseCode>$rowCourses[code]</CourseCode>\n";
192
-					$courses .= "\t\t\t<Coach>$coachs</Coach>\n";
193
-				}
194
-
195
-				// rel user courses
196
-				$sql = "SELECT DISTINCT u.username
178
+                $rs_coachs = Database::query($sql);
179
+                $coachs = array();
180
+                while ($row_coachs = Database::fetch_array($rs_coachs)) {
181
+                    $coachs[] = $row_coachs['username'];
182
+                }
183
+
184
+                $coachs = implode(",", $coachs);
185
+
186
+                if ($cvs) {
187
+                    $courses .= str_replace(';',',',$rowCourses['code']);
188
+                    $courses .= '['.str_replace(';',',',$coachs).'][';
189
+                } else {
190
+                    $courses .= "\t\t<Course>\n";
191
+                    $courses .= "\t\t\t<CourseCode>$rowCourses[code]</CourseCode>\n";
192
+                    $courses .= "\t\t\t<Coach>$coachs</Coach>\n";
193
+                }
194
+
195
+                // rel user courses
196
+                $sql = "SELECT DISTINCT u.username
197 197
 						FROM $tbl_session_course_user scu
198 198
 						INNER JOIN $tbl_session_user su
199 199
 						ON
@@ -206,79 +206,79 @@  discard block
 block discarded – undo
206 206
 							scu.c_id='".$rowCourses['c_id']."' AND
207 207
 							scu.session_id='".$row['id']."'";
208 208
 
209
-				$rsUsersCourse = Database::query($sql);
210
-				$userscourse = '';
211
-				while ($rowUsersCourse = Database::fetch_array($rsUsersCourse)){
212
-					if ($cvs) {
213
-						$userscourse .= str_replace(';',',',$rowUsersCourse['username']).',';
214
-					} else {
215
-						$courses .= "\t\t\t<User>$rowUsersCourse[username]</User>\n";
216
-					}
217
-				}
218
-
219
-				if ($cvs) {
220
-					if (!empty($userscourse)) {
221
-						$userscourse = api_substr(
222
-							$userscourse,
223
-							0,
224
-							api_strlen($userscourse) - 1
225
-						);
226
-					}
227
-
228
-					$courses .= $userscourse.']|';
229
-				} else {
230
-					$courses .= "\t\t</Course>\n";
231
-				}
232
-			}
233
-
234
-			if (!empty($courses) && $cvs) {
235
-				$courses = api_substr($courses, 0, api_strlen($courses) - 1);
236
-			}
237
-			$add = $courses;
238
-
239
-			if (in_array($file_type, ['csv', 'xls'])) {
240
-				$sessionListToExport[] = [
241
-					$row['name'],
242
-					$row['username'],
243
-					$row['access_start_date'],
244
-					$row['access_end_date'],
245
-					$row['visibility'],
246
-					$row['session_category'],
247
-					$users,
248
-					$courses
249
-				];
250
-			} else {
251
-				$add = "\t<Session>\n"
252
-						 ."\t\t<SessionName>$row[name]</SessionName>\n"
253
-						 ."\t\t<Coach>$row[username]</Coach>\n"
254
-						 ."\t\t<DateStart>$row[access_start_date]</DateStart>\n"
255
-						 ."\t\t<DateEnd>$row[access_end_date]</DateEnd>\n"
256
-						 ."\t\t<Visibility>$row[visibility]</Visibility>\n"
257
-						 ."\t\t<SessionCategory>$row[session_category]</SessionCategory>\n";
258
-			}
259
-
260
-		 	if (!$cvs) {
261
-				$add .= "\t</Session>\n";
262
-				fputs($fp, $add);
263
-			}
264
-		}
265
-
266
-		switch ($file_type) {
267
-			case 'xml':
268
-				fputs($fp, "</Sessions>\n");
269
-				fclose($fp);
270
-				$errorMsg = get_lang('UserListHasBeenExported').'<br/>
209
+                $rsUsersCourse = Database::query($sql);
210
+                $userscourse = '';
211
+                while ($rowUsersCourse = Database::fetch_array($rsUsersCourse)){
212
+                    if ($cvs) {
213
+                        $userscourse .= str_replace(';',',',$rowUsersCourse['username']).',';
214
+                    } else {
215
+                        $courses .= "\t\t\t<User>$rowUsersCourse[username]</User>\n";
216
+                    }
217
+                }
218
+
219
+                if ($cvs) {
220
+                    if (!empty($userscourse)) {
221
+                        $userscourse = api_substr(
222
+                            $userscourse,
223
+                            0,
224
+                            api_strlen($userscourse) - 1
225
+                        );
226
+                    }
227
+
228
+                    $courses .= $userscourse.']|';
229
+                } else {
230
+                    $courses .= "\t\t</Course>\n";
231
+                }
232
+            }
233
+
234
+            if (!empty($courses) && $cvs) {
235
+                $courses = api_substr($courses, 0, api_strlen($courses) - 1);
236
+            }
237
+            $add = $courses;
238
+
239
+            if (in_array($file_type, ['csv', 'xls'])) {
240
+                $sessionListToExport[] = [
241
+                    $row['name'],
242
+                    $row['username'],
243
+                    $row['access_start_date'],
244
+                    $row['access_end_date'],
245
+                    $row['visibility'],
246
+                    $row['session_category'],
247
+                    $users,
248
+                    $courses
249
+                ];
250
+            } else {
251
+                $add = "\t<Session>\n"
252
+                            ."\t\t<SessionName>$row[name]</SessionName>\n"
253
+                            ."\t\t<Coach>$row[username]</Coach>\n"
254
+                            ."\t\t<DateStart>$row[access_start_date]</DateStart>\n"
255
+                            ."\t\t<DateEnd>$row[access_end_date]</DateEnd>\n"
256
+                            ."\t\t<Visibility>$row[visibility]</Visibility>\n"
257
+                            ."\t\t<SessionCategory>$row[session_category]</SessionCategory>\n";
258
+            }
259
+
260
+                if (!$cvs) {
261
+                $add .= "\t</Session>\n";
262
+                fputs($fp, $add);
263
+            }
264
+        }
265
+
266
+        switch ($file_type) {
267
+            case 'xml':
268
+                fputs($fp, "</Sessions>\n");
269
+                fclose($fp);
270
+                $errorMsg = get_lang('UserListHasBeenExported').'<br/>
271 271
 				<a class="btn btn-default" href="'.$archiveURL.$archiveFile.'">'.get_lang('ClickHereToDownloadTheFile').'</a>';
272
-				break;
273
-			case 'csv':
274
-				Export::arrayToCsv($sessionListToExport, $archiveFile);
275
-				exit;
276
-			case 'xls':
277
-				Export::arrayToXls($sessionListToExport, $archiveFile);
278
-				exit;
279
-				break;
280
-		}
281
-	}
272
+                break;
273
+            case 'csv':
274
+                Export::arrayToCsv($sessionListToExport, $archiveFile);
275
+                exit;
276
+            case 'xls':
277
+                Export::arrayToXls($sessionListToExport, $archiveFile);
278
+                exit;
279
+                break;
280
+        }
281
+    }
282 282
 }
283 283
 
284 284
 // display the header
@@ -288,26 +288,26 @@  discard block
 block discarded – undo
288 288
 $sql = "SELECT id, name FROM $tbl_session ORDER BY name";
289 289
 
290 290
 if (api_is_multiple_url_enabled()) {
291
-	$tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
292
-	$access_url_id = api_get_current_access_url_id();
293
-	if ($access_url_id != -1){
294
-	$sql = "SELECT s.id, name FROM $tbl_session s
291
+    $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
292
+    $access_url_id = api_get_current_access_url_id();
293
+    if ($access_url_id != -1){
294
+    $sql = "SELECT s.id, name FROM $tbl_session s
295 295
 			INNER JOIN $tbl_session_rel_access_url as session_rel_url
296 296
 			ON (s.id = session_rel_url.session_id)
297 297
 			WHERE access_url_id = $access_url_id
298 298
 			ORDER BY name";
299
-	}
299
+    }
300 300
 }
301 301
 $result = Database::query($sql);
302 302
 $Sessions = Database::store_result($result);
303 303
 
304 304
 echo '<div class="actions">';
305 305
 echo '<a href="../session/session_list.php">'.
306
-		Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('SessionList'),'',ICON_SIZE_MEDIUM).'</a>';
306
+        Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('SessionList'),'',ICON_SIZE_MEDIUM).'</a>';
307 307
 echo '</div>';
308 308
 
309 309
 if (!empty($errorMsg)) {
310
-	Display::display_normal_message($errorMsg, false); //main API
310
+    Display::display_normal_message($errorMsg, false); //main API
311 311
 }
312 312
 
313 313
 $form = new FormValidator('session_export', 'post', api_get_self());
Please login to merge, or discard this patch.
main/document/edit_document.php 1 patch
Indentation   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 $sessionId = api_get_session_id();
70 70
 
71 71
 if (api_is_in_group()) {
72
-	$group_properties = GroupManager::get_group_properties($group_id);
72
+    $group_properties = GroupManager::get_group_properties($group_id);
73 73
 }
74 74
 
75 75
 $dir = '/';
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
         $_GET['id'],
82 82
         api_get_course_id(),
83 83
         true,
84
-		0
84
+        0
85 85
     );
86 86
 
87 87
     if (!empty($sessionId) && empty($document_data)) {
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
         );
94 94
     }
95 95
 
96
-	$document_id = $document_data['id'];
97
-	$file = $document_data['path'];
98
-	$parent_id = DocumentManager::get_document_id($course_info, dirname($file));
99
-	$dir = dirname($document_data['path']);
100
-	$dir_original = $dir;
101
-	$doc = basename($file);
102
-	$readonly = $document_data['readonly'];
96
+    $document_id = $document_data['id'];
97
+    $file = $document_data['path'];
98
+    $parent_id = DocumentManager::get_document_id($course_info, dirname($file));
99
+    $dir = dirname($document_data['path']);
100
+    $dir_original = $dir;
101
+    $doc = basename($file);
102
+    $readonly = $document_data['readonly'];
103 103
 }
104 104
 
105 105
 if (empty($document_data)) {
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 
122 122
 // Level correction for group documents.
123 123
 if (!empty($group_properties['directory'])) {
124
-	$count_dir = $count_dir > 0 ? $count_dir - 1 : 0;
124
+    $count_dir = $count_dir > 0 ? $count_dir - 1 : 0;
125 125
 }
126 126
 $relative_url = '';
127 127
 for ($i = 0; $i < ($count_dir); $i++) {
@@ -143,13 +143,13 @@  discard block
 block discarded – undo
143 143
 );
144 144
 
145 145
 if ($is_certificate_mode) {
146
-	$editorConfig['CreateDocumentDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/';
147
-	$editorConfig['CreateDocumentWebDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/';
148
-	$editorConfig['BaseHref'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir;
146
+    $editorConfig['CreateDocumentDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/';
147
+    $editorConfig['CreateDocumentWebDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/';
148
+    $editorConfig['BaseHref'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir;
149 149
 }
150 150
 
151 151
 $is_allowed_to_edit = api_is_allowed_to_edit(null, true) || $_SESSION['group_member_with_upload_rights']||
152
-	DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $sessionId);
152
+    DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $sessionId);
153 153
 $noPHP_SELF = true;
154 154
 
155 155
 /*	Other initialization code */
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
         'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
163 163
         'name' => get_lang('GroupSpace'),
164 164
     );
165
-	$group_document = true;
166
-	$noPHP_SELF = true;
165
+    $group_document = true;
166
+    $noPHP_SELF = true;
167 167
 }
168 168
 
169 169
 if (!$is_certificate_mode) {
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
 
198 198
 //TODO:check the below code and his funcionality
199 199
 if (!api_is_allowed_to_edit()) {
200
-	if (DocumentManager::check_readonly($course_info, $user_id, $file)) {
201
-		api_not_allowed();
202
-	}
200
+    if (DocumentManager::check_readonly($course_info, $user_id, $file)) {
201
+        api_not_allowed();
202
+    }
203 203
 }
204 204
 
205 205
 /* MAIN TOOL CODE */
@@ -207,18 +207,18 @@  discard block
 block discarded – undo
207 207
 /*	Code to change the comment	*/
208 208
 
209 209
 if (isset($_POST['comment'])) {
210
-	// Fixing the path if it is wrong
211
-	$comment = trim($_POST['comment']);
212
-	$title = trim($_POST['title']);
210
+    // Fixing the path if it is wrong
211
+    $comment = trim($_POST['comment']);
212
+    $title = trim($_POST['title']);
213 213
 
214 214
     // Just in case see BT#3525
215 215
     if (empty($title)) {
216
-		$title = $document_data['title'];
217
-	}
216
+        $title = $document_data['title'];
217
+    }
218 218
 
219
-	if (empty($title)) {
220
-		$title = get_document_title($_POST['filename']);
221
-	}
219
+    if (empty($title)) {
220
+        $title = get_document_title($_POST['filename']);
221
+    }
222 222
 
223 223
     if (!empty($document_id)) {
224 224
         $params = [
@@ -230,43 +230,43 @@  discard block
 block discarded – undo
230 230
             $params,
231 231
             ['c_id = ? AND id = ?' => [$course_id, $document_id]]
232 232
         );
233
-		Display::addFlash(Display::return_message(get_lang('fileModified')));
233
+        Display::addFlash(Display::return_message(get_lang('fileModified')));
234 234
     }
235 235
 }
236 236
 
237 237
 /*	WYSIWYG HTML EDITOR - Program Logic */
238 238
 if ($is_allowed_to_edit) {
239
-	if (isset($_POST['formSent']) && $_POST['formSent'] == 1) {
239
+    if (isset($_POST['formSent']) && $_POST['formSent'] == 1) {
240 240
 
241
-		$filename = stripslashes($_POST['filename']);
241
+        $filename = stripslashes($_POST['filename']);
242 242
         $extension = $_POST['extension'];
243
-		$content = isset($_POST['content']) ? trim(str_replace(array("\r", "\n"), '', stripslashes($_POST['content']))) : null;
244
-		$content = Security::remove_XSS($content, COURSEMANAGERLOWSECURITY);
243
+        $content = isset($_POST['content']) ? trim(str_replace(array("\r", "\n"), '', stripslashes($_POST['content']))) : null;
244
+        $content = Security::remove_XSS($content, COURSEMANAGERLOWSECURITY);
245 245
 
246 246
         if ($dir == '/') {
247 247
             $dir = '';
248 248
         }
249 249
 
250
-		$file = $dir.'/'.$filename.'.'.$extension;
251
-		$read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null;
252
-		$read_only_flag = empty($read_only_flag) ? 0 : 1;
250
+        $file = $dir.'/'.$filename.'.'.$extension;
251
+        $read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null;
252
+        $read_only_flag = empty($read_only_flag) ? 0 : 1;
253 253
 
254
-		if (empty($filename)) {
254
+        if (empty($filename)) {
255 255
             Display::addFlash(Display::return_message(get_lang('NoFileName'), 'warning'));
256
-		} else {
256
+        } else {
257 257
 
258
-		    $file_size = filesize($document_data['absolute_path']);
258
+            $file_size = filesize($document_data['absolute_path']);
259 259
 
260
-			if ($read_only_flag == 0) {
261
-				if (!empty($content)) {
262
-					if ($fp = @fopen($document_data['absolute_path'], 'w')) {
263
-						// For flv player, change absolute path temporarily to prevent from erasing it in the following lines
264
-						$content = str_replace(array('flv=h', 'flv=/'), array('flv=h|', 'flv=/|'), $content);
265
- 						fputs($fp, $content);
266
-						fclose($fp);
260
+            if ($read_only_flag == 0) {
261
+                if (!empty($content)) {
262
+                    if ($fp = @fopen($document_data['absolute_path'], 'w')) {
263
+                        // For flv player, change absolute path temporarily to prevent from erasing it in the following lines
264
+                        $content = str_replace(array('flv=h', 'flv=/'), array('flv=h|', 'flv=/|'), $content);
265
+                            fputs($fp, $content);
266
+                        fclose($fp);
267 267
 
268 268
                         $filepath = $document_data['absolute_parent_path'];
269
-						/*
269
+                        /*
270 270
 						if (!is_dir($filepath.'css')) {
271 271
 							mkdir($filepath.'css', api_get_permissions_for_new_directories());
272 272
 							$doc_id = add_document($_course, $dir.'css', 'folder', 0, 'css');
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 							);
297 297
 						}*/
298 298
 
299
-						/*if (!is_file($filepath.'css/frames.css')) {
299
+                        /*if (!is_file($filepath.'css/frames.css')) {
300 300
 							$platform_theme = api_get_setting('stylesheets');
301 301
 							if (file_exists(api_get_path(SYS_CODE_PATH).'css/'.$platform_theme.'/frames.css')) {
302 302
 								copy(api_get_path(SYS_CODE_PATH).'css/'.$platform_theme.'/frames.css', $filepath.'css/frames.css');
@@ -334,54 +334,54 @@  discard block
 block discarded – undo
334 334
 							}
335 335
 						}*/
336 336
 
337
-						// "WHAT'S NEW" notification: update table item_property
338
-						$document_id = DocumentManager::get_document_id($_course, $file);
339
-
340
-						if ($document_id) {
341
-							update_existing_document(
342
-								$_course,
343
-								$document_id,
344
-								$file_size,
345
-								$read_only_flag
346
-							);
347
-							api_item_property_update(
348
-								$_course,
349
-								TOOL_DOCUMENT,
350
-								$document_id,
351
-								'DocumentUpdated',
352
-								api_get_user_id(),
353
-								null,
354
-								null,
355
-								null,
356
-								null,
357
-								$sessionId
358
-							);
359
-							// Update parent folders
360
-							item_property_update_on_folder(
361
-								$_course,
362
-								$dir,
363
-								api_get_user_id()
364
-							);
365
-							header('Location: document.php?id=' . $document_data['parent_id'] . '&' . api_get_cidreq() . ($is_certificate_mode?'&curdirpath=/certificates&selectcat=1':''));
366
-							exit;
367
-						} else {
337
+                        // "WHAT'S NEW" notification: update table item_property
338
+                        $document_id = DocumentManager::get_document_id($_course, $file);
339
+
340
+                        if ($document_id) {
341
+                            update_existing_document(
342
+                                $_course,
343
+                                $document_id,
344
+                                $file_size,
345
+                                $read_only_flag
346
+                            );
347
+                            api_item_property_update(
348
+                                $_course,
349
+                                TOOL_DOCUMENT,
350
+                                $document_id,
351
+                                'DocumentUpdated',
352
+                                api_get_user_id(),
353
+                                null,
354
+                                null,
355
+                                null,
356
+                                null,
357
+                                $sessionId
358
+                            );
359
+                            // Update parent folders
360
+                            item_property_update_on_folder(
361
+                                $_course,
362
+                                $dir,
363
+                                api_get_user_id()
364
+                            );
365
+                            header('Location: document.php?id=' . $document_data['parent_id'] . '&' . api_get_cidreq() . ($is_certificate_mode?'&curdirpath=/certificates&selectcat=1':''));
366
+                            exit;
367
+                        } else {
368 368
                             Display::addFlash(Display::return_message(get_lang('Impossible'), 'warning'));
369
-						}
370
-					} else {
369
+                        }
370
+                    } else {
371 371
                         Display::addFlash(Display::return_message(get_lang('Impossible'), 'warning'));
372
-					}
373
-				} else {
374
-					if ($document_id) {
372
+                    }
373
+                } else {
374
+                    if ($document_id) {
375 375
                         update_existing_document($_course, $document_id, $file_size, $read_only_flag);
376
-					}
377
-				}
378
-			} else {
376
+                    }
377
+                }
378
+            } else {
379 379
                 if ($document_id) {
380 380
                     update_existing_document($_course, $document_id, $file_size, $read_only_flag);
381 381
                 }
382
-			}
383
-		}
384
-	}
382
+            }
383
+        }
384
+    }
385 385
 }
386 386
 
387 387
 // Replace relative paths by absolute web paths (e.g. './' => 'http://www.chamilo.org/courses/ABC/document/')
@@ -435,35 +435,35 @@  discard block
 block discarded – undo
435 435
         api_get_group_id()
436 436
     )
437 437
 ) {
438
-	$action = api_get_self().'?id='.$document_data['id'].'&'.api_get_cidreq();
438
+    $action = api_get_self().'?id='.$document_data['id'].'&'.api_get_cidreq();
439 439
     if ($is_certificate_mode) {
440 440
         $action .= '&curdirpath=/certificates&selectcat=1';
441 441
     }
442
-	$form = new FormValidator('formEdit', 'post', $action, null, array('class' => 'form-vertical'));
443
-
444
-	// Form title
445
-	$form->addElement('header', $nameTools);
446
-	$form->addElement('hidden', 'filename');
447
-	$form->addElement('hidden', 'extension');
448
-	$form->addElement('hidden', 'file_path');
449
-	$form->addElement('hidden', 'commentPath');
450
-	$form->addElement('hidden', 'showedit');
451
-	$form->addElement('hidden', 'origin');
452
-	$form->addElement('hidden', 'origin_opt');
442
+    $form = new FormValidator('formEdit', 'post', $action, null, array('class' => 'form-vertical'));
443
+
444
+    // Form title
445
+    $form->addElement('header', $nameTools);
446
+    $form->addElement('hidden', 'filename');
447
+    $form->addElement('hidden', 'extension');
448
+    $form->addElement('hidden', 'file_path');
449
+    $form->addElement('hidden', 'commentPath');
450
+    $form->addElement('hidden', 'showedit');
451
+    $form->addElement('hidden', 'origin');
452
+    $form->addElement('hidden', 'origin_opt');
453 453
     $form->addText('title', get_lang('Title'), true, array('cols-size' => [2, 10, 0], 'autofocus'));
454 454
 
455
-	$defaults['title'] = $document_data['title'];
455
+    $defaults['title'] = $document_data['title'];
456 456
 
457
-	$form->addElement('hidden', 'formSent');
458
-	$defaults['formSent'] = 1;
457
+    $form->addElement('hidden', 'formSent');
458
+    $defaults['formSent'] = 1;
459 459
 
460
-	$read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null;
460
+    $read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null;
461 461
 
462
-	// Desactivation of IE proprietary commenting tags inside the text before loading it on the online editor.
463
-	// This fix has been proposed by Hubert Borderiou, see Bug #573, http://support.chamilo.org/issues/573
464
-	$defaults['content'] = str_replace('<!--[', '<!-- [', $content);
462
+    // Desactivation of IE proprietary commenting tags inside the text before loading it on the online editor.
463
+    // This fix has been proposed by Hubert Borderiou, see Bug #573, http://support.chamilo.org/issues/573
464
+    $defaults['content'] = str_replace('<!--[', '<!-- [', $content);
465 465
 
466
-	// HotPotatoes tests are html files, but they should not be edited in order their functionality to be preserved.
466
+    // HotPotatoes tests are html files, but they should not be edited in order their functionality to be preserved.
467 467
 
468 468
     $showSystemFolders = api_get_course_setting('show_system_folders');
469 469
     $condition = stripos($dir, '/HotPotatoes_files') === false;
@@ -471,44 +471,44 @@  discard block
 block discarded – undo
471 471
         $condition = true;
472 472
     }
473 473
 
474
-	if (($extension == 'htm' || $extension == 'html') && $condition) {
475
-		if (empty($readonly) && $readonly == 0) {
474
+    if (($extension == 'htm' || $extension == 'html') && $condition) {
475
+        if (empty($readonly) && $readonly == 0) {
476 476
             $form->addHtmlEditor('content', '', true, true, $editorConfig);
477
-		}
478
-	}
477
+        }
478
+    }
479 479
 
480
-	if (!$group_document && !DocumentManager::is_my_shared_folder(api_get_user_id(), $currentDirPath, $sessionId)) {
481
-		// Updated on field
480
+    if (!$group_document && !DocumentManager::is_my_shared_folder(api_get_user_id(), $currentDirPath, $sessionId)) {
481
+        // Updated on field
482 482
         $display_date = date_to_str_ago($last_edit_date).
483
-			' <span class="dropbox_date">'.api_format_date(api_get_local_time($last_edit_date)).'</span>';
484
-		$form->addElement('static', null, get_lang('UpdatedOn'), $display_date);
485
-	}
483
+            ' <span class="dropbox_date">'.api_format_date(api_get_local_time($last_edit_date)).'</span>';
484
+        $form->addElement('static', null, get_lang('UpdatedOn'), $display_date);
485
+    }
486 486
 
487
-	$form->addElement('textarea', 'comment', get_lang('Comment'), ['cols-size' => [2, 10, 0]]);
487
+    $form->addElement('textarea', 'comment', get_lang('Comment'), ['cols-size' => [2, 10, 0]]);
488 488
 
489
-	if ($owner_id == api_get_user_id() || api_is_platform_admin()) {
490
-		$checked =& $form->addElement('checkbox', 'readonly', null, get_lang('ReadOnly'));
491
-		if ($readonly == 1) {
492
-			$checked->setChecked(true);
493
-		}
494
-	}
489
+    if ($owner_id == api_get_user_id() || api_is_platform_admin()) {
490
+        $checked =& $form->addElement('checkbox', 'readonly', null, get_lang('ReadOnly'));
491
+        if ($readonly == 1) {
492
+            $checked->setChecked(true);
493
+        }
494
+    }
495 495
 
496
-	if ($is_certificate_mode) {
497
-		$form->addButtonUpdate(get_lang('SaveCertificate'));
496
+    if ($is_certificate_mode) {
497
+        $form->addButtonUpdate(get_lang('SaveCertificate'));
498 498
     } else {
499
-		$form->addButtonUpdate(get_lang('SaveDocument'));
499
+        $form->addButtonUpdate(get_lang('SaveDocument'));
500 500
     }
501 501
 
502
-	$defaults['filename'] = $filename;
503
-	$defaults['extension'] = $extension;
504
-	$defaults['file_path'] = isset($_GET['file']) ? Security::remove_XSS($_GET['file']) : null;
505
-	$defaults['commentPath'] = $file;
506
-	$defaults['renameTo'] = $file_name;
507
-	$defaults['comment'] = $document_data['comment'];
508
-	$defaults['origin'] = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null;
509
-	$defaults['origin_opt'] = isset($_GET['origin_opt']) ? Security::remove_XSS($_GET['origin_opt']) : null;
502
+    $defaults['filename'] = $filename;
503
+    $defaults['extension'] = $extension;
504
+    $defaults['file_path'] = isset($_GET['file']) ? Security::remove_XSS($_GET['file']) : null;
505
+    $defaults['commentPath'] = $file;
506
+    $defaults['renameTo'] = $file_name;
507
+    $defaults['comment'] = $document_data['comment'];
508
+    $defaults['origin'] = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null;
509
+    $defaults['origin_opt'] = isset($_GET['origin_opt']) ? Security::remove_XSS($_GET['origin_opt']) : null;
510 510
 
511
-	$form->setDefaults($defaults);
511
+    $form->setDefaults($defaults);
512 512
 
513 513
     show_return(
514 514
         $parent_id,
@@ -518,25 +518,25 @@  discard block
 block discarded – undo
518 518
         $is_certificate_mode
519 519
     );
520 520
 
521
-	if ($is_certificate_mode) {
522
-		$all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(
523
-			api_get_user_id(),
524
-			api_get_course_id()
525
-		);
526
-		$str_info = '';
527
-		foreach ($all_information_by_create_certificate[0] as $info_value) {
528
-			$str_info .= $info_value.'<br/>';
529
-		}
530
-		$create_certificate=get_lang('CreateCertificateWithTags');
531
-		Display::display_normal_message(
532
-			$create_certificate.': <br /><br />'.$str_info,
533
-			false
534
-		);
535
-	}
536
-
537
-	if ($extension=='svg' && !api_browser_support('svg') && api_get_setting('enabled_support_svg') == 'true'){
538
-		Display::display_warning_message(get_lang('BrowserDontSupportsSVG'));
539
-	}
521
+    if ($is_certificate_mode) {
522
+        $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(
523
+            api_get_user_id(),
524
+            api_get_course_id()
525
+        );
526
+        $str_info = '';
527
+        foreach ($all_information_by_create_certificate[0] as $info_value) {
528
+            $str_info .= $info_value.'<br/>';
529
+        }
530
+        $create_certificate=get_lang('CreateCertificateWithTags');
531
+        Display::display_normal_message(
532
+            $create_certificate.': <br /><br />'.$str_info,
533
+            false
534
+        );
535
+    }
536
+
537
+    if ($extension=='svg' && !api_browser_support('svg') && api_get_setting('enabled_support_svg') == 'true'){
538
+        Display::display_warning_message(get_lang('BrowserDontSupportsSVG'));
539
+    }
540 540
     // HTML-editor
541 541
     echo '<div class="page-create">
542 542
             <div class="row" style="overflow:hidden">
@@ -563,26 +563,26 @@  discard block
 block discarded – undo
563 563
 */
564 564
 function change_name($base_work_dir, $source_file, $rename_to, $dir, $doc)
565 565
 {
566
-	$file_name_for_change = $base_work_dir.$dir.$source_file;
566
+    $file_name_for_change = $base_work_dir.$dir.$source_file;
567 567
     $rename_to = disable_dangerous_file($rename_to); // Avoid renaming to .htaccess file
568
-	$rename_to = my_rename($file_name_for_change, stripslashes($rename_to)); // fileManage API
569
-
570
-	if ($rename_to) {
571
-		if (isset($dir) && $dir != '') {
572
-			$source_file = $dir.$source_file;
573
-			$new_full_file_name = dirname($source_file).'/'.$rename_to;
574
-		} else {
575
-			$source_file = '/'.$source_file;
576
-			$new_full_file_name = '/'.$rename_to;
577
-		}
578
-
579
-		update_db_info('update', $source_file, $new_full_file_name); // fileManage API
568
+    $rename_to = my_rename($file_name_for_change, stripslashes($rename_to)); // fileManage API
569
+
570
+    if ($rename_to) {
571
+        if (isset($dir) && $dir != '') {
572
+            $source_file = $dir.$source_file;
573
+            $new_full_file_name = dirname($source_file).'/'.$rename_to;
574
+        } else {
575
+            $source_file = '/'.$source_file;
576
+            $new_full_file_name = '/'.$rename_to;
577
+        }
578
+
579
+        update_db_info('update', $source_file, $new_full_file_name); // fileManage API
580 580
         Display::addFlash(Display::return_message(get_lang('fileModified')));
581 581
 
582
-		return true;
583
-	} else {
582
+        return true;
583
+    } else {
584 584
         Display::addFlash(Display::return_message(get_lang('FileExists')));
585
-	}
585
+    }
586 586
 }
587 587
 
588 588
 //return button back to
@@ -595,32 +595,32 @@  discard block
 block discarded – undo
595 595
     global $parent_id;
596 596
     $url = api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq().'&id='.$parent_id;
597 597
 
598
-	if ($is_certificate_mode) {
599
-		$selectedCategory = (isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : '');
600
-		$actionsLeft .= '<a href="document.php?curdirpath='. $selectedCategory .'&selectcat=' . $selectedCategory .'">'.
598
+    if ($is_certificate_mode) {
599
+        $selectedCategory = (isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : '');
600
+        $actionsLeft .= '<a href="document.php?curdirpath='. $selectedCategory .'&selectcat=' . $selectedCategory .'">'.
601 601
             Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview'),'',ICON_SIZE_MEDIUM).'</a>';
602 602
         $actionsLeft .= '<a id="hide_bar_template" href="#">'.Display::return_icon('expand.png',get_lang('Expand'),array('id'=>'expand'),ICON_SIZE_MEDIUM).Display::return_icon('contract.png',get_lang('Collapse'),array('id'=>'contract', 'class'=>'hide'),ICON_SIZE_MEDIUM).'</a>';
603
-	} elseif($call_from_tool=='slideshow') {
604
-		$actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/document/slideshow.php?slide_id='.$slide_id.'&curdirpath='.Security::remove_XSS(urlencode($_GET['curdirpath'])).'">'.
603
+    } elseif($call_from_tool=='slideshow') {
604
+        $actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/document/slideshow.php?slide_id='.$slide_id.'&curdirpath='.Security::remove_XSS(urlencode($_GET['curdirpath'])).'">'.
605 605
             Display::return_icon('slideshow.png', get_lang('BackTo').' '.get_lang('ViewSlideshow'),'',ICON_SIZE_MEDIUM).'</a>';
606
-	} elseif($call_from_tool=='editdraw') {
607
-		$actionsLeft .= '<a href="'.$url.'">'.
606
+    } elseif($call_from_tool=='editdraw') {
607
+        $actionsLeft .= '<a href="'.$url.'">'.
608 608
             Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
609
-		$actionsLeft .= '<a href="javascript:history.back(1)">'.Display::return_icon('draw.png', get_lang('BackTo').' '.get_lang('Draw'), array(), 32).'</a>';
610
-	} elseif($call_from_tool=='editodf') {
609
+        $actionsLeft .= '<a href="javascript:history.back(1)">'.Display::return_icon('draw.png', get_lang('BackTo').' '.get_lang('Draw'), array(), 32).'</a>';
610
+    } elseif($call_from_tool=='editodf') {
611 611
         $actionsLeft .= '<a href="'.$url.'">'.
612 612
             Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
613 613
         $actionsLeft .= '<a href="javascript:history.back(1)">'.Display::return_icon('draw.png', get_lang('BackTo').' '.get_lang('Write'), array(), 32).'</a>';
614 614
         $actionsLeft .= '<a id="hide_bar_template" href="#">'.Display::return_icon('expand.png',get_lang('Expand'),array('id'=>'expand'),ICON_SIZE_MEDIUM).Display::return_icon('contract.png',get_lang('Collapse'),array('id'=>'contract', 'class'=>'hide'),ICON_SIZE_MEDIUM).'</a>';
615 615
     } elseif($call_from_tool=='editpaint'){
616
-		$actionsLeft .= '<a href="'.$url.'">'.
616
+        $actionsLeft .= '<a href="'.$url.'">'.
617 617
             Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), array(), ICON_SIZE_MEDIUM).'</a>';
618
-		$actionsLeft .= '<a href="javascript:history.back(1)">'.Display::return_icon('paint.png', get_lang('BackTo').' '.get_lang('Paint'), array(), 32).'</a>';
619
-	} else {
620
-		$actionsLeft .= '<a href="'.$url.'">'.
618
+        $actionsLeft .= '<a href="javascript:history.back(1)">'.Display::return_icon('paint.png', get_lang('BackTo').' '.get_lang('Paint'), array(), 32).'</a>';
619
+    } else {
620
+        $actionsLeft .= '<a href="'.$url.'">'.
621 621
             Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
622 622
         $actionsLeft .= '<a id="hide_bar_template" href="#">'.Display::return_icon('expand.png',get_lang('Expand'),array('id'=>'expand'),ICON_SIZE_MEDIUM).Display::return_icon('contract.png',get_lang('Collapse'),array('id'=>'contract', 'class'=>'hide'),ICON_SIZE_MEDIUM).'</a>';
623
-	}
623
+    }
624 624
     
625 625
     echo $toolbar = Display::toolbarAction('actions-documents', array(0 => $actionsLeft, 1 => ''));
626 626
 }
Please login to merge, or discard this patch.
main/exercise/answer.class.php 1 patch
Indentation   +324 added lines, -324 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
     public $new_destination; // id of the next question if feedback option is set to Directfeedback
38 38
     public $course; //Course information
39 39
     public $iid;
40
-	public $questionJSId;
41
-	public $standalone;
40
+    public $questionJSId;
41
+    public $standalone;
42 42
 
43 43
     /**
44 44
      * constructor of the class
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
         return [];
160 160
     }
161 161
 
162
-     /**
163
-     * returns all answer ids from this question Id
164
-     *
165
-     * @author Yoselyn Castillo
166
-     * @return array - $id (answer ids)
167
-     */
162
+        /**
163
+         * returns all answer ids from this question Id
164
+         *
165
+         * @author Yoselyn Castillo
166
+         * @return array - $id (answer ids)
167
+         */
168 168
     public function selectAnswerId()
169 169
     {
170 170
         $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         }
185 185
 
186 186
         return $id;
187
-	}
187
+    }
188 188
 
189 189
     /**
190 190
      * Reads answer information from the data base ordered by parameter
@@ -195,23 +195,23 @@  discard block
 block discarded – undo
195 195
      */
196 196
     public function readOrderedBy($field, $order='ASC')
197 197
     {
198
-		$field = Database::escape_string($field);
199
-		if (empty($field)) {
200
-			$field = 'position';
201
-		}
198
+        $field = Database::escape_string($field);
199
+        if (empty($field)) {
200
+            $field = 'position';
201
+        }
202 202
 
203
-		if ($order != 'ASC' && $order!='DESC') {
204
-			$order = 'ASC';
205
-		}
203
+        if ($order != 'ASC' && $order!='DESC') {
204
+            $order = 'ASC';
205
+        }
206 206
 
207
-		$TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
208
-		$TBL_QUIZ = Database::get_course_table(TABLE_QUIZ_QUESTION);
209
-		$questionId = intval($this->questionId);
207
+        $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
208
+        $TBL_QUIZ = Database::get_course_table(TABLE_QUIZ_QUESTION);
209
+        $questionId = intval($this->questionId);
210 210
 
211
-		$sql = "SELECT type FROM $TBL_QUIZ
211
+        $sql = "SELECT type FROM $TBL_QUIZ
212 212
 		        WHERE c_id = {$this->course_id} AND id = $questionId";
213
-		$result_question = Database::query($sql);
214
-		$questionType = Database::fetch_array($result_question);
213
+        $result_question = Database::query($sql);
214
+        $questionType = Database::fetch_array($result_question);
215 215
 
216 216
         if ($questionType['type'] == DRAGGABLE) {
217 217
             // Random is done by submit.js.tpl
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
             return true;
221 221
         }
222 222
 
223
-		$sql = "SELECT
223
+        $sql = "SELECT
224 224
 		            answer,
225 225
 		            correct,
226 226
 		            comment,
@@ -236,16 +236,16 @@  discard block
 block discarded – undo
236 236
                     c_id = {$this->course_id} AND
237 237
                     question_id='".$questionId."'
238 238
                 ORDER BY $field $order";
239
-		$result=Database::query($sql);
240
-
241
-		$i = 1;
242
-		// while a record is found
243
-		$doubt_data = null;
244
-		while ($object = Database::fetch_object($result)) {
245
-		    if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && $object->position == 666) {
246
-		        $doubt_data = $object;
239
+        $result=Database::query($sql);
240
+
241
+        $i = 1;
242
+        // while a record is found
243
+        $doubt_data = null;
244
+        while ($object = Database::fetch_object($result)) {
245
+            if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && $object->position == 666) {
246
+                $doubt_data = $object;
247 247
                 continue;
248
-		    }
248
+            }
249 249
             $this->answer[$i] = $object->answer;
250 250
             $this->correct[$i] = $object->correct;
251 251
             $this->comment[$i] = $object->comment;
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
             $this->autoId[$i] = $object->id_auto;
258 258
             $this->iid[$i] = $object->iid;
259 259
             $i++;
260
-		}
260
+        }
261 261
 
262
-		if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && !empty($doubt_data)) {
262
+        if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && !empty($doubt_data)) {
263 263
             $this->answer[$i] = $doubt_data->answer;
264 264
             $this->correct[$i] = $doubt_data->correct;
265 265
             $this->comment[$i] = $doubt_data->comment;
@@ -271,88 +271,88 @@  discard block
 block discarded – undo
271 271
             $this->autoId[$i] = $doubt_data->id_auto;
272 272
             $this->iid[$i] = $doubt_data->iid;
273 273
             $i++;
274
-	    }
274
+        }
275 275
         $this->nbrAnswers = $i-1;
276
-	}
277
-
278
-	/**
279
-	 * returns the autoincrement id identificator
280
-	 *
281
-	 * @author Juan Carlos Ra�a
282
-	 * @return integer - answer num
283
-	 */
276
+    }
277
+
278
+    /**
279
+     * returns the autoincrement id identificator
280
+     *
281
+     * @author Juan Carlos Ra�a
282
+     * @return integer - answer num
283
+     */
284 284
     public function selectAutoId($id)
285 285
     {
286
-		return isset($this->autoId[$id]) ? $this->autoId[$id] : 0;
287
-	}
288
-
289
-	/**
290
-	 * returns the number of answers in this question
291
-	 *
292
-	 * @author Olivier Brouckaert
293
-	 * @return integer - number of answers
294
-	 */
295
-	public function selectNbrAnswers()
286
+        return isset($this->autoId[$id]) ? $this->autoId[$id] : 0;
287
+    }
288
+
289
+    /**
290
+     * returns the number of answers in this question
291
+     *
292
+     * @author Olivier Brouckaert
293
+     * @return integer - number of answers
294
+     */
295
+    public function selectNbrAnswers()
296
+    {
297
+        return $this->nbrAnswers;
298
+    }
299
+
300
+    /**
301
+     * returns the question ID which the answers belong to
302
+     *
303
+     * @author Olivier Brouckaert
304
+     * @return integer - the question ID
305
+     */
306
+    public function selectQuestionId()
296 307
     {
297
-		return $this->nbrAnswers;
298
-	}
299
-
300
-	/**
301
-	 * returns the question ID which the answers belong to
302
-	 *
303
-	 * @author Olivier Brouckaert
304
-	 * @return integer - the question ID
305
-	 */
306
-	public function selectQuestionId()
308
+        return $this->questionId;
309
+    }
310
+
311
+    /**
312
+     * returns the question ID of the destination question
313
+     *
314
+     * @author Julio Montoya
315
+     * @param integer $id
316
+     * @return integer - the question ID
317
+     */
318
+    public function selectDestination($id)
307 319
     {
308
-		return $this->questionId;
309
-	}
310
-
311
-	/**
312
-	 * returns the question ID of the destination question
313
-	 *
314
-	 * @author Julio Montoya
315
-	 * @param integer $id
316
-	 * @return integer - the question ID
317
-	 */
318
-	public function selectDestination($id)
320
+        return isset($this->destination[$id]) ? $this->destination[$id] : null;
321
+    }
322
+
323
+    /**
324
+     * returns the answer title
325
+     *
326
+     * @author Olivier Brouckaert
327
+     * @param - integer $id - answer ID
328
+     * @return string - answer title
329
+     */
330
+    public function selectAnswer($id)
319 331
     {
320
-		return isset($this->destination[$id]) ? $this->destination[$id] : null;
321
-	}
332
+        return isset($this->answer[$id]) ? $this->answer[$id] : null;
333
+    }
322 334
 
323 335
     /**
324
-	 * returns the answer title
325
-	 *
326
-	 * @author Olivier Brouckaert
327
-	 * @param - integer $id - answer ID
328
-	 * @return string - answer title
329
-	 */
330
-	public function selectAnswer($id)
331
-	{
332
-		return isset($this->answer[$id]) ? $this->answer[$id] : null;
333
-	}
334
-
335
-	/**
336
-	 * return array answer by id else return a bool
337
-	 * @param integer $auto_id
338
-	 */
339
-	public function selectAnswerByAutoId($auto_id)
340
-	{
341
-		$TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
342
-
343
-		$auto_id = intval($auto_id);
344
-		$sql = "SELECT id, answer, id_auto FROM $TBL_ANSWER
336
+     * return array answer by id else return a bool
337
+     * @param integer $auto_id
338
+     */
339
+    public function selectAnswerByAutoId($auto_id)
340
+    {
341
+        $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
342
+
343
+        $auto_id = intval($auto_id);
344
+        $sql = "SELECT id, answer, id_auto FROM $TBL_ANSWER
345 345
 				WHERE c_id = {$this->course_id} AND id_auto='$auto_id'";
346
-		$rs = Database::query($sql);
346
+        $rs = Database::query($sql);
347 347
 
348
-		if (Database::num_rows($rs) > 0) {
349
-			$row = Database::fetch_array($rs, 'ASSOC');
348
+        if (Database::num_rows($rs) > 0) {
349
+            $row = Database::fetch_array($rs, 'ASSOC');
350 350
 
351
-			return $row;
352
-		}
351
+            return $row;
352
+        }
353 353
 
354
-		return false;
355
-	}
354
+        return false;
355
+    }
356 356
 
357 357
     /**
358 358
      * returns the answer title from an answer's position
@@ -361,18 +361,18 @@  discard block
 block discarded – undo
361 361
      * @param - integer $id - answer ID
362 362
      * @return bool - answer title
363 363
      */
364
-	public function selectAnswerIdByPosition($pos)
365
-	{
366
-		foreach ($this->position as $k => $v) {
367
-			if ($v != $pos) {
368
-				continue;
369
-			}
364
+    public function selectAnswerIdByPosition($pos)
365
+    {
366
+        foreach ($this->position as $k => $v) {
367
+            if ($v != $pos) {
368
+                continue;
369
+            }
370 370
 
371
-			return $k;
372
-		}
371
+            return $k;
372
+        }
373 373
 
374
-		return false;
375
-	}
374
+        return false;
375
+    }
376 376
 
377 377
     /**
378 378
      * Returns a list of answers
@@ -381,18 +381,18 @@  discard block
 block discarded – undo
381 381
      * of (id, answer, comment, grade) and grade=weighting
382 382
      */
383 383
     public function getAnswersList($decode = false)
384
-     {
385
-	 	$list = array();
386
-         for ($i = 1; $i <= $this->nbrAnswers; $i++) {
387
-             if (!empty($this->answer[$i])) {
388
-
389
-	 			//Avoid problems when parsing elements with accents
390
-	 			if ($decode) {
391
-	        		$this->answer[$i] 	= api_html_entity_decode($this->answer[$i], ENT_QUOTES, api_get_system_encoding());
392
-	        		$this->comment[$i]	= api_html_entity_decode($this->comment[$i], ENT_QUOTES, api_get_system_encoding());
393
-	 			}
394
-
395
-	 			$list[] = array(
384
+        {
385
+            $list = array();
386
+            for ($i = 1; $i <= $this->nbrAnswers; $i++) {
387
+                if (!empty($this->answer[$i])) {
388
+
389
+                    //Avoid problems when parsing elements with accents
390
+                    if ($decode) {
391
+                    $this->answer[$i] 	= api_html_entity_decode($this->answer[$i], ENT_QUOTES, api_get_system_encoding());
392
+                    $this->comment[$i]	= api_html_entity_decode($this->comment[$i], ENT_QUOTES, api_get_system_encoding());
393
+                    }
394
+
395
+                    $list[] = array(
396 396
                     'id' => $i,
397 397
                     'answer' => $this->answer[$i],
398 398
                     'comment' => $this->comment[$i],
@@ -401,137 +401,137 @@  discard block
 block discarded – undo
401 401
                     'hotspot_type' => $this->hotspot_type[$i],
402 402
                     'correct' => $this->correct[$i],
403 403
                     'destination' => $this->destination[$i]
404
-				);
404
+                );
405
+            }
405 406
             }
406
-	 	}
407 407
 
408
-	 	return $list;
409
-	 }
408
+            return $list;
409
+        }
410 410
 
411
-	/**
412
-	 * Returns a list of grades
413
-	 * @author Yannick Warnier <[email protected]>
414
-	 * @return array	List of grades where grade=weighting (?)
415
-	 */
411
+    /**
412
+     * Returns a list of grades
413
+     * @author Yannick Warnier <[email protected]>
414
+     * @return array	List of grades where grade=weighting (?)
415
+     */
416 416
     public function getGradesList()
417
-     {
418
-	 	$list = array();
419
-	 	for ($i = 0; $i<$this->nbrAnswers;$i++){
420
-	 		if(!empty($this->answer[$i])){
421
-	 			$list[$i] = $this->weighting[$i];
422
-	 		}
423
-	 	}
424
-	 	return $list;
425
-	 }
426
-
427
-	 /**
428
-	  * Returns the question type
429
-	  * @author	Yannick Warnier <[email protected]>
430
-	  * @return	integer	The type of the question this answer is bound to
431
-	  */
417
+        {
418
+            $list = array();
419
+            for ($i = 0; $i<$this->nbrAnswers;$i++){
420
+                if(!empty($this->answer[$i])){
421
+                    $list[$i] = $this->weighting[$i];
422
+                }
423
+            }
424
+            return $list;
425
+        }
426
+
427
+        /**
428
+         * Returns the question type
429
+         * @author	Yannick Warnier <[email protected]>
430
+         * @return	integer	The type of the question this answer is bound to
431
+         */
432 432
     public function getQuestionType()
433
-     {
434
-	 	$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
435
-	 	$sql = "SELECT type FROM $TBL_QUESTIONS
433
+        {
434
+            $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
435
+            $sql = "SELECT type FROM $TBL_QUESTIONS
436 436
 	 	        WHERE c_id = {$this->course_id} AND id = '".$this->questionId."'";
437
-	 	$res = Database::query($sql);
438
-	 	if (Database::num_rows($res)<=0){
439
-	 		return null;
440
-	 	}
441
-	 	$row = Database::fetch_array($res);
442
-
443
-	 	return $row['type'];
444
-	 }
445
-
446
-
447
-	/**
448
-	 * tells if answer is correct or not
449
-	 *
450
-	 * @author Olivier Brouckaert
451
-	 * @param - integer $id - answer ID
452
-	 * @return integer - 0 if bad answer, not 0 if good answer
453
-	 */
437
+            $res = Database::query($sql);
438
+            if (Database::num_rows($res)<=0){
439
+                return null;
440
+            }
441
+            $row = Database::fetch_array($res);
442
+
443
+            return $row['type'];
444
+        }
445
+
446
+
447
+    /**
448
+     * tells if answer is correct or not
449
+     *
450
+     * @author Olivier Brouckaert
451
+     * @param - integer $id - answer ID
452
+     * @return integer - 0 if bad answer, not 0 if good answer
453
+     */
454 454
     public function isCorrect($id)
455
-	{
456
-		return isset($this->correct[$id]) ? $this->correct[$id] : null;
457
-	}
458
-
459
-	/**
460
-	 * returns answer comment
461
-	 *
462
-	 * @author Olivier Brouckaert
463
-	 * @param - integer $id - answer ID
464
-	 * @return string - answer comment
465
-	 */
455
+    {
456
+        return isset($this->correct[$id]) ? $this->correct[$id] : null;
457
+    }
458
+
459
+    /**
460
+     * returns answer comment
461
+     *
462
+     * @author Olivier Brouckaert
463
+     * @param - integer $id - answer ID
464
+     * @return string - answer comment
465
+     */
466 466
     public function selectComment($id)
467
-	{
467
+    {
468 468
         return isset($this->comment[$id]) ? $this->comment[$id] : null;
469
-	}
470
-
471
-	/**
472
-	 * returns answer weighting
473
-	 *
474
-	 * @author Olivier Brouckaert
475
-	 * @param - integer $id - answer ID
476
-	 * @param integer $id
477
-	 * @return integer - answer weighting
478
-	 */
469
+    }
470
+
471
+    /**
472
+     * returns answer weighting
473
+     *
474
+     * @author Olivier Brouckaert
475
+     * @param - integer $id - answer ID
476
+     * @param integer $id
477
+     * @return integer - answer weighting
478
+     */
479 479
     public function selectWeighting($id)
480
-	{
481
-		return isset($this->weighting[$id]) ? $this->weighting[$id] : null;
482
-	}
483
-
484
-	/**
485
-	 * returns answer position
486
-	 *
487
-	 * @author Olivier Brouckaert
488
-	 * @param - integer $id - answer ID
489
-	 * @return integer - answer position
490
-	 */
491
-	function selectPosition($id)
492
-	{
493
-		return isset($this->position[$id]) ? $this->position[$id] : null;
494
-	}
495
-
496
-	/**
497
-	 * returns answer hotspot coordinates
498
-	 *
499
-	 * @author	Olivier Brouckaert
500
-	 * @param	integer	Answer ID
501
-	 * @param integer $id
502
-	 * @return	integer	Answer position
503
-	 */
480
+    {
481
+        return isset($this->weighting[$id]) ? $this->weighting[$id] : null;
482
+    }
483
+
484
+    /**
485
+     * returns answer position
486
+     *
487
+     * @author Olivier Brouckaert
488
+     * @param - integer $id - answer ID
489
+     * @return integer - answer position
490
+     */
491
+    function selectPosition($id)
492
+    {
493
+        return isset($this->position[$id]) ? $this->position[$id] : null;
494
+    }
495
+
496
+    /**
497
+     * returns answer hotspot coordinates
498
+     *
499
+     * @author	Olivier Brouckaert
500
+     * @param	integer	Answer ID
501
+     * @param integer $id
502
+     * @return	integer	Answer position
503
+     */
504 504
     public function selectHotspotCoordinates($id)
505
-	{
506
-		return isset($this->hotspot_coordinates[$id]) ? $this->hotspot_coordinates[$id] : null;
507
-	}
508
-
509
-	/**
510
-	 * returns answer hotspot type
511
-	 *
512
-	 * @author	Toon Keppens
513
-	 * @param	integer		Answer ID
514
-	 * @param integer $id
515
-	 * @return	integer		Answer position
516
-	 */
505
+    {
506
+        return isset($this->hotspot_coordinates[$id]) ? $this->hotspot_coordinates[$id] : null;
507
+    }
508
+
509
+    /**
510
+     * returns answer hotspot type
511
+     *
512
+     * @author	Toon Keppens
513
+     * @param	integer		Answer ID
514
+     * @param integer $id
515
+     * @return	integer		Answer position
516
+     */
517 517
     public function selectHotspotType($id)
518
-	{
519
-		return isset($this->hotspot_type[$id]) ? $this->hotspot_type[$id] : null;
520
-	}
521
-
522
-	/**
523
-	 * Creates a new answer
524
-	 *
525
-	 * @author Olivier Brouckaert
526
-	 * @param string 	$answer answer title
527
-	 * @param integer 	$correct 0 if bad answer, not 0 if good answer
528
-	 * @param string 	$comment answer comment
529
-	 * @param integer 	$weighting answer weighting
530
-	 * @param integer 	$position answer position
531
-	 * @param array    $new_hotspot_coordinates Coordinates for hotspot exercises (optional)
532
-	 * @param integer	$new_hotspot_type Type for hotspot exercises (optional)
518
+    {
519
+        return isset($this->hotspot_type[$id]) ? $this->hotspot_type[$id] : null;
520
+    }
521
+
522
+    /**
523
+     * Creates a new answer
524
+     *
525
+     * @author Olivier Brouckaert
526
+     * @param string 	$answer answer title
527
+     * @param integer 	$correct 0 if bad answer, not 0 if good answer
528
+     * @param string 	$comment answer comment
529
+     * @param integer 	$weighting answer weighting
530
+     * @param integer 	$position answer position
531
+     * @param array    $new_hotspot_coordinates Coordinates for hotspot exercises (optional)
532
+     * @param integer	$new_hotspot_type Type for hotspot exercises (optional)
533 533
      * @param string   $destination
534
-	 */
534
+     */
535 535
     public function createAnswer(
536 536
         $answer,
537 537
         $correct,
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
         $new_hotspot_type = null,
543 543
         $destination = ''
544 544
     ) {
545
-		$this->new_nbrAnswers++;
545
+        $this->new_nbrAnswers++;
546 546
         $id = $this->new_nbrAnswers;
547 547
         $this->new_answer[$id] = $answer;
548 548
         $this->new_correct[$id] = $correct;
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
         $this->new_hotspot_coordinates[$id] = $new_hotspot_coordinates;
553 553
         $this->new_hotspot_type[$id] = $new_hotspot_type;
554 554
         $this->new_destination[$id] = $destination;
555
-	}
555
+    }
556 556
 
557 557
     /**
558 558
      * Updates an answer
@@ -593,31 +593,31 @@  discard block
 block discarded – undo
593 593
         ];
594 594
 
595 595
         Database::update($answerTable, $params, ['iid = ?' => intval($iid)]);
596
-	}
596
+    }
597 597
 
598
-	/**
599
-	 * Records answers into the data base
600
-	 *
601
-	 * @author Olivier Brouckaert
602
-	 */
598
+    /**
599
+     * Records answers into the data base
600
+     *
601
+     * @author Olivier Brouckaert
602
+     */
603 603
     public function save()
604 604
     {
605
-		$answerTable = Database::get_course_table(TABLE_QUIZ_ANSWER);
606
-		$questionId = intval($this->questionId);
605
+        $answerTable = Database::get_course_table(TABLE_QUIZ_ANSWER);
606
+        $questionId = intval($this->questionId);
607 607
 
608
-		$c_id = $this->course['real_id'];
608
+        $c_id = $this->course['real_id'];
609 609
         $correctList = [];
610 610
         $answerList = [];
611 611
 
612
-		for ($i=1; $i <= $this->new_nbrAnswers; $i++) {
613
-			$answer = $this->new_answer[$i];
614
-			$correct = $this->new_correct[$i];
615
-			$comment = $this->new_comment[$i];
616
-			$weighting = $this->new_weighting[$i];
617
-			$position = $this->new_position[$i];
618
-			$hotspot_coordinates = $this->new_hotspot_coordinates[$i];
619
-			$hotspot_type = $this->new_hotspot_type[$i];
620
-			$destination = $this->new_destination[$i];
612
+        for ($i=1; $i <= $this->new_nbrAnswers; $i++) {
613
+            $answer = $this->new_answer[$i];
614
+            $correct = $this->new_correct[$i];
615
+            $comment = $this->new_comment[$i];
616
+            $weighting = $this->new_weighting[$i];
617
+            $position = $this->new_position[$i];
618
+            $hotspot_coordinates = $this->new_hotspot_coordinates[$i];
619
+            $hotspot_type = $this->new_hotspot_type[$i];
620
+            $destination = $this->new_destination[$i];
621 621
             $autoId = $this->selectAutoId($i);
622 622
             $iid = isset($this->iid[$i]) ? $this->iid[$i] : 0;
623 623
 
@@ -716,37 +716,37 @@  discard block
 block discarded – undo
716 716
             }
717 717
         }
718 718
 
719
-		// moves $new_* arrays
720
-		$this->answer = $this->new_answer;
721
-		$this->correct = $this->new_correct;
722
-		$this->comment = $this->new_comment;
723
-		$this->weighting = $this->new_weighting;
724
-		$this->position = $this->new_position;
725
-		$this->hotspot_coordinates = $this->new_hotspot_coordinates;
726
-		$this->hotspot_type = $this->new_hotspot_type;
727
-
728
-		$this->nbrAnswers = $this->new_nbrAnswers;
729
-		$this->destination = $this->new_destination;
730
-		// clears $new_* arrays
731
-
732
-		$this->cancel();
733
-	}
734
-
735
-	/**
736
-	 * Duplicates answers by copying them into another question
737
-	 *
738
-	 * @author Olivier Brouckaert
739
-	 * @param  int question id
719
+        // moves $new_* arrays
720
+        $this->answer = $this->new_answer;
721
+        $this->correct = $this->new_correct;
722
+        $this->comment = $this->new_comment;
723
+        $this->weighting = $this->new_weighting;
724
+        $this->position = $this->new_position;
725
+        $this->hotspot_coordinates = $this->new_hotspot_coordinates;
726
+        $this->hotspot_type = $this->new_hotspot_type;
727
+
728
+        $this->nbrAnswers = $this->new_nbrAnswers;
729
+        $this->destination = $this->new_destination;
730
+        // clears $new_* arrays
731
+
732
+        $this->cancel();
733
+    }
734
+
735
+    /**
736
+     * Duplicates answers by copying them into another question
737
+     *
738
+     * @author Olivier Brouckaert
739
+     * @param  int question id
740 740
      * @param  array destination course info (result of the function api_get_course_info() )
741 741
      * @param string $newQuestionId
742
-	 */
742
+     */
743 743
     public function duplicate($newQuestionId, $course_info = null)
744 744
     {
745 745
         if (empty($course_info)) {
746 746
             $course_info = $this->course;
747 747
         }
748 748
 
749
-		$TBL_REPONSES = Database :: get_course_table(TABLE_QUIZ_ANSWER);
749
+        $TBL_REPONSES = Database :: get_course_table(TABLE_QUIZ_ANSWER);
750 750
         $fixed_list = array();
751 751
 
752 752
         if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE ||
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 
761 761
             if (!empty($origin_options)) {
762 762
                 foreach ($origin_options as $item) {
763
-            	   $new_option_list[] = $item['id'];
763
+                    $new_option_list[] = $item['id'];
764 764
                 }
765 765
             }
766 766
 
@@ -774,12 +774,12 @@  discard block
 block discarded – undo
774 774
             }
775 775
         }
776 776
 
777
-		// if at least one answer
778
-		if ($this->nbrAnswers) {
779
-			// inserts new answers into data base
780
-			$c_id = $course_info['real_id'];
777
+        // if at least one answer
778
+        if ($this->nbrAnswers) {
779
+            // inserts new answers into data base
780
+            $c_id = $course_info['real_id'];
781 781
 
782
-			for ($i=1;$i <= $this->nbrAnswers;$i++) {
782
+            for ($i=1;$i <= $this->nbrAnswers;$i++) {
783 783
                 if ($this->course['id'] != $course_info['id']) {
784 784
                     $this->answer[$i] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
785 785
                         $this->answer[$i],
@@ -793,8 +793,8 @@  discard block
 block discarded – undo
793 793
                     );
794 794
                 }
795 795
 
796
-				$answer = $this->answer[$i];
797
-				$correct = $this->correct[$i];
796
+                $answer = $this->answer[$i];
797
+                $correct = $this->correct[$i];
798 798
 
799 799
                 if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE ||
800 800
                     self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE
@@ -802,12 +802,12 @@  discard block
 block discarded – undo
802 802
                     $correct = $fixed_list[intval($correct)];
803 803
                 }
804 804
 
805
-				$comment = $this->comment[$i];
806
-				$weighting = $this->weighting[$i];
807
-				$position = $this->position[$i];
808
-				$hotspot_coordinates = $this->hotspot_coordinates[$i];
809
-				$hotspot_type = $this->hotspot_type[$i];
810
-				$destination = $this->destination[$i];
805
+                $comment = $this->comment[$i];
806
+                $weighting = $this->weighting[$i];
807
+                $position = $this->position[$i];
808
+                $hotspot_coordinates = $this->hotspot_coordinates[$i];
809
+                $hotspot_type = $this->hotspot_type[$i];
810
+                $destination = $this->destination[$i];
811 811
 
812 812
                 $params = [
813 813
                     'c_id' => $c_id,
@@ -827,9 +827,9 @@  discard block
 block discarded – undo
827 827
                     $sql = "UPDATE $TBL_REPONSES SET id = iid, id_auto = iid WHERE iid = $id";
828 828
                     Database::query($sql);
829 829
                 }
830
-			}
830
+            }
831 831
         }
832
-	}
832
+    }
833 833
 
834 834
     /**
835 835
      * Get the necessary JavaScript for some answers
@@ -847,25 +847,25 @@  discard block
 block discarded – undo
847 847
             </script>";
848 848
     }
849 849
 
850
-	/**
851
-	 * Check if a answer is correct by an answer auto id
852
-	 * @param $needle int The answer auto id
853
-	 * @return bool
854
-	 */
855
-	public function isCorrectByAutoId($needle)
856
-	{
857
-		$key = 0;
858
-
859
-		foreach ($this->autoId as $autoIdKey => $autoId) {
860
-			if ($autoId == $needle) {
861
-				$key = $autoIdKey;
862
-			}
863
-		}
864
-
865
-		if (!$key) {
866
-			return false;
867
-		}
868
-
869
-		return $this->isCorrect($key) ? true : false;
870
-	}
850
+    /**
851
+     * Check if a answer is correct by an answer auto id
852
+     * @param $needle int The answer auto id
853
+     * @return bool
854
+     */
855
+    public function isCorrectByAutoId($needle)
856
+    {
857
+        $key = 0;
858
+
859
+        foreach ($this->autoId as $autoIdKey => $autoId) {
860
+            if ($autoId == $needle) {
861
+                $key = $autoIdKey;
862
+            }
863
+        }
864
+
865
+        if (!$key) {
866
+            return false;
867
+        }
868
+
869
+        return $this->isCorrect($key) ? true : false;
870
+    }
871 871
 }
Please login to merge, or discard this patch.
main/exercise/export/scorm/scorm_classes.php 1 patch
Indentation   +777 added lines, -777 removed lines patch added patch discarded remove patch
@@ -20,140 +20,140 @@  discard block
 block discarded – undo
20 20
 {
21 21
     public $js_id;
22 22
     public $answer;
23
-	/**
24
-	 * Returns the HTML + JS flow corresponding to one question
25
-	 *
26
-	 * @param int $questionId The question ID
27
-	 * @param bool $standalone (ie including XML tag, DTD declaration, etc)
28
-	 * @param int  $js_id The JavaScript ID for this question.
29
-	 * Due to the nature of interactions, we must have a natural sequence for
30
-	 * questions in the generated JavaScript.
31
-	 * @param integer $js_id
23
+    /**
24
+     * Returns the HTML + JS flow corresponding to one question
25
+     *
26
+     * @param int $questionId The question ID
27
+     * @param bool $standalone (ie including XML tag, DTD declaration, etc)
28
+     * @param int  $js_id The JavaScript ID for this question.
29
+     * Due to the nature of interactions, we must have a natural sequence for
30
+     * questions in the generated JavaScript.
31
+     * @param integer $js_id
32 32
      * @return string|array
33
-	 */
34
-	public static function export_question($questionId, $standalone = true, $js_id)
35
-	{
36
-		$question = new ScormQuestion();
37
-		$qst = $question->read($questionId);
38
-		if (!$qst) {
39
-			return '';
40
-		}
41
-		$question->id = $qst->id;
42
-		$question->js_id = $js_id;
43
-		$question->type = $qst->type;
44
-		$question->question = $qst->question;
45
-		$question->description = $qst->description;
46
-		$question->weighting=$qst->weighting;
47
-		$question->position=$qst->position;
48
-		$question->picture=$qst->picture;
49
-		$assessmentItem = new ScormAssessmentItem($question, $standalone);
50
-
51
-		return $assessmentItem->export();
52
-	}
53
-
54
-	/**
55
-	 * Include the correct answer class and create answer
56
-	 */
57
-	public function setAnswer()
58
-	{
59
-		switch ($this->type) {
60
-			case MCUA:
61
-				$this->answer = new ScormAnswerMultipleChoice($this->id);
62
-				$this->answer->questionJSId = $this->js_id;
63
-				break;
64
-			case MCMA:
65
-			case GLOBAL_MULTIPLE_ANSWER:
66
-				$this->answer = new ScormAnswerMultipleChoice($this->id);
67
-				$this->answer->questionJSId = $this->js_id;
68
-				break;
69
-			case TF:
70
-				$this->answer = new ScormAnswerTrueFalse($this->id);
71
-				$this->answer->questionJSId = $this->js_id;
72
-				break;
73
-			case FIB:
74
-				$this->answer = new ScormAnswerFillInBlanks($this->id);
75
-				$this->answer->questionJSId = $this->js_id;
76
-				break;
77
-			case MATCHING:
78
-			case MATCHING_DRAGGABLE:
79
-			case DRAGGABLE:
80
-				$this->answer = new ScormAnswerMatching($this->id);
81
-				$this->answer->questionJSId = $this->js_id;
82
-				break;
83
-			case ORAL_EXPRESSION:
84
-			case FREE_ANSWER:
85
-				$this->answer = new ScormAnswerFree($this->id);
86
-				$this->answer->questionJSId = $this->js_id;
87
-				break;
88
-			case HOT_SPOT:
89
-				$this->answer = new ScormAnswerHotspot($this->id);
90
-				$this->answer->questionJSId = $this->js_id;
91
-				break;
92
-			case MULTIPLE_ANSWER_COMBINATION:
93
-				$this->answer = new ScormAnswerMultipleChoice($this->id);
94
-				$this->answer->questionJSId = $this->js_id;
95
-				break;
96
-			case HOT_SPOT_ORDER:
97
-				$this->answer = new ScormAnswerHotspot($this->id);
98
-				$this->answer->questionJSId = $this->js_id;
99
-				break;
100
-			case HOT_SPOT_DELINEATION:
101
-				$this->answer = new ScormAnswerHotspot($this->id);
102
-				$this->answer->questionJSId = $this->js_id;
103
-				break;
104
-			// not supported
105
-			case UNIQUE_ANSWER_NO_OPTION:
106
-			case MULTIPLE_ANSWER_TRUE_FALSE:
107
-			case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
108
-			case UNIQUE_ANSWER_IMAGE:
109
-			case CALCULATED_ANSWER:
110
-				$this->answer = new ScormAnswerMultipleChoice($this->id);
111
-				$this->answer->questionJSId = $this->js_id;
112
-				break;
113
-			default:
114
-				$this->answer = new stdClass();
115
-				$this->answer->questionJSId = $this->js_id;
116
-				break;
117
-		}
118
-
119
-		return true;
120
-	}
121
-
122
-	function export()
123
-	{
124
-		$html = $this->getQuestionHTML();
125
-		$js = $this->getQuestionJS();
126
-
127
-		if (is_object($this->answer) && $this->answer instanceof Answer) {
128
-			list($js2, $html2) = $this->answer->export();
129
-			$js .= $js2;
130
-			$html .= $html2;
131
-		} else {
132
-			throw new \Exception('Question not supported. Exercise: '.$this->selectTitle());
133
-		}
134
-
135
-		return array($js, $html);
136
-	}
137
-
138
-	function createAnswersForm($form)
139
-	{
140
-		return true;
141
-	}
142
-
143
-	function processAnswersCreation($form)
144
-	{
145
-		return true;
146
-	}
147
-
148
-	/**
149
-	 * Returns an HTML-formatted question
150
-	 */
151
-	function getQuestionHTML()
152
-	{
33
+     */
34
+    public static function export_question($questionId, $standalone = true, $js_id)
35
+    {
36
+        $question = new ScormQuestion();
37
+        $qst = $question->read($questionId);
38
+        if (!$qst) {
39
+            return '';
40
+        }
41
+        $question->id = $qst->id;
42
+        $question->js_id = $js_id;
43
+        $question->type = $qst->type;
44
+        $question->question = $qst->question;
45
+        $question->description = $qst->description;
46
+        $question->weighting=$qst->weighting;
47
+        $question->position=$qst->position;
48
+        $question->picture=$qst->picture;
49
+        $assessmentItem = new ScormAssessmentItem($question, $standalone);
50
+
51
+        return $assessmentItem->export();
52
+    }
53
+
54
+    /**
55
+     * Include the correct answer class and create answer
56
+     */
57
+    public function setAnswer()
58
+    {
59
+        switch ($this->type) {
60
+            case MCUA:
61
+                $this->answer = new ScormAnswerMultipleChoice($this->id);
62
+                $this->answer->questionJSId = $this->js_id;
63
+                break;
64
+            case MCMA:
65
+            case GLOBAL_MULTIPLE_ANSWER:
66
+                $this->answer = new ScormAnswerMultipleChoice($this->id);
67
+                $this->answer->questionJSId = $this->js_id;
68
+                break;
69
+            case TF:
70
+                $this->answer = new ScormAnswerTrueFalse($this->id);
71
+                $this->answer->questionJSId = $this->js_id;
72
+                break;
73
+            case FIB:
74
+                $this->answer = new ScormAnswerFillInBlanks($this->id);
75
+                $this->answer->questionJSId = $this->js_id;
76
+                break;
77
+            case MATCHING:
78
+            case MATCHING_DRAGGABLE:
79
+            case DRAGGABLE:
80
+                $this->answer = new ScormAnswerMatching($this->id);
81
+                $this->answer->questionJSId = $this->js_id;
82
+                break;
83
+            case ORAL_EXPRESSION:
84
+            case FREE_ANSWER:
85
+                $this->answer = new ScormAnswerFree($this->id);
86
+                $this->answer->questionJSId = $this->js_id;
87
+                break;
88
+            case HOT_SPOT:
89
+                $this->answer = new ScormAnswerHotspot($this->id);
90
+                $this->answer->questionJSId = $this->js_id;
91
+                break;
92
+            case MULTIPLE_ANSWER_COMBINATION:
93
+                $this->answer = new ScormAnswerMultipleChoice($this->id);
94
+                $this->answer->questionJSId = $this->js_id;
95
+                break;
96
+            case HOT_SPOT_ORDER:
97
+                $this->answer = new ScormAnswerHotspot($this->id);
98
+                $this->answer->questionJSId = $this->js_id;
99
+                break;
100
+            case HOT_SPOT_DELINEATION:
101
+                $this->answer = new ScormAnswerHotspot($this->id);
102
+                $this->answer->questionJSId = $this->js_id;
103
+                break;
104
+            // not supported
105
+            case UNIQUE_ANSWER_NO_OPTION:
106
+            case MULTIPLE_ANSWER_TRUE_FALSE:
107
+            case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
108
+            case UNIQUE_ANSWER_IMAGE:
109
+            case CALCULATED_ANSWER:
110
+                $this->answer = new ScormAnswerMultipleChoice($this->id);
111
+                $this->answer->questionJSId = $this->js_id;
112
+                break;
113
+            default:
114
+                $this->answer = new stdClass();
115
+                $this->answer->questionJSId = $this->js_id;
116
+                break;
117
+        }
118
+
119
+        return true;
120
+    }
121
+
122
+    function export()
123
+    {
124
+        $html = $this->getQuestionHTML();
125
+        $js = $this->getQuestionJS();
126
+
127
+        if (is_object($this->answer) && $this->answer instanceof Answer) {
128
+            list($js2, $html2) = $this->answer->export();
129
+            $js .= $js2;
130
+            $html .= $html2;
131
+        } else {
132
+            throw new \Exception('Question not supported. Exercise: '.$this->selectTitle());
133
+        }
134
+
135
+        return array($js, $html);
136
+    }
137
+
138
+    function createAnswersForm($form)
139
+    {
140
+        return true;
141
+    }
142
+
143
+    function processAnswersCreation($form)
144
+    {
145
+        return true;
146
+    }
147
+
148
+    /**
149
+     * Returns an HTML-formatted question
150
+     */
151
+    function getQuestionHTML()
152
+    {
153 153
         $title = $this->selectTitle();
154 154
         $description = $this->selectDescription();
155
-		$cols = 2;
156
-		$s = '<tr>
155
+        $cols = 2;
156
+        $s = '<tr>
157 157
 			<td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;">
158 158
 			'.$title.'
159 159
 			</td>
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
 			<i>'.$description.'</i>
164 164
 			</td>
165 165
 			</tr>';
166
-		return $s;
167
-	}
166
+        return $s;
167
+    }
168 168
 
169
-	/**
170
-	 * Return the JavaScript code bound to the question
171
-	 */
172
-	public function getQuestionJS()
173
-	{
174
-		$weight = $this->selectWeighting();
175
-		$js = 'questions.push('.$this->js_id.');'."\n";
169
+    /**
170
+     * Return the JavaScript code bound to the question
171
+     */
172
+    public function getQuestionJS()
173
+    {
174
+        $weight = $this->selectWeighting();
175
+        $js = 'questions.push('.$this->js_id.');'."\n";
176 176
 
177 177
         switch ($this->type) {
178 178
             case ORAL_EXPRESSION:
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
                 $script .= file_get_contents(api_get_path(LIBRARY_PATH) . 'wami-recorder/gui.js');
182 182
                 $js .= $script;*/
183 183
                 break;
184
-           case HOT_SPOT:
184
+            case HOT_SPOT:
185 185
                 //put the max score to 0 to avoid discounting the points of
186 186
                 //non-exported quiz types in the SCORM
187 187
                 $weight = 0;
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
         }
190 190
         $js .= 'questions_score_max['.$this->js_id.'] = '.$weight.";";
191 191
 
192
-		return $js;
193
-	}
192
+        return $js;
193
+    }
194 194
 }
195 195
 
196 196
 /**
@@ -200,29 +200,29 @@  discard block
 block discarded – undo
200 200
  */
201 201
 class ScormAnswerMultipleChoice extends Answer
202 202
 {
203
-	/**
204
-	 * Return HTML code for possible answers
205
-	 */
206
-	function export()
207
-	{
208
-		$js = '';
209
-		$html = '<tr><td colspan="2"><table width="100%">';
210
-		$type = $this->getQuestionType();
211
-		$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();';
212
-		$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;';
203
+    /**
204
+     * Return HTML code for possible answers
205
+     */
206
+    function export()
207
+    {
208
+        $js = '';
209
+        $html = '<tr><td colspan="2"><table width="100%">';
210
+        $type = $this->getQuestionType();
211
+        $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();';
212
+        $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;';
213 213
 
214 214
         $jstmpw .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();';
215 215
 
216
-		//not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM
217
-		//if ($type == MCMA  || $type == MULTIPLE_ANSWER_COMBINATION ) {
218
-		if ($type == MCMA) {
216
+        //not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM
217
+        //if ($type == MCMA  || $type == MULTIPLE_ANSWER_COMBINATION ) {
218
+        if ($type == MCMA) {
219 219
             $id = 1;
220
-			$jstmp = '';
221
-			$jstmpc = '';
220
+            $jstmp = '';
221
+            $jstmpc = '';
222 222
             foreach ($this->answer as $i => $answer) {
223
-				$identifier = 'question_'.$this->questionJSId.'_multiple_'.$i;
224
-				$html .=
225
-					'<tr>
223
+                $identifier = 'question_'.$this->questionJSId.'_multiple_'.$i;
224
+                $html .=
225
+                    '<tr>
226 226
 					<td align="center" width="5%">
227 227
 					<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />
228 228
 					</td>
@@ -231,19 +231,19 @@  discard block
 block discarded – undo
231 231
 					</td>
232 232
 					</tr>';
233 233
 
234
-				$jstmp .= $i.',';
234
+                $jstmp .= $i.',';
235 235
                 if ($this->correct[$i]) {
236 236
                     $jstmpc .= $i.',';
237 237
                 }
238
-				$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";";
238
+                $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";";
239 239
                 $jstmpw .= 'questions_answers_correct['.$this->questionJSId.']['.$i.'] = '.$this->correct[$i].';';
240
-				$id++;
241
-			}
242
-			$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n";
240
+                $id++;
241
+            }
242
+            $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n";
243 243
             $js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n";
244
-			$js .= $jstmpw;
245
-		} elseif ($type == MULTIPLE_ANSWER_COMBINATION) {
246
-	    	$js = '';
244
+            $js .= $jstmpw;
245
+        } elseif ($type == MULTIPLE_ANSWER_COMBINATION) {
246
+            $js = '';
247 247
             $id = 1;
248 248
             $jstmp = '';
249 249
             $jstmpc = '';
@@ -270,15 +270,15 @@  discard block
 block discarded – undo
270 270
             $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');';
271 271
             $js .= 'questions_types['.$this->questionJSId.'] = "exact";';
272 272
             $js .= $jstmpw;
273
-		} else {
274
-			$id = 1;
275
-			$jstmp = '';
276
-			$jstmpc = '';
273
+        } else {
274
+            $id = 1;
275
+            $jstmp = '';
276
+            $jstmpc = '';
277 277
             foreach ($this->answer as $i => $answer) {
278 278
                 $identifier = 'question_'.$this->questionJSId.'_unique_'.$i;
279
-				$identifier_name = 'question_'.$this->questionJSId.'_unique_answer';
280
-				$html .=
281
-					'<tr>
279
+                $identifier_name = 'question_'.$this->questionJSId.'_unique_answer';
280
+                $html .=
281
+                    '<tr>
282 282
 					<td align="center" width="5%">
283 283
 					<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="checkbox"/>
284 284
 					</td>
@@ -286,22 +286,22 @@  discard block
 block discarded – undo
286 286
 					<label for="'.$identifier.'">' . Security::remove_XSS($this->answer[$i]) . '</label>
287 287
 					</td>
288 288
 					</tr>';
289
-				$jstmp .= $i.',';
289
+                $jstmp .= $i.',';
290 290
                 if ($this->correct[$i]) {
291 291
                     $jstmpc .= $i;
292 292
                 }
293
-				$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";";
293
+                $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";";
294 294
                 $jstmpw .= 'questions_answers_correct['.$this->questionJSId.']['.$i.'] = '.$this->correct[$i].';';
295
-				$id++;
296
-			}
297
-			$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');';
298
-			$js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';';
299
-			$js .= $jstmpw;
300
-		}
301
-		$html .= '</table></td></tr>';
302
-
303
-		return array($js, $html);
304
-	}
295
+                $id++;
296
+            }
297
+            $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');';
298
+            $js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';';
299
+            $js .= $jstmpw;
300
+        }
301
+        $html .= '</table></td></tr>';
302
+
303
+        return array($js, $html);
304
+    }
305 305
 }
306 306
 
307 307
 /**
@@ -310,21 +310,21 @@  discard block
 block discarded – undo
310 310
  */
311 311
 class ScormAnswerTrueFalse extends Answer
312 312
 {
313
-	/**
314
-	 * Return the XML flow for the possible answers.
315
-	 * That's one <response_lid>, containing several <flow_label>
316
-	 *
317
-	 * @author Amand Tihon <[email protected]>
318
-	 */
319
-	function export()
320
-	{
321
-		$js = '';
322
-		$html = '<tr><td colspan="2"><table width="100%">';
323
-		$identifier = 'question_'.$this->questionJSId.'_tf';
324
-		$identifier_true  = $identifier.'_true';
325
-		$identifier_false = $identifier.'_false';
326
-		$html .=
327
-			'<tr>
313
+    /**
314
+     * Return the XML flow for the possible answers.
315
+     * That's one <response_lid>, containing several <flow_label>
316
+     *
317
+     * @author Amand Tihon <[email protected]>
318
+     */
319
+    function export()
320
+    {
321
+        $js = '';
322
+        $html = '<tr><td colspan="2"><table width="100%">';
323
+        $identifier = 'question_'.$this->questionJSId.'_tf';
324
+        $identifier_true  = $identifier.'_true';
325
+        $identifier_false = $identifier.'_false';
326
+        $html .=
327
+            '<tr>
328 328
 				<td align="center" width="5%">
329 329
 				<input name="'.$identifier_true.'" id="'.$identifier_true.'" value="'.$this->trueGrade.'" type="radio" />
330 330
 				</td>
@@ -332,8 +332,8 @@  discard block
 block discarded – undo
332 332
 				<label for="'.$identifier_true.'">' . get_lang('True') . '</label>
333 333
 				</td>
334 334
 				</tr>';
335
-		$html .=
336
-			'<tr>
335
+        $html .=
336
+            '<tr>
337 337
 			<td align="center" width="5%">
338 338
 			<input name="'.$identifier_false.'" id="'.$identifier_false.'" value="'.$this->falseGrade.'" type="radio" />
339 339
 			</td>
@@ -341,20 +341,20 @@  discard block
 block discarded – undo
341 341
 			<label for="'.$identifier_false.'">' . get_lang('False') . '</label>
342 342
 			</td>
343 343
 			</tr></table></td></tr>';
344
-		$js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n";
345
-		$js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n";
346
-		if ($this->response === 'TRUE') {
347
-			$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n";
348
-		} else {
349
-			$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n";
350
-		}
351
-		$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
352
-		$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
353
-		$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n";
354
-		$js .= $jstmpw;
355
-
356
-		return array($js, $html);
357
-	}
344
+        $js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n";
345
+        $js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n";
346
+        if ($this->response === 'TRUE') {
347
+            $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n";
348
+        } else {
349
+            $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n";
350
+        }
351
+        $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
352
+        $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
353
+        $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n";
354
+        $js .= $jstmpw;
355
+
356
+        return array($js, $html);
357
+    }
358 358
 }
359 359
 
360 360
 /**
@@ -363,76 +363,76 @@  discard block
 block discarded – undo
363 363
  */
364 364
 class ScormAnswerFillInBlanks extends Answer
365 365
 {
366
-	/**
367
-	 * Export the text with missing words.
368
-	 *
369
-	 * As a side effect, it stores two lists in the class :
370
-	 * the missing words and their respective weightings.
371
-	 */
372
-	function export()
373
-	{
374
-		global $charset;
375
-		$js = '';
376
-		$html = '<tr><td colspan="2"><table width="100%">';
377
-		// get all enclosed answers
378
-		$blankList = array();
379
-		// build replacement
380
-		$replacementList = array();
381
-		foreach ($this->answer as $i => $answer) {
382
-			$blankList[] = '['.$answer.']';
383
-		}
384
-
385
-		// splits text and weightings that are joined with the character '::'
386
-		list($answer,$weight)=explode('::',$answer);
387
-		$weights = explode(',',$weight);
388
-		// because [] is parsed here we follow this procedure:
389
-		// 1. find everything between the [ and ] tags
390
-		$i=1;
391
-		$jstmp = '';
392
-		$jstmpc = '';
393
-		$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
394
-		$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
395
-		$startlocations=api_strpos($answer,'[');
396
-		$endlocations=api_strpos($answer,']');
397
-		while ($startlocations !== false && $endlocations !== false) {
398
-			$texstring = api_substr($answer,$startlocations,($endlocations-$startlocations)+1);
399
-			$answer = api_substr_replace(
366
+    /**
367
+     * Export the text with missing words.
368
+     *
369
+     * As a side effect, it stores two lists in the class :
370
+     * the missing words and their respective weightings.
371
+     */
372
+    function export()
373
+    {
374
+        global $charset;
375
+        $js = '';
376
+        $html = '<tr><td colspan="2"><table width="100%">';
377
+        // get all enclosed answers
378
+        $blankList = array();
379
+        // build replacement
380
+        $replacementList = array();
381
+        foreach ($this->answer as $i => $answer) {
382
+            $blankList[] = '['.$answer.']';
383
+        }
384
+
385
+        // splits text and weightings that are joined with the character '::'
386
+        list($answer,$weight)=explode('::',$answer);
387
+        $weights = explode(',',$weight);
388
+        // because [] is parsed here we follow this procedure:
389
+        // 1. find everything between the [ and ] tags
390
+        $i=1;
391
+        $jstmp = '';
392
+        $jstmpc = '';
393
+        $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
394
+        $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
395
+        $startlocations=api_strpos($answer,'[');
396
+        $endlocations=api_strpos($answer,']');
397
+        while ($startlocations !== false && $endlocations !== false) {
398
+            $texstring = api_substr($answer,$startlocations,($endlocations-$startlocations)+1);
399
+            $answer = api_substr_replace(
400 400
                 $answer,
401 401
                 '<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />',
402 402
                 $startlocations,
403 403
                 ($endlocations-$startlocations)+1
404 404
             );
405 405
             $jstmp .= $i.',';
406
-			if (!empty($texstring)) {
407
-				$sub = api_substr($texstring, 1, -1);
408
-				if (!empty($sub)) {
409
-					$jstmpc .= "'" . api_htmlentities($sub, ENT_QUOTES, $charset) . "',";
410
-				}
411
-			}
406
+            if (!empty($texstring)) {
407
+                $sub = api_substr($texstring, 1, -1);
408
+                if (!empty($sub)) {
409
+                    $jstmpc .= "'" . api_htmlentities($sub, ENT_QUOTES, $charset) . "',";
410
+                }
411
+            }
412 412
             $my_weight = explode('@', $weights[$i - 1]);
413 413
             if (count($my_weight) == 2) {
414 414
                 $weight_db = $my_weight[0];
415 415
             } else {
416 416
                 $weight_db = $my_weight[0];
417 417
             }
418
-			$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n";
419
-			$i++;
420
-			$startlocations = api_strpos($answer, '[');
421
-			$endlocations = api_strpos($answer, ']');
422
-		}
418
+            $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n";
419
+            $i++;
420
+            $startlocations = api_strpos($answer, '[');
421
+            $endlocations = api_strpos($answer, ']');
422
+        }
423 423
 
424
-		$html .= '<tr>
424
+        $html .= '<tr>
425 425
 			<td>
426 426
 			'.$answer.'
427 427
 			</td>
428 428
 			</tr></table></td></tr>';
429
-		$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n";
430
-		$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n";
431
-		$js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n";
432
-		$js .= $jstmpw;
429
+        $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n";
430
+        $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n";
431
+        $js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n";
432
+        $js .= $jstmpw;
433 433
 
434
-		return array($js,$html);
435
-	}
434
+        return array($js,$html);
435
+    }
436 436
 }
437 437
 
438 438
 /**
@@ -441,65 +441,65 @@  discard block
 block discarded – undo
441 441
  */
442 442
 class ScormAnswerMatching extends Answer
443 443
 {
444
-	/**
445
-	 * Export the question part as a matrix-choice, with only one possible answer per line.
446
-	 * @author Amand Tihon <[email protected]>
447
-	 */
448
-	function export()
449
-	{
450
-		$js = '';
451
-		$html = '<tr><td colspan="2"><table width="100%">';
452
-		// prepare list of right proposition to allow
453
-		// - easiest display
454
-		// - easiest randomisation if needed one day
455
-		// (here I use array_values to change array keys from $code1 $code2 ... to 0 1 ...)
456
-
457
-		// get max length of displayed array
458
-
459
-		$nbrAnswers = $this->selectNbrAnswers();
460
-		$cpt1='A';
461
-		$cpt2=1;
462
-		$Select = array();
463
-		$qId = $this->questionJSId;
464
-		$s = '';
465
-		$jstmp = '';
466
-		$jstmpc = '';
467
-		$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
468
-		$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
469
-
470
-		for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
471
-			$identifier = 'question_'.$qId.'_matching_';
472
-			$answer=$this->selectAnswer($answerId);
473
-			$answerCorrect=$this->isCorrect($answerId);
474
-			$weight=$this->selectWeighting($answerId);
475
-			$jstmp .= $answerId.',';
476
-
477
-			if (!$answerCorrect) {
478
-				// options (A, B, C, ...) that will be put into the list-box
479
-				$Select[$answerId]['Lettre']=$cpt1;
480
-				// answers that will be shown at the right side
481
-				$Select[$answerId]['Reponse'] = $answer;
482
-				$cpt1++;
483
-			} else {
484
-				$s.='<tr>';
485
-				$s.='<td width="40%" valign="top"><b>'.$cpt2.'</b>.&nbsp;'.$answer."</td>";
486
-				$s.='<td width="20%" align="center">&nbsp;&nbsp;<select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">';
487
-				$s.=' <option value="0">--</option>';
488
-				// fills the list-box
444
+    /**
445
+     * Export the question part as a matrix-choice, with only one possible answer per line.
446
+     * @author Amand Tihon <[email protected]>
447
+     */
448
+    function export()
449
+    {
450
+        $js = '';
451
+        $html = '<tr><td colspan="2"><table width="100%">';
452
+        // prepare list of right proposition to allow
453
+        // - easiest display
454
+        // - easiest randomisation if needed one day
455
+        // (here I use array_values to change array keys from $code1 $code2 ... to 0 1 ...)
456
+
457
+        // get max length of displayed array
458
+
459
+        $nbrAnswers = $this->selectNbrAnswers();
460
+        $cpt1='A';
461
+        $cpt2=1;
462
+        $Select = array();
463
+        $qId = $this->questionJSId;
464
+        $s = '';
465
+        $jstmp = '';
466
+        $jstmpc = '';
467
+        $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
468
+        $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
469
+
470
+        for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
471
+            $identifier = 'question_'.$qId.'_matching_';
472
+            $answer=$this->selectAnswer($answerId);
473
+            $answerCorrect=$this->isCorrect($answerId);
474
+            $weight=$this->selectWeighting($answerId);
475
+            $jstmp .= $answerId.',';
476
+
477
+            if (!$answerCorrect) {
478
+                // options (A, B, C, ...) that will be put into the list-box
479
+                $Select[$answerId]['Lettre']=$cpt1;
480
+                // answers that will be shown at the right side
481
+                $Select[$answerId]['Reponse'] = $answer;
482
+                $cpt1++;
483
+            } else {
484
+                $s.='<tr>';
485
+                $s.='<td width="40%" valign="top"><b>'.$cpt2.'</b>.&nbsp;'.$answer."</td>";
486
+                $s.='<td width="20%" align="center">&nbsp;&nbsp;<select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">';
487
+                $s.=' <option value="0">--</option>';
488
+                // fills the list-box
489 489
                 foreach ($Select as $key => $val) {
490 490
                     $s .= '<option value="'.$key.'">'.$val['Lettre'].'</option>';
491 491
                 }  // end foreach()
492 492
 
493
-				$s.='</select>&nbsp;&nbsp;</td>';
494
-				$s.='<td width="40%" valign="top">';
493
+                $s.='</select>&nbsp;&nbsp;</td>';
494
+                $s.='<td width="40%" valign="top">';
495 495
                 if (isset($Select[$cpt2])) {
496 496
                     $s .= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse'];
497 497
                 } else {
498 498
                     $s .= '&nbsp;';
499 499
                 }
500
-				$s.="</td></tr>";
500
+                $s.="</td></tr>";
501 501
 
502
-				$jstmpc .= '['.$answerCorrect.','.$cpt2.'],';
502
+                $jstmpc .= '['.$answerCorrect.','.$cpt2.'],';
503 503
 
504 504
                 $my_weight = explode('@', $weight);
505 505
                 if (count($my_weight) == 2) {
@@ -507,32 +507,32 @@  discard block
 block discarded – undo
507 507
                 } else {
508 508
                     $weight = $my_weight[0];
509 509
                 }
510
-				$jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n";
511
-				$cpt2++;
512
-
513
-				// if the left side of the "matching" has been completely shown
514
-				if ($answerId == $nbrAnswers) {
515
-					// if there remain answers to be shown on the right side
516
-					while (isset($Select[$cpt2])) {
517
-						$s.= '<tr>';
518
-						$s.= '<td width="60%" colspan="2">&nbsp;</td>';
519
-						$s.= '<td width="40%" valign="top">';
520
-						$s.= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse'];
521
-						$s.= "</td></tr>";
522
-						$cpt2++;
523
-					}	// end while()
524
-				}  // end if()
525
-			}
526
-		}
527
-		$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n";
528
-		$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n";
529
-		$js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n";
530
-		$js .= $jstmpw;
531
-		$html .= $s;
532
-		$html .= '</table></td></tr>' . "\n";
533
-
534
-		return array($js, $html);
535
-	}
510
+                $jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n";
511
+                $cpt2++;
512
+
513
+                // if the left side of the "matching" has been completely shown
514
+                if ($answerId == $nbrAnswers) {
515
+                    // if there remain answers to be shown on the right side
516
+                    while (isset($Select[$cpt2])) {
517
+                        $s.= '<tr>';
518
+                        $s.= '<td width="60%" colspan="2">&nbsp;</td>';
519
+                        $s.= '<td width="40%" valign="top">';
520
+                        $s.= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse'];
521
+                        $s.= "</td></tr>";
522
+                        $cpt2++;
523
+                    }	// end while()
524
+                }  // end if()
525
+            }
526
+        }
527
+        $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n";
528
+        $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n";
529
+        $js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n";
530
+        $js .= $jstmpw;
531
+        $html .= $s;
532
+        $html .= '</table></td></tr>' . "\n";
533
+
534
+        return array($js, $html);
535
+    }
536 536
 }
537 537
 
538 538
 /**
@@ -541,19 +541,19 @@  discard block
 block discarded – undo
541 541
  */
542 542
 class ScormAnswerFree extends Answer
543 543
 {
544
-	/**
545
-	 * Export the text with missing words.
546
-	 *
547
-	 * As a side effect, it stores two lists in the class :
548
-	 * the missing words and their respective weightings.
549
-	 *
550
-	 */
551
-	function export()
552
-	{
553
-		$js = '';
544
+    /**
545
+     * Export the text with missing words.
546
+     *
547
+     * As a side effect, it stores two lists in the class :
548
+     * the missing words and their respective weightings.
549
+     *
550
+     */
551
+    function export()
552
+    {
553
+        $js = '';
554 554
         $identifier = 'question_'.$this->questionJSId.'_free';
555
-		// currently the free answers cannot be displayed, so ignore the textarea
556
-		$html = '<tr><td colspan="2">';
555
+        // currently the free answers cannot be displayed, so ignore the textarea
556
+        $html = '<tr><td colspan="2">';
557 557
         $type = $this->getQuestionType();
558 558
 
559 559
         if ($type == ORAL_EXPRESSION) {
@@ -565,21 +565,21 @@  discard block
 block discarded – undo
565 565
             $layout = $template->get_template('document/record_audio.tpl');
566 566
             $html .= $template->fetch($layout);*/
567 567
 
568
-			$html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>';
568
+            $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>';
569 569
 
570 570
             return array($js, $html);
571 571
         }
572 572
 
573 573
         $html .= '<textarea minlength="20" name="'.$identifier.'" id="'.$identifier.'" ></textarea>';
574 574
         $html .= '</td></tr>';
575
-		$js .= 'questions_answers['.$this->questionJSId.'] = new Array();';
576
-		$js .= 'questions_answers_correct['.$this->questionJSId.'] = "";';
577
-		$js .= 'questions_types['.$this->questionJSId.'] = \'free\';';
578
-		$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = "0";';
579
-		$js .= $jstmpw;
580
-
581
-		return array($js, $html);
582
-	}
575
+        $js .= 'questions_answers['.$this->questionJSId.'] = new Array();';
576
+        $js .= 'questions_answers_correct['.$this->questionJSId.'] = "";';
577
+        $js .= 'questions_types['.$this->questionJSId.'] = \'free\';';
578
+        $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = "0";';
579
+        $js .= $jstmpw;
580
+
581
+        return array($js, $html);
582
+    }
583 583
 }
584 584
 /**
585 585
  * This class handles the SCORM export of hotpot questions
@@ -587,63 +587,63 @@  discard block
 block discarded – undo
587 587
  */
588 588
 class ScormAnswerHotspot extends Answer
589 589
 {
590
-	/**
591
-	 * Returns the javascript code that goes with HotSpot exercises
592
-	 * @return string	The JavaScript code
593
-	 */
594
-	function get_js_header()
595
-	{
596
-		if ($this->standalone) {
597
-			$header = '<script>';
598
-			$header .= file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js');
599
-			$header .= '</script>';
600
-			//because this header closes so many times the <script> tag, we have to reopen our own
601
-			$header .= '<script>';
602
-			$header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n";
603
-			$header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n";
604
-			$header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n";
605
-			$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
606
-			$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
607
-			$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n";
608
-			$header .= $jstmpw;
609
-		} else {
610
-			$header = '';
611
-			$header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n";
612
-			$header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n";
613
-			$header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n";
614
-			$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
615
-			$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
616
-			$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'."\n";
617
-			$header .= $jstmpw;
618
-		}
619
-
620
-		return $header;
621
-	}
622
-	/**
623
-	 * Export the text with missing words.
624
-	 *
625
-	 * As a side effect, it stores two lists in the class :
626
-	 * the missing words and their respective weightings.
627
-	 *
628
-	 */
629
-	function export()
630
-	{
631
-		$js = $this->get_js_header();
632
-		$html = '<tr><td colspan="2"><table width="100%">';
633
-		// some javascript must be added for that kind of questions
634
-		$html .= '';
635
-
636
-		// Get the answers, make a list
637
-		$nbrAnswers=$this->selectNbrAnswers();
638
-
639
-		$answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>';
590
+    /**
591
+     * Returns the javascript code that goes with HotSpot exercises
592
+     * @return string	The JavaScript code
593
+     */
594
+    function get_js_header()
595
+    {
596
+        if ($this->standalone) {
597
+            $header = '<script>';
598
+            $header .= file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js');
599
+            $header .= '</script>';
600
+            //because this header closes so many times the <script> tag, we have to reopen our own
601
+            $header .= '<script>';
602
+            $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n";
603
+            $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n";
604
+            $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n";
605
+            $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
606
+            $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
607
+            $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n";
608
+            $header .= $jstmpw;
609
+        } else {
610
+            $header = '';
611
+            $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n";
612
+            $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n";
613
+            $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n";
614
+            $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
615
+            $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
616
+            $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'."\n";
617
+            $header .= $jstmpw;
618
+        }
619
+
620
+        return $header;
621
+    }
622
+    /**
623
+     * Export the text with missing words.
624
+     *
625
+     * As a side effect, it stores two lists in the class :
626
+     * the missing words and their respective weightings.
627
+     *
628
+     */
629
+    function export()
630
+    {
631
+        $js = $this->get_js_header();
632
+        $html = '<tr><td colspan="2"><table width="100%">';
633
+        // some javascript must be added for that kind of questions
634
+        $html .= '';
635
+
636
+        // Get the answers, make a list
637
+        $nbrAnswers=$this->selectNbrAnswers();
638
+
639
+        $answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>';
640 640
         for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
641 641
             $answer_list .= '<li>'.$this->selectAnswer($answerId).'</li>';
642 642
         }
643 643
         $answer_list .= '</ol></div>';
644
-		$canClick = true;
645
-		$relPath = api_get_path(REL_PATH);
646
-		$html .= <<<HTML
644
+        $canClick = true;
645
+        $relPath = api_get_path(REL_PATH);
646
+        $html .= <<<HTML
647 647
             <tr>
648 648
                 <td>
649 649
                     <div id="hotspot-{$this->questionJSId}"></div>
@@ -663,13 +663,13 @@  discard block
 block discarded – undo
663 663
                 </td>
664 664
             <tr>
665 665
 HTML;
666
-		$html .= '</table></td></tr>';
666
+        $html .= '</table></td></tr>';
667 667
 
668
-		// currently the free answers cannot be displayed, so ignore the textarea
669
-		$html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>';
668
+        // currently the free answers cannot be displayed, so ignore the textarea
669
+        $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>';
670 670
 
671
-		return array($js, $html);
672
-	}
671
+        return array($js, $html);
672
+    }
673 673
 }
674 674
 
675 675
 /**
@@ -684,32 +684,32 @@  discard block
 block discarded – undo
684 684
  */
685 685
 class ScormAssessmentItem
686 686
 {
687
-	public $question;
688
-	public $question_ident;
689
-	public $answer;
690
-	public $standalone;
691
-
692
-	/**
693
-	 * Constructor.
694
-	 *
695
-	 * @param ScormQuestion $question The Question object we want to export.
696
-	 */
697
-	public function __construct($question, $standalone = false)
698
-	{
699
-		$this->question = $question;
700
-		$this->question->setAnswer();
701
-		$this->questionIdent = "QST_" . $question->id ;
702
-		$this->standalone = $standalone;
703
-	}
704
-
705
-	/**
706
-	 * Start the XML flow.
707
-	 *
708
-	 * This opens the <item> block, with correct attributes.
709
-	 *
710
-	 */
711
-	function start_page()
712
-	{
687
+    public $question;
688
+    public $question_ident;
689
+    public $answer;
690
+    public $standalone;
691
+
692
+    /**
693
+     * Constructor.
694
+     *
695
+     * @param ScormQuestion $question The Question object we want to export.
696
+     */
697
+    public function __construct($question, $standalone = false)
698
+    {
699
+        $this->question = $question;
700
+        $this->question->setAnswer();
701
+        $this->questionIdent = "QST_" . $question->id ;
702
+        $this->standalone = $standalone;
703
+    }
704
+
705
+    /**
706
+     * Start the XML flow.
707
+     *
708
+     * This opens the <item> block, with correct attributes.
709
+     *
710
+     */
711
+    function start_page()
712
+    {
713 713
         $head = '';
714 714
         if ($this->standalone) {
715 715
             $charset = 'UTF-8';
@@ -717,89 +717,89 @@  discard block
 block discarded – undo
717 717
             $head .= '<html>';
718 718
         }
719 719
 
720
-		return $head;
721
-	}
720
+        return $head;
721
+    }
722
+
723
+    /**
724
+     * End the XML flow, closing the </item> tag.
725
+     *
726
+     */
727
+    function end_page()
728
+    {
729
+        if ($this->standalone) {
730
+            return '</html>';
731
+        }
732
+
733
+        return '';
734
+    }
735
+
736
+    /**
737
+     * Start document header
738
+     */
739
+    function start_header()
740
+    {
741
+        if ($this->standalone) {
742
+            return '<head>';
743
+        }
744
+
745
+        return '';
746
+    }
747
+
748
+    /**
749
+     * Print CSS inclusion
750
+     */
751
+    function css()
752
+    {
753
+        $css = '';
754
+        if ($this->standalone) {
755
+            $css = '<style type="text/css" media="screen, projection">';
756
+            $css .= '/*<![CDATA[*/'."\n";
757
+            $css .= '/*]]>*/'."\n";
758
+            $css .= '</style>'."\n";
759
+            $css .= '<style type="text/css" media="print">';
760
+            $css .= '/*<![CDATA[*/'."\n";
761
+            $css .= '/*]]>*/'."\n";
762
+            $css .= '</style>';
763
+        }
764
+
765
+        return $css;
766
+    }
722 767
 
723
-	/**
724
-	 * End the XML flow, closing the </item> tag.
725
-	 *
726
-	 */
727
-	function end_page()
768
+    /**
769
+     * End document header
770
+     */
771
+    function end_header()
772
+    {
773
+        if ($this->standalone) {
774
+            return '</head>';
775
+        }
776
+
777
+        return '';
778
+    }
779
+    /**
780
+     * Start the itemBody
781
+     *
782
+     */
783
+    function start_js()
728 784
     {
729
-		if ($this->standalone) {
730
-			return '</html>';
731
-		}
732
-
733
-		return '';
734
-	}
735
-
736
-	/**
737
-	 * Start document header
738
-	 */
739
-	function start_header()
740
-	{
741
-		if ($this->standalone) {
742
-			return '<head>';
743
-		}
744
-
745
-		return '';
746
-	}
747
-
748
-	/**
749
-	 * Print CSS inclusion
750
-	 */
751
-	function css()
752
-	{
753
-		$css = '';
754
-		if ($this->standalone) {
755
-			$css = '<style type="text/css" media="screen, projection">';
756
-			$css .= '/*<![CDATA[*/'."\n";
757
-			$css .= '/*]]>*/'."\n";
758
-			$css .= '</style>'."\n";
759
-			$css .= '<style type="text/css" media="print">';
760
-			$css .= '/*<![CDATA[*/'."\n";
761
-			$css .= '/*]]>*/'."\n";
762
-			$css .= '</style>';
763
-		}
764
-
765
-		return $css;
766
-	}
767
-
768
-	/**
769
-	 * End document header
770
-	 */
771
-	function end_header()
772
-	{
773
-		if ($this->standalone) {
774
-			return '</head>';
775
-		}
776
-
777
-		return '';
778
-	}
779
-	/**
780
-	 * Start the itemBody
781
-	 *
782
-	 */
783
-	function start_js()
784
-	{
785 785
         $js = '<script type="text/javascript" src="assets/api_wrapper.js"></script>';
786
-		if ($this->standalone) {
787
-			return '<script>';
788
-		}
789
-		return $js;
790
-	}
791
-
792
-	/**
793
-	 * Common JS functions
794
-	 */
795
-	function common_js()
796
-	{
797
-		$js = 'var questions = new Array();';
798
-		$js .= 'var questions_answers = new Array();';
799
-		$js .= 'var questions_answers_correct = new Array();';
800
-		$js .= 'var questions_types = new Array();';
801
-		$js .= "\n" .
802
-			'/**
786
+        if ($this->standalone) {
787
+            return '<script>';
788
+        }
789
+        return $js;
790
+    }
791
+
792
+    /**
793
+     * Common JS functions
794
+     */
795
+    function common_js()
796
+    {
797
+        $js = 'var questions = new Array();';
798
+        $js .= 'var questions_answers = new Array();';
799
+        $js .= 'var questions_answers_correct = new Array();';
800
+        $js .= 'var questions_types = new Array();';
801
+        $js .= "\n" .
802
+            '/**
803 803
              * Assigns any event handler to any element
804 804
              * @param	object	Element on which the event is added
805 805
              * @param	string	Name of event
@@ -834,79 +834,79 @@  discard block
 block discarded – undo
834 834
             	addEvent(window,\'unload\',unloadPage,false);
835 835
             }'."\n\n";
836 836
 
837
-		$js .= '';
838
-		$js .= 'addEvent(window,\'load\',addListeners,false);'."\n";
837
+        $js .= '';
838
+        $js .= 'addEvent(window,\'load\',addListeners,false);'."\n";
839 839
         if ($this->standalone) {
840 840
             return $js."\n";
841 841
         }
842
-		return '';
843
-	}
844
-
845
-	/**
846
-	 * End the itemBody part.
847
-	 *
848
-	 */
849
-	function end_js()
850
-	{
842
+        return '';
843
+    }
844
+
845
+    /**
846
+     * End the itemBody part.
847
+     *
848
+     */
849
+    function end_js()
850
+    {
851 851
         if ($this->standalone) {
852 852
             return '</script>';
853 853
         }
854 854
 
855 855
         return '';
856
-	}
857
-
858
-	/**
859
-	 * Start the itemBody
860
-	 *
861
-	 */
862
-	function start_body()
863
-	{
864
-		if ($this->standalone) {
865
-			return '<body><form id="dokeos_scorm_form" method="post" action="">';
866
-		}
867
-
868
-		return '';
869
-	}
870
-
871
-	/**
872
-	 * End the itemBody part.
873
-	 *
874
-	 */
875
-	function end_body()
876
-	{
877
-		if ($this->standalone) {
878
-			return '<br /><input class="btn" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>';
879
-		}
880
-
881
-		return '';
882
-	}
883
-
884
-	/**
885
-	 * Export the question as a SCORM Item.
886
-	 * This is a default behaviour, some classes may want to override this.
887
-	 * @return string|array A string, the XML flow for an Item.
888
-	 */
889
-	function export()
890
-	{
891
-		list($js, $html) = $this->question->export();
892
-		if ($this->standalone) {
893
-			$res = $this->start_page()
894
-				. $this->start_header()
895
-				. $this->css()
896
-				. $this->start_js()
897
-				. $this->common_js()
898
-				. $js
899
-				. $this->end_js()
900
-				. $this->end_header()
901
-				. $this->start_body()
856
+    }
857
+
858
+    /**
859
+     * Start the itemBody
860
+     *
861
+     */
862
+    function start_body()
863
+    {
864
+        if ($this->standalone) {
865
+            return '<body><form id="dokeos_scorm_form" method="post" action="">';
866
+        }
867
+
868
+        return '';
869
+    }
870
+
871
+    /**
872
+     * End the itemBody part.
873
+     *
874
+     */
875
+    function end_body()
876
+    {
877
+        if ($this->standalone) {
878
+            return '<br /><input class="btn" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>';
879
+        }
880
+
881
+        return '';
882
+    }
883
+
884
+    /**
885
+     * Export the question as a SCORM Item.
886
+     * This is a default behaviour, some classes may want to override this.
887
+     * @return string|array A string, the XML flow for an Item.
888
+     */
889
+    function export()
890
+    {
891
+        list($js, $html) = $this->question->export();
892
+        if ($this->standalone) {
893
+            $res = $this->start_page()
894
+                . $this->start_header()
895
+                . $this->css()
896
+                . $this->start_js()
897
+                . $this->common_js()
898
+                . $js
899
+                . $this->end_js()
900
+                . $this->end_header()
901
+                . $this->start_body()
902 902
                 . $html
903
-				. $this->end_body()
904
-				. $this->end_page();
905
-			return $res;
906
-		} else {
907
-			return array($js, $html);
908
-		}
909
-	}
903
+                . $this->end_body()
904
+                . $this->end_page();
905
+            return $res;
906
+        } else {
907
+            return array($js, $html);
908
+        }
909
+    }
910 910
 }
911 911
 
912 912
 /**
@@ -923,107 +923,107 @@  discard block
 block discarded – undo
923 923
  */
924 924
 class ScormSection
925 925
 {
926
-	public $exercise;
927
-	public $standalone;
928
-
929
-	/**
930
-	 * Send a complete exercise in SCORM format, from its ID
931
-	 *
932
-	 * @param int $exerciseId The exercise to exporte
933
-	 * @param boolean $standalone Wether it should include XML tag and DTD line.
934
-	 * @return string XML as a string, or an empty string if there's no exercise with given ID.
935
-	 */
936
-	public static function export_exercise_to_scorm($exerciseId, $standalone = true)
937
-	{
938
-		$exercise = new Exercise();
939
-		if (!$exercise->read($exerciseId)) {
940
-			return '';
941
-		}
942
-		$ims = new ScormSection($exercise);
943
-		$xml = $ims->export($standalone);
944
-
945
-		return $xml;
946
-	}
947
-
948
-	/**
949
-	 * Constructor.
950
-	 * @param Exercise $exe The Exercise instance to export
951
-	 * @author Amand Tihon <[email protected]>
952
-	 */
953
-	public function __construct($exe)
954
-	{
955
-		$this->exercise = $exe;
956
-	}
957
-
958
-	/**
959
-	 * Start the XML flow.
960
-	 *
961
-	 * This opens the <item> block, with correct attributes.
962
-	 *
963
-	 */
964
-	function start_page()
965
-	{
926
+    public $exercise;
927
+    public $standalone;
928
+
929
+    /**
930
+     * Send a complete exercise in SCORM format, from its ID
931
+     *
932
+     * @param int $exerciseId The exercise to exporte
933
+     * @param boolean $standalone Wether it should include XML tag and DTD line.
934
+     * @return string XML as a string, or an empty string if there's no exercise with given ID.
935
+     */
936
+    public static function export_exercise_to_scorm($exerciseId, $standalone = true)
937
+    {
938
+        $exercise = new Exercise();
939
+        if (!$exercise->read($exerciseId)) {
940
+            return '';
941
+        }
942
+        $ims = new ScormSection($exercise);
943
+        $xml = $ims->export($standalone);
944
+
945
+        return $xml;
946
+    }
947
+
948
+    /**
949
+     * Constructor.
950
+     * @param Exercise $exe The Exercise instance to export
951
+     * @author Amand Tihon <[email protected]>
952
+     */
953
+    public function __construct($exe)
954
+    {
955
+        $this->exercise = $exe;
956
+    }
957
+
958
+    /**
959
+     * Start the XML flow.
960
+     *
961
+     * This opens the <item> block, with correct attributes.
962
+     *
963
+     */
964
+    function start_page()
965
+    {
966 966
         $charset = 'UTF-8';
967
-		$head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?><html>';
968
-
969
-		return $head;
970
-	}
971
-
972
-	/**
973
-	 * End the XML flow, closing the </item> tag.
974
-	 *
975
-	 */
976
-	function end_page()
977
-	{
978
-		return '</html>';
979
-	}
980
-
981
-	/**
982
-	 * Start document header
983
-	 */
984
-	function start_header()
985
-	{
986
-		return '<head>';
987
-	}
988
-
989
-	/**
990
-	 * Print CSS inclusion
991
-	 */
992
-	private function css()
993
-	{
994
-		return '';
995
-	}
996
-
997
-	/**
998
-	 * End document header
999
-	 */
967
+        $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?><html>';
968
+
969
+        return $head;
970
+    }
971
+
972
+    /**
973
+     * End the XML flow, closing the </item> tag.
974
+     *
975
+     */
976
+    function end_page()
977
+    {
978
+        return '</html>';
979
+    }
980
+
981
+    /**
982
+     * Start document header
983
+     */
984
+    function start_header()
985
+    {
986
+        return '<head>';
987
+    }
988
+
989
+    /**
990
+     * Print CSS inclusion
991
+     */
992
+    private function css()
993
+    {
994
+        return '';
995
+    }
996
+
997
+    /**
998
+     * End document header
999
+     */
1000 1000
     private function end_header()
1001
-	{
1002
-		return '</head>';
1003
-	}
1004
-
1005
-	/**
1006
-	 * Start the itemBody
1007
-	 *
1008
-	 */
1001
+    {
1002
+        return '</head>';
1003
+    }
1004
+
1005
+    /**
1006
+     * Start the itemBody
1007
+     *
1008
+     */
1009 1009
     private function start_js()
1010
-	{
1011
-		return '<script>';
1012
-	}
1013
-
1014
-	/**
1015
-	 * Common JS functions
1016
-	 */
1017
-	public function common_js()
1018
-	{
1019
-		$js = file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js');
1020
-
1021
-		$js .= 'var questions = new Array();' . "\n";
1022
-		$js .= 'var questions_answers = new Array();' . "\n";
1023
-		$js .= 'var questions_answers_correct = new Array();' . "\n";
1024
-		$js .= 'var questions_types = new Array();' . "\n";
1025
-		$js .= "\n" .
1026
-			'/**
1010
+    {
1011
+        return '<script>';
1012
+    }
1013
+
1014
+    /**
1015
+     * Common JS functions
1016
+     */
1017
+    public function common_js()
1018
+    {
1019
+        $js = file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js');
1020
+
1021
+        $js .= 'var questions = new Array();' . "\n";
1022
+        $js .= 'var questions_answers = new Array();' . "\n";
1023
+        $js .= 'var questions_answers_correct = new Array();' . "\n";
1024
+        $js .= 'var questions_types = new Array();' . "\n";
1025
+        $js .= "\n" .
1026
+            '/**
1027 1027
              * Assigns any event handler to any element
1028 1028
              * @param	object	Element on which the event is added
1029 1029
              * @param	string	Name of event
@@ -1065,76 +1065,76 @@  discard block
 block discarded – undo
1065 1065
             }
1066 1066
             '."\n";
1067 1067
 
1068
-		$js .= '';
1069
-		$js .= 'addEvent(window,\'load\',addListeners,false);'."\n";
1070
-		return $js. "\n";
1071
-	}
1068
+        $js .= '';
1069
+        $js .= 'addEvent(window,\'load\',addListeners,false);'."\n";
1070
+        return $js. "\n";
1071
+    }
1072
+
1073
+    /**
1074
+     * End the itemBody part.
1075
+     *
1076
+     */
1077
+    function end_js()
1078
+    {
1079
+        return '</script>';
1080
+    }
1081
+
1082
+    /**
1083
+     * Start the itemBody
1084
+     *
1085
+     */
1086
+    function start_body()
1087
+    {
1088
+        return '<body>'.
1089
+        '<h1>'.$this->exercise->selectTitle().'</h1><p>'.$this->exercise->selectDescription()."</p>".
1090
+        '<form id="dokeos_scorm_form" method="post" action="">'.
1091
+        '<table width="100%">';
1092
+    }
1093
+
1094
+    /**
1095
+     * End the itemBody part.
1096
+     *
1097
+     */
1098
+    function end_body()
1099
+    {
1100
+        return '</table><br /><input class="btn btn-primary" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>';
1101
+    }
1072 1102
 
1073
-	/**
1074
-	 * End the itemBody part.
1075
-	 *
1076
-	 */
1077
-	function end_js()
1103
+    /**
1104
+     * Export the question as a SCORM Item.
1105
+     *
1106
+     * This is a default behaviour, some classes may want to override this.
1107
+     *
1108
+     * @param $standalone: Boolean stating if it should be exported as a stand-alone question
1109
+     * @return string string, the XML flow for an Item.
1110
+     */
1111
+    function export()
1078 1112
     {
1079
-		return '</script>';
1080
-	}
1081
-
1082
-	/**
1083
-	 * Start the itemBody
1084
-	 *
1085
-	 */
1086
-	function start_body()
1087
-	{
1088
-		return '<body>'.
1089
-		'<h1>'.$this->exercise->selectTitle().'</h1><p>'.$this->exercise->selectDescription()."</p>".
1090
-		'<form id="dokeos_scorm_form" method="post" action="">'.
1091
-		'<table width="100%">';
1092
-	}
1093
-
1094
-	/**
1095
-	 * End the itemBody part.
1096
-	 *
1097
-	 */
1098
-	function end_body()
1099
-	{
1100
-		return '</table><br /><input class="btn btn-primary" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>';
1101
-	}
1102
-
1103
-	/**
1104
-	 * Export the question as a SCORM Item.
1105
-	 *
1106
-	 * This is a default behaviour, some classes may want to override this.
1107
-	 *
1108
-	 * @param $standalone: Boolean stating if it should be exported as a stand-alone question
1109
-	 * @return string string, the XML flow for an Item.
1110
-	 */
1111
-	function export()
1112
-	{
1113
-		global $charset;
1114
-
1115
-		$head = '';
1116
-		if ($this->standalone) {
1117
-			$head = '<?xml version = "1.0" encoding = "' . $charset . '" standalone = "no"?>' . "\n"
1118
-				. '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n";
1119
-		}
1120
-
1121
-		list($js, $html) = $this->export_questions();
1122
-		$res = $this->start_page()
1123
-			. $this->start_header()
1124
-			. $this->css()
1113
+        global $charset;
1114
+
1115
+        $head = '';
1116
+        if ($this->standalone) {
1117
+            $head = '<?xml version = "1.0" encoding = "' . $charset . '" standalone = "no"?>' . "\n"
1118
+                . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n";
1119
+        }
1120
+
1121
+        list($js, $html) = $this->export_questions();
1122
+        $res = $this->start_page()
1123
+            . $this->start_header()
1124
+            . $this->css()
1125 1125
             . $this->globalAssets()
1126
-			. $this->start_js()
1127
-			. $this->common_js()
1128
-			. $js
1129
-			. $this->end_js()
1130
-			. $this->end_header()
1131
-			. $this->start_body()
1132
-			. $html
1133
-			. $this->end_body()
1134
-			. $this->end_page();
1135
-
1136
-		return $res;
1137
-	}
1126
+            . $this->start_js()
1127
+            . $this->common_js()
1128
+            . $js
1129
+            . $this->end_js()
1130
+            . $this->end_header()
1131
+            . $this->start_body()
1132
+            . $html
1133
+            . $this->end_body()
1134
+            . $this->end_page();
1135
+
1136
+        return $res;
1137
+    }
1138 1138
 
1139 1139
     /**
1140 1140
      * @return string
@@ -1148,21 +1148,21 @@  discard block
 block discarded – undo
1148 1148
         return $assets;
1149 1149
     }
1150 1150
 
1151
-	/**
1152
-	 * Export the questions, as a succession of <items>
1153
-	 * @author Amand Tihon <[email protected]>
1154
-	 */
1155
-	function export_questions()
1156
-	{
1157
-		$js = $html = "";
1158
-		$js_id = 0;
1159
-		foreach ($this->exercise->selectQuestionList() as $q) {
1160
-			list($jstmp, $htmltmp)= ScormQuestion::export_question($q, false, $js_id);
1161
-			$js .= $jstmp."\n";
1162
-			$html .= $htmltmp."\n";
1163
-			++$js_id;
1164
-		}
1165
-
1166
-		return array($js, $html);
1167
-	}
1151
+    /**
1152
+     * Export the questions, as a succession of <items>
1153
+     * @author Amand Tihon <[email protected]>
1154
+     */
1155
+    function export_questions()
1156
+    {
1157
+        $js = $html = "";
1158
+        $js_id = 0;
1159
+        foreach ($this->exercise->selectQuestionList() as $q) {
1160
+            list($jstmp, $htmltmp)= ScormQuestion::export_question($q, false, $js_id);
1161
+            $js .= $jstmp."\n";
1162
+            $html .= $htmltmp."\n";
1163
+            ++$js_id;
1164
+        }
1165
+
1166
+        return array($js, $html);
1167
+    }
1168 1168
 }
Please login to merge, or discard this patch.
main/webservices/user_import/import.lib.php 1 patch
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -3,121 +3,121 @@  discard block
 block discarded – undo
3 3
  * Validates imported data.
4 4
  */
5 5
 function validate_data($users) {
6
-	global $defined_auth_sources;
7
-	$errors = array ();
8
-	$usernames = array ();
9
-	if(is_array($users)) {
10
-		foreach ($users as $index => $user) {
11
-			// 1. Check whether mandatory fields have been set.
12
-			$mandatory_fields = array ('LastName', 'FirstName');
13
-			if (api_get_setting('registration', 'email') == 'true') {
14
-				$mandatory_fields[] = 'Email';
15
-			}
16
-			foreach ($mandatory_fields as $key => $field) {
17
-				if (!isset ($user[$field]) || strlen($user[$field]) == 0) {
18
-					$user['error'] = get_lang($field.'Mandatory');
19
-					$errors[] = $user;
20
-				}
21
-			}
22
-			// 2. Check username.
23
-			if (!UserManager::is_username_empty($user['UserName'])) {
24
-				// 2.1. Check whether username was used twice in the import file.
25
-				if (isset($usernames[$user['UserName']])) {
26
-					$user['error'] = get_lang('UserNameUsedTwice');
27
-					$errors[] = $user;
28
-				}
29
-				$usernames[$user['UserName']] = 1;
30
-				// 2.2. Check whether username is allready in use in database.
31
-				if (!UserManager::is_username_available($user['UserName'])) {
32
-					$user['error'] = get_lang('UserNameNotAvailable');
33
-					$errors[] = $user;
34
-				}
35
-				// 2.3. Check whether username is too long.
36
-				if (UserManager::is_username_too_long($user['UserName'])) {
37
-					$user['error'] = get_lang('UserNameTooLong');
38
-					$errors[] = $user;
39
-				}
40
-			}
41
-			// 3. Check status.
42
-			if (isset ($user['Status']) && !api_status_exists($user['Status'])) {
43
-				$user['error'] = get_lang('WrongStatus');
44
-				$errors[] = $user;
45
-			}
46
-			// 5. Check authentication source.
47
-			if (isset ($user['AuthSource']) && strlen($user['AuthSource']) != 0) {
48
-				if (!in_array($user['AuthSource'], $defined_auth_sources)) {
49
-					$user['error'] = get_lang('AuthSourceNotAvailable');
50
-					$errors[] = $user;
51
-				}
52
-			}
53
-		}
54
-	}
55
-	return $errors;
6
+    global $defined_auth_sources;
7
+    $errors = array ();
8
+    $usernames = array ();
9
+    if(is_array($users)) {
10
+        foreach ($users as $index => $user) {
11
+            // 1. Check whether mandatory fields have been set.
12
+            $mandatory_fields = array ('LastName', 'FirstName');
13
+            if (api_get_setting('registration', 'email') == 'true') {
14
+                $mandatory_fields[] = 'Email';
15
+            }
16
+            foreach ($mandatory_fields as $key => $field) {
17
+                if (!isset ($user[$field]) || strlen($user[$field]) == 0) {
18
+                    $user['error'] = get_lang($field.'Mandatory');
19
+                    $errors[] = $user;
20
+                }
21
+            }
22
+            // 2. Check username.
23
+            if (!UserManager::is_username_empty($user['UserName'])) {
24
+                // 2.1. Check whether username was used twice in the import file.
25
+                if (isset($usernames[$user['UserName']])) {
26
+                    $user['error'] = get_lang('UserNameUsedTwice');
27
+                    $errors[] = $user;
28
+                }
29
+                $usernames[$user['UserName']] = 1;
30
+                // 2.2. Check whether username is allready in use in database.
31
+                if (!UserManager::is_username_available($user['UserName'])) {
32
+                    $user['error'] = get_lang('UserNameNotAvailable');
33
+                    $errors[] = $user;
34
+                }
35
+                // 2.3. Check whether username is too long.
36
+                if (UserManager::is_username_too_long($user['UserName'])) {
37
+                    $user['error'] = get_lang('UserNameTooLong');
38
+                    $errors[] = $user;
39
+                }
40
+            }
41
+            // 3. Check status.
42
+            if (isset ($user['Status']) && !api_status_exists($user['Status'])) {
43
+                $user['error'] = get_lang('WrongStatus');
44
+                $errors[] = $user;
45
+            }
46
+            // 5. Check authentication source.
47
+            if (isset ($user['AuthSource']) && strlen($user['AuthSource']) != 0) {
48
+                if (!in_array($user['AuthSource'], $defined_auth_sources)) {
49
+                    $user['error'] = get_lang('AuthSourceNotAvailable');
50
+                    $errors[] = $user;
51
+                }
52
+            }
53
+        }
54
+    }
55
+    return $errors;
56 56
 }
57 57
 
58 58
 /**
59 59
  * Adds missing user-information (which isn't required, like password, username, etc).
60 60
  */
61 61
 function complete_missing_data($user) {
62
-	// 1. Create a username if necessary.
63
-	if (UserManager::is_username_empty($user['UserName'])) {
64
-		$user['UserName'] = UserManager::create_unique_username($user['FirstName'], $user['LastName']);
65
-	}
66
-	// 2. Generate a password if necessary.
67
-	if (!isset ($user['Password']) || strlen($user['Password']) == 0) {
68
-		$user['Password'] = api_generate_password();
69
-	}
70
-	// 3. set status if not allready set.
71
-	if (!isset ($user['Status']) || strlen($user['Status']) == 0) {
72
-		$user['Status'] = 'user';
73
-	}
74
-	// 4. Set authsource if not allready set.
75
-	if (!isset ($user['AuthSource']) || strlen($user['AuthSource']) == 0) {
76
-		$user['AuthSource'] = PLATFORM_AUTH_SOURCE;
77
-	}
78
-	return $user;
62
+    // 1. Create a username if necessary.
63
+    if (UserManager::is_username_empty($user['UserName'])) {
64
+        $user['UserName'] = UserManager::create_unique_username($user['FirstName'], $user['LastName']);
65
+    }
66
+    // 2. Generate a password if necessary.
67
+    if (!isset ($user['Password']) || strlen($user['Password']) == 0) {
68
+        $user['Password'] = api_generate_password();
69
+    }
70
+    // 3. set status if not allready set.
71
+    if (!isset ($user['Status']) || strlen($user['Status']) == 0) {
72
+        $user['Status'] = 'user';
73
+    }
74
+    // 4. Set authsource if not allready set.
75
+    if (!isset ($user['AuthSource']) || strlen($user['AuthSource']) == 0) {
76
+        $user['AuthSource'] = PLATFORM_AUTH_SOURCE;
77
+    }
78
+    return $user;
79 79
 }
80 80
 
81 81
 /**
82 82
  * Save the imported data
83 83
  */
84 84
 function save_data($users) {
85
-	$user_table = Database :: get_main_table(TABLE_MAIN_USER);
86
-	if(is_array($users)) {
87
-		foreach ($users as $index => $user) {
88
-			$user = complete_missing_data($user);
85
+    $user_table = Database :: get_main_table(TABLE_MAIN_USER);
86
+    if(is_array($users)) {
87
+        foreach ($users as $index => $user) {
88
+            $user = complete_missing_data($user);
89 89
 
90
-			$user['Status'] = api_status_key($user['Status']);
90
+            $user['Status'] = api_status_key($user['Status']);
91 91
 
92
-			$user_id = UserManager :: create_user($user['FirstName'], $user['LastName'], $user['Status'], $user['Email'], $user['UserName'], $user['Password'], $user['OfficialCode'], api_get_setting('PlatformLanguage'), $user['PhoneNumber'], '', $user['AuthSource']);
93
-			foreach ($user['Courses'] as $index => $course) {
94
-				if(CourseManager :: course_exists($course))
95
-					CourseManager :: subscribe_user($user_id, $course,$user['Status']);
96
-			}
92
+            $user_id = UserManager :: create_user($user['FirstName'], $user['LastName'], $user['Status'], $user['Email'], $user['UserName'], $user['Password'], $user['OfficialCode'], api_get_setting('PlatformLanguage'), $user['PhoneNumber'], '', $user['AuthSource']);
93
+            foreach ($user['Courses'] as $index => $course) {
94
+                if(CourseManager :: course_exists($course))
95
+                    CourseManager :: subscribe_user($user_id, $course,$user['Status']);
96
+            }
97 97
 
98
-			// TODO: Hard-coded French texts.
98
+            // TODO: Hard-coded French texts.
99 99
 
100
-			// Qualite
101
-			if (!empty($user['Qualite'])) {
102
-				UserManager::update_extra_field_value($user_id, 'qualite', $user['Qualite']);
103
-			}
100
+            // Qualite
101
+            if (!empty($user['Qualite'])) {
102
+                UserManager::update_extra_field_value($user_id, 'qualite', $user['Qualite']);
103
+            }
104 104
 
105
-			// Categorie
106
-			if (!empty($user['Categorie'])) {
107
-				UserManager::update_extra_field_value($user_id, 'categorie', $user['Categorie']);
108
-			}
105
+            // Categorie
106
+            if (!empty($user['Categorie'])) {
107
+                UserManager::update_extra_field_value($user_id, 'categorie', $user['Categorie']);
108
+            }
109 109
 
110
-			// Etat
111
-			if (!empty($user['Etat'])) {
112
-				UserManager::update_extra_field_value($user_id, 'etat', $user['Etat']);
113
-			}
110
+            // Etat
111
+            if (!empty($user['Etat'])) {
112
+                UserManager::update_extra_field_value($user_id, 'etat', $user['Etat']);
113
+            }
114 114
 
115
-			// Niveau
116
-			if (!empty($user['Niveau'])) {
117
-				UserManager::update_extra_field_value($user_id, 'niveau', $user['Niveau']);
118
-			}
119
-		}
120
-	}
115
+            // Niveau
116
+            if (!empty($user['Niveau'])) {
117
+                UserManager::update_extra_field_value($user_id, 'niveau', $user['Niveau']);
118
+            }
119
+        }
120
+    }
121 121
 }
122 122
 
123 123
 /**
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
  * @return array All userinformation read from the file
127 127
  */
128 128
 function parse_csv_data($file) {
129
-	$users = Import :: csvToArray($file);
130
-	foreach ($users as $index => $user) {
131
-		if (isset ($user['Courses'])) {
132
-			$user['Courses'] = explode('|', trim($user['Courses']));
133
-		}
134
-		$users[$index] = $user;
135
-	}
136
-	return $users;
129
+    $users = Import :: csvToArray($file);
130
+    foreach ($users as $index => $user) {
131
+        if (isset ($user['Courses'])) {
132
+            $user['Courses'] = explode('|', trim($user['Courses']));
133
+        }
134
+        $users[$index] = $user;
135
+    }
136
+    return $users;
137 137
 }
Please login to merge, or discard this patch.
main/exercise/unique_answer_no_option.class.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -14,20 +14,20 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class UniqueAnswerNoOption extends Question
16 16
 {
17
-	public static $typePicture = 'mcuao.png';
18
-	public static $explanationLangVar = 'UniqueAnswerNoOption';
17
+    public static $typePicture = 'mcuao.png';
18
+    public static $explanationLangVar = 'UniqueAnswerNoOption';
19 19
 
20
-	/**
21
-	 * Constructor
22
-	 */
23
-	public function __construct()
20
+    /**
21
+     * Constructor
22
+     */
23
+    public function __construct()
24 24
     {
25
-		parent::__construct();
26
-		$this -> type = UNIQUE_ANSWER_NO_OPTION;
27
-		$this -> isContent = $this-> getIsContent();
28
-	}
25
+        parent::__construct();
26
+        $this -> type = UNIQUE_ANSWER_NO_OPTION;
27
+        $this -> isContent = $this-> getIsContent();
28
+    }
29 29
 
30
-	/**
30
+    /**
31 31
      * function which redifines Question::createAnswersForm
32 32
      * @param the formvalidator instance
33 33
      * @param the answers number to display
@@ -283,37 +283,37 @@  discard block
 block discarded – undo
283 283
     }
284 284
 
285 285
     /**
286
-	 * Function which creates the form to create / edit the answers of the question
287
-	 * @param the formvalidator instance
288
-	 * @param the answers number to display
289
-	 */
290
-	function processAnswersCreation($form)
286
+     * Function which creates the form to create / edit the answers of the question
287
+     * @param the formvalidator instance
288
+     * @param the answers number to display
289
+     */
290
+    function processAnswersCreation($form)
291 291
     {
292
-		$questionWeighting = $nbrGoodAnswers = 0;
293
-		$correct = $form -> getSubmitValue('correct');
294
-		$objAnswer = new Answer($this->id);
295
-		$nb_answers = $form -> getSubmitValue('nb_answers');
296
-		$minus = 1;
297
-		if ($form -> getSubmitValue('new_question')) {
298
-		    $minus = 0;
299
-		}
300
-
301
-		for ($i=1 ; $i <= $nb_answers - $minus; $i++) {
302
-		    $position   = trim($form -> getSubmitValue('position['.$i.']'));
303
-        	$answer     = trim($form -> getSubmitValue('answer['.$i.']'));
292
+        $questionWeighting = $nbrGoodAnswers = 0;
293
+        $correct = $form -> getSubmitValue('correct');
294
+        $objAnswer = new Answer($this->id);
295
+        $nb_answers = $form -> getSubmitValue('nb_answers');
296
+        $minus = 1;
297
+        if ($form -> getSubmitValue('new_question')) {
298
+            $minus = 0;
299
+        }
300
+
301
+        for ($i=1 ; $i <= $nb_answers - $minus; $i++) {
302
+            $position   = trim($form -> getSubmitValue('position['.$i.']'));
303
+            $answer     = trim($form -> getSubmitValue('answer['.$i.']'));
304 304
             $comment    = trim($form -> getSubmitValue('comment['.$i.']'));
305 305
             $weighting  = trim($form -> getSubmitValue('weighting['.$i.']'));
306 306
             $scenario   = $form -> getSubmitValue('scenario');
307 307
 
308
-           	//$list_destination = $form -> getSubmitValue('destination'.$i);
309
-           	//$destination_str = $form -> getSubmitValue('destination'.$i);
308
+                //$list_destination = $form -> getSubmitValue('destination'.$i);
309
+                //$destination_str = $form -> getSubmitValue('destination'.$i);
310 310
 
311
- 		    $try           = $scenario['try'.$i];
311
+                $try           = $scenario['try'.$i];
312 312
             $lp            = $scenario['lp'.$i];
313
- 			$destination   = $scenario['destination'.$i];
314
- 			$url           = trim($scenario['url'.$i]);
313
+                $destination   = $scenario['destination'.$i];
314
+                $url           = trim($scenario['url'.$i]);
315 315
 
316
- 			/*
316
+                /*
317 317
  			How we are going to parse the destination value
318 318
 
319 319
 			here we parse the destination value which is a string
@@ -326,41 +326,41 @@  discard block
 block discarded – undo
326 326
 			selected_questions= ids of questions
327 327
 			url= an url
328 328
 			*/
329
-			/*
329
+            /*
330 330
  			$destination_str='';
331 331
  			foreach ($list_destination as $destination_id)
332 332
  			{
333 333
  				$destination_str.=$destination_id.';';
334 334
  			}*/
335 335
 
336
-        	$goodAnswer= ($correct == $i) ? true : false;
336
+            $goodAnswer= ($correct == $i) ? true : false;
337 337
 
338
-        	if ($goodAnswer) {
339
-        		$nbrGoodAnswers++;
340
-        		$weighting = abs($weighting);
341
-        		if($weighting > 0) {
338
+            if ($goodAnswer) {
339
+                $nbrGoodAnswers++;
340
+                $weighting = abs($weighting);
341
+                if($weighting > 0) {
342 342
                     $questionWeighting += $weighting;
343 343
                 }
344
-        	}
344
+            }
345 345
 
346
- 			if (empty($try))
347
- 				$try=0;
346
+                if (empty($try))
347
+                    $try=0;
348 348
 
349
- 			if (empty($lp)) {
350
- 				$lp=0;
351
- 			}
349
+                if (empty($lp)) {
350
+                    $lp=0;
351
+                }
352 352
 
353
- 			if (empty($destination)) {
354
- 				$destination=0;
355
- 			}
353
+                if (empty($destination)) {
354
+                    $destination=0;
355
+                }
356 356
 
357
- 			if ($url=='') {
358
- 				$url=0;
359
- 			}
357
+                if ($url=='') {
358
+                    $url=0;
359
+                }
360 360
 
361
- 			//1@@1;2;@@2;4;4;@@http://www.chamilo.org
362
-			$dest= $try.'@@'.$lp.'@@'.$destination.'@@'.$url;
363
-        	$objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i,NULL,NULL,$dest);
361
+                //1@@1;2;@@2;4;4;@@http://www.chamilo.org
362
+            $dest= $try.'@@'.$lp.'@@'.$destination.'@@'.$url;
363
+            $objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i,NULL,NULL,$dest);
364 364
         }
365 365
 
366 366
         //Create 666 answer
@@ -373,18 +373,18 @@  discard block
 block discarded – undo
373 373
 
374 374
         $objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i,NULL,NULL,$dest);
375 375
 
376
-    	// saves the answers into the data base
376
+        // saves the answers into the data base
377 377
         $objAnswer -> save();
378 378
 
379 379
         // sets the total weighting of the question
380 380
         $this -> updateWeighting($questionWeighting);
381 381
         $this -> save();
382
-	}
382
+    }
383 383
 
384
-	function return_header($feedback_type = null, $counter = null, $score = null)
384
+    function return_header($feedback_type = null, $counter = null, $score = null)
385 385
     {
386
-	    $header = parent::return_header($feedback_type, $counter, $score);
387
-	    $header .= '<table class="'.$this->question_table_class .'">
386
+        $header = parent::return_header($feedback_type, $counter, $score);
387
+        $header .= '<table class="'.$this->question_table_class .'">
388 388
 			<tr>
389 389
 				<th>'.get_lang("Choice").'</th>
390 390
 				<th>'. get_lang("ExpectedChoice").'</th>
@@ -392,5 +392,5 @@  discard block
 block discarded – undo
392 392
         $header .= '<th>'.get_lang("Comment").'</th>';
393 393
         $header .= '</tr>';
394 394
         return $header;
395
-	}
395
+    }
396 396
 }
Please login to merge, or discard this patch.
main/exercise/hotspot_savescore.inc.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,8 +25,8 @@
 block discarded – undo
25 25
     // user clicked ON a hotspot
26 26
     $hit = 1;
27 27
     $answerId = api_substr($_GET['answerId'],22,2);
28
-	// Save into session
29
-	$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
28
+    // Save into session
29
+    $_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
30 30
 }
31 31
 //round-up the coordinates
32 32
 $coords = explode('/',$coordinates);
Please login to merge, or discard this patch.