Skip to content

Commit

Permalink
Minor - fix php warning + fix error if $objExercise is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Jun 8, 2020
1 parent a609850 commit bbad3eb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
10 changes: 7 additions & 3 deletions main/exercise/admin.php
Expand Up @@ -139,11 +139,9 @@

// 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;
Expand All @@ -154,6 +152,12 @@
// 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);
Expand Down
4 changes: 4 additions & 0 deletions main/exercise/question.class.php
Expand Up @@ -1827,6 +1827,10 @@ abstract public function processAnswersCreation($form, $exercise);
*/
public static function displayTypeMenu($objExercise)
{
if (empty($objExercise)) {
return '';
}

$feedbackType = $objExercise->getFeedbackType();
$exerciseId = $objExercise->id;

Expand Down
25 changes: 19 additions & 6 deletions main/exercise/unique_answer.class.php
@@ -1,4 +1,5 @@
<?php

/* For licensing terms, see /license.txt */

use Chamilo\CourseBundle\Entity\CQuizAnswer;
Expand Down Expand Up @@ -343,13 +344,25 @@ public function processAnswersCreation($form, $exercise)
$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
Expand Down

0 comments on commit bbad3eb

Please sign in to comment.