From aad2abe7e98f026d9939aeb7e56082df3ddbb380 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 6 May 2020 13:45:31 +0200 Subject: [PATCH] Minor - format code --- main/exercise/exercise_submit.php | 15 ++++----------- main/inc/ajax/exercise.ajax.php | 32 +++++++++++++++---------------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/main/exercise/exercise_submit.php b/main/exercise/exercise_submit.php index c94690fc47..164d6e77cd 100755 --- a/main/exercise/exercise_submit.php +++ b/main/exercise/exercise_submit.php @@ -1,4 +1,5 @@ * Fill in blank option added (2008) @@ -101,7 +100,6 @@ $currentAnswer = isset($_REQUEST['num_answer']) ? (int) $_REQUEST['num_answer'] $logInfo = [ 'tool' => TOOL_QUIZ, 'tool_id' => $exerciseId, - 'tool_id_detail' => 0, 'action' => $learnpath_id, 'action_details' => $learnpath_id, ]; @@ -467,10 +465,6 @@ if (!isset($questionListInSession)) { $questionList = explode(',', $exercise_stat_info['data_tracking']); } Session::write('questionList', $questionList); - - if ($debug > 0) { - error_log('$_SESSION[questionList] was set'); - } } else { if (isset($objExercise) && isset($exerciseInSession)) { $questionList = Session::read('questionList'); @@ -607,7 +601,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); @@ -626,13 +620,12 @@ if ($formSent && isset($_POST)) { error_log('9. $formSent was set'); } - // Initializing if (!is_array($exerciseResult)) { $exerciseResult = []; $exerciseResultCoordinates = []; } - //Only for hotspot + // Only for hotspot if (!isset($choice) && isset($_REQUEST['hidden_hotspot_id'])) { $hotspot_id = (int) $_REQUEST['hidden_hotspot_id']; $choice = [$hotspot_id => '']; @@ -892,7 +885,7 @@ $is_visible_return = $objExercise->is_visible( if ($is_visible_return['value'] == false) { echo $is_visible_return['message']; if (!in_array($origin, ['learnpath', 'embeddable'])) { - Display :: display_footer(); + Display::display_footer(); } exit; } diff --git a/main/inc/ajax/exercise.ajax.php b/main/inc/ajax/exercise.ajax.php index 74c07eb698..33205aa7dd 100755 --- a/main/inc/ajax/exercise.ajax.php +++ b/main/inc/ajax/exercise.ajax.php @@ -460,6 +460,18 @@ switch ($action) { $attemptList = Event::getAllExerciseEventByExeId($exeId); } + // No exe id? Can't save answer. + if (empty($exeId)) { + // Fires an error. + echo 'error'; + if ($debug) { + error_log('exe_id is empty'); + } + exit; + } + + Session::write('exe_id', $exeId); + // Updating Reminder algorithm. if ($objExercise->type == ONE_PER_PAGE) { $bd_reminder_list = explode(',', $exercise_stat_info['questions_to_check']); @@ -482,21 +494,9 @@ switch ($action) { } } - // No exe id? Can't save answer. - if (empty($exeId)) { - // Fires an error. - echo 'error'; - if ($debug) { - error_log('exe_id is empty'); - } - exit; - } - - Session::write('exe_id', $exeId); - // Getting the total weight if the request is simple $total_weight = 0; - if ($type == 'simple') { + if ($type === 'simple') { foreach ($question_list as $my_question_id) { $objQuestionTmp = Question::read($my_question_id, $objExercise->course); $total_weight += $objQuestionTmp->selectWeighting(); @@ -510,7 +510,7 @@ switch ($action) { error_log("Saving question_id = $my_question_id "); } - if ($type == 'simple' && $question_id != $my_question_id) { + if ($type === 'simple' && $question_id != $my_question_id) { continue; } @@ -537,7 +537,7 @@ switch ($action) { : null; } - if ($type == 'all') { + if ($type === 'all') { $total_weight += $objQuestionTmp->selectWeighting(); } @@ -637,7 +637,7 @@ switch ($action) { $duration = 0; $now = time(); - if ($type == 'all') { + if ($type === 'all') { $exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exeId); }