From e5c8ac4cb0ce53473032edfab60edb3610348c16 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 12 Sep 2011 19:00:04 +0200 Subject: [PATCH] Fixing exercise preview URL + fixing show_results condition --- main/exercice/admin.php | 2 +- main/exercice/exercise.class.php | 13 ++++++++----- main/exercice/exercise_result.php | 12 ++++++------ main/exercice/overview.php | 8 ++++++-- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/main/exercice/admin.php b/main/exercice/admin.php index 547c632fe5..ae382eac3f 100755 --- a/main/exercice/admin.php +++ b/main/exercice/admin.php @@ -455,7 +455,7 @@ if (isset($_GET['hotspotadmin']) || isset($_GET['newQuestion']) || isset($_GET[' if (!isset($_GET['hotspotadmin']) && !isset($_GET['newQuestion']) && !isset($_GET['myid']) && !isset($_GET['editQuestion'])) { echo ''.Display::return_icon('back.png', get_lang('BackToExercisesList'),'','32').''; } -echo ''.Display::return_icon('preview_view.png', get_lang('Preview'),'','32').''; +echo ''.Display::return_icon('preview_view.png', get_lang('Preview'),'','32').''; echo Display::url(Display::return_icon('test_results.png', get_lang('Results'),'','32'), 'exercice.php?'.api_get_cidReq().'&show=result&exerciseId='.$objExercise->id); diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index a615dd12a2..59b0e8b129 100755 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -1568,15 +1568,18 @@ class Exercise { $label = get_lang('NextQuestion'); $class = 'next'; } - if ($this->type == ONE_PER_PAGE) { - //Next question - $all_button .= ''.$label.''; - + if ($this->type == ONE_PER_PAGE) { + if ($questionNum != 1) { $prev_question = $questionNum - 2; - $all_button .= ' << '; + $all_button .= ''.get_lang('PreviousQuestion').''; } + //Next question + $all_button .= ''.$label.''; + + + //$all_button .= ' '; $all_button .= ' '; diff --git a/main/exercice/exercise_result.php b/main/exercice/exercise_result.php index 9a3f9d8894..64facae56a 100755 --- a/main/exercice/exercise_result.php +++ b/main/exercice/exercise_result.php @@ -40,7 +40,6 @@ require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php'; $this_section = SECTION_COURSES; /* ACCESS RIGHTS */ -// notice for unauthorized people. api_protect_course_script(true); // Database table definitions @@ -120,7 +119,6 @@ if (api_is_course_admin() && $origin != 'learnpath') { } $feedback_type = $objExercise->feedbacktype; - $exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id); if (!empty($exercise_stat_info['data_tracking'])) { @@ -164,7 +162,7 @@ if ($show_results || $show_only_score) { echo $exercise_header = $objExercise->show_exercise_result_header(api_get_person_name($user_info['firstName'], $user_info['lastName'])); } -Display :: display_confirmation_message(get_lang('Saved').'

',false); +Display :: display_confirmation_message(get_lang('Saved').'
',false); $counter = 1; // Loop over all question to show results for each of them, one by one @@ -187,9 +185,11 @@ if (!empty($question_list)) { // 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); - } + } + + // 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 diff --git a/main/exercice/overview.php b/main/exercice/overview.php index 1b4173892a..a50a3dc1e3 100644 --- a/main/exercice/overview.php +++ b/main/exercice/overview.php @@ -70,9 +70,13 @@ if ($is_allowed_to_edit ) { $html .= Display::tag('h1', $objExercise->name .' '.$edit_link); $html .= Display::div($objExercise->description, array('class'=>'exercise_description')); -//Buttons +$extra_params = ''; +if (isset($_GET['preview'])) { + $extra_params = '&preview=1'; +} + //Notice we not add there the lp_item_view__id because is not already generated -$exercise_url = api_get_path(WEB_CODE_PATH).'exercice/exercise_submit.php?'.api_get_cidreq().'&id_session='.api_get_session_id().'&exerciseId='.$objExercise->id.'&origin='.$origin.'&learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id; +$exercise_url = api_get_path(WEB_CODE_PATH).'exercice/exercise_submit.php?'.api_get_cidreq().'&id_session='.api_get_session_id().'&exerciseId='.$objExercise->id.'&origin='.$origin.'&learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.$extra_params; $label = get_lang('StartTest'); if ($time_control && !empty($clock_expired_time)) {