Skip to content

Commit

Permalink
Fix parameter exercise in question->save().
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed May 31, 2017
1 parent 3a07aff commit 203e45d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 24 deletions.
10 changes: 4 additions & 6 deletions main/exercise/Annotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,18 @@ public function createForm(&$form, $exercise)
}

/**
* @param FormValidator $form
* @param null $objExercise
* @return bool
* @inheritdoc
*/
public function processCreation($form, $objExercise = null)
public function processCreation($form, $exercise)
{
$fileInfo = $form->getSubmitValue('imageUpload');
parent::processCreation($form, $objExercise);
parent::processCreation($form, $exercise);

if (!empty($fileInfo['tmp_name'])) {
$result = $this->uploadPicture($fileInfo['tmp_name']);
if ($result) {
$this->weighting = $form->getSubmitValue('weighting');
$this->save();
$this->save($exercise);
return true;
}

Expand Down
5 changes: 2 additions & 3 deletions main/exercise/export/aiken/aiken_import.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ function aiken_import_exercise($file)
// 1. Create exercise
$exercise = new Exercise();
$exercise->exercise = $exercise_info['name'];

$exercise->save();
$last_exercise_id = $exercise->selectId();
if (!empty($last_exercise_id)) {
Expand All @@ -187,7 +186,7 @@ function aiken_import_exercise($file)
}
$type = $question->selectType();
$question->type = constant($type);
$question->save($last_exercise_id);
$question->save($exercise);
$last_question_id = $question->selectId();
//3. Create answer
$answer = new Answer($last_question_id);
Expand Down Expand Up @@ -217,7 +216,7 @@ function aiken_import_exercise($file)
$answer->save();
// Now that we know the question score, set it!
$question->updateWeighting($max_score);
$question->save();
$question->save($exercise);
}

// Delete the temp dir where the exercise was unzipped
Expand Down
4 changes: 2 additions & 2 deletions main/exercise/export/exercise_import.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ function import_exercise($file)
$description .= $question_array['description'];
}
$question->updateDescription($description);
$question->save($last_exercise_id);
$question->save($exercise);

$last_question_id = $question->selectId();
//3. Create answer
Expand Down Expand Up @@ -261,7 +261,7 @@ function import_exercise($file)
}
}
$question->updateWeighting($totalCorrectWeight);
$question->save($last_exercise_id);
$question->save($exercise);
$answer->save();
}

Expand Down
17 changes: 9 additions & 8 deletions main/exercise/hotspot.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,17 @@ public function createForm(&$form, $exercise)
}

/**
* @param FormValidator $form
* @param null $objExercise
* @return bool
* @inheritdoc
*/
public function processCreation($form, $objExercise = null)
public function processCreation($form, $exercise)
{
$file_info = $form->getSubmitValue('imageUpload');
parent::processCreation($form, $objExercise);
parent::processCreation($form, $exercise);

if (!empty($file_info['tmp_name'])) {
$result = $this->uploadPicture($file_info['tmp_name']);
if ($result) {
$this->save();
$this->save($exercise);
return true;
} else {
return false;
Expand Down Expand Up @@ -133,10 +131,13 @@ public function createForm(&$form, $exercise)
parent::createForm($form);
}

public function processCreation($form, $objExercise = null)
/**
* @inheritdoc
*/
public function processCreation($form, $exercise)
{
$file_info = $form->getSubmitValue('imageUpload');
parent::processCreation($form, $objExercise);
parent::processCreation($form, $exercise);
}

public function createAnswersForm($form)
Expand Down
5 changes: 2 additions & 3 deletions main/exercise/hotspot_admin.inc.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/* 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
Expand All @@ -24,7 +24,6 @@
$okPicture = empty($pictureName) ? false : true;

// if we come from the warning box "this question is used in several exercises"

if ($modifyIn) {
if ($debug > 0) {
echo '$modifyIn was set'."<br />\n";
Expand Down Expand Up @@ -143,7 +142,7 @@

// sets the total weighting of the question
$objQuestion->updateWeighting($questionWeighting);
$objQuestion->save($exerciseId);
$objQuestion->save($objExercise);

$editQuestion = $questionId;
unset($modifyAnswers);
Expand Down
3 changes: 1 addition & 2 deletions main/inc/lib/add_course.lib.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ public static function fill_db_course(
$question->weighting = 10;
$question->position = 1;
$question->course = $courseInfo;
$question->save($exercise_id);
$question->save($exercise);
$questionId = $question->id;

$answer = new Answer($questionId, $courseInfo['real_id']);
Expand All @@ -1028,7 +1028,6 @@ public static function fill_db_course(
$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('Contradiction'), 1, get_lang('NotFalse'), 5, 4);

$answer->save();

/* Forum tool */
Expand Down

0 comments on commit 203e45d

Please sign in to comment.