Julio Montoya 6 жил өмнө
parent
commit
41b1c1b1a4
1 өөрчлөгдсөн 26 нэмэгдсэн , 27 устгасан
  1. 26 27
      main/exercise/exercise.php

+ 26 - 27
main/exercise/exercise.php

@@ -50,7 +50,7 @@ $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
 $TBL_TRACK_EXERCISES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
 
 // document path
-$documentPath = api_get_path(SYS_COURSE_PATH).$courseInfo['path']."/document";
+$documentPath = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/document';
 // picture path
 $picturePath = $documentPath.'/images';
 // audio path
@@ -62,10 +62,9 @@ $exercisePath = api_get_self();
 $exfile = explode('/', $exercisePath);
 $exfile = strtolower($exfile[sizeof($exfile) - 1]);
 $exercisePath = substr($exercisePath, 0, strpos($exercisePath, $exfile));
-$exercisePath = $exercisePath."exercise.php";
+$exercisePath = $exercisePath.'exercise.php';
 
 // Clear the exercise session
-
 Session::erase('objExercise');
 Session::erase('objQuestion');
 Session::erase('objAnswer');
@@ -82,9 +81,9 @@ $choice = isset($_REQUEST['choice']) ? Security::remove_XSS($_REQUEST['choice'])
 $hpchoice = isset($_REQUEST['hpchoice']) ? Security::remove_XSS($_REQUEST['hpchoice']) : null;
 $exerciseId = isset($_REQUEST['exerciseId']) ? (int) $_REQUEST['exerciseId'] : null;
 $file = isset($_REQUEST['file']) ? Database::escape_string($_REQUEST['file']) : null;
-$learnpath_id = isset($_REQUEST['learnpath_id']) ? intval($_REQUEST['learnpath_id']) : null;
-$learnpath_item_id = isset($_REQUEST['learnpath_item_id']) ? intval($_REQUEST['learnpath_item_id']) : null;
-$page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : null;
+$learnpath_id = isset($_REQUEST['learnpath_id']) ? (int) $_REQUEST['learnpath_id'] : null;
+$learnpath_item_id = isset($_REQUEST['learnpath_item_id']) ? (int) $_REQUEST['learnpath_item_id'] : null;
+$page = isset($_REQUEST['page']) ? (int) $_REQUEST['page'] : null;
 
 if ($page < 0) {
     $page = 1;
@@ -106,7 +105,7 @@ if (api_get_course_setting('enable_exercise_auto_launch') == 1 &&
 
 $nameTools = get_lang('Exercises');
 $errorXmlExport = null;
-if ($is_allowedToEdit && !empty($choice) && $choice == 'exportqti2') {
+if ($is_allowedToEdit && !empty($choice) && $choice === 'exportqti2') {
     require_once api_get_path(SYS_CODE_PATH).'exercise/export/qti2/qti2_export.php';
 
     $export = export_exercise_to_qti($exerciseId, true);
@@ -158,7 +157,6 @@ $logInfo = [
     'action' => isset($_REQUEST['learnpath_id']) ? 'learnpath_id' : '',
     'action_details' => isset($_REQUEST['learnpath_id']) ? (int) $_REQUEST['learnpath_id'] : '',
     'current_id' => 0,
-    'info' => '',
 ];
 Event::registerLog($logInfo);
 
@@ -309,7 +307,7 @@ if ($is_allowedToEdit) {
                         );
                         break;
                     case 'clean_results':
-                        //clean student results
+                        // Clean student results
                         if ($exercise_action_locked == false) {
                             $quantity_results_deleted = $objExerciseTmp->cleanResults(true);
                             $title = $objExerciseTmp->selectTitle();
@@ -371,7 +369,7 @@ if ($is_allowedToEdit) {
             case 'enable': // enables an exercise
                 $newVisibilityStatus = "1"; //"visible"
                 $query = "SELECT id FROM $TBL_DOCUMENT
-                          WHERE c_id = $courseId AND path='".Database :: escape_string($file)."'";
+                          WHERE c_id = $courseId AND path='".Database::escape_string($file)."'";
                 $res = Database::query($query);
                 $row = Database :: fetch_array($res, 'ASSOC');
                 api_item_property_update(
@@ -385,9 +383,9 @@ if ($is_allowedToEdit) {
 
                 break;
             case 'disable': // disables an exercise
-                $newVisibilityStatus = "0"; //"invisible"
+                $newVisibilityStatus = '0'; //"invisible"
                 $query = "SELECT id FROM $TBL_DOCUMENT
-                          WHERE c_id = $courseId AND path='".Database :: escape_string($file)."'";
+                          WHERE c_id = $courseId AND path='".Database::escape_string($file)."'";
                 $res = Database::query($query);
                 $row = Database :: fetch_array($res, 'ASSOC');
                 api_item_property_update(
@@ -536,7 +534,6 @@ if ($total > $limit) {
 }
 
 $i = 1;
-
 $online_icon = Display::return_icon(
     'online.png',
     get_lang('Visible'),
@@ -550,8 +547,7 @@ $offline_icon = Display::return_icon(
 
 $exerciseList = [];
 $list_ordered = null;
-
-while ($row = Database :: fetch_array($result, 'ASSOC')) {
+while ($row = Database::fetch_array($result, 'ASSOC')) {
     $exerciseList[$row['iid']] = $row;
 }
 
@@ -975,9 +971,9 @@ if (!empty($exerciseList)) {
                             $my_exercise_id,
                             $random_number_of_question
                         );
-                        $number_of_questions = $nbQuestionsTotal." ";
-                        $number_of_questions .= ($nbQuestionsTotal > 1) ? get_lang("QuestionsLowerCase") : get_lang("QuestionLowerCase");
-                        $number_of_questions .= " - ";
+                        $number_of_questions = $nbQuestionsTotal.' ';
+                        $number_of_questions .= ($nbQuestionsTotal > 1) ? get_lang('QuestionsLowerCase') : get_lang('QuestionLowerCase');
+                        $number_of_questions .= ' - ';
                         $number_of_questions .= min(TestCategory::getNumberMaxQuestionByCat($my_exercise_id), $random_number_of_question).' '.get_lang('QuestionByCategory');
                     } else {
                         $random_label = ' ('.get_lang('Random').') ';
@@ -990,10 +986,6 @@ if (!empty($exerciseList)) {
                 } else {
                     $number_of_questions = $rowi;
                 }
-
-                //Attempts
-                //$attempts = ExerciseLib::get_count_exam_results($row['id']).' '.get_lang('Attempts');
-                //$item .=  Display::tag('td',$attempts);
                 $item .= Display::tag('td', $number_of_questions);
             } else {
                 // Student only.
@@ -1073,10 +1065,18 @@ if (!empty($exerciseList)) {
                             $start_time = api_strtotime($row['start_time'], 'UTC');
                             $end_time = api_strtotime($row['end_time'], 'UTC');
                             if ($today < $start_time) {
-                                $attempt_text = sprintf(get_lang('ExerciseWillBeActivatedFromXToY'), api_convert_and_format_date($row['start_time']), api_convert_and_format_date($row['end_time']));
+                                $attempt_text = sprintf(
+                                    get_lang('ExerciseWillBeActivatedFromXToY'),
+                                    api_convert_and_format_date($row['start_time']),
+                                    api_convert_and_format_date($row['end_time'])
+                                );
                             } else {
                                 if ($today > $end_time) {
-                                    $attempt_text = sprintf(get_lang('ExerciseWasActivatedFromXToY'), api_convert_and_format_date($row['start_time']), api_convert_and_format_date($row['end_time']));
+                                    $attempt_text = sprintf(
+                                        get_lang('ExerciseWasActivatedFromXToY'),
+                                        api_convert_and_format_date($row['start_time']),
+                                        api_convert_and_format_date($row['end_time'])
+                                    );
                                 }
                             }
                         } else {
@@ -1110,7 +1110,6 @@ if (!empty($exerciseList)) {
                             $attempt_text = get_lang('NotAttempted');
                         }
                     } else {
-                        //$attempt_text = get_lang('CantShowResults');
                         $attempt_text = '-';
                     }
                 }
@@ -1186,7 +1185,6 @@ if ($is_allowedToEdit) {
 }
 
 $result = Database::query($sql);
-
 while ($row = Database :: fetch_array($result, 'ASSOC')) {
     $attribute['path'][] = $row['path'];
     $attribute['visibility'][] = $row['visibility'];
@@ -1221,6 +1219,7 @@ if (isset($attribute['path']) && is_array($attribute['path'])) {
                     ),
                 ])
             );
+
             $item .= Display::tag('td', '-');
 
             $actions = Display::url(
@@ -1358,5 +1357,5 @@ if (empty($exerciseList) && $hotpotatoes_exist == false) {
 }
 
 if ($origin != 'learnpath') { //so we are not in learnpath tool
-    Display :: display_footer();
+    Display::display_footer();
 }