Completed
Push — 1.11.x ( 4463da...cd5efc )
by José
55:32 queued 28:22
created
main/inc/lib/usermanager.lib.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
         $connection = Database::getManager()->getConnection();
723 723
         $tableExists = $connection->getSchemaManager()->tablesExist(['plugin_bbb_room']);
724 724
         if ($tableExists) {
725
-             // Delete user from database
725
+                // Delete user from database
726 726
             $sql = "DELETE FROM plugin_bbb_room WHERE participant_id = $user_id";
727 727
             Database::query($sql);
728 728
         }
@@ -1343,13 +1343,13 @@  discard block
 block discarded – undo
1343 1343
     }
1344 1344
 
1345 1345
     /**
1346
-    * Get the users by ID
1347
-    * @param array $ids student ids
1348
-    * @param string $active
1349
-    * @param string $order
1350
-    * @param string $limit
1351
-    * @return array $result student information
1352
-    */
1346
+     * Get the users by ID
1347
+     * @param array $ids student ids
1348
+     * @param string $active
1349
+     * @param string $order
1350
+     * @param string $limit
1351
+     * @return array $result student information
1352
+     */
1353 1353
     public static function get_user_list_by_ids($ids = array(), $active = null, $order = null, $limit = null)
1354 1354
     {
1355 1355
         if (empty($ids)) {
@@ -2510,7 +2510,7 @@  discard block
 block discarded – undo
2510 2510
      *
2511 2511
      * @return array with extra data info of a user i.e array('field_variable'=>'value');
2512 2512
      */
2513
-     public static function get_extra_user_data_by_value($variable, $value, $all_visibility = true)
2513
+        public static function get_extra_user_data_by_value($variable, $value, $all_visibility = true)
2514 2514
     {
2515 2515
         $extraFieldValue = new ExtraFieldValue('user');
2516 2516
         $extraField = new ExtraField('user');
@@ -3650,12 +3650,12 @@  discard block
 block discarded – undo
3650 3650
         if ($tag_id == 0) {
3651 3651
             //the tag doesn't exist
3652 3652
             $sql = "INSERT INTO $table_user_tag (tag, field_id,count) VALUES ('$tag','$field_id', count + 1)";
3653
-             Database::query($sql);
3653
+                Database::query($sql);
3654 3654
             $last_insert_id = Database::insert_id();
3655 3655
         } else {
3656 3656
             //the tag exists we update it
3657 3657
             $sql = "UPDATE $table_user_tag SET count = count + 1 WHERE id  = $tag_id";
3658
-             Database::query($sql);
3658
+                Database::query($sql);
3659 3659
             $last_insert_id = $tag_id;
3660 3660
         }
3661 3661
 
@@ -3850,9 +3850,9 @@  discard block
 block discarded – undo
3850 3850
     }
3851 3851
 
3852 3852
     /**
3853
-      * Get extra filtrable user fields (only type select)
3854
-      * @return array
3855
-      */
3853
+     * Get extra filtrable user fields (only type select)
3854
+     * @return array
3855
+     */
3856 3856
     public static function get_extra_filtrable_fields()
3857 3857
     {
3858 3858
         $extraFieldList = UserManager::get_extra_fields();
@@ -3877,9 +3877,9 @@  discard block
 block discarded – undo
3877 3877
     }
3878 3878
 
3879 3879
     /**
3880
-      * Get extra where clauses for finding users based on extra filtrable user fields (type select)
3881
-      * @return string With AND clauses based on user's ID which have the values to search in extra user fields
3882
-      */
3880
+     * Get extra where clauses for finding users based on extra filtrable user fields (type select)
3881
+     * @return string With AND clauses based on user's ID which have the values to search in extra user fields
3882
+     */
3883 3883
     public static function get_search_form_where_extra_fields()
3884 3884
     {
3885 3885
         $useExtraFields = false;
@@ -4198,23 +4198,23 @@  discard block
 block discarded – undo
4198 4198
     }
4199 4199
 
4200 4200
     /**
4201
-    * Get users followed by human resource manager
4202
-    * @param int $userId
4203
-    * @param int  $userStatus Filter users by status (STUDENT, COURSEMANAGER, etc)
4204
-    * @param bool $getOnlyUserId
4205
-    * @param bool $getSql
4206
-    * @param bool $getCount
4207
-    * @param int $from
4208
-    * @param int $numberItems
4209
-    * @param int $column
4210
-    * @param string $direction
4211
-    * @param int $active
4212
-    * @param string $lastConnectionDate
4213
-    * @param int $status the function is called by who? COURSEMANAGER, DRH?
4214
-    * @param string $keyword
4201
+     * Get users followed by human resource manager
4202
+     * @param int $userId
4203
+     * @param int  $userStatus Filter users by status (STUDENT, COURSEMANAGER, etc)
4204
+     * @param bool $getOnlyUserId
4205
+     * @param bool $getSql
4206
+     * @param bool $getCount
4207
+     * @param int $from
4208
+     * @param int $numberItems
4209
+     * @param int $column
4210
+     * @param string $direction
4211
+     * @param int $active
4212
+     * @param string $lastConnectionDate
4213
+     * @param int $status the function is called by who? COURSEMANAGER, DRH?
4214
+     * @param string $keyword
4215 4215
      *
4216
-    * @return array user list
4217
-    */
4216
+     * @return array user list
4217
+     */
4218 4218
     public static function getUsersFollowedByUser(
4219 4219
         $userId,
4220 4220
         $userStatus = null,
Please login to merge, or discard this patch.
main/exercise/exercise_submit.php 1 patch
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     if (!$objExercise->read($exerciseId) ||
125 125
         (!$objExercise->selectStatus() && !$is_allowedToEdit && $origin != 'learnpath')
126 126
     ) {
127
-    	if ($debug) {error_log('1.1. Error while reading the exercise'); };
127
+        if ($debug) {error_log('1.1. Error while reading the exercise'); };
128 128
         unset ($objExercise);
129 129
         $error = get_lang('ExerciseNotFound');
130 130
     } else {
@@ -137,13 +137,13 @@  discard block
 block discarded – undo
137 137
 }
138 138
 //2. Checking if $objExercise is set
139 139
 if (!isset($objExercise) && isset($exerciseInSession)) {
140
-	if ($debug) { error_log('2. Loading $objExercise from session'); };
140
+    if ($debug) { error_log('2. Loading $objExercise from session'); };
141 141
     $objExercise = $exerciseInSession;
142 142
 }
143 143
 
144 144
 //3. $objExercise is not set, then return to the exercise list
145 145
 if (!is_object($objExercise)) {
146
-	if ($debug) {error_log('3. $objExercise was not set, kill the script'); };
146
+    if ($debug) {error_log('3. $objExercise was not set, kill the script'); };
147 147
     header('Location: exercise.php');
148 148
     exit;
149 149
 }
@@ -322,19 +322,19 @@  discard block
 block discarded – undo
322 322
         $total_weight += floatval($objQuestionTmp->weighting);
323 323
     }
324 324
 
325
-	if ($time_control) {
326
-		$expected_time = $current_timestamp + $total_seconds;
325
+    if ($time_control) {
326
+        $expected_time = $current_timestamp + $total_seconds;
327 327
 
328
-		if ($debug)  error_log('5.1. $current_timestamp '.$current_timestamp);
329
-		if ($debug)  error_log('5.2. $expected_time '.$expected_time);
328
+        if ($debug)  error_log('5.1. $current_timestamp '.$current_timestamp);
329
+        if ($debug)  error_log('5.2. $expected_time '.$expected_time);
330 330
 
331
-		$clock_expired_time 	= api_get_utc_datetime($expected_time);
332
-		if ($debug) error_log('5.3. $expected_time '.$clock_expired_time);
331
+        $clock_expired_time 	= api_get_utc_datetime($expected_time);
332
+        if ($debug) error_log('5.3. $expected_time '.$clock_expired_time);
333 333
 
334
-		//Sessions  that contain the expired time
335
-		$_SESSION['expired_time'][$current_expired_time_key] 	 = $clock_expired_time;
336
-		if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
337
-	}
334
+        //Sessions  that contain the expired time
335
+        $_SESSION['expired_time'][$current_expired_time_key] 	 = $clock_expired_time;
336
+        if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
337
+    }
338 338
 
339 339
     $exe_id = $objExercise->save_stat_track_exercise_info(
340 340
         $clock_expired_time,
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
     );
352 352
     if ($debug)  error_log("5.5  exercise_stat_info[] exists getting exe_id $exe_id");
353 353
 } else {
354
-	$exe_id = $exercise_stat_info['exe_id'];
354
+    $exe_id = $exercise_stat_info['exe_id'];
355 355
     // Remember last question id position.
356 356
     $isFirstTime = Session::read('firstTime');
357 357
 
@@ -411,9 +411,9 @@  discard block
 block discarded – undo
411 411
 if ($debug) { error_log('6. $objExercise->get_stat_track_exercise_info function called::  '.print_r($exercise_stat_info, 1)); };
412 412
 
413 413
 if (!empty($exercise_stat_info['questions_to_check'])) {
414
-	$my_remind_list = $exercise_stat_info['questions_to_check'];
415
-	$my_remind_list = explode(',', $my_remind_list);
416
-	$my_remind_list = array_filter($my_remind_list);
414
+    $my_remind_list = $exercise_stat_info['questions_to_check'];
415
+    $my_remind_list = explode(',', $my_remind_list);
416
+    $my_remind_list = array_filter($my_remind_list);
417 417
 }
418 418
 
419 419
 $params = "exe_id=$exe_id&exerciseId=$exerciseId&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id&".api_get_cidreq();
@@ -421,8 +421,8 @@  discard block
 block discarded – undo
421 421
 
422 422
 if ($reminder == 2 && empty($my_remind_list)) {
423 423
     if ($debug) { error_log("6.2 calling the exercise_reminder.php "); };
424
-	header('Location: exercise_reminder.php?'.$params);
425
-	exit;
424
+    header('Location: exercise_reminder.php?'.$params);
425
+    exit;
426 426
 }
427 427
 
428 428
 /*
@@ -430,56 +430,56 @@  discard block
 block discarded – undo
430 430
  * If the expired time is major that zero(0) then the expired time is compute on this time.
431 431
  */
432 432
 if ($time_control) {
433
-	if ($debug) error_log('7.1. Time control is enabled');
434
-	if ($debug) error_log('7.2. $current_expired_time_key  '.$current_expired_time_key);
435
-	if ($debug) error_log('7.3. $_SESSION[expired_time][$current_expired_time_key]  '.$_SESSION['expired_time'][$current_expired_time_key]);
433
+    if ($debug) error_log('7.1. Time control is enabled');
434
+    if ($debug) error_log('7.2. $current_expired_time_key  '.$current_expired_time_key);
435
+    if ($debug) error_log('7.3. $_SESSION[expired_time][$current_expired_time_key]  '.$_SESSION['expired_time'][$current_expired_time_key]);
436 436
 
437 437
     if (!isset($_SESSION['expired_time'][$current_expired_time_key])) {
438 438
         //Timer - Get expired_time for a student
439 439
         if (!empty($exercise_stat_info)) {
440
-        	if ($debug) {error_log('7.4 Seems that the session ends and the user want to retake the exam'); };
441
-	        $expired_time_of_this_attempt = $exercise_stat_info['expired_time_control'];
442
-			if ($debug) {error_log('7.5 $expired_time_of_this_attempt: '.$expired_time_of_this_attempt); }
443
-	        // Get the last attempt of an exercise
444
-	    	$last_attempt_date = Event::getLastAttemptDateOfExercise($exercise_stat_info['exe_id']);
440
+            if ($debug) {error_log('7.4 Seems that the session ends and the user want to retake the exam'); };
441
+            $expired_time_of_this_attempt = $exercise_stat_info['expired_time_control'];
442
+            if ($debug) {error_log('7.5 $expired_time_of_this_attempt: '.$expired_time_of_this_attempt); }
443
+            // Get the last attempt of an exercise
444
+            $last_attempt_date = Event::getLastAttemptDateOfExercise($exercise_stat_info['exe_id']);
445 445
 
446
-	    	/* This means that the user enters the exam but do not answer the
446
+            /* This means that the user enters the exam but do not answer the
447 447
 	    	   first question we get the date from the track_e_exercises not from
448 448
 	    	   the track_et_attempt see #2069 */
449
-	    	if (empty($last_attempt_date)) {
450
-	    		$diff = $current_timestamp - api_strtotime($exercise_stat_info['start_date'], 'UTC');
451
-	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'],'UTC') + $diff);
452
-	    	} else {
453
-	    		//Recalculate the time control due #2069
454
-	    		$diff = $current_timestamp - api_strtotime($last_attempt_date,'UTC');
455
-	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date,'UTC') + $diff);
456
-	    	}
457
-	        if ($debug) {error_log('7.6. $last_attempt_date: '.$last_attempt_date); }
458
-
459
-	        //New expired time - it is due to the possible closure of session
460
-	        $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date,'UTC');
461
-	        if ($debug) {error_log('7.7. $new_expired_time_in_seconds: '.$new_expired_time_in_seconds); }
462
-
463
-	        $expected_time	= $current_timestamp + $new_expired_time_in_seconds;
464
-	        if ($debug) {error_log('7.8. $expected_time1: '.$expected_time); }
465
-
466
-	        $clock_expired_time  = api_get_utc_datetime($expected_time);
467
-	        if ($debug) {error_log('7.9. $clock_expired_time: '.$clock_expired_time); }
468
-
469
-			// First we update the attempt to today
470
-			/* How the expired time is changed into "track_e_exercises" table,
449
+            if (empty($last_attempt_date)) {
450
+                $diff = $current_timestamp - api_strtotime($exercise_stat_info['start_date'], 'UTC');
451
+                $last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'],'UTC') + $diff);
452
+            } else {
453
+                //Recalculate the time control due #2069
454
+                $diff = $current_timestamp - api_strtotime($last_attempt_date,'UTC');
455
+                $last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date,'UTC') + $diff);
456
+            }
457
+            if ($debug) {error_log('7.6. $last_attempt_date: '.$last_attempt_date); }
458
+
459
+            //New expired time - it is due to the possible closure of session
460
+            $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date,'UTC');
461
+            if ($debug) {error_log('7.7. $new_expired_time_in_seconds: '.$new_expired_time_in_seconds); }
462
+
463
+            $expected_time	= $current_timestamp + $new_expired_time_in_seconds;
464
+            if ($debug) {error_log('7.8. $expected_time1: '.$expected_time); }
465
+
466
+            $clock_expired_time  = api_get_utc_datetime($expected_time);
467
+            if ($debug) {error_log('7.9. $clock_expired_time: '.$clock_expired_time); }
468
+
469
+            // First we update the attempt to today
470
+            /* How the expired time is changed into "track_e_exercises" table,
471 471
                then the last attempt for this student should be changed too */
472
-	        $sql = "UPDATE $exercise_attempt_table SET
472
+            $sql = "UPDATE $exercise_attempt_table SET
473 473
 	                tms = '".api_get_utc_datetime()."'
474 474
 	                WHERE
475 475
 	                    exe_id = '".$exercise_stat_info['exe_id']."' AND
476 476
 	                    tms = '".$last_attempt_date."' ";
477
-	        if ($debug) {error_log('7.10. $sql: '.$sql); }
478
-	        Database::query($sql);
477
+            if ($debug) {error_log('7.10. $sql: '.$sql); }
478
+            Database::query($sql);
479 479
 
480
-	        //Sessions  that contain the expired time
481
-	        $_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
482
-	        if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
480
+            //Sessions  that contain the expired time
481
+            $_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
482
+            if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
483 483
         }
484 484
     } else {
485 485
         $clock_expired_time = $_SESSION['expired_time'][$current_expired_time_key];
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
  * for more details of how it works see this link : http://eric.garside.name/docs.html?p=epiclock
497 497
  */
498 498
 if ($time_control) { //Sends the exercise form when the expired time is finished
499
-	$htmlHeadXtra[] = $objExercise->show_time_control_js($time_left);
499
+    $htmlHeadXtra[] = $objExercise->show_time_control_js($time_left);
500 500
 }
501 501
 
502 502
 //in LP's is enabled the "remember question" feature?
@@ -504,14 +504,14 @@  discard block
 block discarded – undo
504 504
     // selects the list of question ID
505 505
     $questionList = $objExercise->get_validated_question_list();
506 506
     if ($objExercise->isRandom() && !empty($exercise_stat_info['data_tracking'])) {
507
-    	$questionList = explode(',', $exercise_stat_info['data_tracking']);
507
+        $questionList = explode(',', $exercise_stat_info['data_tracking']);
508 508
     }
509 509
     Session::write('questionList', $questionList);
510 510
     if ($debug > 0) { error_log('$_SESSION[questionList] was set'); }
511 511
 } else {
512
-	if (isset($objExercise) && isset($_SESSION['objExercise'])) {
513
-    	$questionList = $_SESSION['questionList'];
514
-	}
512
+    if (isset($objExercise) && isset($_SESSION['objExercise'])) {
513
+        $questionList = $_SESSION['questionList'];
514
+    }
515 515
 }
516 516
 
517 517
 if ($debug) error_log('8. Question list loaded '.print_r($questionList, 1));
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 //Real question count
520 520
 $question_count = 0;
521 521
 if (!empty($questionList)) {
522
-	$question_count = count($questionList);
522
+    $question_count = count($questionList);
523 523
 }
524 524
 
525 525
 if ($current_question > $question_count) {
@@ -569,11 +569,11 @@  discard block
 block discarded – undo
569 569
                 //saving each question
570 570
                 if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_DIRECT) {
571 571
                     $nro_question = $current_question; // - 1;
572
-                 	$questionId = $key;
572
+                        $questionId = $key;
573 573
                     // gets the student choice for this question
574 574
                     $choice = $exerciseResult[$questionId];
575 575
                     if (isset($exe_id)) {
576
-                    	// Manage the question and answer attempts
576
+                        // Manage the question and answer attempts
577 577
                         if ($debug) {
578 578
                             error_log('8.3. manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1));
579 579
                         }
@@ -665,58 +665,58 @@  discard block
 block discarded – undo
665 665
 
666 666
 
667 667
 if ($question_count != 0) {
668
-	if (($objExercise->type == ALL_ON_ONE_PAGE ||
668
+    if (($objExercise->type == ALL_ON_ONE_PAGE ||
669 669
         $current_question > $question_count)
670 670
     ) {
671
-	    if (api_is_allowed_to_session_edit()) {
672
-	        // goes to the script that will show the result of the exercise
673
-	        if ($objExercise->type == ALL_ON_ONE_PAGE) {
674
-	            if ($debug) { error_log('12. Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php'); }
675
-
676
-	            //We check if the user attempts before sending to the exercise_result.php
677
-	            if ($objExercise->selectAttempts() > 0) {
678
-	                $attempt_count = Event::get_attempt_count(
671
+        if (api_is_allowed_to_session_edit()) {
672
+            // goes to the script that will show the result of the exercise
673
+            if ($objExercise->type == ALL_ON_ONE_PAGE) {
674
+                if ($debug) { error_log('12. Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php'); }
675
+
676
+                //We check if the user attempts before sending to the exercise_result.php
677
+                if ($objExercise->selectAttempts() > 0) {
678
+                    $attempt_count = Event::get_attempt_count(
679 679
                         api_get_user_id(),
680 680
                         $exerciseId,
681 681
                         $learnpath_id,
682 682
                         $learnpath_item_id,
683 683
                         $learnpath_item_view_id
684 684
                     );
685
-	                if ($attempt_count >= $objExercise->selectAttempts()) {
686
-	                    Display :: display_warning_message(
685
+                    if ($attempt_count >= $objExercise->selectAttempts()) {
686
+                        Display :: display_warning_message(
687 687
                             sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()),
688 688
                             false
689 689
                         );
690
-	                    if ($origin != 'learnpath') {
691
-	                        //so we are not in learnpath tool
692
-	                        echo '</div>'; //End glossary div
693
-	                        Display :: display_footer();
694
-	                    } else {
695
-	                        echo '</body></html>';
696
-	                    }
697
-	                    exit;
698
-	                }
699
-	            }
700
-	        } else {
701
-	            if ($objExercise->review_answers) {
702
-	            	header('Location: exercise_reminder.php?'.$params);
703
-	            	exit;
704
-	            } else {
690
+                        if ($origin != 'learnpath') {
691
+                            //so we are not in learnpath tool
692
+                            echo '</div>'; //End glossary div
693
+                            Display :: display_footer();
694
+                        } else {
695
+                            echo '</body></html>';
696
+                        }
697
+                        exit;
698
+                    }
699
+                }
700
+            } else {
701
+                if ($objExercise->review_answers) {
702
+                    header('Location: exercise_reminder.php?'.$params);
703
+                    exit;
704
+                } else {
705 705
                     header("Location: exercise_result.php?".api_get_cidreq()."&exe_id=$exe_id&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id");
706 706
                     exit;
707
-	            }
708
-	        }
709
-	    } else {
710
-	        if ($debug) { error_log('Redirecting to exercise_submit.php'); }
711
-	        exit;
712
-	    }
713
-	}
707
+                }
708
+            }
709
+        } else {
710
+            if ($debug) { error_log('Redirecting to exercise_submit.php'); }
711
+            exit;
712
+        }
713
+    }
714 714
 } else {
715
-	$error = get_lang('ThereAreNoQuestionsForThisExercise');
716
-	// if we are in the case where user select random by category, but didn't choose the number of random question
717
-	if ($objExercise->selectRandomByCat() > 0 && $objExercise->random <= 0) {
718
-		$error .= "<br/>".get_lang('PleaseSelectSomeRandomQuestion');
719
-	}
715
+    $error = get_lang('ThereAreNoQuestionsForThisExercise');
716
+    // if we are in the case where user select random by category, but didn't choose the number of random question
717
+    if ($objExercise->selectRandomByCat() > 0 && $objExercise->random <= 0) {
718
+        $error .= "<br/>".get_lang('PleaseSelectSomeRandomQuestion');
719
+    }
720 720
 }
721 721
 
722 722
 if (!empty ($_GET['gradebook']) && $_GET['gradebook'] == 'view') {
@@ -755,9 +755,9 @@  discard block
 block discarded – undo
755 755
 if (api_is_course_admin() && $origin != 'learnpath') {
756 756
     echo '<div class="actions">';
757 757
     if ($show_quiz_edition == false) {
758
-    	echo '<a href="exercise_admin.php?' . api_get_cidreq() . '&modifyExercise=yes&exerciseId=' . $objExercise->id . '">'.Display :: return_icon('settings.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
758
+        echo '<a href="exercise_admin.php?' . api_get_cidreq() . '&modifyExercise=yes&exerciseId=' . $objExercise->id . '">'.Display :: return_icon('settings.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
759 759
     } else {
760
-    	echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
760
+        echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
761 761
     }
762 762
     echo '</div>';
763 763
 }
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
             $message_warning = $permission_to_start ? get_lang('ReachedTimeLimit') : get_lang('ExerciseNoStartedYet');
801 801
             Display :: display_warning_message(sprintf($message_warning, $exercise_title, $objExercise->selectAttempts()));
802 802
             if ($origin != 'learnpath') {
803
-            	Display :: display_footer();
803
+                Display :: display_footer();
804 804
             }
805 805
             exit;
806 806
         } else {
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
 if (isset($_custom['exercises_hidden_when_no_start_date']) &&
816 816
     $_custom['exercises_hidden_when_no_start_date']
817 817
 ) {
818
-	if (empty($objExercise->start_time)) {
818
+    if (empty($objExercise->start_time)) {
819 819
         Display:: display_warning_message(
820 820
             sprintf(
821 821
                 get_lang('ExerciseNoStartedYet'),
@@ -823,20 +823,20 @@  discard block
 block discarded – undo
823 823
                 $objExercise->selectAttempts()
824 824
             )
825 825
         );
826
-		if ($origin != 'learnpath') {
827
-			Display :: display_footer();
828
-		}
829
-	}
826
+        if ($origin != 'learnpath') {
827
+            Display :: display_footer();
828
+        }
829
+    }
830 830
 }
831 831
 
832 832
 //Timer control
833 833
 if ($time_control) {
834 834
     echo $objExercise->return_time_left_div();
835
-	echo '<div style="display:none" class="warning-message" id="expired-message-id">'.get_lang('ExerciseExpiredTimeMessage').'</div>';
835
+    echo '<div style="display:none" class="warning-message" id="expired-message-id">'.get_lang('ExerciseExpiredTimeMessage').'</div>';
836 836
 }
837 837
 
838 838
 if ($origin != 'learnpath') {
839
-   echo '<div id="highlight-plugin" class="glossary-content">';
839
+    echo '<div id="highlight-plugin" class="glossary-content">';
840 840
 }
841 841
 
842 842
 if ($reminder == 2)  {
@@ -847,53 +847,53 @@  discard block
 block discarded – undo
847 847
     $current_question = 1; //set by default the 1st question
848 848
 
849 849
     if (!empty($my_remind_list)) {
850
-    	//Checking which questions we are going to call from the remind list
851
-		for ($i = 0; $i < count($data_tracking); $i++) {
852
-			for($j = 0; $j < count($my_remind_list); $j++) {
853
-
854
-				if (!empty($remind_question_id)) {
855
-					if ($remind_question_id == $my_remind_list[$j]) {
856
-
857
-			        	if ($remind_question_id == $data_tracking[$i]) {
858
-			        		if (isset($my_remind_list[$j+1])) {
859
-			        			$remind_question_id = $my_remind_list[$j+1];
860
-			        			$current_question = $i + 1;
861
-			        		} else {
850
+        //Checking which questions we are going to call from the remind list
851
+        for ($i = 0; $i < count($data_tracking); $i++) {
852
+            for($j = 0; $j < count($my_remind_list); $j++) {
853
+
854
+                if (!empty($remind_question_id)) {
855
+                    if ($remind_question_id == $my_remind_list[$j]) {
856
+
857
+                        if ($remind_question_id == $data_tracking[$i]) {
858
+                            if (isset($my_remind_list[$j+1])) {
859
+                                $remind_question_id = $my_remind_list[$j+1];
860
+                                $current_question = $i + 1;
861
+                            } else {
862 862
                                 // We end the remind list we go to the exercise_reminder.php please
863
-			        			$remind_question_id = -1;
864
-			        			$current_question = $i + 1; // last question
865
-			        		}
866
-			        		break 2;
867
-			            }
868
-					}
869
-				} else {
870
-					if ($my_remind_list[$j] == $data_tracking[$i]) {
871
-						if (isset($my_remind_list[$j+1])) {
872
-							$remind_question_id = $my_remind_list[$j+1];
873
-							$current_question = $i + 1; // last question
874
-						} else {
863
+                                $remind_question_id = -1;
864
+                                $current_question = $i + 1; // last question
865
+                            }
866
+                            break 2;
867
+                        }
868
+                    }
869
+                } else {
870
+                    if ($my_remind_list[$j] == $data_tracking[$i]) {
871
+                        if (isset($my_remind_list[$j+1])) {
872
+                            $remind_question_id = $my_remind_list[$j+1];
873
+                            $current_question = $i + 1; // last question
874
+                        } else {
875 875
                             // We end the remind list we go to the exercise_reminder.php please
876
-							$remind_question_id = -1;
877
-							$current_question = $i + 1; // last question
878
-						}
879
-						break 2;
880
-					}
881
-				}
882
-			}
876
+                            $remind_question_id = -1;
877
+                            $current_question = $i + 1; // last question
878
+                        }
879
+                        break 2;
880
+                    }
881
+                }
882
+            }
883 883
         }
884 884
     } else {
885
-    	if ($objExercise->review_answers) {
885
+        if ($objExercise->review_answers) {
886 886
             if ($debug) { error_log('. redirecting to exercise_reminder.php '); }
887
-	    	header("Location: exercise_reminder.php?$params");
888
-	    	exit;
889
-    	}
887
+            header("Location: exercise_reminder.php?$params");
888
+            exit;
889
+        }
890 890
     }
891 891
 }
892 892
 
893 893
 if ($objExercise->review_answers) {
894
-	$script_php = 'exercise_reminder.php';
894
+    $script_php = 'exercise_reminder.php';
895 895
 } else {
896
-	$script_php = 'exercise_result.php';
896
+    $script_php = 'exercise_result.php';
897 897
 }
898 898
 
899 899
 if (!empty($error)) {
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
          <input type="hidden" name="learnpath_item_id" 		value="'.$learnpath_item_id . '" />
1134 1134
          <input type="hidden" name="learnpath_item_view_id" value="'.$learnpath_item_view_id . '" />';
1135 1135
 
1136
-	// Show list of questions
1136
+    // Show list of questions
1137 1137
     $i = 1;
1138 1138
     $attempt_list = [];
1139 1139
     if (isset($exe_id)) {
@@ -1193,10 +1193,10 @@  discard block
 block discarded – undo
1193 1193
 
1194 1194
         $attributes = array('id' =>'remind_list['.$questionId.']');
1195 1195
         if (in_array($questionId, $remind_list)) {
1196
-        	$is_remind_on = true;
1197
-        	$attributes['checked'] = 1;
1198
-        	$remind_question = true;
1199
-        	$remind_highlight = ' remind_highlight ';
1196
+            $is_remind_on = true;
1197
+            $attributes['checked'] = 1;
1198
+            $remind_question = true;
1199
+            $remind_highlight = ' remind_highlight ';
1200 1200
         }
1201 1201
 
1202 1202
         // Showing the exercise description
@@ -1270,8 +1270,8 @@  discard block
 block discarded – undo
1270 1270
     }
1271 1271
     // end foreach()
1272 1272
     if ($objExercise->type == ALL_ON_ONE_PAGE) {
1273
-    	$exercise_actions =  $objExercise->show_button($questionId, $current_question);
1274
-    	echo Display::div($exercise_actions, array('class'=>'exercise_actions'));
1273
+        $exercise_actions =  $objExercise->show_button($questionId, $current_question);
1274
+        echo Display::div($exercise_actions, array('class'=>'exercise_actions'));
1275 1275
         echo '<br>';
1276 1276
     }
1277 1277
     echo '</form>';
Please login to merge, or discard this patch.
main/social/friends.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@
 block discarded – undo
126 126
         while ($j < $number_friends) {
127 127
             if (isset($friends[$j])) {
128 128
                 $friend = $friends[$j];
129
-                 $toolBar = '<button class="btn btn-danger" onclick="delete_friend(this)" id=img_' . $friend['friend_user_id'] . '>
129
+                    $toolBar = '<button class="btn btn-danger" onclick="delete_friend(this)" id=img_' . $friend['friend_user_id'] . '>
130 130
                     ' . get_lang('Delete') . '
131 131
                 </button>';
132 132
                 $url = api_get_path(WEB_PATH).'main/social/profile.php?u='.$friend['friend_user_id'];
Please login to merge, or discard this patch.
main/gradebook/lib/be/forumthreadlink.class.php 1 patch
Indentation   +253 added lines, -253 removed lines patch added patch discarded remove patch
@@ -10,46 +10,46 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class ForumThreadLink extends AbstractLink
12 12
 {
13
-	private $forum_thread_table = null;
14
-	private $itemprop_table = null;
15
-
16
-	/**
17
-	 * Constructor
18
-	 */
19
-	public function __construct()
20
-	{
21
-		parent::__construct();
22
-		$this->set_type(LINK_FORUM_THREAD);
23
-	}
24
-
25
-	/**
26
-	 * @return string
27
-	 */
28
-	public function get_type_name()
29
-	{
30
-		return get_lang('ForumThreads');
31
-	}
32
-
33
-	/**
34
-	 * @return bool
35
-	 */
36
-	public function is_allowed_to_change_name()
37
-	{
38
-		return false;
39
-	}
40
-
41
-	/**
42
-	 * Generate an array of exercises that a teacher hasn't created a link for.
43
-	 * @return array 2-dimensional array - every element contains 2 subelements (id, name)
44
-	 */
45
-	public function get_not_created_links()
46
-	{
47
-		if (empty($this->course_code)) {
48
-			die('Error in get_not_created_links() : course code not set');
49
-		}
50
-
51
-		$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
52
-		$sql = 'SELECT thread_id,thread_title,thread_title_qualify 
13
+    private $forum_thread_table = null;
14
+    private $itemprop_table = null;
15
+
16
+    /**
17
+     * Constructor
18
+     */
19
+    public function __construct()
20
+    {
21
+        parent::__construct();
22
+        $this->set_type(LINK_FORUM_THREAD);
23
+    }
24
+
25
+    /**
26
+     * @return string
27
+     */
28
+    public function get_type_name()
29
+    {
30
+        return get_lang('ForumThreads');
31
+    }
32
+
33
+    /**
34
+     * @return bool
35
+     */
36
+    public function is_allowed_to_change_name()
37
+    {
38
+        return false;
39
+    }
40
+
41
+    /**
42
+     * Generate an array of exercises that a teacher hasn't created a link for.
43
+     * @return array 2-dimensional array - every element contains 2 subelements (id, name)
44
+     */
45
+    public function get_not_created_links()
46
+    {
47
+        if (empty($this->course_code)) {
48
+            die('Error in get_not_created_links() : course code not set');
49
+        }
50
+
51
+        $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
52
+        $sql = 'SELECT thread_id,thread_title,thread_title_qualify 
53 53
 		        FROM '.$this->get_forum_thread_table().'
54 54
 			    forum_thread WHERE thread_id NOT IN
55 55
 			    (
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
                 ) 
61 61
                 AND forum_thread.session_id='.api_get_session_id();
62 62
 
63
-		$result = Database::query($sql);
63
+        $result = Database::query($sql);
64 64
 
65 65
         $cats = array();
66 66
         while ($data = Database::fetch_array($result)) {
@@ -75,29 +75,29 @@  discard block
 block discarded – undo
75 75
         }
76 76
 
77 77
         return $cats;
78
-	}
79
-
80
-	/**
81
-	 * Generate an array of all exercises available.
82
-	 * @return array 2-dimensional array - every element contains 2 subelements (id, name)
83
-	 */
84
-	public function get_all_links()
85
-	{
86
-		if (empty($this->course_code)) {
87
-			die('Error in get_not_created_links() : course code not set');
88
-		}
89
-
90
-		$tbl_grade_links 	= Database :: get_course_table(TABLE_FORUM_THREAD);
91
-		$tbl_item_property	= Database :: get_course_table(TABLE_ITEM_PROPERTY);
92
-		$session_id = api_get_session_id();
93
-
94
-		if ($session_id) {
95
-			$session_condition = 'tl.session_id='.api_get_session_id();
96
-		} else {
97
-			$session_condition = '(tl.session_id = 0 OR tl.session_id IS NULL)';
98
-		}
99
-
100
-		$sql = 'SELECT tl.thread_id, tl.thread_title, tl.thread_title_qualify
78
+    }
79
+
80
+    /**
81
+     * Generate an array of all exercises available.
82
+     * @return array 2-dimensional array - every element contains 2 subelements (id, name)
83
+     */
84
+    public function get_all_links()
85
+    {
86
+        if (empty($this->course_code)) {
87
+            die('Error in get_not_created_links() : course code not set');
88
+        }
89
+
90
+        $tbl_grade_links 	= Database :: get_course_table(TABLE_FORUM_THREAD);
91
+        $tbl_item_property	= Database :: get_course_table(TABLE_ITEM_PROPERTY);
92
+        $session_id = api_get_session_id();
93
+
94
+        if ($session_id) {
95
+            $session_condition = 'tl.session_id='.api_get_session_id();
96
+        } else {
97
+            $session_condition = '(tl.session_id = 0 OR tl.session_id IS NULL)';
98
+        }
99
+
100
+        $sql = 'SELECT tl.thread_id, tl.thread_title, tl.thread_title_qualify
101 101
 				FROM '.$tbl_grade_links.' tl INNER JOIN '.$tbl_item_property.' ip
102 102
 				ON (tl.thread_id = ip.ref AND tl.c_id = ip.c_id)
103 103
 				WHERE
@@ -108,23 +108,23 @@  discard block
 block discarded – undo
108 108
                     '.$session_condition.'
109 109
                 ';
110 110
 
111
-		$result = Database::query($sql);
112
-		while ($data = Database::fetch_array($result)) {
113
-			if ( isset($data['thread_title_qualify']) && $data['thread_title_qualify'] != "") {
114
-				$cats[] = array($data['thread_id'], $data['thread_title_qualify']);
115
-			} else {
116
-				$cats[] = array($data['thread_id'], $data['thread_title']);
117
-			}
118
-		}
119
-		$my_cats = isset($cats) ? $cats : null;
111
+        $result = Database::query($sql);
112
+        while ($data = Database::fetch_array($result)) {
113
+            if ( isset($data['thread_title_qualify']) && $data['thread_title_qualify'] != "") {
114
+                $cats[] = array($data['thread_id'], $data['thread_title_qualify']);
115
+            } else {
116
+                $cats[] = array($data['thread_id'], $data['thread_title']);
117
+            }
118
+        }
119
+        $my_cats = isset($cats) ? $cats : null;
120 120
 
121
-		return $my_cats;
122
-	}
121
+        return $my_cats;
122
+    }
123 123
 
124 124
     /**
125
-    * Has anyone done this exercise yet ?
126
-    * @return boolean
127
-    */
125
+     * Has anyone done this exercise yet ?
126
+     * @return boolean
127
+     */
128 128
     public function has_results()
129 129
     {
130 130
         $table = Database :: get_course_table(TABLE_FORUM_POST);
@@ -138,50 +138,50 @@  discard block
 block discarded – undo
138 138
         $number = Database::fetch_row($result);
139 139
 
140 140
         return $number[0] != 0;
141
-	}
141
+    }
142 142
 
143
-	/**
144
-	 * @param int    $stud_id
143
+    /**
144
+     * @param int    $stud_id
145 145
      * @param string $type
146 146
      *
147
-	 * @return array|null
148
-	 */
149
-	public function calc_score($stud_id = null, $type = null)
150
-	{
147
+     * @return array|null
148
+     */
149
+    public function calc_score($stud_id = null, $type = null)
150
+    {
151 151
         require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
152 152
         $threadInfo = get_thread_information('', $this->get_ref_id());
153 153
 
154
-		$thread_qualify = Database::get_course_table(TABLE_FORUM_THREAD_QUALIFY);
154
+        $thread_qualify = Database::get_course_table(TABLE_FORUM_THREAD_QUALIFY);
155 155
 
156 156
         $sessionId = $this->get_session_id();
157 157
         $sessionCondition = api_get_session_condition($sessionId, true, false, 'session_id');
158 158
 
159
-		$sql = 'SELECT thread_qualify_max
159
+        $sql = 'SELECT thread_qualify_max
160 160
 		        FROM '.Database :: get_course_table(TABLE_FORUM_THREAD)."
161 161
   				WHERE 
162 162
   				    c_id = ".$this->course_id." AND 
163 163
   				    thread_id = '".$this->get_ref_id()."'
164 164
   				    $sessionCondition
165 165
                 ";
166
-		$query = Database::query($sql);
167
-		$assignment = Database::fetch_array($query);
166
+        $query = Database::query($sql);
167
+        $assignment = Database::fetch_array($query);
168 168
 
169
-		$sql = "SELECT * FROM $thread_qualify
169
+        $sql = "SELECT * FROM $thread_qualify
170 170
 				WHERE 
171 171
 				    c_id = ".$this->course_id." AND 
172 172
 				    thread_id = ".$this->get_ref_id()."
173 173
 				    $sessionCondition
174 174
                 ";
175
-		if (isset($stud_id)) {
176
-			$sql .= ' AND user_id = '.intval($stud_id);
177
-		}
175
+        if (isset($stud_id)) {
176
+            $sql .= ' AND user_id = '.intval($stud_id);
177
+        }
178 178
 
179
-		// order by id, that way the student's first attempt is accessed first
180
-		$sql .= ' ORDER BY qualify_time DESC';
181
-		$scores = Database::query($sql);
179
+        // order by id, that way the student's first attempt is accessed first
180
+        $sql .= ' ORDER BY qualify_time DESC';
181
+        $scores = Database::query($sql);
182 182
 
183
-		// for 1 student
184
-		if (isset($stud_id)) {
183
+        // for 1 student
184
+        if (isset($stud_id)) {
185 185
             if ($threadInfo['thread_peer_qualify'] == 0) {
186 186
                 // Classic way of calculate score
187 187
                 if ($data = Database::fetch_array($scores)) {
@@ -209,176 +209,176 @@  discard block
 block discarded – undo
209 209
                 }
210 210
                 return [$score/$counter, $assignment['thread_qualify_max']];
211 211
             }
212
-		} else {
213
-			// All students -> get average
214
-			$students = array();  // user list, needed to make sure we only
215
-			// take first attempts into account
216
-			$counter = 0;
217
-			$sum = 0;
218
-			$bestResult = 0;
219
-			$weight = 0;
220
-			$sumResult = 0;
221
-
222
-			while ($data = Database::fetch_array($scores)) {
223
-				if (!(array_key_exists($data['user_id'], $students))) {
224
-					if ($assignment['thread_qualify_max'] != 0) {
225
-						$students[$data['user_id']] = $data['qualify'];
226
-						$counter++;
227
-						$sum += $data['qualify'] / $assignment['thread_qualify_max'];
228
-						$sumResult += $data['qualify'];
229
-						if ($data['qualify'] > $bestResult) {
230
-							$bestResult = $data['qualify'];
231
-						}
232
-						$weight = $assignment['thread_qualify_max'];
233
-					}
234
-				}
235
-			}
236
-
237
-			if ($counter == 0) {
238
-				return null;
239
-			} else {
240
-				switch ($type) {
241
-					case 'best':
242
-						return array($bestResult, $weight);
243
-						break;
244
-					case 'average':
245
-						return array($sumResult/$counter, $weight);
246
-						break;
247
-					case 'ranking':
248
-						return AbstractLink::getCurrentUserRanking($stud_id, $students);
249
-						break;
250
-					default:
251
-						return array($sum, $counter);
252
-						break;
253
-				}
254
-			}
255
-		}
256
-	}
257
-
258
-	/**
259
-	 * Lazy load function to get the database table of the student publications
260
-	 */
261
-	private function get_forum_thread_table()
262
-	{
263
-		return $this->forum_thread_table = Database :: get_course_table(TABLE_FORUM_THREAD);
264
-	}
265
-
266
-	public function needs_name_and_description()
267
-	{
268
-		return false;
269
-	}
270
-
271
-	public function needs_max()
272
-	{
273
-		return false;
274
-	}
275
-
276
-	public function needs_results()
277
-	{
278
-		return false;
279
-	}
212
+        } else {
213
+            // All students -> get average
214
+            $students = array();  // user list, needed to make sure we only
215
+            // take first attempts into account
216
+            $counter = 0;
217
+            $sum = 0;
218
+            $bestResult = 0;
219
+            $weight = 0;
220
+            $sumResult = 0;
221
+
222
+            while ($data = Database::fetch_array($scores)) {
223
+                if (!(array_key_exists($data['user_id'], $students))) {
224
+                    if ($assignment['thread_qualify_max'] != 0) {
225
+                        $students[$data['user_id']] = $data['qualify'];
226
+                        $counter++;
227
+                        $sum += $data['qualify'] / $assignment['thread_qualify_max'];
228
+                        $sumResult += $data['qualify'];
229
+                        if ($data['qualify'] > $bestResult) {
230
+                            $bestResult = $data['qualify'];
231
+                        }
232
+                        $weight = $assignment['thread_qualify_max'];
233
+                    }
234
+                }
235
+            }
236
+
237
+            if ($counter == 0) {
238
+                return null;
239
+            } else {
240
+                switch ($type) {
241
+                    case 'best':
242
+                        return array($bestResult, $weight);
243
+                        break;
244
+                    case 'average':
245
+                        return array($sumResult/$counter, $weight);
246
+                        break;
247
+                    case 'ranking':
248
+                        return AbstractLink::getCurrentUserRanking($stud_id, $students);
249
+                        break;
250
+                    default:
251
+                        return array($sum, $counter);
252
+                        break;
253
+                }
254
+            }
255
+        }
256
+    }
257
+
258
+    /**
259
+     * Lazy load function to get the database table of the student publications
260
+     */
261
+    private function get_forum_thread_table()
262
+    {
263
+        return $this->forum_thread_table = Database :: get_course_table(TABLE_FORUM_THREAD);
264
+    }
265
+
266
+    public function needs_name_and_description()
267
+    {
268
+        return false;
269
+    }
270
+
271
+    public function needs_max()
272
+    {
273
+        return false;
274
+    }
275
+
276
+    public function needs_results()
277
+    {
278
+        return false;
279
+    }
280 280
 
281 281
     /**
282 282
      * @return string
283 283
      */
284
-	public function get_name()
285
-	{
286
-		$this->get_exercise_data();
287
-		$thread_title=isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : '';
288
-		$thread_title_qualify=isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : '';
289
-		if ( isset($thread_title_qualify) && $thread_title_qualify!="") {
290
-			return $this->exercise_data['thread_title_qualify'];
291
-		} else {
292
-			return $thread_title;
293
-		}
294
-	}
284
+    public function get_name()
285
+    {
286
+        $this->get_exercise_data();
287
+        $thread_title=isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : '';
288
+        $thread_title_qualify=isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : '';
289
+        if ( isset($thread_title_qualify) && $thread_title_qualify!="") {
290
+            return $this->exercise_data['thread_title_qualify'];
291
+        } else {
292
+            return $thread_title;
293
+        }
294
+    }
295 295
 
296 296
     /**
297 297
      * @return string
298 298
      */
299
-	public function get_description()
300
-	{
301
-		return '';//$this->exercise_data['description'];
302
-	}
303
-
304
-	/**
305
-	 * Check if this still links to an exercise
306
-	 */
307
-	public function is_valid_link()
308
-	{
309
-		$sql = 'SELECT count(id) from '.$this->get_forum_thread_table().'
299
+    public function get_description()
300
+    {
301
+        return '';//$this->exercise_data['description'];
302
+    }
303
+
304
+    /**
305
+     * Check if this still links to an exercise
306
+     */
307
+    public function is_valid_link()
308
+    {
309
+        $sql = 'SELECT count(id) from '.$this->get_forum_thread_table().'
310 310
         		WHERE c_id = '.$this->course_id.' AND thread_id = '.$this->get_ref_id().' AND session_id='.api_get_session_id().'';
311
-		$result = Database::query($sql);
312
-		$number = Database::fetch_row($result);
313
-		return ($number[0] != 0);
314
-	}
315
-
316
-	public function get_test_id()
317
-	{
318
-		return 'DEBUG:ID';
319
-	}
320
-
321
-	public function get_link()
322
-	{
323
-		$sessionId = api_get_session_id();
324
-		//it was extracts the forum id
325
-		$sql = 'SELECT * FROM '.$this->get_forum_thread_table()."
311
+        $result = Database::query($sql);
312
+        $number = Database::fetch_row($result);
313
+        return ($number[0] != 0);
314
+    }
315
+
316
+    public function get_test_id()
317
+    {
318
+        return 'DEBUG:ID';
319
+    }
320
+
321
+    public function get_link()
322
+    {
323
+        $sessionId = api_get_session_id();
324
+        //it was extracts the forum id
325
+        $sql = 'SELECT * FROM '.$this->get_forum_thread_table()."
326 326
     			WHERE c_id = '.$this->course_id.' AND thread_id = '".$this->get_ref_id()."' AND session_id = ".$sessionId."";
327
-		$result = Database::query($sql);
328
-		$row    = Database::fetch_array($result,'ASSOC');
329
-		$forum_id=$row['forum_id'];
330
-
331
-		$url = api_get_path(WEB_PATH).'main/forum/viewthread.php?'.api_get_cidreq_params($this->get_course_code(), $sessionId).'&thread='.$this->get_ref_id().'&gradebook=view&forum='.$forum_id;
332
-		return $url;
333
-	}
334
-
335
-	private function get_exercise_data()
336
-	{
337
-		$session_id = api_get_session_id();
338
-		if ($session_id) {
339
-			$session_condition = 'session_id='.api_get_session_id();
340
-		} else {
341
-			$session_condition = '(session_id = 0 OR session_id IS NULL)';
342
-		}
343
-
344
-		if (!isset($this->exercise_data)) {
345
-			$sql = 'SELECT * FROM '.$this->get_forum_thread_table().'
327
+        $result = Database::query($sql);
328
+        $row    = Database::fetch_array($result,'ASSOC');
329
+        $forum_id=$row['forum_id'];
330
+
331
+        $url = api_get_path(WEB_PATH).'main/forum/viewthread.php?'.api_get_cidreq_params($this->get_course_code(), $sessionId).'&thread='.$this->get_ref_id().'&gradebook=view&forum='.$forum_id;
332
+        return $url;
333
+    }
334
+
335
+    private function get_exercise_data()
336
+    {
337
+        $session_id = api_get_session_id();
338
+        if ($session_id) {
339
+            $session_condition = 'session_id='.api_get_session_id();
340
+        } else {
341
+            $session_condition = '(session_id = 0 OR session_id IS NULL)';
342
+        }
343
+
344
+        if (!isset($this->exercise_data)) {
345
+            $sql = 'SELECT * FROM '.$this->get_forum_thread_table().'
346 346
                     WHERE c_id = '.$this->course_id.' AND  thread_id = '.$this->get_ref_id().' AND '.$session_condition;
347
-			$query = Database::query($sql);
348
-			$this->exercise_data = Database::fetch_array($query);
349
-		}
350
-		return $this->exercise_data;
351
-	}
352
-
353
-	public function get_icon_name()
354
-	{
355
-		return 'forum';
356
-	}
357
-
358
-	function save_linked_data()
359
-	{
360
-		$weight = api_float_val($this->get_weight());
361
-		$ref_id = $this->get_ref_id();
362
-
363
-		if (!empty($ref_id)) {
364
-			$sql = 'UPDATE '.$this->get_forum_thread_table().' SET 
347
+            $query = Database::query($sql);
348
+            $this->exercise_data = Database::fetch_array($query);
349
+        }
350
+        return $this->exercise_data;
351
+    }
352
+
353
+    public function get_icon_name()
354
+    {
355
+        return 'forum';
356
+    }
357
+
358
+    function save_linked_data()
359
+    {
360
+        $weight = api_float_val($this->get_weight());
361
+        $ref_id = $this->get_ref_id();
362
+
363
+        if (!empty($ref_id)) {
364
+            $sql = 'UPDATE '.$this->get_forum_thread_table().' SET 
365 365
 			        thread_weight='.$weight.'
366 366
                     WHERE c_id = '.$this->course_id.' AND thread_id= '.$ref_id;
367
-			Database::query($sql);
368
-		}
369
-	}
370
-
371
-	function delete_linked_data()
372
-	{
373
-		$ref_id = $this->get_ref_id();
374
-		if (!empty($ref_id)) {
375
-			//Cleans forum
376
-			$sql = 'UPDATE '.$this->get_forum_thread_table().' SET
367
+            Database::query($sql);
368
+        }
369
+    }
370
+
371
+    function delete_linked_data()
372
+    {
373
+        $ref_id = $this->get_ref_id();
374
+        if (!empty($ref_id)) {
375
+            //Cleans forum
376
+            $sql = 'UPDATE '.$this->get_forum_thread_table().' SET
377 377
 			        thread_qualify_max = 0,
378 378
 			        thread_weight = 0,
379 379
 			        thread_title_qualify = ""
380 380
                     WHERE c_id = '.$this->course_id.' AND thread_id= '.$ref_id;
381
-			Database::query($sql);
382
-		}
383
-	}
381
+            Database::query($sql);
382
+        }
383
+    }
384 384
 }
Please login to merge, or discard this patch.
main/gradebook/lib/be/evaluation.class.php 1 patch
Indentation   +745 added lines, -745 removed lines patch added patch discarded remove patch
@@ -9,365 +9,365 @@  discard block
 block discarded – undo
9 9
  */
10 10
 class Evaluation implements GradebookItem
11 11
 {
12
-	private $id;
13
-	private $name;
14
-	private $description;
15
-	private $user_id;
16
-	private $course_code;
17
-	/** @var Category */
18
-	private $category;
19
-	private $created_at;
20
-	private $weight;
21
-	private $eval_max;
22
-	private $visible;
23
-	private $sessionId;
24
-	public $studentList;
25
-
26
-	/**
27
-	 * Construct
28
-	 */
29
-	public function __construct()
30
-	{
31
-	}
32
-
33
-	/**
34
-	 * @return Category
35
-	 */
36
-	public function getCategory()
37
-	{
38
-		return $this->category;
39
-	}
40
-
41
-	/**
42
-	 * @param Category $category
43
-	 */
44
-	public function setCategory($category)
45
-	{
46
-		$this->category = $category;
47
-	}
48
-
49
-	/**
50
-	 * @return int
51
-	 */
52
-	public function get_category_id()
53
-	{
54
-		return $this->category->get_id();
55
-	}
56
-
57
-	/**
58
-	 * @param int $category_id
59
-	 */
60
-	public function set_category_id($category_id)
61
-	{
62
-		$categories = Category::load($category_id);
63
-		if (isset($categories[0])) {
64
-			$this->setCategory($categories[0]);
65
-		}
66
-	}
67
-
68
-	/**
69
-	 * @return int
70
-	 */
71
-	public function get_id()
72
-	{
73
-		return $this->id;
74
-	}
75
-
76
-	/**
77
-	 * @return string
78
-	 */
79
-	public function get_name()
80
-	{
81
-		return $this->name;
82
-	}
83
-
84
-	/**
85
-	 * @return string
86
-	 */
87
-	public function get_description()
88
-	{
89
-		return $this->description;
90
-	}
91
-
92
-	public function get_user_id()
93
-	{
94
-		return $this->user_id;
95
-	}
96
-
97
-	public function get_course_code()
98
-	{
99
-		return $this->course_code;
100
-	}
101
-
102
-	/**
103
-	 * @return int
104
-	 */
105
-	public function getSessionId()
106
-	{
107
-		return $this->sessionId;
108
-	}
109
-
110
-	/**
111
-	 * @param int $sessionId
112
-	 */
113
-	public function setSessionId($sessionId)
114
-	{
115
-		$this->sessionId = intval($sessionId);
116
-	}
117
-
118
-	public function get_date()
119
-	{
120
-		return $this->created_at;
121
-	}
122
-
123
-	public function get_weight()
124
-	{
125
-		return $this->weight;
126
-	}
127
-
128
-	public function get_max()
129
-	{
130
-		return $this->eval_max;
131
-	}
132
-
133
-	public function get_type()
134
-	{
135
-		return $this->type;
136
-	}
137
-
138
-	public function is_visible()
139
-	{
140
-		return $this->visible;
141
-	}
142
-
143
-	public function get_locked()
144
-	{
145
-		return $this->locked;
146
-	}
147
-
148
-	public function is_locked()
149
-	{
150
-		return isset($this->locked) && $this->locked == 1 ? true : false;
151
-	}
152
-
153
-	public function set_id($id)
154
-	{
155
-		$this->id = $id;
156
-	}
157
-
158
-	public function set_name($name)
159
-	{
160
-		$this->name = $name;
161
-	}
162
-
163
-	public function set_description($description)
164
-	{
165
-		$this->description = $description;
166
-	}
167
-
168
-	public function set_user_id($user_id)
169
-	{
170
-		$this->user_id = $user_id;
171
-	}
172
-
173
-	public function set_course_code($course_code)
174
-	{
175
-		$this->course_code = $course_code;
176
-	}
177
-
178
-	public function set_date($date)
179
-	{
180
-		$this->created_at = $date;
181
-	}
182
-
183
-	public function set_weight($weight)
184
-	{
185
-		$this->weight = $weight;
186
-	}
187
-
188
-	public function set_max($max)
189
-	{
190
-		$this->eval_max = $max;
191
-	}
192
-
193
-	public function set_visible($visible)
194
-	{
195
-		$this->visible = $visible;
196
-	}
197
-
198
-	public function set_type($type)
199
-	{
200
-		$this->type = $type;
201
-	}
202
-
203
-	public function set_locked($locked)
204
-	{
205
-		$this->locked = $locked;
206
-	}
207
-
208
-	/**
209
-	 * Retrieve evaluations and return them as an array of Evaluation objects
210
-	 * @param int $id evaluation id
211
-	 * @param int $user_id user id (evaluation owner)
212
-	 * @param string $course_code course code
213
-	 * @param int $category_id parent category
214
-	 * @param integer $visible visible
215
-	 */
216
-	public static function load(
217
-		$id = null,
218
-		$user_id = null,
219
-		$course_code = null,
220
-		$category_id = null,
221
-		$visible = null,
222
-		$locked = null
223
-	) {
224
-		$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
225
-		$sql = 'SELECT * FROM '.$tbl_grade_evaluations;
226
-		$paramcount = 0;
227
-
228
-		if (isset ($id)) {
229
-			$sql.= ' WHERE id = '.intval($id);
230
-			$paramcount ++;
231
-		}
232
-
233
-		if (isset($user_id)) {
234
-			if ($paramcount != 0) $sql .= ' AND';
235
-			else $sql .= ' WHERE';
236
-			$sql .= ' user_id = '.intval($user_id);
237
-			$paramcount ++;
238
-		}
239
-
240
-		if (isset($course_code) && $course_code <> '-1') {
241
-			if ($paramcount != 0) $sql .= ' AND';
242
-			else $sql .= ' WHERE';
243
-			$sql .= " course_code = '".Database::escape_string($course_code)."'";
244
-			$paramcount ++;
245
-		}
246
-
247
-		if (isset($category_id)) {
248
-			if ($paramcount != 0) $sql .= ' AND';
249
-			else $sql .= ' WHERE';
250
-			$sql .= ' category_id = '.intval($category_id);
251
-			$paramcount ++;
252
-		}
253
-
254
-		if (isset($visible)) {
255
-			if ($paramcount != 0) $sql .= ' AND';
256
-			else $sql .= ' WHERE';
257
-			$sql .= ' visible = '.intval($visible);
258
-			$paramcount ++;
259
-		}
260
-
261
-		if (isset($locked)) {
262
-			if ($paramcount != 0) $sql .= ' AND';
263
-			else $sql .= ' WHERE';
264
-			$sql .= ' locked = '.intval($locked);
265
-		}
266
-
267
-		$result = Database::query($sql);
268
-		$allEval = Evaluation::create_evaluation_objects_from_sql_result($result);
269
-
270
-		return $allEval;
271
-	}
272
-
273
-	/**
274
-	 * @param array $result
275
-	 * @return array
276
-	 */
277
-	private static function create_evaluation_objects_from_sql_result($result)
278
-	{
279
-		$alleval = array();
280
-		if (Database::num_rows($result)) {
281
-			while ($data = Database::fetch_array($result)) {
282
-				$eval= new Evaluation();
283
-				$eval->set_id($data['id']);
284
-				$eval->set_name($data['name']);
285
-				$eval->set_description($data['description']);
286
-				$eval->set_user_id($data['user_id']);
287
-				$eval->set_course_code($data['course_code']);
288
-				$eval->set_category_id($data['category_id']);
289
-				$eval->set_date(api_get_local_time($data['created_at']));
290
-				$eval->set_weight($data['weight']);
291
-				$eval->set_max($data['max']);
292
-				$eval->set_visible($data['visible']);
293
-				$eval->set_type($data['type']);
294
-				$eval->set_locked($data['locked']);
295
-				$eval->setSessionId(api_get_session_id());
296
-
297
-				$alleval[] = $eval;
298
-			}
299
-		}
300
-
301
-		return $alleval;
302
-	}
303
-
304
-	/**
305
-	 * Insert this evaluation into the database
306
-	 */
12
+    private $id;
13
+    private $name;
14
+    private $description;
15
+    private $user_id;
16
+    private $course_code;
17
+    /** @var Category */
18
+    private $category;
19
+    private $created_at;
20
+    private $weight;
21
+    private $eval_max;
22
+    private $visible;
23
+    private $sessionId;
24
+    public $studentList;
25
+
26
+    /**
27
+     * Construct
28
+     */
29
+    public function __construct()
30
+    {
31
+    }
32
+
33
+    /**
34
+     * @return Category
35
+     */
36
+    public function getCategory()
37
+    {
38
+        return $this->category;
39
+    }
40
+
41
+    /**
42
+     * @param Category $category
43
+     */
44
+    public function setCategory($category)
45
+    {
46
+        $this->category = $category;
47
+    }
48
+
49
+    /**
50
+     * @return int
51
+     */
52
+    public function get_category_id()
53
+    {
54
+        return $this->category->get_id();
55
+    }
56
+
57
+    /**
58
+     * @param int $category_id
59
+     */
60
+    public function set_category_id($category_id)
61
+    {
62
+        $categories = Category::load($category_id);
63
+        if (isset($categories[0])) {
64
+            $this->setCategory($categories[0]);
65
+        }
66
+    }
67
+
68
+    /**
69
+     * @return int
70
+     */
71
+    public function get_id()
72
+    {
73
+        return $this->id;
74
+    }
75
+
76
+    /**
77
+     * @return string
78
+     */
79
+    public function get_name()
80
+    {
81
+        return $this->name;
82
+    }
83
+
84
+    /**
85
+     * @return string
86
+     */
87
+    public function get_description()
88
+    {
89
+        return $this->description;
90
+    }
91
+
92
+    public function get_user_id()
93
+    {
94
+        return $this->user_id;
95
+    }
96
+
97
+    public function get_course_code()
98
+    {
99
+        return $this->course_code;
100
+    }
101
+
102
+    /**
103
+     * @return int
104
+     */
105
+    public function getSessionId()
106
+    {
107
+        return $this->sessionId;
108
+    }
109
+
110
+    /**
111
+     * @param int $sessionId
112
+     */
113
+    public function setSessionId($sessionId)
114
+    {
115
+        $this->sessionId = intval($sessionId);
116
+    }
117
+
118
+    public function get_date()
119
+    {
120
+        return $this->created_at;
121
+    }
122
+
123
+    public function get_weight()
124
+    {
125
+        return $this->weight;
126
+    }
127
+
128
+    public function get_max()
129
+    {
130
+        return $this->eval_max;
131
+    }
132
+
133
+    public function get_type()
134
+    {
135
+        return $this->type;
136
+    }
137
+
138
+    public function is_visible()
139
+    {
140
+        return $this->visible;
141
+    }
142
+
143
+    public function get_locked()
144
+    {
145
+        return $this->locked;
146
+    }
147
+
148
+    public function is_locked()
149
+    {
150
+        return isset($this->locked) && $this->locked == 1 ? true : false;
151
+    }
152
+
153
+    public function set_id($id)
154
+    {
155
+        $this->id = $id;
156
+    }
157
+
158
+    public function set_name($name)
159
+    {
160
+        $this->name = $name;
161
+    }
162
+
163
+    public function set_description($description)
164
+    {
165
+        $this->description = $description;
166
+    }
167
+
168
+    public function set_user_id($user_id)
169
+    {
170
+        $this->user_id = $user_id;
171
+    }
172
+
173
+    public function set_course_code($course_code)
174
+    {
175
+        $this->course_code = $course_code;
176
+    }
177
+
178
+    public function set_date($date)
179
+    {
180
+        $this->created_at = $date;
181
+    }
182
+
183
+    public function set_weight($weight)
184
+    {
185
+        $this->weight = $weight;
186
+    }
187
+
188
+    public function set_max($max)
189
+    {
190
+        $this->eval_max = $max;
191
+    }
192
+
193
+    public function set_visible($visible)
194
+    {
195
+        $this->visible = $visible;
196
+    }
197
+
198
+    public function set_type($type)
199
+    {
200
+        $this->type = $type;
201
+    }
202
+
203
+    public function set_locked($locked)
204
+    {
205
+        $this->locked = $locked;
206
+    }
207
+
208
+    /**
209
+     * Retrieve evaluations and return them as an array of Evaluation objects
210
+     * @param int $id evaluation id
211
+     * @param int $user_id user id (evaluation owner)
212
+     * @param string $course_code course code
213
+     * @param int $category_id parent category
214
+     * @param integer $visible visible
215
+     */
216
+    public static function load(
217
+        $id = null,
218
+        $user_id = null,
219
+        $course_code = null,
220
+        $category_id = null,
221
+        $visible = null,
222
+        $locked = null
223
+    ) {
224
+        $tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
225
+        $sql = 'SELECT * FROM '.$tbl_grade_evaluations;
226
+        $paramcount = 0;
227
+
228
+        if (isset ($id)) {
229
+            $sql.= ' WHERE id = '.intval($id);
230
+            $paramcount ++;
231
+        }
232
+
233
+        if (isset($user_id)) {
234
+            if ($paramcount != 0) $sql .= ' AND';
235
+            else $sql .= ' WHERE';
236
+            $sql .= ' user_id = '.intval($user_id);
237
+            $paramcount ++;
238
+        }
239
+
240
+        if (isset($course_code) && $course_code <> '-1') {
241
+            if ($paramcount != 0) $sql .= ' AND';
242
+            else $sql .= ' WHERE';
243
+            $sql .= " course_code = '".Database::escape_string($course_code)."'";
244
+            $paramcount ++;
245
+        }
246
+
247
+        if (isset($category_id)) {
248
+            if ($paramcount != 0) $sql .= ' AND';
249
+            else $sql .= ' WHERE';
250
+            $sql .= ' category_id = '.intval($category_id);
251
+            $paramcount ++;
252
+        }
253
+
254
+        if (isset($visible)) {
255
+            if ($paramcount != 0) $sql .= ' AND';
256
+            else $sql .= ' WHERE';
257
+            $sql .= ' visible = '.intval($visible);
258
+            $paramcount ++;
259
+        }
260
+
261
+        if (isset($locked)) {
262
+            if ($paramcount != 0) $sql .= ' AND';
263
+            else $sql .= ' WHERE';
264
+            $sql .= ' locked = '.intval($locked);
265
+        }
266
+
267
+        $result = Database::query($sql);
268
+        $allEval = Evaluation::create_evaluation_objects_from_sql_result($result);
269
+
270
+        return $allEval;
271
+    }
272
+
273
+    /**
274
+     * @param array $result
275
+     * @return array
276
+     */
277
+    private static function create_evaluation_objects_from_sql_result($result)
278
+    {
279
+        $alleval = array();
280
+        if (Database::num_rows($result)) {
281
+            while ($data = Database::fetch_array($result)) {
282
+                $eval= new Evaluation();
283
+                $eval->set_id($data['id']);
284
+                $eval->set_name($data['name']);
285
+                $eval->set_description($data['description']);
286
+                $eval->set_user_id($data['user_id']);
287
+                $eval->set_course_code($data['course_code']);
288
+                $eval->set_category_id($data['category_id']);
289
+                $eval->set_date(api_get_local_time($data['created_at']));
290
+                $eval->set_weight($data['weight']);
291
+                $eval->set_max($data['max']);
292
+                $eval->set_visible($data['visible']);
293
+                $eval->set_type($data['type']);
294
+                $eval->set_locked($data['locked']);
295
+                $eval->setSessionId(api_get_session_id());
296
+
297
+                $alleval[] = $eval;
298
+            }
299
+        }
300
+
301
+        return $alleval;
302
+    }
303
+
304
+    /**
305
+     * Insert this evaluation into the database
306
+     */
307 307
     public function add()
308
-	{
309
-		if (isset($this->name) &&
310
-			isset($this->user_id) &&
311
-			isset($this->weight) &&
312
-			isset ($this->eval_max) &&
313
-			isset($this->visible)
314
-		) {
315
-			$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
316
-
317
-			$sql = 'INSERT INTO '.$tbl_grade_evaluations
318
-				.' (name, user_id, weight, max, visible';
319
-			if (isset($this->description)) {
320
-				$sql .= ',description';
321
-			}
322
-			if (isset($this->course_code)) {
323
-				$sql .= ', course_code';
324
-			}
325
-			if (isset($this->category)) {
326
-				$sql .= ', category_id';
327
-			}
328
-			$sql .= ', created_at';
329
-			$sql .= ',type';
330
-			$sql .= ") VALUES ('".Database::escape_string($this->get_name())."'"
331
-				.','.intval($this->get_user_id())
332
-				.','.api_float_val($this->get_weight())
333
-				.','.intval($this->get_max())
334
-				.','.intval($this->is_visible());
335
-			if (isset($this->description)) {
336
-				$sql .= ",'".Database::escape_string($this->get_description())."'";
337
-			}
338
-			if (isset($this->course_code)) {
339
-				$sql .= ",'".Database::escape_string($this->get_course_code())."'";
340
-			}
341
-			if (isset($this->category)) {
342
-				$sql .= ','.intval($this->get_category_id());
343
-			}
344
-			if (empty($this->type)) {
345
-				$this->type = 'evaluation';
346
-			}
347
-			$sql .= ", '".api_get_utc_datetime()."'";
348
-			$sql .= ',\''.Database::escape_string($this->type).'\'';
349
-			$sql .= ")";
350
-
351
-			Database::query($sql);
352
-			$this->set_id(Database::insert_id());
353
-		} else {
354
-			die('Error in Evaluation add: required field empty');
355
-		}
356
-	}
357
-
358
-	/**
359
-	 * @param int $idevaluation
360
-	 */
361
-	public function add_evaluation_log($idevaluation)
362
-	{
363
-		if (!empty($idevaluation)) {
364
-			$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
365
-			$tbl_grade_linkeval_log = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINKEVAL_LOG);
366
-			$eval = new Evaluation();
367
-			$dateobject = $eval->load($idevaluation,null,null,null,null);
368
-			$arreval = get_object_vars($dateobject[0]);
369
-			if (!empty($arreval['id'])) {
370
-				$sql = 'SELECT weight from '.$tbl_grade_evaluations.'
308
+    {
309
+        if (isset($this->name) &&
310
+            isset($this->user_id) &&
311
+            isset($this->weight) &&
312
+            isset ($this->eval_max) &&
313
+            isset($this->visible)
314
+        ) {
315
+            $tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
316
+
317
+            $sql = 'INSERT INTO '.$tbl_grade_evaluations
318
+                .' (name, user_id, weight, max, visible';
319
+            if (isset($this->description)) {
320
+                $sql .= ',description';
321
+            }
322
+            if (isset($this->course_code)) {
323
+                $sql .= ', course_code';
324
+            }
325
+            if (isset($this->category)) {
326
+                $sql .= ', category_id';
327
+            }
328
+            $sql .= ', created_at';
329
+            $sql .= ',type';
330
+            $sql .= ") VALUES ('".Database::escape_string($this->get_name())."'"
331
+                .','.intval($this->get_user_id())
332
+                .','.api_float_val($this->get_weight())
333
+                .','.intval($this->get_max())
334
+                .','.intval($this->is_visible());
335
+            if (isset($this->description)) {
336
+                $sql .= ",'".Database::escape_string($this->get_description())."'";
337
+            }
338
+            if (isset($this->course_code)) {
339
+                $sql .= ",'".Database::escape_string($this->get_course_code())."'";
340
+            }
341
+            if (isset($this->category)) {
342
+                $sql .= ','.intval($this->get_category_id());
343
+            }
344
+            if (empty($this->type)) {
345
+                $this->type = 'evaluation';
346
+            }
347
+            $sql .= ", '".api_get_utc_datetime()."'";
348
+            $sql .= ',\''.Database::escape_string($this->type).'\'';
349
+            $sql .= ")";
350
+
351
+            Database::query($sql);
352
+            $this->set_id(Database::insert_id());
353
+        } else {
354
+            die('Error in Evaluation add: required field empty');
355
+        }
356
+    }
357
+
358
+    /**
359
+     * @param int $idevaluation
360
+     */
361
+    public function add_evaluation_log($idevaluation)
362
+    {
363
+        if (!empty($idevaluation)) {
364
+            $tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
365
+            $tbl_grade_linkeval_log = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINKEVAL_LOG);
366
+            $eval = new Evaluation();
367
+            $dateobject = $eval->load($idevaluation,null,null,null,null);
368
+            $arreval = get_object_vars($dateobject[0]);
369
+            if (!empty($arreval['id'])) {
370
+                $sql = 'SELECT weight from '.$tbl_grade_evaluations.'
371 371
                         WHERE id='.$arreval['id'];
372 372
                 $rs = Database::query($sql);
373 373
                 $row_old_weight = Database::fetch_array($rs, 'ASSOC');
@@ -383,426 +383,426 @@  discard block
 block discarded – undo
383 383
                     'user_id_log' => api_get_user_id()
384 384
                 ];
385 385
                 Database::insert($tbl_grade_linkeval_log, $params);
386
-			}
387
-		}
388
-	}
389
-
390
-	/**
391
-	 * Update the properties of this evaluation in the database
392
-	 */
393
-	public function save()
394
-	{
395
-		$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
396
-		$sql = 'UPDATE '.$tbl_grade_evaluations
397
-			." SET name = '".Database::escape_string($this->get_name())."'"
398
-			.', description = ';
399
-		if (isset($this->description)) {
400
-			$sql .= "'".Database::escape_string($this->get_description())."'";
401
-		}else {
402
-			$sql .= 'null';
403
-		}
404
-		$sql .= ', user_id = '.intval($this->get_user_id())
405
-			.', course_code = ';
406
-		if (isset($this->course_code)) {
407
-			$sql .= "'".Database::escape_string($this->get_course_code())."'";
408
-		} else {
409
-			$sql .= 'null';
410
-		}
411
-		$sql .= ', category_id = ';
412
-		if (isset($this->category)) {
413
-			$sql .= intval($this->get_category_id());
414
-		} else {
415
-			$sql .= 'null';
416
-		}
417
-		$sql .= ', weight = "'.Database::escape_string($this->get_weight()).'" '
418
-			.', max = '.intval($this->get_max())
419
-			.', visible = '.intval($this->is_visible())
420
-			.' WHERE id = '.intval($this->id);
421
-		//recorded history
422
-
423
-		$eval_log = new Evaluation();
424
-		$eval_log->add_evaluation_log($this->id);
425
-		Database::query($sql);
426
-	}
427
-
428
-	/**
429
-	 * Delete this evaluation from the database
430
-	 */
431
-	public function delete()
432
-	{
433
-		$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
434
-		$sql = 'DELETE FROM '.$tbl_grade_evaluations.' WHERE id = '.intval($this->id);
435
-		Database::query($sql);
436
-	}
437
-
438
-	/**
439
-	 * Check if an evaluation name (with the same parent category) already exists
440
-	 * @param $name name to check (if not given, the name property of this object will be checked)
441
-	 * @param $parent parent category
442
-	 */
443
-	public function does_name_exist($name, $parent)
444
-	{
445
-		if (!isset ($name)) {
446
-			$name = $this->name;
447
-			$parent = $this->category;
448
-		}
449
-		$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
450
-		$sql = 'SELECT count(id) AS number'
451
-			.' FROM '.$tbl_grade_evaluations
452
-			." WHERE name = '".Database::escape_string($name)."'";
453
-
454
-		if (api_is_allowed_to_edit()) {
455
-			$parent = Category::load($parent);
456
-			$code = $parent[0]->get_course_code();
457
-			$courseInfo = api_get_course_info($code);
458
-			$courseId = $courseInfo['real_id'];
459
-
460
-			if (isset($code) && $code != '0') {
461
-				$main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
462
-				$sql .= ' AND user_id IN (
386
+            }
387
+        }
388
+    }
389
+
390
+    /**
391
+     * Update the properties of this evaluation in the database
392
+     */
393
+    public function save()
394
+    {
395
+        $tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
396
+        $sql = 'UPDATE '.$tbl_grade_evaluations
397
+            ." SET name = '".Database::escape_string($this->get_name())."'"
398
+            .', description = ';
399
+        if (isset($this->description)) {
400
+            $sql .= "'".Database::escape_string($this->get_description())."'";
401
+        }else {
402
+            $sql .= 'null';
403
+        }
404
+        $sql .= ', user_id = '.intval($this->get_user_id())
405
+            .', course_code = ';
406
+        if (isset($this->course_code)) {
407
+            $sql .= "'".Database::escape_string($this->get_course_code())."'";
408
+        } else {
409
+            $sql .= 'null';
410
+        }
411
+        $sql .= ', category_id = ';
412
+        if (isset($this->category)) {
413
+            $sql .= intval($this->get_category_id());
414
+        } else {
415
+            $sql .= 'null';
416
+        }
417
+        $sql .= ', weight = "'.Database::escape_string($this->get_weight()).'" '
418
+            .', max = '.intval($this->get_max())
419
+            .', visible = '.intval($this->is_visible())
420
+            .' WHERE id = '.intval($this->id);
421
+        //recorded history
422
+
423
+        $eval_log = new Evaluation();
424
+        $eval_log->add_evaluation_log($this->id);
425
+        Database::query($sql);
426
+    }
427
+
428
+    /**
429
+     * Delete this evaluation from the database
430
+     */
431
+    public function delete()
432
+    {
433
+        $tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
434
+        $sql = 'DELETE FROM '.$tbl_grade_evaluations.' WHERE id = '.intval($this->id);
435
+        Database::query($sql);
436
+    }
437
+
438
+    /**
439
+     * Check if an evaluation name (with the same parent category) already exists
440
+     * @param $name name to check (if not given, the name property of this object will be checked)
441
+     * @param $parent parent category
442
+     */
443
+    public function does_name_exist($name, $parent)
444
+    {
445
+        if (!isset ($name)) {
446
+            $name = $this->name;
447
+            $parent = $this->category;
448
+        }
449
+        $tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
450
+        $sql = 'SELECT count(id) AS number'
451
+            .' FROM '.$tbl_grade_evaluations
452
+            ." WHERE name = '".Database::escape_string($name)."'";
453
+
454
+        if (api_is_allowed_to_edit()) {
455
+            $parent = Category::load($parent);
456
+            $code = $parent[0]->get_course_code();
457
+            $courseInfo = api_get_course_info($code);
458
+            $courseId = $courseInfo['real_id'];
459
+
460
+            if (isset($code) && $code != '0') {
461
+                $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
462
+                $sql .= ' AND user_id IN (
463 463
 					 SELECT user_id FROM '.$main_course_user_table.'
464 464
 					 WHERE
465 465
 						c_id = '.$courseId.' AND
466 466
 						status = '.COURSEMANAGER.'
467 467
 					)';
468
-			} else {
469
-				$sql .= ' AND user_id = '.api_get_user_id();
470
-			}
471
-
472
-		}else {
473
-			$sql .= ' AND user_id = '.api_get_user_id();
474
-		}
475
-
476
-		if (!isset ($parent)) {
477
-			$sql.= ' AND category_id is null';
478
-		} else {
479
-			$sql.= ' AND category_id = '.intval($parent);
480
-		}
481
-		$result = Database::query($sql);
482
-		$number=Database::fetch_row($result);
483
-
484
-		return $number[0] != 0;
485
-	}
486
-
487
-	/**
488
-	 * Are there any results for this evaluation yet ?
489
-	 * The 'max' property should not be changed then.
490
-	 */
491
-	public function has_results()
492
-	{
493
-		$tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
494
-		$sql = 'SELECT count(id) AS number
468
+            } else {
469
+                $sql .= ' AND user_id = '.api_get_user_id();
470
+            }
471
+
472
+        }else {
473
+            $sql .= ' AND user_id = '.api_get_user_id();
474
+        }
475
+
476
+        if (!isset ($parent)) {
477
+            $sql.= ' AND category_id is null';
478
+        } else {
479
+            $sql.= ' AND category_id = '.intval($parent);
480
+        }
481
+        $result = Database::query($sql);
482
+        $number=Database::fetch_row($result);
483
+
484
+        return $number[0] != 0;
485
+    }
486
+
487
+    /**
488
+     * Are there any results for this evaluation yet ?
489
+     * The 'max' property should not be changed then.
490
+     */
491
+    public function has_results()
492
+    {
493
+        $tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
494
+        $sql = 'SELECT count(id) AS number
495 495
 				FROM '.$tbl_grade_results.'
496 496
 				WHERE evaluation_id = '.intval($this->id);
497
-		$result = Database::query($sql);
498
-		$number=Database::fetch_row($result);
499
-
500
-		return ($number[0] != 0);
501
-	}
502
-
503
-	/**
504
-	 * Delete all results for this evaluation
505
-	 */
506
-	public function delete_results()
507
-	{
508
-		$tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
509
-		$sql = 'DELETE FROM '.$tbl_grade_results.'
497
+        $result = Database::query($sql);
498
+        $number=Database::fetch_row($result);
499
+
500
+        return ($number[0] != 0);
501
+    }
502
+
503
+    /**
504
+     * Delete all results for this evaluation
505
+     */
506
+    public function delete_results()
507
+    {
508
+        $tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
509
+        $sql = 'DELETE FROM '.$tbl_grade_results.'
510 510
 				WHERE evaluation_id = '.intval($this->id);
511
-		Database::query($sql);
512
-	}
513
-
514
-	/**
515
-	 * Delete this evaluation and all underlying results.
516
-	 */
517
-	public function delete_with_results()
518
-	{
519
-		$this->delete_results();
520
-		$this->delete();
521
-	}
522
-
523
-	/**
524
-	 * Check if the given score is possible for this evaluation
525
-	 */
526
-	public function is_valid_score($score)
527
-	{
528
-		return is_numeric($score) && $score >= 0 && $score <= $this->eval_max;
529
-	}
530
-
531
-	/**
532
-	 * Calculate the score of this evaluation
533
-	 * @param int $stud_id (default: all students who have results for this eval - then the average is returned)
534
-	 * @param string $type (best, average, ranking)
535
-	 * @return	array (score, max) if student is given
536
-	 * 			array (sum of scores, number of scores) otherwise
537
-	 * 			or null if no scores available
538
-	 */
539
-	public function calc_score($stud_id = null, $type = null)
540
-	{
511
+        Database::query($sql);
512
+    }
513
+
514
+    /**
515
+     * Delete this evaluation and all underlying results.
516
+     */
517
+    public function delete_with_results()
518
+    {
519
+        $this->delete_results();
520
+        $this->delete();
521
+    }
522
+
523
+    /**
524
+     * Check if the given score is possible for this evaluation
525
+     */
526
+    public function is_valid_score($score)
527
+    {
528
+        return is_numeric($score) && $score >= 0 && $score <= $this->eval_max;
529
+    }
530
+
531
+    /**
532
+     * Calculate the score of this evaluation
533
+     * @param int $stud_id (default: all students who have results for this eval - then the average is returned)
534
+     * @param string $type (best, average, ranking)
535
+     * @return	array (score, max) if student is given
536
+     * 			array (sum of scores, number of scores) otherwise
537
+     * 			or null if no scores available
538
+     */
539
+    public function calc_score($stud_id = null, $type = null)
540
+    {
541 541
         $useSession = true;
542
-		if (isset($stud_id) && empty($type)) {
543
-			$key = 'result_score_student_list_'.api_get_course_int_id().'_'.api_get_session_id().'_'.$this->id.'_'.$stud_id;
544
-			$data = Session::read('calc_score');
542
+        if (isset($stud_id) && empty($type)) {
543
+            $key = 'result_score_student_list_'.api_get_course_int_id().'_'.api_get_session_id().'_'.$this->id.'_'.$stud_id;
544
+            $data = Session::read('calc_score');
545 545
             $results = isset($data[$key]) ? $data[$key] : null;
546 546
 
547 547
             if ($useSession == false) {
548 548
                 $results  = null;
549 549
             }
550
-			if (empty($results)) {
551
-				$results = Result::load(null, $stud_id, $this->id);
552
-				Session::write('calc_score', array($key => $results));
553
-			}
554
-
555
-			$score = 0;
556
-			/** @var Result $res */
557
-			foreach ($results as $res) {
558
-				$score = $res->get_score();
559
-			}
560
-
561
-			return array($score, $this->get_max());
562
-		} else {
563
-
564
-			$count = 0;
565
-			$sum = 0;
566
-			$bestResult = 0;
567
-			$weight = 0;
568
-			$sumResult = 0;
569
-
570
-			$key = 'result_score_student_list_'.api_get_course_int_id().'_'.api_get_session_id().'_'.$this->id;
550
+            if (empty($results)) {
551
+                $results = Result::load(null, $stud_id, $this->id);
552
+                Session::write('calc_score', array($key => $results));
553
+            }
554
+
555
+            $score = 0;
556
+            /** @var Result $res */
557
+            foreach ($results as $res) {
558
+                $score = $res->get_score();
559
+            }
560
+
561
+            return array($score, $this->get_max());
562
+        } else {
563
+
564
+            $count = 0;
565
+            $sum = 0;
566
+            $bestResult = 0;
567
+            $weight = 0;
568
+            $sumResult = 0;
569
+
570
+            $key = 'result_score_student_list_'.api_get_course_int_id().'_'.api_get_session_id().'_'.$this->id;
571 571
             $data = Session::read('calc_score');
572 572
             $allResults = isset($data[$key]) ? $data[$key] : null;
573 573
             if ($useSession == false) {
574 574
                 $allResults  = null;
575 575
             }
576
-			if (empty($allResults)) {
577
-				$allResults = Result::load(null, null, $this->id);
578
-				Session::write($key, $allResults);
579
-			}
580
-
581
-			$students = array();
582
-			/** @var Result $res */
583
-			foreach ($allResults as $res) {
584
-				$score = $res->get_score();
585
-				if (!empty($score) || $score == '0') {
586
-					$count++;
587
-					$sum += $score / $this->get_max();
588
-					$sumResult += $score;
589
-					if ($score > $bestResult) {
590
-						$bestResult = $score;
591
-					}
592
-					$weight = $this->get_max();
593
-				}
594
-				$students[$res->get_user_id()] = $score;
595
-			}
596
-
597
-			if (empty($count)) {
598
-				return null;
599
-			}
600
-
601
-			switch ($type) {
602
-				case 'best':
603
-					return array($bestResult, $weight);
604
-					break;
605
-				case 'average':
606
-					return array($sumResult/$count, $weight);
607
-					break;
608
-				case 'ranking':
576
+            if (empty($allResults)) {
577
+                $allResults = Result::load(null, null, $this->id);
578
+                Session::write($key, $allResults);
579
+            }
580
+
581
+            $students = array();
582
+            /** @var Result $res */
583
+            foreach ($allResults as $res) {
584
+                $score = $res->get_score();
585
+                if (!empty($score) || $score == '0') {
586
+                    $count++;
587
+                    $sum += $score / $this->get_max();
588
+                    $sumResult += $score;
589
+                    if ($score > $bestResult) {
590
+                        $bestResult = $score;
591
+                    }
592
+                    $weight = $this->get_max();
593
+                }
594
+                $students[$res->get_user_id()] = $score;
595
+            }
596
+
597
+            if (empty($count)) {
598
+                return null;
599
+            }
600
+
601
+            switch ($type) {
602
+                case 'best':
603
+                    return array($bestResult, $weight);
604
+                    break;
605
+                case 'average':
606
+                    return array($sumResult/$count, $weight);
607
+                    break;
608
+                case 'ranking':
609 609
                     $students = array();
610 610
                     /** @var Result $res */
611 611
                     foreach ($allResults as $res) {
612 612
                         $score = $res->get_score();
613 613
                         $students[$res->get_user_id()] = $score;
614 614
                     }
615
-					return AbstractLink::getCurrentUserRanking($stud_id, $students);
616
-					break;
617
-				default:
618
-					return array($sum, $count);
619
-					break;
620
-			}
621
-		}
622
-	}
623
-
624
-	/**
625
-	 * Generate an array of possible categories where this evaluation can be moved to.
626
-	 * Notice: its own parent will be included in the list: it's up to the frontend
627
-	 * to disable this element.
628
-	 * @return array 2-dimensional array - every element contains 3 subelements (id, name, level)
629
-	 */
630
-	public function get_target_categories()
631
-	{
632
-		// - course independent evaluation
633
-		//   -> movable to root or other course independent categories
634
-		// - evaluation inside a course
635
-		//   -> movable to root, independent categories or categories inside the course
636
-		$user = (api_is_platform_admin() ? null : api_get_user_id());
637
-		$targets = array();
638
-		$level = 0;
639
-
640
-		$root = array(0, get_lang('RootCat'), $level);
641
-		$targets[] = $root;
642
-
643
-		if (isset($this->course_code) && !empty($this->course_code)) {
644
-			$crscats = Category::load(null,null,$this->course_code,0);
645
-			foreach ($crscats as $cat) {
646
-				$targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
647
-				$targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
648
-			}
649
-		}
650
-
651
-		$indcats = Category::load(null,$user,0,0);
652
-		foreach ($indcats as $cat) {
653
-			$targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
654
-			$targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
655
-		}
656
-
657
-		return $targets;
658
-	}
659
-
660
-	/**
661
-	 * Internal function used by get_target_categories()
662
-	 * @param integer $level
663
-	 */
664
-	private function add_target_subcategories($targets, $level, $catid)
665
-	{
666
-		$subcats = Category::load(null,null,null,$catid);
667
-		foreach ($subcats as $cat) {
668
-			$targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
669
-			$targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
670
-		}
671
-		return $targets;
672
-	}
673
-
674
-	/**
675
-	 * Move this evaluation to the given category.
676
-	 * If this evaluation moves from inside a course to outside,
677
-	 * its course code is also changed.
678
-	 */
679
-	public function move_to_cat($cat)
680
-	{
681
-		$this->set_category_id($cat->get_id());
682
-		if ($this->get_course_code() != $cat->get_course_code()) {
683
-			$this->set_course_code($cat->get_course_code());
684
-		}
685
-		$this->save();
686
-	}
687
-
688
-	/**
689
-	 * Retrieve evaluations where a student has results for
690
-	 * and return them as an array of Evaluation objects
691
-	 * @param int $cat_id parent category (use 'null' to retrieve them in all categories)
692
-	 * @param int $stud_id student id
693
-	 */
694
-	public static function get_evaluations_with_result_for_student($cat_id = null, $stud_id)
695
-	{
696
-		$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
697
-		$tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
698
-
699
-		$sql = 'SELECT * FROM '.$tbl_grade_evaluations.'
615
+                    return AbstractLink::getCurrentUserRanking($stud_id, $students);
616
+                    break;
617
+                default:
618
+                    return array($sum, $count);
619
+                    break;
620
+            }
621
+        }
622
+    }
623
+
624
+    /**
625
+     * Generate an array of possible categories where this evaluation can be moved to.
626
+     * Notice: its own parent will be included in the list: it's up to the frontend
627
+     * to disable this element.
628
+     * @return array 2-dimensional array - every element contains 3 subelements (id, name, level)
629
+     */
630
+    public function get_target_categories()
631
+    {
632
+        // - course independent evaluation
633
+        //   -> movable to root or other course independent categories
634
+        // - evaluation inside a course
635
+        //   -> movable to root, independent categories or categories inside the course
636
+        $user = (api_is_platform_admin() ? null : api_get_user_id());
637
+        $targets = array();
638
+        $level = 0;
639
+
640
+        $root = array(0, get_lang('RootCat'), $level);
641
+        $targets[] = $root;
642
+
643
+        if (isset($this->course_code) && !empty($this->course_code)) {
644
+            $crscats = Category::load(null,null,$this->course_code,0);
645
+            foreach ($crscats as $cat) {
646
+                $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
647
+                $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
648
+            }
649
+        }
650
+
651
+        $indcats = Category::load(null,$user,0,0);
652
+        foreach ($indcats as $cat) {
653
+            $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
654
+            $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
655
+        }
656
+
657
+        return $targets;
658
+    }
659
+
660
+    /**
661
+     * Internal function used by get_target_categories()
662
+     * @param integer $level
663
+     */
664
+    private function add_target_subcategories($targets, $level, $catid)
665
+    {
666
+        $subcats = Category::load(null,null,null,$catid);
667
+        foreach ($subcats as $cat) {
668
+            $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
669
+            $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
670
+        }
671
+        return $targets;
672
+    }
673
+
674
+    /**
675
+     * Move this evaluation to the given category.
676
+     * If this evaluation moves from inside a course to outside,
677
+     * its course code is also changed.
678
+     */
679
+    public function move_to_cat($cat)
680
+    {
681
+        $this->set_category_id($cat->get_id());
682
+        if ($this->get_course_code() != $cat->get_course_code()) {
683
+            $this->set_course_code($cat->get_course_code());
684
+        }
685
+        $this->save();
686
+    }
687
+
688
+    /**
689
+     * Retrieve evaluations where a student has results for
690
+     * and return them as an array of Evaluation objects
691
+     * @param int $cat_id parent category (use 'null' to retrieve them in all categories)
692
+     * @param int $stud_id student id
693
+     */
694
+    public static function get_evaluations_with_result_for_student($cat_id = null, $stud_id)
695
+    {
696
+        $tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
697
+        $tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
698
+
699
+        $sql = 'SELECT * FROM '.$tbl_grade_evaluations.'
700 700
 				WHERE id IN (
701 701
 					SELECT evaluation_id FROM '.$tbl_grade_results.'
702 702
 					WHERE user_id = '.intval($stud_id).' AND score IS NOT NULL
703 703
 				)';
704
-		if (!api_is_allowed_to_edit()) {
705
-			$sql .= ' AND visible = 1';
706
-		}
707
-		if (isset($cat_id)) {
708
-			$sql .= ' AND category_id = '.intval($cat_id);
709
-		} else {
710
-			$sql .= ' AND category_id >= 0';
711
-		}
712
-
713
-		$result = Database::query($sql);
714
-		$alleval = Evaluation::create_evaluation_objects_from_sql_result($result);
715
-
716
-		return $alleval;
717
-	}
718
-
719
-	/**
720
-	 * Get a list of students that do not have a result record for this evaluation
721
-	 */
722
-	public function get_not_subscribed_students($first_letter_user = '')
723
-	{
724
-		$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
725
-		$tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
726
-
727
-		$sql = 'SELECT user_id,lastname,firstname,username FROM '.$tbl_user
728
-			." WHERE lastname LIKE '".Database::escape_string($first_letter_user)."%'"
729
-			.' AND status = '.STUDENT
730
-			.' AND user_id NOT IN'
731
-			.' (SELECT user_id FROM '.$tbl_grade_results
732
-			.' WHERE evaluation_id = '.intval($this->id)
733
-			.' )'
734
-			.' ORDER BY lastname';
735
-
736
-		$result = Database::query($sql);
737
-		$users = Database::store_result($result);
738
-
739
-		return $users;
740
-	}
741
-
742
-	/**
743
-	 * Find evaluations by name
744
-	 * @param string $name_mask search string
745
-	 * @return array evaluation objects matching the search criterium
746
-	 * @todo can be written more efficiently using a new (but very complex) sql query
747
-	 */
748
-	public function find_evaluations($name_mask,$selectcat)
749
-	{
750
-		$rootcat = Category::load($selectcat);
751
-		$evals = $rootcat[0]->get_evaluations((api_is_allowed_to_create_course() ? null : api_get_user_id()), true);
752
-		$foundevals = array();
753
-		foreach ($evals as $eval) {
754
-			if (!(api_strpos(api_strtolower($eval->get_name()), api_strtolower($name_mask)) === false)) {
755
-				$foundevals[] = $eval;
756
-			}
757
-		}
758
-		return $foundevals;
759
-	}
760
-
761
-	public function get_item_type()
762
-	{
763
-		return 'E';
764
-	}
765
-
766
-	public function get_icon_name()
767
-	{
768
-		return $this->has_results() ? 'evalnotempty' : 'evalempty';
769
-	}
770
-
771
-	/**
772
-	 * Locks an evaluation, only one who can unlock it is the platform administrator.
773
-	 * @param int locked 1 or unlocked 0
774
-	 *
775
-	 **/
776
-	function lock($locked)
777
-	{
778
-		$table_evaluation = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
779
-		$sql = "UPDATE $table_evaluation SET locked = '".intval($locked)."' WHERE id='".intval($this->id)."'";
780
-		Database::query($sql);
781
-	}
782
-
783
-	function check_lock_permissions()
784
-	{
785
-		if (api_is_platform_admin()) {
786
-			return true;
787
-		} else {
788
-			if ($this->is_locked()) {
789
-				api_not_allowed();
790
-			}
791
-		}
792
-	}
793
-
794
-	function delete_linked_data()
795
-	{
796
-
797
-	}
704
+        if (!api_is_allowed_to_edit()) {
705
+            $sql .= ' AND visible = 1';
706
+        }
707
+        if (isset($cat_id)) {
708
+            $sql .= ' AND category_id = '.intval($cat_id);
709
+        } else {
710
+            $sql .= ' AND category_id >= 0';
711
+        }
712
+
713
+        $result = Database::query($sql);
714
+        $alleval = Evaluation::create_evaluation_objects_from_sql_result($result);
715
+
716
+        return $alleval;
717
+    }
718
+
719
+    /**
720
+     * Get a list of students that do not have a result record for this evaluation
721
+     */
722
+    public function get_not_subscribed_students($first_letter_user = '')
723
+    {
724
+        $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
725
+        $tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
726
+
727
+        $sql = 'SELECT user_id,lastname,firstname,username FROM '.$tbl_user
728
+            ." WHERE lastname LIKE '".Database::escape_string($first_letter_user)."%'"
729
+            .' AND status = '.STUDENT
730
+            .' AND user_id NOT IN'
731
+            .' (SELECT user_id FROM '.$tbl_grade_results
732
+            .' WHERE evaluation_id = '.intval($this->id)
733
+            .' )'
734
+            .' ORDER BY lastname';
735
+
736
+        $result = Database::query($sql);
737
+        $users = Database::store_result($result);
738
+
739
+        return $users;
740
+    }
741
+
742
+    /**
743
+     * Find evaluations by name
744
+     * @param string $name_mask search string
745
+     * @return array evaluation objects matching the search criterium
746
+     * @todo can be written more efficiently using a new (but very complex) sql query
747
+     */
748
+    public function find_evaluations($name_mask,$selectcat)
749
+    {
750
+        $rootcat = Category::load($selectcat);
751
+        $evals = $rootcat[0]->get_evaluations((api_is_allowed_to_create_course() ? null : api_get_user_id()), true);
752
+        $foundevals = array();
753
+        foreach ($evals as $eval) {
754
+            if (!(api_strpos(api_strtolower($eval->get_name()), api_strtolower($name_mask)) === false)) {
755
+                $foundevals[] = $eval;
756
+            }
757
+        }
758
+        return $foundevals;
759
+    }
760
+
761
+    public function get_item_type()
762
+    {
763
+        return 'E';
764
+    }
765
+
766
+    public function get_icon_name()
767
+    {
768
+        return $this->has_results() ? 'evalnotempty' : 'evalempty';
769
+    }
770
+
771
+    /**
772
+     * Locks an evaluation, only one who can unlock it is the platform administrator.
773
+     * @param int locked 1 or unlocked 0
774
+     *
775
+     **/
776
+    function lock($locked)
777
+    {
778
+        $table_evaluation = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
779
+        $sql = "UPDATE $table_evaluation SET locked = '".intval($locked)."' WHERE id='".intval($this->id)."'";
780
+        Database::query($sql);
781
+    }
782
+
783
+    function check_lock_permissions()
784
+    {
785
+        if (api_is_platform_admin()) {
786
+            return true;
787
+        } else {
788
+            if ($this->is_locked()) {
789
+                api_not_allowed();
790
+            }
791
+        }
792
+    }
793
+
794
+    function delete_linked_data()
795
+    {
796
+
797
+    }
798 798
 
799 799
     public function getStudentList()
800 800
     {
801 801
         return $this->studentList;
802 802
     }
803 803
 
804
-	public function setStudentList($list)
805
-	{
806
-		$this->studentList = $list;
807
-	}
804
+    public function setStudentList($list)
805
+    {
806
+        $this->studentList = $list;
807
+    }
808 808
 }
Please login to merge, or discard this patch.
main/gradebook/lib/fe/scoredisplayform.class.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -10,24 +10,24 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class ScoreDisplayForm extends FormValidator
12 12
 {
13
-	/**
14
-	 * @param $form_name
15
-	 * @param null $action
16
-	 */
17
-	public function __construct($form_name, $action= null)
18
-	{
19
-		parent :: __construct($form_name, 'post', $action);
20
-		$displayscore = ScoreDisplay :: instance();
21
-		$customdisplays = $displayscore->get_custom_score_display_settings();
22
-
23
-		$nr_items = (count($customdisplays)!='0') ? count($customdisplays) : '1';
24
-		$this->setDefaults(array (
13
+    /**
14
+     * @param $form_name
15
+     * @param null $action
16
+     */
17
+    public function __construct($form_name, $action= null)
18
+    {
19
+        parent :: __construct($form_name, 'post', $action);
20
+        $displayscore = ScoreDisplay :: instance();
21
+        $customdisplays = $displayscore->get_custom_score_display_settings();
22
+
23
+        $nr_items = (count($customdisplays)!='0') ? count($customdisplays) : '1';
24
+        $this->setDefaults(array (
25 25
             'scorecolpercent' => $displayscore->get_color_split_value()
26
-		));
26
+        ));
27 27
 
28
-		$this->addElement('hidden', 'maxvalue', '100');
29
-		$this->addElement('hidden', 'minvalue', '0');
30
-		$counter= 1;
28
+        $this->addElement('hidden', 'maxvalue', '100');
29
+        $this->addElement('hidden', 'minvalue', '0');
30
+        $counter= 1;
31 31
 
32 32
         //setting the default values
33 33
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         }
43 43
         $scorecol = array();
44 44
 
45
-		//settings for the colored score
45
+        //settings for the colored score
46 46
         $this->addElement('header', get_lang('ScoreEdit'));
47 47
 
48 48
         if ($displayscore->is_coloring_enabled()) {
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
             $this->addRule(array('scorecolpercent','minvalue'), get_lang('UnderMin'), 'compare', '>');
68 68
         }
69 69
 
70
-		//Settings for the scoring system
70
+        //Settings for the scoring system
71 71
 
72 72
         if ($displayscore->is_custom()) {
73 73
             $this->addElement('html', '<br /><b>' . get_lang('ScoringSystem') . '</b>');
Please login to merge, or discard this patch.
main/exercise/TestCategory.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
     public $name;
16 16
     public $description;
17 17
 
18
-	/**
19
-	 * Constructor of the class Category
18
+    /**
19
+     * Constructor of the class Category
20 20
      */
21 21
     public function __construct()
22 22
     {
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
         return  false;
50 50
     }
51 51
 
52
-	/**
52
+    /**
53 53
      * add TestCategory in the database if name doesn't already exists
54
-	 */
54
+     */
55 55
     public function addCategoryInBDD()
56 56
     {
57 57
         $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
      * @param int exercise
493 493
      * @param array $check_in_question_list
494 494
      * @param array $categoriesAddedInExercise
495
-    *
496
-    * @param int $exerciseId
497
-    * @return array
498
-    */
495
+     *
496
+     * @param int $exerciseId
497
+     * @return array
498
+     */
499 499
     static function getQuestionsByCat(
500 500
         $exerciseId,
501 501
         $check_in_question_list = array(),
@@ -621,9 +621,9 @@  discard block
 block discarded – undo
621 621
     }
622 622
 
623 623
     /**
624
-    * Display signs [+] and/or (>0) after question title if question has options
625
-    * scoreAlwaysPositive and/or uncheckedMayScore
626
-    */
624
+     * Display signs [+] and/or (>0) after question title if question has options
625
+     * scoreAlwaysPositive and/or uncheckedMayScore
626
+     */
627 627
     public function displayQuestionOption($in_objQuestion)
628 628
     {
629 629
         if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->scoreAlwaysPositive) {
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
      * key of $tabCategoryQuestions are the category id (0 for not in a category)
640 640
      * value is the array of question id of this category
641 641
      * Sort question by Category
642
-    */
642
+     */
643 643
     public static function sortTabByBracketLabel($in_tab)
644 644
     {
645 645
         $tabResult = array();
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
      * count the number of questions in all categories, and return the max
700 700
      * @param int $exerciseId
701 701
      * @author - hubert borderiou
702
-    */
702
+     */
703 703
     public static function getNumberMaxQuestionByCat($exerciseId)
704 704
     {
705 705
         $res_num_max = 0;
Please login to merge, or discard this patch.
main/exercise/export/qti2/qti2_export.php 1 patch
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
     public $answer;
27 27
 
28 28
     /**
29
-    * Constructor.
30
-    *
31
-    * @param Ims2Question $question Ims2Question object we want to export.
32
-    */
29
+     * Constructor.
30
+     *
31
+     * @param Ims2Question $question Ims2Question object we want to export.
32
+     */
33 33
     public function __construct($question)
34 34
     {
35 35
         $this->question = $question;
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
     }
39 39
 
40 40
     /**
41
-    * Start the XML flow.
42
-    *
43
-    * This opens the <item> block, with correct attributes.
44
-    *
45
-    */
41
+     * Start the XML flow.
42
+     *
43
+     * This opens the <item> block, with correct attributes.
44
+     *
45
+     */
46 46
     function start_item()
47 47
     {
48 48
         $categoryTitle = '';
@@ -66,49 +66,49 @@  discard block
 block discarded – undo
66 66
     }
67 67
 
68 68
     /**
69
-    * End the XML flow, closing the </item> tag.
70
-    *
71
-    */
69
+     * End the XML flow, closing the </item> tag.
70
+     *
71
+     */
72 72
     function end_item()
73 73
     {
74 74
         return "</assessmentItem>\n";
75 75
     }
76 76
 
77 77
     /**
78
-    * Start the itemBody
79
-    *
80
-    */
78
+     * Start the itemBody
79
+     *
80
+     */
81 81
     function start_item_body()
82 82
     {
83 83
         return '  <itemBody>' . "\n";
84 84
     }
85 85
 
86 86
     /**
87
-    * End the itemBody part.
88
-    *
89
-    */
87
+     * End the itemBody part.
88
+     *
89
+     */
90 90
     function end_item_body()
91 91
     {
92 92
         return "  </itemBody>\n";
93 93
     }
94 94
 
95 95
     /**
96
-    * add the response processing template used.
97
-    *
98
-    */
96
+     * add the response processing template used.
97
+     *
98
+     */
99 99
     function add_response_processing()
100 100
     {
101 101
         return '  <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>' . "\n";
102 102
     }
103 103
 
104 104
     /**
105
-    * Export the question as an IMS/QTI Item.
106
-    *
107
-    * This is a default behaviour, some classes may want to override this.
108
-    *
109
-    * @param $standalone: Boolean stating if it should be exported as a stand-alone question
110
-    * @return string string, the XML flow for an Item.
111
-    */
105
+     * Export the question as an IMS/QTI Item.
106
+     *
107
+     * This is a default behaviour, some classes may want to override this.
108
+     *
109
+     * @param $standalone: Boolean stating if it should be exported as a stand-alone question
110
+     * @return string string, the XML flow for an Item.
111
+     */
112 112
     function export($standalone = false)
113 113
     {
114 114
         $head = $foot = '';
@@ -203,8 +203,8 @@  discard block
 block discarded – undo
203 203
     function export_presentation()
204 204
     {
205 205
         $out = "<presentation_material><flow_mat><material>\n"
206
-             . "  <mattext><![CDATA[" . formatExerciseQtiDescription($this->exercise->selectDescription()) . "]]></mattext>\n"
207
-             . "</material></flow_mat></presentation_material>\n";
206
+                . "  <mattext><![CDATA[" . formatExerciseQtiDescription($this->exercise->selectDescription()) . "]]></mattext>\n"
207
+                . "</material></flow_mat></presentation_material>\n";
208 208
         return $out;
209 209
     }
210 210
 
@@ -218,15 +218,15 @@  discard block
 block discarded – undo
218 218
         $out = '';
219 219
         if ($n = $this->exercise->getShuffle()) {
220 220
             $out.= "<selection_ordering>"
221
-                 . "  <selection>\n"
222
-                 . "    <selection_number>" . $n . "</selection_number>\n"
223
-                 . "  </selection>\n"
224
-                 . '  <order order_type="Random" />'
225
-                 . "\n</selection_ordering>\n";
221
+                    . "  <selection>\n"
222
+                    . "    <selection_number>" . $n . "</selection_number>\n"
223
+                    . "  </selection>\n"
224
+                    . '  <order order_type="Random" />'
225
+                    . "\n</selection_ordering>\n";
226 226
         } else {
227 227
             $out.= '<selection_ordering sequence_type="Normal">' . "\n"
228
-                 . "  <selection />\n"
229
-                 . "</selection_ordering>\n";
228
+                    . "  <selection />\n"
229
+                    . "</selection_ordering>\n";
230 230
         }
231 231
 
232 232
         return $out;
@@ -257,18 +257,18 @@  discard block
 block discarded – undo
257 257
         $head = $foot = '';
258 258
         if ($standalone) {
259 259
             $head = '<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>' . "\n"
260
-                  . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"
261
-                  . "<questestinterop>\n";
260
+                    . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"
261
+                    . "<questestinterop>\n";
262 262
             $foot = "</questestinterop>\n";
263 263
         }
264 264
         $out = $head
265
-             . $this->start_section()
266
-             . $this->export_duration()
267
-             . $this->export_presentation()
268
-             . $this->export_ordering()
269
-             . $this->export_questions()
270
-             . $this->end_section()
271
-             . $foot;
265
+                . $this->start_section()
266
+                . $this->export_duration()
267
+                . $this->export_presentation()
268
+                . $this->export_ordering()
269
+                . $this->export_questions()
270
+                . $this->end_section()
271
+                . $foot;
272 272
 
273 273
         return $out;
274 274
     }
@@ -309,12 +309,12 @@  discard block
 block discarded – undo
309 309
     public $answer;
310 310
 
311 311
     /**
312
-    * Constructor.
313
-    *
314
-    * @param $question The Question object we want to export.
315
-    * @return ImsItem
316
-    * @author Anamd Tihon
317
-    */
312
+     * Constructor.
313
+     *
314
+     * @param $question The Question object we want to export.
315
+     * @return ImsItem
316
+     * @author Anamd Tihon
317
+     */
318 318
     public function __construct($question)
319 319
     {
320 320
         $this->question = $question;
@@ -323,35 +323,35 @@  discard block
 block discarded – undo
323 323
     }
324 324
 
325 325
     /**
326
-    * Start the XML flow.
327
-    *
328
-    * This opens the <item> block, with correct attributes.
329
-    *
330
-    * @author Amand Tihon <[email protected]>
331
-    */
326
+     * Start the XML flow.
327
+     *
328
+     * This opens the <item> block, with correct attributes.
329
+     *
330
+     * @author Amand Tihon <[email protected]>
331
+     */
332 332
     function start_item()
333 333
     {
334 334
         return '<item title="' . cleanAttribute(formatExerciseQtiDescription($this->question->selectTitle())) . '" ident="' . $this->questionIdent . '">' . "\n";
335 335
     }
336 336
 
337 337
     /**
338
-    * End the XML flow, closing the </item> tag.
339
-    *
340
-    * @author Amand Tihon <[email protected]>
341
-    */
338
+     * End the XML flow, closing the </item> tag.
339
+     *
340
+     * @author Amand Tihon <[email protected]>
341
+     */
342 342
     function end_item()
343 343
     {
344 344
         return "</item>\n";
345 345
     }
346 346
 
347 347
     /**
348
-    * Create the opening, with the question itself.
349
-    *
350
-    * This means it opens the <presentation> but doesn't close it, as this is the role of end_presentation().
351
-    * In between, the export_responses from the subclass should have been called.
352
-    *
353
-    * @author Amand Tihon <[email protected]>
354
-    */
348
+     * Create the opening, with the question itself.
349
+     *
350
+     * This means it opens the <presentation> but doesn't close it, as this is the role of end_presentation().
351
+     * In between, the export_responses from the subclass should have been called.
352
+     *
353
+     * @author Amand Tihon <[email protected]>
354
+     */
355 355
     function start_presentation()
356 356
     {
357 357
         return '<presentation label="' . $this->questionIdent . '"><flow>' . "\n"
@@ -359,44 +359,44 @@  discard block
 block discarded – undo
359 359
     }
360 360
 
361 361
     /**
362
-    * End the </presentation> part, opened by export_header.
363
-    *
364
-    * @author Amand Tihon <[email protected]>
365
-    */
362
+     * End the </presentation> part, opened by export_header.
363
+     *
364
+     * @author Amand Tihon <[email protected]>
365
+     */
366 366
     function end_presentation()
367 367
     {
368 368
         return "</flow></presentation>\n";
369 369
     }
370 370
 
371 371
     /**
372
-    * Start the response processing, and declare the default variable, SCORE, at 0 in the outcomes.
373
-    *
374
-    * @author Amand Tihon <[email protected]>
375
-    */
372
+     * Start the response processing, and declare the default variable, SCORE, at 0 in the outcomes.
373
+     *
374
+     * @author Amand Tihon <[email protected]>
375
+     */
376 376
     function start_processing()
377 377
     {
378 378
         return '<resprocessing><outcomes><decvar vartype="Integer" defaultval="0" /></outcomes>' . "\n";
379 379
     }
380 380
 
381 381
     /**
382
-    * End the response processing part.
383
-    *
384
-    * @author Amand Tihon <[email protected]>
385
-    */
382
+     * End the response processing part.
383
+     *
384
+     * @author Amand Tihon <[email protected]>
385
+     */
386 386
     function end_processing()
387 387
     {
388 388
         return "</resprocessing>\n";
389 389
     }
390 390
 
391 391
     /**
392
-    * Export the question as an IMS/QTI Item.
393
-    *
394
-    * This is a default behaviour, some classes may want to override this.
395
-    *
396
-    * @param $standalone: Boolean stating if it should be exported as a stand-alone question
397
-    * @return string string, the XML flow for an Item.
398
-    * @author Amand Tihon <[email protected]>
399
-    */
392
+     * Export the question as an IMS/QTI Item.
393
+     *
394
+     * This is a default behaviour, some classes may want to override this.
395
+     *
396
+     * @param $standalone: Boolean stating if it should be exported as a stand-alone question
397
+     * @return string string, the XML flow for an Item.
398
+     * @author Amand Tihon <[email protected]>
399
+     */
400 400
     function export($standalone = False)
401 401
     {
402 402
         global $charset;
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
 
405 405
         if ($standalone) {
406 406
             $head = '<?xml version = "1.0" encoding = "'.$charset.'" standalone = "no"?>' . "\n"
407
-                  . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"
408
-                  . "<questestinterop>\n";
407
+                    . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"
408
+                    . "<questestinterop>\n";
409 409
             $foot = "</questestinterop>\n";
410 410
         }
411 411
 
Please login to merge, or discard this patch.
main/admin/user_export.php 1 patch
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -36,20 +36,20 @@  discard block
 block discarded – undo
36 36
 global $_configuration;
37 37
 
38 38
 if (api_is_multiple_url_enabled()) {
39
-	$tbl_course_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
40
-	$access_url_id = api_get_current_access_url_id();
41
-	if ($access_url_id != -1){
42
-	$sql = "SELECT code,visual_code,title
39
+    $tbl_course_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
40
+    $access_url_id = api_get_current_access_url_id();
41
+    if ($access_url_id != -1){
42
+    $sql = "SELECT code,visual_code,title
43 43
 		FROM $course_table as c
44 44
 		INNER JOIN $tbl_course_rel_access_url as course_rel_url
45 45
 		ON (c.id = course_rel_url.c_id)
46 46
 		WHERE access_url_id = $access_url_id
47 47
 		ORDER BY visual_code";
48
-	}
48
+    }
49 49
 }
50 50
 $result = Database::query($sql);
51 51
 while ($course = Database::fetch_object($result)) {
52
-	$courses[$course->code] = $course->visual_code.' - '.$course->title;
52
+    $courses[$course->code] = $course->visual_code.' - '.$course->title;
53 53
 }
54 54
 $form = new FormValidator('export_users');
55 55
 $form->addElement('header', $tool_name);
@@ -64,19 +64,19 @@  discard block
 block discarded – undo
64 64
 $form->setDefaults(array('file_type' => 'csv'));
65 65
 
66 66
 if ($form->validate()) {
67
-	$export = $form->exportValues();
68
-	$file_type = $export['file_type'];
69
-	$course_code = Database::escape_string($export['course_code']);
70
-	$courseInfo = api_get_course_info($course_code);
71
-	$courseId = $courseInfo['real_id'];
72
-
73
-	$courseSessionValue = explode(':', $export['course_session']);
74
-	$courseSessionCode = '';
75
-	$sessionId = 0;
76
-	$courseSessionId = 0;
77
-	$sessionInfo = [];
78
-
79
-	if (is_array($courseSessionValue) && isset($courseSessionValue[1])) {
67
+    $export = $form->exportValues();
68
+    $file_type = $export['file_type'];
69
+    $course_code = Database::escape_string($export['course_code']);
70
+    $courseInfo = api_get_course_info($course_code);
71
+    $courseId = $courseInfo['real_id'];
72
+
73
+    $courseSessionValue = explode(':', $export['course_session']);
74
+    $courseSessionCode = '';
75
+    $sessionId = 0;
76
+    $courseSessionId = 0;
77
+    $sessionInfo = [];
78
+
79
+    if (is_array($courseSessionValue) && isset($courseSessionValue[1])) {
80 80
         $courseSessionCode = $courseSessionValue[0];
81 81
         $sessionId = $courseSessionValue[1];
82 82
         $courseSessionInfo= api_get_course_info($courseSessionCode);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
         $sessionInfo = api_get_session_info($sessionId);
85 85
     }
86 86
 
87
-	$sql = "SELECT
87
+    $sql = "SELECT
88 88
 				u.user_id 	AS UserId,
89 89
 				u.lastname 	AS LastName,
90 90
 				u.firstname 	AS FirstName,
@@ -95,15 +95,15 @@  discard block
 block discarded – undo
95 95
 				u.status		AS Status,
96 96
 				u.official_code	AS OfficialCode,
97 97
 				u.phone		AS Phone";
98
-	if (strlen($course_code) > 0) {
99
-		$sql .= " FROM $user_table u, $course_user_table cu
98
+    if (strlen($course_code) > 0) {
99
+        $sql .= " FROM $user_table u, $course_user_table cu
100 100
 					WHERE
101 101
 						u.user_id = cu.user_id AND
102 102
 						cu.c_id = $courseId AND
103 103
 						cu.relation_type<>".COURSE_RELATION_TYPE_RRHH."
104 104
 					ORDER BY lastname,firstname";
105
-		$filename = 'export_users_'.$course_code.'_'.api_get_local_time();
106
-	} else if (strlen($courseSessionCode) > 0) {
105
+        $filename = 'export_users_'.$course_code.'_'.api_get_local_time();
106
+    } else if (strlen($courseSessionCode) > 0) {
107 107
         $sql .= " FROM $user_table u, $session_course_user_table scu
108 108
 					WHERE
109 109
 						u.user_id = scu.user_id AND
@@ -112,87 +112,87 @@  discard block
 block discarded – undo
112 112
 					ORDER BY lastname,firstname";
113 113
         $filename = 'export_users_'.$courseSessionCode.'_'.$sessionInfo['name'].'_'.api_get_local_time();
114 114
     } else {
115
-		if (api_is_multiple_url_enabled()) {
116
-			$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
117
-			$access_url_id = api_get_current_access_url_id();
118
-			if ($access_url_id != -1) {
119
-			$sql.= " FROM $user_table u
115
+        if (api_is_multiple_url_enabled()) {
116
+            $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
117
+            $access_url_id = api_get_current_access_url_id();
118
+            if ($access_url_id != -1) {
119
+            $sql.= " FROM $user_table u
120 120
 					INNER JOIN $tbl_user_rel_access_url as user_rel_url
121 121
 				ON (u.user_id= user_rel_url.user_id)
122 122
 				WHERE access_url_id = $access_url_id
123 123
 				ORDER BY lastname,firstname";
124
-			}
125
-		} else {
126
-			$sql .= " FROM $user_table u ORDER BY lastname,firstname";
127
-		}
128
-		$filename = 'export_users_'.api_get_local_time();
129
-	}
130
-	$data = array();
131
-	$extra_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC',false);
132
-	if ($export['addcsvheader']=='1' AND $export['file_type']=='csv') {
133
-		if ($_configuration['password_encryption'] != 'none') {
134
-			$data[] = array(
135
-				'UserId',
136
-				'LastName',
137
-				'FirstName',
138
-				'Email',
139
-				'UserName',
140
-				'AuthSource',
141
-				'Status',
142
-				'OfficialCode',
143
-				'PhoneNumber',
144
-			);
145
-		} else {
146
-			$data[] = array(
147
-				'UserId',
148
-				'LastName',
149
-				'FirstName',
150
-				'Email',
151
-				'UserName',
152
-				'Password',
153
-				'AuthSource',
154
-				'Status',
155
-				'OfficialCode',
156
-				'PhoneNumber',
157
-			);
158
-		}
159
-
160
-		foreach($extra_fields as $extra) {
161
-			$data[0][]=$extra[1];
162
-		}
163
-	}
164
-
165
-	$res = Database::query($sql);
166
-	while($user = Database::fetch_array($res,'ASSOC')) {
167
-		$student_data = UserManager:: get_extra_user_data(
168
-			$user['UserId'],
169
-			true,
170
-			false
171
-		);
172
-		foreach($student_data as $key=>$value) {
173
-			$key = substr($key, 6);
174
-			if (is_array($value)) {
175
-				$user[$key] = $value['extra_' . $key];
176
-			} else {
177
-				$user[$key] = $value;
178
-			}
179
-		}
180
-		$data[] = $user	;
181
-	}
182
-
183
-	switch ($file_type) {
184
-		case 'xml':
185
-			Export::arrayToXml($data, $filename, 'Contact', 'Contacts');
186
-			exit;
187
-			break;
188
-		case 'csv':
189
-			Export::arrayToCsv($data, $filename);
190
-			exit;
191
-		case 'xls':
192
-			Export::arrayToXls($data, $filename);
193
-			exit;
194
-			break;
195
-	}
124
+            }
125
+        } else {
126
+            $sql .= " FROM $user_table u ORDER BY lastname,firstname";
127
+        }
128
+        $filename = 'export_users_'.api_get_local_time();
129
+    }
130
+    $data = array();
131
+    $extra_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC',false);
132
+    if ($export['addcsvheader']=='1' AND $export['file_type']=='csv') {
133
+        if ($_configuration['password_encryption'] != 'none') {
134
+            $data[] = array(
135
+                'UserId',
136
+                'LastName',
137
+                'FirstName',
138
+                'Email',
139
+                'UserName',
140
+                'AuthSource',
141
+                'Status',
142
+                'OfficialCode',
143
+                'PhoneNumber',
144
+            );
145
+        } else {
146
+            $data[] = array(
147
+                'UserId',
148
+                'LastName',
149
+                'FirstName',
150
+                'Email',
151
+                'UserName',
152
+                'Password',
153
+                'AuthSource',
154
+                'Status',
155
+                'OfficialCode',
156
+                'PhoneNumber',
157
+            );
158
+        }
159
+
160
+        foreach($extra_fields as $extra) {
161
+            $data[0][]=$extra[1];
162
+        }
163
+    }
164
+
165
+    $res = Database::query($sql);
166
+    while($user = Database::fetch_array($res,'ASSOC')) {
167
+        $student_data = UserManager:: get_extra_user_data(
168
+            $user['UserId'],
169
+            true,
170
+            false
171
+        );
172
+        foreach($student_data as $key=>$value) {
173
+            $key = substr($key, 6);
174
+            if (is_array($value)) {
175
+                $user[$key] = $value['extra_' . $key];
176
+            } else {
177
+                $user[$key] = $value;
178
+            }
179
+        }
180
+        $data[] = $user	;
181
+    }
182
+
183
+    switch ($file_type) {
184
+        case 'xml':
185
+            Export::arrayToXml($data, $filename, 'Contact', 'Contacts');
186
+            exit;
187
+            break;
188
+        case 'csv':
189
+            Export::arrayToCsv($data, $filename);
190
+            exit;
191
+        case 'xls':
192
+            Export::arrayToXls($data, $filename);
193
+            exit;
194
+            break;
195
+    }
196 196
 }
197 197
 
198 198
 Display :: display_header($tool_name);
Please login to merge, or discard this patch.