Update entity annotations, add migrations, fix type hints

pull/3844/head
Julio Montoya 5 years ago
parent ad928ac05f
commit 28ad2fb96b
  1. 12
      src/CoreBundle/Entity/GradebookCertificate.php
  2. 59
      src/CoreBundle/Entity/GradebookEvaluation.php
  3. 12
      src/CoreBundle/Entity/ResourceLink.php
  4. 31
      src/CoreBundle/Migrations/Schema/V200/Version20170625153000.php
  5. 52
      src/CoreBundle/Migrations/Schema/V200/Version20170625154000.php
  6. 44
      src/CoreBundle/Migrations/Schema/V200/Version20180319145700.php
  7. 126
      src/CourseBundle/Entity/CNotebook.php
  8. 12
      src/CourseBundle/Entity/CStudentPublication.php
  9. 1
      src/CourseBundle/Entity/CSurveyGroup.php
  10. 161
      src/CourseBundle/Entity/CSurveyInvitation.php

@ -62,11 +62,6 @@ class GradebookCertificate
*/
protected ?DateTime $downloadedAt = null;
/**
* Set scoreCertificate.
*
* @return GradebookCertificate
*/
public function setScoreCertificate(float $scoreCertificate): self
{
$this->scoreCertificate = $scoreCertificate;
@ -84,12 +79,7 @@ class GradebookCertificate
return $this->scoreCertificate;
}
/**
* Set createdAt.
*
* @return GradebookCertificate
*/
public function setCreatedAt(DateTime $createdAt)
public function setCreatedAt(DateTime $createdAt): self
{
$this->createdAt = $createdAt;

@ -117,12 +117,7 @@ class GradebookEvaluation
$this->locked = 0;
}
/**
* Set name.
*
* @return GradebookEvaluation
*/
public function setName(string $name)
public function setName(string $name): self
{
$this->name = $name;
@ -156,12 +151,7 @@ class GradebookEvaluation
return $this->description;
}
/**
* Set createdAt.
*
* @return GradebookEvaluation
*/
public function setCreatedAt(DateTime $createdAt)
public function setCreatedAt(DateTime $createdAt): self
{
$this->createdAt = $createdAt;
@ -178,12 +168,7 @@ class GradebookEvaluation
return $this->createdAt;
}
/**
* Set weight.
*
* @return GradebookEvaluation
*/
public function setWeight(float $weight)
public function setWeight(float $weight): self
{
$this->weight = $weight;
@ -200,12 +185,7 @@ class GradebookEvaluation
return $this->weight;
}
/**
* Set max.
*
* @return GradebookEvaluation
*/
public function setMax(float $max)
public function setMax(float $max): self
{
$this->max = $max;
@ -222,12 +202,7 @@ class GradebookEvaluation
return $this->max;
}
/**
* Set visible.
*
* @return GradebookEvaluation
*/
public function setVisible(int $visible)
public function setVisible(int $visible): self
{
$this->visible = $visible;
@ -244,12 +219,7 @@ class GradebookEvaluation
return $this->visible;
}
/**
* Set type.
*
* @return GradebookEvaluation
*/
public function setType(string $type)
public function setType(string $type): self
{
$this->type = $type;
@ -266,12 +236,7 @@ class GradebookEvaluation
return $this->type;
}
/**
* Set locked.
*
* @return GradebookEvaluation
*/
public function setLocked(int $locked)
public function setLocked(int $locked): self
{
$this->locked = $locked;
@ -306,10 +271,7 @@ class GradebookEvaluation
return $this->bestScore;
}
/**
* @return GradebookEvaluation
*/
public function setBestScore(float $bestScore)
public function setBestScore(float $bestScore): self
{
$this->bestScore = $bestScore;
@ -324,10 +286,7 @@ class GradebookEvaluation
return $this->averageScore;
}
/**
* @return GradebookEvaluation
*/
public function setAverageScore(float $averageScore)
public function setAverageScore(float $averageScore): self
{
$this->averageScore = $averageScore;

@ -53,12 +53,6 @@ class ResourceLink
*/
protected ?Session $session = null;
/**
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
*/
protected ?User $user = null;
/**
* @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CGroup")
* @ORM\JoinColumn(name="group_id", referencedColumnName="iid", nullable=true, onDelete="CASCADE")
@ -71,6 +65,12 @@ class ResourceLink
*/
protected ?Usergroup $userGroup = null;
/**
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
*/
protected ?User $user = null;
/**
* @ORM\OneToMany(
* targetEntity="Chamilo\CoreBundle\Entity\ResourceRight",

@ -9,11 +9,13 @@ namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* c_forum.
*/
class Version20170625153000 extends AbstractMigrationChamilo
{
public function getDescription(): string
{
return 'Migrate c_forum tables';
}
public function up(Schema $schema): void
{
$table = $schema->getTable('c_forum_attachment');
@ -160,28 +162,5 @@ class Version20170625153000 extends AbstractMigrationChamilo
$this->addSql('UPDATE c_forum_post SET post_date = NOW() WHERE post_date = "" OR post_date is NULL OR post_date = 0');
$this->addSql('ALTER TABLE c_forum_post CHANGE post_date post_date DATETIME NOT NULL');
$table = $schema->getTable('c_course_description');
if (false === $table->hasColumn('resource_node_id')) {
$this->addSql('ALTER TABLE c_course_description ADD resource_node_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE c_course_description ADD CONSTRAINT FK_EC3CD8091BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE');
$this->addSql('CREATE UNIQUE INDEX UNIQ_EC3CD8091BAD783F ON c_course_description (resource_node_id)');
}
if ($table->hasIndex('session_id')) {
$this->addSql('DROP INDEX session_id ON c_course_description');
}
$table = $schema->getTable('c_notebook');
if ($table->hasIndex('course')) {
$this->addSql('DROP INDEX course ON c_notebook');
}
if (false === $table->hasColumn('resource_node_id')) {
$this->addSql('ALTER TABLE c_notebook ADD resource_node_id INT DEFAULT NULL, DROP notebook_id');
$this->addSql('ALTER TABLE c_notebook ADD CONSTRAINT FK_E7EE1CE01BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE');
$this->addSql('CREATE UNIQUE INDEX UNIQ_E7EE1CE01BAD783F ON c_notebook (resource_node_id)');
}
}
}

@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
class Version20170625154000 extends AbstractMigrationChamilo
{
public function getDescription(): string
{
return 'Migrate c_course_description, c_notebook tables';
}
public function up(Schema $schema): void
{
$table = $schema->getTable('c_course_description');
if (false === $table->hasColumn('resource_node_id')) {
$this->addSql('ALTER TABLE c_course_description ADD resource_node_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE c_course_description ADD CONSTRAINT FK_EC3CD8091BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE');
$this->addSql('CREATE UNIQUE INDEX UNIQ_EC3CD8091BAD783F ON c_course_description (resource_node_id)');
}
if ($table->hasIndex('session_id')) {
$this->addSql('DROP INDEX session_id ON c_course_description');
}
$table = $schema->getTable('c_notebook');
if ($table->hasIndex('course')) {
$this->addSql('DROP INDEX course ON c_notebook');
}
if (false === $table->hasColumn('resource_node_id')) {
$this->addSql('ALTER TABLE c_notebook ADD resource_node_id INT DEFAULT NULL, DROP notebook_id');
$this->addSql('ALTER TABLE c_notebook ADD CONSTRAINT FK_E7EE1CE01BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE');
$this->addSql('CREATE UNIQUE INDEX UNIQ_E7EE1CE01BAD783F ON c_notebook (resource_node_id)');
}
$this->addSql('ALTER TABLE c_notebook CHANGE user_id user_id INT DEFAULT NULL');
if (!$table->hasForeignKey('FK_E7EE1CE0A76ED395')) {
$this->addSql('ALTER TABLE c_notebook ADD CONSTRAINT FK_E7EE1CE0A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
}
if (!$table->hasIndex('IDX_E7EE1CE0A76ED395')) {
$this->addSql('CREATE INDEX IDX_E7EE1CE0A76ED395 ON c_notebook (user_id)');
}
}
}

@ -11,11 +11,13 @@ use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
/**
* Survey changes.
*/
class Version20180319145700 extends AbstractMigrationChamilo
{
public function getDescription(): string
{
return 'Migrate Survey tables';
}
public function up(Schema $schema): void
{
$survey = $schema->getTable('c_survey');
@ -85,13 +87,45 @@ class Version20180319145700 extends AbstractMigrationChamilo
);
$table = $schema->getTable('c_survey_invitation');
if (false === $table->hasColumn('answered_at')) {
if (!$table->hasColumn('answered_at')) {
$this->addSql('ALTER TABLE c_survey_invitation ADD answered_at DATETIME DEFAULT NULL;');
}
if (false === $table->hasIndex('idx_survey_inv_code')) {
if (!$table->hasIndex('idx_survey_inv_code')) {
$this->addSql('CREATE INDEX idx_survey_inv_code ON c_survey_invitation (survey_code)');
}
$this->addSql('ALTER TABLE c_survey_invitation CHANGE c_id c_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE c_survey_invitation CHANGE session_id session_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE c_survey_invitation CHANGE group_id group_id INT DEFAULT NULL');
if (!$table->hasForeignKey('FK_D0BC7C291D79BD3')) {
$this->addSql(
'ALTER TABLE c_survey_invitation ADD CONSTRAINT FK_D0BC7C291D79BD3 FOREIGN KEY (c_id) REFERENCES course (id) ON DELETE CASCADE'
);
}
if (!$table->hasForeignKey('FK_D0BC7C2613FECDF')) {
$this->addSql(
'ALTER TABLE c_survey_invitation ADD CONSTRAINT FK_D0BC7C2613FECDF FOREIGN KEY (session_id) REFERENCES session (id) ON DELETE CASCADE'
);
}
if (!$table->hasForeignKey('FK_D0BC7C2FE54D947')) {
$this->addSql(
'ALTER TABLE c_survey_invitation ADD CONSTRAINT FK_D0BC7C2FE54D947 FOREIGN KEY (group_id) REFERENCES c_group_info (iid) ON DELETE CASCADE'
);
}
if (!$table->hasIndex('IDX_D0BC7C2613FECDF')) {
$this->addSql('CREATE INDEX IDX_D0BC7C2613FECDF ON c_survey_invitation (session_id)');
}
if (!$table->hasIndex('IDX_D0BC7C2FE54D947')) {
$this->addSql('CREATE INDEX IDX_D0BC7C2FE54D947 ON c_survey_invitation (group_id)');
}
$table = $schema->getTable('c_survey_question');
if ($table->hasIndex('course')) {

@ -8,6 +8,7 @@ namespace Chamilo\CourseBundle\Entity;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\ResourceInterface;
use Chamilo\CoreBundle\Entity\User;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
@ -31,24 +32,10 @@ class CNotebook extends AbstractResource implements ResourceInterface
protected int $iid;
/**
* @ORM\Column(name="c_id", type="integer")
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")
*/
protected int $cId;
/**
* @ORM\Column(name="user_id", type="integer", nullable=false)
*/
protected int $userId;
/**
* @ORM\Column(name="course", type="string", length=40, nullable=false)
*/
protected string $course;
/**
* @ORM\Column(name="session_id", type="integer", nullable=false)
*/
protected int $sessionId;
protected User $user;
/**
* @Assert\NotBlank()
@ -91,72 +78,18 @@ class CNotebook extends AbstractResource implements ResourceInterface
return $this->getTitle();
}
/**
* Set userId.
*
* @return CNotebook
*/
public function setUserId(int $userId)
{
$this->userId = $userId;
return $this;
}
/**
* Get userId.
*
* @return int
*/
public function getUserId()
{
return $this->userId;
}
/**
* Set course.
*
* @return CNotebook
*/
public function setCourse(string $course)
{
$this->course = $course;
return $this;
}
/**
* Get course.
*
* @return string
*/
public function getCourse()
public function getUser(): User
{
return $this->course;
return $this->user;
}
/**
* Set sessionId.
*
* @return CNotebook
*/
public function setSessionId(int $sessionId)
public function setUser(User $user): self
{
$this->sessionId = $sessionId;
$this->user = $user;
return $this;
}
/**
* Get sessionId.
*
* @return int
*/
public function getSessionId()
{
return $this->sessionId;
}
public function setTitle(string $title): self
{
$this->title = $title;
@ -186,12 +119,7 @@ class CNotebook extends AbstractResource implements ResourceInterface
return $this->description;
}
/**
* Set creationDate.
*
* @return CNotebook
*/
public function setCreationDate(DateTime $creationDate)
public function setCreationDate(DateTime $creationDate): self
{
$this->creationDate = $creationDate;
@ -208,12 +136,7 @@ class CNotebook extends AbstractResource implements ResourceInterface
return $this->creationDate;
}
/**
* Set updateDate.
*
* @return CNotebook
*/
public function setUpdateDate(DateTime $updateDate)
public function setUpdateDate(DateTime $updateDate): self
{
$this->updateDate = $updateDate;
@ -230,12 +153,7 @@ class CNotebook extends AbstractResource implements ResourceInterface
return $this->updateDate;
}
/**
* Set status.
*
* @return CNotebook
*/
public function setStatus(int $status)
public function setStatus(int $status): self
{
$this->status = $status;
@ -252,28 +170,6 @@ class CNotebook extends AbstractResource implements ResourceInterface
return $this->status;
}
/**
* Set cId.
*
* @return CNotebook
*/
public function setCId(int $cId)
{
$this->cId = $cId;
return $this;
}
/**
* Get cId.
*
* @return int
*/
public function getCId()
{
return $this->cId;
}
/**
* Get iid.
*

@ -114,6 +114,12 @@ class CStudentPublication extends AbstractResource implements ResourceInterface
*/
protected ?CStudentPublication $publicationParent;
/**
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
protected User $user;
/**
* @ORM\OneToOne(targetEntity="Chamilo\CourseBundle\Entity\CStudentPublicationAssignment", mappedBy="publication")
*/
@ -129,12 +135,6 @@ class CStudentPublication extends AbstractResource implements ResourceInterface
*/
protected float $weight;
/**
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
protected User $user;
/**
* @ORM\Column(name="allow_text_assignment", type="integer", nullable=false)
*/

@ -11,6 +11,7 @@ use Doctrine\ORM\Mapping as ORM;
/**
* CSurveyGroup.
*
* @deprecated ?
* @ORM\Table(
* name="c_survey_group",
* indexes={

@ -7,6 +7,7 @@ declare(strict_types=1);
namespace Chamilo\CourseBundle\Entity;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Session;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
@ -32,14 +33,22 @@ class CSurveyInvitation
protected int $iid;
/**
* @ORM\Column(name="c_id", type="integer")
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course")
* @ORM\JoinColumn(name="c_id", referencedColumnName="id", nullable=true, onDelete="CASCADE")
*/
protected int $cId;
protected ?Course $course = null;
/**
* @ORM\Column(name="survey_invitation_id", type="integer")
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Session", inversedBy="resourceLinks")
* @ORM\JoinColumn(name="session_id", referencedColumnName="id", nullable=true, onDelete="CASCADE")
*/
protected int $surveyInvitationId;
protected ?Session $session = null;
/**
* @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CGroup")
* @ORM\JoinColumn(name="group_id", referencedColumnName="iid", nullable=true, onDelete="CASCADE")
*/
protected ?CGroup $group = null;
/**
* @ORM\Column(name="survey_code", type="string", length=20, nullable=false)
@ -56,42 +65,27 @@ class CSurveyInvitation
*/
protected string $invitationCode;
/**
* @ORM\Column(name="invitation_date", type="datetime", nullable=false)
*/
protected DateTime $invitationDate;
/**
* @ORM\Column(name="reminder_date", type="datetime", nullable=true)
*/
protected ?DateTime $reminderDate = null;
/**
* @ORM\Column(name="answered", type="integer", nullable=false)
*/
protected int $answered;
/**
* @ORM\Column(name="session_id", type="integer", nullable=false)
* @ORM\Column(name="invitation_date", type="datetime", nullable=false)
*/
protected int $sessionId;
protected DateTime $invitationDate;
/**
* @ORM\Column(name="group_id", type="integer", nullable=false)
* @ORM\Column(name="reminder_date", type="datetime", nullable=true)
*/
protected int $groupId;
protected ?DateTime $reminderDate = null;
/**
* @ORM\Column(name="answered_at", type="datetime", nullable=true)
*/
protected ?DateTime $answeredAt = null;
/**
* Set surveyCode.
*
* @return CSurveyInvitation
*/
public function setSurveyCode(string $surveyCode)
public function setSurveyCode(string $surveyCode): self
{
$this->surveyCode = $surveyCode;
@ -108,12 +102,7 @@ class CSurveyInvitation
return $this->surveyCode;
}
/**
* Set user.
*
* @return CSurveyInvitation
*/
public function setUser(string $user)
public function setUser(string $user): self
{
$this->user = $user;
@ -130,12 +119,7 @@ class CSurveyInvitation
return $this->user;
}
/**
* Set invitationCode.
*
* @return CSurveyInvitation
*/
public function setInvitationCode(string $invitationCode)
public function setInvitationCode(string $invitationCode): self
{
$this->invitationCode = $invitationCode;
@ -152,12 +136,7 @@ class CSurveyInvitation
return $this->invitationCode;
}
/**
* Set invitationDate.
*
* @return CSurveyInvitation
*/
public function setInvitationDate(DateTime $invitationDate)
public function setInvitationDate(DateTime $invitationDate): self
{
$this->invitationDate = $invitationDate;
@ -174,12 +153,7 @@ class CSurveyInvitation
return $this->invitationDate;
}
/**
* Set reminderDate.
*
* @return CSurveyInvitation
*/
public function setReminderDate(DateTime $reminderDate)
public function setReminderDate(DateTime $reminderDate): self
{
$this->reminderDate = $reminderDate;
@ -196,12 +170,7 @@ class CSurveyInvitation
return $this->reminderDate;
}
/**
* Set answered.
*
* @return CSurveyInvitation
*/
public function setAnswered(int $answered)
public function setAnswered(int $answered): self
{
$this->answered = $answered;
@ -218,102 +187,50 @@ class CSurveyInvitation
return $this->answered;
}
/**
* Set sessionId.
*
* @return CSurveyInvitation
*/
public function setSessionId(int $sessionId)
{
$this->sessionId = $sessionId;
return $this;
}
/**
* Get sessionId.
*
* @return int
*/
public function getSessionId()
public function getAnsweredAt(): DateTime
{
return $this->sessionId;
return $this->answeredAt;
}
/**
* Set groupId.
*
* @return CSurveyInvitation
*/
public function setGroupId(int $groupId)
public function setAnsweredAt(DateTime $answeredAt): self
{
$this->groupId = $groupId;
$this->answeredAt = $answeredAt;
return $this;
}
/**
* Get groupId.
*
* @return int
*/
public function getGroupId()
public function getCourse(): ?Course
{
return $this->groupId;
return $this->course;
}
/**
* Set surveyInvitationId.
*
* @return CSurveyInvitation
*/
public function setSurveyInvitationId(int $surveyInvitationId)
public function setCourse(?Course $course): self
{
$this->surveyInvitationId = $surveyInvitationId;
$this->course = $course;
return $this;
}
/**
* Get surveyInvitationId.
*
* @return int
*/
public function getSurveyInvitationId()
public function getSession(): ?Session
{
return $this->surveyInvitationId;
return $this->session;
}
/**
* Set cId.
*
* @return CSurveyInvitation
*/
public function setCId(int $cId)
public function setSession(?Session $session): self
{
$this->cId = $cId;
$this->session = $session;
return $this;
}
/**
* Get cId.
*
* @return int
*/
public function getCId()
public function getGroup(): ?CGroup
{
return $this->cId;
return $this->group;
}
public function getAnsweredAt(): DateTime
public function setGroup(?CGroup $group): self
{
return $this->answeredAt;
}
public function setAnsweredAt(DateTime $answeredAt): self
{
$this->answeredAt = $answeredAt;
$this->group = $group;
return $this;
}

Loading…
Cancel
Save