Fixing exercise preview when editing question order see #3483

skala
Julio Montoya 14 years ago
parent d7ee3eb2a5
commit fd22e76044
  1. 7
      main/exercice/admin.php
  2. 18
      main/exercice/exercice_submit.php
  3. 13
      main/inc/ajax/exercise.ajax.php

@ -163,13 +163,12 @@ if ($_GET['action'] == 'exportqti2' && !empty($_GET['questionId'])) {
// intializes the Exercise object
if (!is_object($objExercise)) {
// construction of the Exercise object
$objExercise=new Exercise();
$objExercise = new Exercise();
// creation of a new exercise if wrong or not specified exercise ID
if($exerciseId) {
if ($exerciseId) {
$objExercise->read($exerciseId);
}
// saves the object into the session
api_session_register('objExercise');
}
@ -431,7 +430,7 @@ if (isset($_GET['hotspotadmin']) || isset($_GET['newQuestion']) || isset($_GET['
if (!isset($_GET['hotspotadmin']) && !isset($_GET['newQuestion']) && !isset($_GET['myid']) && !isset($_GET['editQuestion'])) {
echo '<a href="exercice.php?'.api_get_cidReq().'">'.Display::return_icon('back.png', get_lang('BackToExercisesList'),'','32').'</a>';
}
echo '<a href="exercice_submit.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'.Display::return_icon('preview_view.png', get_lang('Preview'),'','32').'</a>';
echo '<a href="exercice_submit.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&preview=1">'.Display::return_icon('preview_view.png', get_lang('Preview'),'','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 {

@ -117,12 +117,19 @@ $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;
// Loading the $objExercise variable
//if (!isset($_SESSION['objExercise']) || $origin == 'learnpath' || $_SESSION['objExercise']->id != $_REQUEST['exerciseId']) {
/*
* 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');
}
// Loading the $objExercise variable
if (!isset ($_SESSION['objExercise']) || $_SESSION['objExercise']->id != $_REQUEST['exerciseId']) {
// Construction of Exercise
$objExercise = new Exercise();
$objExercise = new Exercise();
if ($debug) {error_log('Setting the $objExercise variable'); };
unset($_SESSION['questionList']);
@ -135,12 +142,13 @@ if (!isset ($_SESSION['objExercise']) || $_SESSION['objExercise']->id != $_REQUE
// saves the object into the session
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'];
$objExercise = $_SESSION['objExercise'];
}
if (!is_object($objExercise)) {

@ -4,11 +4,8 @@
* Responses to AJAX calls
*/
require_once '../../exercice/exercise.class.php';
require_once '../global.inc.php';
api_protect_course_script(true);
$action = $_REQUEST['a'];
switch ($action) {
@ -20,16 +17,6 @@ switch ($action) {
foreach ($new_question_list as $new_order_id) {
Database::update($TBL_QUESTIONS, array('question_order'=>$counter), array('question_id = ? '=>intval($new_order_id)));
$counter++;
}
//Updating question list array from DB
$objExercise = $_SESSION['objExercise'];
if (is_object($objExercise) && !empty($objExercise)) {
$fresh_question_list = $objExercise->selectQuestionList(true);
if (!empty($fresh_question_list)) {
$objExercise->questionList = $fresh_question_list;
api_session_register('objExercise');
}
}
Display::display_confirmation_message(get_lang('Saved'));
}

Loading…
Cancel
Save