diff --git a/main/exercice/exercice_submit.php b/main/exercice/exercice_submit.php index 23248e0afe..131617c88e 100755 --- a/main/exercice/exercice_submit.php +++ b/main/exercice/exercice_submit.php @@ -39,18 +39,18 @@ $htmlHeadXtra[] = ''; if (api_get_setting('show_glossary_in_extra_tools') == 'true') { - $htmlHeadXtra[] = ''; //Glossary - $htmlHeadXtra[] = ''; + $htmlHeadXtra[] = ''; //Glossary + $htmlHeadXtra[] = ''; } //This library is necessary for the time control feature $htmlHeadXtra[] = ''; //jQuery if (!ereg("MSIE",$_SERVER["HTTP_USER_AGENT"])) { - $htmlHeadXtra[] = ""; + $htmlHeadXtra[] = ""; } /* ------------ ACCESS RIGHTS ------------ */ // notice for unauthorized people. @@ -72,110 +72,110 @@ $TBL_REPONSES = Database :: get_course_table(TABLE_QUIZ_ANSWER); // general parameters passed via POST/GET if (empty ($origin)) { - $origin = $_REQUEST['origin']; + $origin = $_REQUEST['origin']; } if (empty ($learnpath_id)) { - $learnpath_id = Security::remove_XSS($_REQUEST['learnpath_id']); + $learnpath_id = Security::remove_XSS($_REQUEST['learnpath_id']); } if (empty ($learnpath_item_id)) { - $learnpath_item_id = Security::remove_XSS($_REQUEST['learnpath_item_id']); + $learnpath_item_id = Security::remove_XSS($_REQUEST['learnpath_item_id']); } if (empty ($formSent)) { - $formSent = $_REQUEST['formSent']; + $formSent = $_REQUEST['formSent']; } if (empty ($exerciseResult)) { - $exerciseResult = $_REQUEST['exerciseResult']; + $exerciseResult = $_REQUEST['exerciseResult']; } if (empty ($exerciseResultCoordinates)) { - $exerciseResultCoordinates = $_REQUEST['exerciseResultCoordinates']; + $exerciseResultCoordinates = $_REQUEST['exerciseResultCoordinates']; } if (empty ($exerciseType)) { - $exerciseType = $_REQUEST['exerciseType']; + $exerciseType = $_REQUEST['exerciseType']; } if (empty ($exerciseId)) { - $exerciseId = Database::escape_string(intval($_REQUEST['exerciseId'])); + $exerciseId = Database::escape_string(intval($_REQUEST['exerciseId'])); } if (empty ($choice)) { - $choice = $_REQUEST['choice']; + $choice = $_REQUEST['choice']; } if (empty ($_REQUEST['choice'])) { - $choice = $_REQUEST['choice2']; + $choice = $_REQUEST['choice2']; } if (empty ($questionNum)) { - $questionNum = Database :: escape_string($_REQUEST['questionNum']); + $questionNum = Database :: escape_string($_REQUEST['questionNum']); } if (empty ($nbrQuestions)) { - $nbrQuestions = Database :: escape_string($_REQUEST['nbrQuestions']); + $nbrQuestions = Database :: escape_string($_REQUEST['nbrQuestions']); } if (empty ($buttonCancel)) { - $buttonCancel = $_REQUEST['buttonCancel']; + $buttonCancel = $_REQUEST['buttonCancel']; } $error = ''; if (!isset ($exerciseType)) { - $exe_start_date = time(); - $_SESSION['exercice_start_date'] = $exe_start_date; + $exe_start_date = time(); + $_SESSION['exercice_start_date'] = $exe_start_date; } // 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"); - exit (); + // returns to the exercise list + header("Location: exercice.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id"); + exit (); } if ($origin == 'learnpath' && isset ($_GET['not_multiple_attempt']) && $_GET['not_multiple_attempt'] == strval(intval($_GET['not_multiple_attempt']))) { - $not_multiple_attempt = (int) $_GET['not_multiple_attempt']; - if ($not_multiple_attempt === 1) { - require_once '../inc/reduced_header.inc.php'; - echo '
 
'; - Display :: display_warning_message(get_lang('ReachedOneAttempt')); - exit; - } + $not_multiple_attempt = (int) $_GET['not_multiple_attempt']; + if ($not_multiple_attempt === 1) { + require_once '../inc/reduced_header.inc.php'; + echo '
 
'; + Display :: display_warning_message(get_lang('ReachedOneAttempt')); + exit; + } } if ($origin == 'builder') { - /*******************************/ - /* Clears the exercise session */ - /*******************************/ - if (isset ($_SESSION['objExercise'])) { - api_session_unregister('objExercise'); - unset ($objExercise); - } - if (isset ($_SESSION['objQuestion'])) { - api_session_unregister('objQuestion'); - unset ($objQuestion); - } - if (isset ($_SESSION['objAnswer'])) { - api_session_unregister('objAnswer'); - unset ($objAnswer); - } - if (isset ($_SESSION['questionList'])) { - api_session_unregister('questionList'); - unset ($questionList); - } - if (isset ($_SESSION['newquestionList'])) { - api_session_unregister('newquestionList'); - unset ($newquestionList); - } - if (isset ($_SESSION['exerciseResult'])) { - api_session_unregister('exerciseResult'); - unset ($exerciseResult); - } - if (isset ($_SESSION['exerciseResultCoordinates'])) { - api_session_unregister('exerciseResultCoordinates'); - unset ($exerciseResultCoordinates); - } + /*******************************/ + /* Clears the exercise session */ + /*******************************/ + if (isset ($_SESSION['objExercise'])) { + api_session_unregister('objExercise'); + unset ($objExercise); + } + if (isset ($_SESSION['objQuestion'])) { + api_session_unregister('objQuestion'); + unset ($objQuestion); + } + if (isset ($_SESSION['objAnswer'])) { + api_session_unregister('objAnswer'); + unset ($objAnswer); + } + if (isset ($_SESSION['questionList'])) { + api_session_unregister('questionList'); + unset ($questionList); + } + if (isset ($_SESSION['newquestionList'])) { + api_session_unregister('newquestionList'); + unset ($newquestionList); + } + if (isset ($_SESSION['exerciseResult'])) { + api_session_unregister('exerciseResult'); + unset ($exerciseResult); + } + if (isset ($_SESSION['exerciseResultCoordinates'])) { + api_session_unregister('exerciseResultCoordinates'); + unset ($exerciseResultCoordinates); + } } $safe_lp_id = ($learnpath_id == '') ? 0 : (int) $learnpath_id; $safe_lp_item_id = ($learnpath_item_id == '') ? 0 : (int) $learnpath_item_id; $condition = ' WHERE ' . - 'exe_exo_id = ' . "'" . $exerciseId . "'" . ' AND ' . - 'exe_user_id = ' . "'" . api_get_user_id() . "'" . ' AND ' . - 'exe_cours_id = ' . "'" . $_course['id'] . "'" . ' AND ' . - 'status = ' . "'incomplete'" . ' AND ' . - 'orig_lp_id = ' . "'" . $safe_lp_id . "'" . ' AND ' . - 'orig_lp_item_id = ' . "'" . $safe_lp_item_id . "'" . ' AND ' . - 'session_id = ' . "'" . (int) $_SESSION['id_session'] . "'"; + 'exe_exo_id = ' . "'" . $exerciseId . "'" . ' AND ' . + 'exe_user_id = ' . "'" . api_get_user_id() . "'" . ' AND ' . + 'exe_cours_id = ' . "'" . $_course['id'] . "'" . ' AND ' . + 'status = ' . "'incomplete'" . ' AND ' . + 'orig_lp_id = ' . "'" . $safe_lp_id . "'" . ' AND ' . + 'orig_lp_item_id = ' . "'" . $safe_lp_item_id . "'" . ' AND ' . + 'session_id = ' . "'" . (int) $_SESSION['id_session'] . "'"; $TBL_EXERCICES = Database :: get_course_table(TABLE_QUIZ_TEST); $sql_track_exercice = "SELECT type,feedback_type,expired_time FROM $TBL_EXERCICES WHERE id=$exerciseId"; @@ -184,6 +184,12 @@ $exercise_row = Database :: fetch_array($result); $exerciseType = $exercise_row['type']; $exerciseFeedbackType = $exercise_row['feedback_type']; +/* + * Time control feature + * if the expired time is major that zero(0) then + * the expired time is compute on this time + */ + //Get the expired time of the current exercice in track_e_exercices $total_minutes = $exercise_row["expired_time"]; @@ -191,64 +197,74 @@ $total_seconds = $total_minutes*60; $current_timestamp = time(); if ($exercise_row['expired_time'] != 0) { - if (!isset($_SESSION['expired_time'])) { - //In case that the current session php is broken - //Timer - Get expired_time for a student - $condition = ' WHERE ' . - 'exe_exo_id = '."'".Database::escape_string($exerciseId)."'".' AND ' . - 'exe_user_id = '."'".api_get_user_id()."'".' AND ' . - 'exe_cours_id = '."'".api_get_course_id()."'".' AND ' . - 'status = '."'incomplete'".' AND '. - 'session_id = '."'".api_get_session_id()."'"; - - $sql_track = 'SELECT exe_id,expired_time_control FROM '.$stat_table.$condition; - $rs_sql = Database::query($sql_track,__FILE__,__LINE__); - $exists_into_database = Database::num_rows($rs_sql); - $track_exercice_row = Database::fetch_array($rs_sql); - $expired_time_of_this_attempt = $track_exercice_row['expired_time_control']; - - //Get the last attempt of an exercice - $sql_track_attempt = 'SELECT max(tms) as last_attempt_date FROM '.$exercice_attemp_table.' WHERE exe_id="'.$track_exercice_row['exe_id'].'"'; - $rs_last_attempt = Database::query($sql_track_attempt,__FILE__,__LINE__); - $row_last_attempt = Database::fetch_array($rs_last_attempt); - $my_last_attempt_date = $row_last_attempt['last_attempt_date']; - - //change the date format - $my_last_attempt_date = strtotime($my_last_attempt_date); - $expired_time_of_this_attempt = strtotime($expired_time_of_this_attempt); - - //New expired time - $new_expired_time_in_seconds = $expired_time_of_this_attempt - $my_last_attempt_date; - - if ($exists_into_database == 1) { - $expected_time = $current_timestamp + $new_expired_time_in_seconds; - - $plugin_expired_time = date('M d, Y H:i:s',$expected_time); - $clock_expired_time = date('Y-m-d H:i:s',$expected_time); - - //We modify the "expired_time_control" field in track_e_exercices for this attempt - $sql_track_e_exe = "UPDATE $stat_table SET expired_time_control = '".$clock_expired_time."' WHERE exe_id = '".$track_exercice_row['exe_id']."'"; - Database::query($sql_track_e_exe,__FILE__,__LINE__); + if (!isset($_SESSION['expired_time'])) { + //In case that the current session php is broken + //Timer - Get expired_time for a student + $condition = ' WHERE ' . + 'exe_exo_id = '."'".Database::escape_string($exerciseId)."'".' AND ' . + 'exe_user_id = '."'".api_get_user_id()."'".' AND ' . + 'exe_cours_id = '."'".api_get_course_id()."'".' AND ' . + 'status = '."'incomplete'".' AND '. + 'session_id = '."'".api_get_session_id()."'"; + + $sql_track = 'SELECT exe_id,expired_time_control FROM '.$stat_table.$condition; + $rs_sql = Database::query($sql_track,__FILE__,__LINE__); + $exists_into_database = Database::num_rows($rs_sql); + $track_exercice_row = Database::fetch_array($rs_sql); + $expired_time_of_this_attempt = $track_exercice_row['expired_time_control']; + + //Get the last attempt of an exercice + $sql_track_attempt = 'SELECT max(tms) as last_attempt_date FROM '.$exercice_attemp_table.' WHERE exe_id="'.$track_exercice_row['exe_id'].'"'; + $rs_last_attempt = Database::query($sql_track_attempt,__FILE__,__LINE__); + $row_last_attempt = Database::fetch_array($rs_last_attempt); + $my_last_attempt_date = $row_last_attempt['last_attempt_date'];//Get the date of last attempt + $date_of_last_attempt = $my_last_attempt_date;// Necessary for to change the last attempt + + //change the date format + $my_last_attempt_date = strtotime($my_last_attempt_date); + $expired_time_of_this_attempt = strtotime($expired_time_of_this_attempt); + + //New expired time - it is due to the possible closure of session + $new_expired_time_in_seconds = $expired_time_of_this_attempt - $my_last_attempt_date; + + if ($exists_into_database == 1) { + $expected_time = $current_timestamp + $new_expired_time_in_seconds; + $plugin_expired_time = date('M d, Y H:i:s', $expected_time); + $clock_expired_time = date('Y-m-d H:i:s' , $expected_time); + $new_last_attempt = date('Y-m-d H:i:s' , $current_timestamp); + + //We modify the "expired_time_control" field in track_e_exercices for this attempt + $sql_track_e_exe = "UPDATE $stat_table SET expired_time_control = '".$clock_expired_time."' WHERE exe_id = '".$track_exercice_row['exe_id']."'"; + Database::query($sql_track_e_exe,__FILE__,__LINE__); + + // How the expired time is changed into "track_e_exercices" table,then the last attempt for this student should be changed too,so + $sql_track_e_exe = "UPDATE $exercice_attemp_table SET tms = '".$new_last_attempt."' WHERE exe_id = '".$track_exercice_row['exe_id']."' and tms = '".$date_of_last_attempt."' "; + Database::query($sql_track_e_exe,__FILE__,__LINE__); + //Sessions that contain the expired time - $_SESSION['expired_time'] = $clock_expired_time; - $_SESSION['end_expired_time'] = date('M d, Y H:i:s',$expected_time); - } else { - $expected_time = $current_timestamp + $total_seconds; - - $plugin_expired_time = date('M d, Y H:i:s',$expected_time); - $clock_expired_time = date('Y-m-d H:i:s',$expected_time); + $_SESSION['expired_time'] = $clock_expired_time; + $_SESSION['end_expired_time'] = date('M d, Y H:i:s',$expected_time); + } else { + $expected_time = $current_timestamp + $total_seconds; + + $plugin_expired_time = date('M d, Y H:i:s',$expected_time); + $clock_expired_time = date('Y-m-d H:i:s',$expected_time); //Sessions that contain the expired time - $_SESSION['expired_time'] = $clock_expired_time; - $_SESSION['end_expired_time'] = date('M d, Y H:i:s',$expected_time); - } - - } else { - $plugin_expired_time = $_SESSION['end_expired_time']; - } + $_SESSION['expired_time'] = $clock_expired_time; + $_SESSION['end_expired_time'] = date('M d, Y H:i:s',$expected_time); + } + + } else { + $plugin_expired_time = $_SESSION['end_expired_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 ($exercise_row['expired_time'] != 0) { //Sends the exercice form when the expired time is finished $htmlHeadXtra[] = " - - - - - "; - Display :: display_header($nameTools, "Exercise"); - if (!api_is_allowed_to_session_edit() ) { - Display :: display_warning_message(get_lang('SessionIsReadOnly')); - } + $htmlHeadXtra[] = " + + + + + "; + Display :: display_header($nameTools, "Exercise"); + if (!api_is_allowed_to_session_edit() ) { + Display :: display_warning_message(get_lang('SessionIsReadOnly')); + } } else { - if (empty ($charset)) { - $charset = 'ISO-8859-15'; - } - /* - * HTML HEADER - */ - Display::display_reduced_header(); - echo '
 
'; + if (empty ($charset)) { + $charset = 'ISO-8859-15'; + } + /* + * HTML HEADER + */ + Display::display_reduced_header(); + echo '
 
'; } // I'm in a preview mode if (api_is_course_admin() && $origin != 'learnpath') { - echo '
'; - echo Display :: return_icon('quiz.gif', get_lang('GoBackToEx')) . '' . get_lang('GoBackToEx') . ''; - echo Display :: return_icon('edit.gif', get_lang('ModifyExercise')) . '' . get_lang('ModifyExercise') . ''; - echo '
'; + echo '
'; + echo Display :: return_icon('quiz.gif', get_lang('GoBackToEx')) . '' . get_lang('GoBackToEx') . ''; + echo Display :: return_icon('edit.gif', get_lang('ModifyExercise')) . '' . get_lang('ModifyExercise') . ''; + echo '
'; } //Timer control if ($exercise_row['expired_time'] != 0) { @@ -1020,233 +1033,233 @@ $exerciseTitle = api_parse_tex($exerciseTitle); echo "

" . $exerciseTitle . "

"; if ($exerciseAttempts > 0) { - $user_id = api_get_user_id(); - $course_code = api_get_course_id(); - $sql = "SELECT count(*) FROM $stat_table WHERE exe_exo_id = '$quizID' - AND exe_user_id = '$user_id' - AND status != 'incomplete' - AND orig_lp_id = $safe_lp_id - AND orig_lp_item_id = $safe_lp_item_id - AND exe_cours_id = '$course_code' AND session_id = '" . (int) $_SESSION['id_session'] . "'"; - - $aquery = Database::query($sql, __FILE__, __LINE__); - $attempt = Database :: fetch_array($aquery); - - if ($attempt[0] >= $exerciseAttempts) { - if (!api_is_allowed_to_edit(null,true)) { - Display :: display_warning_message(sprintf(get_lang('ReachedMaxAttempts'), $exerciseTitle, $exerciseAttempts), false); - if ($origin != 'learnpath') - Display :: display_footer(); - exit; - } else { - Display :: display_warning_message(sprintf(get_lang('ReachedMaxAttemptsAdmin'), $exerciseTitle, $exerciseAttempts), false); - } - } + $user_id = api_get_user_id(); + $course_code = api_get_course_id(); + $sql = "SELECT count(*) FROM $stat_table WHERE exe_exo_id = '$quizID' + AND exe_user_id = '$user_id' + AND status != 'incomplete' + AND orig_lp_id = $safe_lp_id + AND orig_lp_item_id = $safe_lp_item_id + AND exe_cours_id = '$course_code' AND session_id = '" . (int) $_SESSION['id_session'] . "'"; + + $aquery = Database::query($sql, __FILE__, __LINE__); + $attempt = Database :: fetch_array($aquery); + + if ($attempt[0] >= $exerciseAttempts) { + if (!api_is_allowed_to_edit(null,true)) { + Display :: display_warning_message(sprintf(get_lang('ReachedMaxAttempts'), $exerciseTitle, $exerciseAttempts), false); + if ($origin != 'learnpath') + Display :: display_footer(); + exit; + } else { + Display :: display_warning_message(sprintf(get_lang('ReachedMaxAttemptsAdmin'), $exerciseTitle, $exerciseAttempts), false); + } + } } if (!function_exists('convert_date_to_number')) { - function convert_date_to_number($default) { - // 2008-10-12 00:00:00 ---to--> 12345672218 (timestamp) - $parts = split(' ', $default); - list ($d_year, $d_month, $d_day) = split('-', $parts[0]); - list ($d_hour, $d_minute, $d_second) = split(':', $parts[1]); - return mktime($d_hour, $d_minute, $d_second, $d_month, $d_day, $d_year); - } + function convert_date_to_number($default) { + // 2008-10-12 00:00:00 ---to--> 12345672218 (timestamp) + $parts = split(' ', $default); + list ($d_year, $d_month, $d_day) = split('-', $parts[0]); + list ($d_hour, $d_minute, $d_second) = split(':', $parts[1]); + return mktime($d_hour, $d_minute, $d_second, $d_month, $d_day, $d_year); + } } $limit_time_exists = (($Exe_starttime != '0000-00-00 00:00:00') || ($Exe_endtime != '0000-00-00 00:00:00')) ? true : false; if ($limit_time_exists) { - $exercise_start_time = convert_date_to_number($Exe_starttime); - $exercise_end_time = convert_date_to_number($Exe_endtime); - $time_now = convert_date_to_number(date('Y-m-d H:i:s')); - $permission_to_start = (($time_now - $exercise_start_time) > 0) ? true : false; - if ($_SERVER['REQUEST_METHOD'] != 'POST') - $exercise_timeover = (($time_now - $exercise_end_time) > 0) ? true : false; - if ($permission_to_start == false || $exercise_timeover == true) { // - if (!api_is_allowed_to_edit(null,true)) { - $message_warning = ($permission_to_start == false) ? get_lang('ExerciseNoStartedYet') : get_lang('ReachedTimeLimit'); - Display :: display_warning_message(sprintf($message_warning, $exerciseTitle, $exerciseAttempts)); - Display :: display_footer(); - exit; - } else { - $message_warning = ($permission_to_start == false) ? get_lang('ExerciseNoStartedAdmin') : get_lang('ReachedTimeLimitAdmin'); - Display :: display_warning_message(sprintf($message_warning, $exerciseTitle, $exerciseAttempts)); - } - } + $exercise_start_time = convert_date_to_number($Exe_starttime); + $exercise_end_time = convert_date_to_number($Exe_endtime); + $time_now = convert_date_to_number(date('Y-m-d H:i:s')); + $permission_to_start = (($time_now - $exercise_start_time) > 0) ? true : false; + if ($_SERVER['REQUEST_METHOD'] != 'POST') + $exercise_timeover = (($time_now - $exercise_end_time) > 0) ? true : false; + if ($permission_to_start == false || $exercise_timeover == true) { // + if (!api_is_allowed_to_edit(null,true)) { + $message_warning = ($permission_to_start == false) ? get_lang('ExerciseNoStartedYet') : get_lang('ReachedTimeLimit'); + Display :: display_warning_message(sprintf($message_warning, $exerciseTitle, $exerciseAttempts)); + Display :: display_footer(); + exit; + } else { + $message_warning = ($permission_to_start == false) ? get_lang('ExerciseNoStartedAdmin') : get_lang('ReachedTimeLimitAdmin'); + Display :: display_warning_message(sprintf($message_warning, $exerciseTitle, $exerciseAttempts)); + } + } } if (!empty ($error)) { - Display :: display_error_message($error, false); + Display :: display_error_message($error, false); } else { - if (!empty ($exerciseSound)) { - echo "", ", get_lang('Sound') .
-		"; - } - - // Get number of hotspot questions for javascript validation - $number_of_hotspot_questions = 0; - $onsubmit = ''; - $i = 0; - //i have a doubt in this line cvargas - //var_dump($questionList); - if (!strcmp($questionList[0], '') === 0) { - foreach ($questionList as $questionId) { - $i++; - $objQuestionTmp = Question :: read($questionId); - // for sequential exercises - if ($exerciseType == ONE_PER_PAGE) { - // if it is not the right question, goes to the next loop iteration - if ($questionNum != $i) { - continue; - } else { - if ($objQuestionTmp->selectType() == HOT_SPOT) { - $number_of_hotspot_questions++; - } - - break; - } - } else { - if ($objQuestionTmp->selectType() == HOT_SPOT) { - $number_of_hotspot_questions++; - } - } - } - } - if ($number_of_hotspot_questions > 0) { - $onsubmit = "onsubmit=\"return validateFlashVar('" . $number_of_hotspot_questions . "', '" . get_lang('HotspotValidateError1') . "', '" . get_lang('HotspotValidateError2') . "');\""; - } - $s = "

$exerciseDescription

"; - - if ($exerciseType == ONE_PER_PAGE) - { - $s2 = "&exerciseId=" . $exerciseId; - } - - $s .= "
- - - - - - - - - - -
- "; + if (!empty ($exerciseSound)) { + echo "", ", get_lang('Sound') .
+        "; + } + + // Get number of hotspot questions for javascript validation + $number_of_hotspot_questions = 0; + $onsubmit = ''; + $i = 0; + //i have a doubt in this line cvargas + //var_dump($questionList); + if (!strcmp($questionList[0], '') === 0) { + foreach ($questionList as $questionId) { + $i++; + $objQuestionTmp = Question :: read($questionId); + // for sequential exercises + if ($exerciseType == ONE_PER_PAGE) { + // if it is not the right question, goes to the next loop iteration + if ($questionNum != $i) { + continue; + } else { + if ($objQuestionTmp->selectType() == HOT_SPOT) { + $number_of_hotspot_questions++; + } + + break; + } + } else { + if ($objQuestionTmp->selectType() == HOT_SPOT) { + $number_of_hotspot_questions++; + } + } + } + } + if ($number_of_hotspot_questions > 0) { + $onsubmit = "onsubmit=\"return validateFlashVar('" . $number_of_hotspot_questions . "', '" . get_lang('HotspotValidateError1') . "', '" . get_lang('HotspotValidateError2') . "');\""; + } + $s = "

$exerciseDescription

"; + + if ($exerciseType == ONE_PER_PAGE) + { + $s2 = "&exerciseId=" . $exerciseId; + } + + $s .= " + + + + + + + + +
+ + - -
+ "; echo '
'; - echo $s; - $i = 1; - foreach ($questionList as $questionId) { - // for sequential exercises - if ($exerciseType == ONE_PER_PAGE) { - // if it is not the right question, goes to the next loop iteration - if ($questionNum != $i) { - $i++; - continue; - } else { - if ($exerciseFeedbackType != EXERCISE_FEEDBACK_TYPE_DIRECT) { - // if the user has already answered this question - if (isset ($exerciseResult[$questionId])) { - // construction of the Question object - $objQuestionTmp = Question :: read($questionId); - $questionName = $objQuestionTmp->selectTitle(); - // destruction of the Question object - unset ($objQuestionTmp); - Display :: display_normal_message(get_lang('AlreadyAnswered')); - $i++; - //echo '
'; - break; - } - } - } - } - // shows the question and its answers - showQuestion($questionId, false, $origin, $i, $nbrQuestions); - $i++; - // for sequential exercises - if ($exerciseType == ONE_PER_PAGE) { - // quits the loop - break; - } - } - // end foreach() - echo "
"; - echo '
'; - $submit_btn = "
'; + break; + } + } + } + } + // shows the question and its answers + showQuestion($questionId, false, $origin, $i, $nbrQuestions); + $i++; + // for sequential exercises + if ($exerciseType == ONE_PER_PAGE) { + // quits the loop + break; + } + } + // end foreach() + echo "
"; + echo '
'; + $submit_btn = ""; + } + $submit_btn .= ""; if ($exercise_row['expired_time'] != 0) { - echo $submit_btn =""; + echo $submit_btn =""; } else { - echo $submit_btn; + echo $submit_btn; } - } + } - } + } - echo "
'.get_lang('AlreadyAnswered').' "'.$questionName.'"
'.get_lang('AlreadyAnswered').' "'.$questionName.'"
-
"; - $b = 2; + echo "
+ + + "; + $b = 2; } echo ''; if ($_configuration['live_exercise_tracking'] == true && $exerciseFeedbackType != EXERCISE_FEEDBACK_TYPE_DIRECT) { - - if ($table_recorded_not_exist) { //$table_recorded_not_exist - if ($exercise_row['expired_time'] != 0) { - $sql_fields = "expired_time_control, "; - $sql_fields_values = "'"."$clock_expired_time"."',"; - } else { - $sql_fields = ""; - $sql_fields_values = ""; - } - - if ($exerciseType == ONE_PER_PAGE) { - $sql = "INSERT INTO $stat_table($sql_fields exe_exo_id,exe_user_id,exe_cours_id,status,session_id,data_tracking,start_date,orig_lp_id,orig_lp_item_id) - VALUES($sql_fields_values '$exerciseId','" . api_get_user_id() . "','" . $_course['id'] . "','incomplete','" . api_get_session_id() . "','" . implode(',', $questionList) . "','" . date('Y-m-d H:i:s') . "',$safe_lp_id,$safe_lp_item_id)"; + + if ($table_recorded_not_exist) { //$table_recorded_not_exist + if ($exercise_row['expired_time'] != 0) { + $sql_fields = "expired_time_control, "; + $sql_fields_values = "'"."$clock_expired_time"."',"; + } else { + $sql_fields = ""; + $sql_fields_values = ""; + } + + if ($exerciseType == ONE_PER_PAGE) { + $sql = "INSERT INTO $stat_table($sql_fields exe_exo_id,exe_user_id,exe_cours_id,status,session_id,data_tracking,start_date,orig_lp_id,orig_lp_item_id) + VALUES($sql_fields_values '$exerciseId','" . api_get_user_id() . "','" . $_course['id'] . "','incomplete','" . api_get_session_id() . "','" . implode(',', $questionList) . "','" . date('Y-m-d H:i:s') . "',$safe_lp_id,$safe_lp_item_id)"; - Database::query($sql, __FILE__, __LINE__); - } else { - echo $sql = "INSERT INTO $stat_table ($sql_fields exe_exo_id,exe_user_id,exe_cours_id,status,session_id,start_date,orig_lp_id,orig_lp_item_id) - VALUES($sql_fields_values '$exerciseId','" . api_get_user_id() . "','" . $_course['id'] . "','incomplete','" . api_get_session_id() . "','" . date('Y-m-d H:i:s') . "',$safe_lp_id,$safe_lp_item_id)"; - Database::query($sql, __FILE__, __LINE__); - } - - } + Database::query($sql, __FILE__, __LINE__); + } else { + echo $sql = "INSERT INTO $stat_table ($sql_fields exe_exo_id,exe_user_id,exe_cours_id,status,session_id,start_date,orig_lp_id,orig_lp_item_id) + VALUES($sql_fields_values '$exerciseId','" . api_get_user_id() . "','" . $_course['id'] . "','incomplete','" . api_get_session_id() . "','" . date('Y-m-d H:i:s') . "',$safe_lp_id,$safe_lp_item_id)"; + Database::query($sql, __FILE__, __LINE__); + } + + } } if ($origin != 'learnpath') { - //so we are not in learnpath tool + //so we are not in learnpath tool echo ''; //End glossary div - Display :: display_footer(); + Display :: display_footer(); } else { - echo ''; + echo ''; }