Przeglądaj źródła

Add migration for c_survey_question.is_required - refs BT#13203

Angel Fernando Quiroz Campos 7 lat temu
rodzic
commit
17118163c0

+ 47 - 0
src/CoreBundle/Migrations/Schema/V2_0_1/Version20170904173000.php

@@ -0,0 +1,47 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Migrations\Schema\V2_0_1;
+
+use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
+use Doctrine\DBAL\Schema\Schema;
+use Doctrine\DBAL\Types\Type;
+use Oro\Bundle\MigrationBundle\Migration\QueryBag;
+use Oro\Bundle\MigrationBundle\Migration\OrderedMigrationInterface;
+
+/**
+ * Class Version20170904173000
+ * @package Application\Migrations\Schema\V200
+ */
+class Version20170904173000 extends AbstractMigrationChamilo implements OrderedMigrationInterface
+{
+    /**
+    * {@inheritdoc}
+    */
+    public function getOrder()
+    {
+        return 3;
+    }
+
+    /**
+     * @param Schema $schema
+     * @param QueryBag $queries
+     */
+    public function up(Schema $schema, QueryBag $queries)
+    {
+        $tblQuestion = $schema->getTable('c_survey_question');
+
+        if (!$tblQuestion->hasColumn('is_required')) {
+            $tblQuestion
+                ->addColumn('is_required', Type::BOOLEAN)
+                ->setDefault(false);
+        }
+    }
+
+    /**
+     * @param \Doctrine\DBAL\Schema\Schema $schema
+     */
+    public function down(Schema $schema)
+    {
+    }
+}

+ 27 - 0
src/CourseBundle/Entity/CSurveyQuestion.php

@@ -118,6 +118,12 @@ class CSurveyQuestion
      */
     private $surveyGroupSec2;
 
+    /**
+     * @var bool
+     * @ORM\Column(name="is_required", type="boolean", options={"default": false})
+     */
+    private $isMandatory = false;
+
     /**
      * Set surveyId
      *
@@ -416,4 +422,25 @@ class CSurveyQuestion
     {
         return $this->cId;
     }
+
+    /**
+     * Set isMandatory
+     * @return bool
+     */
+    public function isMandatory(): bool
+    {
+        return $this->isMandatory;
+    }
+
+    /**
+     * Get isMandatory
+     * @param bool $isMandatory
+     * @return CSurveyQuestion
+     */
+    public function setIsMandatory(bool $isMandatory): CSurveyQuestion
+    {
+        $this->isMandatory = $isMandatory;
+
+        return $this;
+    }
 }