Create save_correct_answers column on c_quiz table - refs BT#11024

ofaj
Angel Fernando Quiroz Campos 9 years ago
parent 84b34f3df0
commit 879d991f15
  1. 34
      app/Migrations/Schema/V111/Version20160418093800.php
  2. 31
      main/exercice/exercise.class.php
  3. 25
      src/Chamilo/CourseBundle/Entity/CQuiz.php

@ -0,0 +1,34 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version20160418093800
* Add save_correct_answers column to c_quiz table
* @package Application\Migrations\Schema\V111
*/
class Version20160418093800 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$cQuizTable = $schema->getTable('c_quiz');
$cQuizTable->addColumn('save_correct_answers', Type::BOOLEAN);
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
}
}

@ -35,6 +35,7 @@ class Exercise
public $course; public $course;
public $course_id; public $course_id;
public $propagate_neg; public $propagate_neg;
public $saveCorrectAnswers;
public $review_answers; public $review_answers;
public $randomByCat; public $randomByCat;
public $text_when_finished; public $text_when_finished;
@ -91,6 +92,7 @@ class Exercise
$this->results_disabled = 1; $this->results_disabled = 1;
$this->expired_time = '0000-00-00 00:00:00'; $this->expired_time = '0000-00-00 00:00:00';
$this->propagate_neg = 0; $this->propagate_neg = 0;
$this->saveCorrectAnswers = 0;
$this->review_answers = false; $this->review_answers = false;
$this->randomByCat = 0; $this->randomByCat = 0;
$this->text_when_finished = ''; $this->text_when_finished = '';
@ -152,6 +154,7 @@ class Exercise
$this->attempts = $object->max_attempt; $this->attempts = $object->max_attempt;
$this->feedback_type = $object->feedback_type; $this->feedback_type = $object->feedback_type;
$this->propagate_neg = $object->propagate_neg; $this->propagate_neg = $object->propagate_neg;
$this->saveCorrectAnswers = $object->save_correct_answers;
$this->randomByCat = $object->random_by_category; $this->randomByCat = $object->random_by_category;
$this->text_when_finished = $object->text_when_finished; $this->text_when_finished = $object->text_when_finished;
$this->display_category_name = $object->display_category_name; $this->display_category_name = $object->display_category_name;
@ -1133,6 +1136,14 @@ class Exercise
return $this->propagate_neg; return $this->propagate_neg;
} }
/**
* @return int
*/
public function selectSaveCorrectAnswers()
{
return $this->saveCorrectAnswers;
}
/** /**
* Selects questions randomly in the question list * Selects questions randomly in the question list
* *
@ -1275,6 +1286,14 @@ class Exercise
$this->propagate_neg = $value; $this->propagate_neg = $value;
} }
/**
* @param $value int
*/
public function updateSaveCorrectAnswers($value)
{
$this->saveCorrectAnswers = $value;
}
/** /**
* @param $value * @param $value
*/ */
@ -1523,6 +1542,7 @@ class Exercise
$random_answers = $this->random_answers; $random_answers = $this->random_answers;
$active = $this->active; $active = $this->active;
$propagate_neg = $this->propagate_neg; $propagate_neg = $this->propagate_neg;
$saveCorrectAnswers = isset($this->saveCorrectAnswers) && $this->saveCorrectAnswers ? true : false;
$review_answers = isset($this->review_answers) && $this->review_answers ? 1 : 0; $review_answers = isset($this->review_answers) && $this->review_answers ? 1 : 0;
$randomByCat = intval($this->randomByCat); $randomByCat = intval($this->randomByCat);
$text_when_finished = $this->text_when_finished; $text_when_finished = $this->text_when_finished;
@ -1573,6 +1593,7 @@ class Exercise
'max_attempt' => $attempts, 'max_attempt' => $attempts,
'expired_time' => $expired_time, 'expired_time' => $expired_time,
'propagate_neg' => $propagate_neg, 'propagate_neg' => $propagate_neg,
'save_correct_answers' => $saveCorrectAnswers,
'review_answers' => $review_answers, 'review_answers' => $review_answers,
'random_by_category' => $randomByCat, 'random_by_category' => $randomByCat,
'text_when_finished' => $text_when_finished, 'text_when_finished' => $text_when_finished,
@ -1643,7 +1664,8 @@ class Exercise
'random_by_category' => $randomByCat, 'random_by_category' => $randomByCat,
'text_when_finished' => $text_when_finished, 'text_when_finished' => $text_when_finished,
'display_category_name' => $display_category_name, '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); $this->id = Database::insert($TBL_EXERCISES, $params);
@ -2154,6 +2176,11 @@ class Exercise
//$check_option=$this->selectType(); //$check_option=$this->selectType();
$diplay = 'block'; $diplay = 'block';
$form->addElement('checkbox', 'propagate_neg', null, get_lang('PropagateNegativeResults')); $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','<div class="clear">&nbsp;</div>'); $form->addElement('html','<div class="clear">&nbsp;</div>');
$form->addElement('checkbox', 'review_answers', null, get_lang('ReviewAnswers')); $form->addElement('checkbox', 'review_answers', null, get_lang('ReviewAnswers'));
@ -2275,6 +2302,7 @@ class Exercise
$defaults['exerciseFeedbackType'] = $this->selectFeedbackType(); $defaults['exerciseFeedbackType'] = $this->selectFeedbackType();
$defaults['results_disabled'] = $this->selectResultsDisabled(); $defaults['results_disabled'] = $this->selectResultsDisabled();
$defaults['propagate_neg'] = $this->selectPropagateNeg(); $defaults['propagate_neg'] = $this->selectPropagateNeg();
$defaults['save_correct_answers'] = $this->selectSaveCorrectAnswers();
$defaults['review_answers'] = $this->review_answers; $defaults['review_answers'] = $this->review_answers;
$defaults['randomByCat'] = $this->selectRandomByCat(); $defaults['randomByCat'] = $this->selectRandomByCat();
$defaults['text_when_finished'] = $this->selectTextWhenFinished(); $defaults['text_when_finished'] = $this->selectTextWhenFinished();
@ -2366,6 +2394,7 @@ class Exercise
$this->updateResultsDisabled($form->getSubmitValue('results_disabled')); $this->updateResultsDisabled($form->getSubmitValue('results_disabled'));
$this->updateExpiredTime($form->getSubmitValue('enabletimercontroltotalminutes')); $this->updateExpiredTime($form->getSubmitValue('enabletimercontroltotalminutes'));
$this->updatePropagateNegative($form->getSubmitValue('propagate_neg')); $this->updatePropagateNegative($form->getSubmitValue('propagate_neg'));
$this->updateSaveCorrectAnswers($form->getSubmitValue('save_correct_answers'));
$this->updateRandomByCat($form->getSubmitValue('randomByCat')); $this->updateRandomByCat($form->getSubmitValue('randomByCat'));
$this->updateTextWhenFinished($form->getSubmitValue('text_when_finished')); $this->updateTextWhenFinished($form->getSubmitValue('text_when_finished'));
$this->updateDisplayCategoryName($form->getSubmitValue('display_category_name')); $this->updateDisplayCategoryName($form->getSubmitValue('display_category_name'));

@ -154,6 +154,12 @@ class CQuiz
*/ */
private $propagateNeg; private $propagateNeg;
/**
* @var boolean
* @ORm\Column(name="save_correct_answers", type="boolean", nullable=false)
*/
private $saveCorrectAnswers;
/** /**
* @var integer * @var integer
* *
@ -564,6 +570,25 @@ class CQuiz
return $this->propagateNeg; 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 * Set reviewAnswers
* *

Loading…
Cancel
Save