get_stat_track_exercise_info_by_exe_id($exe_id); if (!empty($exercise_stat_info) && isset($exercise_stat_info['exe_exo_id'])) { header('Location: overview.php?exerciseId='.$exercise_stat_info['exe_exo_id'].'&'.api_get_cidreq()); exit; } api_not_allowed(true); } $js = ''; $htmlHeadXtra[] = $js; if (api_is_in_gradebook()) { $interbreadcrumb[] = [ 'url' => Category::getUrl(), 'name' => get_lang('Assessments'), ]; } $nameTools = get_lang('Tests'); $interbreadcrumb[] = [ 'url' => 'exercise.php?'.api_get_cidreq(), 'name' => get_lang('Tests'), ]; $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; if (api_get_configuration_value('quiz_prevent_copy_paste')) { $htmlHeadXtra[] = ''; } if (!empty($objExercise->getResultAccess())) { /*$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/renderers/minute/epiclock.minute.css'); $htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.dateformat.min.js'); $htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.epiclock.min.js'); $htmlHeadXtra[] = api_get_js('epiclock/renderers/minute/epiclock.minute.js');*/ } $htmlHeadXtra[] = api_get_build_js('exercise.js'); if (!in_array($origin, ['learnpath', 'embeddable'])) { // So we are not in learnpath tool Display::display_header($nameTools, get_lang('Test')); } else { $htmlHeadXtra[] = " "; Display::display_reduced_header(); } // I'm in a preview mode as course admin. Display the action menu. if (api_is_course_admin() && !in_array($origin, ['learnpath', 'embeddable'])) { echo '
'; echo ''. Display::return_icon('back.png', get_lang('Go back to the questions list'), [], 32).''; echo ''. Display::return_icon('edit.png', get_lang('ModifyTest'), [], 32).''; echo '
'; } $exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id); $learnpath_id = isset($exercise_stat_info['orig_lp_id']) ? $exercise_stat_info['orig_lp_id'] : 0; $learnpath_item_id = isset($exercise_stat_info['orig_lp_item_id']) ? $exercise_stat_info['orig_lp_item_id'] : 0; $learnpath_item_view_id = isset($exercise_stat_info['orig_lp_item_view_id']) ? $exercise_stat_info['orig_lp_item_view_id'] : 0; if ($origin === 'learnpath') { ?>
$objExercise->id, 'learnpath_id' => $learnpath_id, 'learnpath_item_id' => $learnpath_item_id, 'learnpath_item_view_id' => $learnpath_item_view_id, ]), 'pencil-square-o', 'info' ); } // We check if the user attempts before sending to the exercise_result.php if ($objExercise->selectAttempts() > 0) { $attempt_count = Event::get_attempt_count( api_get_user_id(), $objExercise->id, $learnpath_id, $learnpath_item_id, $learnpath_item_view_id ); if ($attempt_count >= $objExercise->selectAttempts()) { echo Display::return_message( sprintf(get_lang('You cannot take test %s because you have already reached the maximum of %s attempts.'), $objExercise->selectTitle(), $objExercise->selectAttempts()), 'warning', false ); if (!in_array($origin, ['learnpath', 'embeddable'])) { //we are not in learnpath tool Display::display_footer(); } exit; } else { $attempt_count++; $remainingAttempts = $objExercise->selectAttempts() - $attempt_count; if ($remainingAttempts) { $attemptMessage = sprintf(get_lang('Remaining %d attempts'), $remainingAttempts); $remainingMessage = sprintf('

%s

%s', $attemptMessage, $attemptButton); } } } else { $remainingMessage = $attemptButton ? "

$attemptButton

" : ''; } $total_score = 0; if (!empty($exercise_stat_info)) { $total_score = $exercise_stat_info['score']; } $max_score = $objExercise->get_max_score(); if ($origin === 'embeddable') { showEmbeddableFinishButton(); } else { echo Display::return_message(get_lang('Saved.').'
', 'normal', false); } $saveResults = true; $feedbackType = $objExercise->getFeedbackType(); if (!in_array($feedbackType, [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP])) { //$saveResults = false; } // Display and save questions ExerciseLib::displayQuestionListByAttempt( $objExercise, $exe_id, $saveResults, $remainingMessage ); //Unset session for clock time ExerciseLib::exercise_time_control_delete( $objExercise->id, $learnpath_id, $learnpath_item_id ); ExerciseLib::delete_chat_exercise_session($exe_id); if (!in_array($origin, ['learnpath', 'embeddable'])) { echo '
'; echo Display::url( get_lang('Return to Course Homepage'), api_get_course_url(), ['class' => 'btn btn-primary'] ); echo '
'; if (api_is_allowed_to_session_edit()) { Exercise::cleanSessionVariables(); } Display::display_footer(); } elseif ($origin === 'embeddable') { if (api_is_allowed_to_session_edit()) { Exercise::cleanSessionVariables(); } Session::write('attempt_remaining', $remainingMessage); showEmbeddableFinishButton(); Display::display_reduced_footer(); } else { $lp_mode = Session::read('lp_mode'); $url = '../lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exercise_stat_info['exe_id'].'&fb_type='.$objExercise->getFeedbackType().'#atoc_'.$learnpath_item_id; $href = $lp_mode === 'fullscreen' ? ' window.opener.location.href="'.$url.'" ' : ' top.location.href="'.$url.'"'; if (api_is_allowed_to_session_edit()) { Exercise::cleanSessionVariables(); } Session::write('attempt_remaining', $remainingMessage); // Record the results in the learning path, using the SCORM interface (API) echo ""; echo ''; Display::display_reduced_footer(); } function showEmbeddableFinishButton() { echo ''; echo Display::tag( 'p', Display::toolbarButton( get_lang('End test'), '#', 'times', 'warning', ['role' => 'button', 'class' => 'btn-close-quiz'] ), ['class' => 'text-right'] ); }