123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696 |
- <?php
- require_once 'exercise.class.php';
- require_once 'question.class.php';
- require_once 'answer.class.php';
- require_once 'exercise.lib.php';
- $language_file = 'exercice';
- require_once '../inc/global.inc.php';
- $this_section = SECTION_COURSES;
- if($debug) { error_log('Entered exercise_submit.php: '.print_r($_POST,1)); }
- api_protect_course_script(true);
- $is_allowedToEdit = api_is_allowed_to_edit(null,true);
- if (api_get_setting('show_glossary_in_extra_tools') == 'true') {
- $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/glossary.js" type="text/javascript" language="javascript"></script>';
- $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.highlight.js" type="text/javascript" language="javascript"></script>';
- }
- $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.epiclock.min.js" type="text/javascript" language="javascript"></script>';
- $_configuration['live_exercise_tracking'] = true;
- $stat_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
- $exercice_attemp_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
- $TBL_EXERCICE_QUESTION = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
- $TBL_EXERCICES = Database :: get_course_table(TABLE_QUIZ_TEST);
- $TBL_QUESTIONS = Database :: get_course_table(TABLE_QUIZ_QUESTION);
- $TBL_REPONSES = Database :: get_course_table(TABLE_QUIZ_ANSWER);
- if (empty ($origin)) {
- $origin = Security::remove_XSS($_REQUEST['origin']);
- }
- if (empty ($learnpath_id)) {
- $learnpath_id = intval($_REQUEST['learnpath_id']);
- }
- if (empty ($learnpath_item_id)) {
- $learnpath_item_id = intval($_REQUEST['learnpath_item_id']);
- }
- if (empty ($learnpath_item_view_id)) {
- $learnpath_item_view_id = intval($_REQUEST['learnpath_item_view_id']);
- }
- if (empty ($formSent)) {
- $formSent = $_REQUEST['formSent'];
- }
- if (empty ($exerciseResult)) {
- $exerciseResult = $_REQUEST['exerciseResult'];
- }
- if (empty ($exerciseResultCoordinates)) {
- $exerciseResultCoordinates = $_REQUEST['exerciseResultCoordinates'];
- }
- if (empty ($exerciseType)) {
- $exerciseType = $_REQUEST['exerciseType'];
- }
- if (empty ($exerciseId)) {
- $exerciseId = intval($_REQUEST['exerciseId']);
- }
- if (empty ($choice)) {
- $choice = $_REQUEST['choice'];
- }
- if (empty ($_REQUEST['choice'])) {
- $choice = $_REQUEST['choice2'];
- }
- if (empty ($questionNum)) {
- $questionNum = intval($_REQUEST['questionNum']);
- }
- if (empty ($nbrQuestions)) {
- $nbrQuestions = intval($_REQUEST['nbrQuestions']);
- }
- if (empty ($buttonCancel)) {
- $buttonCancel = $_REQUEST['buttonCancel'];
- }
- $error = '';
- if ($buttonCancel) {
-
- 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;
- if (api_is_allowed_to_edit(null,true) && $_GET['preview'] == 1 ) {
- api_session_unregister('objExercise');
- }
- if (!isset ($_SESSION['objExercise']) || $_SESSION['objExercise']->id != $_REQUEST['exerciseId']) {
-
- $objExercise = new Exercise();
- if ($debug) {error_log('Setting the $objExercise variable'); };
- unset($_SESSION['questionList']);
-
- if (!$objExercise->read($exerciseId) || (!$objExercise->selectStatus() && !$is_allowedToEdit && ($origin != 'learnpath'))) {
- if ($debug) {error_log('Error while reading the exercise'); };
- unset ($objExercise);
- $error = get_lang('ExerciseNotFound');
- } else {
-
- api_session_register('objExercise');
- if ($debug) {error_log('$_SESSION[objExercise] was unset - set now - end'); };
- }
- }
- if (!isset ($objExercise) && isset($_SESSION['objExercise'])) {
- if ($debug) {error_log('Loading $objExercise from session'); };
-
- $objExercise = $_SESSION['objExercise'];
- }
- if (!is_object($objExercise)) {
- if ($debug) {error_log('$objExercise was not set, kill the script'); };
- header('Location: exercice.php');
- exit;
- }
- $exerciseType = $objExercise->type;
- $current_timestamp = time();
- $exercise_stat_info = $objExercise->get_stat_track_exercise_info($safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id);
- if ($debug) {error_log('$objExercise->get_stat_track_exercise_info function called:: '.print_r($exercise_stat_info, 1)); };
- $time_control = false;
- if ($objExercise->expired_time != 0 && $origin != 'learnpath') {
- $time_control = true;
- }
- if ($time_control) {
-
- $total_seconds = $objExercise->expired_time*60;
-
- $current_expired_time_key = generate_time_control_key($objExercise->id);
- if ($debug) {error_log('$current_expired_time_key '.$current_expired_time_key); };
- if (!isset($_SESSION['expired_time'][$current_expired_time_key])) {
-
- if (!empty($exercise_stat_info)) {
- if ($debug) {error_log('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('$expired_time_of_this_attempt: '.$expired_time_of_this_attempt); }
-
- $last_attempt_date = get_last_attempt_date_of_exercise($exercise_stat_info['exe_id']);
-
-
- 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 {
-
- $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('$last_attempt_date: '.$last_attempt_date); }
-
-
- $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date,'UTC');
- if ($debug) {error_log('$new_expired_time_in_seconds: '.$new_expired_time_in_seconds); }
-
- $expected_time = $current_timestamp + $new_expired_time_in_seconds;
- if ($debug) {error_log('$expected_time1: '.$expected_time); }
-
-
- $clock_expired_time = api_get_utc_datetime($expected_time);
- if ($debug) {error_log('$clock_expired_time: '.$clock_expired_time); }
-
-
-
-
-
-
- $sql_track_e_exe = "UPDATE $exercice_attemp_table SET tms = '".api_get_utc_datetime()."' WHERE exe_id = '".$exercise_stat_info['exe_id']."' AND tms = '".$last_attempt_date."' ";
- if ($debug) {error_log('$sql_track_e_exe2: '.$sql_track_e_exe); }
- Database::query($sql_track_e_exe);
-
-
- $_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
-
- if ($debug) {error_log('1. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
- } else {
- $expected_time = $current_timestamp + $total_seconds;
- if ($debug) error_log('$current_timestamp '.$current_timestamp);
- if ($debug) error_log('$expected_time '.$expected_time);
-
-
-
-
- $clock_expired_time = api_get_utc_datetime($expected_time);
- if ($debug) error_log('$expected_time '.$clock_expired_time);
-
- $_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
-
- if ($debug) {error_log('2. 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('Getting the $_SESSION[end_expired_time]: '.$_SESSION['end_expired_time'][$current_expired_time_key] ); };
- }
- }
- $time_left = api_strtotime($clock_expired_time,'UTC') - time();
- if ($time_control) {
- $htmlHeadXtra[] = $objExercise->show_time_control_js($time_left);
- }
- if ($_configuration['live_exercise_tracking'] && $objExercise->type == ONE_PER_PAGE && $objExercise->feedbacktype != EXERCISE_FEEDBACK_TYPE_DIRECT) {
- if (!empty($exercise_stat_info)) {
- $exe_id = $exercise_stat_info['exe_id'];
- if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- define('QUESTION_LIST_ALREADY_LOGGED', 1);
- $recorded['questionList'] = explode(',', $exercise_stat_info['data_tracking']);
- $query = 'SELECT * FROM ' . $exercice_attemp_table . ' WHERE exe_id = ' . $exercise_stat_info['exe_id'] . ' ORDER BY tms ASC';
- $result = Database::query($query);
- while ($row = Database :: fetch_array($result,'ASSOC')) {
- $recorded['exerciseResult'][$row['question_id']] = 1;
- }
- $exerciseResult = $_SESSION['exerciseResult'] = $recorded['exerciseResult'];
- $questionNum = count($recorded['exerciseResult']);
- $questionNum++;
- $questionList = $_SESSION['questionList'] = $recorded['questionList'];
- }
- }
- }
- if ($formSent && isset($_POST)) {
- if ($debug > 0) { error_log('$formSent was set'); }
-
- if (!is_array($exerciseResult)) {
- $exerciseResult = array ();
- $exerciseResultCoordinates = array();
- }
-
- if (!isset($choice) && isset($_REQUEST['hidden_hotspot_id'])) {
- $hotspot_id = (int)($_REQUEST['hidden_hotspot_id']);
- $choice = array($hotspot_id => '');
- }
-
- if (is_array($choice)) {
- if ($debug) { error_log('$choice is an array '.print_r($choice, 1)); }
-
-
- if (isset ($_POST['hotspot'])) {
- $exerciseResultCoordinates = $_POST['hotspot'];
- if ($debug) { error_log('$_POST[hotspot] data '.print_r($exerciseResultCoordinates, 1)); }
- }
- if ($exerciseType == ALL_ON_ONE_PAGE) {
-
-
- $exerciseResult = $choice;
- } else {
-
- list ($key) = array_keys($choice);
-
- if (!isset($exerciseResult[$key])) {
-
- $exerciseResult[$key] = $choice[$key];
-
- if ($_configuration['live_exercise_tracking'] && $objExercise->feedbacktype != EXERCISE_FEEDBACK_TYPE_DIRECT) {
- $nro_question = $questionNum;
-
- define('ENABLED_LIVE_EXERCISE_TRACKING', 1);
- $questionId = $key;
-
- $choice = $exerciseResult[$questionId];
- if (isset($exe_id)) {
-
- if ($debug > 0) { error_log('manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1)); }
- $objExercise->manage_answer($exe_id, $questionId, $choice,'exercise_show',$exerciseResultCoordinates, true, false,false);
- }
-
- }
- }
- }
- if ($debug > 0) { error_log('$choice is an array - end'); }
- }
-
- api_session_register('exerciseResult');
- api_session_register('exerciseResultCoordinates');
-
- if ($exerciseType == ALL_ON_ONE_PAGE || $questionNum >= $nbrQuestions) {
- if (api_is_allowed_to_session_edit()) {
-
- if ($exerciseType == ALL_ON_ONE_PAGE) {
- if ($debug) { error_log('Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php'); }
-
-
- if ($objExercise->selectAttempts() > 0) {
- $attempt_count = get_attempt_count(api_get_user_id(), $exerciseId, $safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id);
- if ($attempt_count >= $objExercise->selectAttempts()) {
- Display :: display_warning_message(sprintf(get_lang('ReachedMaxAttempts'), $exerciseTitle, $objExercise->selectAttempts()), false);
- if ($origin != 'learnpath') {
-
- echo '</div>';
- Display :: display_footer();
- } else {
- echo '</body></html>';
- }
- }
- }
- header("Location: exercise_result.php?exerciseType=$exerciseType&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 {
-
- if (!empty($exe_id) && is_numeric($exe_id)) {
-
- if (exercise_time_control_is_valid($exerciseId)) {
- $sql_exe_result = "";
- if ($debug) { error_log('exercise_time_control_is_valid is valid'); }
- } else {
- $sql_exe_result = ", exe_result = 0";
- if ($debug) { error_log('exercise_time_control_is_valid is NOT valid then exe_result = 0 '); }
- }
-
- $update_query = "UPDATE $stat_table SET status = '', exe_date = '".api_get_utc_datetime() ."' , orig_lp_item_view_id = '$safe_lp_item_view_id' $sql_exe_result WHERE exe_id = ".$exe_id;
-
- if ($debug) { error_log('Updating track_e_exercises '.$update_query); }
- Database::query($update_query);
- }
- if ($debug) { error_log('Redirecting to exercise_show.php'); }
- header("Location: exercise_show.php?id=$exe_id&exerciseType=$exerciseType&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 {
- if ($debug) { error_log('Redirecting to exercise_submit.php'); }
- header("Location: exercise_submit.php?exerciseId=$exerciseId");
- exit;
- }
- }
- if ($debug > 0) { error_log('$formSent was set - end'); }
- }
- $exerciseTitle = $objExercise->selectTitle();
- $exerciseDescription = $objExercise->selectDescription();
- $exerciseSound = $objExercise->selectSound();
- $exerciseType = $objExercise->selectType();
- if (!isset($_SESSION['questionList'])) {
-
- $questionList = ($objExercise->isRandom() ? $objExercise->selectRandomList() : $objExercise->selectQuestionList());
- api_session_register('questionList');
- if ($debug > 0) { error_log('$_SESSION[questionList] was set'); }
- }
- if (!isset ($objExercise) && isset ($_SESSION['objExercise'])) {
- $questionList = $_SESSION['questionList'];
- }
- $quizStartTime = time();
- api_session_register('quizStartTime');
- $nbrQuestions = count($questionList);
- if (!$questionNum || $_POST['questionNum']) {
-
- if (!$questionNum) {
- $questionNum = 1;
- } else {
- $questionNum++;
- }
- }
- if (!empty ($_GET['gradebook']) && $_GET['gradebook'] == 'view') {
- $_SESSION['gradebook'] = Security :: remove_XSS($_GET['gradebook']);
- $gradebook = $_SESSION['gradebook'];
- } elseif (empty ($_GET['gradebook'])) {
- unset ($_SESSION['gradebook']);
- $gradebook = '';
- }
- if (!empty ($gradebook) && $gradebook == 'view') {
- $interbreadcrumb[] = array ('url' => '../gradebook/' . Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('ToolGradebook'));
- }
- $interbreadcrumb[] = array ("url" => "exercice.php?gradebook=$gradebook", "name" => get_lang('Exercices'));
- $interbreadcrumb[] = array ("url" => "#","name" => $objExercise->name);
- if ($origin != 'learnpath') {
-
- Display :: display_header($nameTools,'Exercises');
- if (!api_is_allowed_to_session_edit() ) {
- Display :: display_warning_message(get_lang('SessionIsReadOnly'));
- }
- } else {
- Display::display_reduced_header();
- echo '<div style="height:10px"> </div>';
- }
- $show_quiz_edition = true;
- if (isset($exerciseId) && !empty($exerciseId)) {
- $TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM);
- $sql="SELECT max_score FROM $TBL_LP_ITEM WHERE item_type = '".TOOL_QUIZ."' AND path ='".$exerciseId."'";
- $result = Database::query($sql);
- if (Database::num_rows($result) > 0) {
- $show_quiz_edition = false;
- }
- }
- if (api_is_course_admin() && $origin != 'learnpath') {
- echo '<div class="actions">';
- echo '<a href="exercice.php?show=test&id_session='.api_get_session_id().'">' . Display :: return_icon('back.png', get_lang('BackToExercisesList'),'','32').'</a>';
- if ($show_quiz_edition) {
- echo '<a href="exercise_admin.php?' . api_get_cidreq() . '&modifyExercise=yes&exerciseId=' . $objExercise->id . '">'.Display :: return_icon('settings.png', get_lang('ModifyExercise'),'','32').'</a>';
-
- } else {
- echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'','32').'</a>';
- }
- echo '</div>';
- }
- $exerciseTitle = text_filter($objExercise->selectTitle());
- echo Display::tag('h2', $exerciseTitle);
- $show_clock = true;
- $user_id = api_get_user_id();
- if ($objExercise->selectAttempts() > 0) {
- $attempt_count = get_attempt_count($user_id, $exerciseId, $safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id);
-
- if ($attempt_count >= $objExercise->selectAttempts()) {
- $show_clock = false;
- if (!api_is_allowed_to_edit(null,true)) {
-
- if ($objExercise->results_disabled == 0 && $origin != 'learnpath') {
-
-
- $exercise_stat_info = get_all_exercise_results_by_user($user_id, $exerciseId, api_get_course_id(), api_get_session_id());
-
- if (!empty($exercise_stat_info)) {
- $max_exe_id = max(array_keys($exercise_stat_info));
- $last_attempt_info = $exercise_stat_info[$max_exe_id];
- echo Display::div(get_lang('Date').': '.api_get_local_time($last_attempt_info['exe_date']), array('id'=>''));
-
- Display :: display_warning_message(sprintf(get_lang('ReachedMaxAttempts'), $exerciseTitle, $objExercise->selectAttempts()), false);
-
- if (!empty($last_attempt_info['question_list'])) {
- foreach($last_attempt_info['question_list'] as $question_data) {
- $question_id = $question_data['question_id'];
- $marks = $question_data['marks'];
-
- $question_info = Question::read($question_id);
- echo Display::div($question_info->question, array('id'=>'question_title','class'=>'sectiontitle'));
- echo Display::div(get_lang('Score').' '.$marks, array('id'=>'question_score'));
- }
- }
- $score = show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']);
- echo Display::div(get_lang('YourTotalScore').' '.$score, array('id'=>'question_score'));
-
-
-
- } else {
- Display :: display_warning_message(sprintf(get_lang('ReachedMaxAttempts'), $exerciseTitle, $objExercise->selectAttempts()), false);
- }
- } else {
- Display :: display_warning_message(sprintf(get_lang('ReachedMaxAttempts'), $exerciseTitle, $objExercise->selectAttempts()), false);
- }
- if ($origin != 'learnpath')
- Display :: display_footer();
- exit;
- } else {
- Display :: display_warning_message(sprintf(get_lang('ReachedMaxAttemptsAdmin'), $exerciseTitle, $objExercise->selectAttempts()), false);
- }
- }
- }
- $limit_time_exists = (($objExercise->start_time != '0000-00-00 00:00:00') || ($objExercise->end_time != '0000-00-00 00:00:00')) ? true : false;
- if ($limit_time_exists) {
- $exercise_start_time = api_strtotime($objExercise->start_time,'UTC');
- $exercise_end_time = api_strtotime($objExercise->end_time,'UTC');
- $time_now = time();
-
- if ($objExercise->start_time != '0000-00-00 00:00:00') {
- $permission_to_start = (($time_now - $exercise_start_time) > 0) ? true : false;
- } else {
- $permission_to_start = true;
- }
- if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- if ($objExercise->end_time != '0000-00-00 00:00:00') {
- $exercise_timeover = (($time_now - $exercise_end_time) > 0) ? true : false;
- } else {
- $exercise_timeover = false;
- }
- }
-
- if (!$permission_to_start || $exercise_timeover) {
- if (!api_is_allowed_to_edit(null,true)) {
- $message_warning = $permission_to_start ? get_lang('ReachedTimeLimit') : get_lang('ExerciseNoStartedYet');
- Display :: display_warning_message(sprintf($message_warning, $exerciseTitle, $objExercise->selectAttempts()));
- if ($origin != 'learnpath') {
- Display :: display_footer();
- }
- exit;
- } else {
- $message_warning = $permission_to_start ? get_lang('ReachedTimeLimitAdmin') : get_lang('ExerciseNoStartedAdmin');
- Display :: display_warning_message(sprintf($message_warning, $exerciseTitle, $objExercise->selectAttempts()));
- exit;
- }
- }
- }
- if ($time_control) {
- echo '<div align="left" id="wrapper-clock"><div id="square" class="rounded"><div id="text-content" align="center" class="count_down"></div></div></div>';
- echo '<div style="display:none" class="warning-message" id="expired-message-id">'.get_lang('ExerciceExpiredTimeMessage').'</div>';
- }
- if ($origin != 'learnpath') {
- echo '<div id="highlight-plugin" class="glossary-content">';
- }
- if (!empty ($error)) {
- Display :: display_error_message($error, false);
- } else {
- if (!empty ($exerciseSound)) {
- echo "<a href=\"../document/download.php?doc_url=%2Faudio%2F" . Security::remove_XSS($exerciseSound) . "\" target=\"_blank\">", "<img src=\"../img/sound.gif\" border=\"0\" align=\"absmiddle\" alt=", get_lang('Sound') . "\" /></a>";
- }
-
- $number_of_hotspot_questions = 0;
- $onsubmit = '';
- $i = 0;
-
-
- if (!strcmp($questionList[0], '') === 0) {
- foreach ($questionList as $questionId) {
- $i++;
- $objQuestionTmp = Question::read($questionId);
-
- if ($exerciseType == ONE_PER_PAGE) {
-
- if ($questionNum != $i) {
- continue;
- } else {
- if ($objQuestionTmp->selectType() == HOT_SPOT || $objQuestionTmp->selectType() == HOT_SPOT_DELINEATION) {
- $number_of_hotspot_questions++;
- }
- break;
- }
- } else {
- if ($objQuestionTmp->selectType() == HOT_SPOT || $objQuestionTmp->selectType() == HOT_SPOT_DELINEATION) {
- $number_of_hotspot_questions++;
- }
- }
- }
- }
- if ($number_of_hotspot_questions > 0) {
- $onsubmit = "onsubmit=\"return validateFlashVar('" . $number_of_hotspot_questions . "', '" . get_lang('HotspotValidateError1') . "', '" . get_lang('HotspotValidateError2') . "');\"";
- }
- echo "<p>$exerciseDescription</p>";
- $exercise_condition = '';
- if ($exerciseType == ONE_PER_PAGE) {
- $exercise_condition = "&exerciseId=" . $exerciseId;
- }
- echo '<form id="exercise_form" method="post" action="'.api_get_self().'?'.api_get_cidreq().'&autocomplete=off&gradebook='.$gradebook.$exercise_condition .'" name="frm_exercise" '.$onsubmit.'>
- <input type="hidden" name="formSent" value="1" />
- <input type="hidden" name="exerciseType" value="' . $exerciseType . '" />
- <input type="hidden" name="exerciseId" value="' . $exerciseId . '" />
- <input type="hidden" name="questionNum" value="' . $questionNum . '" />
- <input type="hidden" name="nbrQuestions" value="' . $nbrQuestions . '" />
- <input type="hidden" name="origin" value="' . $origin . '" />
- <input type="hidden" name="learnpath_id" value="' . $learnpath_id . '" />
- <input type="hidden" name="learnpath_item_id" value="'. $learnpath_item_id . '" />
- <table id="question_list" width="100%" border="0" cellpadding="1" cellspacing="0">
- <tr>
- <td>
- <table width="100%" cellpadding="3" cellspacing="0" border="0">';
-
-
- $i = 1;
- foreach ($questionList as $questionId) {
-
-
- if ($exerciseType == ONE_PER_PAGE) {
-
- if ($questionNum != $i) {
- $i++;
- continue;
- } else {
- if ($objExercise->feedbacktype != EXERCISE_FEEDBACK_TYPE_DIRECT) {
-
- if (isset ($exerciseResult[$questionId])) {
-
- $objQuestionTmp = Question::read($questionId);
- $questionName = $objQuestionTmp->selectTitle();
-
- unset ($objQuestionTmp);
- Display :: display_normal_message(get_lang('AlreadyAnswered'));
- $i++;
- break;
- }
- }
- }
- }
-
- showQuestion($questionId, false, $origin, $i);
- $i++;
-
- if ($exerciseType == ONE_PER_PAGE) {
-
- break;
- }
- }
-
- echo $objExercise->show_button($nbrQuestions, $questionNum, $exerciseId);
- echo '</table>
- </td>
- </tr>
- </table></form>';
- }
- if ($objExercise->type == ONE_PER_PAGE) {
- if (empty($exercise_stat_info)) {
- $total_weight = 0;
- foreach($questionList as $question_id) {
- $objQuestionTmp = Question::read($question_id);
- $total_weight += floatval($objQuestionTmp->weighting);
- }
- $objExercise->save_stat_track_exercise_info($clock_expired_time, $safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id, $questionList, $total_weight);
- }
- }
- if ($origin != 'learnpath') {
-
- echo '</div>';
- Display :: display_footer();
- } else {
- echo '</body></html>';
- }
|