@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | krsort($langs, SORT_NUMERIC); |
30 | 30 | // Choosing the best match |
31 | 31 | foreach($langs as $weight => $codes) { |
32 | - foreach ($codes as $code) { |
|
33 | - if (in_array($code, $available_langs)) { |
|
34 | - return $code; |
|
35 | - } |
|
36 | - } |
|
32 | + foreach ($codes as $code) { |
|
33 | + if (in_array($code, $available_langs)) { |
|
34 | + return $code; |
|
35 | + } |
|
36 | + } |
|
37 | 37 | } |
38 | 38 | // No match |
39 | 39 | return null; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * use this if you want to avoid translation caching issues |
45 | 45 | */ |
46 | 46 | function cp_get_lang($variable) { |
47 | - return get_lang($variable, null, $_SESSION['user_language_choice']); |
|
47 | + return get_lang($variable, null, $_SESSION['user_language_choice']); |
|
48 | 48 | } |
49 | 49 | /** |
50 | 50 | * Code |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | |
64 | 64 | // Chamilo overrides this parameters at some places, e.g. in the logout link |
65 | 65 | if (isset($_REQUEST['language']) && !empty($_REQUEST['language']) && in_array($_REQUEST['language'], $chamilo_langs)) { |
66 | - $lang_match = $_REQUEST['language']; |
|
66 | + $lang_match = $_REQUEST['language']; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // Maybe a language had already been selected, we should honor this |
70 | 70 | if (isset($_SESSION['user_language_choice']) && in_array($_SESSION['user_language_choice'], $chamilo_langs)) { |
71 | - $lang_match = $_SESSION['user_language_choice']; |
|
71 | + $lang_match = $_SESSION['user_language_choice']; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | // We need to set the relevant session variables to the best match, to use Chamilo's i18n lib. |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * Security checks |
15 | 15 | */ |
16 | 16 | if (! isset($_SESSION['conditional_login']['uid'])) |
17 | - die("Not Authorised"); |
|
17 | + die("Not Authorised"); |
|
18 | 18 | |
19 | 19 | if (isset($_POST['password'])) { |
20 | 20 | $u = api_get_user_info($_SESSION['conditional_login']['uid']); |
@@ -27,26 +27,26 @@ discard block |
||
27 | 27 | exit(); |
28 | 28 | } |
29 | 29 | $password = $_POST['password']; |
30 | - $updated = UserManager::update_user( |
|
31 | - $u['user_id'], |
|
32 | - $u['firstname'], |
|
33 | - $u['lastname'], |
|
34 | - $u['username'], |
|
35 | - $password, |
|
36 | - $u['auth_source'], |
|
37 | - $u['email'], |
|
38 | - $u['status'], |
|
39 | - $u['official_code'], |
|
40 | - $u['phone'], |
|
41 | - $u['picture_uri'], |
|
42 | - $u['expiration_date'], |
|
43 | - $u['active'], |
|
44 | - $u['creator_id'], |
|
45 | - $u['hr_dept_id'], |
|
46 | - null, |
|
47 | - $u['language'], |
|
48 | - '' |
|
49 | - ); |
|
30 | + $updated = UserManager::update_user( |
|
31 | + $u['user_id'], |
|
32 | + $u['firstname'], |
|
33 | + $u['lastname'], |
|
34 | + $u['username'], |
|
35 | + $password, |
|
36 | + $u['auth_source'], |
|
37 | + $u['email'], |
|
38 | + $u['status'], |
|
39 | + $u['official_code'], |
|
40 | + $u['phone'], |
|
41 | + $u['picture_uri'], |
|
42 | + $u['expiration_date'], |
|
43 | + $u['active'], |
|
44 | + $u['creator_id'], |
|
45 | + $u['hr_dept_id'], |
|
46 | + null, |
|
47 | + $u['language'], |
|
48 | + '' |
|
49 | + ); |
|
50 | 50 | |
51 | 51 | if ($updated !== false) { |
52 | 52 | UserManager::update_extra_field_value($u['user_id'], 'already_logged_in', 'true'); |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | <div id="changepassword-form-box" class="form-box"> |
105 | 105 | <div class="info"> <?php echo custompages_get_lang('FirstLoginChangePassword');?> </div> |
106 | 106 | <?php if (isset($error_message)) { |
107 | - echo '<div id="changepassword-form-error" class="form-error">'.$error_message.'</div>'; |
|
108 | - }?> |
|
107 | + echo '<div id="changepassword-form-error" class="form-error">'.$error_message.'</div>'; |
|
108 | + }?> |
|
109 | 109 | <form id="changepassword-form" class="form" method="post"> |
110 | 110 | <div> |
111 | 111 | <label for="password">*<?php echo custompages_get_lang('Password');?></label> |
@@ -9,30 +9,30 @@ discard block |
||
9 | 9 | * Get the preferred language base on the browser headers |
10 | 10 | */ |
11 | 11 | function get_preferred_language($available_langs) { |
12 | - $langs = array(); |
|
13 | - foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $httplang) { |
|
14 | - $rawlang = explode(';q=', $httplang); |
|
15 | - if (strpos($rawlang[0], '-') !== FALSE) { |
|
16 | - $rawlang[0] = substr($rawlang[0], 0, strpos($rawlang[0], '-')); |
|
17 | - } |
|
18 | - if (count($rawlang) == 1) { |
|
19 | - $rawlang[1] = 1.0; |
|
20 | - } |
|
21 | - $langs[$rawlang[1]] = $rawlang[0]; |
|
22 | - } |
|
23 | - krsort($langs, SORT_NUMERIC); |
|
24 | - foreach($langs as $weight => $code) { |
|
25 | - if (in_array($code, $available_langs)) { |
|
26 | - return $code; |
|
27 | - } |
|
28 | - } |
|
29 | - return null; |
|
12 | + $langs = array(); |
|
13 | + foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $httplang) { |
|
14 | + $rawlang = explode(';q=', $httplang); |
|
15 | + if (strpos($rawlang[0], '-') !== FALSE) { |
|
16 | + $rawlang[0] = substr($rawlang[0], 0, strpos($rawlang[0], '-')); |
|
17 | + } |
|
18 | + if (count($rawlang) == 1) { |
|
19 | + $rawlang[1] = 1.0; |
|
20 | + } |
|
21 | + $langs[$rawlang[1]] = $rawlang[0]; |
|
22 | + } |
|
23 | + krsort($langs, SORT_NUMERIC); |
|
24 | + foreach($langs as $weight => $code) { |
|
25 | + if (in_array($code, $available_langs)) { |
|
26 | + return $code; |
|
27 | + } |
|
28 | + } |
|
29 | + return null; |
|
30 | 30 | } |
31 | 31 | /** |
32 | 32 | * Get a language variable in a specific language |
33 | 33 | */ |
34 | 34 | function custompages_get_lang($variable) { |
35 | - return get_lang($variable, null, $_SESSION['user_language_choice']); |
|
35 | + return get_lang($variable, null, $_SESSION['user_language_choice']); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | $available_langs = array('en', 'fr', 'es', 'gl', 'eu'); |
@@ -49,15 +49,15 @@ discard block |
||
49 | 49 | $lang_match = $chamilo_langs[get_preferred_language($available_langs)]; |
50 | 50 | // recover previous value ... |
51 | 51 | if (isset($_SESSION['user_language_choice'])) |
52 | - $lang_match = $_SESSION['user_language_choice']; |
|
52 | + $lang_match = $_SESSION['user_language_choice']; |
|
53 | 53 | |
54 | 54 | // Chamilo parameter, on logout |
55 | 55 | if (isset($_REQUEST['language']) && !empty($_REQUEST['language']) && in_array($_REQUEST['language'], $chamilo_langs)) { |
56 | - $lang_match = $_REQUEST['language']; |
|
56 | + $lang_match = $_REQUEST['language']; |
|
57 | 57 | } |
58 | 58 | // Incoming link parameter |
59 | 59 | if (isset($_REQUEST['lang']) && !empty($_REQUEST['lang']) && in_array($_REQUEST['lang'], $available_langs)) { |
60 | - $lang_match = $chamilo_langs[$_REQUEST['lang']]; |
|
60 | + $lang_match = $chamilo_langs[$_REQUEST['lang']]; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | $detect = api_get_setting('auto_detect_language_custom_pages'); |
@@ -46,10 +46,9 @@ discard block |
||
46 | 46 | - Universite Jean Monet (J Dubois / Michel Courbon) |
47 | 47 | - Michel Panckoucke for reporting and fixing a bug |
48 | 48 | - Patrick Cool: fixing security hole |
49 | - |
|
50 | - * @author Roan Embrechts |
|
51 | - * @version 3.0 |
|
52 | - * @package chamilo.auth.ldap |
|
49 | + * @author Roan Embrechts |
|
50 | + * @version 3.0 |
|
51 | + * @package chamilo.auth.ldap |
|
53 | 52 | * Note: |
54 | 53 | * If you are using a firewall, you might need to check port 389 is open in |
55 | 54 | * order for Chamilo to communicate with the LDAP server. |
@@ -211,8 +210,8 @@ discard block |
||
211 | 210 | $language = api_get_setting('platformLanguage'); |
212 | 211 | if (empty($language)) { $language = 'english'; } |
213 | 212 | $_userId = UserManager::create_user($prenom, $nom, $status, |
214 | - $email, $uname, $password, $official_code, |
|
215 | - $language,'', '', 'ldap'); |
|
213 | + $email, $uname, $password, $official_code, |
|
214 | + $language,'', '', 'ldap'); |
|
216 | 215 | |
217 | 216 | //echo "new user added to Chamilo, id = $_userId"; |
218 | 217 | |
@@ -271,7 +270,7 @@ discard block |
||
271 | 270 | // Open anonymous LDAP connection |
272 | 271 | $result=false; |
273 | 272 | $ldap_bind_res = ldap_handle_bind($ds,$result); |
274 | - // Executing the search with the $filter parametr |
|
273 | + // Executing the search with the $filter parametr |
|
275 | 274 | //error_log('Searching for '.$filter.' on LDAP server',0); |
276 | 275 | $sr=ldap_search($ds,$ldap_basedn,$filter); |
277 | 276 | $info = ldap_get_entries($ds, $sr); |
@@ -564,35 +563,35 @@ discard block |
||
564 | 563 | foreach ($UserList as $enreg_user) { |
565 | 564 | $enreg_user = (int) $enreg_user; |
566 | 565 | Database::query("INSERT IGNORE ". |
567 | - " INTO $tbl_session_rel_course_rel_user ". |
|
568 | - "(session_id,c_id,user_id) VALUES ". |
|
569 | - "('$id_session','$enreg_course','$enreg_user')"); |
|
566 | + " INTO $tbl_session_rel_course_rel_user ". |
|
567 | + "(session_id,c_id,user_id) VALUES ". |
|
568 | + "('$id_session','$enreg_course','$enreg_user')"); |
|
570 | 569 | } |
571 | 570 | $sql = "SELECT COUNT(user_id) as nbUsers ". |
572 | - " FROM $tbl_session_rel_course_rel_user " . |
|
573 | - " WHERE session_id='$id_session' ". |
|
574 | - " AND c_id='$enreg_course'"; |
|
571 | + " FROM $tbl_session_rel_course_rel_user " . |
|
572 | + " WHERE session_id='$id_session' ". |
|
573 | + " AND c_id='$enreg_course'"; |
|
575 | 574 | $rs = Database::query($sql); |
576 | 575 | list($nbr_users) = Database::fetch_array($rs); |
577 | 576 | Database::query("UPDATE $tbl_session_rel_course ". |
578 | - " SET nbr_users=$nbr_users " . |
|
579 | - " WHERE session_id='$id_session' ". |
|
580 | - " AND c_id='$enreg_course'"); |
|
577 | + " SET nbr_users=$nbr_users " . |
|
578 | + " WHERE session_id='$id_session' ". |
|
579 | + " AND c_id='$enreg_course'"); |
|
581 | 580 | } |
582 | 581 | foreach ($UserList as $enreg_user) { |
583 | 582 | $enreg_user = (int) $enreg_user; |
584 | 583 | Database::query("INSERT IGNORE INTO $tbl_session_rel_user ". |
585 | - " (session_id, user_id, registered_at) " . |
|
586 | - " VALUES('$id_session','$enreg_user', '" . api_get_utc_datetime() . "')"); |
|
584 | + " (session_id, user_id, registered_at) " . |
|
585 | + " VALUES('$id_session','$enreg_user', '" . api_get_utc_datetime() . "')"); |
|
587 | 586 | } |
588 | 587 | // We update the number of users in the session |
589 | 588 | $sql = "SELECT COUNT(user_id) as nbUsers FROM $tbl_session_rel_user ". |
590 | - " WHERE session_id='$id_session' ". |
|
591 | - " AND relation_type<>".SESSION_RELATION_TYPE_RRHH." "; |
|
589 | + " WHERE session_id='$id_session' ". |
|
590 | + " AND relation_type<>".SESSION_RELATION_TYPE_RRHH." "; |
|
592 | 591 | $rs = Database::query($sql); |
593 | 592 | list($nbr_users) = Database::fetch_array($rs); |
594 | 593 | Database::query("UPDATE $tbl_session SET nbr_users=$nbr_users ". |
595 | - " WHERE id='$id_session'"); |
|
594 | + " WHERE id='$id_session'"); |
|
596 | 595 | } |
597 | 596 | |
598 | 597 | function syncro_users() { |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | |
56 | 56 | function createAnswersForm($form) |
57 | 57 | { |
58 | - return true; |
|
58 | + return true; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | function processAnswersCreation($form) |
62 | 62 | { |
63 | - return true; |
|
63 | + return true; |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | /** |
@@ -76,21 +76,21 @@ discard block |
||
76 | 76 | public function imsExportResponses($questionIdent, $questionStatment) |
77 | 77 | { |
78 | 78 | // @todo getAnswersList() converts the answers using api_html_entity_decode() |
79 | - $this->answerList = $this->getAnswersList(true); |
|
79 | + $this->answerList = $this->getAnswersList(true); |
|
80 | 80 | $out = ' <choiceInteraction responseIdentifier="' . $questionIdent . '" >' . "\n"; |
81 | 81 | $out .= ' <prompt><![CDATA['.formatExerciseQtiTitle($questionStatment) . ']]></prompt>'. "\n"; |
82 | - if (is_array($this->answerList)) { |
|
83 | - foreach ($this->answerList as $current_answer) { |
|
84 | - $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false"> |
|
82 | + if (is_array($this->answerList)) { |
|
83 | + foreach ($this->answerList as $current_answer) { |
|
84 | + $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false"> |
|
85 | 85 | <![CDATA['.formatExerciseQtiTitle($current_answer['answer']).']]>'; |
86 | - if (isset($current_answer['comment']) && $current_answer['comment'] != '') { |
|
87 | - $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '"> |
|
86 | + if (isset($current_answer['comment']) && $current_answer['comment'] != '') { |
|
87 | + $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '"> |
|
88 | 88 | <![CDATA['.formatExerciseQtiTitle($current_answer['comment']).']]> |
89 | 89 | </feedbackInline>'; |
90 | - } |
|
91 | - $out .= '</simpleChoice>'. "\n"; |
|
92 | - } |
|
93 | - } |
|
90 | + } |
|
91 | + $out .= '</simpleChoice>'. "\n"; |
|
92 | + } |
|
93 | + } |
|
94 | 94 | $out .= ' </choiceInteraction>'. "\n"; |
95 | 95 | |
96 | 96 | return $out; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function imsExportResponsesDeclaration($questionIdent) |
104 | 104 | { |
105 | - $this->answerList = $this->getAnswersList(true); |
|
106 | - $type = $this->getQuestionType(); |
|
105 | + $this->answerList = $this->getAnswersList(true); |
|
106 | + $type = $this->getQuestionType(); |
|
107 | 107 | if ($type == MCMA) $cardinality = 'multiple'; else $cardinality = 'single'; |
108 | 108 | |
109 | 109 | $out = ' <responseDeclaration identifier="' . $questionIdent . '" cardinality="' . $cardinality . '" baseType="identifier">' . "\n"; |
@@ -111,25 +111,25 @@ discard block |
||
111 | 111 | // Match the correct answers. |
112 | 112 | |
113 | 113 | $out .= ' <correctResponse>'. "\n"; |
114 | - if (is_array($this->answerList)) { |
|
115 | - foreach($this->answerList as $current_answer) { |
|
116 | - if ($current_answer['correct']) { |
|
117 | - $out .= ' <value>answer_'. $current_answer['id'] .'</value>'. "\n"; |
|
118 | - } |
|
119 | - } |
|
120 | - } |
|
114 | + if (is_array($this->answerList)) { |
|
115 | + foreach($this->answerList as $current_answer) { |
|
116 | + if ($current_answer['correct']) { |
|
117 | + $out .= ' <value>answer_'. $current_answer['id'] .'</value>'. "\n"; |
|
118 | + } |
|
119 | + } |
|
120 | + } |
|
121 | 121 | $out .= ' </correctResponse>'. "\n"; |
122 | 122 | |
123 | 123 | //Add the grading |
124 | 124 | |
125 | 125 | $out .= ' <mapping>'. "\n"; |
126 | - if (is_array($this->answerList)) { |
|
127 | - foreach($this->answerList as $current_answer) { |
|
128 | - if (isset($current_answer['grade'])) { |
|
129 | - $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n"; |
|
130 | - } |
|
131 | - } |
|
132 | - } |
|
126 | + if (is_array($this->answerList)) { |
|
127 | + foreach($this->answerList as $current_answer) { |
|
128 | + if (isset($current_answer['grade'])) { |
|
129 | + $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n"; |
|
130 | + } |
|
131 | + } |
|
132 | + } |
|
133 | 133 | $out .= ' </mapping>'. "\n"; |
134 | 134 | $out .= ' </responseDeclaration>'. "\n"; |
135 | 135 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function imsExportResponses($questionIdent, $questionStatment) |
152 | 152 | { |
153 | - $this->answerList = $this->getAnswersList(true); |
|
153 | + $this->answerList = $this->getAnswersList(true); |
|
154 | 154 | $text = ''; |
155 | 155 | $text .= $this->answerText; |
156 | 156 | if (is_array($this->answerList)) { |
@@ -171,28 +171,28 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function imsExportResponsesDeclaration($questionIdent) |
173 | 173 | { |
174 | - $this->answerList = $this->getAnswersList(true); |
|
175 | - $this->gradeList = $this->getGradesList(); |
|
174 | + $this->answerList = $this->getAnswersList(true); |
|
175 | + $this->gradeList = $this->getGradesList(); |
|
176 | 176 | $out = ''; |
177 | - if (is_array($this->answerList)) { |
|
178 | - foreach ($this->answerList as $answer) { |
|
179 | - $answerKey = $answer['id']; |
|
180 | - $answer = $answer['answer']; |
|
181 | - $out .= ' <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n"; |
|
182 | - $out .= ' <correctResponse>'. "\n"; |
|
177 | + if (is_array($this->answerList)) { |
|
178 | + foreach ($this->answerList as $answer) { |
|
179 | + $answerKey = $answer['id']; |
|
180 | + $answer = $answer['answer']; |
|
181 | + $out .= ' <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n"; |
|
182 | + $out .= ' <correctResponse>'. "\n"; |
|
183 | 183 | $out .= ' <value><![CDATA['.formatExerciseQtiTitle($answer).']]></value>'. "\n"; |
184 | - $out .= ' </correctResponse>'. "\n"; |
|
185 | - if (isset($this->gradeList[$answerKey])) { |
|
186 | - $out .= ' <mapping>'. "\n"; |
|
187 | - $out .= ' <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n"; |
|
188 | - $out .= ' </mapping>'. "\n"; |
|
189 | - } |
|
190 | - |
|
191 | - $out .= ' </responseDeclaration>'. "\n"; |
|
192 | - } |
|
193 | - } |
|
194 | - |
|
195 | - return $out; |
|
184 | + $out .= ' </correctResponse>'. "\n"; |
|
185 | + if (isset($this->gradeList[$answerKey])) { |
|
186 | + $out .= ' <mapping>'. "\n"; |
|
187 | + $out .= ' <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n"; |
|
188 | + $out .= ' </mapping>'. "\n"; |
|
189 | + } |
|
190 | + |
|
191 | + $out .= ' </responseDeclaration>'. "\n"; |
|
192 | + } |
|
193 | + } |
|
194 | + |
|
195 | + return $out; |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function imsExportResponses($questionIdent, $questionStatment) |
209 | 209 | { |
210 | - $this->answerList = $this->getAnswersList(true); |
|
211 | - $maxAssociation = max(count($this->leftList), count($this->rightList)); |
|
210 | + $this->answerList = $this->getAnswersList(true); |
|
211 | + $maxAssociation = max(count($this->leftList), count($this->rightList)); |
|
212 | 212 | |
213 | 213 | $out = ""; |
214 | 214 | |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | //add left column |
219 | 219 | |
220 | 220 | $out .= ' <simpleMatchSet>'. "\n"; |
221 | - if (is_array($this->leftList)) { |
|
222 | - foreach ($this->leftList as $leftKey=>$leftElement) { |
|
223 | - $out .= ' |
|
221 | + if (is_array($this->leftList)) { |
|
222 | + foreach ($this->leftList as $leftKey=>$leftElement) { |
|
223 | + $out .= ' |
|
224 | 224 | <simpleAssociableChoice identifier="left_'.$leftKey.'" > |
225 | 225 | <![CDATA['.formatExerciseQtiTitle($leftElement['answer']).']]> |
226 | 226 | </simpleAssociableChoice>'. "\n"; |
227 | - } |
|
228 | - } |
|
227 | + } |
|
228 | + } |
|
229 | 229 | |
230 | 230 | $out .= ' </simpleMatchSet>'. "\n"; |
231 | 231 | |
@@ -235,14 +235,14 @@ discard block |
||
235 | 235 | |
236 | 236 | $i = 0; |
237 | 237 | |
238 | - if (is_array($this->rightList)) { |
|
239 | - foreach($this->rightList as $rightKey=>$rightElement) { |
|
240 | - $out .= '<simpleAssociableChoice identifier="right_'.$i.'" > |
|
238 | + if (is_array($this->rightList)) { |
|
239 | + foreach($this->rightList as $rightKey=>$rightElement) { |
|
240 | + $out .= '<simpleAssociableChoice identifier="right_'.$i.'" > |
|
241 | 241 | <![CDATA['.formatExerciseQtiTitle($rightElement['answer']).']]> |
242 | 242 | </simpleAssociableChoice>'. "\n"; |
243 | - $i++; |
|
244 | - } |
|
245 | - } |
|
243 | + $i++; |
|
244 | + } |
|
245 | + } |
|
246 | 246 | $out .= ' </simpleMatchSet>'. "\n"; |
247 | 247 | $out .= '</matchInteraction>'. "\n"; |
248 | 248 | |
@@ -254,30 +254,30 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public function imsExportResponsesDeclaration($questionIdent) |
256 | 256 | { |
257 | - $this->answerList = $this->getAnswersList(true); |
|
257 | + $this->answerList = $this->getAnswersList(true); |
|
258 | 258 | $out = ' <responseDeclaration identifier="' . $questionIdent . '" cardinality="single" baseType="identifier">' . "\n"; |
259 | 259 | $out .= ' <correctResponse>' . "\n"; |
260 | 260 | |
261 | 261 | $gradeArray = array(); |
262 | - if (is_array($this->leftList)) { |
|
263 | - foreach ($this->leftList as $leftKey=>$leftElement) { |
|
264 | - $i=0; |
|
265 | - foreach ($this->rightList as $rightKey=>$rightElement) { |
|
266 | - if (($leftElement['match'] == $rightElement['code'])) { |
|
267 | - $out .= ' <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n"; |
|
268 | - |
|
269 | - $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade']; |
|
270 | - } |
|
271 | - $i++; |
|
272 | - } |
|
273 | - } |
|
274 | - } |
|
262 | + if (is_array($this->leftList)) { |
|
263 | + foreach ($this->leftList as $leftKey=>$leftElement) { |
|
264 | + $i=0; |
|
265 | + foreach ($this->rightList as $rightKey=>$rightElement) { |
|
266 | + if (($leftElement['match'] == $rightElement['code'])) { |
|
267 | + $out .= ' <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n"; |
|
268 | + |
|
269 | + $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade']; |
|
270 | + } |
|
271 | + $i++; |
|
272 | + } |
|
273 | + } |
|
274 | + } |
|
275 | 275 | $out .= ' </correctResponse>'. "\n"; |
276 | 276 | $out .= ' <mapping>' . "\n"; |
277 | 277 | if (is_array($gradeArray)) { |
278 | - foreach ($gradeArray as $gradeKey=>$grade) { |
|
279 | - $out .= ' <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n"; |
|
280 | - } |
|
278 | + foreach ($gradeArray as $gradeKey=>$grade) { |
|
279 | + $out .= ' <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n"; |
|
280 | + } |
|
281 | 281 | } |
282 | 282 | $out .= ' </mapping>' . "\n"; |
283 | 283 | $out .= ' </responseDeclaration>'. "\n"; |
@@ -298,49 +298,49 @@ discard block |
||
298 | 298 | */ |
299 | 299 | public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='') |
300 | 300 | { |
301 | - $this->answerList = $this->getAnswersList(true); |
|
302 | - $questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia; |
|
303 | - $mimetype = mime_content_type($questionMedia); |
|
304 | - if(empty($mimetype)){ |
|
305 | - $mimetype = 'image/jpeg'; |
|
306 | - } |
|
307 | - |
|
308 | - $text = ' <p>'.$questionStatment.'</p>'."\n"; |
|
309 | - $text .= ' <graphicOrderInteraction responseIdentifier="hotspot_'.$questionIdent.'">'."\n"; |
|
310 | - $text .= ' <prompt>'.$questionDesc.'</prompt>'."\n"; |
|
311 | - $text .= ' <object type="'.$mimetype.'" width="250" height="230" data="'.$questionMedia.'">-</object>'."\n"; |
|
301 | + $this->answerList = $this->getAnswersList(true); |
|
302 | + $questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia; |
|
303 | + $mimetype = mime_content_type($questionMedia); |
|
304 | + if(empty($mimetype)){ |
|
305 | + $mimetype = 'image/jpeg'; |
|
306 | + } |
|
307 | + |
|
308 | + $text = ' <p>'.$questionStatment.'</p>'."\n"; |
|
309 | + $text .= ' <graphicOrderInteraction responseIdentifier="hotspot_'.$questionIdent.'">'."\n"; |
|
310 | + $text .= ' <prompt>'.$questionDesc.'</prompt>'."\n"; |
|
311 | + $text .= ' <object type="'.$mimetype.'" width="250" height="230" data="'.$questionMedia.'">-</object>'."\n"; |
|
312 | 312 | if (is_array($this->answerList)) { |
313 | - foreach ($this->answerList as $key=>$answer) { |
|
314 | - $key = $answer['id']; |
|
315 | - $answerTxt = $answer['answer']; |
|
316 | - $len = api_strlen($answerTxt); |
|
317 | - //coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663 |
|
318 | - $coords = ''; |
|
319 | - $type = 'default'; |
|
320 | - switch($answer['hotspot_type']){ |
|
321 | - case 'square': |
|
322 | - $type = 'rect'; |
|
323 | - $res = array(); |
|
324 | - $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
325 | - $coords = $res[1].','.$res[2].','.((int)$res[1]+(int)$res[3]).",".((int)$res[2]+(int)$res[4]); |
|
326 | - break; |
|
327 | - case 'circle': |
|
328 | - $type = 'circle'; |
|
329 | - $res = array(); |
|
330 | - $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
331 | - $coords = $res[1].','.$res[2].','.sqrt(pow(($res[1]-$res[3]),2)+pow(($res[2]-$res[4]))); |
|
332 | - break; |
|
333 | - case 'poly': |
|
334 | - $type = 'poly'; |
|
335 | - $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
336 | - break; |
|
337 | - case 'delineation' : |
|
338 | - $type = 'delineation'; |
|
339 | - $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
340 | - break; |
|
341 | - } |
|
342 | - $text .= ' <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n"; |
|
343 | - } |
|
313 | + foreach ($this->answerList as $key=>$answer) { |
|
314 | + $key = $answer['id']; |
|
315 | + $answerTxt = $answer['answer']; |
|
316 | + $len = api_strlen($answerTxt); |
|
317 | + //coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663 |
|
318 | + $coords = ''; |
|
319 | + $type = 'default'; |
|
320 | + switch($answer['hotspot_type']){ |
|
321 | + case 'square': |
|
322 | + $type = 'rect'; |
|
323 | + $res = array(); |
|
324 | + $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
325 | + $coords = $res[1].','.$res[2].','.((int)$res[1]+(int)$res[3]).",".((int)$res[2]+(int)$res[4]); |
|
326 | + break; |
|
327 | + case 'circle': |
|
328 | + $type = 'circle'; |
|
329 | + $res = array(); |
|
330 | + $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
331 | + $coords = $res[1].','.$res[2].','.sqrt(pow(($res[1]-$res[3]),2)+pow(($res[2]-$res[4]))); |
|
332 | + break; |
|
333 | + case 'poly': |
|
334 | + $type = 'poly'; |
|
335 | + $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
336 | + break; |
|
337 | + case 'delineation' : |
|
338 | + $type = 'delineation'; |
|
339 | + $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
340 | + break; |
|
341 | + } |
|
342 | + $text .= ' <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n"; |
|
343 | + } |
|
344 | 344 | } |
345 | 345 | $text .= ' </graphicOrderInteraction>'."\n"; |
346 | 346 | $out = $text; |
@@ -353,23 +353,23 @@ discard block |
||
353 | 353 | */ |
354 | 354 | public function imsExportResponsesDeclaration($questionIdent) |
355 | 355 | { |
356 | - $this->answerList = $this->getAnswersList(true); |
|
357 | - $this->gradeList = $this->getGradesList(); |
|
356 | + $this->answerList = $this->getAnswersList(true); |
|
357 | + $this->gradeList = $this->getGradesList(); |
|
358 | 358 | $out = ''; |
359 | 359 | $out .= ' <responseDeclaration identifier="hotspot_'.$questionIdent.'" cardinality="ordered" baseType="identifier">' . "\n"; |
360 | 360 | $out .= ' <correctResponse>'. "\n"; |
361 | 361 | |
362 | - if (is_array($this->answerList)) { |
|
363 | - foreach ($this->answerList as $answerKey=>$answer) { |
|
364 | - $answerKey = $answer['id']; |
|
365 | - $answer = $answer['answer']; |
|
366 | - $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>'; |
|
367 | - } |
|
368 | - } |
|
362 | + if (is_array($this->answerList)) { |
|
363 | + foreach ($this->answerList as $answerKey=>$answer) { |
|
364 | + $answerKey = $answer['id']; |
|
365 | + $answer = $answer['answer']; |
|
366 | + $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>'; |
|
367 | + } |
|
368 | + } |
|
369 | 369 | $out .= ' </correctResponse>'. "\n"; |
370 | 370 | $out .= ' </responseDeclaration>'. "\n"; |
371 | 371 | |
372 | - return $out; |
|
372 | + return $out; |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | |
@@ -384,14 +384,14 @@ discard block |
||
384 | 384 | * Export the question part as a matrix-choice, with only one possible answer per line. |
385 | 385 | */ |
386 | 386 | public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='') |
387 | - { |
|
388 | - return ''; |
|
389 | - } |
|
387 | + { |
|
388 | + return ''; |
|
389 | + } |
|
390 | 390 | /** |
391 | 391 | * |
392 | 392 | */ |
393 | 393 | public function imsExportResponsesDeclaration($questionIdent) |
394 | 394 | { |
395 | - return ''; |
|
395 | + return ''; |
|
396 | 396 | } |
397 | 397 | } |
@@ -281,7 +281,7 @@ |
||
281 | 281 | $correct_answer_index = array_search($matches[1], $answers_array); |
282 | 282 | $exercise_info['question'][$question_index]['title'] = $matches[1]; |
283 | 283 | } elseif (preg_match('/^TAGS:\s?([A-Z])\s?/', $info, $matches)) { |
284 | - //TAGS for chamilo >= 1.10 |
|
284 | + //TAGS for chamilo >= 1.10 |
|
285 | 285 | $exercise_info['question'][$question_index]['answer_tags'] = explode(',', $matches[1]); |
286 | 286 | } elseif (preg_match('/^ETIQUETAS:\s?([A-Z])\s?/', $info, $matches)) { |
287 | 287 | //TAGS for chamilo >= 1.10 (Spanish e-ducativa format) |
@@ -49,86 +49,86 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | - * Include the correct answer class and create answer |
|
53 | - */ |
|
54 | - public function setAnswer() |
|
55 | - { |
|
56 | - switch ($this->type) { |
|
57 | - case MCUA: |
|
58 | - $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
52 | + * Include the correct answer class and create answer |
|
53 | + */ |
|
54 | + public function setAnswer() |
|
55 | + { |
|
56 | + switch ($this->type) { |
|
57 | + case MCUA: |
|
58 | + $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
59 | 59 | $this->answer->questionJSId = $this->js_id; |
60 | - break; |
|
61 | - case MCMA: |
|
60 | + break; |
|
61 | + case MCMA: |
|
62 | 62 | case GLOBAL_MULTIPLE_ANSWER: |
63 | - $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
63 | + $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
64 | 64 | $this->answer->questionJSId = $this->js_id; |
65 | - break; |
|
66 | - case TF: |
|
67 | - $this->answer = new ScormAnswerTrueFalse($this->id); |
|
65 | + break; |
|
66 | + case TF: |
|
67 | + $this->answer = new ScormAnswerTrueFalse($this->id); |
|
68 | 68 | $this->answer->questionJSId = $this->js_id; |
69 | - break; |
|
70 | - case FIB: |
|
71 | - $this->answer = new ScormAnswerFillInBlanks($this->id); |
|
69 | + break; |
|
70 | + case FIB: |
|
71 | + $this->answer = new ScormAnswerFillInBlanks($this->id); |
|
72 | 72 | $this->answer->questionJSId = $this->js_id; |
73 | - break; |
|
74 | - case MATCHING: |
|
73 | + break; |
|
74 | + case MATCHING: |
|
75 | 75 | case MATCHING_DRAGGABLE: |
76 | - $this->answer = new ScormAnswerMatching($this->id); |
|
76 | + $this->answer = new ScormAnswerMatching($this->id); |
|
77 | 77 | $this->answer->questionJSId = $this->js_id; |
78 | - break; |
|
78 | + break; |
|
79 | 79 | case ORAL_EXPRESSION: |
80 | - case FREE_ANSWER: |
|
81 | - $this->answer = new ScormAnswerFree($this->id); |
|
80 | + case FREE_ANSWER: |
|
81 | + $this->answer = new ScormAnswerFree($this->id); |
|
82 | 82 | $this->answer->questionJSId = $this->js_id; |
83 | - break; |
|
84 | - case HOT_SPOT: |
|
85 | - $this->answer = new ScormAnswerHotspot($this->id); |
|
83 | + break; |
|
84 | + case HOT_SPOT: |
|
85 | + $this->answer = new ScormAnswerHotspot($this->id); |
|
86 | 86 | $this->answer->questionJSId = $this->js_id; |
87 | - break; |
|
88 | - case MULTIPLE_ANSWER_COMBINATION: |
|
89 | - $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
87 | + break; |
|
88 | + case MULTIPLE_ANSWER_COMBINATION: |
|
89 | + $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
90 | 90 | $this->answer->questionJSId = $this->js_id; |
91 | - break; |
|
91 | + break; |
|
92 | 92 | case HOT_SPOT_ORDER: |
93 | - $this->answer = new ScormAnswerHotspot($this->id); |
|
93 | + $this->answer = new ScormAnswerHotspot($this->id); |
|
94 | 94 | $this->answer->questionJSId = $this->js_id; |
95 | - break; |
|
96 | - case HOT_SPOT_DELINEATION: |
|
97 | - $this->answer = new ScormAnswerHotspot($this->id); |
|
95 | + break; |
|
96 | + case HOT_SPOT_DELINEATION: |
|
97 | + $this->answer = new ScormAnswerHotspot($this->id); |
|
98 | 98 | $this->answer->questionJSId = $this->js_id; |
99 | - break; |
|
100 | - default : |
|
101 | - $this->answer = null; |
|
99 | + break; |
|
100 | + default : |
|
101 | + $this->answer = null; |
|
102 | 102 | $this->answer->questionJSId = $this->js_id; |
103 | - break; |
|
104 | - } |
|
103 | + break; |
|
104 | + } |
|
105 | 105 | |
106 | - return true; |
|
107 | - } |
|
106 | + return true; |
|
107 | + } |
|
108 | 108 | |
109 | - function export() |
|
110 | - { |
|
111 | - $html = $this->getQuestionHTML(); |
|
112 | - $js = $this->getQuestionJS(); |
|
109 | + function export() |
|
110 | + { |
|
111 | + $html = $this->getQuestionHTML(); |
|
112 | + $js = $this->getQuestionJS(); |
|
113 | 113 | |
114 | - if( is_object($this->answer) ) |
|
115 | - { |
|
116 | - list($js2,$html2) = $this->answer->export(); |
|
117 | - $js .= $js2; |
|
118 | - $html .= $html2; |
|
119 | - } |
|
114 | + if( is_object($this->answer) ) |
|
115 | + { |
|
116 | + list($js2,$html2) = $this->answer->export(); |
|
117 | + $js .= $js2; |
|
118 | + $html .= $html2; |
|
119 | + } |
|
120 | 120 | |
121 | - return array($js,$html); |
|
122 | - } |
|
121 | + return array($js,$html); |
|
122 | + } |
|
123 | 123 | |
124 | 124 | function createAnswersForm($form) |
125 | 125 | { |
126 | - return true; |
|
126 | + return true; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | function processAnswersCreation($form) |
130 | 130 | { |
131 | - return true; |
|
131 | + return true; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -136,20 +136,20 @@ discard block |
||
136 | 136 | */ |
137 | 137 | function getQuestionHTML() |
138 | 138 | { |
139 | - $title = $this->selectTitle(); |
|
140 | - $description = $this->selectDescription(); |
|
141 | - $cols = 2; |
|
142 | - $s='<tr>' . |
|
143 | - '<td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;">' . "\n" . |
|
144 | - $title. |
|
145 | - '</td>' . "\n" . |
|
146 | - '</tr>' . "\n" . |
|
147 | - '<tr>' . "\n" . |
|
148 | - '<td valign="top" colspan="'.$cols.'">' . "\n" . |
|
149 | - '<i>'.$description.'</i>' . "\n" . |
|
150 | - '</td>' . "\n" . |
|
151 | - '</tr>' . "\n"; |
|
152 | - return $s; |
|
139 | + $title = $this->selectTitle(); |
|
140 | + $description = $this->selectDescription(); |
|
141 | + $cols = 2; |
|
142 | + $s='<tr>' . |
|
143 | + '<td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;">' . "\n" . |
|
144 | + $title. |
|
145 | + '</td>' . "\n" . |
|
146 | + '</tr>' . "\n" . |
|
147 | + '<tr>' . "\n" . |
|
148 | + '<td valign="top" colspan="'.$cols.'">' . "\n" . |
|
149 | + '<i>'.$description.'</i>' . "\n" . |
|
150 | + '</td>' . "\n" . |
|
151 | + '</tr>' . "\n"; |
|
152 | + return $s; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -157,16 +157,16 @@ discard block |
||
157 | 157 | */ |
158 | 158 | function getQuestionJS() |
159 | 159 | { |
160 | - //$id = $this->id; |
|
161 | - $w = $this->selectWeighting(); |
|
162 | - $s = 'questions.push('.$this->js_id.');'."\n"; |
|
163 | - if($this->type == FREE_ANSWER or $this->type == HOT_SPOT) |
|
164 | - { //put the max score to 0 to avoid discounting the points of |
|
165 | - //non-exported quiz types in the SCORM |
|
166 | - $w=0; |
|
167 | - } |
|
168 | - $s .= 'questions_score_max['.$this->js_id.'] = '.$w.";\n"; |
|
169 | - return $s; |
|
160 | + //$id = $this->id; |
|
161 | + $w = $this->selectWeighting(); |
|
162 | + $s = 'questions.push('.$this->js_id.');'."\n"; |
|
163 | + if($this->type == FREE_ANSWER or $this->type == HOT_SPOT) |
|
164 | + { //put the max score to 0 to avoid discounting the points of |
|
165 | + //non-exported quiz types in the SCORM |
|
166 | + $w=0; |
|
167 | + } |
|
168 | + $s .= 'questions_score_max['.$this->js_id.'] = '.$w.";\n"; |
|
169 | + return $s; |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
@@ -177,107 +177,107 @@ discard block |
||
177 | 177 | */ |
178 | 178 | class ScormAnswerMultipleChoice extends Answer |
179 | 179 | { |
180 | - /** |
|
181 | - * Return HTML code for possible answers |
|
180 | + /** |
|
181 | + * Return HTML code for possible answers |
|
182 | 182 | */ |
183 | - function export() |
|
184 | - { |
|
185 | - $html = ''; |
|
186 | - $js = ''; |
|
187 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
188 | - $type = $this->getQuestionType(); |
|
189 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
190 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
191 | - |
|
192 | - //not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM |
|
183 | + function export() |
|
184 | + { |
|
185 | + $html = ''; |
|
186 | + $js = ''; |
|
187 | + $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
188 | + $type = $this->getQuestionType(); |
|
189 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
190 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
191 | + |
|
192 | + //not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM |
|
193 | 193 | //if ($type == MCMA || $type == MULTIPLE_ANSWER_COMBINATION ) { |
194 | - if ($type == MCMA ) { |
|
195 | - //$questionTypeLang = get_lang('MultipleChoiceMultipleAnswers'); |
|
196 | - $id = 1; |
|
197 | - $jstmp = ''; |
|
198 | - $jstmpc = ''; |
|
199 | - foreach( $this->answer as $i => $answer ) |
|
200 | - { |
|
201 | - $identifier = 'question_'.$this->questionJSId.'_multiple_'.$i; |
|
202 | - $html .= |
|
203 | - '<tr>' . "\n" |
|
204 | - . '<td align="center" width="5%">' . "\n" |
|
205 | - . '<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />' . "\n" |
|
206 | - . '</td>' . "\n" |
|
207 | - . '<td width="95%">' . "\n" |
|
208 | - . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
209 | - . '</td>' . "\n" |
|
210 | - . '</tr>' . "\n\n"; |
|
211 | - $jstmp .= $i.','; |
|
212 | - if($this->correct[$i]) |
|
213 | - { |
|
214 | - $jstmpc .= $i.','; |
|
215 | - } |
|
216 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
|
217 | - $id++; |
|
218 | - } |
|
219 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
220 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
221 | - if ($type == MCMA) { |
|
222 | - $js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n"; |
|
223 | - } else { |
|
224 | - $js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n"; |
|
225 | - } |
|
226 | - $js .= $jstmpw; |
|
194 | + if ($type == MCMA ) { |
|
195 | + //$questionTypeLang = get_lang('MultipleChoiceMultipleAnswers'); |
|
196 | + $id = 1; |
|
197 | + $jstmp = ''; |
|
198 | + $jstmpc = ''; |
|
199 | + foreach( $this->answer as $i => $answer ) |
|
200 | + { |
|
201 | + $identifier = 'question_'.$this->questionJSId.'_multiple_'.$i; |
|
202 | + $html .= |
|
203 | + '<tr>' . "\n" |
|
204 | + . '<td align="center" width="5%">' . "\n" |
|
205 | + . '<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />' . "\n" |
|
206 | + . '</td>' . "\n" |
|
207 | + . '<td width="95%">' . "\n" |
|
208 | + . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
209 | + . '</td>' . "\n" |
|
210 | + . '</tr>' . "\n\n"; |
|
211 | + $jstmp .= $i.','; |
|
212 | + if($this->correct[$i]) |
|
213 | + { |
|
214 | + $jstmpc .= $i.','; |
|
215 | + } |
|
216 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
|
217 | + $id++; |
|
218 | + } |
|
219 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
220 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
221 | + if ($type == MCMA) { |
|
222 | + $js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n"; |
|
223 | + } else { |
|
224 | + $js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n"; |
|
225 | + } |
|
226 | + $js .= $jstmpw; |
|
227 | 227 | } elseif ($type == MULTIPLE_ANSWER_COMBINATION) { |
228 | - //To this items we show the ThisItemIsNotExportable |
|
229 | - $qId = $this->questionJSId; |
|
230 | - $js = ''; |
|
231 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
232 | - // some javascript must be added for that kind of questions |
|
233 | - $html .= '<tr>' . "\n" |
|
234 | - . '<td>' . "\n" |
|
235 | - . '<textarea name="question_'.$qId.'_free" id="question_'.$qId.'_exact" rows="20" cols="100"></textarea>' . "\n" |
|
236 | - . '</td>' . "\n" |
|
237 | - . '</tr>' . "\n"; |
|
238 | - $html .= '</table></td></tr>' . "\n"; |
|
239 | - // currently the exact answers cannot be displayed, so ignore the textarea |
|
240 | - $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
241 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
242 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
243 | - $js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n"; |
|
244 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
245 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
246 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
247 | - $js .= $jstmpw; |
|
248 | - return array($js,$html); |
|
228 | + //To this items we show the ThisItemIsNotExportable |
|
229 | + $qId = $this->questionJSId; |
|
230 | + $js = ''; |
|
231 | + $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
232 | + // some javascript must be added for that kind of questions |
|
233 | + $html .= '<tr>' . "\n" |
|
234 | + . '<td>' . "\n" |
|
235 | + . '<textarea name="question_'.$qId.'_free" id="question_'.$qId.'_exact" rows="20" cols="100"></textarea>' . "\n" |
|
236 | + . '</td>' . "\n" |
|
237 | + . '</tr>' . "\n"; |
|
238 | + $html .= '</table></td></tr>' . "\n"; |
|
239 | + // currently the exact answers cannot be displayed, so ignore the textarea |
|
240 | + $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
241 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
242 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
243 | + $js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n"; |
|
244 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
245 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
246 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
247 | + $js .= $jstmpw; |
|
248 | + return array($js,$html); |
|
249 | 249 | } else { |
250 | - //$questionTypeLang = get_lang('MultipleChoiceUniqueAnswer'); |
|
251 | - $id = 1; |
|
252 | - $jstmp = ''; |
|
253 | - $jstmpc = ''; |
|
254 | - foreach( $this->answer as $i => $answer ) |
|
255 | - { |
|
256 | - $identifier = 'question_'.$this->questionJSId.'_unique_'.$i; |
|
257 | - $identifier_name = 'question_'.$this->questionJSId.'_unique_answer'; |
|
258 | - $html .= |
|
259 | - '<tr>' . "\n" |
|
260 | - . '<td align="center" width="5%">' . "\n" |
|
261 | - . '<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="radio"/>' . "\n" |
|
262 | - . '</td>' . "\n" |
|
263 | - . '<td width="95%">' . "\n" |
|
264 | - . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
265 | - . '</td>' . "\n" |
|
266 | - . '</tr>' . "\n\n"; |
|
267 | - $jstmp .= $i.','; |
|
268 | - if($this->correct[$i]) |
|
269 | - { |
|
270 | - $jstmpc .= $i; |
|
271 | - } |
|
272 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
|
273 | - $id++; |
|
274 | - } |
|
275 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
276 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = '.$jstmpc.';'."\n"; |
|
277 | - $js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';'."\n"; |
|
278 | - $js .= $jstmpw; |
|
250 | + //$questionTypeLang = get_lang('MultipleChoiceUniqueAnswer'); |
|
251 | + $id = 1; |
|
252 | + $jstmp = ''; |
|
253 | + $jstmpc = ''; |
|
254 | + foreach( $this->answer as $i => $answer ) |
|
255 | + { |
|
256 | + $identifier = 'question_'.$this->questionJSId.'_unique_'.$i; |
|
257 | + $identifier_name = 'question_'.$this->questionJSId.'_unique_answer'; |
|
258 | + $html .= |
|
259 | + '<tr>' . "\n" |
|
260 | + . '<td align="center" width="5%">' . "\n" |
|
261 | + . '<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="radio"/>' . "\n" |
|
262 | + . '</td>' . "\n" |
|
263 | + . '<td width="95%">' . "\n" |
|
264 | + . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
265 | + . '</td>' . "\n" |
|
266 | + . '</tr>' . "\n\n"; |
|
267 | + $jstmp .= $i.','; |
|
268 | + if($this->correct[$i]) |
|
269 | + { |
|
270 | + $jstmpc .= $i; |
|
271 | + } |
|
272 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
|
273 | + $id++; |
|
274 | + } |
|
275 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
276 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = '.$jstmpc.';'."\n"; |
|
277 | + $js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';'."\n"; |
|
278 | + $js .= $jstmpw; |
|
279 | 279 | } |
280 | - $html .= '</table></td></tr>' . "\n"; |
|
280 | + $html .= '</table></td></tr>' . "\n"; |
|
281 | 281 | return array($js,$html); |
282 | 282 | } |
283 | 283 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | */ |
289 | 289 | class ScormAnswerTrueFalse extends Answer |
290 | 290 | { |
291 | - /** |
|
291 | + /** |
|
292 | 292 | * Return the XML flow for the possible answers. |
293 | 293 | * That's one <response_lid>, containing several <flow_label> |
294 | 294 | * |
@@ -296,46 +296,46 @@ discard block |
||
296 | 296 | */ |
297 | 297 | function export() |
298 | 298 | { |
299 | - $js = ''; |
|
300 | - $html = '<tr><td colspan="2"><table width="100%">'; |
|
301 | - $identifier = 'question_'.$this->questionJSId.'_tf'; |
|
302 | - $identifier_true = $identifier.'_true'; |
|
303 | - $identifier_false = $identifier.'_false'; |
|
304 | - $html .= |
|
305 | - '<tr>' . "\n" |
|
306 | - . '<td align="center" width="5%">' . "\n" |
|
307 | - . '<input name="'.$identifier_true.'" id="'.$identifier_true.'" value="'.$this->trueGrade.'" type="radio" ' |
|
308 | - . '/>' . "\n" |
|
309 | - . '</td>' . "\n" |
|
310 | - . '<td width="95%">' . "\n" |
|
311 | - . '<label for="'.$identifier_true.'">' . get_lang('True') . '</label>' . "\n" |
|
312 | - . '</td>' . "\n" |
|
313 | - . '</tr>' . "\n\n"; |
|
314 | - $html .= |
|
315 | - '<tr>' . "\n" |
|
316 | - . '<td align="center" width="5%">' . "\n" |
|
317 | - . '<input name="'.$identifier_false.'" id="'.$identifier_false.'" value="'.$this->falseGrade.'" type="radio" ' |
|
318 | - . '/>' . "\n" |
|
319 | - . '</td>' . "\n" |
|
320 | - . '<td width="95%">' . "\n" |
|
321 | - . '<label for="'.$identifier_false.'">' . get_lang('False') . '</label>' . "\n" |
|
322 | - . '</td>' . "\n" |
|
323 | - . '</tr>' . "\n\n"; |
|
324 | - $html .= '</table></td></tr>' . "\n"; |
|
325 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n"; |
|
326 | - $js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n"; |
|
327 | - if($this->response == 'TRUE') |
|
328 | - { |
|
329 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n"; |
|
330 | - } |
|
331 | - else |
|
332 | - { |
|
333 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n"; |
|
334 | - } |
|
335 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
336 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
337 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n"; |
|
338 | - $js .= $jstmpw; |
|
299 | + $js = ''; |
|
300 | + $html = '<tr><td colspan="2"><table width="100%">'; |
|
301 | + $identifier = 'question_'.$this->questionJSId.'_tf'; |
|
302 | + $identifier_true = $identifier.'_true'; |
|
303 | + $identifier_false = $identifier.'_false'; |
|
304 | + $html .= |
|
305 | + '<tr>' . "\n" |
|
306 | + . '<td align="center" width="5%">' . "\n" |
|
307 | + . '<input name="'.$identifier_true.'" id="'.$identifier_true.'" value="'.$this->trueGrade.'" type="radio" ' |
|
308 | + . '/>' . "\n" |
|
309 | + . '</td>' . "\n" |
|
310 | + . '<td width="95%">' . "\n" |
|
311 | + . '<label for="'.$identifier_true.'">' . get_lang('True') . '</label>' . "\n" |
|
312 | + . '</td>' . "\n" |
|
313 | + . '</tr>' . "\n\n"; |
|
314 | + $html .= |
|
315 | + '<tr>' . "\n" |
|
316 | + . '<td align="center" width="5%">' . "\n" |
|
317 | + . '<input name="'.$identifier_false.'" id="'.$identifier_false.'" value="'.$this->falseGrade.'" type="radio" ' |
|
318 | + . '/>' . "\n" |
|
319 | + . '</td>' . "\n" |
|
320 | + . '<td width="95%">' . "\n" |
|
321 | + . '<label for="'.$identifier_false.'">' . get_lang('False') . '</label>' . "\n" |
|
322 | + . '</td>' . "\n" |
|
323 | + . '</tr>' . "\n\n"; |
|
324 | + $html .= '</table></td></tr>' . "\n"; |
|
325 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n"; |
|
326 | + $js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n"; |
|
327 | + if($this->response == 'TRUE') |
|
328 | + { |
|
329 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n"; |
|
330 | + } |
|
331 | + else |
|
332 | + { |
|
333 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n"; |
|
334 | + } |
|
335 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
336 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
337 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n"; |
|
338 | + $js .= $jstmpw; |
|
339 | 339 | |
340 | 340 | return array($js,$html); |
341 | 341 | } |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | */ |
348 | 348 | class ScormAnswerFillInBlanks extends Answer |
349 | 349 | { |
350 | - /** |
|
350 | + /** |
|
351 | 351 | * Export the text with missing words. |
352 | 352 | * |
353 | 353 | * As a side effect, it stores two lists in the class : |
@@ -355,57 +355,57 @@ discard block |
||
355 | 355 | */ |
356 | 356 | function export() |
357 | 357 | { |
358 | - global $charset; |
|
359 | - $js = ''; |
|
360 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
361 | - // get all enclosed answers |
|
362 | - $blankList = array(); |
|
363 | - // build replacement |
|
364 | - $replacementList = array(); |
|
365 | - foreach( $this->answer as $i => $answer) { |
|
366 | - $blankList[] = '['.$answer.']'; |
|
367 | - } |
|
368 | - $answerCount = count($blankList); |
|
369 | - |
|
370 | - // splits text and weightings that are joined with the character '::' |
|
371 | - list($answer,$weight)=explode('::',$answer); |
|
372 | - $weights = explode(',',$weight); |
|
373 | - // because [] is parsed here we follow this procedure: |
|
374 | - // 1. find everything between the [ and ] tags |
|
375 | - $i=1; |
|
376 | - $jstmp = ''; |
|
377 | - $jstmpc = ''; |
|
378 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
379 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
380 | - $startlocations=api_strpos($answer,'['); |
|
381 | - $endlocations=api_strpos($answer,']'); |
|
382 | - while($startlocations !== false && $endlocations !== false) { |
|
383 | - $texstring=api_substr($answer,$startlocations,($endlocations-$startlocations)+1); |
|
384 | - $answer = api_substr_replace($answer,'<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />',$startlocations,($endlocations-$startlocations)+1); |
|
385 | - $jstmp .= $i.','; |
|
386 | - $jstmpc .= "'".api_htmlentities(api_substr($texstring,1,-1),ENT_QUOTES,$charset)."',"; |
|
387 | - $my_weight=explode('@',$weights[$i-1]); |
|
388 | - if (count($my_weight)==2) { |
|
389 | - $weight_db=$my_weight[0]; |
|
390 | - } else { |
|
391 | - $weight_db=$my_weight[0]; |
|
392 | - } |
|
393 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n"; |
|
394 | - $i++; |
|
395 | - $startlocations=api_strpos($answer,'['); |
|
396 | - $endlocations=api_strpos($answer,']'); |
|
397 | - } |
|
358 | + global $charset; |
|
359 | + $js = ''; |
|
360 | + $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
361 | + // get all enclosed answers |
|
362 | + $blankList = array(); |
|
363 | + // build replacement |
|
364 | + $replacementList = array(); |
|
365 | + foreach( $this->answer as $i => $answer) { |
|
366 | + $blankList[] = '['.$answer.']'; |
|
367 | + } |
|
368 | + $answerCount = count($blankList); |
|
369 | + |
|
370 | + // splits text and weightings that are joined with the character '::' |
|
371 | + list($answer,$weight)=explode('::',$answer); |
|
372 | + $weights = explode(',',$weight); |
|
373 | + // because [] is parsed here we follow this procedure: |
|
374 | + // 1. find everything between the [ and ] tags |
|
375 | + $i=1; |
|
376 | + $jstmp = ''; |
|
377 | + $jstmpc = ''; |
|
378 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
379 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
380 | + $startlocations=api_strpos($answer,'['); |
|
381 | + $endlocations=api_strpos($answer,']'); |
|
382 | + while($startlocations !== false && $endlocations !== false) { |
|
383 | + $texstring=api_substr($answer,$startlocations,($endlocations-$startlocations)+1); |
|
384 | + $answer = api_substr_replace($answer,'<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />',$startlocations,($endlocations-$startlocations)+1); |
|
385 | + $jstmp .= $i.','; |
|
386 | + $jstmpc .= "'".api_htmlentities(api_substr($texstring,1,-1),ENT_QUOTES,$charset)."',"; |
|
387 | + $my_weight=explode('@',$weights[$i-1]); |
|
388 | + if (count($my_weight)==2) { |
|
389 | + $weight_db=$my_weight[0]; |
|
390 | + } else { |
|
391 | + $weight_db=$my_weight[0]; |
|
392 | + } |
|
393 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n"; |
|
394 | + $i++; |
|
395 | + $startlocations=api_strpos($answer,'['); |
|
396 | + $endlocations=api_strpos($answer,']'); |
|
397 | + } |
|
398 | 398 | |
399 | - $html .= '<tr>' . "\n" |
|
400 | - . '<td>' . "\n" |
|
401 | - . $answer . "\n" |
|
402 | - . '</td>' . "\n" |
|
403 | - . '</tr>' . "\n"; |
|
404 | - $html .= '</table></td></tr>' . "\n"; |
|
405 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n"; |
|
406 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n"; |
|
407 | - $js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n"; |
|
408 | - $js .= $jstmpw; |
|
399 | + $html .= '<tr>' . "\n" |
|
400 | + . '<td>' . "\n" |
|
401 | + . $answer . "\n" |
|
402 | + . '</td>' . "\n" |
|
403 | + . '</tr>' . "\n"; |
|
404 | + $html .= '</table></td></tr>' . "\n"; |
|
405 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n"; |
|
406 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n"; |
|
407 | + $js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n"; |
|
408 | + $js .= $jstmpw; |
|
409 | 409 | return array($js,$html); |
410 | 410 | } |
411 | 411 | } |
@@ -416,101 +416,101 @@ discard block |
||
416 | 416 | */ |
417 | 417 | class ScormAnswerMatching extends Answer |
418 | 418 | { |
419 | - /** |
|
419 | + /** |
|
420 | 420 | * Export the question part as a matrix-choice, with only one possible answer per line. |
421 | 421 | * @author Amand Tihon <[email protected]> |
422 | 422 | */ |
423 | 423 | function export() |
424 | 424 | { |
425 | - $js = ''; |
|
426 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
427 | - // prepare list of right proposition to allow |
|
428 | - // - easiest display |
|
429 | - // - easiest randomisation if needed one day |
|
430 | - // (here I use array_values to change array keys from $code1 $code2 ... to 0 1 ...) |
|
431 | - if (is_array($this->rightList)) { |
|
432 | - $displayedRightList = array_values($this->rightList); |
|
433 | - } |
|
434 | - // get max length of displayed array |
|
435 | - $arrayLength = max( count($this->leftList), count($this->rightList) ); |
|
436 | - |
|
437 | - $nbrAnswers=$this->selectNbrAnswers(); |
|
438 | - $cpt1='A'; |
|
439 | - $cpt2=1; |
|
440 | - $Select=array(); |
|
441 | - $qId = $this->questionJSId; |
|
442 | - $s = ''; |
|
443 | - $jstmp = ''; |
|
444 | - $jstmpc = ''; |
|
425 | + $js = ''; |
|
426 | + $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
427 | + // prepare list of right proposition to allow |
|
428 | + // - easiest display |
|
429 | + // - easiest randomisation if needed one day |
|
430 | + // (here I use array_values to change array keys from $code1 $code2 ... to 0 1 ...) |
|
431 | + if (is_array($this->rightList)) { |
|
432 | + $displayedRightList = array_values($this->rightList); |
|
433 | + } |
|
434 | + // get max length of displayed array |
|
435 | + $arrayLength = max( count($this->leftList), count($this->rightList) ); |
|
436 | + |
|
437 | + $nbrAnswers=$this->selectNbrAnswers(); |
|
438 | + $cpt1='A'; |
|
439 | + $cpt2=1; |
|
440 | + $Select=array(); |
|
441 | + $qId = $this->questionJSId; |
|
442 | + $s = ''; |
|
443 | + $jstmp = ''; |
|
444 | + $jstmpc = ''; |
|
445 | 445 | $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
446 | 446 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
447 | 447 | |
448 | - for($answerId=1;$answerId <= $nbrAnswers;$answerId++) { |
|
449 | - $identifier = 'question_'.$qId.'_matching_'; |
|
450 | - $answer=$this->selectAnswer($answerId); |
|
451 | - $answerCorrect=$this->isCorrect($answerId); |
|
452 | - $weight=$this->selectWeighting($answerId); |
|
453 | - $jstmp .= $answerId.','; |
|
454 | - |
|
455 | - if (!$answerCorrect) { |
|
456 | - // options (A, B, C, ...) that will be put into the list-box |
|
457 | - $Select[$answerId]['Lettre']=$cpt1; |
|
458 | - // answers that will be shown at the right side |
|
459 | - $Select[$answerId]['Reponse'] = $answer; |
|
460 | - $cpt1++; |
|
461 | - } else { |
|
462 | - $s.='<tr>'."\n"; |
|
463 | - $s.='<td width="40%" valign="top">'."\n".'<b>'.$cpt2.'</b>. '.$answer."\n</td>\n"; |
|
464 | - $s.='<td width="20%" align="center"> <select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">'; |
|
465 | - $s.=' <option value="0">--</option>'; |
|
466 | - // fills the list-box |
|
467 | - foreach($Select as $key=>$val) |
|
468 | - { |
|
469 | - $s.='<option value="'.$key.'">'.$val['Lettre'].'</option>'; |
|
470 | - } // end foreach() |
|
471 | - |
|
472 | - $s.='</select> </td>'."\n"; |
|
473 | - $s.='<td width="40%" valign="top">'; |
|
474 | - if(isset($Select[$cpt2])) $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
475 | - else $s.=' '; |
|
476 | - $s.="</td>\n</tr>\n"; |
|
477 | - |
|
478 | - $jstmpc .= '['.$answerCorrect.','.$cpt2.'],'; |
|
479 | - |
|
480 | - $my_weight=explode('@',$weight); |
|
481 | - if (count($my_weight)==2) { |
|
482 | - $weight=$my_weight[0]; |
|
483 | - } else { |
|
484 | - $weight=$my_weight[0]; |
|
485 | - } |
|
486 | - $jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n"; |
|
487 | - $cpt2++; |
|
488 | - |
|
489 | - // if the left side of the "matching" has been completely shown |
|
490 | - if($answerId == $nbrAnswers) |
|
491 | - { |
|
492 | - // if there remain answers to be shown on the right side |
|
493 | - while(isset($Select[$cpt2])) |
|
494 | - { |
|
495 | - //$s.='<tr>'."\n"; |
|
496 | - //$s.='<td colspan="2">'."\n"; |
|
497 | - //$s.='<table border="0" cellpadding="0" cellspacing="0" width="100%">'."\n"; |
|
498 | - $s.='<tr>'."\n"; |
|
499 | - $s.='<td width="60%" colspan="2"> </td>'."\n"; |
|
500 | - $s.='<td width="40%" valign="top">'; |
|
501 | - $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
502 | - $s.="</td>\n</tr>\n"; |
|
503 | - $cpt2++; |
|
504 | - } // end while() |
|
505 | - } // end if() |
|
506 | - } |
|
507 | - } |
|
508 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
509 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
510 | - $js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n"; |
|
511 | - $js .= $jstmpw; |
|
512 | - $html .= $s; |
|
513 | - $html .= '</table></td></tr>' . "\n"; |
|
448 | + for($answerId=1;$answerId <= $nbrAnswers;$answerId++) { |
|
449 | + $identifier = 'question_'.$qId.'_matching_'; |
|
450 | + $answer=$this->selectAnswer($answerId); |
|
451 | + $answerCorrect=$this->isCorrect($answerId); |
|
452 | + $weight=$this->selectWeighting($answerId); |
|
453 | + $jstmp .= $answerId.','; |
|
454 | + |
|
455 | + if (!$answerCorrect) { |
|
456 | + // options (A, B, C, ...) that will be put into the list-box |
|
457 | + $Select[$answerId]['Lettre']=$cpt1; |
|
458 | + // answers that will be shown at the right side |
|
459 | + $Select[$answerId]['Reponse'] = $answer; |
|
460 | + $cpt1++; |
|
461 | + } else { |
|
462 | + $s.='<tr>'."\n"; |
|
463 | + $s.='<td width="40%" valign="top">'."\n".'<b>'.$cpt2.'</b>. '.$answer."\n</td>\n"; |
|
464 | + $s.='<td width="20%" align="center"> <select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">'; |
|
465 | + $s.=' <option value="0">--</option>'; |
|
466 | + // fills the list-box |
|
467 | + foreach($Select as $key=>$val) |
|
468 | + { |
|
469 | + $s.='<option value="'.$key.'">'.$val['Lettre'].'</option>'; |
|
470 | + } // end foreach() |
|
471 | + |
|
472 | + $s.='</select> </td>'."\n"; |
|
473 | + $s.='<td width="40%" valign="top">'; |
|
474 | + if(isset($Select[$cpt2])) $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
475 | + else $s.=' '; |
|
476 | + $s.="</td>\n</tr>\n"; |
|
477 | + |
|
478 | + $jstmpc .= '['.$answerCorrect.','.$cpt2.'],'; |
|
479 | + |
|
480 | + $my_weight=explode('@',$weight); |
|
481 | + if (count($my_weight)==2) { |
|
482 | + $weight=$my_weight[0]; |
|
483 | + } else { |
|
484 | + $weight=$my_weight[0]; |
|
485 | + } |
|
486 | + $jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n"; |
|
487 | + $cpt2++; |
|
488 | + |
|
489 | + // if the left side of the "matching" has been completely shown |
|
490 | + if($answerId == $nbrAnswers) |
|
491 | + { |
|
492 | + // if there remain answers to be shown on the right side |
|
493 | + while(isset($Select[$cpt2])) |
|
494 | + { |
|
495 | + //$s.='<tr>'."\n"; |
|
496 | + //$s.='<td colspan="2">'."\n"; |
|
497 | + //$s.='<table border="0" cellpadding="0" cellspacing="0" width="100%">'."\n"; |
|
498 | + $s.='<tr>'."\n"; |
|
499 | + $s.='<td width="60%" colspan="2"> </td>'."\n"; |
|
500 | + $s.='<td width="40%" valign="top">'; |
|
501 | + $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
502 | + $s.="</td>\n</tr>\n"; |
|
503 | + $cpt2++; |
|
504 | + } // end while() |
|
505 | + } // end if() |
|
506 | + } |
|
507 | + } |
|
508 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
509 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
510 | + $js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n"; |
|
511 | + $js .= $jstmpw; |
|
512 | + $html .= $s; |
|
513 | + $html .= '</table></td></tr>' . "\n"; |
|
514 | 514 | |
515 | 515 | return array($js,$html); |
516 | 516 | } |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | */ |
523 | 523 | class ScormAnswerFree extends Answer |
524 | 524 | { |
525 | - /** |
|
525 | + /** |
|
526 | 526 | * Export the text with missing words. |
527 | 527 | * |
528 | 528 | * As a side effect, it stores two lists in the class : |
@@ -531,24 +531,24 @@ discard block |
||
531 | 531 | */ |
532 | 532 | function export() |
533 | 533 | { |
534 | - //$qId = $this->questionJSId; |
|
535 | - $js = ''; |
|
536 | - /*$html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
534 | + //$qId = $this->questionJSId; |
|
535 | + $js = ''; |
|
536 | + /*$html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
537 | 537 | // some javascript must be added for that kind of questions |
538 | 538 | $html .= '<tr><td> |
539 | 539 | <textarea name="question_'.$qId.'_free" id="question_'.$qId.'_free" rows="20" cols="100"></textarea> |
540 | 540 | </td> |
541 | 541 | </tr>'; |
542 | 542 | $html .= '</table></td></tr>';*/ |
543 | - // currently the free answers cannot be displayed, so ignore the textarea |
|
544 | - $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
545 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
546 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
547 | - $js .= 'questions_types['.$this->questionJSId.'] = \'free\';'."\n"; |
|
548 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
549 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
550 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
551 | - $js .= $jstmpw; |
|
543 | + // currently the free answers cannot be displayed, so ignore the textarea |
|
544 | + $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
545 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
546 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
547 | + $js .= 'questions_types['.$this->questionJSId.'] = \'free\';'."\n"; |
|
548 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
549 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
550 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
551 | + $js .= $jstmpw; |
|
552 | 552 | return array($js,$html); |
553 | 553 | } |
554 | 554 | } |
@@ -558,40 +558,40 @@ discard block |
||
558 | 558 | */ |
559 | 559 | class ScormAnswerHotspot extends Answer |
560 | 560 | { |
561 | - /** |
|
562 | - * Returns the javascript code that goes with HotSpot exercises |
|
563 | - * @return string The JavaScript code |
|
564 | - */ |
|
565 | - function get_js_header() |
|
566 | - { |
|
567 | - if ($this->standalone) { |
|
568 | - $header = '<script type="text/javascript" language="javascript">'; |
|
569 | - $header .= file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js'); |
|
570 | - $header .= '</script>'; |
|
571 | - //because this header closes so many times the <script> tag, we have to reopen our own |
|
572 | - $header .= '<script type="text/javascript" language="javascript">'."\n"; |
|
573 | - $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
574 | - $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
575 | - $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
576 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
577 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
578 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
579 | - $header .= $jstmpw; |
|
580 | - } |
|
581 | - else |
|
582 | - { |
|
583 | - $header = ''; |
|
584 | - $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
585 | - $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
586 | - $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
587 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
588 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
589 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'."\n"; |
|
590 | - $header .= $jstmpw; |
|
591 | - } |
|
592 | - return $header; |
|
593 | - } |
|
594 | - /** |
|
561 | + /** |
|
562 | + * Returns the javascript code that goes with HotSpot exercises |
|
563 | + * @return string The JavaScript code |
|
564 | + */ |
|
565 | + function get_js_header() |
|
566 | + { |
|
567 | + if ($this->standalone) { |
|
568 | + $header = '<script type="text/javascript" language="javascript">'; |
|
569 | + $header .= file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js'); |
|
570 | + $header .= '</script>'; |
|
571 | + //because this header closes so many times the <script> tag, we have to reopen our own |
|
572 | + $header .= '<script type="text/javascript" language="javascript">'."\n"; |
|
573 | + $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
574 | + $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
575 | + $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
576 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
577 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
578 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
579 | + $header .= $jstmpw; |
|
580 | + } |
|
581 | + else |
|
582 | + { |
|
583 | + $header = ''; |
|
584 | + $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
585 | + $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
586 | + $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
587 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
588 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
589 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'."\n"; |
|
590 | + $header .= $jstmpw; |
|
591 | + } |
|
592 | + return $header; |
|
593 | + } |
|
594 | + /** |
|
595 | 595 | * Export the text with missing words. |
596 | 596 | * |
597 | 597 | * As a side effect, it stores two lists in the class : |
@@ -600,22 +600,22 @@ discard block |
||
600 | 600 | */ |
601 | 601 | function export() |
602 | 602 | { |
603 | - $js = $this->get_js_header(); |
|
604 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
605 | - // some javascript must be added for that kind of questions |
|
606 | - $html .= ''; |
|
603 | + $js = $this->get_js_header(); |
|
604 | + $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
605 | + // some javascript must be added for that kind of questions |
|
606 | + $html .= ''; |
|
607 | 607 | |
608 | - // Get the answers, make a list |
|
609 | - $nbrAnswers=$this->selectNbrAnswers(); |
|
608 | + // Get the answers, make a list |
|
609 | + $nbrAnswers=$this->selectNbrAnswers(); |
|
610 | 610 | |
611 | - $answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>'; |
|
612 | - for($answerId=1;$answerId <= $nbrAnswers;$answerId++) |
|
613 | - { |
|
614 | - $answer_list .= '<li>'.$this->selectAnswer($answerId).'</li>'; |
|
615 | - } |
|
616 | - $answer_list .= '</ol></div>'; |
|
611 | + $answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>'; |
|
612 | + for($answerId=1;$answerId <= $nbrAnswers;$answerId++) |
|
613 | + { |
|
614 | + $answer_list .= '<li>'.$this->selectAnswer($answerId).'</li>'; |
|
615 | + } |
|
616 | + $answer_list .= '</ol></div>'; |
|
617 | 617 | |
618 | - /* |
|
618 | + /* |
|
619 | 619 | if(!$onlyAnswers) |
620 | 620 | { |
621 | 621 | $s="<tr> |
@@ -633,11 +633,11 @@ discard block |
||
633 | 633 | } |
634 | 634 | */ |
635 | 635 | |
636 | - //$canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1'); |
|
637 | - $canClick = true; |
|
638 | - //$tes = isset($_GET['modifyAnswers']) ? '0' : '1'; |
|
639 | - //echo $tes; |
|
640 | - $relPath = api_get_path(REL_PATH); |
|
636 | + //$canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1'); |
|
637 | + $canClick = true; |
|
638 | + //$tes = isset($_GET['modifyAnswers']) ? '0' : '1'; |
|
639 | + //echo $tes; |
|
640 | + $relPath = api_get_path(REL_PATH); |
|
641 | 641 | $html .= <<<HTML |
642 | 642 | <tr> |
643 | 643 | <td> |
@@ -658,10 +658,10 @@ discard block |
||
658 | 658 | </td> |
659 | 659 | <tr> |
660 | 660 | HTML; |
661 | - $html .= '</table></td></tr>' . "\n"; |
|
661 | + $html .= '</table></td></tr>' . "\n"; |
|
662 | 662 | |
663 | - // currently the free answers cannot be displayed, so ignore the textarea |
|
664 | - $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
663 | + // currently the free answers cannot be displayed, so ignore the textarea |
|
664 | + $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
665 | 665 | return array($js,$html); |
666 | 666 | } |
667 | 667 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | // Access restriction |
26 | 26 | if (!api_is_allowed_to_edit()) { |
27 | - api_not_allowed(true); |
|
27 | + api_not_allowed(true); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | $tool_name = get_lang("SubscribeUserToCourse"); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $courseInfo = api_get_course_info(); |
35 | 35 | |
36 | 36 | if ($type == COURSEMANAGER) { |
37 | - $tool_name = get_lang("SubscribeUserToCourseAsTeacher"); |
|
37 | + $tool_name = get_lang("SubscribeUserToCourseAsTeacher"); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | //extra entries in breadcrumb |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | "url" => "subscribe_user.php?type=".$type.'&'.api_get_cidreq(), |
48 | 48 | "name" => $tool_name, |
49 | 49 | ); |
50 | - $tool_name = get_lang('SearchResults'); |
|
50 | + $tool_name = get_lang('SearchResults'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | $current_session_id = api_get_session_id(); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | ); |
77 | 77 | } |
78 | 78 | |
79 | - $user_id_temp = $_SESSION['session_user_id']; |
|
79 | + $user_id_temp = $_SESSION['session_user_id']; |
|
80 | 80 | |
81 | 81 | if (is_array($user_id_temp)) { |
82 | 82 | $counter = count($user_id_temp); |
@@ -169,16 +169,16 @@ discard block |
||
169 | 169 | |
170 | 170 | header('Location:'.api_get_path(WEB_CODE_PATH).'user/user.php?'.api_get_cidreq().'&type='.$type); |
171 | 171 | exit; |
172 | - break; |
|
173 | - } |
|
172 | + break; |
|
173 | + } |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | if (!empty($_SESSION['session_user_id'])) { |
177 | - unset($_SESSION['session_user_id']); |
|
177 | + unset($_SESSION['session_user_id']); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | if (!empty($_SESSION['session_user_name'])) { |
181 | - unset($_SESSION['session_user_name']); |
|
181 | + unset($_SESSION['session_user_name']); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | $is_western_name_order = api_is_western_name_order(); |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | |
187 | 187 | // Build table |
188 | 188 | $table = new SortableTable( |
189 | - 'subscribe_users', |
|
190 | - 'get_number_of_users', |
|
191 | - 'get_user_data', |
|
192 | - ($is_western_name_order xor $sort_by_first_name) ? 3 : 2 |
|
189 | + 'subscribe_users', |
|
190 | + 'get_number_of_users', |
|
191 | + 'get_user_data', |
|
192 | + ($is_western_name_order xor $sort_by_first_name) ? 3 : 2 |
|
193 | 193 | ); |
194 | 194 | $parameters['keyword'] = $keyword; |
195 | 195 | $parameters['type'] = $type; |
@@ -272,20 +272,20 @@ discard block |
||
272 | 272 | */ |
273 | 273 | function get_number_of_users() |
274 | 274 | { |
275 | - // Database table definition |
|
276 | - $user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
277 | - $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
278 | - $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
279 | - $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
275 | + // Database table definition |
|
276 | + $user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
277 | + $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
278 | + $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
279 | + $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
280 | 280 | |
281 | 281 | $courseCode = api_get_course_id(); |
282 | 282 | $sessionId = api_get_session_id(); |
283 | 283 | |
284 | - if (isset($_REQUEST['type']) && $_REQUEST['type']=='teacher') { |
|
284 | + if (isset($_REQUEST['type']) && $_REQUEST['type']=='teacher') { |
|
285 | 285 | |
286 | - if (api_get_session_id() != 0) { |
|
286 | + if (api_get_session_id() != 0) { |
|
287 | 287 | |
288 | - $sql = "SELECT COUNT(u.user_id) |
|
288 | + $sql = "SELECT COUNT(u.user_id) |
|
289 | 289 | FROM $user_table u |
290 | 290 | LEFT JOIN $tbl_session_rel_course_user cu |
291 | 291 | ON |
@@ -297,11 +297,11 @@ discard block |
||
297 | 297 | u.status = 1 AND |
298 | 298 | (u.official_code <> 'ADMIN' OR u.official_code IS NULL) "; |
299 | 299 | |
300 | - if (api_is_multiple_url_enabled()) { |
|
301 | - $url_access_id = api_get_current_access_url_id(); |
|
302 | - if ($url_access_id !=-1) { |
|
303 | - $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
304 | - $sql = "SELECT COUNT(u.user_id) |
|
300 | + if (api_is_multiple_url_enabled()) { |
|
301 | + $url_access_id = api_get_current_access_url_id(); |
|
302 | + if ($url_access_id !=-1) { |
|
303 | + $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
304 | + $sql = "SELECT COUNT(u.user_id) |
|
305 | 305 | FROM $user_table u |
306 | 306 | LEFT JOIN $tbl_session_rel_course_user cu |
307 | 307 | ON |
@@ -315,34 +315,34 @@ discard block |
||
315 | 315 | u.status = 1 AND |
316 | 316 | (u.official_code <> 'ADMIN' OR u.official_code IS NULL) |
317 | 317 | "; |
318 | - } |
|
319 | - } |
|
320 | - } else { |
|
321 | - $sql = "SELECT COUNT(u.user_id) |
|
318 | + } |
|
319 | + } |
|
320 | + } else { |
|
321 | + $sql = "SELECT COUNT(u.user_id) |
|
322 | 322 | FROM $user_table u |
323 | 323 | LEFT JOIN $course_user_table cu |
324 | 324 | ON u.user_id = cu.user_id and c_id='".api_get_course_int_id()."' |
325 | 325 | WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
326 | 326 | |
327 | - if (api_is_multiple_url_enabled()) { |
|
328 | - $url_access_id = api_get_current_access_url_id(); |
|
329 | - if ($url_access_id !=-1) { |
|
330 | - $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
327 | + if (api_is_multiple_url_enabled()) { |
|
328 | + $url_access_id = api_get_current_access_url_id(); |
|
329 | + if ($url_access_id !=-1) { |
|
330 | + $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
331 | 331 | |
332 | - $sql = "SELECT COUNT(u.user_id) |
|
332 | + $sql = "SELECT COUNT(u.user_id) |
|
333 | 333 | FROM $user_table u |
334 | 334 | LEFT JOIN $course_user_table cu |
335 | 335 | ON u.user_id = cu.user_id AND c_id='".api_get_course_int_id()."' |
336 | 336 | INNER JOIN $tbl_url_rel_user as url_rel_user |
337 | 337 | ON (url_rel_user.user_id = u.user_id) |
338 | 338 | WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
339 | - } |
|
340 | - } |
|
341 | - } |
|
342 | - } else { |
|
343 | - // students |
|
344 | - if (api_get_session_id() != 0) { |
|
345 | - $sql = "SELECT COUNT(u.user_id) |
|
339 | + } |
|
340 | + } |
|
341 | + } |
|
342 | + } else { |
|
343 | + // students |
|
344 | + if (api_get_session_id() != 0) { |
|
345 | + $sql = "SELECT COUNT(u.user_id) |
|
346 | 346 | FROM $user_table u |
347 | 347 | LEFT JOIN $tbl_session_rel_course_user cu |
348 | 348 | ON |
@@ -354,11 +354,11 @@ discard block |
||
354 | 354 | u.status<>".DRH." AND |
355 | 355 | (u.official_code <> 'ADMIN' OR u.official_code IS NULL) "; |
356 | 356 | |
357 | - if (api_is_multiple_url_enabled()) { |
|
358 | - $url_access_id = api_get_current_access_url_id(); |
|
359 | - if ($url_access_id !=-1) { |
|
360 | - $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
361 | - $sql = "SELECT COUNT(u.user_id) |
|
357 | + if (api_is_multiple_url_enabled()) { |
|
358 | + $url_access_id = api_get_current_access_url_id(); |
|
359 | + if ($url_access_id !=-1) { |
|
360 | + $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
361 | + $sql = "SELECT COUNT(u.user_id) |
|
362 | 362 | FROM $user_table u |
363 | 363 | LEFT JOIN $tbl_session_rel_course_user cu |
364 | 364 | ON |
@@ -372,21 +372,21 @@ discard block |
||
372 | 372 | u.status<>".DRH." AND |
373 | 373 | access_url_id= $url_access_id AND |
374 | 374 | (u.official_code <> 'ADMIN' OR u.official_code IS NULL) "; |
375 | - } |
|
376 | - } |
|
377 | - } else { |
|
378 | - $sql = "SELECT COUNT(u.user_id) |
|
375 | + } |
|
376 | + } |
|
377 | + } else { |
|
378 | + $sql = "SELECT COUNT(u.user_id) |
|
379 | 379 | FROM $user_table u |
380 | 380 | LEFT JOIN $course_user_table cu |
381 | 381 | ON u.user_id = cu.user_id AND c_id='".api_get_course_int_id()."'"; |
382 | 382 | |
383 | - // we change the SQL when we have a filter |
|
384 | - if (isset($_GET['subscribe_user_filter_value']) && |
|
383 | + // we change the SQL when we have a filter |
|
384 | + if (isset($_GET['subscribe_user_filter_value']) && |
|
385 | 385 | !empty($_GET['subscribe_user_filter_value']) && |
386 | 386 | api_get_setting('ProfilingFilterAddingUsers') == 'true' |
387 | 387 | ){ |
388 | - $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
389 | - $sql .= " |
|
388 | + $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
389 | + $sql .= " |
|
390 | 390 | LEFT JOIN $table_user_field_values field_values |
391 | 391 | ON field_values.item_id = u.user_id |
392 | 392 | WHERE |
@@ -395,32 +395,32 @@ discard block |
||
395 | 395 | field_values.field_id = '".intval($field_identification[0])."' AND |
396 | 396 | field_values.value = '".Database::escape_string($field_identification[1])."' |
397 | 397 | "; |
398 | - } else { |
|
399 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
400 | - } |
|
398 | + } else { |
|
399 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
400 | + } |
|
401 | 401 | |
402 | - if (api_is_multiple_url_enabled()) { |
|
403 | - $url_access_id = api_get_current_access_url_id(); |
|
402 | + if (api_is_multiple_url_enabled()) { |
|
403 | + $url_access_id = api_get_current_access_url_id(); |
|
404 | 404 | |
405 | - if ($url_access_id !=-1) { |
|
405 | + if ($url_access_id !=-1) { |
|
406 | 406 | |
407 | - $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
407 | + $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
408 | 408 | |
409 | - $sql = "SELECT COUNT(u.user_id) |
|
409 | + $sql = "SELECT COUNT(u.user_id) |
|
410 | 410 | FROM $user_table u |
411 | 411 | LEFT JOIN $course_user_table cu on u.user_id = cu.user_id and c_id='".api_get_course_int_id()."' |
412 | 412 | INNER JOIN $tbl_url_rel_user as url_rel_user |
413 | 413 | ON (url_rel_user.user_id = u.user_id) |
414 | 414 | WHERE cu.user_id IS NULL AND access_url_id= $url_access_id AND u.status<>".DRH." "; |
415 | - } |
|
416 | - } |
|
417 | - } |
|
418 | - } |
|
419 | - |
|
420 | - // when there is a keyword then we are searching and we have to change the SQL statement |
|
421 | - if (isset($_GET['keyword']) AND !empty($_GET['keyword'])) { |
|
422 | - $keyword = Database::escape_string(trim($_REQUEST['keyword'])); |
|
423 | - $sql .= " AND ( |
|
415 | + } |
|
416 | + } |
|
417 | + } |
|
418 | + } |
|
419 | + |
|
420 | + // when there is a keyword then we are searching and we have to change the SQL statement |
|
421 | + if (isset($_GET['keyword']) AND !empty($_GET['keyword'])) { |
|
422 | + $keyword = Database::escape_string(trim($_REQUEST['keyword'])); |
|
423 | + $sql .= " AND ( |
|
424 | 424 | firstname LIKE '%".$keyword."%' OR |
425 | 425 | lastname LIKE '%".$keyword."%' OR |
426 | 426 | email LIKE '%".$keyword."%' OR |
@@ -428,37 +428,37 @@ discard block |
||
428 | 428 | official_code LIKE '%".$keyword."%' |
429 | 429 | )"; |
430 | 430 | |
431 | - // we also want to search for users who have something in their profile fields that matches the keyword |
|
432 | - if (api_get_setting('ProfilingFilterAddingUsers') == 'true') { |
|
433 | - $additional_users = search_additional_profile_fields($keyword); |
|
434 | - } |
|
431 | + // we also want to search for users who have something in their profile fields that matches the keyword |
|
432 | + if (api_get_setting('ProfilingFilterAddingUsers') == 'true') { |
|
433 | + $additional_users = search_additional_profile_fields($keyword); |
|
434 | + } |
|
435 | 435 | |
436 | - // getting all the users of the course (to make sure that we do not display users that are already in the course) |
|
437 | - if (!empty($_SESSION["id_session"])) { |
|
436 | + // getting all the users of the course (to make sure that we do not display users that are already in the course) |
|
437 | + if (!empty($_SESSION["id_session"])) { |
|
438 | 438 | $a_course_users = CourseManager:: get_user_list_from_course_code( |
439 | 439 | $courseCode, |
440 | 440 | $sessionId |
441 | 441 | ); |
442 | - } else { |
|
442 | + } else { |
|
443 | 443 | $a_course_users = CourseManager:: get_user_list_from_course_code( |
444 | 444 | $courseCode, |
445 | 445 | 0 |
446 | 446 | ); |
447 | - } |
|
448 | - foreach ($a_course_users as $user_id=>$course_user) { |
|
449 | - $users_of_course[] = $course_user['user_id']; |
|
450 | - } |
|
451 | - } |
|
447 | + } |
|
448 | + foreach ($a_course_users as $user_id=>$course_user) { |
|
449 | + $users_of_course[] = $course_user['user_id']; |
|
450 | + } |
|
451 | + } |
|
452 | 452 | $sql .=" AND u.status <> ".ANONYMOUS." "; |
453 | - $res = Database::query($sql); |
|
453 | + $res = Database::query($sql); |
|
454 | 454 | $count_user = 0; |
455 | 455 | |
456 | 456 | if ($res) { |
457 | - $row = Database::fetch_row($res); |
|
458 | - $count_user = $row[0]; |
|
459 | - } |
|
457 | + $row = Database::fetch_row($res); |
|
458 | + $count_user = $row[0]; |
|
459 | + } |
|
460 | 460 | |
461 | - return $count_user; |
|
461 | + return $count_user; |
|
462 | 462 | } |
463 | 463 | /** |
464 | 464 | * Get the users to display on the current page. |
@@ -468,17 +468,17 @@ discard block |
||
468 | 468 | $url_access_id = api_get_current_access_url_id(); |
469 | 469 | $course_code = api_get_course_id(); |
470 | 470 | $session_id = api_get_session_id(); |
471 | - $courseId = api_get_course_int_id(); |
|
471 | + $courseId = api_get_course_int_id(); |
|
472 | 472 | |
473 | - // Database table definitions |
|
474 | - $user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
475 | - $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
476 | - $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
477 | - $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
473 | + // Database table definitions |
|
474 | + $user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
475 | + $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
476 | + $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
477 | + $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
478 | 478 | $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
479 | 479 | |
480 | 480 | // adding teachers |
481 | - $is_western_name_order = api_is_western_name_order(); |
|
481 | + $is_western_name_order = api_is_western_name_order(); |
|
482 | 482 | |
483 | 483 | if (api_get_setting('show_email_addresses') == 'true') { |
484 | 484 | |
@@ -503,10 +503,10 @@ discard block |
||
503 | 503 | u.active AS col4, |
504 | 504 | u.user_id AS col5"; |
505 | 505 | } |
506 | - if (isset($_REQUEST['type']) && $_REQUEST['type'] == COURSEMANAGER) { |
|
507 | - // adding a teacher through a session |
|
508 | - if (!empty($session_id)) { |
|
509 | - $sql = "SELECT $select_fields |
|
506 | + if (isset($_REQUEST['type']) && $_REQUEST['type'] == COURSEMANAGER) { |
|
507 | + // adding a teacher through a session |
|
508 | + if (!empty($session_id)) { |
|
509 | + $sql = "SELECT $select_fields |
|
510 | 510 | FROM $user_table u |
511 | 511 | LEFT JOIN $tbl_session_rel_course_user cu |
512 | 512 | ON |
@@ -516,13 +516,13 @@ discard block |
||
516 | 516 | INNER JOIN $tbl_url_rel_user as url_rel_user |
517 | 517 | ON (url_rel_user.user_id = u.user_id) "; |
518 | 518 | |
519 | - // applying the filter of the additional user profile fields |
|
520 | - if (isset($_GET['subscribe_user_filter_value']) && |
|
521 | - !empty($_GET['subscribe_user_filter_value']) && |
|
522 | - api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
523 | - ) { |
|
524 | - $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
525 | - $sql .= " |
|
519 | + // applying the filter of the additional user profile fields |
|
520 | + if (isset($_GET['subscribe_user_filter_value']) && |
|
521 | + !empty($_GET['subscribe_user_filter_value']) && |
|
522 | + api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
523 | + ) { |
|
524 | + $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
525 | + $sql .= " |
|
526 | 526 | LEFT JOIN $table_user_field_values field_values |
527 | 527 | ON field_values.item_id = u.user_id |
528 | 528 | WHERE |
@@ -531,53 +531,53 @@ discard block |
||
531 | 531 | (u.official_code <> 'ADMIN' OR u.official_code IS NULL) AND |
532 | 532 | field_values.field_id = '".intval($field_identification[0])."' AND |
533 | 533 | field_values.value = '".Database::escape_string($field_identification[1])."'"; |
534 | - } else { |
|
535 | - $sql .= "WHERE cu.user_id IS NULL AND u.status=1 AND (u.official_code <> 'ADMIN' OR u.official_code IS NULL) "; |
|
536 | - } |
|
534 | + } else { |
|
535 | + $sql .= "WHERE cu.user_id IS NULL AND u.status=1 AND (u.official_code <> 'ADMIN' OR u.official_code IS NULL) "; |
|
536 | + } |
|
537 | 537 | |
538 | 538 | $sql .= " AND access_url_id= $url_access_id"; |
539 | 539 | |
540 | - } else { |
|
541 | - // adding a teacher NOT through a session |
|
542 | - $sql = "SELECT $select_fields |
|
540 | + } else { |
|
541 | + // adding a teacher NOT through a session |
|
542 | + $sql = "SELECT $select_fields |
|
543 | 543 | FROM $user_table u |
544 | 544 | LEFT JOIN $course_user_table cu |
545 | 545 | ON u.user_id = cu.user_id AND c_id = '".$courseId."'"; |
546 | 546 | |
547 | - // applying the filter of the additional user profile fields |
|
548 | - if (isset($_GET['subscribe_user_filter_value']) && |
|
549 | - !empty($_GET['subscribe_user_filter_value']) && |
|
550 | - api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
551 | - ) { |
|
552 | - $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
553 | - $sql .= " |
|
547 | + // applying the filter of the additional user profile fields |
|
548 | + if (isset($_GET['subscribe_user_filter_value']) && |
|
549 | + !empty($_GET['subscribe_user_filter_value']) && |
|
550 | + api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
551 | + ) { |
|
552 | + $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
553 | + $sql .= " |
|
554 | 554 | LEFT JOIN $table_user_field_values field_values |
555 | 555 | ON field_values.item_id = u.user_id |
556 | 556 | WHERE |
557 | 557 | cu.user_id IS NULL AND u.status<>".DRH." AND |
558 | 558 | field_values.field_id = '".intval($field_identification[0])."' AND |
559 | 559 | field_values.value = '".Database::escape_string($field_identification[1])."'"; |
560 | - } else { |
|
561 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
562 | - } |
|
563 | - |
|
564 | - // adding a teacher NOT trough a session on a portal with multiple URLs |
|
565 | - if (api_is_multiple_url_enabled()) { |
|
566 | - if ($url_access_id !=-1) { |
|
567 | - $sql = "SELECT $select_fields |
|
560 | + } else { |
|
561 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
562 | + } |
|
563 | + |
|
564 | + // adding a teacher NOT trough a session on a portal with multiple URLs |
|
565 | + if (api_is_multiple_url_enabled()) { |
|
566 | + if ($url_access_id !=-1) { |
|
567 | + $sql = "SELECT $select_fields |
|
568 | 568 | FROM $user_table u |
569 | 569 | LEFT JOIN $course_user_table cu |
570 | 570 | ON u.user_id = cu.user_id and c_id='".$courseId."' |
571 | 571 | INNER JOIN $tbl_url_rel_user as url_rel_user |
572 | 572 | ON (url_rel_user.user_id = u.user_id) "; |
573 | 573 | |
574 | - // applying the filter of the additional user profile fields |
|
575 | - if (isset($_GET['subscribe_user_filter_value']) && |
|
576 | - !empty($_GET['subscribe_user_filter_value']) && |
|
577 | - api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
578 | - ){ |
|
579 | - $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
580 | - $sql .= " |
|
574 | + // applying the filter of the additional user profile fields |
|
575 | + if (isset($_GET['subscribe_user_filter_value']) && |
|
576 | + !empty($_GET['subscribe_user_filter_value']) && |
|
577 | + api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
578 | + ){ |
|
579 | + $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
580 | + $sql .= " |
|
581 | 581 | LEFT JOIN $table_user_field_values field_values |
582 | 582 | ON field_values.item_id = u.user_id |
583 | 583 | WHERE |
@@ -585,16 +585,16 @@ discard block |
||
585 | 585 | u.status<>".DRH." AND |
586 | 586 | field_values.field_id = '".intval($field_identification[0])."' AND |
587 | 587 | field_values.value = '".Database::escape_string($field_identification[1])."'"; |
588 | - } else { |
|
589 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
|
590 | - } |
|
591 | - } |
|
592 | - } |
|
593 | - } |
|
594 | - } else { |
|
595 | - // adding a student |
|
596 | - if (!empty($session_id)) { |
|
597 | - $sql = "SELECT $select_fields |
|
588 | + } else { |
|
589 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
|
590 | + } |
|
591 | + } |
|
592 | + } |
|
593 | + } |
|
594 | + } else { |
|
595 | + // adding a student |
|
596 | + if (!empty($session_id)) { |
|
597 | + $sql = "SELECT $select_fields |
|
598 | 598 | FROM $user_table u |
599 | 599 | LEFT JOIN $tbl_session_rel_course_user cu |
600 | 600 | ON |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | $sql .= "AND access_url_id = $url_access_id"; |
630 | 630 | } |
631 | 631 | |
632 | - } else { |
|
632 | + } else { |
|
633 | 633 | $sql = "SELECT $select_fields |
634 | 634 | FROM $user_table u |
635 | 635 | LEFT JOIN $course_user_table cu |
@@ -637,10 +637,10 @@ discard block |
||
637 | 637 | u.user_id = cu.user_id AND |
638 | 638 | c_id ='".$courseId."'"; |
639 | 639 | |
640 | - // applying the filter of the additional user profile fields |
|
641 | - if (isset($_GET['subscribe_user_filter_value']) && !empty($_GET['subscribe_user_filter_value'])){ |
|
642 | - $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
643 | - $sql .= " |
|
640 | + // applying the filter of the additional user profile fields |
|
641 | + if (isset($_GET['subscribe_user_filter_value']) && !empty($_GET['subscribe_user_filter_value'])){ |
|
642 | + $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
643 | + $sql .= " |
|
644 | 644 | LEFT JOIN $table_user_field_values field_values |
645 | 645 | ON field_values.item_id = u.user_id |
646 | 646 | WHERE |
@@ -648,28 +648,28 @@ discard block |
||
648 | 648 | u.status<>".DRH." AND |
649 | 649 | field_values.field_id = '".intval($field_identification[0])."' AND |
650 | 650 | field_values.value = '".Database::escape_string($field_identification[1])."'"; |
651 | - } else { |
|
652 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
653 | - } |
|
651 | + } else { |
|
652 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
653 | + } |
|
654 | 654 | |
655 | - //showing only the courses of the current Chamilo access_url_id |
|
655 | + //showing only the courses of the current Chamilo access_url_id |
|
656 | 656 | |
657 | - if (api_is_multiple_url_enabled()) { |
|
658 | - if ($url_access_id !=-1) { |
|
659 | - $sql = "SELECT $select_fields |
|
657 | + if (api_is_multiple_url_enabled()) { |
|
658 | + if ($url_access_id !=-1) { |
|
659 | + $sql = "SELECT $select_fields |
|
660 | 660 | FROM $user_table u |
661 | 661 | LEFT JOIN $course_user_table cu |
662 | 662 | ON u.user_id = cu.user_id AND c_id='".$courseId."' |
663 | 663 | INNER JOIN $tbl_url_rel_user as url_rel_user |
664 | 664 | ON (url_rel_user.user_id = u.user_id) "; |
665 | 665 | |
666 | - // applying the filter of the additional user profile fields |
|
667 | - if (isset($_GET['subscribe_user_filter_value']) && |
|
668 | - !empty($_GET['subscribe_user_filter_value']) && |
|
669 | - api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
670 | - ){ |
|
671 | - $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
672 | - $sql .= " |
|
666 | + // applying the filter of the additional user profile fields |
|
667 | + if (isset($_GET['subscribe_user_filter_value']) && |
|
668 | + !empty($_GET['subscribe_user_filter_value']) && |
|
669 | + api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
670 | + ){ |
|
671 | + $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
672 | + $sql .= " |
|
673 | 673 | LEFT JOIN $table_user_field_values field_values |
674 | 674 | ON field_values.item_id = u.user_id |
675 | 675 | WHERE |
@@ -679,19 +679,19 @@ discard block |
||
679 | 679 | field_values.value = '".Database::escape_string($field_identification[1])."' AND |
680 | 680 | access_url_id = $url_access_id |
681 | 681 | "; |
682 | - } else { |
|
683 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
|
684 | - } |
|
685 | - } |
|
686 | - } |
|
687 | - } |
|
688 | - } |
|
689 | - |
|
690 | - // adding additional WHERE statements to the SQL for the search functionality |
|
682 | + } else { |
|
683 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
|
684 | + } |
|
685 | + } |
|
686 | + } |
|
687 | + } |
|
688 | + } |
|
689 | + |
|
690 | + // adding additional WHERE statements to the SQL for the search functionality |
|
691 | 691 | $additional_users = null; |
692 | - if (isset($_REQUEST['keyword'])) { |
|
693 | - $keyword = Database::escape_string(trim($_REQUEST['keyword'])); |
|
694 | - $sql .= " AND ( |
|
692 | + if (isset($_REQUEST['keyword'])) { |
|
693 | + $keyword = Database::escape_string(trim($_REQUEST['keyword'])); |
|
694 | + $sql .= " AND ( |
|
695 | 695 | firstname LIKE '%".$keyword."%' OR |
696 | 696 | lastname LIKE '%".$keyword."%' OR |
697 | 697 | email LIKE '%".$keyword."%' OR |
@@ -700,46 +700,46 @@ discard block |
||
700 | 700 | ) |
701 | 701 | "; |
702 | 702 | |
703 | - if (api_get_setting('ProfilingFilterAddingUsers') == 'true') { |
|
704 | - // we also want to search for users who have something in |
|
705 | - // their profile fields that matches the keyword |
|
706 | - $additional_users = search_additional_profile_fields($keyword); |
|
707 | - } |
|
708 | - |
|
709 | - // getting all the users of the course (to make sure that we do not |
|
710 | - // display users that are already in the course) |
|
711 | - if (!empty($session_id)) { |
|
712 | - $a_course_users = CourseManager :: get_user_list_from_course_code($course_code, $session_id); |
|
713 | - } else { |
|
714 | - $a_course_users = CourseManager :: get_user_list_from_course_code($course_code, 0); |
|
715 | - } |
|
716 | - foreach ($a_course_users as $user_id=>$course_user) { |
|
717 | - $users_of_course[] = $course_user['user_id']; |
|
718 | - } |
|
719 | - } |
|
720 | - |
|
721 | - $sql .=" AND u.status != ".ANONYMOUS." "; |
|
722 | - |
|
723 | - // Sorting and pagination (used by the sortable table) |
|
724 | - $sql .= " ORDER BY col$column $direction "; |
|
725 | - $sql .= " LIMIT $from,$number_of_items"; |
|
726 | - |
|
727 | - $res = Database::query($sql); |
|
728 | - $users = array (); |
|
729 | - while ($user = Database::fetch_row($res)) { |
|
730 | - $users[] = $user; |
|
731 | - $_SESSION['session_user_id'][] = $user[0]; |
|
732 | - if ($is_western_name_order) { |
|
733 | - $_SESSION['session_user_name'][] = api_get_person_name($user[2], $user[3]); |
|
734 | - } else { |
|
735 | - $_SESSION['session_user_name'][] = api_get_person_name($user[3], $user[2]); |
|
736 | - } |
|
737 | - } |
|
738 | - // adding additional users based on the search on the additional profile fields |
|
739 | - if (isset($_REQUEST['keyword'])){ |
|
740 | - if (is_array($additional_users)) { |
|
741 | - foreach($additional_users as $additional_user_key=>$additional_user_value){ |
|
742 | - if (!in_array($additional_user_key, $_SESSION['session_user_id']) && |
|
703 | + if (api_get_setting('ProfilingFilterAddingUsers') == 'true') { |
|
704 | + // we also want to search for users who have something in |
|
705 | + // their profile fields that matches the keyword |
|
706 | + $additional_users = search_additional_profile_fields($keyword); |
|
707 | + } |
|
708 | + |
|
709 | + // getting all the users of the course (to make sure that we do not |
|
710 | + // display users that are already in the course) |
|
711 | + if (!empty($session_id)) { |
|
712 | + $a_course_users = CourseManager :: get_user_list_from_course_code($course_code, $session_id); |
|
713 | + } else { |
|
714 | + $a_course_users = CourseManager :: get_user_list_from_course_code($course_code, 0); |
|
715 | + } |
|
716 | + foreach ($a_course_users as $user_id=>$course_user) { |
|
717 | + $users_of_course[] = $course_user['user_id']; |
|
718 | + } |
|
719 | + } |
|
720 | + |
|
721 | + $sql .=" AND u.status != ".ANONYMOUS." "; |
|
722 | + |
|
723 | + // Sorting and pagination (used by the sortable table) |
|
724 | + $sql .= " ORDER BY col$column $direction "; |
|
725 | + $sql .= " LIMIT $from,$number_of_items"; |
|
726 | + |
|
727 | + $res = Database::query($sql); |
|
728 | + $users = array (); |
|
729 | + while ($user = Database::fetch_row($res)) { |
|
730 | + $users[] = $user; |
|
731 | + $_SESSION['session_user_id'][] = $user[0]; |
|
732 | + if ($is_western_name_order) { |
|
733 | + $_SESSION['session_user_name'][] = api_get_person_name($user[2], $user[3]); |
|
734 | + } else { |
|
735 | + $_SESSION['session_user_name'][] = api_get_person_name($user[3], $user[2]); |
|
736 | + } |
|
737 | + } |
|
738 | + // adding additional users based on the search on the additional profile fields |
|
739 | + if (isset($_REQUEST['keyword'])){ |
|
740 | + if (is_array($additional_users)) { |
|
741 | + foreach($additional_users as $additional_user_key=>$additional_user_value){ |
|
742 | + if (!in_array($additional_user_key, $_SESSION['session_user_id']) && |
|
743 | 743 | !in_array($additional_user_key,$users_of_course) |
744 | 744 | ){ |
745 | 745 | $users[] = array( |
@@ -751,11 +751,11 @@ discard block |
||
751 | 751 | $additional_user_value['col5'], |
752 | 752 | $additional_user_value['col6'], |
753 | 753 | ); |
754 | - } |
|
755 | - } |
|
756 | - } |
|
757 | - } |
|
758 | - return $users; |
|
754 | + } |
|
755 | + } |
|
756 | + } |
|
757 | + } |
|
758 | + return $users; |
|
759 | 759 | } |
760 | 760 | /** |
761 | 761 | * Returns a mailto-link |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | * @return string HTML-code with a mailto-link |
764 | 764 | */ |
765 | 765 | function email_filter($email) { |
766 | - return Display :: encrypted_mailto_link($email, $email); |
|
766 | + return Display :: encrypted_mailto_link($email, $email); |
|
767 | 767 | } |
768 | 768 | /** |
769 | 769 | * Build the reg-column of the table |
@@ -776,8 +776,8 @@ discard block |
||
776 | 776 | } else { |
777 | 777 | $type = STUDENT; |
778 | 778 | } |
779 | - $result = '<a class="btn btn-small btn-primary" href="'.api_get_self().'?register=yes&type='.$type.'&user_id='.$user_id.'">'.get_lang("reg").'</a>'; |
|
780 | - return $result; |
|
779 | + $result = '<a class="btn btn-small btn-primary" href="'.api_get_self().'?register=yes&type='.$type.'&user_id='.$user_id.'">'.get_lang("reg").'</a>'; |
|
780 | + return $result; |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | /** |
@@ -791,23 +791,23 @@ discard block |
||
791 | 791 | */ |
792 | 792 | |
793 | 793 | function active_filter($active, $url_params, $row) { |
794 | - $_user = api_get_user_info(); |
|
795 | - if ($active=='1') { |
|
796 | - $action='AccountActive'; |
|
797 | - $image='accept'; |
|
798 | - } |
|
799 | - |
|
800 | - if ($active=='0') { |
|
801 | - $action='AccountInactive'; |
|
802 | - $image='error'; |
|
803 | - } |
|
794 | + $_user = api_get_user_info(); |
|
795 | + if ($active=='1') { |
|
796 | + $action='AccountActive'; |
|
797 | + $image='accept'; |
|
798 | + } |
|
799 | + |
|
800 | + if ($active=='0') { |
|
801 | + $action='AccountInactive'; |
|
802 | + $image='error'; |
|
803 | + } |
|
804 | 804 | $result = null; |
805 | - if ($row['0']<>$_user['user_id']) { |
|
806 | - // you cannot lock yourself out otherwise you could disable all the accounts |
|
807 | - // including your own => everybody is locked out and nobody can change it anymore. |
|
808 | - $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array() , ICON_SIZE_TINY); |
|
809 | - } |
|
810 | - return $result; |
|
805 | + if ($row['0']<>$_user['user_id']) { |
|
806 | + // you cannot lock yourself out otherwise you could disable all the accounts |
|
807 | + // including your own => everybody is locked out and nobody can change it anymore. |
|
808 | + $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array() , ICON_SIZE_TINY); |
|
809 | + } |
|
810 | + return $result; |
|
811 | 811 | } |
812 | 812 | |
813 | 813 | /** |
@@ -825,29 +825,29 @@ discard block |
||
825 | 825 | */ |
826 | 826 | function search_additional_profile_fields($keyword) |
827 | 827 | { |
828 | - // database table definitions |
|
829 | - $table_user_field_options = Database :: get_main_table(TABLE_EXTRA_FIELD_OPTIONS); |
|
830 | - $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
828 | + // database table definitions |
|
829 | + $table_user_field_options = Database :: get_main_table(TABLE_EXTRA_FIELD_OPTIONS); |
|
830 | + $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
831 | 831 | $tableExtraField = Database::get_main_table(TABLE_EXTRA_FIELD); |
832 | - $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
832 | + $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
833 | 833 | |
834 | - // getting the field option text that match this keyword (for radio buttons and checkboxes) |
|
835 | - $sql = "SELECT * FROM $table_user_field_options |
|
834 | + // getting the field option text that match this keyword (for radio buttons and checkboxes) |
|
835 | + $sql = "SELECT * FROM $table_user_field_options |
|
836 | 836 | WHERE display_text LIKE '%".$keyword."%'"; |
837 | - $result_profiling = Database::query($sql); |
|
838 | - while ($profiling_field_options = Database::fetch_array($result_profiling)) { |
|
839 | - $profiling_field_options_exact_values[] = $profiling_field_options; |
|
840 | - } |
|
837 | + $result_profiling = Database::query($sql); |
|
838 | + while ($profiling_field_options = Database::fetch_array($result_profiling)) { |
|
839 | + $profiling_field_options_exact_values[] = $profiling_field_options; |
|
840 | + } |
|
841 | 841 | $profiling_field_options_exact_values_sql = ''; |
842 | - foreach ($profiling_field_options_exact_values as $profilingkey => $profilingvalue){ |
|
843 | - $profiling_field_options_exact_values_sql .= " OR (field_id = '".$profilingvalue['field_id']."' AND value='".$profilingvalue['option_value']."') "; |
|
844 | - } |
|
842 | + foreach ($profiling_field_options_exact_values as $profilingkey => $profilingvalue){ |
|
843 | + $profiling_field_options_exact_values_sql .= " OR (field_id = '".$profilingvalue['field_id']."' AND value='".$profilingvalue['option_value']."') "; |
|
844 | + } |
|
845 | 845 | |
846 | 846 | $extraFieldType = \Chamilo\CoreBundle\Entity\ExtraField::USER_FIELD_TYPE; |
847 | 847 | |
848 | - // getting all the user ids of the users who have chosen on of the predefined fields that contain the keyword |
|
849 | - // or all the users who have entered the keyword in a free-form field |
|
850 | - $sql = "SELECT |
|
848 | + // getting all the user ids of the users who have chosen on of the predefined fields that contain the keyword |
|
849 | + // or all the users who have entered the keyword in a free-form field |
|
850 | + $sql = "SELECT |
|
851 | 851 | user.user_id as col0, |
852 | 852 | user.official_code as col1, |
853 | 853 | user.lastname as col2, |
@@ -861,13 +861,13 @@ discard block |
||
861 | 861 | user_values.field_id = e.id AND |
862 | 862 | e.extra_field_type = $extraFieldType AND |
863 | 863 | (value LIKE '%".$keyword."%'".$profiling_field_options_exact_values_sql.")"; |
864 | - $result = Database::query($sql); |
|
864 | + $result = Database::query($sql); |
|
865 | 865 | $additional_users = array(); |
866 | - while ($profiled_users = Database::fetch_array($result)) { |
|
867 | - $additional_users[$profiled_users['col0']] = $profiled_users; |
|
868 | - } |
|
866 | + while ($profiled_users = Database::fetch_array($result)) { |
|
867 | + $additional_users[$profiled_users['col0']] = $profiled_users; |
|
868 | + } |
|
869 | 869 | |
870 | - return $additional_users; |
|
870 | + return $additional_users; |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | /** |
@@ -879,41 +879,41 @@ discard block |
||
879 | 879 | */ |
880 | 880 | function display_extra_profile_fields_filter() |
881 | 881 | { |
882 | - // getting all the additional user profile fields |
|
883 | - $extra = UserManager::get_extra_fields(0,50,5,'ASC'); |
|
884 | - |
|
885 | - $return='<option value="">'.get_lang('SelectFilter').'</option>'; |
|
886 | - |
|
887 | - // looping through the additional user profile fields |
|
888 | - foreach ($extra as $id => $field_details) { |
|
889 | - // $field_details[2] contains the type of the additional user profile field |
|
890 | - switch ($field_details[2]) { |
|
891 | - // text fields cannot be used as a filter |
|
892 | - case ExtraField::FIELD_TYPE_TEXT: |
|
893 | - break; |
|
894 | - // text area fields cannot be used as a filter |
|
895 | - case ExtraField::FIELD_TYPE_TEXTAREA: |
|
896 | - break; |
|
897 | - case ExtraField::FIELD_TYPE_RADIO: |
|
898 | - case ExtraField::FIELD_TYPE_SELECT: |
|
899 | - case ExtraField::FIELD_TYPE_SELECT_MULTIPLE: |
|
900 | - $return .= '<optgroup label="'.$field_details[3].'">'; |
|
901 | - foreach($field_details[9] as $option_id => $option_details) { |
|
902 | - if ($_GET['subscribe_user_filter_value'] == $field_details[0].'*'.$option_details[1]) { |
|
903 | - $selected = 'selected="selected"'; |
|
904 | - } else { |
|
905 | - $selected = false; |
|
906 | - } |
|
907 | - $return .= '<option value="'.$field_details[0].'*'.$option_details[1].'" '.$selected.'>'.$option_details[2].'</option>'; |
|
908 | - } |
|
909 | - $return .= '</optgroup>'; |
|
910 | - break; |
|
911 | - } |
|
912 | - } |
|
913 | - |
|
914 | - echo '<form id="subscribe_user_filter" name="subscribe_user_filter" method="get" action="'.api_get_self().'?api_get_cidreq" style="float:left;">'; |
|
915 | - echo ' <input type="hidden" name="type" id="type" value="'.Security::remove_XSS($_REQUEST['type']).'" />'; |
|
916 | - echo '<select name="subscribe_user_filter_value" id="subscribe_user_filter_value">'.$return.'</select>'; |
|
917 | - echo '<button type="submit" name="submit_filter" id="submit_filter" value="" class="search">'.get_lang('Filter').'</button>'; |
|
918 | - echo '</form>'; |
|
882 | + // getting all the additional user profile fields |
|
883 | + $extra = UserManager::get_extra_fields(0,50,5,'ASC'); |
|
884 | + |
|
885 | + $return='<option value="">'.get_lang('SelectFilter').'</option>'; |
|
886 | + |
|
887 | + // looping through the additional user profile fields |
|
888 | + foreach ($extra as $id => $field_details) { |
|
889 | + // $field_details[2] contains the type of the additional user profile field |
|
890 | + switch ($field_details[2]) { |
|
891 | + // text fields cannot be used as a filter |
|
892 | + case ExtraField::FIELD_TYPE_TEXT: |
|
893 | + break; |
|
894 | + // text area fields cannot be used as a filter |
|
895 | + case ExtraField::FIELD_TYPE_TEXTAREA: |
|
896 | + break; |
|
897 | + case ExtraField::FIELD_TYPE_RADIO: |
|
898 | + case ExtraField::FIELD_TYPE_SELECT: |
|
899 | + case ExtraField::FIELD_TYPE_SELECT_MULTIPLE: |
|
900 | + $return .= '<optgroup label="'.$field_details[3].'">'; |
|
901 | + foreach($field_details[9] as $option_id => $option_details) { |
|
902 | + if ($_GET['subscribe_user_filter_value'] == $field_details[0].'*'.$option_details[1]) { |
|
903 | + $selected = 'selected="selected"'; |
|
904 | + } else { |
|
905 | + $selected = false; |
|
906 | + } |
|
907 | + $return .= '<option value="'.$field_details[0].'*'.$option_details[1].'" '.$selected.'>'.$option_details[2].'</option>'; |
|
908 | + } |
|
909 | + $return .= '</optgroup>'; |
|
910 | + break; |
|
911 | + } |
|
912 | + } |
|
913 | + |
|
914 | + echo '<form id="subscribe_user_filter" name="subscribe_user_filter" method="get" action="'.api_get_self().'?api_get_cidreq" style="float:left;">'; |
|
915 | + echo ' <input type="hidden" name="type" id="type" value="'.Security::remove_XSS($_REQUEST['type']).'" />'; |
|
916 | + echo '<select name="subscribe_user_filter_value" id="subscribe_user_filter_value">'.$return.'</select>'; |
|
917 | + echo '<button type="submit" name="submit_filter" id="submit_filter" value="" class="search">'.get_lang('Filter').'</button>'; |
|
918 | + echo '</form>'; |
|
919 | 919 | } |
@@ -28,15 +28,15 @@ |
||
28 | 28 | switch ($_GET["cmd"]) { |
29 | 29 | case "clear_stapi": |
30 | 30 | echo "Are you sure you are willing to erease all storage api data (no backup)? <a href='cli.php?cmd=clear_stapi_confirm' >Yes</a>"; |
31 | - break; |
|
31 | + break; |
|
32 | 32 | case "clear_stapi_confirm": |
33 | 33 | Database::query("delete from ".Database::get_main_table(TABLE_TRACK_STORED_VALUES)); |
34 | - Database::query("delete from ".Database::get_main_table(TABLE_TRACK_STORED_VALUES_STACK)); |
|
35 | - echo "Done"; |
|
36 | - break; |
|
34 | + Database::query("delete from ".Database::get_main_table(TABLE_TRACK_STORED_VALUES_STACK)); |
|
35 | + echo "Done"; |
|
36 | + break; |
|
37 | 37 | default: |
38 | 38 | echo "UNKNOWN COMMAND"; |
39 | - break; |
|
39 | + break; |
|
40 | 40 | } |
41 | 41 | /** |
42 | 42 | * Footer |