From 4cc5ef2e63bc1f921b885c6a326999e86f0c10d7 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 5 Nov 2019 16:08:12 +0100 Subject: [PATCH] Exercises: Remove item property unused code. --- main/exercise/exercise.class.php | 865 +------------------------------ main/exercise/exercise.php | 2 +- 2 files changed, 10 insertions(+), 857 deletions(-) diff --git a/main/exercise/exercise.class.php b/main/exercise/exercise.class.php index 101c883739..77d59648c5 100755 --- a/main/exercise/exercise.class.php +++ b/main/exercise/exercise.class.php @@ -1706,24 +1706,6 @@ class Exercise api_get_group_entity() ); - // insert into the item_property table - /*api_item_property_update( - $this->course, - TOOL_QUIZ, - $this->id, - 'QuizAdded', - api_get_user_id() - ); - - // This function save the quiz again, carefull about start_time - // and end_time if you remove this line (see above) - api_set_default_visibility( - $this->id, - TOOL_QUIZ, - null, - $this->course - );*/ - if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) { $this->search_engine_save(); } @@ -6224,15 +6206,16 @@ class Exercise ]; } - // Checking visibility in the item_property table. - $visibility = api_get_item_visibility( - api_get_course_info(), - TOOL_QUIZ, - $this->id, - api_get_session_id() - ); + $repo = Container::getExerciseRepository(); + $exercise = $repo->find($this->iId); - if ($visibility == 0 || $visibility == 2) { + if ($exercise === null) { + return []; + } + + $link = $exercise->getFirstResourceLinkFromCourseSession(); + + if ($link->isDraft()) { $this->active = 0; } @@ -8608,836 +8591,6 @@ class Exercise return $html; } - /** - * Return an HTML table of exercises for on-screen printing, including - * action icons. If no exercise is present and the user can edit the - * course, show a "create test" button. - - * - * @param int $categoryId - * @param string $keyword - * - * @return string - */ - public static function exerciseGrid($categoryId, $keyword = '') - { - $TBL_EXERCISE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION); - $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST); - $TBL_TRACK_EXERCISES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); - - $categoryId = (int) $categoryId; - $keyword = Database::escape_string($keyword); - $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; - - $autoLaunchAvailable = false; - if (api_get_course_setting('enable_exercise_auto_launch') == 1 && - api_get_configuration_value('allow_exercise_auto_launch') - ) { - $autoLaunchAvailable = true; - } - - $is_allowedToEdit = api_is_allowed_to_edit(null, true); - $courseInfo = api_get_course_info(); - $sessionId = api_get_session_id(); - $courseId = $courseInfo['real_id']; - $tableRows = []; - $origin = api_get_origin(); - $userInfo = api_get_user_info(); - $charset = 'utf-8'; - $token = Security::get_token(); - $userId = api_get_user_id(); - $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh($userId, $courseInfo); - $limitTeacherAccess = api_get_configuration_value('limit_exercise_teacher_access'); - - // Condition for the session - $condition_session = api_get_session_condition($sessionId, true, true); - $content = ''; - $column = 0; - if ($is_allowedToEdit) { - $column = 1; - } - - $table = new SortableTableFromArrayConfig( - [], - $column, - self::PAGINATION_ITEMS_PER_PAGE, - 'exercises_cat_'.$categoryId - ); - - $limit = $table->per_page; - $page = $table->page_nr; - $from = $limit * ($page - 1); - - $categoryCondition = ''; - if (api_get_configuration_value('allow_exercise_categories')) { - if (!empty($categoryId)) { - $categoryCondition = " AND exercise_category_id = $categoryId "; - } else { - $categoryCondition = ' AND exercise_category_id IS NULL '; - } - } - - $keywordCondition = ''; - if (!empty($keyword)) { - $keywordCondition = " AND title LIKE '%$keyword%' "; - } - - // Only for administrators - if ($is_allowedToEdit) { - $total_sql = "SELECT count(iid) as count - FROM $TBL_EXERCISES - WHERE - c_id = $courseId AND - active <> -1 - $condition_session - $categoryCondition - $keywordCondition - "; - $sql = "SELECT * FROM $TBL_EXERCISES - WHERE - c_id = $courseId AND - active <> -1 - $condition_session - $categoryCondition - $keywordCondition - ORDER BY title - LIMIT $from , $limit"; - } else { - // Only for students - $total_sql = "SELECT count(iid) as count - FROM $TBL_EXERCISES - WHERE - c_id = $courseId AND - active = 1 - $condition_session - $categoryCondition - $keywordCondition - "; - $sql = "SELECT * FROM $TBL_EXERCISES - WHERE c_id = $courseId AND - active = 1 - $condition_session - $categoryCondition - $keywordCondition - ORDER BY title - LIMIT $from , $limit"; - } - - $result = Database::query($sql); - $result_total = Database::query($total_sql); - - $total_exercises = 0; - if (Database :: num_rows($result_total)) { - $result_total = Database::fetch_array($result_total); - $total_exercises = $result_total['count']; - } - - $total = $total_exercises; - $exerciseList = []; - while ($row = Database::fetch_array($result, 'ASSOC')) { - $exerciseList[] = $row; - } - - if (!empty($exerciseList) && - api_get_setting('exercise_invisible_in_session') === 'true' - ) { - if (!empty($sessionId)) { - $changeDefaultVisibility = true; - if (api_get_setting('configure_exercise_visibility_in_course') === 'true') { - $changeDefaultVisibility = false; - if (api_get_course_setting('exercise_invisible_in_session') == 1) { - $changeDefaultVisibility = true; - } - } - - if ($changeDefaultVisibility) { - // Check exercise - foreach ($exerciseList as $exercise) { - if ($exercise['session_id'] == 0) { - $visibilityInfo = api_get_item_property_info( - $courseId, - TOOL_QUIZ, - $exercise['iid'], - $sessionId - ); - - if (empty($visibilityInfo)) { - // Create a record for this - api_item_property_update( - $courseInfo, - TOOL_QUIZ, - $exercise['iid'], - 'invisible', - api_get_user_id(), - 0, - null, - '', - '', - $sessionId - ); - } - } - } - } - } - } - - if (!empty($exerciseList)) { - if ($origin !== 'learnpath') { - $visibilitySetting = api_get_configuration_value('show_hidden_exercise_added_to_lp'); - //avoid sending empty parameters - $mylpid = empty($learnpath_id) ? '' : '&learnpath_id='.$learnpath_id; - $mylpitemid = empty($learnpath_item_id) ? '' : '&learnpath_item_id='.$learnpath_item_id; - foreach ($exerciseList as $row) { - $currentRow = []; - $my_exercise_id = $row['id']; - $attempt_text = ''; - $actions = ''; - $exercise = new Exercise(); - $exercise->read($my_exercise_id, false); - - if (empty($exercise->id)) { - continue; - } - - $locked = $exercise->is_gradebook_locked; - // Validation when belongs to a session - $session_img = api_get_session_image($row['session_id'], $userInfo['status']); - - $time_limits = false; - if (!empty($row['start_time']) || !empty($row['end_time'])) { - $time_limits = true; - } - - $is_actived_time = false; - if ($time_limits) { - // check if start time - $start_time = false; - if (!empty($row['start_time'])) { - $start_time = api_strtotime($row['start_time'], 'UTC'); - } - $end_time = false; - if (!empty($row['end_time'])) { - $end_time = api_strtotime($row['end_time'], 'UTC'); - } - $now = time(); - - //If both "clocks" are enable - if ($start_time && $end_time) { - if ($now > $start_time && $end_time > $now) { - $is_actived_time = true; - } - } else { - //we check the start and end - if ($start_time) { - if ($now > $start_time) { - $is_actived_time = true; - } - } - if ($end_time) { - if ($end_time > $now) { - $is_actived_time = true; - } - } - } - } - - // Blocking empty start times see BT#2800 - global $_custom; - if (isset($_custom['exercises_hidden_when_no_start_date']) && - $_custom['exercises_hidden_when_no_start_date'] - ) { - if (empty($row['start_time'])) { - $time_limits = true; - $is_actived_time = false; - } - } - - $cut_title = $exercise->getCutTitle(); - $alt_title = ''; - if ($cut_title != $row['title']) { - $alt_title = ' title = "'.$exercise->getUnformattedTitle().'" '; - } - - // Teacher only - if ($is_allowedToEdit) { - $lp_blocked = null; - if ($exercise->exercise_was_added_in_lp == true) { - $lp_blocked = Display::div( - get_lang('This exercise has been included in a learning path, so it cannot be accessed by students directly from here. If you want to put the same exercise available through the exercises tool, please make a copy of the current exercise using the copy icon.'), - ['class' => 'lp_content_type_label'] - ); - } - - // Get visibility in base course - $visibility = api_get_item_visibility( - $courseInfo, - TOOL_QUIZ, - $my_exercise_id, - 0 - ); - - if (!empty($sessionId)) { - // If we are in a session, the test is invisible - // in the base course, it is included in a LP - // *and* the setting to show it is *not* - // specifically set to true, then hide it. - if ($visibility == 0) { - if (!$visibilitySetting) { - if ($exercise->exercise_was_added_in_lp == true) { - continue; - } - } - } - - $visibility = api_get_item_visibility( - $courseInfo, - TOOL_QUIZ, - $my_exercise_id, - $sessionId - ); - } - - if ($row['active'] == 0 || $visibility == 0) { - $title = Display::tag('font', $cut_title, ['style' => 'color:grey']); - } else { - $title = $cut_title; - } - - $count_exercise_not_validated = (int) Event::count_exercise_result_not_validated( - $my_exercise_id, - $courseId, - $sessionId - ); - - /*$move = Display::return_icon( - 'all_directions.png', - get_lang('Move'), - ['class' => 'moved', 'style' => 'margin-bottom:-0.5em;'] - );*/ - $move = null; - $class_tip = ''; - if (!empty($count_exercise_not_validated)) { - $results_text = $count_exercise_not_validated == 1 ? get_lang('Result not reviewed') : get_lang('Results and feedback and feedback and feedback and feedback and feedback and feedback not reviewed'); - $title .= ''; - $class_tip = 'link_tooltip'; - } - - $url = $move.' - '.Display::return_icon('quiz.png', $row['title']).' - '.$title.' '.PHP_EOL; - - if (ExerciseLib::isQuizEmbeddable($row)) { - $embeddableIcon = Display::return_icon('om_integration.png', get_lang('ThisQuizCanBeEmbeddable')); - $url .= Display::div($embeddableIcon, ['class' => 'pull-right']); - } - - $currentRow['title'] = $url.' '.$session_img.$lp_blocked; - - // Count number exercise - teacher - $sql = "SELECT count(*) count FROM $TBL_EXERCISE_QUESTION - WHERE c_id = $courseId AND exercice_id = $my_exercise_id"; - $sqlresult = Database::query($sql); - $rowi = (int) Database::result($sqlresult, 0, 0); - - if ($sessionId == $row['session_id']) { - // Questions list - $actions = Display::url( - Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL), - 'admin.php?'.api_get_cidreq().'&exerciseId='.$row['id'] - ); - - // Test settings - $settings = Display::url( - Display::return_icon('settings.png', get_lang('Configure'), '', ICON_SIZE_SMALL), - 'exercise_admin.php?'.api_get_cidreq().'&exerciseId='.$row['id'] - ); - - if ($limitTeacherAccess && !api_is_platform_admin()) { - $settings = ''; - } - $actions .= $settings; - - // Exercise results - $resultsLink = ''. - Display::return_icon('test_results.png', get_lang('Results and feedback and feedback and feedback and feedback and feedback and feedback'), '', ICON_SIZE_SMALL).''; - - if ($limitTeacherAccess) { - if (api_is_platform_admin()) { - $actions .= $resultsLink; - } - } else { - // Exercise results - $actions .= $resultsLink; - } - - // Auto launch - if ($autoLaunchAvailable) { - $autoLaunch = $exercise->getAutoLaunch(); - if (empty($autoLaunch)) { - $actions .= Display::url( - Display::return_icon( - 'launch_na.png', - get_lang('Enable'), - '', - ICON_SIZE_SMALL - ), - 'exercise.php?'.api_get_cidreq().'&action=enable_launch&sec_token='.$token.'&exerciseId='.$row['id'] - ); - } else { - $actions .= Display::url( - Display::return_icon( - 'launch.png', - get_lang('Disable'), - '', - ICON_SIZE_SMALL - ), - 'exercise.php?'.api_get_cidreq().'&action=disable_launch&sec_token='.$token.'&exerciseId='.$row['id'] - ); - } - } - - // Export - $actions .= Display::url( - Display::return_icon('cd.png', get_lang('CopyTest')), - '', - [ - 'onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('Are you sure to copy'), ENT_QUOTES, $charset))." ".addslashes($row['title'])."?"."')) return false;", - 'href' => 'exercise.php?'.api_get_cidreq().'&action=copy_exercise&sec_token='.$token.'&exerciseId='.$row['id'], - ] - ); - - // Clean exercise - if ($locked == false) { - $clean = Display::url( - Display::return_icon( - 'clean.png', - get_lang('Clear all learners results for this exercise and feedback'), - '', - ICON_SIZE_SMALL - ), - '', - [ - 'onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('Are you sure to delete results and feedback'), ENT_QUOTES, $charset))." ".addslashes($row['title'])."?"."')) return false;", - 'href' => 'exercise.php?'.api_get_cidreq().'&action=clean_results&sec_token='.$token.'&exerciseId='.$row['id'], - ] - ); - } else { - $clean = Display::return_icon( - 'clean_na.png', - get_lang('This option is not available because this activity is contained by an assessment, which is currently locked. To unlock the assessment, ask your platform administrator.'), - '', - ICON_SIZE_SMALL - ); - } - - if ($limitTeacherAccess && !api_is_platform_admin()) { - $clean = ''; - } - $actions .= $clean; - // Visible / invisible - // Check if this exercise was added in a LP - if ($exercise->exercise_was_added_in_lp == true) { - $visibility = Display::return_icon( - 'invisible.png', - get_lang('This exercise has been included in a learning path, so it cannot be accessed by students directly from here. If you want to put the same exercise available through the exercises tool, please make a copy of the current exercise using the copy icon.'), - '', - ICON_SIZE_SMALL - ); - } else { - if ($row['active'] == 0 || $visibility == 0) { - $visibility = Display::url( - Display::return_icon( - 'invisible.png', - get_lang('Activate'), - '', - ICON_SIZE_SMALL - ), - 'exercise.php?'.api_get_cidreq().'&action=enable&sec_token='.$token.'&exerciseId='.$row['id'] - ); - } else { - // else if not active - $visibility = Display::url( - Display::return_icon( - 'visible.png', - get_lang('Deactivate'), - '', - ICON_SIZE_SMALL - ), - 'exercise.php?'.api_get_cidreq().'&action=disable&sec_token='.$token.'&exerciseId='.$row['id'] - ); - } - } - - if ($limitTeacherAccess && !api_is_platform_admin()) { - $visibility = ''; - } - - $actions .= $visibility; - - // Export qti ... - $export = Display::url( - Display::return_icon( - 'export_qti2.png', - 'IMS/QTI', - '', - ICON_SIZE_SMALL - ), - 'exercise.php?action=exportqti2&exerciseId='.$row['id'].'&'.api_get_cidreq() - ); - - if ($limitTeacherAccess && !api_is_platform_admin()) { - $export = ''; - } - - $actions .= $export; - } else { - // not session - $actions = Display::return_icon( - 'edit_na.png', - get_lang('TestEditionNotAvailableInSession') - ); - - // Check if this exercise was added in a LP - if ($exercise->exercise_was_added_in_lp == true) { - $visibility = Display::return_icon( - 'invisible.png', - get_lang('This exercise has been included in a learning path, so it cannot be accessed by students directly from here. If you want to put the same exercise available through the exercises tool, please make a copy of the current exercise using the copy icon.'), - '', - ICON_SIZE_SMALL - ); - } else { - if ($row['active'] == 0 || $visibility == 0) { - $visibility = Display::url( - Display::return_icon( - 'invisible.png', - get_lang('Activate'), - '', - ICON_SIZE_SMALL - ), - 'exercise.php?'.api_get_cidreq().'&action=enable&sec_token='.$token.'&exerciseId='.$row['id'] - ); - } else { - // else if not active - $visibility = Display::url( - Display::return_icon( - 'visible.png', - get_lang('Deactivate'), - '', - ICON_SIZE_SMALL - ), - 'exercise.php?'.api_get_cidreq().'&action=disable&sec_token='.$token.'&exerciseId='.$row['id'] - ); - } - } - - if ($limitTeacherAccess && !api_is_platform_admin()) { - $visibility = ''; - } - - $actions .= $visibility; - $actions .= ''. - Display::return_icon('test_results.png', get_lang('Results and feedback and feedback and feedback and feedback and feedback and feedback'), '', ICON_SIZE_SMALL).''; - $actions .= Display::url( - Display::return_icon('cd.gif', get_lang('CopyTest')), - '', - [ - 'onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('Are you sure to copy'), ENT_QUOTES, $charset))." ".addslashes($row['title'])."?"."')) return false;", - 'href' => 'exercise.php?'.api_get_cidreq().'&action=copy_exercise&sec_token='.$token.'&exerciseId='.$row['id'], - ] - ); - } - - // Delete - $delete = ''; - if ($sessionId == $row['session_id']) { - if ($locked == false) { - $delete = Display::url( - Display::return_icon( - 'delete.png', - get_lang('Delete'), - '', - ICON_SIZE_SMALL - ), - '', - [ - 'onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('Are you sure to delete'), ENT_QUOTES, $charset))." ".addslashes($exercise->getUnformattedTitle())."?"."')) return false;", - 'href' => 'exercise.php?'.api_get_cidreq().'&action=delete&sec_token='.$token.'&exerciseId='.$row['id'], - ] - ); - } else { - $delete = Display::return_icon( - 'delete_na.png', - get_lang('This option is not available because this activity is contained by an assessment, which is currently locked. To unlock the assessment, ask your platform administrator.'), - '', - ICON_SIZE_SMALL - ); - } - } - - if ($limitTeacherAccess && !api_is_platform_admin()) { - $delete = ''; - } - - $actions .= $delete; - - // Number of questions - $random_label = null; - if ($row['random'] > 0 || $row['random'] == -1) { - // if random == -1 means use random questions with all questions - $random_number_of_question = $row['random']; - if ($random_number_of_question == -1) { - $random_number_of_question = $rowi; - } - if ($row['random_by_category'] > 0) { - $nbQuestionsTotal = TestCategory::getNumberOfQuestionRandomByCategory( - $my_exercise_id, - $random_number_of_question - ); - $number_of_questions = $nbQuestionsTotal.' '; - $number_of_questions .= ($nbQuestionsTotal > 1) ? get_lang('questions') : get_lang('question'); - $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').') '; - $number_of_questions = $random_number_of_question.' '.$random_label.' / '.$rowi; - // Bug if we set a random value bigger than the real number of questions - if ($random_number_of_question > $rowi) { - $number_of_questions = $rowi.' '.$random_label; - } - } - } else { - $number_of_questions = $rowi; - } - - $currentRow['count_questions'] = $number_of_questions; - } else { - // Student only. - $visibility = api_get_item_visibility( - $courseInfo, - TOOL_QUIZ, - $my_exercise_id, - $sessionId - ); - - if ($visibility == 0) { - continue; - } - - $url = ''. - $cut_title.''; - - // Link of the exercise. - $currentRow['title'] = $url.' '.$session_img; - - // This query might be improved later on by ordering by the new "tms" field rather than by exe_id - // Don't remove this marker: note-query-exe-results - $sql = "SELECT * FROM $TBL_TRACK_EXERCISES - WHERE - exe_exo_id = ".$row['id']." AND - exe_user_id = $userId AND - c_id = ".api_get_course_int_id()." AND - status <> 'incomplete' AND - orig_lp_id = 0 AND - orig_lp_item_id = 0 AND - session_id = '".api_get_session_id()."' - ORDER BY exe_id DESC"; - - $qryres = Database::query($sql); - $num = Database :: num_rows($qryres); - - // Hide the results. - $my_result_disabled = $row['results_disabled']; - - $attempt_text = '-'; - // Time limits are on - if ($time_limits) { - // Exam is ready to be taken - if ($is_actived_time) { - // Show results - if ( - in_array( - $my_result_disabled, - [ - RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS, - RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS_AND_RANKING, - RESULT_DISABLE_SHOW_SCORE_ONLY, - RESULT_DISABLE_RANKING, - ] - ) - ) { - // More than one attempt - if ($num > 0) { - $row_track = Database :: fetch_array($qryres); - $attempt_text = get_lang('LatestAttempt').' : '; - $attempt_text .= ExerciseLib::show_score( - $row_track['exe_result'], - $row_track['exe_weighting'] - ); - } else { - //No attempts - $attempt_text = get_lang('Not attempted'); - } - } else { - $attempt_text = '-'; - } - } else { - // Quiz not ready due to time limits - //@todo use the is_visible function - if (!empty($row['start_time']) && !empty($row['end_time'])) { - $today = time(); - $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']) - ); - } 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']) - ); - } - } - } else { - //$attempt_text = get_lang('ExamNotAvailableAtThisTime'); - if (!empty($row['start_time'])) { - $attempt_text = sprintf( - get_lang('TestAvailableFromX'), - api_convert_and_format_date($row['start_time']) - ); - } - if (!empty($row['end_time'])) { - $attempt_text = sprintf( - get_lang('TestAvailableUntilX'), - api_convert_and_format_date($row['end_time']) - ); - } - } - } - } else { - // Normal behaviour. - // Show results. - if ( - in_array( - $my_result_disabled, - [ - RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS, - RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS_AND_RANKING, - RESULT_DISABLE_SHOW_SCORE_ONLY, - RESULT_DISABLE_RANKING, - ] - ) - ) { - if ($num > 0) { - $row_track = Database :: fetch_array($qryres); - $attempt_text = get_lang('LatestAttempt').' : '; - $attempt_text .= ExerciseLib::show_score( - $row_track['exe_result'], - $row_track['exe_weighting'] - ); - } else { - $attempt_text = get_lang('Not attempted'); - } - } - } - } - - $currentRow['attempt'] = $attempt_text; - - if ($is_allowedToEdit) { - $additionalActions = ExerciseLib::getAdditionalTeacherActions($row['id']); - - if (!empty($additionalActions)) { - $actions .= $additionalActions.PHP_EOL; - } - - $currentRow = [ - $row['id'], - $currentRow['title'], - $currentRow['count_questions'], - $actions, - ]; - } else { - $currentRow = [ - $currentRow['title'], - $currentRow['attempt'], - ]; - - if ($isDrhOfCourse) { - $currentRow[] = ''. - Display::return_icon('test_results.png', get_lang('Results and feedback and feedback and feedback and feedback and feedback and feedback'), '', ICON_SIZE_SMALL).''; - } - } - - $tableRows[] = $currentRow; - } - } - } - - if (empty($tableRows) && empty($categoryId)) { - if ($is_allowedToEdit && $origin != 'learnpath') { - $content .= '
'; - $content .= '

'.get_lang('Tests').'

'; - $content .= Display::return_icon('quiz.png', '', [], 64); - $content .= '
'; - $content .= Display::url( - ' '.get_lang('Create a new test'), - 'exercise_admin.php?'.api_get_cidreq(), - ['class' => 'btn btn-primary'] - ); - $content .= '
'; - $content .= '
'; - } - } else { - if (empty($tableRows)) { - return ''; - } - $table->setTableData($tableRows); - $table->setTotalNumberOfItems($total); - $table->set_additional_parameters([ - 'cidReq' => api_get_course_id(), - 'id_session' => api_get_session_id(), - 'category_id' => $categoryId, - ]); - - if ($is_allowedToEdit) { - $formActions = []; - $formActions['visible'] = get_lang('Activate'); - $formActions['invisible'] = get_lang('Deactivate'); - $formActions['delete'] = get_lang('Delete'); - $table->set_form_actions($formActions); - } - - $i = 0; - if ($is_allowedToEdit) { - $table->set_header($i++, '', false, 'width="18px"'); - } - $table->set_header($i++, get_lang('Test name'), false); - - if ($is_allowedToEdit) { - $table->set_header($i++, get_lang('Questions'), false); - $table->set_header($i++, get_lang('Detail'), false); - } else { - $table->set_header($i++, get_lang('Status'), false); - if ($isDrhOfCourse) { - $table->set_header($i++, get_lang('Detail'), false); - } - } - - $content .= $table->return_table(); - } - - return $content; - } - /** * @return int value in minutes */ diff --git a/main/exercise/exercise.php b/main/exercise/exercise.php index afad784cf9..5b107c09ac 100644 --- a/main/exercise/exercise.php +++ b/main/exercise/exercise.php @@ -378,7 +378,7 @@ if ($is_allowedToEdit) { } if (api_get_configuration_value('allow_exercise_categories') === false) { - echo Exercise::exerciseGrid(0, $keyword); + echo Exercise::exerciseGridResource(0, $keyword); } else { if (empty($categoryId)) { echo Display::page_subheader(get_lang('General'));