diff --git a/app/Migrations/Schema/V111/Version20160418093800.php b/app/Migrations/Schema/V111/Version20160418093800.php new file mode 100644 index 0000000000..b4d67bda7a --- /dev/null +++ b/app/Migrations/Schema/V111/Version20160418093800.php @@ -0,0 +1,34 @@ +getTable('c_quiz'); + $cQuizTable->addColumn('save_correct_answers', Type::BOOLEAN); + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + + } +} \ No newline at end of file diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index 6fe08df0b7..b5face4dea 100755 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -35,6 +35,7 @@ class Exercise public $course; public $course_id; public $propagate_neg; + public $saveCorrectAnswers; public $review_answers; public $randomByCat; public $text_when_finished; @@ -91,6 +92,7 @@ class Exercise $this->results_disabled = 1; $this->expired_time = '0000-00-00 00:00:00'; $this->propagate_neg = 0; + $this->saveCorrectAnswers = 0; $this->review_answers = false; $this->randomByCat = 0; $this->text_when_finished = ''; @@ -152,6 +154,7 @@ class Exercise $this->attempts = $object->max_attempt; $this->feedback_type = $object->feedback_type; $this->propagate_neg = $object->propagate_neg; + $this->saveCorrectAnswers = $object->save_correct_answers; $this->randomByCat = $object->random_by_category; $this->text_when_finished = $object->text_when_finished; $this->display_category_name = $object->display_category_name; @@ -1133,6 +1136,14 @@ class Exercise return $this->propagate_neg; } + /** + * @return int + */ + public function selectSaveCorrectAnswers() + { + return $this->saveCorrectAnswers; + } + /** * Selects questions randomly in the question list * @@ -1275,6 +1286,14 @@ class Exercise $this->propagate_neg = $value; } + /** + * @param $value int + */ + public function updateSaveCorrectAnswers($value) + { + $this->saveCorrectAnswers = $value; + } + /** * @param $value */ @@ -1523,6 +1542,7 @@ class Exercise $random_answers = $this->random_answers; $active = $this->active; $propagate_neg = $this->propagate_neg; + $saveCorrectAnswers = isset($this->saveCorrectAnswers) && $this->saveCorrectAnswers ? true : false; $review_answers = isset($this->review_answers) && $this->review_answers ? 1 : 0; $randomByCat = intval($this->randomByCat); $text_when_finished = $this->text_when_finished; @@ -1573,6 +1593,7 @@ class Exercise 'max_attempt' => $attempts, 'expired_time' => $expired_time, 'propagate_neg' => $propagate_neg, + 'save_correct_answers' => $saveCorrectAnswers, 'review_answers' => $review_answers, 'random_by_category' => $randomByCat, 'text_when_finished' => $text_when_finished, @@ -1643,7 +1664,8 @@ class Exercise 'random_by_category' => $randomByCat, 'text_when_finished' => $text_when_finished, 'display_category_name' => $display_category_name, - 'pass_percentage' => $pass_percentage + 'pass_percentage' => $pass_percentage, + 'save_correct_answers' => $saveCorrectAnswers ]; $this->id = Database::insert($TBL_EXERCISES, $params); @@ -2154,6 +2176,11 @@ class Exercise //$check_option=$this->selectType(); $diplay = 'block'; $form->addElement('checkbox', 'propagate_neg', null, get_lang('PropagateNegativeResults')); + $form->addCheckBox( + 'save_correct_answers', + null, + get_lang('Save the correct answers for the next attempt') + ); $form->addElement('html','
 
'); $form->addElement('checkbox', 'review_answers', null, get_lang('ReviewAnswers')); @@ -2275,6 +2302,7 @@ class Exercise $defaults['exerciseFeedbackType'] = $this->selectFeedbackType(); $defaults['results_disabled'] = $this->selectResultsDisabled(); $defaults['propagate_neg'] = $this->selectPropagateNeg(); + $defaults['save_correct_answers'] = $this->selectSaveCorrectAnswers(); $defaults['review_answers'] = $this->review_answers; $defaults['randomByCat'] = $this->selectRandomByCat(); $defaults['text_when_finished'] = $this->selectTextWhenFinished(); @@ -2366,6 +2394,7 @@ class Exercise $this->updateResultsDisabled($form->getSubmitValue('results_disabled')); $this->updateExpiredTime($form->getSubmitValue('enabletimercontroltotalminutes')); $this->updatePropagateNegative($form->getSubmitValue('propagate_neg')); + $this->updateSaveCorrectAnswers($form->getSubmitValue('save_correct_answers')); $this->updateRandomByCat($form->getSubmitValue('randomByCat')); $this->updateTextWhenFinished($form->getSubmitValue('text_when_finished')); $this->updateDisplayCategoryName($form->getSubmitValue('display_category_name')); diff --git a/src/Chamilo/CourseBundle/Entity/CQuiz.php b/src/Chamilo/CourseBundle/Entity/CQuiz.php index a1c510c544..ad4881674a 100644 --- a/src/Chamilo/CourseBundle/Entity/CQuiz.php +++ b/src/Chamilo/CourseBundle/Entity/CQuiz.php @@ -154,6 +154,12 @@ class CQuiz */ private $propagateNeg; + /** + * @var boolean + * @ORm\Column(name="save_correct_answers", type="boolean", nullable=false) + */ + private $saveCorrectAnswers; + /** * @var integer * @@ -564,6 +570,25 @@ class CQuiz return $this->propagateNeg; } + /** + * @param $saveCorrectAnswers boolean + * @return CQuiz + */ + public function setSaveCorrectAnswers($saveCorrectAnswers) + { + $this->saveCorrectAnswers = $saveCorrectAnswers; + + return $this; + } + + /** + * @return boolean + */ + public function getSaveCorrectAnswers() + { + return $this->saveCorrectAnswers; + } + /** * Set reviewAnswers *