Fix parameter exercise in question->save().

pull/2487/head
jmontoyaa 8 years ago
parent 3a07aff3dd
commit 203e45d074
  1. 10
      main/exercise/Annotation.php
  2. 5
      main/exercise/export/aiken/aiken_import.inc.php
  3. 4
      main/exercise/export/exercise_import.inc.php
  4. 17
      main/exercise/hotspot.class.php
  5. 5
      main/exercise/hotspot_admin.inc.php
  6. 3
      main/inc/lib/add_course.lib.inc.php

@ -83,20 +83,18 @@ class Annotation extends Question
} }
/** /**
* @param FormValidator $form * @inheritdoc
* @param null $objExercise
* @return bool
*/ */
public function processCreation($form, $objExercise = null) public function processCreation($form, $exercise)
{ {
$fileInfo = $form->getSubmitValue('imageUpload'); $fileInfo = $form->getSubmitValue('imageUpload');
parent::processCreation($form, $objExercise); parent::processCreation($form, $exercise);
if (!empty($fileInfo['tmp_name'])) { if (!empty($fileInfo['tmp_name'])) {
$result = $this->uploadPicture($fileInfo['tmp_name']); $result = $this->uploadPicture($fileInfo['tmp_name']);
if ($result) { if ($result) {
$this->weighting = $form->getSubmitValue('weighting'); $this->weighting = $form->getSubmitValue('weighting');
$this->save(); $this->save($exercise);
return true; return true;
} }

@ -170,7 +170,6 @@ function aiken_import_exercise($file)
// 1. Create exercise // 1. Create exercise
$exercise = new Exercise(); $exercise = new Exercise();
$exercise->exercise = $exercise_info['name']; $exercise->exercise = $exercise_info['name'];
$exercise->save(); $exercise->save();
$last_exercise_id = $exercise->selectId(); $last_exercise_id = $exercise->selectId();
if (!empty($last_exercise_id)) { if (!empty($last_exercise_id)) {
@ -187,7 +186,7 @@ function aiken_import_exercise($file)
} }
$type = $question->selectType(); $type = $question->selectType();
$question->type = constant($type); $question->type = constant($type);
$question->save($last_exercise_id); $question->save($exercise);
$last_question_id = $question->selectId(); $last_question_id = $question->selectId();
//3. Create answer //3. Create answer
$answer = new Answer($last_question_id); $answer = new Answer($last_question_id);
@ -217,7 +216,7 @@ function aiken_import_exercise($file)
$answer->save(); $answer->save();
// Now that we know the question score, set it! // Now that we know the question score, set it!
$question->updateWeighting($max_score); $question->updateWeighting($max_score);
$question->save(); $question->save($exercise);
} }
// Delete the temp dir where the exercise was unzipped // Delete the temp dir where the exercise was unzipped

@ -223,7 +223,7 @@ function import_exercise($file)
$description .= $question_array['description']; $description .= $question_array['description'];
} }
$question->updateDescription($description); $question->updateDescription($description);
$question->save($last_exercise_id); $question->save($exercise);
$last_question_id = $question->selectId(); $last_question_id = $question->selectId();
//3. Create answer //3. Create answer
@ -261,7 +261,7 @@ function import_exercise($file)
} }
} }
$question->updateWeighting($totalCorrectWeight); $question->updateWeighting($totalCorrectWeight);
$question->save($last_exercise_id); $question->save($exercise);
$answer->save(); $answer->save();
} }

@ -73,19 +73,17 @@ class HotSpot extends Question
} }
/** /**
* @param FormValidator $form * @inheritdoc
* @param null $objExercise
* @return bool
*/ */
public function processCreation($form, $objExercise = null) public function processCreation($form, $exercise)
{ {
$file_info = $form->getSubmitValue('imageUpload'); $file_info = $form->getSubmitValue('imageUpload');
parent::processCreation($form, $objExercise); parent::processCreation($form, $exercise);
if (!empty($file_info['tmp_name'])) { if (!empty($file_info['tmp_name'])) {
$result = $this->uploadPicture($file_info['tmp_name']); $result = $this->uploadPicture($file_info['tmp_name']);
if ($result) { if ($result) {
$this->save(); $this->save($exercise);
return true; return true;
} else { } else {
return false; return false;
@ -133,10 +131,13 @@ class HotSpotDelineation extends HotSpot
parent::createForm($form); parent::createForm($form);
} }
public function processCreation($form, $objExercise = null) /**
* @inheritdoc
*/
public function processCreation($form, $exercise)
{ {
$file_info = $form->getSubmitValue('imageUpload'); $file_info = $form->getSubmitValue('imageUpload');
parent::processCreation($form, $objExercise); parent::processCreation($form, $exercise);
} }
public function createAnswersForm($form) public function createAnswersForm($form)

@ -1,7 +1,7 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use \ChamiloSession as Session; use ChamiloSession as Session;
/** /**
* This script allows to manage answers. It is included from the * This script allows to manage answers. It is included from the
@ -24,7 +24,6 @@ $debug = 0; // debug variable to get where we are
$okPicture = empty($pictureName) ? false : true; $okPicture = empty($pictureName) ? false : true;
// if we come from the warning box "this question is used in several exercises" // if we come from the warning box "this question is used in several exercises"
if ($modifyIn) { if ($modifyIn) {
if ($debug > 0) { if ($debug > 0) {
echo '$modifyIn was set'."<br />\n"; echo '$modifyIn was set'."<br />\n";
@ -143,7 +142,7 @@ if ($submitAnswers || $buttonBack) {
// sets the total weighting of the question // sets the total weighting of the question
$objQuestion->updateWeighting($questionWeighting); $objQuestion->updateWeighting($questionWeighting);
$objQuestion->save($exerciseId); $objQuestion->save($objExercise);
$editQuestion = $questionId; $editQuestion = $questionId;
unset($modifyAnswers); unset($modifyAnswers);

@ -1019,7 +1019,7 @@ class AddCourse
$question->weighting = 10; $question->weighting = 10;
$question->position = 1; $question->position = 1;
$question->course = $courseInfo; $question->course = $courseInfo;
$question->save($exercise_id); $question->save($exercise);
$questionId = $question->id; $questionId = $question->id;
$answer = new Answer($questionId, $courseInfo['real_id']); $answer = new Answer($questionId, $courseInfo['real_id']);
@ -1028,7 +1028,6 @@ class AddCourse
$answer->createAnswer(get_lang('AdmitError'), 0, get_lang('NoSeduction'), -5, 2); $answer->createAnswer(get_lang('AdmitError'), 0, get_lang('NoSeduction'), -5, 2);
$answer->createAnswer(get_lang('Force'), 1, get_lang('Indeed'), 5, 3); $answer->createAnswer(get_lang('Force'), 1, get_lang('Indeed'), 5, 3);
$answer->createAnswer(get_lang('Contradiction'), 1, get_lang('NotFalse'), 5, 4); $answer->createAnswer(get_lang('Contradiction'), 1, get_lang('NotFalse'), 5, 4);
$answer->save(); $answer->save();
/* Forum tool */ /* Forum tool */

Loading…
Cancel
Save