diff --git a/public/main/calendar/agenda.php b/public/main/calendar/agenda.php index 9541eec667..3f3425400e 100644 --- a/public/main/calendar/agenda.php +++ b/public/main/calendar/agenda.php @@ -20,7 +20,7 @@ $this_section = SECTION_COURSES; $url = null; if (empty($action)) { if (!empty($course_info)) { - $url = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=course'.'&'.api_get_cidreq(); + $url = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=course&'.api_get_cidreq(); } else { $url = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?'; } diff --git a/public/main/calendar/agenda_list.php b/public/main/calendar/agenda_list.php index a992d7aa26..d81086a535 100644 --- a/public/main/calendar/agenda_list.php +++ b/public/main/calendar/agenda_list.php @@ -12,7 +12,8 @@ $logInfo = [ ]; Event::registerLog($logInfo); -$type = $_REQUEST['type'] ?? null; +$typeList = ['personal', 'course', 'admin', 'platform']; +$type = isset($_REQUEST['type']) && in_array($_REQUEST['type'], $typeList, true) ? $_REQUEST['type'] : null; $interbreadcrumb[] = [ 'url' => api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type='.Security::remove_XSS($type), diff --git a/public/main/exercise/exercise_question_reminder.php b/public/main/exercise/exercise_question_reminder.php index e24e90a729..490f637975 100644 --- a/public/main/exercise/exercise_question_reminder.php +++ b/public/main/exercise/exercise_question_reminder.php @@ -38,10 +38,11 @@ if (empty($objExercise) || empty($questionCategoryId) || empty($exeId) || empty( api_not_allowed(true); } -$categoryId = $categoryObj->id; +$categoryId = (int) $categoryObj->id; $params = "exe_id=$exeId&exerciseId=$exerciseId&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id&".api_get_cidreq(); $url = api_get_path(WEB_CODE_PATH).'exercise/exercise_submit.php?'.$params; -$validateUrl = api_get_self().'?'.$params.'&category_id='.$categoryId.'&validate=1'; +$validateUrl = api_get_path(WEB_CODE_PATH).'exercise/exercise_question_reminder.php?'. + $params.'&category_id='.$categoryId.'&validate=1'; $time_control = false; $clock_expired_time = ExerciseLib::get_session_time_control_key( @@ -103,11 +104,11 @@ if (!$hideHeaderAndFooter) { } // I'm in a preview mode as course admin. Display the action menu. -if (api_is_course_admin() && !$hideHeaderAndFooter) { +if (!$hideHeaderAndFooter && api_is_course_admin()) { echo '
'; - echo ''. + echo ''. Display::return_icon('back.png', get_lang('GoBackToQuestionList'), [], 32).''; - echo ''. + echo ''. Display::return_icon('edit.png', get_lang('ModifyExercise'), [], 32).''; echo '
'; } @@ -115,12 +116,14 @@ echo Display::page_header($categoryObj->name); echo '

'.Security::remove_XSS($categoryObj->description).'

'; echo '

'.get_lang('BlockCategoryExplanation').'

'; -if ($objExercise->review_answers) { +$categoryList = Session::read('categoryList'); +$disableAllQuestions = ''; $questionList = []; - $categoryList = Session::read('categoryList'); if (isset($categoryList[$categoryId])) { $questionList = $categoryList[$categoryId]; } +if ($objExercise->review_answers) { + $disableAllQuestions = 'changeOptionStatus(0);'; echo $objExercise->getReminderTable($questionList, $trackInfo); } @@ -130,19 +133,27 @@ if ($time_control) { echo Display::div('', ['id' => 'message']); $previousQuestion = $currentQuestion - 1; +$nextQuestion = $currentQuestion + 1; +if (!empty($questionList)) { + $firstQuestionOfCategory = end($questionList); + $dataTracking = explode(',', $trackInfo['data_tracking']); + $index = 0; + foreach ($dataTracking as $index => $question) { + if ($firstQuestionOfCategory == $question) { + break; + } + } + $nextQuestion = $index + 1; +} echo ''; @@ -180,7 +180,7 @@ if (empty($exerciseInSession) || (!empty($exerciseInSession) && ($exerciseInSess } else { Session::write('firstTime', false); } -//2. Checking if $objExercise is set +// 2. Checking if $objExercise is set. /** @var |Exercise $objExercise */ if (!isset($objExercise) && isset($exerciseInSession)) { if ($debug) { @@ -191,7 +191,7 @@ if (!isset($objExercise) && isset($exerciseInSession)) { $exerciseInSession = Session::read('objExercise'); -//3. $objExercise is not set, then return to the exercise list +// 3. $objExercise is not set, then return to the exercise list. if (!is_object($objExercise)) { header('Location: exercise.php?'.api_get_cidreq()); exit; @@ -204,7 +204,7 @@ if ('true' === api_get_plugin_setting('positioning', 'tool_enable')) { } } -// if the user has submitted the form +// if the user has submitted the form. $exercise_title = $objExercise->selectTitle(); $exercise_sound = $objExercise->selectSound(); @@ -450,7 +450,7 @@ if (empty($exercise_stat_info)) { if (!empty($resolvedQuestions) && !empty($exercise_stat_info['data_tracking']) ) { - $last = current(end($resolvedQuestions)); + /*$last = current(end($resolvedQuestions)); $attemptQuestionList = explode(',', $exercise_stat_info['data_tracking']); $count = 1; foreach ($attemptQuestionList as $question) { @@ -460,10 +460,25 @@ if (empty($exercise_stat_info)) { $count++; } $current_question = $count; + */ + // Get current question based in data_tracking question list, instead of track_e_attempt order BT#17789. + $resolvedQuestionsQuestionIds = array_keys($resolvedQuestions); + $count = 0; + $attemptQuestionList = explode(',', $exercise_stat_info['data_tracking']); + //var_dump($attemptQuestionList, $resolvedQuestionsQuestionIds); + foreach ($attemptQuestionList as $index => $question) { + if (in_array($question, $resolvedQuestionsQuestionIds)) { + $count = $index; + continue; } + } + $current_question = $count; + //var_dump($current_question, $index);exit; +} } } Session::write('exe_id', $exe_id); +$checkAnswersUrl = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?a=check_answers&exe_id='.$exe_id.'&'.api_get_cidreq(); $saveDurationUrl = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?a=update_duration&exe_id='.$exe_id.'&'.api_get_cidreq(); $questionListInSession = Session::read('questionList'); $selectionType = $objExercise->getQuestionSelectionType(); @@ -523,7 +538,7 @@ if (!empty($exercise_stat_info['questions_to_check'])) { $params = "exe_id=$exe_id&exerciseId=$exerciseId&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id&".api_get_cidreq().'&reminder='.$reminder; -if (2 == $reminder && empty($myRemindList)) { +if (2 === $reminder && empty($myRemindList)) { if ($debug) { error_log('6.2 calling the exercise_reminder.php '); } @@ -546,7 +561,7 @@ if ($time_control) { } if (!isset($_SESSION['expired_time'][$current_expired_time_key])) { - //Timer - Get expired_time for a student + // Timer - Get expired_time for a student. if (!empty($exercise_stat_info)) { $expired_time_of_this_attempt = $exercise_stat_info['expired_time_control']; if ($debug) { @@ -570,7 +585,7 @@ if ($time_control) { $last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date, 'UTC') + $diff); } - //New expired time - it is due to the possible closure of session + // New expired time - it is due to the possible closure of session. $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date, 'UTC'); $expected_time = $current_timestamp + $new_expired_time_in_seconds; $clock_expired_time = api_get_utc_datetime($expected_time); @@ -609,7 +624,8 @@ $time_left = api_strtotime($clock_expired_time, 'UTC') - time(); * The time control feature is enable here - this feature is enable for a jquery plugin called epiclock * for more details of how it works see this link : http://eric.garside.name/docs.html?p=epiclock */ -if ($time_control) { //Sends the exercise form when the expired time is finished +if ($time_control) { + //Sends the exercise form when the expired time is finished. $htmlHeadXtra[] = $objExercise->showTimeControlJS($time_left); } @@ -672,42 +688,55 @@ if ($allowBlockCategory && $count++; } + //var_dump($questionCheck);exit; // Use reminder list to get the current question. - if (2 === $reminder && !empty($myRemindList)) { + /*if (2 === $reminder && !empty($myRemindList)) { $remindQuestionId = current($myRemindList); $questionCheck = Question::read($remindQuestionId); - } + }*/ $categoryId = 0; if (null !== $questionCheck) { $categoryId = $questionCheck->category; } + if ($objExercise->review_answers && isset($_GET['category_id'])) { + $categoryId = $_GET['category_id'] ?? 0; + } + //var_dump($categoryId, $categoryList); if (!empty($categoryId)) { $categoryInfo = $categoryList[$categoryId]; $count = 1; $total = count($categoryList[$categoryId]); + //var_dump($questionCheck); foreach ($categoryList[$categoryId] as $checkQuestionId) { - if ((int) $checkQuestionId === $questionCheck->iid) { + if ((int) $checkQuestionId === (int) $questionCheck->iid) { break; } $count++; } + //var_dump($count , $total); if ($count === $total) { $isLastQuestionInCategory = $categoryId; if ($isLastQuestionInCategory) { // This is the last question if ((int) $current_question + 1 === count($questionList)) { + if (false === $objExercise->review_answers) { $isLastQuestionInCategory = 0; } } } + } if (0 === $isLastQuestionInCategory) { $showPreviousButton = false; } + if (0 === $isLastQuestionInCategory && 2 === $reminder) { + // $isLastQuestionInCategory = $categoryId; + } } + //var_dump($categoryId, $blockedCategories, $isLastQuestionInCategory); // Blocked if category was already answered. if ($categoryId && in_array($categoryId, $blockedCategories)) { @@ -721,7 +750,7 @@ if ($debug) { error_log('8. Question list loaded '.print_r($questionList, 1)); } -//Real question count +// Real question count. $question_count = 0; if (!empty($questionList)) { $question_count = count($questionList); @@ -770,12 +799,12 @@ if ($formSent && isset($_POST)) { $exerciseResult = $choice; } else { // gets the question ID from $choice. It is the key of the array - list($key) = array_keys($choice); + [$key] = array_keys($choice); // if the user didn't already answer this question if (!isset($exerciseResult[$key])) { // stores the user answer into the array $exerciseResult[$key] = $choice[$key]; - //saving each question + // Saving each question. if (!in_array($objExercise->getFeedbackType(), [EXERCISE_FEEDBACK_TYPE_DIRECT])) { $nro_question = $current_question; // - 1; $questionId = $key; @@ -965,6 +994,7 @@ $interbreadcrumb[] = [ ]; $interbreadcrumb[] = ['url' => '#', 'name' => $objExercise->selectTitle(true)]; +// Time per question. $questionTimeCondition = ''; $showQuestionClock = false; if ($allowTimePerQuestion && $objExercise->type == ONE_PER_PAGE) { @@ -1011,7 +1041,8 @@ if ($allowTimePerQuestion && $objExercise->type == ONE_PER_PAGE) { "; } } -if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp'])) { //so we are not in learnpath tool +if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp'])) { + //so we are not in learnpath tool SessionManager::addFlashSessionReadOnly(); Display::display_header(null, 'Exercises'); @@ -1131,7 +1162,6 @@ if (isset($_custom['exercises_hidden_when_no_start_date']) && } } -// Timer control if ($time_control) { echo $objExercise->returnTimeLeftDiv(); echo '