Skip to content

Commit

Permalink
Fix c_quiz_answer's correct field with id_auto
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Dec 21, 2015
1 parent ac29dcd commit 4c6d2e9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
42 changes: 42 additions & 0 deletions app/Migrations/Schema/V110/Version20151221150100.php
@@ -0,0 +1,42 @@
<?php
/* For licensing terms, see /license.txt */

namespace Application\Migrations\Schema\V110;

use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;

/**
* Fix c_quiz_answer's correct field for id_auto
*/
class Version20151221150100 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
$this->addSql("
UPDATE track_e_attempt a
INNER JOIN c_quiz_answer qa
ON (a.question_id = qa.question_id AND a.c_id = qa.c_id)
SET a.answer = qa.id_auto
WHERE a.answer = qa.id
");

$this->addSql("
UPDATE c_quiz_answer a
INNER JOIN c_quiz_answer b
ON (a.question_id = b.question_id AND a.c_id = b.c_id)
SET a.correct = b.id_auto
WHERE a.correct = b.id
");
}

/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
}
}
2 changes: 1 addition & 1 deletion main/inc/lib/exercise.lib.php
Expand Up @@ -141,7 +141,7 @@ public static function showQuestion(
$select_items[0]['letter'] = '--';
$select_items[0]['answer'] = '';
foreach ($answer_matching as $id => $value) {
$select_items[$i]['id'] = $value['id'];
$select_items[$i]['id'] = $value['id_auto'];
$select_items[$i]['letter'] = $cpt1[$id];
$select_items[$i]['answer'] = $value['answer'];
$i++;
Expand Down

0 comments on commit 4c6d2e9

Please sign in to comment.