|
|
|
@ -4,29 +4,29 @@ |
|
|
|
|
use ChamiloSession as Session; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Exercise submission |
|
|
|
|
* This script allows to run an exercise. According to the exercise type, questions |
|
|
|
|
* can be on an unique page, or one per page with a Next button. |
|
|
|
|
* |
|
|
|
|
* One exercise may contain different types of answers (unique or multiple selection, |
|
|
|
|
* matching, fill in blanks, free answer, hot-spot). |
|
|
|
|
* |
|
|
|
|
* Questions are selected randomly or not. |
|
|
|
|
* |
|
|
|
|
* When the user has answered all questions and clicks on the button "Ok", |
|
|
|
|
* it goes to exercise_result.php |
|
|
|
|
* |
|
|
|
|
* Notice : This script is also used to show a question before modifying it by |
|
|
|
|
* the administrator |
|
|
|
|
* @package chamilo.exercise |
|
|
|
|
* @author Olivier Brouckaert |
|
|
|
|
* @author Julio Montoya <gugli100@gmail.com> |
|
|
|
|
* Fill in blank option added (2008) |
|
|
|
|
* Cleaning exercises (2010), |
|
|
|
|
* Adding hotspot delineation support (2011) |
|
|
|
|
* Adding reminder + ajax support (2011) |
|
|
|
|
* Modified by hubert.borderiou (2011-10-21 question category) |
|
|
|
|
*/ |
|
|
|
|
* Exercise submission |
|
|
|
|
* This script allows to run an exercise. According to the exercise type, questions |
|
|
|
|
* can be on an unique page, or one per page with a Next button. |
|
|
|
|
* |
|
|
|
|
* One exercise may contain different types of answers (unique or multiple selection, |
|
|
|
|
* matching, fill in blanks, free answer, hot-spot). |
|
|
|
|
* |
|
|
|
|
* Questions are selected randomly or not. |
|
|
|
|
* |
|
|
|
|
* When the user has answered all questions and clicks on the button "Ok", |
|
|
|
|
* it goes to exercise_result.php |
|
|
|
|
* |
|
|
|
|
* Notice : This script is also used to show a question before modifying it by |
|
|
|
|
* the administrator |
|
|
|
|
* @package chamilo.exercise |
|
|
|
|
* @author Olivier Brouckaert |
|
|
|
|
* @author Julio Montoya <gugli100@gmail.com> |
|
|
|
|
* Fill in blank option added (2008) |
|
|
|
|
* Cleaning exercises (2010), |
|
|
|
|
* Adding hotspot delineation support (2011) |
|
|
|
|
* Adding reminder + ajax support (2011) |
|
|
|
|
* Modified by hubert.borderiou (2011-10-21 question category) |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
require_once __DIR__.'/../inc/global.inc.php'; |
|
|
|
|
$current_course_tool = TOOL_QUIZ; |
|
|
|
@ -117,33 +117,43 @@ if (!isset($exerciseInSession) || isset($exerciseInSession) && ($exerciseInSessi |
|
|
|
|
// Construction of Exercise |
|
|
|
|
$objExercise = new Exercise(); |
|
|
|
|
Session::write('firstTime', true); |
|
|
|
|
if ($debug) {error_log('1. Setting the $objExercise variable'); }; |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log('1. Setting the $objExercise variable'); |
|
|
|
|
} |
|
|
|
|
Session::erase('questionList'); |
|
|
|
|
|
|
|
|
|
// if the specified exercise doesn't exist or is disabled |
|
|
|
|
if (!$objExercise->read($exerciseId) || |
|
|
|
|
(!$objExercise->selectStatus() && !$is_allowedToEdit && $origin != 'learnpath') |
|
|
|
|
) { |
|
|
|
|
if ($debug) {error_log('1.1. Error while reading the exercise'); }; |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log('1.1. Error while reading the exercise'); |
|
|
|
|
} |
|
|
|
|
unset($objExercise); |
|
|
|
|
$error = get_lang('ExerciseNotFound'); |
|
|
|
|
} else { |
|
|
|
|
// Saves the object into the session |
|
|
|
|
Session::write('objExercise', $objExercise); |
|
|
|
|
if ($debug) {error_log('1.1. $exerciseInSession was unset - set now - end'); }; |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log('1.1. $exerciseInSession was unset - set now - end'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
Session::write('firstTime', false); |
|
|
|
|
} |
|
|
|
|
//2. Checking if $objExercise is set |
|
|
|
|
if (!isset($objExercise) && isset($exerciseInSession)) { |
|
|
|
|
if ($debug) { error_log('2. Loading $objExercise from session'); }; |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log('2. Loading $objExercise from session'); |
|
|
|
|
} |
|
|
|
|
$objExercise = $exerciseInSession; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//3. $objExercise is not set, then return to the exercise list |
|
|
|
|
if (!is_object($objExercise)) { |
|
|
|
|
if ($debug) {error_log('3. $objExercise was not set, kill the script'); }; |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log('3. $objExercise was not set, kill the script'); |
|
|
|
|
} |
|
|
|
|
header('Location: exercise.php'); |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
@ -313,7 +323,9 @@ Session::write('question_list_uncompressed', $questionListUncompressed); |
|
|
|
|
|
|
|
|
|
$clock_expired_time = null; |
|
|
|
|
if (empty($exercise_stat_info)) { |
|
|
|
|
if ($debug) error_log('5 $exercise_stat_info is empty '); |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log('5 $exercise_stat_info is empty '); |
|
|
|
|
} |
|
|
|
|
$total_weight = 0; |
|
|
|
|
$questionList = $objExercise->get_validated_question_list(); |
|
|
|
|
foreach ($questionListUncompressed as $question_id) { |
|
|
|
@ -321,19 +333,28 @@ if (empty($exercise_stat_info)) { |
|
|
|
|
$total_weight += floatval($objQuestionTmp->weighting); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($time_control) { |
|
|
|
|
$expected_time = $current_timestamp + $total_seconds; |
|
|
|
|
|
|
|
|
|
if ($debug) error_log('5.1. $current_timestamp '.$current_timestamp); |
|
|
|
|
if ($debug) error_log('5.2. $expected_time '.$expected_time); |
|
|
|
|
if ($time_control) { |
|
|
|
|
$expected_time = $current_timestamp + $total_seconds; |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log('5.1. $current_timestamp '.$current_timestamp); |
|
|
|
|
} |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log('5.2. $expected_time '.$expected_time); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$clock_expired_time = api_get_utc_datetime($expected_time); |
|
|
|
|
if ($debug) error_log('5.3. $expected_time '.$clock_expired_time); |
|
|
|
|
$clock_expired_time = api_get_utc_datetime($expected_time); |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log('5.3. $expected_time '.$clock_expired_time); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//Sessions that contain the expired time |
|
|
|
|
$_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time; |
|
|
|
|
if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key]); }; |
|
|
|
|
} |
|
|
|
|
//Sessions that contain the expired time |
|
|
|
|
$_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time; |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log( |
|
|
|
|
'5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] |
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$exe_id = $objExercise->save_stat_track_exercise_info( |
|
|
|
|
$clock_expired_time, |
|
|
|
@ -348,9 +369,11 @@ if (empty($exercise_stat_info)) { |
|
|
|
|
$learnpath_item_id, |
|
|
|
|
$learnpath_item_view_id |
|
|
|
|
); |
|
|
|
|
if ($debug) error_log("5.5 exercise_stat_info[] exists getting exe_id $exe_id"); |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log("5.5 exercise_stat_info[] exists getting exe_id $exe_id"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
$exe_id = $exercise_stat_info['exe_id']; |
|
|
|
|
$exe_id = $exercise_stat_info['exe_id']; |
|
|
|
|
// Remember last question id position. |
|
|
|
|
$isFirstTime = Session::read('firstTime'); |
|
|
|
|
|
|
|
|
@ -372,7 +395,9 @@ if (empty($exercise_stat_info)) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($debug) error_log("5 exercise_stat_info[] exists getting exe_id $exe_id "); |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log("5 exercise_stat_info[] exists getting exe_id $exe_id "); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$questionListInSession = Session::read('questionList'); |
|
|
|
@ -407,21 +432,32 @@ if (!isset($questionListInSession)) { |
|
|
|
|
// Array to check in order to block the chat |
|
|
|
|
ExerciseLib::create_chat_exercise_session($exe_id); |
|
|
|
|
|
|
|
|
|
if ($debug) { error_log('6. $objExercise->get_stat_track_exercise_info function called:: '.print_r($exercise_stat_info, 1)); }; |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log( |
|
|
|
|
'6. $objExercise->get_stat_track_exercise_info function called:: '.print_r( |
|
|
|
|
$exercise_stat_info, |
|
|
|
|
1 |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if (!empty($exercise_stat_info['questions_to_check'])) { |
|
|
|
|
$my_remind_list = $exercise_stat_info['questions_to_check']; |
|
|
|
|
$my_remind_list = explode(',', $my_remind_list); |
|
|
|
|
$my_remind_list = array_filter($my_remind_list); |
|
|
|
|
$my_remind_list = $exercise_stat_info['questions_to_check']; |
|
|
|
|
$my_remind_list = explode(',', $my_remind_list); |
|
|
|
|
$my_remind_list = array_filter($my_remind_list); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$params = "exe_id=$exe_id&exerciseId=$exerciseId&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id&".api_get_cidreq(); |
|
|
|
|
if ($debug) { error_log("6.1 params: -> $params"); }; |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log("6.1 params: -> $params"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($reminder == 2 && empty($my_remind_list)) { |
|
|
|
|
if ($debug) { error_log("6.2 calling the exercise_reminder.php "); }; |
|
|
|
|
header('Location: exercise_reminder.php?'.$params); |
|
|
|
|
exit; |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log("6.2 calling the exercise_reminder.php "); |
|
|
|
|
}; |
|
|
|
|
header('Location: exercise_reminder.php?'.$params); |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
@ -429,62 +465,64 @@ if ($reminder == 2 && empty($my_remind_list)) { |
|
|
|
|
* If the expired time is major that zero(0) then the expired time is compute on this time. |
|
|
|
|
*/ |
|
|
|
|
if ($time_control) { |
|
|
|
|
if ($debug) error_log('7.1. Time control is enabled'); |
|
|
|
|
if ($debug) error_log('7.2. $current_expired_time_key '.$current_expired_time_key); |
|
|
|
|
if ($debug) error_log('7.3. $_SESSION[expired_time][$current_expired_time_key] '.$_SESSION['expired_time'][$current_expired_time_key]); |
|
|
|
|
if ($debug) error_log('7.1. Time control is enabled'); |
|
|
|
|
if ($debug) error_log('7.2. $current_expired_time_key '.$current_expired_time_key); |
|
|
|
|
if ($debug) error_log('7.3. $_SESSION[expired_time][$current_expired_time_key] '.$_SESSION['expired_time'][$current_expired_time_key]); |
|
|
|
|
|
|
|
|
|
if (!isset($_SESSION['expired_time'][$current_expired_time_key])) { |
|
|
|
|
//Timer - Get expired_time for a student |
|
|
|
|
if (!empty($exercise_stat_info)) { |
|
|
|
|
if ($debug) {error_log('7.4 Seems that the session ends and the user want to retake the exam'); }; |
|
|
|
|
$expired_time_of_this_attempt = $exercise_stat_info['expired_time_control']; |
|
|
|
|
if ($debug) {error_log('7.5 $expired_time_of_this_attempt: '.$expired_time_of_this_attempt); } |
|
|
|
|
// Get the last attempt of an exercise |
|
|
|
|
$last_attempt_date = Event::getLastAttemptDateOfExercise($exercise_stat_info['exe_id']); |
|
|
|
|
|
|
|
|
|
/* This means that the user enters the exam but do not answer the |
|
|
|
|
first question we get the date from the track_e_exercises not from |
|
|
|
|
the track_et_attempt see #2069 */ |
|
|
|
|
if (empty($last_attempt_date)) { |
|
|
|
|
$diff = $current_timestamp - api_strtotime($exercise_stat_info['start_date'], 'UTC'); |
|
|
|
|
$last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'], 'UTC') + $diff); |
|
|
|
|
} else { |
|
|
|
|
//Recalculate the time control due #2069 |
|
|
|
|
$diff = $current_timestamp - api_strtotime($last_attempt_date, 'UTC'); |
|
|
|
|
$last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date, 'UTC') + $diff); |
|
|
|
|
} |
|
|
|
|
if ($debug) {error_log('7.6. $last_attempt_date: '.$last_attempt_date); } |
|
|
|
|
|
|
|
|
|
//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'); |
|
|
|
|
if ($debug) {error_log('7.7. $new_expired_time_in_seconds: '.$new_expired_time_in_seconds); } |
|
|
|
|
|
|
|
|
|
$expected_time = $current_timestamp + $new_expired_time_in_seconds; |
|
|
|
|
if ($debug) {error_log('7.8. $expected_time1: '.$expected_time); } |
|
|
|
|
|
|
|
|
|
$clock_expired_time = api_get_utc_datetime($expected_time); |
|
|
|
|
if ($debug) {error_log('7.9. $clock_expired_time: '.$clock_expired_time); } |
|
|
|
|
|
|
|
|
|
// First we update the attempt to today |
|
|
|
|
/* How the expired time is changed into "track_e_exercises" table, |
|
|
|
|
if ($debug) {error_log('7.4 Seems that the session ends and the user want to retake the exam'); }; |
|
|
|
|
$expired_time_of_this_attempt = $exercise_stat_info['expired_time_control']; |
|
|
|
|
if ($debug) {error_log('7.5 $expired_time_of_this_attempt: '.$expired_time_of_this_attempt); } |
|
|
|
|
// Get the last attempt of an exercise |
|
|
|
|
$last_attempt_date = Event::getLastAttemptDateOfExercise($exercise_stat_info['exe_id']); |
|
|
|
|
|
|
|
|
|
/* This means that the user enters the exam but do not answer the |
|
|
|
|
first question we get the date from the track_e_exercises not from |
|
|
|
|
the track_et_attempt see #2069 */ |
|
|
|
|
if (empty($last_attempt_date)) { |
|
|
|
|
$diff = $current_timestamp - api_strtotime($exercise_stat_info['start_date'], 'UTC'); |
|
|
|
|
$last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'], 'UTC') + $diff); |
|
|
|
|
} else { |
|
|
|
|
//Recalculate the time control due #2069 |
|
|
|
|
$diff = $current_timestamp - api_strtotime($last_attempt_date, 'UTC'); |
|
|
|
|
$last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date, 'UTC') + $diff); |
|
|
|
|
} |
|
|
|
|
if ($debug) {error_log('7.6. $last_attempt_date: '.$last_attempt_date); } |
|
|
|
|
|
|
|
|
|
//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'); |
|
|
|
|
if ($debug) {error_log('7.7. $new_expired_time_in_seconds: '.$new_expired_time_in_seconds); } |
|
|
|
|
|
|
|
|
|
$expected_time = $current_timestamp + $new_expired_time_in_seconds; |
|
|
|
|
if ($debug) {error_log('7.8. $expected_time1: '.$expected_time); } |
|
|
|
|
|
|
|
|
|
$clock_expired_time = api_get_utc_datetime($expected_time); |
|
|
|
|
if ($debug) {error_log('7.9. $clock_expired_time: '.$clock_expired_time); } |
|
|
|
|
|
|
|
|
|
// First we update the attempt to today |
|
|
|
|
/* How the expired time is changed into "track_e_exercises" table, |
|
|
|
|
then the last attempt for this student should be changed too */ |
|
|
|
|
$sql = "UPDATE $exercise_attempt_table SET |
|
|
|
|
tms = '".api_get_utc_datetime()."' |
|
|
|
|
WHERE |
|
|
|
|
exe_id = '".$exercise_stat_info['exe_id']."' AND |
|
|
|
|
tms = '".$last_attempt_date."' "; |
|
|
|
|
if ($debug) {error_log('7.10. $sql: '.$sql); } |
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
|
//Sessions that contain the expired time |
|
|
|
|
$_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time; |
|
|
|
|
if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key]); }; |
|
|
|
|
$sql = "UPDATE $exercise_attempt_table SET |
|
|
|
|
tms = '".api_get_utc_datetime()."' |
|
|
|
|
WHERE |
|
|
|
|
exe_id = '".$exercise_stat_info['exe_id']."' AND |
|
|
|
|
tms = '".$last_attempt_date."' "; |
|
|
|
|
if ($debug) {error_log('7.10. $sql: '.$sql); } |
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
|
//Sessions that contain the expired time |
|
|
|
|
$_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time; |
|
|
|
|
if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key]); }; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
$clock_expired_time = $_SESSION['expired_time'][$current_expired_time_key]; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if ($debug) { error_log("7 No time control"); }; |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log("7 No time control"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Get time left for expiring time |
|
|
|
@ -495,7 +533,7 @@ $time_left = api_strtotime($clock_expired_time, 'UTC') - time(); |
|
|
|
|
* 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 |
|
|
|
|
$htmlHeadXtra[] = $objExercise->show_time_control_js($time_left); |
|
|
|
|
$htmlHeadXtra[] = $objExercise->show_time_control_js($time_left); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//in LP's is enabled the "remember question" feature? |
|
|
|
@ -503,22 +541,24 @@ if (!isset($_SESSION['questionList'])) { |
|
|
|
|
// selects the list of question ID |
|
|
|
|
$questionList = $objExercise->get_validated_question_list(); |
|
|
|
|
if ($objExercise->isRandom() && !empty($exercise_stat_info['data_tracking'])) { |
|
|
|
|
$questionList = explode(',', $exercise_stat_info['data_tracking']); |
|
|
|
|
$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($_SESSION['objExercise'])) { |
|
|
|
|
$questionList = $_SESSION['questionList']; |
|
|
|
|
} |
|
|
|
|
if (isset($objExercise) && isset($_SESSION['objExercise'])) { |
|
|
|
|
$questionList = $_SESSION['questionList']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($debug) error_log('8. Question list loaded '.print_r($questionList, 1)); |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log('8. Question list loaded '.print_r($questionList, 1)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//Real question count |
|
|
|
|
$question_count = 0; |
|
|
|
|
if (!empty($questionList)) { |
|
|
|
|
$question_count = count($questionList); |
|
|
|
|
$question_count = count($questionList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($current_question > $question_count) { |
|
|
|
@ -568,11 +608,11 @@ if ($formSent && isset($_POST)) { |
|
|
|
|
//saving each question |
|
|
|
|
if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_DIRECT) { |
|
|
|
|
$nro_question = $current_question; // - 1; |
|
|
|
|
$questionId = $key; |
|
|
|
|
$questionId = $key; |
|
|
|
|
// gets the student choice for this question |
|
|
|
|
$choice = $exerciseResult[$questionId]; |
|
|
|
|
if (isset($exe_id)) { |
|
|
|
|
// Manage the question and answer attempts |
|
|
|
|
// Manage the question and answer attempts |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log('8.3. manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice, 1)); |
|
|
|
|
} |
|
|
|
@ -663,61 +703,60 @@ if (is_null($current_question)) { |
|
|
|
|
$current_question++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($question_count != 0) { |
|
|
|
|
if (($objExercise->type == ALL_ON_ONE_PAGE || |
|
|
|
|
if (($objExercise->type == ALL_ON_ONE_PAGE || |
|
|
|
|
$current_question > $question_count) |
|
|
|
|
) { |
|
|
|
|
if (api_is_allowed_to_session_edit()) { |
|
|
|
|
// goes to the script that will show the result of the exercise |
|
|
|
|
if ($objExercise->type == ALL_ON_ONE_PAGE) { |
|
|
|
|
if ($debug) { error_log('12. Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php'); } |
|
|
|
|
|
|
|
|
|
//We check if the user attempts before sending to the exercise_result.php |
|
|
|
|
if ($objExercise->selectAttempts() > 0) { |
|
|
|
|
$attempt_count = Event::get_attempt_count( |
|
|
|
|
if (api_is_allowed_to_session_edit()) { |
|
|
|
|
// goes to the script that will show the result of the exercise |
|
|
|
|
if ($objExercise->type == ALL_ON_ONE_PAGE) { |
|
|
|
|
if ($debug) { error_log('12. Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php'); } |
|
|
|
|
|
|
|
|
|
//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(), |
|
|
|
|
$exerciseId, |
|
|
|
|
$learnpath_id, |
|
|
|
|
$learnpath_item_id, |
|
|
|
|
$learnpath_item_view_id |
|
|
|
|
); |
|
|
|
|
if ($attempt_count >= $objExercise->selectAttempts()) { |
|
|
|
|
Display::return_message( |
|
|
|
|
if ($attempt_count >= $objExercise->selectAttempts()) { |
|
|
|
|
Display::return_message( |
|
|
|
|
sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), |
|
|
|
|
'warning', |
|
|
|
|
false |
|
|
|
|
); |
|
|
|
|
if ($origin != 'learnpath') { |
|
|
|
|
//so we are not in learnpath tool |
|
|
|
|
echo '</div>'; //End glossary div |
|
|
|
|
Display :: display_footer(); |
|
|
|
|
} else { |
|
|
|
|
echo '</body></html>'; |
|
|
|
|
} |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if ($objExercise->review_answers) { |
|
|
|
|
header('Location: exercise_reminder.php?'.$params); |
|
|
|
|
exit; |
|
|
|
|
} else { |
|
|
|
|
if ($origin != 'learnpath') { |
|
|
|
|
//so we are not in learnpath tool |
|
|
|
|
echo '</div>'; //End glossary div |
|
|
|
|
Display :: display_footer(); |
|
|
|
|
} else { |
|
|
|
|
echo '</body></html>'; |
|
|
|
|
} |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if ($objExercise->review_answers) { |
|
|
|
|
header('Location: exercise_reminder.php?'.$params); |
|
|
|
|
exit; |
|
|
|
|
} else { |
|
|
|
|
header("Location: exercise_result.php?".api_get_cidreq()."&exe_id=$exe_id&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id"); |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if ($debug) { error_log('Redirecting to exercise_submit.php'); } |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if ($debug) { error_log('Redirecting to exercise_submit.php'); } |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
$error = get_lang('ThereAreNoQuestionsForThisExercise'); |
|
|
|
|
// if we are in the case where user select random by category, but didn't choose the number of random question |
|
|
|
|
if ($objExercise->selectRandomByCat() > 0 && $objExercise->random <= 0) { |
|
|
|
|
$error .= "<br/>".get_lang('PleaseSelectSomeRandomQuestion'); |
|
|
|
|
} |
|
|
|
|
$error = get_lang('ThereAreNoQuestionsForThisExercise'); |
|
|
|
|
// if we are in the case where user select random by category, but didn't choose the number of random question |
|
|
|
|
if ($objExercise->selectRandomByCat() > 0 && $objExercise->random <= 0) { |
|
|
|
|
$error .= "<br/>".get_lang('PleaseSelectSomeRandomQuestion'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!empty ($_GET['gradebook']) && $_GET['gradebook'] == 'view') { |
|
|
|
@ -759,9 +798,9 @@ $show_quiz_edition = $objExercise->added_in_lp(); |
|
|
|
|
if (api_is_course_admin() && $origin != 'learnpath') { |
|
|
|
|
echo '<div class="actions">'; |
|
|
|
|
if ($show_quiz_edition == false) { |
|
|
|
|
echo '<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.Display::return_icon('settings.png', get_lang('ModifyExercise'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
echo '<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.Display::return_icon('settings.png', get_lang('ModifyExercise'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
} else { |
|
|
|
|
echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
} |
|
|
|
|
echo '</div>'; |
|
|
|
|
} |
|
|
|
@ -804,7 +843,7 @@ if ($limit_time_exists) { |
|
|
|
|
$message_warning = $permission_to_start ? get_lang('ReachedTimeLimit') : get_lang('ExerciseNoStartedYet'); |
|
|
|
|
echo Display::return_message(sprintf($message_warning, $exercise_title, $objExercise->selectAttempts()), 'warning'); |
|
|
|
|
if ($origin != 'learnpath') { |
|
|
|
|
Display :: display_footer(); |
|
|
|
|
Display :: display_footer(); |
|
|
|
|
} |
|
|
|
|
exit; |
|
|
|
|
} else { |
|
|
|
@ -819,7 +858,7 @@ global $_custom; |
|
|
|
|
if (isset($_custom['exercises_hidden_when_no_start_date']) && |
|
|
|
|
$_custom['exercises_hidden_when_no_start_date'] |
|
|
|
|
) { |
|
|
|
|
if (empty($objExercise->start_time)) { |
|
|
|
|
if (empty($objExercise->start_time)) { |
|
|
|
|
echo Display:: return_message( |
|
|
|
|
sprintf( |
|
|
|
|
get_lang('ExerciseNoStartedYet'), |
|
|
|
@ -828,16 +867,16 @@ if (isset($_custom['exercises_hidden_when_no_start_date']) && |
|
|
|
|
), |
|
|
|
|
'warning' |
|
|
|
|
); |
|
|
|
|
if ($origin != 'learnpath') { |
|
|
|
|
Display :: display_footer(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if ($origin != 'learnpath') { |
|
|
|
|
Display :: display_footer(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//Timer control |
|
|
|
|
if ($time_control) { |
|
|
|
|
echo $objExercise->return_time_left_div(); |
|
|
|
|
echo '<div style="display:none" class="warning-message" id="expired-message-id">'.get_lang('ExerciseExpiredTimeMessage').'</div>'; |
|
|
|
|
echo '<div style="display:none" class="warning-message" id="expired-message-id">'.get_lang('ExerciseExpiredTimeMessage').'</div>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($origin != 'learnpath') { |
|
|
|
@ -852,53 +891,51 @@ if ($reminder == 2) { |
|
|
|
|
$current_question = 1; //set by default the 1st question |
|
|
|
|
|
|
|
|
|
if (!empty($my_remind_list)) { |
|
|
|
|
//Checking which questions we are going to call from the remind list |
|
|
|
|
for ($i = 0; $i < count($data_tracking); $i++) { |
|
|
|
|
for ($j = 0; $j < count($my_remind_list); $j++) { |
|
|
|
|
|
|
|
|
|
if (!empty($remind_question_id)) { |
|
|
|
|
if ($remind_question_id == $my_remind_list[$j]) { |
|
|
|
|
|
|
|
|
|
if ($remind_question_id == $data_tracking[$i]) { |
|
|
|
|
if (isset($my_remind_list[$j + 1])) { |
|
|
|
|
$remind_question_id = $my_remind_list[$j + 1]; |
|
|
|
|
$current_question = $i + 1; |
|
|
|
|
} else { |
|
|
|
|
//Checking which questions we are going to call from the remind list |
|
|
|
|
for ($i = 0; $i < count($data_tracking); $i++) { |
|
|
|
|
for ($j = 0; $j < count($my_remind_list); $j++) { |
|
|
|
|
if (!empty($remind_question_id)) { |
|
|
|
|
if ($remind_question_id == $my_remind_list[$j]) { |
|
|
|
|
if ($remind_question_id == $data_tracking[$i]) { |
|
|
|
|
if (isset($my_remind_list[$j + 1])) { |
|
|
|
|
$remind_question_id = $my_remind_list[$j + 1]; |
|
|
|
|
$current_question = $i + 1; |
|
|
|
|
} else { |
|
|
|
|
// We end the remind list we go to the exercise_reminder.php please |
|
|
|
|
$remind_question_id = -1; |
|
|
|
|
$current_question = $i + 1; // last question |
|
|
|
|
} |
|
|
|
|
break 2; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if ($my_remind_list[$j] == $data_tracking[$i]) { |
|
|
|
|
if (isset($my_remind_list[$j + 1])) { |
|
|
|
|
$remind_question_id = $my_remind_list[$j + 1]; |
|
|
|
|
$current_question = $i + 1; // last question |
|
|
|
|
} else { |
|
|
|
|
$remind_question_id = -1; |
|
|
|
|
$current_question = $i + 1; // last question |
|
|
|
|
} |
|
|
|
|
break 2; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if ($my_remind_list[$j] == $data_tracking[$i]) { |
|
|
|
|
if (isset($my_remind_list[$j + 1])) { |
|
|
|
|
$remind_question_id = $my_remind_list[$j + 1]; |
|
|
|
|
$current_question = $i + 1; // last question |
|
|
|
|
} else { |
|
|
|
|
// We end the remind list we go to the exercise_reminder.php please |
|
|
|
|
$remind_question_id = -1; |
|
|
|
|
$current_question = $i + 1; // last question |
|
|
|
|
} |
|
|
|
|
break 2; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$remind_question_id = -1; |
|
|
|
|
$current_question = $i + 1; // last question |
|
|
|
|
} |
|
|
|
|
break 2; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if ($objExercise->review_answers) { |
|
|
|
|
if ($objExercise->review_answers) { |
|
|
|
|
if ($debug) { error_log('. redirecting to exercise_reminder.php '); } |
|
|
|
|
header("Location: exercise_reminder.php?$params"); |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
header("Location: exercise_reminder.php?$params"); |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($objExercise->review_answers) { |
|
|
|
|
$script_php = 'exercise_reminder.php'; |
|
|
|
|
$script_php = 'exercise_reminder.php'; |
|
|
|
|
} else { |
|
|
|
|
$script_php = 'exercise_result.php'; |
|
|
|
|
$script_php = 'exercise_result.php'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!empty($error)) { |
|
|
|
@ -1022,10 +1059,10 @@ if (!empty($error)) { |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
function previous_question(question_num) { |
|
|
|
|
url = "exercise_submit.php?'.$params.'&num="+question_num; |
|
|
|
|
window.location = url; |
|
|
|
|
} |
|
|
|
|
function previous_question(question_num) { |
|
|
|
|
url = "exercise_submit.php?'.$params.'&num="+question_num; |
|
|
|
|
window.location = url; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function previous_question_and_save(previous_question_id, question_id_to_save) { |
|
|
|
|
url = "exercise_submit.php?'.$params.'&num="+previous_question_id; |
|
|
|
@ -1180,7 +1217,7 @@ if (!empty($error)) { |
|
|
|
|
<input type="hidden" name="learnpath_item_id" value="'.$learnpath_item_id.'" /> |
|
|
|
|
<input type="hidden" name="learnpath_item_view_id" value="'.$learnpath_item_view_id.'" />'; |
|
|
|
|
|
|
|
|
|
// Show list of questions |
|
|
|
|
// Show list of questions |
|
|
|
|
$i = 1; |
|
|
|
|
$attempt_list = []; |
|
|
|
|
if (isset($exe_id)) { |
|
|
|
@ -1240,10 +1277,10 @@ if (!empty($error)) { |
|
|
|
|
|
|
|
|
|
$attributes = array('id' =>'remind_list['.$questionId.']'); |
|
|
|
|
if (in_array($questionId, $remind_list)) { |
|
|
|
|
$is_remind_on = true; |
|
|
|
|
$attributes['checked'] = 1; |
|
|
|
|
$remind_question = true; |
|
|
|
|
$remind_highlight = ' remind_highlight '; |
|
|
|
|
$is_remind_on = true; |
|
|
|
|
$attributes['checked'] = 1; |
|
|
|
|
$remind_question = true; |
|
|
|
|
$remind_highlight = ' remind_highlight '; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Showing the exercise description |
|
|
|
@ -1326,8 +1363,8 @@ if (!empty($error)) { |
|
|
|
|
} |
|
|
|
|
// end foreach() |
|
|
|
|
if ($objExercise->type == ALL_ON_ONE_PAGE) { |
|
|
|
|
$exercise_actions = $objExercise->show_button($questionId, $current_question); |
|
|
|
|
echo Display::div($exercise_actions, array('class'=>'exercise_actions')); |
|
|
|
|
$exercise_actions = $objExercise->show_button($questionId, $current_question); |
|
|
|
|
echo Display::div($exercise_actions, array('class'=>'exercise_actions')); |
|
|
|
|
echo '<br>'; |
|
|
|
|
} |
|
|
|
|
echo '</form>'; |
|
|
|
|