Completed
Push — 1.10.x ( 5d5324...cf3164 )
by Julito
60:26
created
main/exercice/answer.class.php 1 patch
Indentation   +299 added lines, -299 removed lines patch added patch discarded remove patch
@@ -157,12 +157,12 @@  discard block
 block discarded – undo
157 157
         return [];
158 158
     }
159 159
 
160
-     /**
161
-     * returns all answer ids from this question Id
162
-     *
163
-     * @author Yoselyn Castillo
164
-     * @return array - $id (answer ids)
165
-     */
160
+        /**
161
+         * returns all answer ids from this question Id
162
+         *
163
+         * @author Yoselyn Castillo
164
+         * @return array - $id (answer ids)
165
+         */
166 166
     public function selectAnswerId()
167 167
     {
168 168
         $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         }
183 183
 
184 184
         return $id;
185
-	}
185
+    }
186 186
 
187 187
     /**
188 188
      * Reads answer information from the data base ordered by parameter
@@ -193,23 +193,23 @@  discard block
 block discarded – undo
193 193
      */
194 194
     public function readOrderedBy($field, $order='ASC')
195 195
     {
196
-		$field = Database::escape_string($field);
197
-		if (empty($field)) {
198
-			$field = 'position';
199
-		}
196
+        $field = Database::escape_string($field);
197
+        if (empty($field)) {
198
+            $field = 'position';
199
+        }
200 200
 
201
-		if ($order != 'ASC' && $order!='DESC') {
202
-			$order = 'ASC';
203
-		}
201
+        if ($order != 'ASC' && $order!='DESC') {
202
+            $order = 'ASC';
203
+        }
204 204
 
205
-		$TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
206
-		$TBL_QUIZ = Database::get_course_table(TABLE_QUIZ_QUESTION);
207
-		$questionId = intval($this->questionId);
205
+        $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
206
+        $TBL_QUIZ = Database::get_course_table(TABLE_QUIZ_QUESTION);
207
+        $questionId = intval($this->questionId);
208 208
 
209
-		$sql = "SELECT type FROM $TBL_QUIZ
209
+        $sql = "SELECT type FROM $TBL_QUIZ
210 210
 		        WHERE c_id = {$this->course_id} AND id = $questionId";
211
-		$result_question = Database::query($sql);
212
-		$questionType = Database::fetch_array($result_question);
211
+        $result_question = Database::query($sql);
212
+        $questionType = Database::fetch_array($result_question);
213 213
 
214 214
         if ($questionType['type'] == DRAGGABLE) {
215 215
             // Random is done by submit.js.tpl
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
             return true;
219 219
         }
220 220
 
221
-		$sql = "SELECT
221
+        $sql = "SELECT
222 222
 		            answer,
223 223
 		            correct,
224 224
 		            comment,
@@ -234,16 +234,16 @@  discard block
 block discarded – undo
234 234
                     c_id = {$this->course_id} AND
235 235
                     question_id='".$questionId."'
236 236
                 ORDER BY $field $order";
237
-		$result=Database::query($sql);
238
-
239
-		$i = 1;
240
-		// while a record is found
241
-		$doubt_data = null;
242
-		while ($object = Database::fetch_object($result)) {
243
-		    if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && $object->position == 666) {
244
-		        $doubt_data = $object;
237
+        $result=Database::query($sql);
238
+
239
+        $i = 1;
240
+        // while a record is found
241
+        $doubt_data = null;
242
+        while ($object = Database::fetch_object($result)) {
243
+            if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && $object->position == 666) {
244
+                $doubt_data = $object;
245 245
                 continue;
246
-		    }
246
+            }
247 247
             $this->answer[$i] = $object->answer;
248 248
             $this->correct[$i] = $object->correct;
249 249
             $this->comment[$i] = $object->comment;
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
             $this->autoId[$i] = $object->id_auto;
256 256
             $this->iid[$i] = $object->iid;
257 257
             $i++;
258
-		}
258
+        }
259 259
 
260
-		if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && !empty($doubt_data)) {
260
+        if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && !empty($doubt_data)) {
261 261
             $this->answer[$i] = $doubt_data->answer;
262 262
             $this->correct[$i] = $doubt_data->correct;
263 263
             $this->comment[$i] = $doubt_data->comment;
@@ -269,88 +269,88 @@  discard block
 block discarded – undo
269 269
             $this->autoId[$i] = $doubt_data->id_auto;
270 270
             $this->iid[$i] = $doubt_data->iid;
271 271
             $i++;
272
-	    }
272
+        }
273 273
         $this->nbrAnswers = $i-1;
274
-	}
275
-
276
-	/**
277
-	 * returns the autoincrement id identificator
278
-	 *
279
-	 * @author Juan Carlos Ra�a
280
-	 * @return integer - answer num
281
-	 */
274
+    }
275
+
276
+    /**
277
+     * returns the autoincrement id identificator
278
+     *
279
+     * @author Juan Carlos Ra�a
280
+     * @return integer - answer num
281
+     */
282 282
     public function selectAutoId($id)
283 283
     {
284
-		return isset($this->autoId[$id]) ? $this->autoId[$id] : 0;
285
-	}
286
-
287
-	/**
288
-	 * returns the number of answers in this question
289
-	 *
290
-	 * @author Olivier Brouckaert
291
-	 * @return integer - number of answers
292
-	 */
293
-	public function selectNbrAnswers()
284
+        return isset($this->autoId[$id]) ? $this->autoId[$id] : 0;
285
+    }
286
+
287
+    /**
288
+     * returns the number of answers in this question
289
+     *
290
+     * @author Olivier Brouckaert
291
+     * @return integer - number of answers
292
+     */
293
+    public function selectNbrAnswers()
294 294
     {
295
-		return $this->nbrAnswers;
296
-	}
297
-
298
-	/**
299
-	 * returns the question ID which the answers belong to
300
-	 *
301
-	 * @author Olivier Brouckaert
302
-	 * @return integer - the question ID
303
-	 */
304
-	public function selectQuestionId()
295
+        return $this->nbrAnswers;
296
+    }
297
+
298
+    /**
299
+     * returns the question ID which the answers belong to
300
+     *
301
+     * @author Olivier Brouckaert
302
+     * @return integer - the question ID
303
+     */
304
+    public function selectQuestionId()
305
+    {
306
+        return $this->questionId;
307
+    }
308
+
309
+    /**
310
+     * returns the question ID of the destination question
311
+     *
312
+     * @author Julio Montoya
313
+     * @param integer $id
314
+     * @return integer - the question ID
315
+     */
316
+    public function selectDestination($id)
305 317
     {
306
-		return $this->questionId;
307
-	}
308
-
309
-	/**
310
-	 * returns the question ID of the destination question
311
-	 *
312
-	 * @author Julio Montoya
313
-	 * @param integer $id
314
-	 * @return integer - the question ID
315
-	 */
316
-	public function selectDestination($id)
318
+        return isset($this->destination[$id]) ? $this->destination[$id] : null;
319
+    }
320
+
321
+    /**
322
+     * returns the answer title
323
+     *
324
+     * @author Olivier Brouckaert
325
+     * @param - integer $id - answer ID
326
+     * @return string - answer title
327
+     */
328
+    public function selectAnswer($id)
317 329
     {
318
-		return isset($this->destination[$id]) ? $this->destination[$id] : null;
319
-	}
330
+        return isset($this->answer[$id]) ? $this->answer[$id] : null;
331
+    }
320 332
 
321 333
     /**
322
-	 * returns the answer title
323
-	 *
324
-	 * @author Olivier Brouckaert
325
-	 * @param - integer $id - answer ID
326
-	 * @return string - answer title
327
-	 */
328
-	public function selectAnswer($id)
329
-	{
330
-		return isset($this->answer[$id]) ? $this->answer[$id] : null;
331
-	}
332
-
333
-	/**
334
-	 * return array answer by id else return a bool
335
-	 * @param integer $auto_id
336
-	 */
337
-	public function selectAnswerByAutoId($auto_id)
338
-	{
339
-		$TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
340
-
341
-		$auto_id = intval($auto_id);
342
-		$sql = "SELECT id, answer, id_auto FROM $TBL_ANSWER
334
+     * return array answer by id else return a bool
335
+     * @param integer $auto_id
336
+     */
337
+    public function selectAnswerByAutoId($auto_id)
338
+    {
339
+        $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
340
+
341
+        $auto_id = intval($auto_id);
342
+        $sql = "SELECT id, answer, id_auto FROM $TBL_ANSWER
343 343
 				WHERE c_id = {$this->course_id} AND id_auto='$auto_id'";
344
-		$rs = Database::query($sql);
344
+        $rs = Database::query($sql);
345 345
 
346
-		if (Database::num_rows($rs) > 0) {
347
-			$row = Database::fetch_array($rs, 'ASSOC');
346
+        if (Database::num_rows($rs) > 0) {
347
+            $row = Database::fetch_array($rs, 'ASSOC');
348 348
 
349
-			return $row;
350
-		}
349
+            return $row;
350
+        }
351 351
 
352
-		return false;
353
-	}
352
+        return false;
353
+    }
354 354
 
355 355
     /**
356 356
      * returns the answer title from an answer's position
@@ -359,18 +359,18 @@  discard block
 block discarded – undo
359 359
      * @param - integer $id - answer ID
360 360
      * @return bool - answer title
361 361
      */
362
-	public function selectAnswerIdByPosition($pos)
363
-	{
364
-		foreach ($this->position as $k => $v) {
365
-			if ($v != $pos) {
366
-				continue;
367
-			}
362
+    public function selectAnswerIdByPosition($pos)
363
+    {
364
+        foreach ($this->position as $k => $v) {
365
+            if ($v != $pos) {
366
+                continue;
367
+            }
368 368
 
369
-			return $k;
370
-		}
369
+            return $k;
370
+        }
371 371
 
372
-		return false;
373
-	}
372
+        return false;
373
+    }
374 374
 
375 375
     /**
376 376
      * Returns a list of answers
@@ -379,18 +379,18 @@  discard block
 block discarded – undo
379 379
      * of (id, answer, comment, grade) and grade=weighting
380 380
      */
381 381
     public function getAnswersList($decode = false)
382
-     {
383
-	 	$list = array();
384
-         for ($i = 1; $i <= $this->nbrAnswers; $i++) {
385
-             if (!empty($this->answer[$i])) {
386
-
387
-	 			//Avoid problems when parsing elements with accents
388
-	 			if ($decode) {
389
-	        		$this->answer[$i] 	= api_html_entity_decode($this->answer[$i], ENT_QUOTES, api_get_system_encoding());
390
-	        		$this->comment[$i]	= api_html_entity_decode($this->comment[$i], ENT_QUOTES, api_get_system_encoding());
391
-	 			}
392
-
393
-	 			$list[] = array(
382
+        {
383
+            $list = array();
384
+            for ($i = 1; $i <= $this->nbrAnswers; $i++) {
385
+                if (!empty($this->answer[$i])) {
386
+
387
+                    //Avoid problems when parsing elements with accents
388
+                    if ($decode) {
389
+                    $this->answer[$i] 	= api_html_entity_decode($this->answer[$i], ENT_QUOTES, api_get_system_encoding());
390
+                    $this->comment[$i]	= api_html_entity_decode($this->comment[$i], ENT_QUOTES, api_get_system_encoding());
391
+                    }
392
+
393
+                    $list[] = array(
394 394
                     'id' => $i,
395 395
                     'answer' => $this->answer[$i],
396 396
                     'comment' => $this->comment[$i],
@@ -399,137 +399,137 @@  discard block
 block discarded – undo
399 399
                     'hotspot_type' => $this->hotspot_type[$i],
400 400
                     'correct' => $this->correct[$i],
401 401
                     'destination' => $this->destination[$i]
402
-				);
402
+                );
403
+            }
403 404
             }
404
-	 	}
405 405
 
406
-	 	return $list;
407
-	 }
406
+            return $list;
407
+        }
408 408
 
409
-	/**
410
-	 * Returns a list of grades
411
-	 * @author Yannick Warnier <[email protected]>
412
-	 * @return array	List of grades where grade=weighting (?)
413
-	 */
409
+    /**
410
+     * Returns a list of grades
411
+     * @author Yannick Warnier <[email protected]>
412
+     * @return array	List of grades where grade=weighting (?)
413
+     */
414 414
     public function getGradesList()
415
-     {
416
-	 	$list = array();
417
-	 	for ($i = 0; $i<$this->nbrAnswers;$i++){
418
-	 		if(!empty($this->answer[$i])){
419
-	 			$list[$i] = $this->weighting[$i];
420
-	 		}
421
-	 	}
422
-	 	return $list;
423
-	 }
424
-
425
-	 /**
426
-	  * Returns the question type
427
-	  * @author	Yannick Warnier <[email protected]>
428
-	  * @return	integer	The type of the question this answer is bound to
429
-	  */
415
+        {
416
+            $list = array();
417
+            for ($i = 0; $i<$this->nbrAnswers;$i++){
418
+                if(!empty($this->answer[$i])){
419
+                    $list[$i] = $this->weighting[$i];
420
+                }
421
+            }
422
+            return $list;
423
+        }
424
+
425
+        /**
426
+         * Returns the question type
427
+         * @author	Yannick Warnier <[email protected]>
428
+         * @return	integer	The type of the question this answer is bound to
429
+         */
430 430
     public function getQuestionType()
431
-     {
432
-	 	$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
433
-	 	$sql = "SELECT type FROM $TBL_QUESTIONS
431
+        {
432
+            $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
433
+            $sql = "SELECT type FROM $TBL_QUESTIONS
434 434
 	 	        WHERE c_id = {$this->course_id} AND id = '".$this->questionId."'";
435
-	 	$res = Database::query($sql);
436
-	 	if (Database::num_rows($res)<=0){
437
-	 		return null;
438
-	 	}
439
-	 	$row = Database::fetch_array($res);
440
-
441
-	 	return $row['type'];
442
-	 }
443
-
444
-
445
-	/**
446
-	 * tells if answer is correct or not
447
-	 *
448
-	 * @author Olivier Brouckaert
449
-	 * @param - integer $id - answer ID
450
-	 * @return integer - 0 if bad answer, not 0 if good answer
451
-	 */
435
+            $res = Database::query($sql);
436
+            if (Database::num_rows($res)<=0){
437
+                return null;
438
+            }
439
+            $row = Database::fetch_array($res);
440
+
441
+            return $row['type'];
442
+        }
443
+
444
+
445
+    /**
446
+     * tells if answer is correct or not
447
+     *
448
+     * @author Olivier Brouckaert
449
+     * @param - integer $id - answer ID
450
+     * @return integer - 0 if bad answer, not 0 if good answer
451
+     */
452 452
     public function isCorrect($id)
453
-	{
454
-		return isset($this->correct[$id]) ? $this->correct[$id] : null;
455
-	}
456
-
457
-	/**
458
-	 * returns answer comment
459
-	 *
460
-	 * @author Olivier Brouckaert
461
-	 * @param - integer $id - answer ID
462
-	 * @return string - answer comment
463
-	 */
453
+    {
454
+        return isset($this->correct[$id]) ? $this->correct[$id] : null;
455
+    }
456
+
457
+    /**
458
+     * returns answer comment
459
+     *
460
+     * @author Olivier Brouckaert
461
+     * @param - integer $id - answer ID
462
+     * @return string - answer comment
463
+     */
464 464
     public function selectComment($id)
465
-	{
465
+    {
466 466
         return isset($this->comment[$id]) ? $this->comment[$id] : null;
467
-	}
468
-
469
-	/**
470
-	 * returns answer weighting
471
-	 *
472
-	 * @author Olivier Brouckaert
473
-	 * @param - integer $id - answer ID
474
-	 * @param integer $id
475
-	 * @return integer - answer weighting
476
-	 */
467
+    }
468
+
469
+    /**
470
+     * returns answer weighting
471
+     *
472
+     * @author Olivier Brouckaert
473
+     * @param - integer $id - answer ID
474
+     * @param integer $id
475
+     * @return integer - answer weighting
476
+     */
477 477
     public function selectWeighting($id)
478
-	{
479
-		return isset($this->weighting[$id]) ? $this->weighting[$id] : null;
480
-	}
481
-
482
-	/**
483
-	 * returns answer position
484
-	 *
485
-	 * @author Olivier Brouckaert
486
-	 * @param - integer $id - answer ID
487
-	 * @return integer - answer position
488
-	 */
489
-	function selectPosition($id)
490
-	{
491
-		return isset($this->position[$id]) ? $this->position[$id] : null;
492
-	}
493
-
494
-	/**
495
-	 * returns answer hotspot coordinates
496
-	 *
497
-	 * @author	Olivier Brouckaert
498
-	 * @param	integer	Answer ID
499
-	 * @param integer $id
500
-	 * @return	integer	Answer position
501
-	 */
478
+    {
479
+        return isset($this->weighting[$id]) ? $this->weighting[$id] : null;
480
+    }
481
+
482
+    /**
483
+     * returns answer position
484
+     *
485
+     * @author Olivier Brouckaert
486
+     * @param - integer $id - answer ID
487
+     * @return integer - answer position
488
+     */
489
+    function selectPosition($id)
490
+    {
491
+        return isset($this->position[$id]) ? $this->position[$id] : null;
492
+    }
493
+
494
+    /**
495
+     * returns answer hotspot coordinates
496
+     *
497
+     * @author	Olivier Brouckaert
498
+     * @param	integer	Answer ID
499
+     * @param integer $id
500
+     * @return	integer	Answer position
501
+     */
502 502
     public function selectHotspotCoordinates($id)
503
-	{
504
-		return isset($this->hotspot_coordinates[$id]) ? $this->hotspot_coordinates[$id] : null;
505
-	}
506
-
507
-	/**
508
-	 * returns answer hotspot type
509
-	 *
510
-	 * @author	Toon Keppens
511
-	 * @param	integer		Answer ID
512
-	 * @param integer $id
513
-	 * @return	integer		Answer position
514
-	 */
503
+    {
504
+        return isset($this->hotspot_coordinates[$id]) ? $this->hotspot_coordinates[$id] : null;
505
+    }
506
+
507
+    /**
508
+     * returns answer hotspot type
509
+     *
510
+     * @author	Toon Keppens
511
+     * @param	integer		Answer ID
512
+     * @param integer $id
513
+     * @return	integer		Answer position
514
+     */
515 515
     public function selectHotspotType($id)
516
-	{
517
-		return isset($this->hotspot_type[$id]) ? $this->hotspot_type[$id] : null;
518
-	}
519
-
520
-	/**
521
-	 * Creates a new answer
522
-	 *
523
-	 * @author Olivier Brouckaert
524
-	 * @param string 	$answer answer title
525
-	 * @param integer 	$correct 0 if bad answer, not 0 if good answer
526
-	 * @param string 	$comment answer comment
527
-	 * @param integer 	$weighting answer weighting
528
-	 * @param integer 	$position answer position
529
-	 * @param array    $new_hotspot_coordinates Coordinates for hotspot exercises (optional)
530
-	 * @param integer	$new_hotspot_type Type for hotspot exercises (optional)
516
+    {
517
+        return isset($this->hotspot_type[$id]) ? $this->hotspot_type[$id] : null;
518
+    }
519
+
520
+    /**
521
+     * Creates a new answer
522
+     *
523
+     * @author Olivier Brouckaert
524
+     * @param string 	$answer answer title
525
+     * @param integer 	$correct 0 if bad answer, not 0 if good answer
526
+     * @param string 	$comment answer comment
527
+     * @param integer 	$weighting answer weighting
528
+     * @param integer 	$position answer position
529
+     * @param array    $new_hotspot_coordinates Coordinates for hotspot exercises (optional)
530
+     * @param integer	$new_hotspot_type Type for hotspot exercises (optional)
531 531
      * @param string   $destination
532
-	 */
532
+     */
533 533
     public function createAnswer(
534 534
         $answer,
535 535
         $correct,
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
         $new_hotspot_type = null,
541 541
         $destination = ''
542 542
     ) {
543
-		$this->new_nbrAnswers++;
543
+        $this->new_nbrAnswers++;
544 544
         $id = $this->new_nbrAnswers;
545 545
         $this->new_answer[$id] = $answer;
546 546
         $this->new_correct[$id] = $correct;
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
         $this->new_hotspot_coordinates[$id] = $new_hotspot_coordinates;
551 551
         $this->new_hotspot_type[$id] = $new_hotspot_type;
552 552
         $this->new_destination[$id] = $destination;
553
-	}
553
+    }
554 554
 
555 555
     /**
556 556
      * Updates an answer
@@ -591,31 +591,31 @@  discard block
 block discarded – undo
591 591
         ];
592 592
 
593 593
         Database::update($answerTable, $params, ['iid = ?' => intval($iid)]);
594
-	}
594
+    }
595 595
 
596
-	/**
597
-	 * Records answers into the data base
598
-	 *
599
-	 * @author Olivier Brouckaert
600
-	 */
596
+    /**
597
+     * Records answers into the data base
598
+     *
599
+     * @author Olivier Brouckaert
600
+     */
601 601
     public function save()
602 602
     {
603
-		$answerTable = Database::get_course_table(TABLE_QUIZ_ANSWER);
604
-		$questionId = intval($this->questionId);
603
+        $answerTable = Database::get_course_table(TABLE_QUIZ_ANSWER);
604
+        $questionId = intval($this->questionId);
605 605
 
606
-		$c_id = $this->course['real_id'];
606
+        $c_id = $this->course['real_id'];
607 607
         $correctList = [];
608 608
         $answerList = [];
609 609
 
610
-		for ($i=1; $i <= $this->new_nbrAnswers; $i++) {
611
-			$answer = $this->new_answer[$i];
612
-			$correct = isset($this->new_correct[$i]) ? $this->new_correct[$i] : '';
613
-			$comment = isset($this->new_comment[$i]) ? $this->new_comment[$i] : '';
614
-			$weighting = isset($this->new_weighting[$i]) ? $this->new_weighting[$i] : '';
615
-			$position = isset($this->new_position[$i]) ? $this->new_position[$i] : '';
616
-			$hotspot_coordinates = isset($this->new_hotspot_coordinates[$i]) ? $this->new_hotspot_coordinates[$i] : '';
617
-			$hotspot_type = isset($this->new_hotspot_type[$i]) ? $this->new_hotspot_type[$i] : '';
618
-			$destination = isset($this->new_destination[$i]) ? $this->new_destination[$i] : '';
610
+        for ($i=1; $i <= $this->new_nbrAnswers; $i++) {
611
+            $answer = $this->new_answer[$i];
612
+            $correct = isset($this->new_correct[$i]) ? $this->new_correct[$i] : '';
613
+            $comment = isset($this->new_comment[$i]) ? $this->new_comment[$i] : '';
614
+            $weighting = isset($this->new_weighting[$i]) ? $this->new_weighting[$i] : '';
615
+            $position = isset($this->new_position[$i]) ? $this->new_position[$i] : '';
616
+            $hotspot_coordinates = isset($this->new_hotspot_coordinates[$i]) ? $this->new_hotspot_coordinates[$i] : '';
617
+            $hotspot_type = isset($this->new_hotspot_type[$i]) ? $this->new_hotspot_type[$i] : '';
618
+            $destination = isset($this->new_destination[$i]) ? $this->new_destination[$i] : '';
619 619
             $autoId = $this->selectAutoId($i);
620 620
             $iid = isset($this->iid[$i]) ? $this->iid[$i] : 0;
621 621
 
@@ -714,35 +714,35 @@  discard block
 block discarded – undo
714 714
             }
715 715
         }
716 716
 
717
-		// moves $new_* arrays
718
-		$this->answer = $this->new_answer;
719
-		$this->correct = $this->new_correct;
720
-		$this->comment = $this->new_comment;
721
-		$this->weighting = $this->new_weighting;
722
-		$this->position = $this->new_position;
723
-		$this->hotspot_coordinates = $this->new_hotspot_coordinates;
724
-		$this->hotspot_type = $this->new_hotspot_type;
725
-		$this->nbrAnswers = $this->new_nbrAnswers;
726
-		$this->destination = $this->new_destination;
727
-
728
-		$this->cancel();
729
-	}
730
-
731
-	/**
732
-	 * Duplicates answers by copying them into another question
733
-	 *
734
-	 * @author Olivier Brouckaert
735
-	 * @param  int question id
717
+        // moves $new_* arrays
718
+        $this->answer = $this->new_answer;
719
+        $this->correct = $this->new_correct;
720
+        $this->comment = $this->new_comment;
721
+        $this->weighting = $this->new_weighting;
722
+        $this->position = $this->new_position;
723
+        $this->hotspot_coordinates = $this->new_hotspot_coordinates;
724
+        $this->hotspot_type = $this->new_hotspot_type;
725
+        $this->nbrAnswers = $this->new_nbrAnswers;
726
+        $this->destination = $this->new_destination;
727
+
728
+        $this->cancel();
729
+    }
730
+
731
+    /**
732
+     * Duplicates answers by copying them into another question
733
+     *
734
+     * @author Olivier Brouckaert
735
+     * @param  int question id
736 736
      * @param  array destination course info (result of the function api_get_course_info() )
737 737
      * @param string $newQuestionId
738
-	 */
738
+     */
739 739
     public function duplicate($newQuestionId, $course_info = null)
740 740
     {
741 741
         if (empty($course_info)) {
742 742
             $course_info = $this->course;
743 743
         }
744 744
 
745
-		$TBL_REPONSES = Database :: get_course_table(TABLE_QUIZ_ANSWER);
745
+        $TBL_REPONSES = Database :: get_course_table(TABLE_QUIZ_ANSWER);
746 746
         $fixed_list = array();
747 747
 
748 748
         if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE ||
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 
757 757
             if (!empty($origin_options)) {
758 758
                 foreach ($origin_options as $item) {
759
-            	   $new_option_list[] = $item['id'];
759
+                    $new_option_list[] = $item['id'];
760 760
                 }
761 761
             }
762 762
 
@@ -770,12 +770,12 @@  discard block
 block discarded – undo
770 770
             }
771 771
         }
772 772
 
773
-		// if at least one answer
774
-		if ($this->nbrAnswers) {
775
-			// inserts new answers into data base
776
-			$c_id = $course_info['real_id'];
773
+        // if at least one answer
774
+        if ($this->nbrAnswers) {
775
+            // inserts new answers into data base
776
+            $c_id = $course_info['real_id'];
777 777
 
778
-			for ($i=1;$i <= $this->nbrAnswers;$i++) {
778
+            for ($i=1;$i <= $this->nbrAnswers;$i++) {
779 779
                 if ($this->course['id'] != $course_info['id']) {
780 780
                     $this->answer[$i] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
781 781
                         $this->answer[$i],
@@ -789,8 +789,8 @@  discard block
 block discarded – undo
789 789
                     );
790 790
                 }
791 791
 
792
-				$answer = $this->answer[$i];
793
-				$correct = $this->correct[$i];
792
+                $answer = $this->answer[$i];
793
+                $correct = $this->correct[$i];
794 794
 
795 795
                 if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE ||
796 796
                     self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE
@@ -798,12 +798,12 @@  discard block
 block discarded – undo
798 798
                     $correct = $fixed_list[intval($correct)];
799 799
                 }
800 800
 
801
-				$comment = $this->comment[$i];
802
-				$weighting = $this->weighting[$i];
803
-				$position = $this->position[$i];
804
-				$hotspot_coordinates = $this->hotspot_coordinates[$i];
805
-				$hotspot_type = $this->hotspot_type[$i];
806
-				$destination = $this->destination[$i];
801
+                $comment = $this->comment[$i];
802
+                $weighting = $this->weighting[$i];
803
+                $position = $this->position[$i];
804
+                $hotspot_coordinates = $this->hotspot_coordinates[$i];
805
+                $hotspot_type = $this->hotspot_type[$i];
806
+                $destination = $this->destination[$i];
807 807
 
808 808
                 $params = [
809 809
                     'c_id' => $c_id,
@@ -823,9 +823,9 @@  discard block
 block discarded – undo
823 823
                     $sql = "UPDATE $TBL_REPONSES SET id = iid, id_auto = iid WHERE iid = $id";
824 824
                     Database::query($sql);
825 825
                 }
826
-			}
826
+            }
827 827
         }
828
-	}
828
+    }
829 829
 
830 830
     /**
831 831
      * Get the necessary JavaScript for some answers
Please login to merge, or discard this patch.
main/exercice/export/qti2/qti2_export.php 1 patch
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -34,21 +34,21 @@  discard block
 block discarded – undo
34 34
      *
35 35
      * @param Ims2Question $question Ims2Question object we want to export.
36 36
      */
37
-     function __construct($question)
38
-     {
37
+        function __construct($question)
38
+        {
39 39
         $this->question = $question;
40 40
         $this->answer = $this->question->setAnswer();
41 41
         $this->questionIdent = "QST_" . $question->id ;
42
-     }
43
-
44
-     /**
45
-      * Start the XML flow.
46
-      *
47
-      * This opens the <item> block, with correct attributes.
48
-      *
49
-      */
50
-      function start_item()
51
-      {
42
+        }
43
+
44
+        /**
45
+         * Start the XML flow.
46
+         *
47
+         * This opens the <item> block, with correct attributes.
48
+         *
49
+         */
50
+        function start_item()
51
+        {
52 52
         $string = '<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p1"
53 53
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
54 54
                     xsi:schemaLocation="http://www.imsglobal.org/xsd/imsqti_v2p1 imsqti_v2p1.xsd"
@@ -56,55 +56,55 @@  discard block
 block discarded – undo
56 56
                     title="'.htmlspecialchars(formatExerciseQtiTitle($this->question->selectTitle())).'">'."\n";
57 57
 
58 58
         return $string;
59
-      }
60
-
61
-      /**
62
-       * End the XML flow, closing the </item> tag.
63
-       *
64
-       */
65
-      function end_item()
66
-      {
59
+        }
60
+
61
+        /**
62
+         * End the XML flow, closing the </item> tag.
63
+         *
64
+         */
65
+        function end_item()
66
+        {
67 67
         return "</assessmentItem>\n";
68
-      }
69
-
70
-     /**
71
-      * Start the itemBody
72
-      *
73
-      */
74
-     function start_item_body()
75
-     {
68
+        }
69
+
70
+        /**
71
+         * Start the itemBody
72
+         *
73
+         */
74
+        function start_item_body()
75
+        {
76 76
         return '  <itemBody>' . "\n";
77
-     }
78
-
79
-     /**
80
-      * End the itemBody part.
81
-      *
82
-      */
83
-     function end_item_body()
84
-     {
77
+        }
78
+
79
+        /**
80
+         * End the itemBody part.
81
+         *
82
+         */
83
+        function end_item_body()
84
+        {
85 85
         return "  </itemBody>\n";
86
-     }
87
-
88
-     /**
89
-      * add the response processing template used.
90
-      *
91
-      */
92
-
93
-      function add_response_processing()
94
-      {
95
-          return '  <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>' . "\n";
96
-      }
97
-
98
-     /**
99
-      * Export the question as an IMS/QTI Item.
100
-      *
101
-      * This is a default behaviour, some classes may want to override this.
102
-      *
103
-      * @param $standalone: Boolean stating if it should be exported as a stand-alone question
104
-      * @return string string, the XML flow for an Item.
105
-      */
106
-     function export($standalone = false)
107
-     {
86
+        }
87
+
88
+        /**
89
+         * add the response processing template used.
90
+         *
91
+         */
92
+
93
+        function add_response_processing()
94
+        {
95
+            return '  <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>' . "\n";
96
+        }
97
+
98
+        /**
99
+         * Export the question as an IMS/QTI Item.
100
+         *
101
+         * This is a default behaviour, some classes may want to override this.
102
+         *
103
+         * @param $standalone: Boolean stating if it should be exported as a stand-alone question
104
+         * @return string string, the XML flow for an Item.
105
+         */
106
+        function export($standalone = false)
107
+        {
108 108
         $head = $foot = "";
109 109
 
110 110
         if ($standalone) {
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
             .$foot;
132 132
 
133 133
         return $res;
134
-     }
134
+        }
135 135
 }
136 136
 
137 137
 /**
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
     function export_presentation()
195 195
     {
196 196
         $out = "<presentation_material><flow_mat><material>\n"
197
-             . "  <mattext><![CDATA[" . formatExerciseQtiDescription($this->exercise->selectDescription()) . "]]></mattext>\n"
198
-             . "</material></flow_mat></presentation_material>\n";
197
+                . "  <mattext><![CDATA[" . formatExerciseQtiDescription($this->exercise->selectDescription()) . "]]></mattext>\n"
198
+                . "</material></flow_mat></presentation_material>\n";
199 199
         return $out;
200 200
     }
201 201
 
@@ -209,15 +209,15 @@  discard block
 block discarded – undo
209 209
         $out = '';
210 210
         if ($n = $this->exercise->getShuffle()) {
211 211
             $out.= "<selection_ordering>"
212
-                 . "  <selection>\n"
213
-                 . "    <selection_number>" . $n . "</selection_number>\n"
214
-                 . "  </selection>\n"
215
-                 . '  <order order_type="Random" />'
216
-                 . "\n</selection_ordering>\n";
212
+                    . "  <selection>\n"
213
+                    . "    <selection_number>" . $n . "</selection_number>\n"
214
+                    . "  </selection>\n"
215
+                    . '  <order order_type="Random" />'
216
+                    . "\n</selection_ordering>\n";
217 217
         } else {
218 218
             $out.= '<selection_ordering sequence_type="Normal">' . "\n"
219
-                 . "  <selection />\n"
220
-                 . "</selection_ordering>\n";
219
+                    . "  <selection />\n"
220
+                    . "</selection_ordering>\n";
221 221
         }
222 222
 
223 223
         return $out;
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
     {
232 232
         $out = "";
233 233
         foreach ($this->exercise->selectQuestionList() as $q) {
234
-        	$out .= export_question_qti($q, false);
234
+            $out .= export_question_qti($q, false);
235 235
         }
236 236
         return $out;
237 237
     }
@@ -248,18 +248,18 @@  discard block
 block discarded – undo
248 248
         $head = $foot = "";
249 249
         if ($standalone) {
250 250
             $head = '<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>' . "\n"
251
-                  . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"
252
-                  . "<questestinterop>\n";
251
+                    . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"
252
+                    . "<questestinterop>\n";
253 253
             $foot = "</questestinterop>\n";
254 254
         }
255 255
         $out = $head
256
-             . $this->start_section()
257
-             . $this->export_duration()
258
-             . $this->export_presentation()
259
-             . $this->export_ordering()
260
-             . $this->export_questions()
261
-             . $this->end_section()
262
-             . $foot;
256
+                . $this->start_section()
257
+                . $this->export_duration()
258
+                . $this->export_presentation()
259
+                . $this->export_ordering()
260
+                . $this->export_questions()
261
+                . $this->end_section()
262
+                . $foot;
263 263
 
264 264
         return $out;
265 265
     }
@@ -306,97 +306,97 @@  discard block
 block discarded – undo
306 306
      * @return ImsItem
307 307
      * @author Anamd Tihon
308 308
      */
309
-     function __construct($question)
310
-     {
309
+        function __construct($question)
310
+        {
311 311
         $this->question = $question;
312 312
         $this->answer = $question->answer;
313 313
         $this->questionIdent = "QST_" . $question->selectId() ;
314
-     }
315
-
316
-     /**
317
-      * Start the XML flow.
318
-      *
319
-      * This opens the <item> block, with correct attributes.
320
-      *
321
-      * @author Amand Tihon <[email protected]>
322
-      */
323
-      function start_item()
324
-      {
314
+        }
315
+
316
+        /**
317
+         * Start the XML flow.
318
+         *
319
+         * This opens the <item> block, with correct attributes.
320
+         *
321
+         * @author Amand Tihon <[email protected]>
322
+         */
323
+        function start_item()
324
+        {
325 325
         return '<item title="' . cleanAttribute(formatExerciseQtiDescription($this->question->selectTitle())) . '" ident="' . $this->questionIdent . '">' . "\n";
326
-      }
327
-
328
-      /**
329
-       * End the XML flow, closing the </item> tag.
330
-       *
331
-       * @author Amand Tihon <[email protected]>
332
-       */
333
-      function end_item()
334
-      {
326
+        }
327
+
328
+        /**
329
+         * End the XML flow, closing the </item> tag.
330
+         *
331
+         * @author Amand Tihon <[email protected]>
332
+         */
333
+        function end_item()
334
+        {
335 335
         return "</item>\n";
336
-      }
337
-
338
-     /**
339
-      * Create the opening, with the question itself.
340
-      *
341
-      * This means it opens the <presentation> but doesn't close it, as this is the role of end_presentation().
342
-      * In between, the export_responses from the subclass should have been called.
343
-      *
344
-      * @author Amand Tihon <[email protected]>
345
-      */
346
-     function start_presentation()
347
-     {
336
+        }
337
+
338
+        /**
339
+         * Create the opening, with the question itself.
340
+         *
341
+         * This means it opens the <presentation> but doesn't close it, as this is the role of end_presentation().
342
+         * In between, the export_responses from the subclass should have been called.
343
+         *
344
+         * @author Amand Tihon <[email protected]>
345
+         */
346
+        function start_presentation()
347
+        {
348 348
         return '<presentation label="' . $this->questionIdent . '"><flow>' . "\n"
349
-             . '<material><mattext>' . formatExerciseQtiDescription($this->question->selectDescription()) . "</mattext></material>\n";
350
-     }
351
-
352
-     /**
353
-      * End the </presentation> part, opened by export_header.
354
-      *
355
-      * @author Amand Tihon <[email protected]>
356
-      */
357
-     function end_presentation()
358
-     {
349
+                . '<material><mattext>' . formatExerciseQtiDescription($this->question->selectDescription()) . "</mattext></material>\n";
350
+        }
351
+
352
+        /**
353
+         * End the </presentation> part, opened by export_header.
354
+         *
355
+         * @author Amand Tihon <[email protected]>
356
+         */
357
+        function end_presentation()
358
+        {
359 359
         return "</flow></presentation>\n";
360
-     }
361
-
362
-     /**
363
-      * Start the response processing, and declare the default variable, SCORE, at 0 in the outcomes.
364
-      *
365
-      * @author Amand Tihon <[email protected]>
366
-      */
367
-     function start_processing()
368
-     {
360
+        }
361
+
362
+        /**
363
+         * Start the response processing, and declare the default variable, SCORE, at 0 in the outcomes.
364
+         *
365
+         * @author Amand Tihon <[email protected]>
366
+         */
367
+        function start_processing()
368
+        {
369 369
         return '<resprocessing><outcomes><decvar vartype="Integer" defaultval="0" /></outcomes>' . "\n";
370
-     }
371
-
372
-     /**
373
-      * End the response processing part.
374
-      *
375
-      * @author Amand Tihon <[email protected]>
376
-      */
377
-     function end_processing()
378
-     {
370
+        }
371
+
372
+        /**
373
+         * End the response processing part.
374
+         *
375
+         * @author Amand Tihon <[email protected]>
376
+         */
377
+        function end_processing()
378
+        {
379 379
         return "</resprocessing>\n";
380
-     }
381
-
382
-     /**
383
-      * Export the question as an IMS/QTI Item.
384
-      *
385
-      * This is a default behaviour, some classes may want to override this.
386
-      *
387
-      * @param $standalone: Boolean stating if it should be exported as a stand-alone question
388
-      * @return string string, the XML flow for an Item.
389
-      * @author Amand Tihon <[email protected]>
390
-      */
391
-     function export($standalone = False)
392
-     {
380
+        }
381
+
382
+        /**
383
+         * Export the question as an IMS/QTI Item.
384
+         *
385
+         * This is a default behaviour, some classes may want to override this.
386
+         *
387
+         * @param $standalone: Boolean stating if it should be exported as a stand-alone question
388
+         * @return string string, the XML flow for an Item.
389
+         * @author Amand Tihon <[email protected]>
390
+         */
391
+        function export($standalone = False)
392
+        {
393 393
         global $charset;
394 394
         $head = $foot = "";
395 395
 
396 396
         if ($standalone) {
397 397
             $head = '<?xml version = "1.0" encoding = "'.$charset.'" standalone = "no"?>' . "\n"
398
-                  . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"
399
-                  . "<questestinterop>\n";
398
+                    . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"
399
+                    . "<questestinterop>\n";
400 400
             $foot = "</questestinterop>\n";
401 401
         }
402 402
 
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
             . $this->answer->imsExportFeedback($this->questionIdent)
412 412
             . $this->end_item()
413 413
             . $foot;
414
-     }
414
+        }
415 415
 }
416 416
 
417 417
 /**
@@ -450,9 +450,9 @@  discard block
 block discarded – undo
450 450
     $question->type = $qst->type;
451 451
     $question->question = $qst->question;
452 452
     $question->description = $qst->description;
453
-	$question->weighting=$qst->weighting;
454
-	$question->position=$qst->position;
455
-	$question->picture=$qst->picture;
453
+    $question->weighting=$qst->weighting;
454
+    $question->position=$qst->position;
455
+    $question->picture=$qst->picture;
456 456
     $ims = new ImsAssessmentItem($question);
457 457
 
458 458
     return $ims->export($standalone);
Please login to merge, or discard this patch.
main/exercice/export/aiken/aiken_classes.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@  discard block
 block discarded – undo
11 11
 
12 12
 if (!function_exists('mime_content_type')) {
13 13
 
14
-	/**
15
-	 * @param string $filename
14
+    /**
15
+     * @param string $filename
16 16
      * @return string
17
-	 */
18
-	function mime_content_type($filename) {
19
-		return DocumentManager::file_get_mime_type((string)$filename);
20
-	}
17
+     */
18
+    function mime_content_type($filename) {
19
+        return DocumentManager::file_get_mime_type((string)$filename);
20
+    }
21 21
 }
22 22
 
23 23
 /**
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         {
35 35
             case MCUA :
36 36
                 $answer = new AikenAnswerMultipleChoice($this->id);
37
-            	return $answer;
37
+                return $answer;
38 38
             default :
39 39
                 $answer = null;
40 40
                 break;
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
     }
44 44
     function createAnswersForm($form)
45 45
     {
46
-    	return true;
46
+        return true;
47 47
     }
48 48
     function processAnswersCreation($form)
49 49
     {
50
-    	return true;
50
+        return true;
51 51
     }
52 52
 }
53 53
 
Please login to merge, or discard this patch.
main/inc/lib/fileUpload.lib.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2110,7 +2110,7 @@
 block discarded – undo
2110 2110
                         $newFolderData = DocumentManager::get_document_data_by_id($documentId, $courseInfo, false, $sessionId);
2111 2111
                     }
2112 2112
                 } else {
2113
-                   $newFolderData = create_unexisting_directory(
2113
+                    $newFolderData = create_unexisting_directory(
2114 2114
                         $courseInfo,
2115 2115
                         $userId,
2116 2116
                         $sessionId,
Please login to merge, or discard this patch.
main/group/group_creation.php 1 patch
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
             exit;
53 53
             break;
54 54
         case 'create_subgroups':
55
-			GroupManager::create_subgroups(
56
-				$_POST['base_group'],
57
-				$_POST['number_of_groups']
58
-			);
55
+            GroupManager::create_subgroups(
56
+                $_POST['base_group'],
57
+                $_POST['number_of_groups']
58
+            );
59 59
             Display::addFlash(Display::return_message(get_lang('GroupsAdded')));
60 60
             header("Location: ".$currentUrl);
61 61
             exit;
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
 if (isset($_POST['number_of_groups'])) {
80 80
     if (!is_numeric($_POST['number_of_groups']) || intval($_POST['number_of_groups']) < 1) {
81 81
         Display :: display_error_message(
82
-			get_lang('PleaseEnterValidNumber').'<br /><br />
82
+            get_lang('PleaseEnterValidNumber').'<br /><br />
83 83
 			<a href="group_creation.php?'.api_get_cidreq().'">&laquo; '.get_lang('Back').'</a>',
84
-			false
85
-		);
84
+            false
85
+        );
86 86
     } else {
87 87
         $number_of_groups = intval($_POST['number_of_groups']);
88 88
         if ($number_of_groups > 1) {
@@ -120,20 +120,20 @@  discard block
 block discarded – undo
120 120
     }
121 121
     </script>
122 122
     <?php
123
-		}
124
-		$group_categories = GroupManager::get_categories();
125
-		$group_id = GroupManager :: get_number_of_groups() + 1;
126
-		$cat_options = [];
127
-		foreach ($group_categories as $index => $category) {
128
-			$cat_options[$category['id']] = $category['title'];
129
-		}
123
+        }
124
+        $group_categories = GroupManager::get_categories();
125
+        $group_id = GroupManager :: get_number_of_groups() + 1;
126
+        $cat_options = [];
127
+        foreach ($group_categories as $index => $category) {
128
+            $cat_options[$category['id']] = $category['title'];
129
+        }
130 130
         $form = new FormValidator('create_groups_step2', 'POST', api_get_self().'?'.api_get_cidreq());
131 131
 
132
-		// Modify the default templates
133
-		$renderer = $form->defaultRenderer();
134
-		$form_template = "<form {attributes}>\n<div class='create-groups'>\n<table>\n{content}\n</table>\n</div>\n</form>";
135
-		$renderer->setFormTemplate($form_template);
136
-		$element_template = <<<EOT
132
+        // Modify the default templates
133
+        $renderer = $form->defaultRenderer();
134
+        $form_template = "<form {attributes}>\n<div class='create-groups'>\n<table>\n{content}\n</table>\n</div>\n</form>";
135
+        $renderer->setFormTemplate($form_template);
136
+        $element_template = <<<EOT
137 137
         <tr class="separate">
138 138
 		<td>
139 139
 			<!-- BEGIN required -->
@@ -146,35 +146,35 @@  discard block
 block discarded – undo
146 146
 	</tr>
147 147
 
148 148
 EOT;
149
-		$renderer->setCustomElementTemplate($element_template);
149
+        $renderer->setCustomElementTemplate($element_template);
150 150
         $form->addElement('header', $nameTools);
151
-		$form->addElement('hidden', 'action');
152
-		$form->addElement('hidden', 'number_of_groups');
153
-		$defaults = array();
154
-		// Table heading
155
-		$group_el = array();
156
-		$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupName').'</b>');
151
+        $form->addElement('hidden', 'action');
152
+        $form->addElement('hidden', 'number_of_groups');
153
+        $defaults = array();
154
+        // Table heading
155
+        $group_el = array();
156
+        $group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupName').'</b>');
157 157
 
158
-		if (api_get_setting('allow_group_categories') == 'true') {
159
-			$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupCategory').'</b>');
160
-		}
161
-		$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupPlacesThis').'</b>');
162
-		$form->addGroup($group_el, 'groups', null, "</td><td>", false);
163
-		// Checkboxes
164
-		if ($_POST['number_of_groups'] > 1) {
165
-			$group_el = array ();
166
-			$group_el[] = $form->createElement('static', null, null, ' ');
167
-			if (api_get_setting('allow_group_categories') == 'true') {
168
-				$group_el[] = $form->createElement('checkbox', 'same_category', null, get_lang('SameForAll'), array('onclick' => "javascript: switch_state('category');"));
169
-			}
170
-			$group_el[] = $form->createElement('checkbox', 'same_places', null, get_lang('SameForAll'), array ('onclick' => "javascript: switch_state('places');"));
171
-			$form->addGroup($group_el, 'groups', null, '</td><td>', false);
172
-		}
173
-		// Properties for all groups
174
-		for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number ++) {
175
-			$group_el = array();
176
-			$group_el[] = $form->createElement('text', 'group_'.$group_number.'_name');
177
-			if (api_get_setting('allow_group_categories') == 'true') {
158
+        if (api_get_setting('allow_group_categories') == 'true') {
159
+            $group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupCategory').'</b>');
160
+        }
161
+        $group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupPlacesThis').'</b>');
162
+        $form->addGroup($group_el, 'groups', null, "</td><td>", false);
163
+        // Checkboxes
164
+        if ($_POST['number_of_groups'] > 1) {
165
+            $group_el = array ();
166
+            $group_el[] = $form->createElement('static', null, null, ' ');
167
+            if (api_get_setting('allow_group_categories') == 'true') {
168
+                $group_el[] = $form->createElement('checkbox', 'same_category', null, get_lang('SameForAll'), array('onclick' => "javascript: switch_state('category');"));
169
+            }
170
+            $group_el[] = $form->createElement('checkbox', 'same_places', null, get_lang('SameForAll'), array ('onclick' => "javascript: switch_state('places');"));
171
+            $form->addGroup($group_el, 'groups', null, '</td><td>', false);
172
+        }
173
+        // Properties for all groups
174
+        for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number ++) {
175
+            $group_el = array();
176
+            $group_el[] = $form->createElement('text', 'group_'.$group_number.'_name');
177
+            if (api_get_setting('allow_group_categories') == 'true') {
178 178
                 $group_el[] = $form->createElement(
179 179
                     'select',
180 180
                     'group_'.$group_number.'_category',
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
                     $cat_options,
183 183
                     array('id' => 'category_'.$group_number)
184 184
                 );
185
-			} else {
185
+            } else {
186 186
                 $group_el[] = $form->createElement('hidden', 'group_'.$group_number.'_category', 0);
187 187
                 $defaults['group_'.$group_number.'_category'] = array_keys($cat_options)[0];
188 188
             }
@@ -193,111 +193,111 @@  discard block
 block discarded – undo
193 193
                 array('class' => 'span1', 'id' => 'places_'.$group_number)
194 194
             );
195 195
 
196
-			if ($_POST['number_of_groups'] < 10000) {
197
-				if ($group_id < 10) {
198
-					$prev = '000';
199
-				} elseif ($group_id < 100) {
200
-					$prev = '00';
201
-				} elseif ($group_id<1000) {
202
-					$prev = '0';
203
-				} else {
204
-					$prev = '';
205
-				}
206
-			}
196
+            if ($_POST['number_of_groups'] < 10000) {
197
+                if ($group_id < 10) {
198
+                    $prev = '000';
199
+                } elseif ($group_id < 100) {
200
+                    $prev = '00';
201
+                } elseif ($group_id<1000) {
202
+                    $prev = '0';
203
+                } else {
204
+                    $prev = '';
205
+                }
206
+            }
207 207
 
208
-			$defaults['group_'.$group_number.'_name'] = get_lang('GroupSingle').' '.$prev.$group_id ++;
209
-			$form->addGroup($group_el, 'group_'.$group_number, null, '</td><td>', false);
210
-		}
211
-		$defaults['action'] = 'create_groups';
212
-		$defaults['number_of_groups'] = intval($_POST['number_of_groups']);
213
-		$form->setDefaults($defaults);
214
-		$form->addButtonCreate(get_lang('CreateGroup'), 'submit');
208
+            $defaults['group_'.$group_number.'_name'] = get_lang('GroupSingle').' '.$prev.$group_id ++;
209
+            $form->addGroup($group_el, 'group_'.$group_number, null, '</td><td>', false);
210
+        }
211
+        $defaults['action'] = 'create_groups';
212
+        $defaults['number_of_groups'] = intval($_POST['number_of_groups']);
213
+        $form->setDefaults($defaults);
214
+        $form->addButtonCreate(get_lang('CreateGroup'), 'submit');
215 215
         $form->display();
216
-	}
216
+    }
217 217
 } else {
218
-	/*
218
+    /*
219 219
 	 * Show form to generate new groups
220 220
 	 */
221 221
 
222
-	$create_groups_form = new FormValidator('create_groups', 'post', api_get_self().'?'.api_get_cidreq());
223
-	$create_groups_form->addElement('header', $nameTools);
222
+    $create_groups_form = new FormValidator('create_groups', 'post', api_get_self().'?'.api_get_cidreq());
223
+    $create_groups_form->addElement('header', $nameTools);
224 224
     $create_groups_form->addText('number_of_groups',get_lang('NumberOfGroupsToCreate'),null,array('value'=>'1'));
225 225
     $create_groups_form->addButton('submit', get_lang('ProceedToCreateGroup'),'plus','primary');
226
-	$defaults = array();
227
-	$defaults['number_of_groups'] = 1;
228
-	$create_groups_form->setDefaults($defaults);
229
-	$create_groups_form->display();
226
+    $defaults = array();
227
+    $defaults['number_of_groups'] = 1;
228
+    $create_groups_form->setDefaults($defaults);
229
+    $create_groups_form->display();
230 230
 
231
-	/*
231
+    /*
232 232
 	 * Show form to generate subgroups
233 233
 	 */
234
-	if (api_get_setting('allow_group_categories') == 'true' && count(GroupManager :: get_group_list()) > 0) {
235
-		$base_group_options = array ();
236
-		$groups = GroupManager :: get_group_list();
237
-		foreach ($groups as $index => $group) {
238
-			$number_of_students = GroupManager :: number_of_students($group['id']);
239
-			if ($number_of_students > 0) {
240
-				$base_group_options[$group['id']] = $group['name'].' ('.$number_of_students.' '.get_lang('Users').')';
241
-			}
242
-		}
243
-		if (count($base_group_options) > 0) {
244
-			$create_subgroups_form = new FormValidator('create_subgroups', 'post', api_get_self().'?'.api_get_cidreq());
234
+    if (api_get_setting('allow_group_categories') == 'true' && count(GroupManager :: get_group_list()) > 0) {
235
+        $base_group_options = array ();
236
+        $groups = GroupManager :: get_group_list();
237
+        foreach ($groups as $index => $group) {
238
+            $number_of_students = GroupManager :: number_of_students($group['id']);
239
+            if ($number_of_students > 0) {
240
+                $base_group_options[$group['id']] = $group['name'].' ('.$number_of_students.' '.get_lang('Users').')';
241
+            }
242
+        }
243
+        if (count($base_group_options) > 0) {
244
+            $create_subgroups_form = new FormValidator('create_subgroups', 'post', api_get_self().'?'.api_get_cidreq());
245 245
             $create_subgroups_form->addElement('header', get_lang('CreateSubgroups'));
246 246
             $create_subgroups_form->addElement('html', get_lang('CreateSubgroupsInfo'));
247
-			$create_subgroups_form->addElement('hidden', 'action');
248
-			$group_el = array();
249
-			$group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('CreateNumberOfGroups'));
250
-			$group_el[] = $create_subgroups_form->createElement('text', 'number_of_groups', null, array('size' => 3));
251
-			$group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('WithUsersFrom'));
252
-			$group_el[] = $create_subgroups_form->createElement('select', 'base_group', null, $base_group_options);
253
-			$group_el[] = $create_subgroups_form->createElement('button', 'submit', get_lang('Ok'));
254
-			$create_subgroups_form->addGroup($group_el, 'create_groups', null, ' ', false);
255
-			$defaults = array();
256
-			$defaults['action'] = 'create_subgroups';
257
-			$create_subgroups_form->setDefaults($defaults);
258
-			$create_subgroups_form->display();
259
-		}
260
-	}
247
+            $create_subgroups_form->addElement('hidden', 'action');
248
+            $group_el = array();
249
+            $group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('CreateNumberOfGroups'));
250
+            $group_el[] = $create_subgroups_form->createElement('text', 'number_of_groups', null, array('size' => 3));
251
+            $group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('WithUsersFrom'));
252
+            $group_el[] = $create_subgroups_form->createElement('select', 'base_group', null, $base_group_options);
253
+            $group_el[] = $create_subgroups_form->createElement('button', 'submit', get_lang('Ok'));
254
+            $create_subgroups_form->addGroup($group_el, 'create_groups', null, ' ', false);
255
+            $defaults = array();
256
+            $defaults['action'] = 'create_subgroups';
257
+            $create_subgroups_form->setDefaults($defaults);
258
+            $create_subgroups_form->display();
259
+        }
260
+    }
261 261
 
262
-	/*
262
+    /*
263 263
 	 * Show form to generate groups from classes subscribed to the course
264 264
 	 */
265 265
     $options['where'] = array(" usergroup.course_id = ? " =>  api_get_real_course_id());
266 266
     $obj = new UserGroup();
267 267
     $classes = $obj->getUserGroupInCourse($options);
268
-	if (count($classes) > 0) {
269
-		echo '<b>'.get_lang('GroupsFromClasses').'</b>';
270
-		echo '<blockquote>';
271
-		echo '<p>'.get_lang('GroupsFromClassesInfo').'</p>';
272
-		echo '<ul>';
273
-		foreach ($classes as $index => $class) {
274
-			$number_of_users = count($obj->get_users_by_usergroup($class['id']));
275
-			echo '<li>';
276
-			echo $class['name'];
277
-			echo ' ('.$number_of_users.' '.get_lang('Users').')';
278
-			echo '</li>';
279
-		}
280
-		echo '</ul>';
268
+    if (count($classes) > 0) {
269
+        echo '<b>'.get_lang('GroupsFromClasses').'</b>';
270
+        echo '<blockquote>';
271
+        echo '<p>'.get_lang('GroupsFromClassesInfo').'</p>';
272
+        echo '<ul>';
273
+        foreach ($classes as $index => $class) {
274
+            $number_of_users = count($obj->get_users_by_usergroup($class['id']));
275
+            echo '<li>';
276
+            echo $class['name'];
277
+            echo ' ('.$number_of_users.' '.get_lang('Users').')';
278
+            echo '</li>';
279
+        }
280
+        echo '</ul>';
281 281
 
282
-		$create_class_groups_form = new FormValidator('create_class_groups_form', 'post', api_get_self().'?'.api_get_cidreq());
283
-		$create_class_groups_form->addElement('hidden', 'action');
284
-		if (api_get_setting('allow_group_categories') == 'true') {
285
-			$group_categories = GroupManager :: get_categories();
286
-			$cat_options = array();
287
-			foreach ($group_categories as $index => $category) {
288
-				$cat_options[$category['id']] = $category['title'];
289
-			}
290
-			$create_class_groups_form->addElement('select', 'group_category', null, $cat_options);
291
-		} else {
292
-			$create_class_groups_form->addElement('hidden', 'group_category');
293
-		}
294
-		$create_class_groups_form->addElement('submit', 'submit', get_lang('Ok'));
295
-		$defaults['group_category'] = GroupManager::DEFAULT_GROUP_CATEGORY;
296
-		$defaults['action'] = 'create_class_groups';
297
-		$create_class_groups_form->setDefaults($defaults);
298
-		$create_class_groups_form->display();
299
-		echo '</blockquote>';
300
-	}
282
+        $create_class_groups_form = new FormValidator('create_class_groups_form', 'post', api_get_self().'?'.api_get_cidreq());
283
+        $create_class_groups_form->addElement('hidden', 'action');
284
+        if (api_get_setting('allow_group_categories') == 'true') {
285
+            $group_categories = GroupManager :: get_categories();
286
+            $cat_options = array();
287
+            foreach ($group_categories as $index => $category) {
288
+                $cat_options[$category['id']] = $category['title'];
289
+            }
290
+            $create_class_groups_form->addElement('select', 'group_category', null, $cat_options);
291
+        } else {
292
+            $create_class_groups_form->addElement('hidden', 'group_category');
293
+        }
294
+        $create_class_groups_form->addElement('submit', 'submit', get_lang('Ok'));
295
+        $defaults['group_category'] = GroupManager::DEFAULT_GROUP_CATEGORY;
296
+        $defaults['action'] = 'create_class_groups';
297
+        $create_class_groups_form->setDefaults($defaults);
298
+        $create_class_groups_form->display();
299
+        echo '</blockquote>';
300
+    }
301 301
 }
302 302
 
303 303
 Display :: display_footer();
Please login to merge, or discard this patch.
main/session/index.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
                             if ($exercise_info->start_time != '0000-00-00 00:00:00') {
283 283
                                 $allowed_time = api_strtotime($exercise_info->start_time, 'UTC');
284 284
                                 if ($now < $allowed_time) {
285
-                                      continue;
285
+                                        continue;
286 286
                                 }
287 287
                             }
288 288
                             $exercise_info->exercise = Display::url(
@@ -512,11 +512,11 @@  discard block
 block discarded – undo
512 512
 		window.location.href=ui.tab;
513 513
     });
514 514
 <?php
515
-     //Displays js code to use a jqgrid
516
-     echo Display::grid_js('courses',       '',             $columns_courses, $column_model_courses, $extra_params_courses, $new_course_list);
517
-     echo Display::grid_js('list_default',  $url,           $columns,         $column_model,$extra_params,array(), '');
518
-     echo Display::grid_js('list_course',   $url_by_course, $columns,         $column_model,$extra_params_course,array(),'');
519
-     echo Display::grid_js('list_week',     $url_week,      $column_week,     $column_week_model, $extra_params_week,array(),'');
515
+        //Displays js code to use a jqgrid
516
+        echo Display::grid_js('courses',       '',             $columns_courses, $column_model_courses, $extra_params_courses, $new_course_list);
517
+        echo Display::grid_js('list_default',  $url,           $columns,         $column_model,$extra_params,array(), '');
518
+        echo Display::grid_js('list_course',   $url_by_course, $columns,         $column_model,$extra_params_course,array(),'');
519
+        echo Display::grid_js('list_week',     $url_week,      $column_week,     $column_week_model, $extra_params_week,array(),'');
520 520
 
521 521
     if (!api_is_anonymous()) {
522 522
         echo Display::grid_js('exercises', '', $column_exercise, $column_exercise_model, $extra_params_exercise, $my_real_array);
Please login to merge, or discard this patch.
main/inc/lib/sessionmanager.lib.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3362,7 +3362,7 @@  discard block
 block discarded – undo
3362 3362
         }
3363 3363
 
3364 3364
         if (!empty($platformCourses)) {
3365
-              foreach ($platformCourses as $course) {
3365
+                foreach ($platformCourses as $course) {
3366 3366
                 $courses[$course['real_id']] = $course;
3367 3367
             }
3368 3368
         }
@@ -6085,7 +6085,7 @@  discard block
 block discarded – undo
6085 6085
         ]);
6086 6086
     }
6087 6087
 
6088
-	/**
6088
+    /**
6089 6089
      * Get the count of user courses in session
6090 6090
      * @param int $sessionId The session id
6091 6091
      * @return array
Please login to merge, or discard this patch.
main/inc/lib/tracking.lib.php 1 patch
Indentation   +854 added lines, -854 removed lines patch added patch discarded remove patch
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
                     $extend_link = '';
315 315
                     if (!empty($inter_num)) {
316 316
                         $extend_link = Display::url(
317
-                              Display::return_icon('visible.gif', get_lang('HideAttemptView')),
318
-                              api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
317
+                                Display::return_icon('visible.gif', get_lang('HideAttemptView')),
318
+                                api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
319 319
                         );
320 320
                     }
321 321
                     $title = $row['mytitle'];
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
                 $newDate = new DateTime('-30 days', new DateTimeZone('UTC'));
1367 1367
                 $condition_time = " AND (login_date >= '{$newDate->format('Y-m-d H:i:s')}'";
1368 1368
                 $condition_time .= "AND logout_date <= '{$today->format('Y-m-d H:i:s')}') ";
1369
-               break;
1369
+                break;
1370 1370
             case 'custom':
1371 1371
                 if (!empty($start_date) && !empty($end_date)) {
1372 1372
                     $start_date = Database::escape_string($start_date);
@@ -1376,10 +1376,10 @@  discard block
 block discarded – undo
1376 1376
                 break;
1377 1377
         }
1378 1378
 
1379
-    	$sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1379
+        $sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1380 1380
     	        FROM '.$tbl_track_login.'
1381 1381
                 WHERE '.$userCondition.$condition_time;
1382
-    	$rs = Database::query($sql);
1382
+        $rs = Database::query($sql);
1383 1383
         $row = Database::fetch_array($rs, 'ASSOC');
1384 1384
         $diff = $row['diff'];
1385 1385
 
@@ -1401,18 +1401,18 @@  discard block
 block discarded – undo
1401 1401
     public static function get_time_spent_on_the_course($user_id, $courseId, $session_id = 0)
1402 1402
     {
1403 1403
         $courseId = intval($courseId);
1404
-    	$session_id  = intval($session_id);
1405
-
1406
-    	$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1407
-    	if (is_array($user_id)) {
1408
-    	    $user_id = array_map('intval', $user_id);
1409
-    		$condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1410
-    	} else {
1411
-    		$user_id = intval($user_id);
1412
-    		$condition_user = " AND user_id = $user_id ";
1413
-    	}
1414
-
1415
-    	$sql = "SELECT
1404
+        $session_id  = intval($session_id);
1405
+
1406
+        $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1407
+        if (is_array($user_id)) {
1408
+            $user_id = array_map('intval', $user_id);
1409
+            $condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1410
+        } else {
1411
+            $user_id = intval($user_id);
1412
+            $condition_user = " AND user_id = $user_id ";
1413
+        }
1414
+
1415
+        $sql = "SELECT
1416 1416
     	        SUM(UNIX_TIMESTAMP(logout_course_date) - UNIX_TIMESTAMP(login_course_date)) as nb_seconds
1417 1417
                 FROM $tbl_track_course
1418 1418
                 WHERE UNIX_TIMESTAMP(logout_course_date) > UNIX_TIMESTAMP(login_course_date) ";
@@ -1427,9 +1427,9 @@  discard block
 block discarded – undo
1427 1427
 
1428 1428
         $sql .= $condition_user;
1429 1429
         $rs = Database::query($sql);
1430
-    	$row = Database::fetch_array($rs);
1430
+        $row = Database::fetch_array($rs);
1431 1431
 
1432
-    	return $row['nb_seconds'];
1432
+        return $row['nb_seconds'];
1433 1433
     }
1434 1434
 
1435 1435
     /**
@@ -1440,25 +1440,25 @@  discard block
 block discarded – undo
1440 1440
      */
1441 1441
     public static function get_first_connection_date($student_id)
1442 1442
     {
1443
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1444
-    	$sql = 'SELECT login_date
1443
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1444
+        $sql = 'SELECT login_date
1445 1445
     	        FROM ' . $tbl_track_login . '
1446 1446
                 WHERE login_user_id = ' . intval($student_id) . '
1447 1447
                 ORDER BY login_date ASC
1448 1448
                 LIMIT 0,1';
1449 1449
 
1450
-    	$rs = Database::query($sql);
1451
-    	if (Database::num_rows($rs)>0) {
1452
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1450
+        $rs = Database::query($sql);
1451
+        if (Database::num_rows($rs)>0) {
1452
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1453 1453
                 return api_convert_and_format_date(
1454 1454
                     $first_login_date,
1455 1455
                     DATE_FORMAT_SHORT,
1456 1456
                     date_default_timezone_get()
1457 1457
                 );
1458
-    		}
1459
-    	}
1458
+            }
1459
+        }
1460 1460
 
1461
-    	return false;
1461
+        return false;
1462 1462
     }
1463 1463
 
1464 1464
     /**
@@ -1471,38 +1471,38 @@  discard block
 block discarded – undo
1471 1471
      */
1472 1472
     public static function get_last_connection_date($student_id, $warning_message = false, $return_timestamp = false)
1473 1473
     {
1474
-    	$table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1475
-    	$sql = 'SELECT login_date
1474
+        $table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1475
+        $sql = 'SELECT login_date
1476 1476
     	        FROM ' . $table . '
1477 1477
                 WHERE login_user_id = ' . intval($student_id) . '
1478 1478
                 ORDER BY login_date
1479 1479
                 DESC LIMIT 0,1';
1480 1480
 
1481
-    	$rs = Database::query($sql);
1482
-    	if (Database::num_rows($rs) > 0) {
1483
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1484
-    			$last_login_date = api_get_local_time($last_login_date);
1485
-    			if ($return_timestamp) {
1486
-    				return api_strtotime($last_login_date,'UTC');
1487
-    			} else {
1488
-    				if (!$warning_message) {
1489
-    					return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1490
-    				} else {
1491
-    					$timestamp = api_strtotime($last_login_date,'UTC');
1492
-    					$currentTimestamp = time();
1493
-
1494
-    					//If the last connection is > than 7 days, the text is red
1495
-    					//345600 = 7 days in seconds
1496
-    					if ($currentTimestamp - $timestamp > 604800) {
1497
-    						return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1498
-    					} else {
1499
-    						return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1500
-    					}
1501
-    				}
1502
-    			}
1503
-    		}
1504
-    	}
1505
-    	return false;
1481
+        $rs = Database::query($sql);
1482
+        if (Database::num_rows($rs) > 0) {
1483
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1484
+                $last_login_date = api_get_local_time($last_login_date);
1485
+                if ($return_timestamp) {
1486
+                    return api_strtotime($last_login_date,'UTC');
1487
+                } else {
1488
+                    if (!$warning_message) {
1489
+                        return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1490
+                    } else {
1491
+                        $timestamp = api_strtotime($last_login_date,'UTC');
1492
+                        $currentTimestamp = time();
1493
+
1494
+                        //If the last connection is > than 7 days, the text is red
1495
+                        //345600 = 7 days in seconds
1496
+                        if ($currentTimestamp - $timestamp > 604800) {
1497
+                            return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1498
+                        } else {
1499
+                            return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1500
+                        }
1501
+                    }
1502
+                }
1503
+            }
1504
+        }
1505
+        return false;
1506 1506
     }
1507 1507
 
1508 1508
     /**
@@ -1556,30 +1556,30 @@  discard block
 block discarded – undo
1556 1556
         $session_id = 0,
1557 1557
         $convert_date = true
1558 1558
     ) {
1559
-    	$student_id  = intval($student_id);
1559
+        $student_id  = intval($student_id);
1560 1560
         $courseId = intval($courseId);
1561
-    	$session_id  = intval($session_id);
1561
+        $session_id  = intval($session_id);
1562 1562
 
1563
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1564
-    	$sql = 'SELECT login_course_date
1563
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1564
+        $sql = 'SELECT login_course_date
1565 1565
     	        FROM '.$tbl_track_login.'
1566 1566
                 WHERE
1567 1567
                     user_id = '.$student_id.' AND
1568 1568
                     c_id = '.$courseId.' AND
1569 1569
                     session_id = '.$session_id.'
1570 1570
                 ORDER BY login_course_date ASC LIMIT 0,1';
1571
-    	$rs = Database::query($sql);
1572
-    	if (Database::num_rows($rs) > 0) {
1573
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1574
-    			if ($convert_date) {
1575
-    				return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1576
-    			} else {
1577
-    				return $first_login_date;
1578
-    			}
1579
-    		}
1580
-    	}
1581
-
1582
-    	return false;
1571
+        $rs = Database::query($sql);
1572
+        if (Database::num_rows($rs) > 0) {
1573
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1574
+                if ($convert_date) {
1575
+                    return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1576
+                } else {
1577
+                    return $first_login_date;
1578
+                }
1579
+            }
1580
+        }
1581
+
1582
+        return false;
1583 1583
     }
1584 1584
 
1585 1585
     /**
@@ -1595,13 +1595,13 @@  discard block
 block discarded – undo
1595 1595
         $session_id = 0,
1596 1596
         $convert_date = true
1597 1597
     ) {
1598
-    	// protect data
1599
-    	$student_id  = intval($student_id);
1598
+        // protect data
1599
+        $student_id  = intval($student_id);
1600 1600
         $courseId = $courseInfo['real_id'];
1601
-    	$session_id  = intval($session_id);
1601
+        $session_id  = intval($session_id);
1602 1602
 
1603
-    	$tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1604
-    	$sql = 'SELECT access_date
1603
+        $tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1604
+        $sql = 'SELECT access_date
1605 1605
                 FROM '.$tbl_track_e_access.'
1606 1606
                 WHERE   access_user_id = '.$student_id.' AND
1607 1607
                         c_id = "'.$courseId.'" AND
@@ -1609,39 +1609,39 @@  discard block
 block discarded – undo
1609 1609
                 ORDER BY access_date DESC
1610 1610
                 LIMIT 0,1';
1611 1611
 
1612
-    	$rs = Database::query($sql);
1613
-    	if (Database::num_rows($rs) > 0) {
1614
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1612
+        $rs = Database::query($sql);
1613
+        if (Database::num_rows($rs) > 0) {
1614
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1615 1615
                 if (empty($last_login_date) || $last_login_date == '0000-00-00 00:00:00') {
1616 1616
                     return false;
1617 1617
                 }
1618 1618
                 //see #5736
1619 1619
                 $last_login_date_timestamp = api_strtotime($last_login_date);
1620
-    			$now = time();
1621
-    			//If the last connection is > than 7 days, the text is red
1622
-    			//345600 = 7 days in seconds
1623
-    			if ($now - $last_login_date_timestamp > 604800) {
1624
-    				if ($convert_date) {
1620
+                $now = time();
1621
+                //If the last connection is > than 7 days, the text is red
1622
+                //345600 = 7 days in seconds
1623
+                if ($now - $last_login_date_timestamp > 604800) {
1624
+                    if ($convert_date) {
1625 1625
                         $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1626 1626
                         $icon = api_is_allowed_to_edit() ?
1627 1627
                             '<a href="'.api_get_path(WEB_CODE_PATH).'announcements/announcements.php?action=add&remind_inactive='.$student_id.'&cidReq='.$courseInfo['code'].'" title="'.get_lang('RemindInactiveUser').'">
1628 1628
                               '.Display::return_icon('messagebox_warning.gif').'
1629 1629
                              </a>'
1630 1630
                             : null;
1631
-    					return $icon. Display::label($last_login_date, 'warning');
1632
-    				} else {
1633
-    					return $last_login_date;
1634
-    				}
1635
-    			} else {
1636
-    				if ($convert_date) {
1637
-    					return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1638
-    				} else {
1639
-    					return $last_login_date;
1640
-    				}
1641
-    			}
1642
-    		}
1643
-    	}
1644
-    	return false;
1631
+                        return $icon. Display::label($last_login_date, 'warning');
1632
+                    } else {
1633
+                        return $last_login_date;
1634
+                    }
1635
+                } else {
1636
+                    if ($convert_date) {
1637
+                        return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1638
+                    } else {
1639
+                        return $last_login_date;
1640
+                    }
1641
+                }
1642
+            }
1643
+        }
1644
+        return false;
1645 1645
     }
1646 1646
 
1647 1647
     /**
@@ -1655,11 +1655,11 @@  discard block
 block discarded – undo
1655 1655
     public static function get_course_connections_count($courseId, $session_id = 0, $start = 0, $stop = null)
1656 1656
     {
1657 1657
         if ($start < 0) {
1658
-    		$start = 0;
1659
-    	}
1660
-    	if (!isset($stop) or ($stop < 0)) {
1661
-    		$stop = api_get_utc_datetime();
1662
-    	}
1658
+            $start = 0;
1659
+        }
1660
+        if (!isset($stop) or ($stop < 0)) {
1661
+            $stop = api_get_utc_datetime();
1662
+        }
1663 1663
 
1664 1664
         // Given we're storing in cache, round the start and end times
1665 1665
         // to the lower minute
@@ -1668,11 +1668,11 @@  discard block
 block discarded – undo
1668 1668
         $roundedStart = Database::escape_string($roundedStart);
1669 1669
         $roundedStop = Database::escape_string($roundedStop);
1670 1670
 
1671
-    	$month_filter = " AND login_course_date > '$roundedStart' AND login_course_date < '$roundedStop' ";
1671
+        $month_filter = " AND login_course_date > '$roundedStart' AND login_course_date < '$roundedStop' ";
1672 1672
 
1673 1673
         $courseId = intval($courseId);
1674
-    	$session_id  = intval($session_id);
1675
-    	$count = 0;
1674
+        $session_id  = intval($session_id);
1675
+        $count = 0;
1676 1676
         $tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1677 1677
         $sql =  "SELECT count(*) as count_connections
1678 1678
                 FROM $tbl_track_e_course_access
@@ -1711,7 +1711,7 @@  discard block
 block discarded – undo
1711 1711
             }
1712 1712
         }
1713 1713
 
1714
-    	return $count;
1714
+        return $count;
1715 1715
     }
1716 1716
 
1717 1717
     /**
@@ -1722,25 +1722,25 @@  discard block
 block discarded – undo
1722 1722
      */
1723 1723
     public static function count_course_per_student($user_id, $include_sessions = true)
1724 1724
     {
1725
-    	$user_id = intval($user_id);
1726
-    	$tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1727
-    	$tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1725
+        $user_id = intval($user_id);
1726
+        $tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1727
+        $tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1728 1728
 
1729
-    	$sql = 'SELECT DISTINCT c_id
1729
+        $sql = 'SELECT DISTINCT c_id
1730 1730
                 FROM ' . $tbl_course_rel_user . '
1731 1731
                 WHERE user_id = ' . $user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH;
1732
-    	$rs = Database::query($sql);
1733
-    	$nb_courses = Database::num_rows($rs);
1732
+        $rs = Database::query($sql);
1733
+        $nb_courses = Database::num_rows($rs);
1734 1734
 
1735
-    	if ($include_sessions) {
1736
-    		$sql = 'SELECT DISTINCT c_id
1735
+        if ($include_sessions) {
1736
+            $sql = 'SELECT DISTINCT c_id
1737 1737
                     FROM ' . $tbl_session_course_rel_user . '
1738 1738
                     WHERE user_id = ' . $user_id;
1739
-    		$rs = Database::query($sql);
1740
-    		$nb_courses += Database::num_rows($rs);
1741
-    	}
1739
+            $rs = Database::query($sql);
1740
+            $nb_courses += Database::num_rows($rs);
1741
+        }
1742 1742
 
1743
-    	return $nb_courses;
1743
+        return $nb_courses;
1744 1744
     }
1745 1745
 
1746 1746
     /**
@@ -1771,25 +1771,25 @@  discard block
 block discarded – undo
1771 1771
         $into_lp = 0
1772 1772
     ) {
1773 1773
         $course_code = Database::escape_string($course_code);
1774
-    	$course_info = api_get_course_info($course_code);
1775
-    	if (!empty($course_info)) {
1776
-    		// table definition
1777
-    		$tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1778
-    		$tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1779
-
1780
-    		// Compose a filter based on optional exercise given
1781
-    		$condition_quiz = "";
1782
-    		if (!empty($exercise_id)) {
1783
-    			$exercise_id = intval($exercise_id);
1784
-    			$condition_quiz =" AND id = $exercise_id ";
1785
-    		}
1786
-
1787
-    		// Compose a filter based on optional session id given
1788
-    		$condition_session = "";
1789
-    		if (isset($session_id)) {
1790
-    			$session_id = intval($session_id);
1791
-    			$condition_session = " AND session_id = $session_id ";
1792
-    		}
1774
+        $course_info = api_get_course_info($course_code);
1775
+        if (!empty($course_info)) {
1776
+            // table definition
1777
+            $tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1778
+            $tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1779
+
1780
+            // Compose a filter based on optional exercise given
1781
+            $condition_quiz = "";
1782
+            if (!empty($exercise_id)) {
1783
+                $exercise_id = intval($exercise_id);
1784
+                $condition_quiz =" AND id = $exercise_id ";
1785
+            }
1786
+
1787
+            // Compose a filter based on optional session id given
1788
+            $condition_session = "";
1789
+            if (isset($session_id)) {
1790
+                $session_id = intval($session_id);
1791
+                $condition_session = " AND session_id = $session_id ";
1792
+            }
1793 1793
             if ($active_filter == 1) {
1794 1794
                 $condition_active = 'AND active <> -1';
1795 1795
             } elseif ($active_filter == 0) {
@@ -1805,25 +1805,25 @@  discard block
 block discarded – undo
1805 1805
                 $select_lp_id = ', orig_lp_id as lp_id ';
1806 1806
             }
1807 1807
 
1808
-    		$sql = "SELECT count(id) FROM $tbl_course_quiz
1808
+            $sql = "SELECT count(id) FROM $tbl_course_quiz
1809 1809
     				WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz ";
1810
-    		$count_quiz = Database::fetch_row(Database::query($sql));
1810
+            $count_quiz = Database::fetch_row(Database::query($sql));
1811 1811
 
1812
-    		if (!empty($count_quiz[0]) && !empty($student_id)) {
1813
-    			if (is_array($student_id)) {
1812
+            if (!empty($count_quiz[0]) && !empty($student_id)) {
1813
+                if (is_array($student_id)) {
1814 1814
                     $student_id = array_map('intval', $student_id);
1815
-    				$condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1816
-    			} else {
1815
+                    $condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1816
+                } else {
1817 1817
                     $student_id = intval($student_id);
1818
-    				$condition_user = " AND exe_user_id = '$student_id' ";
1819
-    			}
1818
+                    $condition_user = " AND exe_user_id = '$student_id' ";
1819
+                }
1820 1820
 
1821
-    			if (empty($exercise_id)) {
1822
-    				$sql = "SELECT id FROM $tbl_course_quiz
1821
+                if (empty($exercise_id)) {
1822
+                    $sql = "SELECT id FROM $tbl_course_quiz
1823 1823
     						WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz";
1824 1824
                     $result = Database::query($sql);
1825 1825
                     $exercise_list = array();
1826
-    				$exercise_id = null;
1826
+                    $exercise_id = null;
1827 1827
                     if (Database::num_rows($result)) {
1828 1828
                         while ($row = Database::fetch_array($result)) {
1829 1829
                             $exercise_list[] = $row['id'];
@@ -1832,11 +1832,11 @@  discard block
 block discarded – undo
1832 1832
                     if (!empty($exercise_list)) {
1833 1833
                         $exercise_id = implode("','",$exercise_list);
1834 1834
                     }
1835
-    			}
1835
+                }
1836 1836
 
1837
-    			$count_quiz = Database::fetch_row(Database::query($sql));
1837
+                $count_quiz = Database::fetch_row(Database::query($sql));
1838 1838
 
1839
-    			$sql = "SELECT
1839
+                $sql = "SELECT
1840 1840
     			        SUM(exe_result/exe_weighting*100) as avg_score,
1841 1841
     			        COUNT(*) as num_attempts
1842 1842
     			        $select_lp_id
@@ -1850,20 +1850,20 @@  discard block
 block discarded – undo
1850 1850
                             $condition_into_lp
1851 1851
                         ORDER BY exe_date DESC";
1852 1852
 
1853
-    			$res = Database::query($sql);
1854
-    			$row = Database::fetch_array($res);
1855
-    			$quiz_avg_score = null;
1853
+                $res = Database::query($sql);
1854
+                $row = Database::fetch_array($res);
1855
+                $quiz_avg_score = null;
1856 1856
 
1857
-    			if (!empty($row['avg_score'])) {
1858
-    				$quiz_avg_score = round($row['avg_score'],2);
1859
-    			}
1857
+                if (!empty($row['avg_score'])) {
1858
+                    $quiz_avg_score = round($row['avg_score'],2);
1859
+                }
1860 1860
 
1861
-    			if(!empty($row['num_attempts'])) {
1862
-    				$quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1863
-    			}
1864
-    			if (is_array($student_id)) {
1865
-    				$quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1866
-    			}
1861
+                if(!empty($row['num_attempts'])) {
1862
+                    $quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1863
+                }
1864
+                if (is_array($student_id)) {
1865
+                    $quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1866
+                }
1867 1867
                 if ($into_lp == 0) {
1868 1868
                     return $quiz_avg_score;
1869 1869
                 } else {
@@ -1886,9 +1886,9 @@  discard block
 block discarded – undo
1886 1886
                         return array($quiz_avg_score, null);
1887 1887
                     }
1888 1888
                 }
1889
-    		}
1890
-    	}
1891
-    	return null;
1889
+            }
1890
+        }
1891
+        return null;
1892 1892
     }
1893 1893
 
1894 1894
     /**
@@ -1921,15 +1921,15 @@  discard block
 block discarded – undo
1921 1921
         $find_all_lp = 0
1922 1922
     ) {
1923 1923
         $courseId = intval($courseId);
1924
-    	$student_id  = intval($student_id);
1925
-    	$exercise_id = intval($exercise_id);
1926
-    	$session_id  = intval($session_id);
1924
+        $student_id  = intval($student_id);
1925
+        $exercise_id = intval($exercise_id);
1926
+        $session_id  = intval($session_id);
1927 1927
 
1928
-    	$lp_id = intval($lp_id);
1928
+        $lp_id = intval($lp_id);
1929 1929
         $lp_item_id = intval($lp_item_id);
1930
-    	$tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1930
+        $tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1931 1931
 
1932
-    	$sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1932
+        $sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1933 1933
                 WHERE  ex.c_id = $courseId
1934 1934
                 AND ex.exe_exo_id = $exercise_id
1935 1935
                 AND status = ''
@@ -1944,11 +1944,11 @@  discard block
 block discarded – undo
1944 1944
                 AND orig_lp_item_id = $lp_item_id";
1945 1945
         }
1946 1946
 
1947
-    	$rs = Database::query($sql);
1948
-    	$row = Database::fetch_row($rs);
1949
-    	$count_attempts = $row[0];
1947
+        $rs = Database::query($sql);
1948
+        $row = Database::fetch_row($rs);
1949
+        $count_attempts = $row[0];
1950 1950
 
1951
-    	return $count_attempts;
1951
+        return $count_attempts;
1952 1952
     }
1953 1953
 
1954 1954
     /**
@@ -1958,7 +1958,7 @@  discard block
 block discarded – undo
1958 1958
      * @param int    $user_id
1959 1959
      * @param int    $courseId
1960 1960
      * @param int    $session_id
1961
-    */
1961
+     */
1962 1962
     public static function get_exercise_student_progress($exercise_list, $user_id, $courseId, $session_id)
1963 1963
     {
1964 1964
         $courseId = intval($courseId);
@@ -3622,8 +3622,8 @@  discard block
 block discarded – undo
3622 3622
 
3623 3623
         $condition_session = '';
3624 3624
         if (isset($session_id)) {
3625
-             $session_id = intval($session_id);
3626
-             $condition_session = ' AND f.session_id = '. $session_id;
3625
+                $session_id = intval($session_id);
3626
+                $condition_session = ' AND f.session_id = '. $session_id;
3627 3627
         }
3628 3628
 
3629 3629
         $groupId = intval($groupId);
@@ -5522,9 +5522,9 @@  discard block
 block discarded – undo
5522 5522
     }
5523 5523
 
5524 5524
     /**
5525
-    * @param FormValidator $form
5526
-    * @return mixed
5527
-    */
5525
+     * @param FormValidator $form
5526
+     * @return mixed
5527
+     */
5528 5528
     public static function setUserSearchForm($form)
5529 5529
     {
5530 5530
         global $_configuration;
@@ -5838,26 +5838,26 @@  discard block
 block discarded – undo
5838 5838
         $session_id = api_get_session_id();
5839 5839
         $course_id = api_get_course_int_id();
5840 5840
 
5841
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5842
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
5841
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5842
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
5843 5843
 
5844
-    	$sql = "SELECT count(tool) AS total_number_of_items
5844
+        $sql = "SELECT count(tool) AS total_number_of_items
5845 5845
     	        FROM $table_item_property track_resource, $table_user user
5846 5846
     	        WHERE
5847 5847
                     track_resource.c_id = $course_id AND
5848 5848
                     track_resource.insert_user_id = user.user_id AND
5849 5849
                     session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5850 5850
 
5851
-    	if (isset($_GET['keyword'])) {
5852
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
5853
-    		$sql .= " AND (
5851
+        if (isset($_GET['keyword'])) {
5852
+            $keyword = Database::escape_string(trim($_GET['keyword']));
5853
+            $sql .= " AND (
5854 5854
     		            user.username LIKE '%".$keyword."%' OR
5855 5855
     		            lastedit_type LIKE '%".$keyword."%' OR
5856 5856
     		            tool LIKE '%".$keyword."%'
5857 5857
                     )";
5858
-    	}
5858
+        }
5859 5859
 
5860
-    	$sql .= " AND tool IN (
5860
+        $sql .= " AND tool IN (
5861 5861
     	            'document',
5862 5862
     	            'learnpath',
5863 5863
     	            'quiz',
@@ -5869,10 +5869,10 @@  discard block
 block discarded – undo
5869 5869
     	            'thematic_advance',
5870 5870
     	            'thematic_plan'
5871 5871
                 )";
5872
-    	$res = Database::query($sql);
5873
-    	$obj = Database::fetch_object($res);
5872
+        $res = Database::query($sql);
5873
+        $obj = Database::fetch_object($res);
5874 5874
 
5875
-    	return $obj->total_number_of_items;
5875
+        return $obj->total_number_of_items;
5876 5876
     }
5877 5877
 
5878 5878
     /**
@@ -5887,12 +5887,12 @@  discard block
 block discarded – undo
5887 5887
         $session_id = api_get_session_id();
5888 5888
         $course_id = api_get_course_int_id();
5889 5889
 
5890
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5891
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
5892
-    	$table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
5893
-    	$session_id = intval($session_id);
5890
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5891
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
5892
+        $table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
5893
+        $session_id = intval($session_id);
5894 5894
 
5895
-    	$sql = "SELECT
5895
+        $sql = "SELECT
5896 5896
                     tool as col0,
5897 5897
                     lastedit_type as col1,
5898 5898
                     ref as ref,
@@ -5906,16 +5906,16 @@  discard block
 block discarded – undo
5906 5906
                   track_resource.insert_user_id = user.user_id AND
5907 5907
                   session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5908 5908
 
5909
-    	if (isset($_GET['keyword'])) {
5910
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
5911
-    		$sql .= " AND (
5909
+        if (isset($_GET['keyword'])) {
5910
+            $keyword = Database::escape_string(trim($_GET['keyword']));
5911
+            $sql .= " AND (
5912 5912
     		            user.username LIKE '%".$keyword."%' OR
5913 5913
     		            lastedit_type LIKE '%".$keyword."%' OR
5914 5914
     		            tool LIKE '%".$keyword."%'
5915 5915
                      ) ";
5916
-    	}
5916
+        }
5917 5917
 
5918
-    	$sql .= " AND tool IN (
5918
+        $sql .= " AND tool IN (
5919 5919
     	            'document',
5920 5920
     	            'learnpath',
5921 5921
     	            'quiz',
@@ -5928,41 +5928,41 @@  discard block
 block discarded – undo
5928 5928
     	            'thematic_plan'
5929 5929
                 )";
5930 5930
 
5931
-    	if ($column == 0) {
5932
-    		$column = '0';
5933
-    	}
5934
-    	if ($column != '' && $direction != '') {
5935
-    		if ($column != 2 && $column != 4) {
5936
-    			$sql .= " ORDER BY col$column $direction";
5937
-    		}
5938
-    	} else {
5939
-    		$sql .= " ORDER BY col5 DESC ";
5940
-    	}
5931
+        if ($column == 0) {
5932
+            $column = '0';
5933
+        }
5934
+        if ($column != '' && $direction != '') {
5935
+            if ($column != 2 && $column != 4) {
5936
+                $sql .= " ORDER BY col$column $direction";
5937
+            }
5938
+        } else {
5939
+            $sql .= " ORDER BY col5 DESC ";
5940
+        }
5941 5941
 
5942 5942
         $from = intval($from);
5943 5943
         $number_of_items = intval($number_of_items);
5944 5944
 
5945
-    	$sql .= " LIMIT $from, $number_of_items ";
5946
-
5947
-    	$res = Database::query($sql);
5948
-    	$resources = array();
5949
-    	$thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
5950
-    	while ($row = Database::fetch_array($res)) {
5951
-    		$ref = $row['ref'];
5952
-    		$table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
5953
-    		$table_tool = Database :: get_course_table($table_name['table_name']);
5945
+        $sql .= " LIMIT $from, $number_of_items ";
5954 5946
 
5955
-    		$id = $table_name['id_tool'];
5956
-    		$recorset = false;
5957
-
5958
-    		if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
5959
-    			$tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
5960
-    			$sql = "SELECT thematic_id FROM $table_tool
5947
+        $res = Database::query($sql);
5948
+        $resources = array();
5949
+        $thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
5950
+        while ($row = Database::fetch_array($res)) {
5951
+            $ref = $row['ref'];
5952
+            $table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
5953
+            $table_tool = Database :: get_course_table($table_name['table_name']);
5954
+
5955
+            $id = $table_name['id_tool'];
5956
+            $recorset = false;
5957
+
5958
+            if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
5959
+                $tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
5960
+                $sql = "SELECT thematic_id FROM $table_tool
5961 5961
     			        WHERE c_id = $course_id AND id = $ref";
5962
-    			$rs_thematic  = Database::query($sql);
5963
-    			if (Database::num_rows($rs_thematic)) {
5964
-    				$row_thematic = Database::fetch_array($rs_thematic);
5965
-    				$thematic_id = $row_thematic['thematic_id'];
5962
+                $rs_thematic  = Database::query($sql);
5963
+                if (Database::num_rows($rs_thematic)) {
5964
+                    $row_thematic = Database::fetch_array($rs_thematic);
5965
+                    $thematic_id = $row_thematic['thematic_id'];
5966 5966
 
5967 5967
                     $sql = "SELECT session.id, session.name, user.username
5968 5968
                             FROM $tbl_thematic t, $table_session session, $table_user user
@@ -5971,9 +5971,9 @@  discard block
 block discarded – undo
5971 5971
                               t.session_id = session.id AND
5972 5972
                               session.id_coach = user.user_id AND
5973 5973
                               t.id = $thematic_id";
5974
-    				$recorset = Database::query($sql);
5975
-    			}
5976
-    		} else {
5974
+                    $recorset = Database::query($sql);
5975
+                }
5976
+            } else {
5977 5977
                 $sql = "SELECT session.id, session.name, user.username
5978 5978
                           FROM $table_tool tool, $table_session session, $table_user user
5979 5979
     			          WHERE
@@ -5981,127 +5981,127 @@  discard block
 block discarded – undo
5981 5981
     			              tool.session_id = session.id AND
5982 5982
     			              session.id_coach = user.user_id AND
5983 5983
     			              tool.$id = $ref";
5984
-    			$recorset = Database::query($sql);
5985
-    		}
5986
-
5987
-    		if (!empty($recorset)) {
5988
-    			$obj = Database::fetch_object($recorset);
5989
-
5990
-    			$name_session = '';
5991
-    			$coach_name = '';
5992
-    			if (!empty($obj)) {
5993
-    				$name_session = $obj->name;
5994
-    				$coach_name   = $obj->username;
5995
-    			}
5996
-
5997
-    			$url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
5998
-    			$row[0] = '';
5999
-    			if ($row['col6'] != 2) {
6000
-    				if (in_array($row['col0'], $thematic_tools)) {
6001
-
6002
-    					$exp_thematic_tool = explode('_', $row['col0']);
6003
-    					$thematic_tool_title = '';
6004
-    					if (is_array($exp_thematic_tool)) {
6005
-    						foreach ($exp_thematic_tool as $exp) {
6006
-    							$thematic_tool_title .= api_ucfirst($exp);
6007
-    						}
6008
-    					} else {
6009
-    						$thematic_tool_title = api_ucfirst($row['col0']);
6010
-    					}
6011
-
6012
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
6013
-    				} else {
6014
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
6015
-    				}
6016
-    			} else {
6017
-    				$row[0] = api_ucfirst($row['col0']);
6018
-    			}
6019
-    			$row[1] = get_lang($row[1]);
6020
-    			$row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
6021
-    			$row[5] = '';
6022
-    			//@todo Improve this code please
6023
-    			switch ($table_name['table_name']) {
6024
-    				case 'document' :
6025
-    					$sql = "SELECT tool.title as title FROM $table_tool tool
5984
+                $recorset = Database::query($sql);
5985
+            }
5986
+
5987
+            if (!empty($recorset)) {
5988
+                $obj = Database::fetch_object($recorset);
5989
+
5990
+                $name_session = '';
5991
+                $coach_name = '';
5992
+                if (!empty($obj)) {
5993
+                    $name_session = $obj->name;
5994
+                    $coach_name   = $obj->username;
5995
+                }
5996
+
5997
+                $url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
5998
+                $row[0] = '';
5999
+                if ($row['col6'] != 2) {
6000
+                    if (in_array($row['col0'], $thematic_tools)) {
6001
+
6002
+                        $exp_thematic_tool = explode('_', $row['col0']);
6003
+                        $thematic_tool_title = '';
6004
+                        if (is_array($exp_thematic_tool)) {
6005
+                            foreach ($exp_thematic_tool as $exp) {
6006
+                                $thematic_tool_title .= api_ucfirst($exp);
6007
+                            }
6008
+                        } else {
6009
+                            $thematic_tool_title = api_ucfirst($row['col0']);
6010
+                        }
6011
+
6012
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
6013
+                    } else {
6014
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
6015
+                    }
6016
+                } else {
6017
+                    $row[0] = api_ucfirst($row['col0']);
6018
+                }
6019
+                $row[1] = get_lang($row[1]);
6020
+                $row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
6021
+                $row[5] = '';
6022
+                //@todo Improve this code please
6023
+                switch ($table_name['table_name']) {
6024
+                    case 'document' :
6025
+                        $sql = "SELECT tool.title as title FROM $table_tool tool
6026 6026
                                 WHERE c_id = $course_id AND id = $ref";
6027
-    					$rs_document = Database::query($sql);
6028
-    					$obj_document = Database::fetch_object($rs_document);
6029
-    					$row[5] = $obj_document->title;
6027
+                        $rs_document = Database::query($sql);
6028
+                        $obj_document = Database::fetch_object($rs_document);
6029
+                        $row[5] = $obj_document->title;
6030 6030
 
6031
-    					break;
6032
-    				case 'announcement':
6031
+                        break;
6032
+                    case 'announcement':
6033 6033
                         $sql = "SELECT title FROM $table_tool
6034 6034
                                 WHERE c_id = $course_id AND id = $ref";
6035
-    					$rs_document = Database::query($sql);
6036
-    					$obj_document = Database::fetch_object($rs_document);
6035
+                        $rs_document = Database::query($sql);
6036
+                        $obj_document = Database::fetch_object($rs_document);
6037 6037
                         if ($obj_document) {
6038 6038
                             $row[5] = $obj_document->title;
6039 6039
                         }
6040
-    					break;
6041
-    				case 'glossary':
6040
+                        break;
6041
+                    case 'glossary':
6042 6042
                         $sql = "SELECT name FROM $table_tool
6043 6043
     					        WHERE c_id = $course_id AND glossary_id = $ref";
6044
-    					$rs_document = Database::query($sql);
6045
-    					$obj_document = Database::fetch_object($rs_document);
6044
+                        $rs_document = Database::query($sql);
6045
+                        $obj_document = Database::fetch_object($rs_document);
6046 6046
                         if ($obj_document) {
6047 6047
                             $row[5] = $obj_document->name;
6048 6048
                         }
6049
-    					break;
6050
-    				case 'lp':
6049
+                        break;
6050
+                    case 'lp':
6051 6051
                         $sql = "SELECT name
6052 6052
                                 FROM $table_tool WHERE c_id = $course_id AND id = $ref";
6053
-    					$rs_document = Database::query($sql);
6054
-    					$obj_document = Database::fetch_object($rs_document);
6055
-    					$row[5] = $obj_document->name;
6056
-    					break;
6057
-    				case 'quiz':
6053
+                        $rs_document = Database::query($sql);
6054
+                        $obj_document = Database::fetch_object($rs_document);
6055
+                        $row[5] = $obj_document->name;
6056
+                        break;
6057
+                    case 'quiz':
6058 6058
                         $sql = "SELECT title FROM $table_tool
6059 6059
                                 WHERE c_id = $course_id AND id = $ref";
6060
-    					$rs_document = Database::query($sql);
6061
-    					$obj_document = Database::fetch_object($rs_document);
6060
+                        $rs_document = Database::query($sql);
6061
+                        $obj_document = Database::fetch_object($rs_document);
6062 6062
                         if ($obj_document) {
6063 6063
                             $row[5] = $obj_document->title;
6064 6064
                         }
6065
-    					break;
6066
-    				case 'course_description':
6065
+                        break;
6066
+                    case 'course_description':
6067 6067
                         $sql = "SELECT title FROM $table_tool
6068 6068
                                 WHERE c_id = $course_id AND id = $ref";
6069
-    					$rs_document = Database::query($sql);
6070
-    					$obj_document = Database::fetch_object($rs_document);
6069
+                        $rs_document = Database::query($sql);
6070
+                        $obj_document = Database::fetch_object($rs_document);
6071 6071
                         if ($obj_document) {
6072 6072
                             $row[5] = $obj_document->title;
6073 6073
                         }
6074
-    					break;
6075
-    				case 'thematic':
6076
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6077
-    					if (Database::num_rows($rs) > 0) {
6078
-    						$obj = Database::fetch_object($rs);
6079
-    						$row[5] = $obj->title;
6080
-    					}
6081
-    					break;
6082
-    				case 'thematic_advance':
6083
-    					$rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6084
-    					if (Database::num_rows($rs) > 0) {
6085
-    						$obj = Database::fetch_object($rs);
6086
-    						$row[5] = $obj->content;
6087
-    					}
6088
-    					break;
6089
-    				case 'thematic_plan':
6090
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6091
-    					if (Database::num_rows($rs) > 0) {
6092
-    						$obj = Database::fetch_object($rs);
6093
-    						$row[5] = $obj->title;
6094
-    					}
6095
-    					break;
6096
-    				default:
6097
-    					break;
6098
-    			}
6099
-
6100
-    			$row2 = $name_session;
6101
-    			if (!empty($coach_name)) {
6102
-    				$row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
6103
-    			}
6104
-    			$row[2] = $row2;
6074
+                        break;
6075
+                    case 'thematic':
6076
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6077
+                        if (Database::num_rows($rs) > 0) {
6078
+                            $obj = Database::fetch_object($rs);
6079
+                            $row[5] = $obj->title;
6080
+                        }
6081
+                        break;
6082
+                    case 'thematic_advance':
6083
+                        $rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6084
+                        if (Database::num_rows($rs) > 0) {
6085
+                            $obj = Database::fetch_object($rs);
6086
+                            $row[5] = $obj->content;
6087
+                        }
6088
+                        break;
6089
+                    case 'thematic_plan':
6090
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6091
+                        if (Database::num_rows($rs) > 0) {
6092
+                            $obj = Database::fetch_object($rs);
6093
+                            $row[5] = $obj->title;
6094
+                        }
6095
+                        break;
6096
+                    default:
6097
+                        break;
6098
+                }
6099
+
6100
+                $row2 = $name_session;
6101
+                if (!empty($coach_name)) {
6102
+                    $row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
6103
+                }
6104
+                $row[2] = $row2;
6105 6105
                 if (!empty($row['col3'])) {
6106 6106
                     $userInfo = api_get_user_info($row['user_id']);
6107 6107
 
@@ -6118,11 +6118,11 @@  discard block
 block discarded – undo
6118 6118
                     $row[4] = $ip;
6119 6119
                 }
6120 6120
 
6121
-    			$resources[] = $row;
6122
-    		}
6123
-    	}
6121
+                $resources[] = $row;
6122
+            }
6123
+        }
6124 6124
 
6125
-    	return $resources;
6125
+        return $resources;
6126 6126
     }
6127 6127
 
6128 6128
     /**
@@ -6132,63 +6132,63 @@  discard block
 block discarded – undo
6132 6132
      */
6133 6133
     public static function get_tool_name_table($tool)
6134 6134
     {
6135
-    	switch ($tool) {
6136
-    		case 'document':
6137
-    			$table_name = TABLE_DOCUMENT;
6138
-    			$link_tool = 'document/document.php';
6139
-    			$id_tool = 'id';
6140
-    			break;
6141
-    		case 'learnpath':
6142
-    			$table_name = TABLE_LP_MAIN;
6143
-    			$link_tool = 'newscorm/lp_controller.php';
6144
-    			$id_tool = 'id';
6145
-    			break;
6146
-    		case 'quiz':
6147
-    			$table_name = TABLE_QUIZ_TEST;
6148
-    			$link_tool = 'exercice/exercice.php';
6149
-    			$id_tool = 'id';
6150
-    			break;
6151
-    		case 'glossary':
6152
-    			$table_name = TABLE_GLOSSARY;
6153
-    			$link_tool = 'glossary/index.php';
6154
-    			$id_tool = 'glossary_id';
6155
-    			break;
6156
-    		case 'link':
6157
-    			$table_name = TABLE_LINK;
6158
-    			$link_tool = 'link/link.php';
6159
-    			$id_tool = 'id';
6160
-    			break;
6161
-    		case 'course_description':
6162
-    			$table_name = TABLE_COURSE_DESCRIPTION;
6163
-    			$link_tool = 'course_description/';
6164
-    			$id_tool = 'id';
6165
-    			break;
6166
-    		case 'announcement':
6167
-    			$table_name = TABLE_ANNOUNCEMENT;
6168
-    			$link_tool = 'announcements/announcements.php';
6169
-    			$id_tool = 'id';
6170
-    			break;
6171
-    		case 'thematic':
6172
-    			$table_name = TABLE_THEMATIC;
6173
-    			$link_tool = 'course_progress/index.php';
6174
-    			$id_tool = 'id';
6175
-    			break;
6176
-    		case 'thematic_advance':
6177
-    			$table_name = TABLE_THEMATIC_ADVANCE;
6178
-    			$link_tool = 'course_progress/index.php';
6179
-    			$id_tool = 'id';
6180
-    			break;
6181
-    		case 'thematic_plan':
6182
-    			$table_name = TABLE_THEMATIC_PLAN;
6183
-    			$link_tool = 'course_progress/index.php';
6184
-    			$id_tool = 'id';
6185
-    			break;
6186
-    		default:
6187
-    			$table_name = $tool;
6188
-    		break;
6189
-    	}
6190
-
6191
-    	return array(
6135
+        switch ($tool) {
6136
+            case 'document':
6137
+                $table_name = TABLE_DOCUMENT;
6138
+                $link_tool = 'document/document.php';
6139
+                $id_tool = 'id';
6140
+                break;
6141
+            case 'learnpath':
6142
+                $table_name = TABLE_LP_MAIN;
6143
+                $link_tool = 'newscorm/lp_controller.php';
6144
+                $id_tool = 'id';
6145
+                break;
6146
+            case 'quiz':
6147
+                $table_name = TABLE_QUIZ_TEST;
6148
+                $link_tool = 'exercice/exercice.php';
6149
+                $id_tool = 'id';
6150
+                break;
6151
+            case 'glossary':
6152
+                $table_name = TABLE_GLOSSARY;
6153
+                $link_tool = 'glossary/index.php';
6154
+                $id_tool = 'glossary_id';
6155
+                break;
6156
+            case 'link':
6157
+                $table_name = TABLE_LINK;
6158
+                $link_tool = 'link/link.php';
6159
+                $id_tool = 'id';
6160
+                break;
6161
+            case 'course_description':
6162
+                $table_name = TABLE_COURSE_DESCRIPTION;
6163
+                $link_tool = 'course_description/';
6164
+                $id_tool = 'id';
6165
+                break;
6166
+            case 'announcement':
6167
+                $table_name = TABLE_ANNOUNCEMENT;
6168
+                $link_tool = 'announcements/announcements.php';
6169
+                $id_tool = 'id';
6170
+                break;
6171
+            case 'thematic':
6172
+                $table_name = TABLE_THEMATIC;
6173
+                $link_tool = 'course_progress/index.php';
6174
+                $id_tool = 'id';
6175
+                break;
6176
+            case 'thematic_advance':
6177
+                $table_name = TABLE_THEMATIC_ADVANCE;
6178
+                $link_tool = 'course_progress/index.php';
6179
+                $id_tool = 'id';
6180
+                break;
6181
+            case 'thematic_plan':
6182
+                $table_name = TABLE_THEMATIC_PLAN;
6183
+                $link_tool = 'course_progress/index.php';
6184
+                $id_tool = 'id';
6185
+                break;
6186
+            default:
6187
+                $table_name = $tool;
6188
+            break;
6189
+        }
6190
+
6191
+        return array(
6192 6192
             'table_name' => $table_name,
6193 6193
             'link_tool' => $link_tool,
6194 6194
             'id_tool' => $id_tool
@@ -6197,45 +6197,45 @@  discard block
 block discarded – undo
6197 6197
 
6198 6198
     public static function display_additional_profile_fields()
6199 6199
     {
6200
-    	// getting all the extra profile fields that are defined by the platform administrator
6201
-    	$extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6202
-
6203
-    	// creating the form
6204
-    	$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6205
-
6206
-    	// the select field with the additional user profile fields (= this is where we select the field of which we want to see
6207
-    	// the information the users have entered or selected.
6208
-    	$return .= '<select name="additional_profile_field">';
6209
-    	$return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6210
-    	$extra_fields_to_show = 0;
6211
-    	foreach ($extra_fields as $key=>$field) {
6212
-    		// show only extra fields that are visible + and can be filtered, added by J.Montoya
6213
-    		if ($field[6]==1 && $field[8] == 1) {
6214
-    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6215
-    				$selected = 'selected="selected"';
6216
-    			} else {
6217
-    				$selected = '';
6218
-    			}
6219
-    			$extra_fields_to_show++;
6220
-    			$return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6221
-    		}
6222
-    	}
6223
-    	$return .= '</select>';
6224
-
6225
-    	// the form elements for the $_GET parameters (because the form is passed through GET
6226
-    	foreach ($_GET as $key=>$value){
6227
-    		if ($key <> 'additional_profile_field')    {
6228
-    			$return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6229
-    		}
6230
-    	}
6231
-    	// the submit button
6232
-    	$return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6233
-    	$return .= '</form>';
6234
-    	if ($extra_fields_to_show > 0) {
6235
-    		return $return;
6236
-    	} else {
6237
-    		return '';
6238
-    	}
6200
+        // getting all the extra profile fields that are defined by the platform administrator
6201
+        $extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6202
+
6203
+        // creating the form
6204
+        $return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6205
+
6206
+        // the select field with the additional user profile fields (= this is where we select the field of which we want to see
6207
+        // the information the users have entered or selected.
6208
+        $return .= '<select name="additional_profile_field">';
6209
+        $return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6210
+        $extra_fields_to_show = 0;
6211
+        foreach ($extra_fields as $key=>$field) {
6212
+            // show only extra fields that are visible + and can be filtered, added by J.Montoya
6213
+            if ($field[6]==1 && $field[8] == 1) {
6214
+                if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6215
+                    $selected = 'selected="selected"';
6216
+                } else {
6217
+                    $selected = '';
6218
+                }
6219
+                $extra_fields_to_show++;
6220
+                $return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6221
+            }
6222
+        }
6223
+        $return .= '</select>';
6224
+
6225
+        // the form elements for the $_GET parameters (because the form is passed through GET
6226
+        foreach ($_GET as $key=>$value){
6227
+            if ($key <> 'additional_profile_field')    {
6228
+                $return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6229
+            }
6230
+        }
6231
+        // the submit button
6232
+        $return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6233
+        $return .= '</form>';
6234
+        if ($extra_fields_to_show > 0) {
6235
+            return $return;
6236
+        } else {
6237
+            return '';
6238
+        }
6239 6239
     }
6240 6240
 
6241 6241
     /**
@@ -6254,31 +6254,31 @@  discard block
 block discarded – undo
6254 6254
      */
6255 6255
     public static function get_addtional_profile_information_of_field_by_user($field_id, $users)
6256 6256
     {
6257
-    	// Database table definition
6258
-    	$table_user = Database::get_main_table(TABLE_MAIN_USER);
6259
-    	$table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6257
+        // Database table definition
6258
+        $table_user = Database::get_main_table(TABLE_MAIN_USER);
6259
+        $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6260 6260
         $extraField = Database::get_main_table(TABLE_EXTRA_FIELD);
6261
-    	$result_extra_field = UserManager::get_extra_field_information($field_id);
6262
-
6263
-    	if (!empty($users)) {
6264
-    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6265
-    			foreach($users as $user_id) {
6266
-    				$user_result = UserManager::get_user_tags($user_id, $field_id);
6267
-    				$tag_list = array();
6268
-    				foreach($user_result as $item) {
6269
-    					$tag_list[] = $item['tag'];
6270
-    				}
6271
-    				$return[$user_id][] = implode(', ',$tag_list);
6272
-    			}
6273
-    		} else {
6274
-    			$new_user_array = array();
6275
-    			foreach ($users as $user_id) {
6276
-    				$new_user_array[]= "'".$user_id."'";
6277
-    			}
6278
-    			$users = implode(',',$new_user_array);
6261
+        $result_extra_field = UserManager::get_extra_field_information($field_id);
6262
+
6263
+        if (!empty($users)) {
6264
+            if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6265
+                foreach($users as $user_id) {
6266
+                    $user_result = UserManager::get_user_tags($user_id, $field_id);
6267
+                    $tag_list = array();
6268
+                    foreach($user_result as $item) {
6269
+                        $tag_list[] = $item['tag'];
6270
+                    }
6271
+                    $return[$user_id][] = implode(', ',$tag_list);
6272
+                }
6273
+            } else {
6274
+                $new_user_array = array();
6275
+                foreach ($users as $user_id) {
6276
+                    $new_user_array[]= "'".$user_id."'";
6277
+                }
6278
+                $users = implode(',',$new_user_array);
6279 6279
                 $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
6280
-    			// Selecting only the necessary information NOT ALL the user list
6281
-    			$sql = "SELECT user.user_id, v.value
6280
+                // Selecting only the necessary information NOT ALL the user list
6281
+                $sql = "SELECT user.user_id, v.value
6282 6282
     			        FROM $table_user user
6283 6283
     			        INNER JOIN $table_user_field_values v
6284 6284
                         ON (user.user_id = v.item_id)
@@ -6289,27 +6289,27 @@  discard block
 block discarded – undo
6289 6289
                             v.field_id=".intval($field_id)." AND
6290 6290
                             user.user_id IN ($users)";
6291 6291
 
6292
-    			$result = Database::query($sql);
6293
-    			while($row = Database::fetch_array($result)) {
6294
-    				// get option value for field type double select by id
6295
-    				if (!empty($row['value'])) {
6296
-    					if ($result_extra_field['field_type'] ==
6292
+                $result = Database::query($sql);
6293
+                while($row = Database::fetch_array($result)) {
6294
+                    // get option value for field type double select by id
6295
+                    if (!empty($row['value'])) {
6296
+                        if ($result_extra_field['field_type'] ==
6297 6297
                             ExtraField::FIELD_TYPE_DOUBLE_SELECT
6298 6298
                         ) {
6299
-    						$id_double_select = explode(';', $row['value']);
6300
-    						if (is_array($id_double_select)) {
6301
-    							$value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6302
-    							$value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6303
-    							$row['value'] = ($value1.';'.$value2);
6304
-    						}
6305
-    					}
6306
-    				}
6307
-    				// get other value from extra field
6308
-    				$return[$row['user_id']][] = $row['value'];
6309
-    			}
6310
-    		}
6311
-    	}
6312
-    	return $return;
6299
+                            $id_double_select = explode(';', $row['value']);
6300
+                            if (is_array($id_double_select)) {
6301
+                                $value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6302
+                                $value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6303
+                                $row['value'] = ($value1.';'.$value2);
6304
+                            }
6305
+                        }
6306
+                    }
6307
+                    // get other value from extra field
6308
+                    $return[$row['user_id']][] = $row['value'];
6309
+                }
6310
+            }
6311
+        }
6312
+        return $return;
6313 6313
     }
6314 6314
 
6315 6315
     /**
@@ -6318,18 +6318,18 @@  discard block
 block discarded – undo
6318 6318
      */
6319 6319
     public function count_student_in_course()
6320 6320
     {
6321
-    	global $nbStudents;
6322
-    	return $nbStudents;
6321
+        global $nbStudents;
6322
+        return $nbStudents;
6323 6323
     }
6324 6324
 
6325 6325
     public function sort_users($a, $b)
6326 6326
     {
6327
-    	return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6327
+        return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6328 6328
     }
6329 6329
 
6330 6330
     public function sort_users_desc($a, $b)
6331 6331
     {
6332
-    	return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6332
+        return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6333 6333
     }
6334 6334
 
6335 6335
     /**
@@ -6338,8 +6338,8 @@  discard block
 block discarded – undo
6338 6338
      */
6339 6339
     public static function get_number_of_users()
6340 6340
     {
6341
-    	global $user_ids;
6342
-    	return count($user_ids);
6341
+        global $user_ids;
6342
+        return count($user_ids);
6343 6343
     }
6344 6344
 
6345 6345
     /**
@@ -6355,37 +6355,37 @@  discard block
 block discarded – undo
6355 6355
     {
6356 6356
         global $user_ids, $course_code, $additional_user_profile_info, $export_csv, $is_western_name_order, $csv_content, $session_id;
6357 6357
 
6358
-    	$course_code = Database::escape_string($course_code);
6359
-    	$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6360
-    	$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6358
+        $course_code = Database::escape_string($course_code);
6359
+        $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6360
+        $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6361 6361
 
6362
-    	$access_url_id = api_get_current_access_url_id();
6362
+        $access_url_id = api_get_current_access_url_id();
6363 6363
 
6364
-    	// get all users data from a course for sortable with limit
6365
-    	if (is_array($user_ids)) {
6366
-    		$user_ids = array_map('intval', $user_ids);
6367
-    		$condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6368
-    	} else {
6369
-    		$user_ids = intval($user_ids);
6370
-    		$condition_user = " WHERE user.user_id = $user_ids ";
6371
-    	}
6364
+        // get all users data from a course for sortable with limit
6365
+        if (is_array($user_ids)) {
6366
+            $user_ids = array_map('intval', $user_ids);
6367
+            $condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6368
+        } else {
6369
+            $user_ids = intval($user_ids);
6370
+            $condition_user = " WHERE user.user_id = $user_ids ";
6371
+        }
6372 6372
 
6373
-    	if (!empty($_GET['user_keyword'])) {
6374
-    		$keyword = trim(Database::escape_string($_GET['user_keyword']));
6375
-    		$condition_user .=  " AND (
6373
+        if (!empty($_GET['user_keyword'])) {
6374
+            $keyword = trim(Database::escape_string($_GET['user_keyword']));
6375
+            $condition_user .=  " AND (
6376 6376
                 user.firstname LIKE '%".$keyword."%' OR
6377 6377
                 user.lastname LIKE '%".$keyword."%'  OR
6378 6378
                 user.username LIKE '%".$keyword."%'  OR
6379 6379
                 user.email LIKE '%".$keyword."%'
6380 6380
              ) ";
6381
-    	}
6381
+        }
6382 6382
 
6383 6383
         $url_table = null;
6384 6384
         $url_condition = null;
6385
-    	if (api_is_multiple_url_enabled()) {
6386
-    		$url_table = ", ".$tbl_url_rel_user." as url_users";
6387
-    		$url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6388
-    	}
6385
+        if (api_is_multiple_url_enabled()) {
6386
+            $url_table = ", ".$tbl_url_rel_user." as url_users";
6387
+            $url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6388
+        }
6389 6389
 
6390 6390
         $invitedUsersCondition = '';
6391 6391
 
@@ -6393,7 +6393,7 @@  discard block
 block discarded – undo
6393 6393
             $invitedUsersCondition = " AND user.status != " . INVITEE;
6394 6394
         }
6395 6395
 
6396
-    	$sql = "SELECT  user.user_id as user_id,
6396
+        $sql = "SELECT  user.user_id as user_id,
6397 6397
                     user.official_code  as col0,
6398 6398
                     user.lastname       as col1,
6399 6399
                     user.firstname      as col2,
@@ -6401,17 +6401,17 @@  discard block
 block discarded – undo
6401 6401
                 FROM $tbl_user as user $url_table
6402 6402
     	        $condition_user $url_condition $invitedUsersCondition";
6403 6403
 
6404
-    	if (!in_array($direction, array('ASC','DESC'))) {
6405
-    		$direction = 'ASC';
6406
-    	}
6404
+        if (!in_array($direction, array('ASC','DESC'))) {
6405
+            $direction = 'ASC';
6406
+        }
6407 6407
 
6408
-    	$column = intval($column);
6408
+        $column = intval($column);
6409 6409
 
6410
-    	$from = intval($from);
6411
-    	$number_of_items = intval($number_of_items);
6410
+        $from = intval($from);
6411
+        $number_of_items = intval($number_of_items);
6412 6412
 
6413
-    	$sql .= " ORDER BY col$column $direction ";
6414
-    	$sql .= " LIMIT $from,$number_of_items";
6413
+        $sql .= " ORDER BY col$column $direction ";
6414
+        $sql .= " LIMIT $from,$number_of_items";
6415 6415
 
6416 6416
         $res = Database::query($sql);
6417 6417
         $users = array();
@@ -6445,7 +6445,7 @@  discard block
 block discarded – undo
6445 6445
             }
6446 6446
         }
6447 6447
 
6448
-    	while ($user = Database::fetch_array($res, 'ASSOC')) {
6448
+        while ($user = Database::fetch_array($res, 'ASSOC')) {
6449 6449
             $courseInfo = api_get_course_info($course_code);
6450 6450
             $courseId = $courseInfo['real_id'];
6451 6451
 
@@ -6476,10 +6476,10 @@  discard block
 block discarded – undo
6476 6476
                 $session_id
6477 6477
             );
6478 6478
 
6479
-    		if (empty($avg_student_progress)) {
6479
+            if (empty($avg_student_progress)) {
6480 6480
                 $avg_student_progress = 0;
6481
-    		}
6482
-    		$user['average_progress'] = $avg_student_progress.'%';
6481
+            }
6482
+            $user['average_progress'] = $avg_student_progress.'%';
6483 6483
 
6484 6484
             $total_user_exercise = Tracking::get_exercise_student_progress(
6485 6485
                 $total_exercises,
@@ -6499,11 +6499,11 @@  discard block
 block discarded – undo
6499 6499
 
6500 6500
             $user['exercise_average_best_attempt'] = $total_user_exercise;
6501 6501
 
6502
-    		if (is_numeric($avg_student_score)) {
6503
-    			$user['student_score']  = $avg_student_score.'%';
6504
-    		} else {
6505
-    			$user['student_score']  = $avg_student_score;
6506
-    		}
6502
+            if (is_numeric($avg_student_score)) {
6503
+                $user['student_score']  = $avg_student_score.'%';
6504
+            } else {
6505
+                $user['student_score']  = $avg_student_score;
6506
+            }
6507 6507
 
6508 6508
             $user['count_assignments'] = Tracking::count_student_assignments(
6509 6509
                 $user['user_id'],
@@ -6526,29 +6526,29 @@  discard block
 block discarded – undo
6526 6526
                 $session_id
6527 6527
             );
6528 6528
 
6529
-    		// we need to display an additional profile field
6530
-    		$user['additional'] = '';
6529
+            // we need to display an additional profile field
6530
+            $user['additional'] = '';
6531 6531
 
6532
-    		if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6533
-    			if (isset($additional_user_profile_info[$user['user_id']]) &&
6532
+            if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6533
+                if (isset($additional_user_profile_info[$user['user_id']]) &&
6534 6534
                     is_array($additional_user_profile_info[$user['user_id']])
6535 6535
                 ) {
6536
-    				$user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6537
-    			}
6538
-    		}
6536
+                    $user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6537
+                }
6538
+            }
6539 6539
 
6540 6540
             if (empty($session_id)) {
6541 6541
                 $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys;
6542 6542
             }
6543 6543
 
6544
-    		$user['link'] = '<center>
6544
+            $user['link'] = '<center>
6545 6545
                              <a href="../mySpace/myStudents.php?student='.$user['user_id'].'&details=true&course='.$course_code.'&origin=tracking_course&id_session='.$session_id.'">
6546 6546
     		                 '.Display::return_icon('2rightarrow.png').'
6547 6547
     		                 </a>
6548 6548
                          </center>';
6549 6549
 
6550
-    		// store columns in array $users
6551
-    		$is_western_name_order = api_is_western_name_order();
6550
+            // store columns in array $users
6551
+            $is_western_name_order = api_is_western_name_order();
6552 6552
             $user_row = array();
6553 6553
             $user_row[]= $user['official_code']; //0
6554 6554
             if ($is_western_name_order) {
@@ -6584,21 +6584,21 @@  discard block
 block discarded – undo
6584 6584
 
6585 6585
             $users[] = $user_row;
6586 6586
 
6587
-    		if ($export_csv) {
6588
-    		    if (empty($session_id)) {
6587
+            if ($export_csv) {
6588
+                if (empty($session_id)) {
6589 6589
                     $user_row = array_map('strip_tags', $user_row);
6590
-    			    unset($user_row[14]);
6591
-    			    unset($user_row[15]);
6590
+                    unset($user_row[14]);
6591
+                    unset($user_row[15]);
6592 6592
                 } else {
6593 6593
                     $user_row = array_map('strip_tags', $user_row);
6594 6594
                     unset($user_row[13]);
6595 6595
                     unset($user_row[14]);
6596 6596
                 }
6597 6597
 
6598
-    			$csv_content[] = $user_row;
6599
-    		}
6600
-    	}
6601
-    	return $users;
6598
+                $csv_content[] = $user_row;
6599
+            }
6600
+        }
6601
+        return $users;
6602 6602
     }
6603 6603
 }
6604 6604
 
@@ -6616,18 +6616,18 @@  discard block
 block discarded – undo
6616 6616
      */
6617 6617
     public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
6618 6618
     {
6619
-    	$MonthsLong = $GLOBALS['MonthsLong'];
6620
-
6621
-    	// protected data
6622
-    	$user_id = intval($user_id);
6623
-    	$session_id = intval($session_id);
6624
-    	$course_id = Database::escape_string($course_id);
6625
-
6626
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6627
-    	$tempView = $view;
6628
-    	if(substr($view,0,1) == '1') {
6629
-    		$new_view = substr_replace($view,'0',0,1);
6630
-    		echo "
6619
+        $MonthsLong = $GLOBALS['MonthsLong'];
6620
+
6621
+        // protected data
6622
+        $user_id = intval($user_id);
6623
+        $session_id = intval($session_id);
6624
+        $course_id = Database::escape_string($course_id);
6625
+
6626
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6627
+        $tempView = $view;
6628
+        if(substr($view,0,1) == '1') {
6629
+            $new_view = substr_replace($view,'0',0,1);
6630
+            echo "
6631 6631
                 <tr>
6632 6632
                     <td valign='top'>
6633 6633
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font>" .
@@ -6635,9 +6635,9 @@  discard block
 block discarded – undo
6635 6635
                     </td>
6636 6636
                 </tr>
6637 6637
                 ";
6638
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6638
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6639 6639
 
6640
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6640
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6641 6641
                         FROM $track_access_table
6642 6642
                         WHERE access_user_id = $user_id
6643 6643
                         AND c_id = $course_id
@@ -6645,11 +6645,11 @@  discard block
 block discarded – undo
6645 6645
                         GROUP BY YEAR(access_date),MONTH(access_date)
6646 6646
                         ORDER BY YEAR(access_date),MONTH(access_date) ASC";
6647 6647
 
6648
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6649
-    		$results = getManyResults3Col($sql);
6648
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6649
+            $results = getManyResults3Col($sql);
6650 6650
 
6651
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6652
-    		echo "<tr>
6651
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6652
+            echo "<tr>
6653 6653
                     <td class='secLine'>
6654 6654
                     ".get_lang('LoginsTitleMonthColumn')."
6655 6655
                     </td>
@@ -6657,36 +6657,36 @@  discard block
 block discarded – undo
6657 6657
                     ".get_lang('LoginsTitleCountColumn')."
6658 6658
                     </td>
6659 6659
                 </tr>";
6660
-    		$total = 0;
6661
-    		if (is_array($results)) {
6662
-    			for($j = 0 ; $j < count($results) ; $j++) {
6663
-    				echo "<tr>";
6664
-    				echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>";
6665
-    				echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6666
-    				echo"</tr>";
6667
-    				$total = $total + $results[$j][1];
6668
-    			}
6669
-    			echo "<tr>";
6670
-    			echo "<td>".get_lang('Total')."</td>";
6671
-    			echo "<td align='right' class='content'>".$total."</td>";
6672
-    			echo"</tr>";
6673
-    		} else {
6674
-    			echo "<tr>";
6675
-    			echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6676
-    			echo"</tr>";
6677
-    		}
6678
-    		echo "</table>";
6679
-    		echo "</td></tr>";
6680
-    	} else {
6681
-    		$new_view = substr_replace($view,'1',0,1);
6682
-    		echo "
6660
+            $total = 0;
6661
+            if (is_array($results)) {
6662
+                for($j = 0 ; $j < count($results) ; $j++) {
6663
+                    echo "<tr>";
6664
+                    echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>";
6665
+                    echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6666
+                    echo"</tr>";
6667
+                    $total = $total + $results[$j][1];
6668
+                }
6669
+                echo "<tr>";
6670
+                echo "<td>".get_lang('Total')."</td>";
6671
+                echo "<td align='right' class='content'>".$total."</td>";
6672
+                echo"</tr>";
6673
+            } else {
6674
+                echo "<tr>";
6675
+                echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6676
+                echo"</tr>";
6677
+            }
6678
+            echo "</table>";
6679
+            echo "</td></tr>";
6680
+        } else {
6681
+            $new_view = substr_replace($view,'1',0,1);
6682
+            echo "
6683 6683
                 <tr>
6684 6684
                     <td valign='top'>
6685 6685
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".$user_id."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LoginsAndAccessTools')."</a>
6686 6686
                     </td>
6687 6687
                 </tr>
6688 6688
             ";
6689
-    	}
6689
+        }
6690 6690
     }
6691 6691
 
6692 6692
     /**
@@ -6699,38 +6699,38 @@  discard block
 block discarded – undo
6699 6699
      */
6700 6700
     public function display_exercise_tracking_info($view, $user_id, $courseCode)
6701 6701
     {
6702
-    	global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6702
+        global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6703 6703
         $courseId = api_get_course_int_id($courseCode);
6704
-    	if(substr($view,1,1) == '1') {
6705
-    		$new_view = substr_replace($view,'0',1,1);
6706
-    		echo "<tr>
6704
+        if(substr($view,1,1) == '1') {
6705
+            $new_view = substr_replace($view,'0',1,1);
6706
+            echo "<tr>
6707 6707
                     <td valign='top'>
6708 6708
                         <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('ExercicesResults')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=01000'>".get_lang('ExportAsCSV')."</a>]
6709 6709
                     </td>
6710 6710
                 </tr>";
6711
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6711
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6712 6712
 
6713
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6713
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6714 6714
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
6715 6715
                     WHERE te.c_id = $courseId
6716 6716
                         AND te.exe_user_id = ".intval($user_id)."
6717 6717
                         AND te.exe_exo_id = ce.id
6718 6718
                     ORDER BY ce.title ASC, te.exe_date ASC";
6719 6719
 
6720
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6720
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6721 6721
                         FROM $TBL_TRACK_HOTPOTATOES AS te
6722 6722
                         WHERE te.exe_user_id = '".intval($user_id)."' AND te.c_id = $courseId
6723 6723
                         ORDER BY te.c_id ASC, te.exe_date ASC";
6724 6724
 
6725
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6725
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6726 6726
 
6727
-    		$NoTestRes = 0;
6728
-    		$NoHPTestRes = 0;
6727
+            $NoTestRes = 0;
6728
+            $NoHPTestRes = 0;
6729 6729
 
6730
-    		echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6731
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6732
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6733
-    		echo "
6730
+            echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6731
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
6732
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6733
+            echo "
6734 6734
                 <tr bgcolor='#E6E6E6'>
6735 6735
                     <td>
6736 6736
                     ".get_lang('ExercicesTitleExerciceColumn')."
@@ -6743,28 +6743,28 @@  discard block
 block discarded – undo
6743 6743
                     </td>
6744 6744
                 </tr>";
6745 6745
 
6746
-    		if (is_array($results)) {
6747
-    			for($i = 0; $i < sizeof($results); $i++) {
6748
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6749
-    				echo "<tr>\n";
6750
-    				echo "<td class='content'>".$results[$i][0]."</td>\n";
6751
-    				echo "<td class='content'>".$display_date."</td>\n";
6752
-    				echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6753
-    				echo "</tr>\n";
6754
-    			}
6755
-    		} else {
6756
-    			// istvan begin
6757
-    			$NoTestRes = 1;
6758
-    		}
6759
-
6760
-    		// The Result of Tests
6761
-    		if (is_array($hpresults)) {
6762
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6763
-    				$title = GetQuizName($hpresults[$i][0],'');
6764
-    				if ($title == '')
6765
-    				$title = basename($hpresults[$i][0]);
6766
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6767
-    				?>
6746
+            if (is_array($results)) {
6747
+                for($i = 0; $i < sizeof($results); $i++) {
6748
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6749
+                    echo "<tr>\n";
6750
+                    echo "<td class='content'>".$results[$i][0]."</td>\n";
6751
+                    echo "<td class='content'>".$display_date."</td>\n";
6752
+                    echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6753
+                    echo "</tr>\n";
6754
+                }
6755
+            } else {
6756
+                // istvan begin
6757
+                $NoTestRes = 1;
6758
+            }
6759
+
6760
+            // The Result of Tests
6761
+            if (is_array($hpresults)) {
6762
+                for($i = 0; $i < sizeof($hpresults); $i++) {
6763
+                    $title = GetQuizName($hpresults[$i][0],'');
6764
+                    if ($title == '')
6765
+                    $title = basename($hpresults[$i][0]);
6766
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6767
+                    ?>
6768 6768
                     <tr>
6769 6769
                         <td class="content"><?php echo $title; ?></td>
6770 6770
                         <td class="content" align="center"><?php echo $display_date; ?></td>
@@ -6774,26 +6774,26 @@  discard block
 block discarded – undo
6774 6774
 
6775 6775
                     <?php
6776 6776
                 }
6777
-    		} else {
6778
-    			$NoHPTestRes = 1;
6779
-    		}
6780
-
6781
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6782
-    			echo "<tr>\n";
6783
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6784
-    			echo "</tr>\n";
6785
-    		}
6786
-    		echo "</table>";
6787
-    		echo "</td>\n</tr>\n";
6788
-    	} else {
6789
-    		$new_view = substr_replace($view,'1',1,1);
6790
-    		echo "
6777
+            } else {
6778
+                $NoHPTestRes = 1;
6779
+            }
6780
+
6781
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6782
+                echo "<tr>\n";
6783
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6784
+                echo "</tr>\n";
6785
+            }
6786
+            echo "</table>";
6787
+            echo "</td>\n</tr>\n";
6788
+        } else {
6789
+            $new_view = substr_replace($view,'1',1,1);
6790
+            echo "
6791 6791
                 <tr>
6792 6792
                     <td valign='top'>
6793 6793
                         +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=$user_id&view=".$new_view."' class='specialLink'>".get_lang('ExercicesResults')."</a>
6794 6794
                     </td>
6795 6795
                 </tr>";
6796
-    	}
6796
+        }
6797 6797
     }
6798 6798
 
6799 6799
     /**
@@ -6802,27 +6802,27 @@  discard block
 block discarded – undo
6802 6802
      */
6803 6803
     public function display_student_publications_tracking_info($view, $user_id, $course_id)
6804 6804
     {
6805
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6805
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6806 6806
         $_course = api_get_course_info_by_id($course_id);
6807 6807
 
6808
-    	if (substr($view,2,1) == '1') {
6809
-    		$new_view = substr_replace($view,'0',2,1);
6810
-    		echo "<tr>
6808
+        if (substr($view,2,1) == '1') {
6809
+            $new_view = substr_replace($view,'0',2,1);
6810
+            echo "<tr>
6811 6811
                     <td valign='top'>
6812 6812
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('WorkUploads')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00100'>".get_lang('ExportAsCSV')."</a>]
6813 6813
                     </td>
6814 6814
                 </tr>";
6815
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6816
-    		$sql = "SELECT u.upload_date, w.title, w.author,w.url
6815
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6816
+            $sql = "SELECT u.upload_date, w.title, w.author,w.url
6817 6817
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
6818 6818
                     WHERE u.upload_work_id = w.id
6819 6819
                         AND u.upload_user_id = '".intval($user_id)."'
6820 6820
                         AND u.c_id = '".intval($course_id)."'
6821 6821
                     ORDER BY u.upload_date DESC";
6822
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6823
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
6824
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6825
-    		echo "<tr>
6822
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6823
+            $results = StatsUtils::getManyResultsXCol($sql,4);
6824
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6825
+            echo "<tr>
6826 6826
                     <td class='secLine' width='40%'>
6827 6827
                     ".get_lang('WorkTitle')."
6828 6828
                     </td>
@@ -6833,35 +6833,35 @@  discard block
 block discarded – undo
6833 6833
                     ".get_lang('Date')."
6834 6834
                     </td>
6835 6835
                 </tr>";
6836
-    		if (is_array($results)) {
6837
-    			for($j = 0 ; $j < count($results) ; $j++) {
6838
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6839
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6840
-    				echo "<tr>";
6841
-    				echo "<td class='content'>"
6842
-    				."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6843
-    				."</td>";
6844
-    				echo "<td class='content'>".$results[$j][2]."</td>";
6845
-    				echo "<td class='content'>".$beautifulDate."</td>";
6846
-    				echo"</tr>";
6847
-    			}
6848
-    		} else {
6849
-    			echo "<tr>";
6850
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6851
-    			echo"</tr>";
6852
-    		}
6853
-    		echo "</table>";
6854
-    		echo "</td></tr>";
6855
-    	} else {
6856
-    		$new_view = substr_replace($view,'1',2,1);
6857
-    		echo "
6836
+            if (is_array($results)) {
6837
+                for($j = 0 ; $j < count($results) ; $j++) {
6838
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6839
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6840
+                    echo "<tr>";
6841
+                    echo "<td class='content'>"
6842
+                    ."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6843
+                    ."</td>";
6844
+                    echo "<td class='content'>".$results[$j][2]."</td>";
6845
+                    echo "<td class='content'>".$beautifulDate."</td>";
6846
+                    echo"</tr>";
6847
+                }
6848
+            } else {
6849
+                echo "<tr>";
6850
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6851
+                echo"</tr>";
6852
+            }
6853
+            echo "</table>";
6854
+            echo "</td></tr>";
6855
+        } else {
6856
+            $new_view = substr_replace($view,'1',2,1);
6857
+            echo "
6858 6858
                 <tr>
6859 6859
                     <td valign='top'>
6860 6860
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('WorkUploads')."</a>
6861 6861
                     </td>
6862 6862
                 </tr>
6863 6863
             ";
6864
-    	}
6864
+        }
6865 6865
     }
6866 6866
 
6867 6867
     /**
@@ -6870,55 +6870,55 @@  discard block
 block discarded – undo
6870 6870
      */
6871 6871
     public function display_links_tracking_info($view, $user_id, $courseCode)
6872 6872
     {
6873
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
6873
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
6874 6874
         $courseId = api_get_course_int_id($courseCode);
6875
-    	if (substr($view,3,1) == '1') {
6876
-    		$new_view = substr_replace($view,'0',3,1);
6877
-    		echo "
6875
+        if (substr($view,3,1) == '1') {
6876
+            $new_view = substr_replace($view,'0',3,1);
6877
+            echo "
6878 6878
                 <tr>
6879 6879
                         <td valign='top'>
6880 6880
                         <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('LinksAccess')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00010'>".get_lang('ExportAsCSV')."</a>]
6881 6881
                         </td>
6882 6882
                 </tr>
6883 6883
             ";
6884
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
6885
-    		$sql = "SELECT cl.title, cl.url
6884
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
6885
+            $sql = "SELECT cl.title, cl.url
6886 6886
                     FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
6887 6887
                     WHERE sl.links_link_id = cl.id
6888 6888
                         AND sl.c_id = $courseId
6889 6889
                         AND sl.links_user_id = ".intval($user_id)."
6890 6890
                     GROUP BY cl.title, cl.url";
6891
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6892
-    		$results = StatsUtils::getManyResults2Col($sql);
6893
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6894
-    		echo "<tr>
6891
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6892
+            $results = StatsUtils::getManyResults2Col($sql);
6893
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6894
+            echo "<tr>
6895 6895
                     <td class='secLine'>
6896 6896
                     ".get_lang('LinksTitleLinkColumn')."
6897 6897
                     </td>
6898 6898
                 </tr>";
6899
-    		if (is_array($results)) {
6900
-    			for($j = 0 ; $j < count($results) ; $j++) {
6901
-    				echo "<tr>";
6902
-    				echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
6903
-    				echo"</tr>";
6904
-    			}
6905
-    		} else {
6906
-    			echo "<tr>";
6907
-    			echo "<td ><center>".get_lang('NoResult')."</center></td>";
6908
-    			echo"</tr>";
6909
-    		}
6910
-    		echo "</table>";
6911
-    		echo "</td></tr>";
6912
-    	} else {
6913
-    		$new_view = substr_replace($view,'1',3,1);
6914
-    		echo "
6899
+            if (is_array($results)) {
6900
+                for($j = 0 ; $j < count($results) ; $j++) {
6901
+                    echo "<tr>";
6902
+                    echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
6903
+                    echo"</tr>";
6904
+                }
6905
+            } else {
6906
+                echo "<tr>";
6907
+                echo "<td ><center>".get_lang('NoResult')."</center></td>";
6908
+                echo"</tr>";
6909
+            }
6910
+            echo "</table>";
6911
+            echo "</td></tr>";
6912
+        } else {
6913
+            $new_view = substr_replace($view,'1',3,1);
6914
+            echo "
6915 6915
                 <tr>
6916 6916
                     <td valign='top'>
6917 6917
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LinksAccess')."</a>
6918 6918
                     </td>
6919 6919
                 </tr>
6920 6920
             ";
6921
-    	}
6921
+        }
6922 6922
     }
6923 6923
 
6924 6924
     /**
@@ -6931,61 +6931,61 @@  discard block
 block discarded – undo
6931 6931
      */
6932 6932
     public static function display_document_tracking_info($view, $user_id, $course_code, $session_id = 0)
6933 6933
     {
6934
-    	// protect data
6934
+        // protect data
6935 6935
         $user_id = intval($user_id);
6936 6936
         $courseId = api_get_course_int_id($course_code);
6937
-    	$session_id = intval($session_id);
6937
+        $session_id = intval($session_id);
6938 6938
 
6939
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
6940
-    	if(substr($view,4,1) == '1') {
6941
-    		$new_view = substr_replace($view,'0',4,1);
6942
-    		echo "
6939
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
6940
+        if(substr($view,4,1) == '1') {
6941
+            $new_view = substr_replace($view,'0',4,1);
6942
+            echo "
6943 6943
                 <tr>
6944 6944
                     <td valign='top'>
6945 6945
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('DocumentsAccess')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00001'>".get_lang('ExportAsCSV')."</a>]
6946 6946
                     </td>
6947 6947
                 </tr>
6948 6948
             ";
6949
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
6949
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
6950 6950
 
6951
-    		$sql = "SELECT down_doc_path
6951
+            $sql = "SELECT down_doc_path
6952 6952
                     FROM $downloads_table
6953 6953
                     WHERE c_id = $courseId
6954 6954
                         AND down_user_id = $user_id
6955 6955
                         AND down_session_id = $session_id
6956 6956
                     GROUP BY down_doc_path";
6957 6957
 
6958
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6959
-    		$results = StatsUtils::getManyResults1Col($sql);
6960
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
6961
-    		echo "<tr>
6958
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6959
+            $results = StatsUtils::getManyResults1Col($sql);
6960
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
6961
+            echo "<tr>
6962 6962
                     <td class='secLine'>
6963 6963
                     ".get_lang('DocumentsTitleDocumentColumn')."
6964 6964
                     </td>
6965 6965
                 </tr>";
6966
-    		if (is_array($results)) {
6967
-    			for($j = 0 ; $j < count($results) ; $j++) {
6968
-    				echo "<tr>";
6969
-    				echo "<td class='content'>".$results[$j]."</td>";
6970
-    				echo"</tr>";
6971
-    			}
6972
-    		} else {
6973
-    			echo "<tr>";
6974
-    			echo "<td><center>".get_lang('NoResult')."</center></td>";
6975
-    			echo"</tr>";
6976
-    		}
6977
-    		echo "</table>";
6978
-    		echo "</td></tr>";
6979
-    	} else {
6980
-    		$new_view = substr_replace($view,'1',4,1);
6981
-    		echo "
6966
+            if (is_array($results)) {
6967
+                for($j = 0 ; $j < count($results) ; $j++) {
6968
+                    echo "<tr>";
6969
+                    echo "<td class='content'>".$results[$j]."</td>";
6970
+                    echo"</tr>";
6971
+                }
6972
+            } else {
6973
+                echo "<tr>";
6974
+                echo "<td><center>".get_lang('NoResult')."</center></td>";
6975
+                echo"</tr>";
6976
+            }
6977
+            echo "</table>";
6978
+            echo "</td></tr>";
6979
+        } else {
6980
+            $new_view = substr_replace($view,'1',4,1);
6981
+            echo "
6982 6982
                 <tr>
6983 6983
                     <td valign='top'>
6984 6984
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('DocumentsAccess')."</a>
6985 6985
                     </td>
6986 6986
                 </tr>
6987 6987
             ";
6988
-    	}
6988
+        }
6989 6989
     }
6990 6990
 
6991 6991
     /**
@@ -7042,43 +7042,43 @@  discard block
 block discarded – undo
7042 7042
      */
7043 7043
     public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
7044 7044
     {
7045
-    	$MonthsLong = $GLOBALS['MonthsLong'];
7046
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
7047
-
7048
-    	// protected data
7049
-    	$user_id    = intval($user_id);
7050
-    	$session_id = intval($session_id);
7051
-    	$course_id  = intval($course_id);
7052
-
7053
-    	$tempView = $view;
7054
-    	if (substr($view,0,1) == '1') {
7055
-    		$new_view = substr_replace($view,'0',0,1);
7056
-    		$title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7057
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
7045
+        $MonthsLong = $GLOBALS['MonthsLong'];
7046
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
7047
+
7048
+        // protected data
7049
+        $user_id    = intval($user_id);
7050
+        $session_id = intval($session_id);
7051
+        $course_id  = intval($course_id);
7052
+
7053
+        $tempView = $view;
7054
+        if (substr($view,0,1) == '1') {
7055
+            $new_view = substr_replace($view,'0',0,1);
7056
+            $title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7057
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
7058 7058
                     FROM $track_access_table
7059 7059
                     WHERE access_user_id = $user_id
7060 7060
                     AND c_id = $course_id
7061 7061
                     AND access_session_id = $session_id
7062 7062
                     GROUP BY YEAR(access_date),MONTH(access_date)
7063 7063
                     ORDER BY YEAR(access_date),MONTH(access_date) ASC";
7064
-    		//$results = getManyResults2Col($sql);
7065
-    		$results = getManyResults3Col($sql);
7066
-    		$title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7067
-    		$line='';
7068
-    		$total = 0;
7069
-    		if (is_array($results)) {
7070
-    			for($j = 0 ; $j < count($results) ; $j++) {
7071
-    				$line .= $results[$j][0].';'.$results[$j][1]."\n";
7072
-    				$total = $total + $results[$j][1];
7073
-    			}
7074
-    			$line .= get_lang('Total').";".$total."\n";
7075
-    		} else {
7076
-    			$line= get_lang('NoResult')."</center></td>";
7077
-    		}
7078
-    	} else {
7079
-    		$new_view = substr_replace($view,'1',0,1);
7080
-    	}
7081
-    	return array($title_line, $line);
7064
+            //$results = getManyResults2Col($sql);
7065
+            $results = getManyResults3Col($sql);
7066
+            $title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7067
+            $line='';
7068
+            $total = 0;
7069
+            if (is_array($results)) {
7070
+                for($j = 0 ; $j < count($results) ; $j++) {
7071
+                    $line .= $results[$j][0].';'.$results[$j][1]."\n";
7072
+                    $total = $total + $results[$j][1];
7073
+                }
7074
+                $line .= get_lang('Total').";".$total."\n";
7075
+            } else {
7076
+                $line= get_lang('NoResult')."</center></td>";
7077
+            }
7078
+        } else {
7079
+            $new_view = substr_replace($view,'1',0,1);
7080
+        }
7081
+        return array($title_line, $line);
7082 7082
     }
7083 7083
 
7084 7084
     /**
@@ -7091,67 +7091,67 @@  discard block
 block discarded – undo
7091 7091
      */
7092 7092
     public function display_exercise_tracking_info($view, $userId, $courseCode)
7093 7093
     {
7094
-    	global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7094
+        global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7095 7095
         $courseId = api_get_course_int_id($courseCode);
7096 7096
         $userId = intval($userId);
7097
-    	if (substr($view,1,1) == '1') {
7098
-    		$new_view = substr_replace($view,'0',1,1);
7099
-    		$title[1] = get_lang('ExercicesDetails');
7100
-    		$line = '';
7101
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7097
+        if (substr($view,1,1) == '1') {
7098
+            $new_view = substr_replace($view,'0',1,1);
7099
+            $title[1] = get_lang('ExercicesDetails');
7100
+            $line = '';
7101
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7102 7102
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
7103 7103
                     WHERE te.c_id = $courseId
7104 7104
                         AND te.exe_user_id = $userId
7105 7105
                         AND te.exe_exo_id = ce.id
7106 7106
                     ORDER BY ce.title ASC, te.exe_date ASC";
7107 7107
 
7108
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7108
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7109 7109
                         FROM $TABLETRACK_HOTPOTATOES AS te
7110 7110
                         WHERE te.exe_user_id = '$userId' AND te.c_id = $courseId
7111 7111
                         ORDER BY te.c_id ASC, te.exe_date ASC";
7112 7112
 
7113
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
7113
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
7114 7114
 
7115
-    		$NoTestRes = 0;
7116
-    		$NoHPTestRes = 0;
7115
+            $NoTestRes = 0;
7116
+            $NoHPTestRes = 0;
7117 7117
 
7118
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
7119
-    		$title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7118
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
7119
+            $title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7120 7120
 
7121
-    		if (is_array($results)) {
7122
-    			for($i = 0; $i < sizeof($results); $i++)
7123
-    			{
7124
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7125
-    				$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
7126
-    			}
7127
-    		} else {
7121
+            if (is_array($results)) {
7122
+                for($i = 0; $i < sizeof($results); $i++)
7123
+                {
7124
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7125
+                    $line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
7126
+                }
7127
+            } else {
7128 7128
                 // istvan begin
7129
-    			$NoTestRes = 1;
7130
-    		}
7131
-
7132
-    		// The Result of Tests
7133
-    		if (is_array($hpresults)) {
7134
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
7135
-    				$title = GetQuizName($hpresults[$i][0],'');
7136
-
7137
-    				if ($title == '')
7138
-    				$title = basename($hpresults[$i][0]);
7139
-
7140
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
7141
-
7142
-    				$line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
7143
-    			}
7144
-    		} else {
7145
-    			$NoHPTestRes = 1;
7146
-    		}
7147
-
7148
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7149
-    			$line=get_lang('NoResult');
7150
-    		}
7151
-    	} else {
7152
-    		$new_view = substr_replace($view,'1',1,1);
7153
-    	}
7154
-    	return array($title_line, $line);
7129
+                $NoTestRes = 1;
7130
+            }
7131
+
7132
+            // The Result of Tests
7133
+            if (is_array($hpresults)) {
7134
+                for($i = 0; $i < sizeof($hpresults); $i++) {
7135
+                    $title = GetQuizName($hpresults[$i][0],'');
7136
+
7137
+                    if ($title == '')
7138
+                    $title = basename($hpresults[$i][0]);
7139
+
7140
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
7141
+
7142
+                    $line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
7143
+                }
7144
+            } else {
7145
+                $NoHPTestRes = 1;
7146
+            }
7147
+
7148
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7149
+                $line=get_lang('NoResult');
7150
+            }
7151
+        } else {
7152
+            $new_view = substr_replace($view,'1',1,1);
7153
+        }
7154
+        return array($title_line, $line);
7155 7155
     }
7156 7156
 
7157 7157
     /**
@@ -7160,37 +7160,37 @@  discard block
 block discarded – undo
7160 7160
      */
7161 7161
     public function display_student_publications_tracking_info($view, $user_id, $course_id)
7162 7162
     {
7163
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7163
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7164 7164
         $_course = api_get_course_info();
7165 7165
         $user_id = intval($user_id);
7166 7166
         $course_id = intval($course_id);
7167 7167
 
7168
-    	if (substr($view,2,1) == '1') {
7169
-    		$sql = "SELECT u.upload_date, w.title, w.author, w.url
7168
+        if (substr($view,2,1) == '1') {
7169
+            $sql = "SELECT u.upload_date, w.title, w.author, w.url
7170 7170
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
7171 7171
                     WHERE
7172 7172
                         u.upload_work_id = w.id AND
7173 7173
                         u.upload_user_id = '$user_id' AND
7174 7174
                         u.c_id = '$course_id'
7175 7175
                     ORDER BY u.upload_date DESC";
7176
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
7177
-
7178
-    		$title[1]=get_lang('WorksDetails');
7179
-    		$line='';
7180
-    		$title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7181
-
7182
-    		if (is_array($results)) {
7183
-    			for($j = 0 ; $j < count($results) ; $j++) {
7184
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7185
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7186
-    				$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7187
-    			}
7188
-
7189
-    		} else {
7190
-    			$line= get_lang('NoResult');
7191
-    		}
7192
-    	}
7193
-    	return array($title_line, $line);
7176
+            $results = StatsUtils::getManyResultsXCol($sql,4);
7177
+
7178
+            $title[1]=get_lang('WorksDetails');
7179
+            $line='';
7180
+            $title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7181
+
7182
+            if (is_array($results)) {
7183
+                for($j = 0 ; $j < count($results) ; $j++) {
7184
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7185
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7186
+                    $line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7187
+                }
7188
+
7189
+            } else {
7190
+                $line= get_lang('NoResult');
7191
+            }
7192
+        }
7193
+        return array($title_line, $line);
7194 7194
     }
7195 7195
 
7196 7196
     /**
@@ -7199,32 +7199,32 @@  discard block
 block discarded – undo
7199 7199
      */
7200 7200
     public function display_links_tracking_info($view, $userId, $courseCode)
7201 7201
     {
7202
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7202
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7203 7203
         $courseId = api_get_course_int_id($courseCode);
7204 7204
         $userId = intval($userId);
7205 7205
         $line = null;
7206
-    	if (substr($view,3,1) == '1') {
7207
-    		$new_view = substr_replace($view,'0',3,1);
7208
-    		$title[1]=get_lang('LinksDetails');
7209
-    		$sql = "SELECT cl.title, cl.url
7206
+        if (substr($view,3,1) == '1') {
7207
+            $new_view = substr_replace($view,'0',3,1);
7208
+            $title[1]=get_lang('LinksDetails');
7209
+            $sql = "SELECT cl.title, cl.url
7210 7210
                         FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7211 7211
                         WHERE sl.links_link_id = cl.id
7212 7212
                             AND sl.c_id = $courseId
7213 7213
                             AND sl.links_user_id = $userId
7214 7214
                         GROUP BY cl.title, cl.url";
7215
-    		$results = StatsUtils::getManyResults2Col($sql);
7216
-    		$title_line= get_lang('LinksTitleLinkColumn')."\n";
7217
-    		if (is_array($results)) {
7218
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7219
-    				$line .= $results[$j][0]."\n";
7220
-    			}
7221
-    		} else {
7222
-    			$line=get_lang('NoResult');
7223
-    		}
7224
-    	} else {
7225
-    		$new_view = substr_replace($view,'1',3,1);
7226
-    	}
7227
-    	return array($title_line, $line);
7215
+            $results = StatsUtils::getManyResults2Col($sql);
7216
+            $title_line= get_lang('LinksTitleLinkColumn')."\n";
7217
+            if (is_array($results)) {
7218
+                for ($j = 0 ; $j < count($results) ; $j++) {
7219
+                    $line .= $results[$j][0]."\n";
7220
+                }
7221
+            } else {
7222
+                $line=get_lang('NoResult');
7223
+            }
7224
+        } else {
7225
+            $new_view = substr_replace($view,'1',3,1);
7226
+        }
7227
+        return array($title_line, $line);
7228 7228
     }
7229 7229
 
7230 7230
     /**
@@ -7237,38 +7237,38 @@  discard block
 block discarded – undo
7237 7237
      */
7238 7238
     public function display_document_tracking_info($view, $user_id, $courseCode, $session_id = 0)
7239 7239
     {
7240
-    	// protect data
7241
-    	$user_id     = intval($user_id);
7240
+        // protect data
7241
+        $user_id     = intval($user_id);
7242 7242
         $courseId = api_get_course_int_id($courseCode);
7243
-    	$session_id = intval($session_id);
7243
+        $session_id = intval($session_id);
7244 7244
 
7245
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7245
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7246 7246
 
7247
-    	if (substr($view,4,1) == '1') {
7248
-    		$new_view = substr_replace($view,'0',4,1);
7249
-    		$title[1]= get_lang('DocumentsDetails');
7247
+        if (substr($view,4,1) == '1') {
7248
+            $new_view = substr_replace($view,'0',4,1);
7249
+            $title[1]= get_lang('DocumentsDetails');
7250 7250
 
7251
-    		$sql = "SELECT down_doc_path
7251
+            $sql = "SELECT down_doc_path
7252 7252
                         FROM $downloads_table
7253 7253
                         WHERE c_id = $courseId
7254 7254
                             AND down_user_id = $user_id
7255 7255
                             AND down_session_id = $session_id
7256 7256
                         GROUP BY down_doc_path";
7257 7257
 
7258
-    		$results = StatsUtils::getManyResults1Col($sql);
7259
-    		$title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7258
+            $results = StatsUtils::getManyResults1Col($sql);
7259
+            $title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7260 7260
             $line = null;
7261
-    		if (is_array($results)) {
7262
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7263
-    				$line .= $results[$j]."\n";
7264
-    			}
7265
-    		} else {
7266
-    			$line = get_lang('NoResult');
7267
-    		}
7268
-    	} else {
7269
-    		$new_view = substr_replace($view,'1',4,1);
7270
-    	}
7271
-    	return array($title_line, $line);
7261
+            if (is_array($results)) {
7262
+                for ($j = 0 ; $j < count($results) ; $j++) {
7263
+                    $line .= $results[$j]."\n";
7264
+                }
7265
+            } else {
7266
+                $line = get_lang('NoResult');
7267
+            }
7268
+        } else {
7269
+            $new_view = substr_replace($view,'1',4,1);
7270
+        }
7271
+        return array($title_line, $line);
7272 7272
     }
7273 7273
 
7274 7274
     /**
Please login to merge, or discard this patch.
main/mySpace/current_courses.php 1 patch
Indentation   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 $filename = 'reporting.xls';
13 13
 
14 14
 if (!api_is_allowed_to_create_course()) {
15
-	api_not_allowed(true);
15
+    api_not_allowed(true);
16 16
 }
17 17
 
18 18
 $user_id = api_get_user_id();
@@ -23,222 +23,222 @@  discard block
 block discarded – undo
23 23
 $session_id = 0;
24 24
 
25 25
 if (!empty($my_courses)) {
26
-	foreach ($my_courses as $course) {
27
-		$course_code = $course['code'];
28
-		$course_id = $course['real_id'];
29
-		$course_info = api_get_course_info($course_code);
30
-
31
-		//Only show open courses
32
-		if ($course_info['visibility'] == 0) {
33
-			continue;
34
-		}
35
-
36
-		$teachers = CourseManager::get_teacher_list_from_course_code($course_code);
37
-		$teacher_list =  array();
38
-
39
-		if (!empty($teachers)) {
40
-			foreach($teachers as $teacher) {
41
-				$teacher_list[]= $teacher['firstname'].' '.$teacher['lastname'];
42
-			}
43
-		}
44
-
45
-		$tmp_students = CourseManager :: get_student_list_from_course_code($course_code, false);
46
-
47
-		//Cleaning students only REAL students
48
-		$students = array();
49
-		foreach ($tmp_students  as $student) {
50
-			$user_info = api_get_user_info($student['user_id']);
51
-			if ($user_info['status'] != STUDENT) {
52
-				continue;
53
-			}
54
-			$students[] = $student['user_id'];
55
-		}
56
-
57
-		$t_lp 	= Database :: get_course_table(TABLE_LP_MAIN);
58
-		$sql_lp = "SELECT lp.name, lp.id FROM $t_lp lp
26
+    foreach ($my_courses as $course) {
27
+        $course_code = $course['code'];
28
+        $course_id = $course['real_id'];
29
+        $course_info = api_get_course_info($course_code);
30
+
31
+        //Only show open courses
32
+        if ($course_info['visibility'] == 0) {
33
+            continue;
34
+        }
35
+
36
+        $teachers = CourseManager::get_teacher_list_from_course_code($course_code);
37
+        $teacher_list =  array();
38
+
39
+        if (!empty($teachers)) {
40
+            foreach($teachers as $teacher) {
41
+                $teacher_list[]= $teacher['firstname'].' '.$teacher['lastname'];
42
+            }
43
+        }
44
+
45
+        $tmp_students = CourseManager :: get_student_list_from_course_code($course_code, false);
46
+
47
+        //Cleaning students only REAL students
48
+        $students = array();
49
+        foreach ($tmp_students  as $student) {
50
+            $user_info = api_get_user_info($student['user_id']);
51
+            if ($user_info['status'] != STUDENT) {
52
+                continue;
53
+            }
54
+            $students[] = $student['user_id'];
55
+        }
56
+
57
+        $t_lp 	= Database :: get_course_table(TABLE_LP_MAIN);
58
+        $sql_lp = "SELECT lp.name, lp.id FROM $t_lp lp
59 59
 				   WHERE c_id = $course_id AND lp.session_id = 0";
60
-		$rs_lp 	= Database::query($sql_lp);
61
-		$t_lpi 	= Database :: get_course_table(TABLE_LP_ITEM);
62
-		$t_news = Database :: get_course_table(TABLE_ANNOUNCEMENT);
63
-
64
-		$total_tools_list = Tracking::get_tools_most_used_by_course(
65
-			$course_id,
66
-			$session_id
67
-		);
68
-
69
-		$total_tools = 0;
70
-		foreach($total_tools_list as $tool) {
71
-			$total_tools += $tool['count_access_tool'];
72
-		}
73
-
74
-		if (Database :: num_rows($rs_lp) > 0) {
75
-			while ($learnpath = Database :: fetch_array($rs_lp)) {
76
-				$lp_id = $learnpath['id'];
77
-
78
-				$lp_items =
79
-				$array[$i]['lp'] = '<a href="'.api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?cidReq='.$course_code.'&amp;action=view&amp;lp_id='.$lp_id.'" target="_blank">'.$learnpath['name'].'</a>';
80
-
81
-				$array[$i]['teachers'] = '';
82
-				if (!empty($teacher_list)) {
83
-					$array[$i]['teachers'] = implode(', ', $teacher_list);
84
-				}
85
-
86
-				$array[$i]['course_name'] = $course['title'];
87
-				$count_students_accessing = 0;
88
-				$count_students_complete_all_activities = 0;
89
-				$count_students_complete_all_activities_at_50 = 0;
90
-				$total_time_spent = 0;
91
-				$total_average_progress = 0;
92
-
93
-				if (!empty($students)) {
94
-					foreach ($students  as $student_id) {
95
-						$avg_student_progress   = Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id), $session_id);
96
-						$myavg_temp 			= Tracking::get_avg_student_score($student_id, $course_code, array($lp_id), $session_id);
97
-						$avg_progress_in_course = Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id), $session_id);
98
-
99
-						if (intval($avg_progress_in_course) == 100) {
100
-							$count_students_complete_all_activities++;
101
-						}
102
-						if (intval($avg_progress_in_course) > 0 && intval($avg_progress_in_course) <= 50) {
103
-							$count_students_complete_all_activities_at_50 ++;
104
-						}
105
-						$total_average_progress +=$avg_progress_in_course;
106
-
107
-						$time_spent = Tracking::get_time_spent_on_the_course($student_id, $course_id, $session_id);
108
-						$total_time_spent += $time_spent;
109
-						if (!empty($time_spent)) {
110
-							$count_students_accessing++;
111
-						}
112
-					}
113
-					//$total_tools += $nb_assignments +  $messages + $links + $chat_last_connection + $documents;
114
-				}
115
-
116
-				$student_count = count($students);
117
-
118
-				$array[$i]['count_students'] = $student_count;
119
-				$array[$i]['count_students_accessing'] = 0;
120
-				$array[$i]['count_students_accessing_percentage'] = 0;
121
-				$array[$i]['count_students_complete_all_activities_at_50'] = 0;
122
-				$array[$i]['count_students_complete_all_activities'] = 0;
123
-				$array[$i]['average_percentage_activities_completed_per_student'] = 0;
124
-				$array[$i]['total_time_spent'] = 0;
125
-				$array[$i]['average_time_spent_per_student'] = 0;
126
-				$array[$i]['total_time_spent'] = 0;
127
-				$array[$i]['average_time_spent_per_student'] = 0;
128
-				//$array[$i]['tools_used'] = 0;
129
-				$array[$i]['learnpath_docs'] = 0;
130
-				$array[$i]['learnpath_exercises'] = 0;
131
-				$array[$i]['learnpath_links'] = 0;
132
-				$array[$i]['learnpath_forums'] = 0;
133
-				$array[$i]['learnpath_assignments'] = 0;
134
-
135
-				//registering the number of each category of
136
-				//items in learning path
137
-				$sql_lpi = "SELECT lpi.item_type FROM $t_lpi lpi
60
+        $rs_lp 	= Database::query($sql_lp);
61
+        $t_lpi 	= Database :: get_course_table(TABLE_LP_ITEM);
62
+        $t_news = Database :: get_course_table(TABLE_ANNOUNCEMENT);
63
+
64
+        $total_tools_list = Tracking::get_tools_most_used_by_course(
65
+            $course_id,
66
+            $session_id
67
+        );
68
+
69
+        $total_tools = 0;
70
+        foreach($total_tools_list as $tool) {
71
+            $total_tools += $tool['count_access_tool'];
72
+        }
73
+
74
+        if (Database :: num_rows($rs_lp) > 0) {
75
+            while ($learnpath = Database :: fetch_array($rs_lp)) {
76
+                $lp_id = $learnpath['id'];
77
+
78
+                $lp_items =
79
+                $array[$i]['lp'] = '<a href="'.api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?cidReq='.$course_code.'&amp;action=view&amp;lp_id='.$lp_id.'" target="_blank">'.$learnpath['name'].'</a>';
80
+
81
+                $array[$i]['teachers'] = '';
82
+                if (!empty($teacher_list)) {
83
+                    $array[$i]['teachers'] = implode(', ', $teacher_list);
84
+                }
85
+
86
+                $array[$i]['course_name'] = $course['title'];
87
+                $count_students_accessing = 0;
88
+                $count_students_complete_all_activities = 0;
89
+                $count_students_complete_all_activities_at_50 = 0;
90
+                $total_time_spent = 0;
91
+                $total_average_progress = 0;
92
+
93
+                if (!empty($students)) {
94
+                    foreach ($students  as $student_id) {
95
+                        $avg_student_progress   = Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id), $session_id);
96
+                        $myavg_temp 			= Tracking::get_avg_student_score($student_id, $course_code, array($lp_id), $session_id);
97
+                        $avg_progress_in_course = Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id), $session_id);
98
+
99
+                        if (intval($avg_progress_in_course) == 100) {
100
+                            $count_students_complete_all_activities++;
101
+                        }
102
+                        if (intval($avg_progress_in_course) > 0 && intval($avg_progress_in_course) <= 50) {
103
+                            $count_students_complete_all_activities_at_50 ++;
104
+                        }
105
+                        $total_average_progress +=$avg_progress_in_course;
106
+
107
+                        $time_spent = Tracking::get_time_spent_on_the_course($student_id, $course_id, $session_id);
108
+                        $total_time_spent += $time_spent;
109
+                        if (!empty($time_spent)) {
110
+                            $count_students_accessing++;
111
+                        }
112
+                    }
113
+                    //$total_tools += $nb_assignments +  $messages + $links + $chat_last_connection + $documents;
114
+                }
115
+
116
+                $student_count = count($students);
117
+
118
+                $array[$i]['count_students'] = $student_count;
119
+                $array[$i]['count_students_accessing'] = 0;
120
+                $array[$i]['count_students_accessing_percentage'] = 0;
121
+                $array[$i]['count_students_complete_all_activities_at_50'] = 0;
122
+                $array[$i]['count_students_complete_all_activities'] = 0;
123
+                $array[$i]['average_percentage_activities_completed_per_student'] = 0;
124
+                $array[$i]['total_time_spent'] = 0;
125
+                $array[$i]['average_time_spent_per_student'] = 0;
126
+                $array[$i]['total_time_spent'] = 0;
127
+                $array[$i]['average_time_spent_per_student'] = 0;
128
+                //$array[$i]['tools_used'] = 0;
129
+                $array[$i]['learnpath_docs'] = 0;
130
+                $array[$i]['learnpath_exercises'] = 0;
131
+                $array[$i]['learnpath_links'] = 0;
132
+                $array[$i]['learnpath_forums'] = 0;
133
+                $array[$i]['learnpath_assignments'] = 0;
134
+
135
+                //registering the number of each category of
136
+                //items in learning path
137
+                $sql_lpi = "SELECT lpi.item_type FROM $t_lpi lpi
138 138
 						    WHERE c_id = $course_id AND lpi.lp_id = $lp_id
139 139
 						    ORDER BY item_type";
140
-				$res_lpi = Database::query($sql_lpi);
141
-				while ($row_lpi = Database::fetch_array($res_lpi)) {
142
-					switch($row_lpi['item_type']) {
143
-						case 'document':
144
-							$array[$i]['learnpath_docs']++;
145
-							break;
146
-						case 'quiz':
147
-							$array[$i]['learnpath_exercises']++;
148
-							break;
149
-						case 'link':
150
-							$array[$i]['learnpath_links']++;
151
-							break;
152
-						case 'forum':
153
-						case 'thread':
154
-							$array[$i]['learnpath_forums']++;
155
-							break;
156
-						case 'student_publication':
157
-							$array[$i]['learnpath_assignments']++;
158
-							break;
159
-					}
160
-				}
161
-				// Count announcements
162
-				$array[$i]['total_announcements'] = 0;
163
-				$sql_news = "SELECT count(id) FROM $t_news WHERE c_id = $course_id ";
164
-				$res_news = Database::query($sql_news);
165
-				while ($row_news = Database::fetch_array($res_news)) {
166
-					$array[$i]['total_announcements'] = $row_news[0];
167
-				}
168
-
169
-				//@todo don't know what means this value
170
-				$count_students_complete_all_activities_at_50 = 0;
171
-
172
-				if (!empty($student_count)) {
173
-					$array[$i]['count_students_accessing'] = $count_students_accessing;
174
-					$array[$i]['count_students_accessing_percentage'] = round($count_students_accessing / $student_count *100 , 0);
175
-					$array[$i]['count_students_complete_all_activities_at_50'] = $count_students_complete_all_activities;
176
-					$array[$i]['count_students_complete_all_activities'] = round($count_students_complete_all_activities / $student_count *100 , 0);;
177
-					$array[$i]['average_percentage_activities_completed_per_student'] = round($count_students_complete_all_activities/$student_count*100,2);
178
-					$array[$i]['total_time_spent'] = 0;
179
-					$array[$i]['average_time_spent_per_student'] = 0;
180
-
181
-					if (!empty($total_time_spent)) {
182
-						$array[$i]['total_time_spent'] = api_time_to_hms($total_time_spent);
183
-						$array[$i]['average_time_spent_per_student'] = api_time_to_hms($total_time_spent / $student_count);
184
-					}
185
-					//$array[$i]['tools_used'] = $total_tools;
186
-				}
187
-				$i++;
188
-			}
189
-		}
190
-	}
140
+                $res_lpi = Database::query($sql_lpi);
141
+                while ($row_lpi = Database::fetch_array($res_lpi)) {
142
+                    switch($row_lpi['item_type']) {
143
+                        case 'document':
144
+                            $array[$i]['learnpath_docs']++;
145
+                            break;
146
+                        case 'quiz':
147
+                            $array[$i]['learnpath_exercises']++;
148
+                            break;
149
+                        case 'link':
150
+                            $array[$i]['learnpath_links']++;
151
+                            break;
152
+                        case 'forum':
153
+                        case 'thread':
154
+                            $array[$i]['learnpath_forums']++;
155
+                            break;
156
+                        case 'student_publication':
157
+                            $array[$i]['learnpath_assignments']++;
158
+                            break;
159
+                    }
160
+                }
161
+                // Count announcements
162
+                $array[$i]['total_announcements'] = 0;
163
+                $sql_news = "SELECT count(id) FROM $t_news WHERE c_id = $course_id ";
164
+                $res_news = Database::query($sql_news);
165
+                while ($row_news = Database::fetch_array($res_news)) {
166
+                    $array[$i]['total_announcements'] = $row_news[0];
167
+                }
168
+
169
+                //@todo don't know what means this value
170
+                $count_students_complete_all_activities_at_50 = 0;
171
+
172
+                if (!empty($student_count)) {
173
+                    $array[$i]['count_students_accessing'] = $count_students_accessing;
174
+                    $array[$i]['count_students_accessing_percentage'] = round($count_students_accessing / $student_count *100 , 0);
175
+                    $array[$i]['count_students_complete_all_activities_at_50'] = $count_students_complete_all_activities;
176
+                    $array[$i]['count_students_complete_all_activities'] = round($count_students_complete_all_activities / $student_count *100 , 0);;
177
+                    $array[$i]['average_percentage_activities_completed_per_student'] = round($count_students_complete_all_activities/$student_count*100,2);
178
+                    $array[$i]['total_time_spent'] = 0;
179
+                    $array[$i]['average_time_spent_per_student'] = 0;
180
+
181
+                    if (!empty($total_time_spent)) {
182
+                        $array[$i]['total_time_spent'] = api_time_to_hms($total_time_spent);
183
+                        $array[$i]['average_time_spent_per_student'] = api_time_to_hms($total_time_spent / $student_count);
184
+                    }
185
+                    //$array[$i]['tools_used'] = $total_tools;
186
+                }
187
+                $i++;
188
+            }
189
+        }
190
+    }
191 191
 }
192 192
 
193 193
 $headers = array(
194
-	get_lang('LearningPath'),
195
-	get_lang('Teachers'),
196
-	get_lang('Courses'),
197
-	get_lang('NumberOfStudents'),
198
-	get_lang('NumberStudentsAccessingCourse'),
199
-	get_lang('PercentageStudentsAccessingCourse'),
200
-	get_lang('NumberStudentsCompleteAllActivities'),
201
-	get_lang('PercentageStudentsCompleteAllActivities'),
202
-	get_lang('AverageOfActivitiesCompletedPerStudent'),
203
-	get_lang('TotalTimeSpentInTheCourse'),
204
-	get_lang('AverageTimePerStudentInCourse'),
205
-	get_lang('NumberOfDocumentsInLearnpath'),
206
-	get_lang('NumberOfExercisesInLearnpath'),
207
-	get_lang('NumberOfLinksInLearnpath'),
208
-	get_lang('NumberOfForumsInLearnpath'),
209
-	get_lang('NumberOfAssignmentsInLearnpath'),
210
-	get_lang('NumberOfAnnouncementsInCourse'),
194
+    get_lang('LearningPath'),
195
+    get_lang('Teachers'),
196
+    get_lang('Courses'),
197
+    get_lang('NumberOfStudents'),
198
+    get_lang('NumberStudentsAccessingCourse'),
199
+    get_lang('PercentageStudentsAccessingCourse'),
200
+    get_lang('NumberStudentsCompleteAllActivities'),
201
+    get_lang('PercentageStudentsCompleteAllActivities'),
202
+    get_lang('AverageOfActivitiesCompletedPerStudent'),
203
+    get_lang('TotalTimeSpentInTheCourse'),
204
+    get_lang('AverageTimePerStudentInCourse'),
205
+    get_lang('NumberOfDocumentsInLearnpath'),
206
+    get_lang('NumberOfExercisesInLearnpath'),
207
+    get_lang('NumberOfLinksInLearnpath'),
208
+    get_lang('NumberOfForumsInLearnpath'),
209
+    get_lang('NumberOfAssignmentsInLearnpath'),
210
+    get_lang('NumberOfAnnouncementsInCourse'),
211 211
 );
212 212
 
213 213
 if (isset($_GET['export'])) {
214
-	global $charset;
214
+    global $charset;
215 215
     $spreadsheet = new PHPExcel();
216 216
     $spreadsheet->setActiveSheetIndex(0);
217 217
     $worksheet = $spreadsheet->getActiveSheet();
218 218
 
219
-	$line = 0;
220
-	$column = 0; //skip the first column (row titles)
221
-
222
-	foreach ($headers as $header) {
223
-		$worksheet->setCellValueByColumnAndRow($column, $line, $header);
224
-		$column++;
225
-	}
226
-	$line++;
227
-	foreach ($array as $row) {
228
-		$column = 0;
229
-		foreach ($row as $item) {
230
-			$worksheet->setCellValueByColumnAndRow($column, $line, html_entity_decode(strip_tags($item)));
231
-			$column++;
232
-		}
233
-		$line++;
234
-	}
235
-	$line++;
219
+    $line = 0;
220
+    $column = 0; //skip the first column (row titles)
221
+
222
+    foreach ($headers as $header) {
223
+        $worksheet->setCellValueByColumnAndRow($column, $line, $header);
224
+        $column++;
225
+    }
226
+    $line++;
227
+    foreach ($array as $row) {
228
+        $column = 0;
229
+        foreach ($row as $item) {
230
+            $worksheet->setCellValueByColumnAndRow($column, $line, html_entity_decode(strip_tags($item)));
231
+            $column++;
232
+        }
233
+        $line++;
234
+    }
235
+    $line++;
236 236
 
237 237
     $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename);
238 238
     $writer = new PHPExcel_Writer_Excel2007($spreadsheet);
239 239
     $writer->save($file);
240 240
     DocumentManager::file_send_for_download($file, true, $filename);
241
-	exit;
241
+    exit;
242 242
 }
243 243
 
244 244
 $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('MySpace'));
@@ -249,20 +249,20 @@  discard block
 block discarded – undo
249 249
 $row = 0;
250 250
 $column = 0;
251 251
 foreach ($headers as $header) {
252
-	$table->setHeaderContents($row, $column, $header);
253
-	$column++;
252
+    $table->setHeaderContents($row, $column, $header);
253
+    $column++;
254 254
 }
255 255
 $row++;
256 256
 
257 257
 foreach ($array as $row_table) {
258
-	$column = 0;
259
-	foreach ($row_table as $cell) {
260
-		$table->setCellContents($row, $column, $cell);
261
-		//$table->updateCellAttributes($row, $column, 'align="center"');
262
-		$column++;
263
-	}
264
-	$table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
265
-	$row++;
258
+    $column = 0;
259
+    foreach ($row_table as $cell) {
260
+        $table->setCellContents($row, $column, $cell);
261
+        //$table->updateCellAttributes($row, $column, 'align="center"');
262
+        $column++;
263
+    }
264
+    $table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
265
+    $row++;
266 266
 }
267 267
 
268 268
 echo '<div class="actions">';
Please login to merge, or discard this patch.