diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php
index 0464a1f443..3803e0fbb4 100755
--- a/main/exercice/exercise.class.php
+++ b/main/exercice/exercise.class.php
@@ -1607,45 +1607,46 @@ class Exercise {
$time_left = intval($time_left);
return "";
}
diff --git a/main/exercice/exercise_result.php b/main/exercice/exercise_result.php
index e626ff829d..7eee2c2cef 100755
--- a/main/exercice/exercise_result.php
+++ b/main/exercice/exercise_result.php
@@ -167,30 +167,32 @@ Display :: display_confirmation_message(get_lang('Saved').'
',false);
$counter = 1;
// Loop over all question to show results for each of them, one by one
-foreach ($question_list as $questionId) {
- // destruction of the Question object
- unset($objQuestionTmp);
-
- // gets the student choice for this question
- $choice = $exerciseResult[$questionId];
-
- // creates a temporary Question object
- $objQuestionTmp = Question :: read($questionId);
+if (!empty($question_list)) {
+ foreach ($question_list as $questionId) {
+ // destruction of the Question object
+ unset($objQuestionTmp);
- //this variable commes from exercise_submit_modal.php
-
- //$hotspot_delineation_result = $_SESSION['hotspot_delineation_result'][$objExercise->selectId()][$quesId];
+ // gets the student choice for this question
+ $choice = $exerciseResult[$questionId];
+
+ // creates a temporary Question object
+ $objQuestionTmp = Question :: read($questionId);
+
+ //this variable commes from exercise_submit_modal.php
- if ($show_results) {
- // show titles
- echo $objQuestionTmp->return_header($objExercise->feedback_type, $counter);
- $counter++;
- // We're inside *one* question. Go through each possible answer for this question
- $result = $objExercise->manage_answer($exercise_stat_info['exe_id'], $questionId, null ,'exercise_result', array(), false, true, $show_results, $objExercise->selectPropagateNeg(), $hotspot_delineation_result);
- }
- $total_score += $result['score'];
- $total_weight += $result['weight'];
-} // end foreach() block that loops over all questions
+ //$hotspot_delineation_result = $_SESSION['hotspot_delineation_result'][$objExercise->selectId()][$quesId];
+
+ if ($show_results) {
+ // show titles
+ echo $objQuestionTmp->return_header($objExercise->feedback_type, $counter);
+ $counter++;
+ // We're inside *one* question. Go through each possible answer for this question
+ $result = $objExercise->manage_answer($exercise_stat_info['exe_id'], $questionId, null ,'exercise_result', array(), false, true, $show_results, $objExercise->selectPropagateNeg(), $hotspot_delineation_result);
+ }
+ $total_score += $result['score'];
+ $total_weight += $result['weight'];
+ } // end foreach() block that loops over all questions
+}
if ($origin != 'learnpath') {
if ($show_results || $show_only_score) {
@@ -212,12 +214,23 @@ if ($origin != 'learnpath') {
$quizDuration = (!empty($_SESSION['quizStartTime']) ? time() - $_SESSION['quizStartTime'] : 0);
$feed = $objExercise->feedbacktype;
-if (api_is_allowed_to_session_edit()) {
- update_event_exercice($exercise_stat_info['exe_id'], $objExercise->selectId(), $total_score, $total_weight, api_get_session_id(), $safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id, $quiz_duration, $question_list, '');
- api_session_unregister('objExercise');
- api_session_unregister('exe_id');
+if (api_is_allowed_to_session_edit()) {
+ update_event_exercice($exercise_stat_info['exe_id'], $objExercise->selectId(), $total_score, $total_weight, api_get_session_id(), $safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id, $quiz_duration, $question_list, '');
}
+
+//If is not valid
+$session_control_key = get_session_time_control_key($objExercise->id);
+if (isset($session_control_key) && !exercise_time_control_is_valid($objExercise->id)) {
+ $TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
+ $sql_fraud = "UPDATE $TBL_TRACK_ATTEMPT SET answer = 0, marks=0, position=0 WHERE exe_id = $exe_id ";
+ Database::query($sql_fraud);
+}
+
+//Unset session for clock time
+var_dump($objExercise->id);
+exercise_time_control_delete($objExercise->id);
+
if ($origin != 'learnpath') {
Display::display_footer();
} else {
@@ -235,3 +248,7 @@ if ($origin != 'learnpath') {
if (!api_is_allowed_to_edit(null,true)) {
$objExercise->send_notification($arrques, $arrans, $origin);
}
+if (api_is_allowed_to_session_edit()) {
+ api_session_unregister('objExercise');
+ api_session_unregister('exe_id');
+}
diff --git a/main/exercice/exercise_submit.php b/main/exercice/exercise_submit.php
index 985a0a4de6..0a4b653aa2 100644
--- a/main/exercice/exercise_submit.php
+++ b/main/exercice/exercise_submit.php
@@ -50,16 +50,12 @@ $is_allowedToEdit = api_is_allowed_to_edit(null,true);
$htmlHeadXtra[] = api_get_jquery_js();
if (api_get_setting('show_glossary_in_extra_tools') == 'true') {
- $htmlHeadXtra[] = ''; //Glossary
- $htmlHeadXtra[] = '';
+ $htmlHeadXtra[] = api_get_js('glossary.js'); //Glossary
+ $htmlHeadXtra[] = api_get_js('jquery.highlight.js'); //highlight
}
//This library is necessary for the time control feature
-$htmlHeadXtra[] = ''; //jQuery
-
-//Table calls
-$stat_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
-$exercice_attemp_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
+$htmlHeadXtra[] = api_get_js('jquery.epiclock.min.js');
// General parameters passed via POST/GET
if (empty ($origin)) {
@@ -98,41 +94,35 @@ if (empty ($questionNum)) {
if (empty ($current_question)) {
$current_question = intval($_REQUEST['num']);
}
-if (empty ($buttonCancel)) {
- $buttonCancel = $_REQUEST['buttonCancel'];
-}
+
+//Error message
+$error = '';
$reminder = isset($_GET['reminder']) ? intval($_GET['reminder']) : 0;
$remind_question_id = isset($_GET['remind_question_id']) ? intval($_GET['remind_question_id']) : 0;
+$safe_lp_id = ($learnpath_id == '') ? 0 : $learnpath_id;
+$safe_lp_item_id = ($learnpath_item_id == '') ? 0 : $learnpath_item_id;
+$safe_lp_item_view_id = ($learnpath_item_view_id == '') ? 0 : $learnpath_item_view_id;
+
+//if reminder ends we jump to the exexrcise_reminder
if ($remind_question_id == -1) {
header('Location: exercise_reminder.php?origin='.$origin.'&exerciseId='.$exerciseId);
exit;
}
-$error = '';
-
-// If the user has clicked on the "Cancel" button
-if ($buttonCancel) {
- // returns to the exercise list
- header("Location: exercice.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id");
- exit;
-}
-
-$safe_lp_id = ($learnpath_id == '') ? 0 : $learnpath_id;
-$safe_lp_item_id = ($learnpath_item_id == '') ? 0 : $learnpath_item_id;
-$safe_lp_item_view_id = ($learnpath_item_view_id == '') ? 0 : $learnpath_item_view_id;
+//Table calls
+$stat_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+$exercice_attemp_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
-/*
- * Teacher takes an exam and want to see a preview, we delete the objExercise from the session in order to get the latest changes
- in the exercise
-*/
+/* Teacher takes an exam and want to see a preview, we delete the objExercise from the session in order to get the latest changes in the exercise */
if (api_is_allowed_to_edit(null,true) && $_GET['preview'] == 1 ) {
api_session_unregister('objExercise');
}
// 1. Loading the $objExercise variable
-if (!isset ($_SESSION['objExercise']) || $_SESSION['objExercise']->id != $_REQUEST['exerciseId']) {
+
+if (!isset($_SESSION['objExercise']) || $_SESSION['objExercise']->id != $_REQUEST['exerciseId']) {
// Construction of Exercise
$objExercise = new Exercise();
if ($debug) {error_log('1. Setting the $objExercise variable'); };
@@ -163,19 +153,62 @@ if (!is_object($objExercise)) {
exit;
}
-$current_timestamp = time();
+$current_timestamp = time();
+$my_remind_list = array();
//4. Setting the exe_id (attempt id)
+/*
$exe_id = null;
if (isset($_SESSION['exe_id'])) {
$exe_id = $_SESSION['exe_id'];
+}*/
+
+$time_control = false;
+if ($objExercise->expired_time != 0 && $origin != 'learnpath') {
+ $time_control = true;
+}
+
+if ($time_control) {
+ //Get the expired time of the current exercice in track_e_exercices
+ $total_seconds = $objExercise->expired_time*60;
+
+ //Generating the time control key for the user
+ $current_expired_time_key = generate_time_control_key($objExercise->id);
}
+if ($debug) { error_log("4. Setting the exe_id $exe_id");} ;
-//4. Getting user exercise info (if the user took the exam before)
+//5. Getting user exercise info (if the user took the exam before) - generating exe_id
$exercise_stat_info = $objExercise->get_stat_track_exercise_info($safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id);
-//$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
-$my_remind_list = array();
+
+if (empty($exercise_stat_info)) {
+ $total_weight = 0;
+ $questionList = $objExercise->get_validated_question_list();
+ foreach($questionList as $question_id) {
+ $objQuestionTmp = Question::read($question_id);
+ $total_weight += floatval($objQuestionTmp->weighting);
+ }
+ $clock_expired_time = '';
+ if ($time_control) {
+ $expected_time = $current_timestamp + $total_seconds;
+
+ if ($debug) error_log('6.3. $current_timestamp '.$current_timestamp);
+ if ($debug) error_log('6.4. $expected_time '.$expected_time);
+
+ $clock_expired_time = api_get_utc_datetime($expected_time);
+ if ($debug) error_log('6.5. $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('6.6. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] );
+ };
+ }
+ $exe_id = $objExercise->save_stat_track_exercise_info($clock_expired_time, $safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id, $questionList, $total_weight);
+ $exercise_stat_info = $objExercise->get_stat_track_exercise_info($safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id);
+} else {
+ $exe_id = $exercise_stat_info['exe_id'];
+}
if ($debug) { error_log('5. $objExercise->get_stat_track_exercise_info function called:: '.print_r($exercise_stat_info, 1)); };
@@ -184,9 +217,11 @@ if (!empty($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;
+if ($debug) { error_log("5.1 params: -> $params"); };
-if ($reminder == 2 && empty($my_remind_list)) {
+if ($reminder == 2 && empty($my_remind_list)) {
header('Location: exercise_reminder.php?'.$params);
exit;
}
@@ -196,17 +231,12 @@ 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. Disable for learning path
*/
-$time_control = false;
-if ($objExercise->expired_time != 0 && $origin != 'learnpath') {
- $time_control = true;
-}
+
if ($time_control) {
- if ($debug) error_log('6.1. Time control is enabled');
- //Get the expired time of the current exercice in track_e_exercices
- $total_seconds = $objExercise->expired_time*60;
- //Generating the time control key
- $current_expired_time_key = generate_time_control_key($objExercise->id);
+ if ($debug) error_log('6.1. Time control is enabled');
if ($debug) {error_log('6.2. $current_expired_time_key '.$current_expired_time_key); };
+ if ($debug) { error_log('6.2. $_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)) {
@@ -245,23 +275,10 @@ if ($time_control) {
//Sessions that contain the expired time
$_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
-
if ($debug) {error_log('6.9. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
- } else {
- $expected_time = $current_timestamp + $total_seconds;
- if ($debug) error_log('6.3. $current_timestamp '.$current_timestamp);
- if ($debug) error_log('6.4. $expected_time '.$expected_time);
-
- $clock_expired_time = api_get_utc_datetime($expected_time);
- if ($debug) error_log('6.5. $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('6.6. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
}
} else {
- $clock_expired_time = $_SESSION['expired_time'][$current_expired_time_key];
- if ($debug) {error_log('6.2. Getting the $_SESSION[end_expired_time]: '.$_SESSION['end_expired_time'][$current_expired_time_key] ); };
+ $clock_expired_time = $_SESSION['expired_time'][$current_expired_time_key];
}
}
@@ -272,7 +289,7 @@ $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 exercice form when the expired time is finished
+if ($time_control) { //Sends the exercice form when the expired time is finished
$htmlHeadXtra[] = $objExercise->show_time_control_js($time_left);
}
@@ -302,14 +319,16 @@ $exercise_sound = $objExercise->selectSound();
//if (!isset($_SESSION['questionList']) || $origin == 'learnpath') {
//in LP's is enabled the "remember question" feature?
+
if (!isset($_SESSION['questionList'])) {
// selects the list of question ID
$questionList = $objExercise->get_validated_question_list();
- api_session_register('questionList');
+ api_session_register('questionList');
if ($debug > 0) { error_log('$_SESSION[questionList] was set'); }
-}
-if (!isset($objExercise) && isset($_SESSION['objExercise'])) {
- $questionList = $_SESSION['questionList'];
+} else {
+ if (isset($objExercise) && isset($_SESSION['objExercise'])) {
+ $questionList = $_SESSION['questionList'];
+ }
}
if ($debug) error_log('7 Question list loaded '.print_r($questionList, 1));
@@ -427,7 +446,8 @@ if ($formSent && isset($_POST)) {
Database::query($update_query);*/
}
if ($debug) { error_log('Redirecting to exercise_show.php'); }
- header("Location: exercise_show.php?id=$exe_id&origin=$origin&learnpath_id=$safe_lp_id&learnpath_item_id=$safe_lp_item_id&learnpath_item_view_id=$safe_lp_item_view_id");
+ //header("Location: exercise_show.php?id=$exe_id&origin=$origin&learnpath_id=$safe_lp_id&learnpath_item_id=$safe_lp_item_id&learnpath_item_view_id=$safe_lp_item_view_id");
+ header("Location: exercise_result.php?exe_id=$exe_id&origin=$origin&learnpath_id=$safe_lp_id&learnpath_item_id=$safe_lp_item_id&learnpath_item_view_id=$safe_lp_item_view_id");
exit;
}
} else {
@@ -453,7 +473,7 @@ if (!$current_question || $_REQUEST['num']) {
$current_question++;
}
}
-
+//var_dump($current_question , $question_count);
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
@@ -478,11 +498,13 @@ if (($objExercise->type == ALL_ON_ONE_PAGE || $current_question > $question_coun
//header("Location: exercise_result.php?origin=$origin&learnpath_id=$safe_lp_id&learnpath_item_id=$safe_lp_item_id&learnpath_item_view_id=$safe_lp_item_view_id");
//exit;
} else {
- //Time control is only enabled for ONE PER PAGE
-
+
+ //Time control is only enabled for ONE PER PAGE
if (!empty($exe_id) && is_numeric($exe_id)) {
//Verify if the current test is fraudulent
- if (exercise_time_control_is_valid($exerciseId)) {
+ $check = exercise_time_control_is_valid($exerciseId);
+
+ if ($check) {
$sql_exe_result = "";
if ($debug) { error_log('exercise_time_control_is_valid is valid'); }
} else {
@@ -496,9 +518,10 @@ if (($objExercise->type == ALL_ON_ONE_PAGE || $current_question > $question_coun
//if ($debug) { error_log('Updating track_e_exercises '.$update_query); }
Database::query($update_query);*/
}
- //if ($debug) { error_log('Redirecting to exercise_show.php'); }
+ //if ($debug) { error_log('Redirecting to exercise_show.php'); }
header('Location: exercise_reminder.php?'.$params);
exit;
+ //header("Location: exercise_submit.php?exerciseId=$exerciseId");
}
} else {
if ($debug) { error_log('Redirecting to exercise_submit.php'); }
@@ -537,7 +560,7 @@ $show_quiz_edition = $objExercise->added_in_lp();
// I'm in a preview mode
if (api_is_course_admin() && $origin != 'learnpath') {
echo '