diff --git a/main/exercise/admin.php b/main/exercise/admin.php index 86a5e2b89f..87a18b46a9 100755 --- a/main/exercise/admin.php +++ b/main/exercise/admin.php @@ -139,11 +139,9 @@ if (!empty($_GET['action']) && $_GET['action'] == 'exportqti2' && !empty($_GET[' // Exercise object creation. if (!is_object($objExercise)) { - // construction of the Exercise object - $objExercise = new Exercise(); - // creation of a new exercise if wrong or not specified exercise ID if ($exerciseId) { + $objExercise = new Exercise(); $parseQuestionList = $showPagination > 0 ? false : true; if ($editQuestion) { $parseQuestionList = false; @@ -154,6 +152,12 @@ if (!is_object($objExercise)) { // saves the object into the session Session::write('objExercise', $objExercise); } + +if (empty($objExercise)) { + header('Location: '.api_get_path(WEB_CODE_PATH).'exercise/exercise.php?'.api_get_cidreq()); + exit; +} + // Exercise can be edited in their course. if ($objExercise->sessionId != $sessionId) { api_not_allowed(true); diff --git a/main/exercise/question.class.php b/main/exercise/question.class.php index cb56f01101..942379e9ba 100755 --- a/main/exercise/question.class.php +++ b/main/exercise/question.class.php @@ -1827,6 +1827,10 @@ abstract class Question */ public static function displayTypeMenu($objExercise) { + if (empty($objExercise)) { + return ''; + } + $feedbackType = $objExercise->getFeedbackType(); $exerciseId = $objExercise->id; diff --git a/main/exercise/unique_answer.class.php b/main/exercise/unique_answer.class.php index a374e6cc49..f3557cecd0 100755 --- a/main/exercise/unique_answer.class.php +++ b/main/exercise/unique_answer.class.php @@ -1,4 +1,5 @@ getSubmitValue('weighting['.$i.']')); $scenario = $form->getSubmitValue('scenario'); - //$list_destination = $form -> getSubmitValue('destination'.$i); - //$destination_str = $form -> getSubmitValue('destination'.$i); + $try = null; + $lp = null; + $destination = null; + $url = null; + if (isset($scenario['try'.$i])) { + $try = !empty($scenario['try'.$i]); + } + + if (isset($scenario['lp'.$i])) { + $lp = $scenario['lp'.$i]; + } - $try = !empty($scenario['try'.$i]); - $lp = $scenario['lp'.$i]; - $destination = $scenario['destination'.$i]; - $url = trim($scenario['url'.$i]); + if (isset($scenario['destination'.$i])) { + $destination = $scenario['destination'.$i]; + } + + if (isset($scenario['url'.$i])) { + $url = trim($scenario['url'.$i]); + } /* How we are going to parse the destination value