@@ -35,120 +35,120 @@ discard block |
||
35 | 35 | class AccessToken |
36 | 36 | { |
37 | 37 | |
38 | - /** |
|
39 | - * The access token. |
|
40 | - * |
|
41 | - * @var string |
|
42 | - */ |
|
43 | - protected $accessToken; |
|
44 | - |
|
45 | - /** |
|
46 | - * A unique ID to identify a client. |
|
47 | - * |
|
48 | - * @var string |
|
49 | - */ |
|
50 | - protected $machineId; |
|
51 | - |
|
52 | - /** |
|
53 | - * Date when token expires. |
|
54 | - * |
|
55 | - * @var \DateTime|null |
|
56 | - */ |
|
57 | - protected $expiresAt; |
|
58 | - |
|
59 | - /** |
|
60 | - * Create a new access token entity. |
|
61 | - * |
|
62 | - * @param string $accessToken |
|
63 | - * @param int $expiresAt |
|
64 | - * @param string|null machineId |
|
65 | - * @param string $machineId |
|
66 | - */ |
|
67 | - public function __construct($accessToken, $expiresAt = 0, $machineId = null) |
|
68 | - { |
|
38 | + /** |
|
39 | + * The access token. |
|
40 | + * |
|
41 | + * @var string |
|
42 | + */ |
|
43 | + protected $accessToken; |
|
44 | + |
|
45 | + /** |
|
46 | + * A unique ID to identify a client. |
|
47 | + * |
|
48 | + * @var string |
|
49 | + */ |
|
50 | + protected $machineId; |
|
51 | + |
|
52 | + /** |
|
53 | + * Date when token expires. |
|
54 | + * |
|
55 | + * @var \DateTime|null |
|
56 | + */ |
|
57 | + protected $expiresAt; |
|
58 | + |
|
59 | + /** |
|
60 | + * Create a new access token entity. |
|
61 | + * |
|
62 | + * @param string $accessToken |
|
63 | + * @param int $expiresAt |
|
64 | + * @param string|null machineId |
|
65 | + * @param string $machineId |
|
66 | + */ |
|
67 | + public function __construct($accessToken, $expiresAt = 0, $machineId = null) |
|
68 | + { |
|
69 | 69 | $this->accessToken = $accessToken; |
70 | 70 | if ($expiresAt) { |
71 | - $this->setExpiresAtFromTimeStamp($expiresAt); |
|
71 | + $this->setExpiresAtFromTimeStamp($expiresAt); |
|
72 | 72 | } |
73 | 73 | $this->machineId = $machineId; |
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Setter for expires_at. |
|
78 | - * |
|
79 | - * @param int $timeStamp |
|
80 | - */ |
|
81 | - protected function setExpiresAtFromTimeStamp($timeStamp) |
|
82 | - { |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Setter for expires_at. |
|
78 | + * |
|
79 | + * @param int $timeStamp |
|
80 | + */ |
|
81 | + protected function setExpiresAtFromTimeStamp($timeStamp) |
|
82 | + { |
|
83 | 83 | $dt = new \DateTime(); |
84 | 84 | $dt->setTimestamp($timeStamp); |
85 | 85 | $this->expiresAt = $dt; |
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Getter for expiresAt. |
|
90 | - * |
|
91 | - * @return \DateTime|null |
|
92 | - */ |
|
93 | - public function getExpiresAt() |
|
94 | - { |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Getter for expiresAt. |
|
90 | + * |
|
91 | + * @return \DateTime|null |
|
92 | + */ |
|
93 | + public function getExpiresAt() |
|
94 | + { |
|
95 | 95 | return $this->expiresAt; |
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * Getter for machineId. |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - public function getMachineId() |
|
104 | - { |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * Getter for machineId. |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + public function getMachineId() |
|
104 | + { |
|
105 | 105 | return $this->machineId; |
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Determines whether or not this is a long-lived token. |
|
110 | - * |
|
111 | - * @return bool |
|
112 | - */ |
|
113 | - public function isLongLived() |
|
114 | - { |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Determines whether or not this is a long-lived token. |
|
110 | + * |
|
111 | + * @return bool |
|
112 | + */ |
|
113 | + public function isLongLived() |
|
114 | + { |
|
115 | 115 | if ($this->expiresAt) { |
116 | - return $this->expiresAt->getTimestamp() > time() + (60 * 60 * 2); |
|
116 | + return $this->expiresAt->getTimestamp() > time() + (60 * 60 * 2); |
|
117 | 117 | } |
118 | 118 | return false; |
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * Checks the validity of the access token. |
|
123 | - * |
|
124 | - * @param string|null $appId Application ID to use |
|
125 | - * @param string|null $appSecret App secret value to use |
|
126 | - * @param string|null $machineId |
|
127 | - * |
|
128 | - * @return boolean |
|
129 | - */ |
|
130 | - public function isValid($appId = null, $appSecret = null, $machineId = null) |
|
131 | - { |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * Checks the validity of the access token. |
|
123 | + * |
|
124 | + * @param string|null $appId Application ID to use |
|
125 | + * @param string|null $appSecret App secret value to use |
|
126 | + * @param string|null $machineId |
|
127 | + * |
|
128 | + * @return boolean |
|
129 | + */ |
|
130 | + public function isValid($appId = null, $appSecret = null, $machineId = null) |
|
131 | + { |
|
132 | 132 | $accessTokenInfo = $this->getInfo($appId, $appSecret); |
133 | 133 | $machineId = $machineId ?: $this->machineId; |
134 | 134 | return static::validateAccessToken($accessTokenInfo, $appId, $machineId); |
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * Ensures the provided GraphSessionInfo object is valid, |
|
139 | - * throwing an exception if not. Ensures the appId matches, |
|
140 | - * that the machineId matches if it's being used, |
|
141 | - * that the token is valid and has not expired. |
|
142 | - * |
|
143 | - * @param GraphSessionInfo $tokenInfo |
|
144 | - * @param string|null $appId Application ID to use |
|
145 | - * @param string|null $machineId |
|
146 | - * |
|
147 | - * @return boolean |
|
148 | - */ |
|
149 | - public static function validateAccessToken(GraphSessionInfo $tokenInfo, |
|
150 | - $appId = null, $machineId = null) |
|
151 | - { |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * Ensures the provided GraphSessionInfo object is valid, |
|
139 | + * throwing an exception if not. Ensures the appId matches, |
|
140 | + * that the machineId matches if it's being used, |
|
141 | + * that the token is valid and has not expired. |
|
142 | + * |
|
143 | + * @param GraphSessionInfo $tokenInfo |
|
144 | + * @param string|null $appId Application ID to use |
|
145 | + * @param string|null $machineId |
|
146 | + * |
|
147 | + * @return boolean |
|
148 | + */ |
|
149 | + public static function validateAccessToken(GraphSessionInfo $tokenInfo, |
|
150 | + $appId = null, $machineId = null) |
|
151 | + { |
|
152 | 152 | $targetAppId = FacebookSession::_getTargetAppId($appId); |
153 | 153 | |
154 | 154 | $appIdIsValid = $tokenInfo->getAppId() == $targetAppId; |
@@ -157,90 +157,90 @@ discard block |
||
157 | 157 | |
158 | 158 | // Not all access tokens return an expiration. E.g. an app access token. |
159 | 159 | if ($tokenInfo->getExpiresAt() instanceof \DateTime) { |
160 | - $accessTokenIsStillAlive = $tokenInfo->getExpiresAt()->getTimestamp() >= time(); |
|
160 | + $accessTokenIsStillAlive = $tokenInfo->getExpiresAt()->getTimestamp() >= time(); |
|
161 | 161 | } else { |
162 | - $accessTokenIsStillAlive = true; |
|
162 | + $accessTokenIsStillAlive = true; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | return $appIdIsValid && $machineIdIsValid && $accessTokenIsValid && $accessTokenIsStillAlive; |
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * Get a valid access token from a code. |
|
170 | - * |
|
171 | - * @param string $code |
|
172 | - * @param string|null $appId |
|
173 | - * @param string|null $appSecret |
|
174 | - * @param string|null $machineId |
|
175 | - * |
|
176 | - * @return AccessToken |
|
177 | - */ |
|
178 | - public static function getAccessTokenFromCode($code, $appId = null, $appSecret = null, $machineId = null) |
|
179 | - { |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * Get a valid access token from a code. |
|
170 | + * |
|
171 | + * @param string $code |
|
172 | + * @param string|null $appId |
|
173 | + * @param string|null $appSecret |
|
174 | + * @param string|null $machineId |
|
175 | + * |
|
176 | + * @return AccessToken |
|
177 | + */ |
|
178 | + public static function getAccessTokenFromCode($code, $appId = null, $appSecret = null, $machineId = null) |
|
179 | + { |
|
180 | 180 | $params = array( |
181 | - 'code' => $code, |
|
182 | - 'redirect_uri' => '', |
|
181 | + 'code' => $code, |
|
182 | + 'redirect_uri' => '', |
|
183 | 183 | ); |
184 | 184 | |
185 | 185 | if ($machineId) { |
186 | - $params['machine_id'] = $machineId; |
|
186 | + $params['machine_id'] = $machineId; |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | return static::requestAccessToken($params, $appId, $appSecret); |
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * Get a valid code from an access token. |
|
194 | - * |
|
195 | - * @param AccessToken $accessToken |
|
196 | - * @param string|null $appId |
|
197 | - * @param string|null $appSecret |
|
198 | - * |
|
199 | - * @return string |
|
200 | - */ |
|
201 | - public static function getCodeFromAccessToken($accessToken, $appId = null, $appSecret = null) |
|
202 | - { |
|
190 | + } |
|
191 | + |
|
192 | + /** |
|
193 | + * Get a valid code from an access token. |
|
194 | + * |
|
195 | + * @param AccessToken $accessToken |
|
196 | + * @param string|null $appId |
|
197 | + * @param string|null $appSecret |
|
198 | + * |
|
199 | + * @return string |
|
200 | + */ |
|
201 | + public static function getCodeFromAccessToken($accessToken, $appId = null, $appSecret = null) |
|
202 | + { |
|
203 | 203 | $accessToken = (string) $accessToken; |
204 | 204 | |
205 | 205 | $params = array( |
206 | - 'access_token' => $accessToken, |
|
207 | - 'redirect_uri' => '', |
|
206 | + 'access_token' => $accessToken, |
|
207 | + 'redirect_uri' => '', |
|
208 | 208 | ); |
209 | 209 | |
210 | 210 | return static::requestCode($params, $appId, $appSecret); |
211 | - } |
|
212 | - |
|
213 | - /** |
|
214 | - * Exchanges a short lived access token with a long lived access token. |
|
215 | - * |
|
216 | - * @param string|null $appId |
|
217 | - * @param string|null $appSecret |
|
218 | - * |
|
219 | - * @return AccessToken |
|
220 | - */ |
|
221 | - public function extend($appId = null, $appSecret = null) |
|
222 | - { |
|
211 | + } |
|
212 | + |
|
213 | + /** |
|
214 | + * Exchanges a short lived access token with a long lived access token. |
|
215 | + * |
|
216 | + * @param string|null $appId |
|
217 | + * @param string|null $appSecret |
|
218 | + * |
|
219 | + * @return AccessToken |
|
220 | + */ |
|
221 | + public function extend($appId = null, $appSecret = null) |
|
222 | + { |
|
223 | 223 | $params = array( |
224 | - 'grant_type' => 'fb_exchange_token', |
|
225 | - 'fb_exchange_token' => $this->accessToken, |
|
224 | + 'grant_type' => 'fb_exchange_token', |
|
225 | + 'fb_exchange_token' => $this->accessToken, |
|
226 | 226 | ); |
227 | 227 | |
228 | 228 | return static::requestAccessToken($params, $appId, $appSecret); |
229 | - } |
|
230 | - |
|
231 | - /** |
|
232 | - * Request an access token based on a set of params. |
|
233 | - * |
|
234 | - * @param array $params |
|
235 | - * @param string|null $appId |
|
236 | - * @param string|null $appSecret |
|
237 | - * |
|
238 | - * @return AccessToken |
|
239 | - * |
|
240 | - * @throws FacebookRequestException |
|
241 | - */ |
|
242 | - public static function requestAccessToken(array $params, $appId = null, $appSecret = null) |
|
243 | - { |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * Request an access token based on a set of params. |
|
233 | + * |
|
234 | + * @param array $params |
|
235 | + * @param string|null $appId |
|
236 | + * @param string|null $appSecret |
|
237 | + * |
|
238 | + * @return AccessToken |
|
239 | + * |
|
240 | + * @throws FacebookRequestException |
|
241 | + */ |
|
242 | + public static function requestAccessToken(array $params, $appId = null, $appSecret = null) |
|
243 | + { |
|
244 | 244 | $response = static::request('/oauth/access_token', $params, $appId, $appSecret); |
245 | 245 | $data = $response->getResponse(); |
246 | 246 | |
@@ -249,133 +249,133 @@ discard block |
||
249 | 249 | * @see https://github.com/facebook/facebook-php-sdk-v4/issues/36 |
250 | 250 | */ |
251 | 251 | if (is_array($data)) { |
252 | - if (isset($data['access_token'])) { |
|
252 | + if (isset($data['access_token'])) { |
|
253 | 253 | $expiresAt = isset($data['expires']) ? time() + $data['expires'] : 0; |
254 | 254 | return new static($data['access_token'], $expiresAt); |
255 | - } |
|
255 | + } |
|
256 | 256 | } elseif($data instanceof \stdClass) { |
257 | - if (isset($data->access_token)) { |
|
257 | + if (isset($data->access_token)) { |
|
258 | 258 | $expiresAt = isset($data->expires_in) ? time() + $data->expires_in : 0; |
259 | 259 | $machineId = isset($data->machine_id) ? (string) $data->machine_id : null; |
260 | 260 | return new static((string) $data->access_token, $expiresAt, $machineId); |
261 | - } |
|
261 | + } |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | throw FacebookRequestException::create( |
265 | - $response->getRawResponse(), |
|
266 | - $data, |
|
267 | - 401 |
|
265 | + $response->getRawResponse(), |
|
266 | + $data, |
|
267 | + 401 |
|
268 | 268 | ); |
269 | - } |
|
270 | - |
|
271 | - /** |
|
272 | - * Request a code from a long lived access token. |
|
273 | - * |
|
274 | - * @param array $params |
|
275 | - * @param string|null $appId |
|
276 | - * @param string|null $appSecret |
|
277 | - * |
|
278 | - * @return string |
|
279 | - * |
|
280 | - * @throws FacebookRequestException |
|
281 | - */ |
|
282 | - public static function requestCode(array $params, $appId = null, $appSecret = null) |
|
283 | - { |
|
269 | + } |
|
270 | + |
|
271 | + /** |
|
272 | + * Request a code from a long lived access token. |
|
273 | + * |
|
274 | + * @param array $params |
|
275 | + * @param string|null $appId |
|
276 | + * @param string|null $appSecret |
|
277 | + * |
|
278 | + * @return string |
|
279 | + * |
|
280 | + * @throws FacebookRequestException |
|
281 | + */ |
|
282 | + public static function requestCode(array $params, $appId = null, $appSecret = null) |
|
283 | + { |
|
284 | 284 | $response = static::request('/oauth/client_code', $params, $appId, $appSecret); |
285 | 285 | $data = $response->getResponse(); |
286 | 286 | |
287 | 287 | if (isset($data->code)) { |
288 | - return (string) $data->code; |
|
288 | + return (string) $data->code; |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | throw FacebookRequestException::create( |
292 | - $response->getRawResponse(), |
|
293 | - $data, |
|
294 | - 401 |
|
292 | + $response->getRawResponse(), |
|
293 | + $data, |
|
294 | + 401 |
|
295 | 295 | ); |
296 | - } |
|
297 | - |
|
298 | - /** |
|
299 | - * Send a request to Graph with an app access token. |
|
300 | - * |
|
301 | - * @param string $endpoint |
|
302 | - * @param array $params |
|
303 | - * @param string|null $appId |
|
304 | - * @param string|null $appSecret |
|
305 | - * |
|
306 | - * @return \Facebook\FacebookResponse |
|
307 | - * |
|
308 | - * @throws FacebookRequestException |
|
309 | - */ |
|
310 | - protected static function request($endpoint, array $params, $appId = null, $appSecret = null) |
|
311 | - { |
|
296 | + } |
|
297 | + |
|
298 | + /** |
|
299 | + * Send a request to Graph with an app access token. |
|
300 | + * |
|
301 | + * @param string $endpoint |
|
302 | + * @param array $params |
|
303 | + * @param string|null $appId |
|
304 | + * @param string|null $appSecret |
|
305 | + * |
|
306 | + * @return \Facebook\FacebookResponse |
|
307 | + * |
|
308 | + * @throws FacebookRequestException |
|
309 | + */ |
|
310 | + protected static function request($endpoint, array $params, $appId = null, $appSecret = null) |
|
311 | + { |
|
312 | 312 | $targetAppId = FacebookSession::_getTargetAppId($appId); |
313 | 313 | $targetAppSecret = FacebookSession::_getTargetAppSecret($appSecret); |
314 | 314 | |
315 | 315 | if (!isset($params['client_id'])) { |
316 | - $params['client_id'] = $targetAppId; |
|
316 | + $params['client_id'] = $targetAppId; |
|
317 | 317 | } |
318 | 318 | if (!isset($params['client_secret'])) { |
319 | - $params['client_secret'] = $targetAppSecret; |
|
319 | + $params['client_secret'] = $targetAppSecret; |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | // The response for this endpoint is not JSON, so it must be handled |
323 | 323 | // differently, not as a GraphObject. |
324 | 324 | $request = new FacebookRequest( |
325 | - FacebookSession::newAppSession($targetAppId, $targetAppSecret), |
|
326 | - 'GET', |
|
327 | - $endpoint, |
|
328 | - $params |
|
325 | + FacebookSession::newAppSession($targetAppId, $targetAppSecret), |
|
326 | + 'GET', |
|
327 | + $endpoint, |
|
328 | + $params |
|
329 | 329 | ); |
330 | 330 | return $request->execute(); |
331 | - } |
|
332 | - |
|
333 | - /** |
|
334 | - * Get more info about an access token. |
|
335 | - * |
|
336 | - * @param string|null $appId |
|
337 | - * @param string|null $appSecret |
|
338 | - * |
|
339 | - * @return GraphSessionInfo |
|
340 | - */ |
|
341 | - public function getInfo($appId = null, $appSecret = null) |
|
342 | - { |
|
331 | + } |
|
332 | + |
|
333 | + /** |
|
334 | + * Get more info about an access token. |
|
335 | + * |
|
336 | + * @param string|null $appId |
|
337 | + * @param string|null $appSecret |
|
338 | + * |
|
339 | + * @return GraphSessionInfo |
|
340 | + */ |
|
341 | + public function getInfo($appId = null, $appSecret = null) |
|
342 | + { |
|
343 | 343 | $params = array('input_token' => $this->accessToken); |
344 | 344 | |
345 | 345 | $request = new FacebookRequest( |
346 | - FacebookSession::newAppSession($appId, $appSecret), |
|
347 | - 'GET', |
|
348 | - '/debug_token', |
|
349 | - $params |
|
346 | + FacebookSession::newAppSession($appId, $appSecret), |
|
347 | + 'GET', |
|
348 | + '/debug_token', |
|
349 | + $params |
|
350 | 350 | ); |
351 | 351 | $response = $request->execute()->getGraphObject(GraphSessionInfo::className()); |
352 | 352 | |
353 | 353 | // Update the data on this token |
354 | 354 | if ($response->getExpiresAt()) { |
355 | - $this->expiresAt = $response->getExpiresAt(); |
|
355 | + $this->expiresAt = $response->getExpiresAt(); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | return $response; |
359 | - } |
|
360 | - |
|
361 | - /** |
|
362 | - * Returns the access token as a string. |
|
363 | - * |
|
364 | - * @return string |
|
365 | - */ |
|
366 | - public function __toString() |
|
367 | - { |
|
359 | + } |
|
360 | + |
|
361 | + /** |
|
362 | + * Returns the access token as a string. |
|
363 | + * |
|
364 | + * @return string |
|
365 | + */ |
|
366 | + public function __toString() |
|
367 | + { |
|
368 | 368 | return $this->accessToken; |
369 | - } |
|
370 | - |
|
371 | - /** |
|
372 | - * Returns true if the access token is an app session token. |
|
373 | - * |
|
374 | - * @return bool |
|
375 | - */ |
|
376 | - public function isAppSession() |
|
377 | - { |
|
369 | + } |
|
370 | + |
|
371 | + /** |
|
372 | + * Returns true if the access token is an app session token. |
|
373 | + * |
|
374 | + * @return bool |
|
375 | + */ |
|
376 | + public function isAppSession() |
|
377 | + { |
|
378 | 378 | return strpos($this->accessToken, "|") !== false; |
379 | - } |
|
379 | + } |
|
380 | 380 | |
381 | 381 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $locked = api_resource_is_locked_by_gradebook($exercise_id, LINK_EXERCISE); |
93 | 93 | |
94 | 94 | if (empty($objExercise)) { |
95 | - $objExercise = new Exercise(); |
|
95 | + $objExercise = new Exercise(); |
|
96 | 96 | $objExercise->read($exercise_id); |
97 | 97 | } |
98 | 98 | $feedback_type = $objExercise->feedback_type; |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | //Only users can see their own results |
101 | 101 | if (!$is_allowedToEdit) { |
102 | 102 | if ($student_id != $current_user_id) { |
103 | - api_not_allowed(true); |
|
103 | + api_not_allowed(true); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | 107 | if (isset($_SESSION['gradebook'])) { |
108 | - $gradebook= Security::remove_XSS($_SESSION['gradebook']); |
|
108 | + $gradebook= Security::remove_XSS($_SESSION['gradebook']); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | if (!empty($gradebook) && $gradebook=='view') { |
112 | - $interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'],'name' => get_lang('ToolGradebook')); |
|
112 | + $interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'],'name' => get_lang('ToolGradebook')); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | $fromlink = ''; |
@@ -124,14 +124,14 @@ discard block |
||
124 | 124 | $htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/js/hotspot.js"></script>'; |
125 | 125 | |
126 | 126 | if ($origin != 'learnpath') { |
127 | - Display::display_header(''); |
|
127 | + Display::display_header(''); |
|
128 | 128 | } else { |
129 | 129 | $htmlHeadXtra[] = " |
130 | 130 | <style> |
131 | 131 | body { background: none;} |
132 | 132 | </style> |
133 | 133 | "; |
134 | - Display::display_reduced_header(); |
|
134 | + Display::display_reduced_header(); |
|
135 | 135 | } |
136 | 136 | ?> |
137 | 137 | <script> |
@@ -232,12 +232,12 @@ discard block |
||
232 | 232 | } |
233 | 233 | } |
234 | 234 | } else { |
235 | - Display::display_warning_message(get_lang('CantViewResults')); |
|
236 | - $show_results = false; |
|
235 | + Display::display_warning_message(get_lang('CantViewResults')); |
|
236 | + $show_results = false; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | if ($origin == 'learnpath' && !isset($_GET['fb_type']) ) { |
240 | - $show_results = false; |
|
240 | + $show_results = false; |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoices) { |
@@ -285,13 +285,13 @@ discard block |
||
285 | 285 | $exerciseResult = array(); |
286 | 286 | |
287 | 287 | while ($row = Database::fetch_array($result)) { |
288 | - $question_list_from_database[] = $row['question_id']; |
|
289 | - $exerciseResult[$row['question_id']] = $row['answer']; |
|
288 | + $question_list_from_database[] = $row['question_id']; |
|
289 | + $exerciseResult[$row['question_id']] = $row['answer']; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | //Fixing #2073 Fixing order of questions |
293 | 293 | if (!empty($track_exercise_info['data_tracking'])) { |
294 | - $temp_question_list = explode(',', $track_exercise_info['data_tracking']); |
|
294 | + $temp_question_list = explode(',', $track_exercise_info['data_tracking']); |
|
295 | 295 | |
296 | 296 | // Getting question list from data_tracking |
297 | 297 | if (!empty($temp_question_list)) { |
@@ -330,21 +330,21 @@ discard block |
||
330 | 330 | |
331 | 331 | foreach ($questionList as $questionId) { |
332 | 332 | |
333 | - $choice = $exerciseResult[$questionId]; |
|
334 | - // destruction of the Question object |
|
335 | - unset($objQuestionTmp); |
|
333 | + $choice = $exerciseResult[$questionId]; |
|
334 | + // destruction of the Question object |
|
335 | + unset($objQuestionTmp); |
|
336 | 336 | |
337 | 337 | // creates a temporary Question object |
338 | 338 | $objQuestionTmp = Question::read($questionId); |
339 | 339 | $questionWeighting = $objQuestionTmp->selectWeighting(); |
340 | 340 | $answerType = $objQuestionTmp->selectType(); |
341 | 341 | |
342 | - // Start buffer |
|
342 | + // Start buffer |
|
343 | 343 | ob_start(); |
344 | 344 | |
345 | 345 | // Use switch |
346 | 346 | |
347 | - if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) { |
|
347 | + if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) { |
|
348 | 348 | $question_result = $objExercise->manage_answer( |
349 | 349 | $id, |
350 | 350 | $questionId, |
@@ -490,12 +490,12 @@ discard block |
||
490 | 490 | ); |
491 | 491 | $questionScore = $question_result['score']; |
492 | 492 | $totalScore += $question_result['score']; |
493 | - } elseif ($answerType == HOT_SPOT) { |
|
494 | - if ($show_results || $showTotalScoreAndUserChoices) { |
|
495 | - echo '<table width="500" border="0"><tr> |
|
493 | + } elseif ($answerType == HOT_SPOT) { |
|
494 | + if ($show_results || $showTotalScoreAndUserChoices) { |
|
495 | + echo '<table width="500" border="0"><tr> |
|
496 | 496 | <td valign="top" align="center" style="padding-left:0px;" > |
497 | 497 | <table border="1" bordercolor="#A4A4A4" style="border-collapse: collapse;" width="552">'; |
498 | - } |
|
498 | + } |
|
499 | 499 | $question_result = $objExercise->manage_answer( |
500 | 500 | $id, |
501 | 501 | $questionId, |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | <br> |
537 | 537 | "; |
538 | 538 | } |
539 | - } else if($answerType == HOT_SPOT_DELINEATION) { |
|
539 | + } else if($answerType == HOT_SPOT_DELINEATION) { |
|
540 | 540 | |
541 | 541 | $question_result = $objExercise->manage_answer( |
542 | 542 | $id, |
@@ -693,15 +693,15 @@ discard block |
||
693 | 693 | </table> |
694 | 694 | "; |
695 | 695 | } |
696 | - } |
|
696 | + } |
|
697 | 697 | |
698 | - if ($show_results) { |
|
699 | - if ($answerType != HOT_SPOT) { |
|
700 | - echo '</table>'; |
|
701 | - } |
|
702 | - } |
|
698 | + if ($show_results) { |
|
699 | + if ($answerType != HOT_SPOT) { |
|
700 | + echo '</table>'; |
|
701 | + } |
|
702 | + } |
|
703 | 703 | |
704 | - $comnt = null; |
|
704 | + $comnt = null; |
|
705 | 705 | |
706 | 706 | if ($show_results) { |
707 | 707 | if ( |
@@ -718,18 +718,18 @@ discard block |
||
718 | 718 | |
719 | 719 | $marksname = ''; |
720 | 720 | |
721 | - if ($isFeedbackAllowed) { |
|
722 | - $name = "fckdiv".$questionId; |
|
723 | - $marksname = "marksName".$questionId; |
|
724 | - if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { |
|
725 | - $url_name = get_lang('EditCommentsAndMarks'); |
|
726 | - } else { |
|
727 | - if ($action=='edit') { |
|
728 | - $url_name = get_lang('EditIndividualComment'); |
|
729 | - } else { |
|
730 | - $url_name = get_lang('AddComments'); |
|
731 | - } |
|
732 | - } |
|
721 | + if ($isFeedbackAllowed) { |
|
722 | + $name = "fckdiv".$questionId; |
|
723 | + $marksname = "marksName".$questionId; |
|
724 | + if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { |
|
725 | + $url_name = get_lang('EditCommentsAndMarks'); |
|
726 | + } else { |
|
727 | + if ($action=='edit') { |
|
728 | + $url_name = get_lang('EditIndividualComment'); |
|
729 | + } else { |
|
730 | + $url_name = get_lang('AddComments'); |
|
731 | + } |
|
732 | + } |
|
733 | 733 | echo '<br />'; |
734 | 734 | echo Display::url( |
735 | 735 | $url_name, |
@@ -738,26 +738,26 @@ discard block |
||
738 | 738 | 'class' => 'btn btn-default', |
739 | 739 | 'onclick' => "showfck('".$name."', '".$marksname."');") |
740 | 740 | ); |
741 | - echo '<br />'; |
|
741 | + echo '<br />'; |
|
742 | 742 | |
743 | 743 | echo '<div id="feedback_'.$name.'" style="width:100%">'; |
744 | - $comnt = trim(Event::get_comments($id, $questionId)); |
|
745 | - if (empty($comnt)) { |
|
746 | - echo '<br />'; |
|
747 | - } else { |
|
748 | - echo '<div id="question_feedback">'.$comnt.'</div>'; |
|
749 | - } |
|
750 | - echo '</div>'; |
|
744 | + $comnt = trim(Event::get_comments($id, $questionId)); |
|
745 | + if (empty($comnt)) { |
|
746 | + echo '<br />'; |
|
747 | + } else { |
|
748 | + echo '<div id="question_feedback">'.$comnt.'</div>'; |
|
749 | + } |
|
750 | + echo '</div>'; |
|
751 | 751 | |
752 | 752 | echo '<div id="'.$name.'" style="display:none">'; |
753 | - $arrid[] = $questionId; |
|
754 | - $feedback_form = new FormValidator('frmcomments'.$questionId,'post',''); |
|
755 | - $feedback_form->addElement('html','<br>'); |
|
756 | - $renderer =& $feedback_form->defaultRenderer(); |
|
757 | - $renderer->setFormTemplate('<form{attributes}><div align="left">{content}</div></form>'); |
|
758 | - $renderer->setCustomElementTemplate('<div align="left">{element}</div>'); |
|
759 | - $comnt = Event::get_comments($id, $questionId); |
|
760 | - $default = array('comments_'.$questionId => $comnt); |
|
753 | + $arrid[] = $questionId; |
|
754 | + $feedback_form = new FormValidator('frmcomments'.$questionId,'post',''); |
|
755 | + $feedback_form->addElement('html','<br>'); |
|
756 | + $renderer =& $feedback_form->defaultRenderer(); |
|
757 | + $renderer->setFormTemplate('<form{attributes}><div align="left">{content}</div></form>'); |
|
758 | + $renderer->setCustomElementTemplate('<div align="left">{element}</div>'); |
|
759 | + $comnt = Event::get_comments($id, $questionId); |
|
760 | + $default = array('comments_'.$questionId => $comnt); |
|
761 | 761 | |
762 | 762 | if ($useAdvancedEditor) { |
763 | 763 | $feedback_form->addElement( |
@@ -774,52 +774,52 @@ discard block |
||
774 | 774 | } else { |
775 | 775 | $feedback_form->addElement('textarea', 'comments_' . $questionId); |
776 | 776 | } |
777 | - $feedback_form->addElement('html','<br>'); |
|
778 | - $feedback_form->setDefaults($default); |
|
779 | - $feedback_form->display(); |
|
780 | - echo '</div>'; |
|
781 | - |
|
782 | - } else { |
|
783 | - $comnt = Event::get_comments($id, $questionId); |
|
784 | - echo '<br />'; |
|
785 | - if (!empty($comnt)) { |
|
786 | - echo '<b>'.get_lang('Feedback').'</b>'; |
|
787 | - echo '<div id="question_feedback">'.$comnt.'</div>'; |
|
788 | - } |
|
789 | - } |
|
790 | - |
|
791 | - if ($is_allowedToEdit && $isFeedbackAllowed) { |
|
792 | - if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { |
|
793 | - $marksname = "marksName".$questionId; |
|
777 | + $feedback_form->addElement('html','<br>'); |
|
778 | + $feedback_form->setDefaults($default); |
|
779 | + $feedback_form->display(); |
|
780 | + echo '</div>'; |
|
781 | + |
|
782 | + } else { |
|
783 | + $comnt = Event::get_comments($id, $questionId); |
|
784 | + echo '<br />'; |
|
785 | + if (!empty($comnt)) { |
|
786 | + echo '<b>'.get_lang('Feedback').'</b>'; |
|
787 | + echo '<div id="question_feedback">'.$comnt.'</div>'; |
|
788 | + } |
|
789 | + } |
|
790 | + |
|
791 | + if ($is_allowedToEdit && $isFeedbackAllowed) { |
|
792 | + if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { |
|
793 | + $marksname = "marksName".$questionId; |
|
794 | 794 | echo '<div id="'.$marksname.'" style="display:none">'; |
795 | 795 | echo '<form name="marksform_'.$questionId.'" method="post" action="">'; |
796 | - $arrmarks[] = $questionId; |
|
797 | - echo get_lang("AssignMarks"); |
|
798 | - echo " <select name='marks' id='marks'>"; |
|
799 | - for ($i=0;$i<=$questionWeighting;$i++) { |
|
800 | - echo '<option '.(($i==$questionScore)?"selected='selected'":'').'>'.$i.'</option>'; |
|
801 | - } |
|
802 | - echo '</select>'; |
|
803 | - echo '</form><br /></div>'; |
|
804 | - |
|
805 | - if ($questionScore == -1 ) { |
|
806 | - $questionScore = 0; |
|
807 | - echo Display::return_message(get_lang('notCorrectedYet')); |
|
808 | - } |
|
809 | - } else { |
|
810 | - $arrmarks[] = $questionId; |
|
811 | - echo '<div id="'.$marksname.'" style="display:none"><form name="marksform_'.$questionId.'" method="post" action=""> |
|
796 | + $arrmarks[] = $questionId; |
|
797 | + echo get_lang("AssignMarks"); |
|
798 | + echo " <select name='marks' id='marks'>"; |
|
799 | + for ($i=0;$i<=$questionWeighting;$i++) { |
|
800 | + echo '<option '.(($i==$questionScore)?"selected='selected'":'').'>'.$i.'</option>'; |
|
801 | + } |
|
802 | + echo '</select>'; |
|
803 | + echo '</form><br /></div>'; |
|
804 | + |
|
805 | + if ($questionScore == -1 ) { |
|
806 | + $questionScore = 0; |
|
807 | + echo Display::return_message(get_lang('notCorrectedYet')); |
|
808 | + } |
|
809 | + } else { |
|
810 | + $arrmarks[] = $questionId; |
|
811 | + echo '<div id="'.$marksname.'" style="display:none"><form name="marksform_'.$questionId.'" method="post" action=""> |
|
812 | 812 | <select name="marks" id="marks" style="display:none;"><option>'.$questionScore.'</option></select></form><br/ ></div>'; |
813 | - } |
|
814 | - } else { |
|
815 | - if ($questionScore == -1) { |
|
816 | - $questionScore = 0; |
|
817 | - } |
|
818 | - } |
|
819 | - } |
|
813 | + } |
|
814 | + } else { |
|
815 | + if ($questionScore == -1) { |
|
816 | + $questionScore = 0; |
|
817 | + } |
|
818 | + } |
|
819 | + } |
|
820 | 820 | |
821 | 821 | $my_total_score = $questionScore; |
822 | - $my_total_weight = $questionWeighting; |
|
822 | + $my_total_weight = $questionWeighting; |
|
823 | 823 | $totalWeighting += $questionWeighting; |
824 | 824 | $category_was_added_for_this_test = false; |
825 | 825 | |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | |
866 | 866 | $score = array(); |
867 | 867 | if ($show_results) { |
868 | - $score['result'] = get_lang('Score')." : ".ExerciseLib::show_score($my_total_score, $my_total_weight, false, false); |
|
868 | + $score['result'] = get_lang('Score')." : ".ExerciseLib::show_score($my_total_score, $my_total_weight, false, false); |
|
869 | 869 | $score['pass'] = $my_total_score >= $my_total_weight ? true : false; |
870 | 870 | $score['type'] = $answerType; |
871 | 871 | $score['score'] = $my_total_score; |
@@ -873,16 +873,16 @@ discard block |
||
873 | 873 | $score['comments'] = isset($comnt) ? $comnt : null; |
874 | 874 | } |
875 | 875 | |
876 | - unset($objAnswerTmp); |
|
877 | - $i++; |
|
876 | + unset($objAnswerTmp); |
|
877 | + $i++; |
|
878 | 878 | |
879 | 879 | $contents = ob_get_clean(); |
880 | 880 | $question_content = '<div class="question_row">'; |
881 | - if ($show_results) { |
|
881 | + if ($show_results) { |
|
882 | 882 | // Shows question title an description |
883 | - $question_content .= $objQuestionTmp->return_header(null, $counter, $score); |
|
884 | - } |
|
885 | - $counter++; |
|
883 | + $question_content .= $objQuestionTmp->return_header(null, $counter, $score); |
|
884 | + } |
|
885 | + $counter++; |
|
886 | 886 | $question_content .= $contents; |
887 | 887 | $question_content .= '</div>'; |
888 | 888 | $exercise_content .= $question_content; |
@@ -892,12 +892,12 @@ discard block |
||
892 | 892 | |
893 | 893 | //Total score |
894 | 894 | if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) { |
895 | - if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoices) { |
|
895 | + if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoices) { |
|
896 | 896 | $total_score_text .= '<div class="question_row">'; |
897 | 897 | $my_total_score_temp = $totalScore; |
898 | - if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) { |
|
899 | - $my_total_score_temp = 0; |
|
900 | - } |
|
898 | + if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) { |
|
899 | + $my_total_score_temp = 0; |
|
900 | + } |
|
901 | 901 | $total_score_text .= ExerciseLib::get_question_ribbon( |
902 | 902 | $objExercise, |
903 | 903 | $my_total_score_temp, |
@@ -905,7 +905,7 @@ discard block |
||
905 | 905 | true |
906 | 906 | ); |
907 | 907 | $total_score_text .= '</div>'; |
908 | - } |
|
908 | + } |
|
909 | 909 | } |
910 | 910 | |
911 | 911 | if (!empty($category_list) && ($show_results || $show_only_total_score || $showTotalScoreAndUserChoices)) { |
@@ -929,26 +929,26 @@ discard block |
||
929 | 929 | } |
930 | 930 | |
931 | 931 | if ($isFeedbackAllowed) { |
932 | - if (in_array($origin, array('tracking_course','user_course','correct_exercise_in_lp'))) { |
|
933 | - echo '<form name="myform" id="myform" action="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'&filter=2&comments=update&exeid='.$id.'&origin='.$origin.'&details=true&course='.Security::remove_XSS($_GET['cidReq']).$fromlink.'" method="post">'; |
|
934 | - echo '<input type = "hidden" name="lp_item_id" value="'.$learnpath_id.'">'; |
|
935 | - echo '<input type = "hidden" name="lp_item_view_id" value="'.$lp_item_view_id.'">'; |
|
936 | - echo '<input type = "hidden" name="student_id" value="'.$student_id.'">'; |
|
937 | - echo '<input type = "hidden" name="total_score" value="'.$totalScore.'"> '; |
|
938 | - echo '<input type = "hidden" name="my_exe_exo_id" value="'.$exercise_id.'"> '; |
|
939 | - } else { |
|
940 | - echo ' <form name="myform" id="myform" action="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'&filter=1&comments=update&exeid='.$id.'" method="post">'; |
|
941 | - } |
|
942 | - if ($origin !='learnpath' && $origin!='student_progress') { |
|
932 | + if (in_array($origin, array('tracking_course','user_course','correct_exercise_in_lp'))) { |
|
933 | + echo '<form name="myform" id="myform" action="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'&filter=2&comments=update&exeid='.$id.'&origin='.$origin.'&details=true&course='.Security::remove_XSS($_GET['cidReq']).$fromlink.'" method="post">'; |
|
934 | + echo '<input type = "hidden" name="lp_item_id" value="'.$learnpath_id.'">'; |
|
935 | + echo '<input type = "hidden" name="lp_item_view_id" value="'.$lp_item_view_id.'">'; |
|
936 | + echo '<input type = "hidden" name="student_id" value="'.$student_id.'">'; |
|
937 | + echo '<input type = "hidden" name="total_score" value="'.$totalScore.'"> '; |
|
938 | + echo '<input type = "hidden" name="my_exe_exo_id" value="'.$exercise_id.'"> '; |
|
939 | + } else { |
|
940 | + echo ' <form name="myform" id="myform" action="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'&filter=1&comments=update&exeid='.$id.'" method="post">'; |
|
941 | + } |
|
942 | + if ($origin !='learnpath' && $origin!='student_progress') { |
|
943 | 943 | echo '<label><input type= "checkbox" name="send_notification"> '.get_lang('SendEmail').'</label>'; |
944 | - ?> |
|
944 | + ?> |
|
945 | 945 | <br /> |
946 | 946 | <button type="submit" class="btn btn-primary" value="<?php echo get_lang('Ok'); ?>" onclick="getFCK('<?php echo $strids; ?>','<?php echo $marksid; ?>');"> |
947 | 947 | <?php echo get_lang('CorrectTest'); ?> |
948 | 948 | </button> |
949 | 949 | </form> |
950 | 950 | <?php |
951 | - } |
|
951 | + } |
|
952 | 952 | } |
953 | 953 | |
954 | 954 | //Came from lpstats in a lp |
@@ -965,21 +965,21 @@ discard block |
||
965 | 965 | } |
966 | 966 | |
967 | 967 | if ($origin != 'learnpath') { |
968 | - //we are not in learnpath tool |
|
969 | - Display::display_footer(); |
|
968 | + //we are not in learnpath tool |
|
969 | + Display::display_footer(); |
|
970 | 970 | } else { |
971 | - if (!isset($_GET['fb_type'])) { |
|
972 | - $lp_mode = $_SESSION['lp_mode']; |
|
973 | - $url = '../newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$feedback_type; |
|
974 | - $href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" '; |
|
975 | - echo '<script type="text/javascript">'.$href.'</script>'; |
|
976 | - // Record the results in the learning path, using the SCORM interface (API) |
|
977 | - echo "<script>window.parent.API.void_save_asset('$totalScore', '$totalWeighting', 0, 'completed'); </script>"; |
|
978 | - echo '</body></html>'; |
|
979 | - } else { |
|
980 | - Display::display_normal_message(get_lang('ExerciseFinished').' '.get_lang('ToContinueUseMenu')); |
|
971 | + if (!isset($_GET['fb_type'])) { |
|
972 | + $lp_mode = $_SESSION['lp_mode']; |
|
973 | + $url = '../newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$feedback_type; |
|
974 | + $href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" '; |
|
975 | + echo '<script type="text/javascript">'.$href.'</script>'; |
|
976 | + // Record the results in the learning path, using the SCORM interface (API) |
|
977 | + echo "<script>window.parent.API.void_save_asset('$totalScore', '$totalWeighting', 0, 'completed'); </script>"; |
|
978 | + echo '</body></html>'; |
|
979 | + } else { |
|
980 | + Display::display_normal_message(get_lang('ExerciseFinished').' '.get_lang('ToContinueUseMenu')); |
|
981 | 981 | echo '<br />'; |
982 | - } |
|
982 | + } |
|
983 | 983 | } |
984 | 984 | |
985 | 985 | // Destroying the session |
@@ -17,25 +17,25 @@ discard block |
||
17 | 17 | */ |
18 | 18 | class ExerciseShowFunctions |
19 | 19 | { |
20 | - /** |
|
21 | - * Shows the answer to a fill-in-the-blanks question, as HTML |
|
20 | + /** |
|
21 | + * Shows the answer to a fill-in-the-blanks question, as HTML |
|
22 | 22 | * @param int $feedbackType |
23 | - * @param string $answer |
|
24 | - * @param int $id Exercise ID |
|
25 | - * @param int $questionId Question ID |
|
23 | + * @param string $answer |
|
24 | + * @param int $id Exercise ID |
|
25 | + * @param int $questionId Question ID |
|
26 | 26 | * @param int $resultsDisabled |
27 | 27 | * @param string $originalStudentAnswer |
28 | - * |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public static function display_fill_in_blanks_answer( |
|
32 | - $feedbackType, |
|
33 | - $answer, |
|
34 | - $id, |
|
35 | - $questionId, |
|
36 | - $resultsDisabled, |
|
37 | - $originalStudentAnswer = '', |
|
38 | - $showTotalScoreAndUserChoices |
|
28 | + * |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public static function display_fill_in_blanks_answer( |
|
32 | + $feedbackType, |
|
33 | + $answer, |
|
34 | + $id, |
|
35 | + $questionId, |
|
36 | + $resultsDisabled, |
|
37 | + $originalStudentAnswer = '', |
|
38 | + $showTotalScoreAndUserChoices |
|
39 | 39 | ) { |
40 | 40 | $answerHTML = FillBlanks::getHtmlDisplayForAnswer($answer, $resultsDisabled, $showTotalScoreAndUserChoices); |
41 | 41 | if (strpos($originalStudentAnswer, 'font color') !== false) { |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | </tr> |
65 | 65 | <?php |
66 | 66 | } |
67 | - } |
|
67 | + } |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * Shows the answer to a calculated question, as HTML |
@@ -105,20 +105,20 @@ discard block |
||
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
108 | - /** |
|
109 | - * Shows the answer to a free-answer question, as HTML |
|
110 | - * @param string Answer text |
|
111 | - * @param int Exercise ID |
|
112 | - * @param int Question ID |
|
113 | - * @return void |
|
114 | - */ |
|
115 | - public static function display_free_answer( |
|
116 | - $feedback_type, |
|
117 | - $answer, |
|
118 | - $exe_id, |
|
119 | - $questionId, |
|
120 | - $questionScore = null, |
|
121 | - $results_disabled = 0 |
|
108 | + /** |
|
109 | + * Shows the answer to a free-answer question, as HTML |
|
110 | + * @param string Answer text |
|
111 | + * @param int Exercise ID |
|
112 | + * @param int Question ID |
|
113 | + * @return void |
|
114 | + */ |
|
115 | + public static function display_free_answer( |
|
116 | + $feedback_type, |
|
117 | + $answer, |
|
118 | + $exe_id, |
|
119 | + $questionId, |
|
120 | + $questionScore = null, |
|
121 | + $results_disabled = 0 |
|
122 | 122 | ) { |
123 | 123 | $comments = Event::get_comments($exe_id, $questionId); |
124 | 124 | |
@@ -136,21 +136,21 @@ discard block |
||
136 | 136 | echo '</tr>'; |
137 | 137 | } |
138 | 138 | } |
139 | - } |
|
139 | + } |
|
140 | 140 | |
141 | 141 | /** |
142 | - * @param $feedback_type |
|
143 | - * @param $answer |
|
144 | - * @param $id |
|
145 | - * @param $questionId |
|
146 | - * @param null $nano |
|
147 | - * @param int $results_disabled |
|
142 | + * @param $feedback_type |
|
143 | + * @param $answer |
|
144 | + * @param $id |
|
145 | + * @param $questionId |
|
146 | + * @param null $nano |
|
147 | + * @param int $results_disabled |
|
148 | 148 | */ |
149 | - public static function display_oral_expression_answer( |
|
150 | - $feedback_type, |
|
151 | - $answer, |
|
152 | - $id, |
|
153 | - $questionId, |
|
149 | + public static function display_oral_expression_answer( |
|
150 | + $feedback_type, |
|
151 | + $answer, |
|
152 | + $id, |
|
153 | + $questionId, |
|
154 | 154 | $nano = null, |
155 | 155 | $results_disabled = 0 |
156 | 156 | ) { |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
189 | - /** |
|
190 | - * Displays the answer to a hotspot question |
|
189 | + /** |
|
190 | + * Displays the answer to a hotspot question |
|
191 | 191 | * @param int $feedback_type |
192 | 192 | * @param int $answerId |
193 | 193 | * @param string $answer |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @param int $resultsDisabled |
197 | 197 | * @param int $orderColor |
198 | 198 | */ |
199 | - public static function display_hotspot_answer( |
|
199 | + public static function display_hotspot_answer( |
|
200 | 200 | $feedback_type, |
201 | 201 | $answerId, |
202 | 202 | $answer, |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | - $hotspot_colors = array( |
|
222 | + $hotspot_colors = array( |
|
223 | 223 | "", // $i starts from 1 on next loop (ugly fix) |
224 | 224 | "#4271B5", |
225 | 225 | "#FE8E16", |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | "#F7BDE2" |
237 | 237 | ); |
238 | 238 | |
239 | - ?> |
|
239 | + ?> |
|
240 | 240 | <table class="data_table"> |
241 | 241 | <tr> |
242 | 242 | <td class="text-center" width="5%"> |
@@ -248,10 +248,10 @@ discard block |
||
248 | 248 | <td class="text-left" width="10%"> |
249 | 249 | <?php |
250 | 250 | if (!$hide_expected_answer) { |
251 | - $my_choice = $studentChoice ? get_lang('Correct') : get_lang('Fault'); |
|
252 | - echo $my_choice; |
|
251 | + $my_choice = $studentChoice ? get_lang('Correct') : get_lang('Fault'); |
|
252 | + echo $my_choice; |
|
253 | 253 | } |
254 | - ?> |
|
254 | + ?> |
|
255 | 255 | </td> |
256 | 256 | <?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?> |
257 | 257 | <td class="text-left" width="60%"> |
@@ -259,29 +259,29 @@ discard block |
||
259 | 259 | if ($studentChoice) { |
260 | 260 | echo '<span style="font-weight: bold; color: #008000;">'.nl2br($answerComment).'</span>'; |
261 | 261 | } |
262 | - ?> |
|
262 | + ?> |
|
263 | 263 | </td> |
264 | 264 | <?php } else { ?> |
265 | 265 | <td class="text-left" width="60%"> </td> |
266 | 266 | <?php } ?> |
267 | 267 | </tr> |
268 | 268 | <?php |
269 | - } |
|
270 | - |
|
271 | - /** |
|
272 | - * Display the answers to a multiple choice question |
|
273 | - * @param int $feedback_type Feedback type |
|
274 | - * @param integer Answer type |
|
275 | - * @param integer Student choice |
|
276 | - * @param string Textual answer |
|
277 | - * @param string Comment on answer |
|
278 | - * @param string Correct answer comment |
|
279 | - * @param integer Exercise ID |
|
280 | - * @param integer Question ID |
|
281 | - * @param boolean Whether to show the answer comment or not |
|
282 | - * @return void |
|
283 | - */ |
|
284 | - public static function display_unique_or_multiple_answer( |
|
269 | + } |
|
270 | + |
|
271 | + /** |
|
272 | + * Display the answers to a multiple choice question |
|
273 | + * @param int $feedback_type Feedback type |
|
274 | + * @param integer Answer type |
|
275 | + * @param integer Student choice |
|
276 | + * @param string Textual answer |
|
277 | + * @param string Comment on answer |
|
278 | + * @param string Correct answer comment |
|
279 | + * @param integer Exercise ID |
|
280 | + * @param integer Question ID |
|
281 | + * @param boolean Whether to show the answer comment or not |
|
282 | + * @return void |
|
283 | + */ |
|
284 | + public static function display_unique_or_multiple_answer( |
|
285 | 285 | $feedback_type, |
286 | 286 | $answerType, |
287 | 287 | $studentChoice, |
@@ -309,14 +309,14 @@ discard block |
||
309 | 309 | } |
310 | 310 | |
311 | 311 | $icon = in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION)) ? 'radio':'checkbox'; |
312 | - $icon .= $studentChoice?'_on':'_off'; |
|
313 | - $icon .= '.gif'; |
|
312 | + $icon .= $studentChoice?'_on':'_off'; |
|
313 | + $icon .= '.gif'; |
|
314 | 314 | |
315 | - $iconAnswer = in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION)) ? 'radio':'checkbox'; |
|
316 | - $iconAnswer .= $answerCorrect ? '_on' : '_off'; |
|
317 | - $iconAnswer .= '.gif'; |
|
315 | + $iconAnswer = in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION)) ? 'radio':'checkbox'; |
|
316 | + $iconAnswer .= $answerCorrect ? '_on' : '_off'; |
|
317 | + $iconAnswer .= '.gif'; |
|
318 | 318 | |
319 | - ?> |
|
319 | + ?> |
|
320 | 320 | <tr> |
321 | 321 | <td width="5%"> |
322 | 322 | <?php echo Display::return_icon($icon); ?> |
@@ -330,39 +330,39 @@ discard block |
||
330 | 330 | </td> |
331 | 331 | <td width="40%"> |
332 | 332 | <?php |
333 | - echo $answer; |
|
334 | - ?> |
|
333 | + echo $answer; |
|
334 | + ?> |
|
335 | 335 | </td> |
336 | 336 | |
337 | 337 | <?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?> |
338 | 338 | <td width="20%"> |
339 | 339 | <?php |
340 | 340 | if ($studentChoice) { |
341 | - if ($answerCorrect) { |
|
341 | + if ($answerCorrect) { |
|
342 | 342 | $color = 'green'; |
343 | - //echo '<span style="font-weight: bold; color: #008000;">'.nl2br($answerComment).'</span>'; |
|
344 | - } else { |
|
343 | + //echo '<span style="font-weight: bold; color: #008000;">'.nl2br($answerComment).'</span>'; |
|
344 | + } else { |
|
345 | 345 | $color = 'black'; |
346 | 346 | //echo '<span style="font-weight: bold; color: #FF0000;">'.nl2br($answerComment).'</span>'; |
347 | - } |
|
348 | - if ($hide_expected_answer) { |
|
349 | - $color = ''; |
|
350 | - } |
|
347 | + } |
|
348 | + if ($hide_expected_answer) { |
|
349 | + $color = ''; |
|
350 | + } |
|
351 | 351 | echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>'; |
352 | - } |
|
353 | - ?> |
|
352 | + } |
|
353 | + ?> |
|
354 | 354 | </td> |
355 | 355 | <?php |
356 | - if ($ans==1) { |
|
357 | - $comm = Event::get_comments($id,$questionId); |
|
358 | - } |
|
359 | - ?> |
|
356 | + if ($ans==1) { |
|
357 | + $comm = Event::get_comments($id,$questionId); |
|
358 | + } |
|
359 | + ?> |
|
360 | 360 | <?php } else { ?> |
361 | 361 | <td> </td> |
362 | 362 | <?php } ?> |
363 | 363 | </tr> |
364 | 364 | <?php |
365 | - } |
|
365 | + } |
|
366 | 366 | |
367 | 367 | /** |
368 | 368 | * Display the answers to a multiple choice question |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | if (isset($new_options[$studentChoice])) { |
416 | 416 | echo get_lang($new_options[$studentChoice]['name']); |
417 | 417 | } else { |
418 | - echo '-'; |
|
418 | + echo '-'; |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | ?> |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | <td width="5%"> |
424 | 424 | <?php |
425 | 425 | |
426 | - // Expected choice |
|
426 | + // Expected choice |
|
427 | 427 | if (!$hide_expected_answer) { |
428 | 428 | if (isset($new_options[$answerCorrect])) { |
429 | 429 | echo get_lang($new_options[$answerCorrect]['name']); |
@@ -449,8 +449,8 @@ discard block |
||
449 | 449 | } |
450 | 450 | |
451 | 451 | if ($hide_expected_answer) { |
452 | - $color = ''; |
|
453 | - } |
|
452 | + $color = ''; |
|
453 | + } |
|
454 | 454 | |
455 | 455 | echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>'; |
456 | 456 | } |
@@ -468,19 +468,19 @@ discard block |
||
468 | 468 | <?php |
469 | 469 | } |
470 | 470 | |
471 | - /** |
|
472 | - * Display the answers to a multiple choice question |
|
473 | - * |
|
474 | - * @param integer Answer type |
|
475 | - * @param integer Student choice |
|
476 | - * @param string Textual answer |
|
477 | - * @param string Comment on answer |
|
478 | - * @param string Correct answer comment |
|
479 | - * @param integer Exercise ID |
|
480 | - * @param integer Question ID |
|
481 | - * @param boolean Whether to show the answer comment or not |
|
482 | - * @return void |
|
483 | - */ |
|
471 | + /** |
|
472 | + * Display the answers to a multiple choice question |
|
473 | + * |
|
474 | + * @param integer Answer type |
|
475 | + * @param integer Student choice |
|
476 | + * @param string Textual answer |
|
477 | + * @param string Comment on answer |
|
478 | + * @param string Correct answer comment |
|
479 | + * @param integer Exercise ID |
|
480 | + * @param integer Question ID |
|
481 | + * @param boolean Whether to show the answer comment or not |
|
482 | + * @return void |
|
483 | + */ |
|
484 | 484 | public static function display_multiple_answer_combination_true_false( |
485 | 485 | $feedback_type, |
486 | 486 | $answerType, |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | <tr> |
512 | 512 | <td width="5%"> |
513 | 513 | <?php |
514 | - //Your choice |
|
514 | + //Your choice |
|
515 | 515 | $question = new MultipleAnswerCombinationTrueFalse(); |
516 | 516 | if (isset($question->options[$studentChoice])) { |
517 | 517 | echo $question->options[$studentChoice]; |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | </td> |
523 | 523 | <td width="5%"> |
524 | 524 | <?php |
525 | - // Expected choice |
|
525 | + // Expected choice |
|
526 | 526 | if (!$hide_expected_answer) { |
527 | 527 | if (isset($question->options[$answerCorrect])) { |
528 | 528 | echo $question->options[$answerCorrect]; |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | <?php |
548 | 548 | //@todo replace this harcoded value |
549 | 549 | if ($studentChoice) { |
550 | - $color = "black"; |
|
550 | + $color = "black"; |
|
551 | 551 | if ($studentChoice == $answerCorrect) { |
552 | 552 | $color = "green"; |
553 | 553 | } |