Minor - fix php warning + fix error if $objExercise is empty

pull/3288/head
Julio Montoya 6 years ago
parent a609850cab
commit bbad3eb865
  1. 10
      main/exercise/admin.php
  2. 4
      main/exercise/question.class.php
  3. 25
      main/exercise/unique_answer.class.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);

@ -1827,6 +1827,10 @@ abstract class Question
*/
public static function displayTypeMenu($objExercise)
{
if (empty($objExercise)) {
return '';
}
$feedbackType = $objExercise->getFeedbackType();
$exerciseId = $objExercise->id;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CourseBundle\Entity\CQuizAnswer;
@ -343,13 +344,25 @@ class UniqueAnswer extends Question
$weighting = trim($form->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

Loading…
Cancel
Save