Update entities, fix relations, add migrations

pull/3844/head
Julio Montoya 4 years ago
parent 3b9d17ef0a
commit ace28cba12
  1. 4
      src/CoreBundle/Entity/Course.php
  2. 2
      src/CoreBundle/Entity/GradebookCategory.php
  3. 4
      src/CoreBundle/Entity/Session.php
  4. 2
      src/CoreBundle/Entity/SettingsCurrent.php
  5. 14
      src/CoreBundle/Entity/TrackEOnline.php
  6. 50
      src/CoreBundle/Entity/UserRelUser.php
  7. 9
      src/CoreBundle/Migrations/Schema/V200/Version20170626122900.php
  8. 13
      src/CoreBundle/Migrations/Schema/V200/Version20170904145500.php
  9. 16
      src/CourseBundle/Entity/CForumForum.php
  10. 4
      src/CourseBundle/Entity/CForumThread.php
  11. 2
      src/CourseBundle/Entity/CGroup.php
  12. 69
      src/CourseBundle/Entity/CQuiz.php
  13. 15
      src/CourseBundle/Entity/CQuizAnswer.php
  14. 33
      src/CourseBundle/Entity/CQuizQuestion.php
  15. 77
      src/CourseBundle/Entity/CQuizQuestionOption.php
  16. 7
      src/CourseBundle/Entity/CQuizRelQuestion.php

@ -961,7 +961,7 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
*/ */
public function setSubscribe(bool $subscribe) public function setSubscribe(bool $subscribe)
{ {
$this->subscribe = (bool) $subscribe; $this->subscribe = $subscribe;
return $this; return $this;
} }
@ -983,7 +983,7 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
*/ */
public function setUnsubscribe(bool $unsubscribe) public function setUnsubscribe(bool $unsubscribe)
{ {
$this->unsubscribe = (bool) $unsubscribe; $this->unsubscribe = $unsubscribe;
return $this; return $this;
} }

@ -194,7 +194,7 @@ class GradebookCategory
public function setWeight(float $weight): self public function setWeight(float $weight): self
{ {
$this->weight = (float) $weight; $this->weight = $weight;
return $this; return $this;
} }

@ -345,7 +345,7 @@ class Session
} }
/** /**
* @return ArrayCollection * @return Collection
*/ */
public function getUsers() public function getUsers()
{ {
@ -407,7 +407,7 @@ class Session
} }
/** /**
* @return ArrayCollection * @return Collection
*/ */
public function getCourses() public function getCourses()
{ {

@ -307,7 +307,7 @@ class SettingsCurrent
public function setAccessUrlLocked(int $accessUrlLocked): self public function setAccessUrlLocked(int $accessUrlLocked): self
{ {
$this->accessUrlLocked = (int) $accessUrlLocked; $this->accessUrlLocked = $accessUrlLocked;
return $this; return $this;
} }

@ -24,6 +24,13 @@ use Doctrine\ORM\Mapping as ORM;
*/ */
class TrackEOnline class TrackEOnline
{ {
/**
* @ORM\Column(name="login_id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected int $loginId;
/** /**
* @ORM\Column(name="login_user_id", type="integer", nullable=false) * @ORM\Column(name="login_user_id", type="integer", nullable=false)
*/ */
@ -54,13 +61,6 @@ class TrackEOnline
*/ */
protected int $accessUrlId; protected int $accessUrlId;
/**
* @ORM\Column(name="login_id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected int $loginId;
/** /**
* Set loginUserId. * Set loginUserId.
* *

@ -38,9 +38,10 @@ class UserRelUser
protected User $user; protected User $user;
/** /**
* @ORM\Column(name="friend_user_id", type="integer", nullable=false) * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User")
* @ORM\JoinColumn(name="friend_user_id", referencedColumnName="id", onDelete="CASCADE")
*/ */
protected int $friendUserId; protected User $friend;
/** /**
* @ORM\Column(name="relation_type", type="integer", nullable=false) * @ORM\Column(name="relation_type", type="integer", nullable=false)
@ -52,34 +53,32 @@ class UserRelUser
*/ */
protected ?DateTime $lastEdit = null; protected ?DateTime $lastEdit = null;
/** public function getUser(): User
* Set friendUserId. {
* return $this->user;
* @return UserRelUser }
*/
public function setFriendUserId(int $friendUserId) public function setUser(User $user): self
{ {
$this->friendUserId = $friendUserId; $this->user = $user;
return $this; return $this;
} }
/** public function getFriend(): User
* Get friendUserId.
*
* @return int
*/
public function getFriendUserId()
{ {
return $this->friendUserId; return $this->friend;
} }
/** public function setFriend(User $friend): self
* Set relationType. {
* $this->friend = $friend;
* @return UserRelUser
*/ return $this;
public function setRelationType(int $relationType) }
public function setRelationType(int $relationType): self
{ {
$this->relationType = $relationType; $this->relationType = $relationType;
@ -96,12 +95,7 @@ class UserRelUser
return $this->relationType; return $this->relationType;
} }
/** public function setLastEdit(DateTime $lastEdit): self
* Set lastEdit.
*
* @return UserRelUser
*/
public function setLastEdit(DateTime $lastEdit)
{ {
$this->lastEdit = $lastEdit; $this->lastEdit = $lastEdit;

@ -149,7 +149,16 @@ class Version20170626122900 extends AbstractMigrationChamilo
} }
$table = $schema->getTable('user_rel_user'); $table = $schema->getTable('user_rel_user');
$this->addSql('DELETE FROM user_rel_user WHERE user_id = 0 OR friend_user_id = 0');
$this->addSql('ALTER TABLE user_rel_user CHANGE user_id user_id INT DEFAULT NULL'); $this->addSql('ALTER TABLE user_rel_user CHANGE user_id user_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE user_rel_user CHANGE friend_user_id friend_user_id INT DEFAULT NULL');
if (false === $table->hasForeignKey('FK_DBF650A893D1119E')) {
$this->addSql(
' ALTER TABLE user_rel_user ADD CONSTRAINT FK_DBF650A893D1119E FOREIGN KEY (friend_user_id) REFERENCES user (id) ON DELETE CASCADE;'
);
}
if (false === $table->hasForeignKey('FK_DBF650A8A76ED395')) { if (false === $table->hasForeignKey('FK_DBF650A8A76ED395')) {
$this->addSql( $this->addSql(

@ -54,6 +54,14 @@ class Version20170904145500 extends AbstractMigrationChamilo
$this->addSql('CREATE INDEX IDX_B7A1C35FB48D66 ON c_quiz (exercise_category_id);'); $this->addSql('CREATE INDEX IDX_B7A1C35FB48D66 ON c_quiz (exercise_category_id);');
} }
if ($table->hasIndex('course')) {
$this->addSql('DROP INDEX course ON c_quiz');
}
if ($table->hasIndex('session')) {
$this->addSql('DROP INDEX session ON c_quiz');
}
if (false === $table->hasColumn('show_previous_button')) { if (false === $table->hasColumn('show_previous_button')) {
$this->addSql( $this->addSql(
'ALTER TABLE c_quiz ADD COLUMN show_previous_button TINYINT(1) DEFAULT 1 NOT NULL' 'ALTER TABLE c_quiz ADD COLUMN show_previous_button TINYINT(1) DEFAULT 1 NOT NULL'
@ -176,6 +184,11 @@ class Version20170904145500 extends AbstractMigrationChamilo
$this->addSql('ALTER TABLE c_quiz_question_option DROP id'); $this->addSql('ALTER TABLE c_quiz_question_option DROP id');
} }
if (!$table->hasForeignKey('FK_499A73F31E27F6BF')) {
$this->addSql('ALTER TABLE c_quiz_question_option ADD CONSTRAINT FK_499A73F31E27F6BF FOREIGN KEY (question_id) REFERENCES c_quiz_question (iid) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_499A73F31E27F6BF ON c_quiz_question_option (question_id);');
}
$table = $schema->getTable('c_quiz_rel_question'); $table = $schema->getTable('c_quiz_rel_question');
$this->addSql('UPDATE c_quiz_rel_category SET count_questions = 0 WHERE count_questions IS NULL'); $this->addSql('UPDATE c_quiz_rel_category SET count_questions = 0 WHERE count_questions IS NULL');

@ -65,7 +65,7 @@ class CForumForum extends AbstractResource implements ResourceInterface
* @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CForumPost") * @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CForumPost")
* @ORM\JoinColumn(name="forum_last_post", referencedColumnName="iid") * @ORM\JoinColumn(name="forum_last_post", referencedColumnName="iid")
*/ */
protected CForumPost $forumLastPost; protected ?CForumPost $forumLastPost = null;
/** /**
* @Gedmo\SortableGroup * @Gedmo\SortableGroup
@ -531,12 +531,7 @@ class CForumForum extends AbstractResource implements ResourceInterface
return $this->forumImage; return $this->forumImage;
} }
/** public function setStartTime(?DateTime $startTime): self
* Set startTime.
*
* @return CForumForum
*/
public function setStartTime(DateTime $startTime)
{ {
$this->startTime = $startTime; $this->startTime = $startTime;
@ -553,12 +548,7 @@ class CForumForum extends AbstractResource implements ResourceInterface
return $this->startTime; return $this->startTime;
} }
/** public function setEndTime(?DateTime $endTime): self
* Set endTime.
*
* @return CForumForum
*/
public function setEndTime(DateTime $endTime)
{ {
$this->endTime = $endTime; $this->endTime = $endTime;

@ -303,7 +303,7 @@ class CForumThread extends AbstractResource implements ResourceInterface
public function setThreadQualifyMax(float $threadQualifyMax): self public function setThreadQualifyMax(float $threadQualifyMax): self
{ {
$this->threadQualifyMax = (float) $threadQualifyMax; $this->threadQualifyMax = $threadQualifyMax;
return $this; return $this;
} }
@ -342,7 +342,7 @@ class CForumThread extends AbstractResource implements ResourceInterface
*/ */
public function setThreadWeight(float $threadWeight): self public function setThreadWeight(float $threadWeight): self
{ {
$this->threadWeight = (float) $threadWeight; $this->threadWeight = $threadWeight;
return $this; return $this;
} }

@ -448,7 +448,7 @@ class CGroup extends AbstractResource implements ResourceInterface
return $relation->count() > 0; return $relation->count() > 0;
} }
public function getCategory(): CGroupCategory public function getCategory(): ?CGroupCategory
{ {
return $this->category; return $this->category;
} }

@ -23,8 +23,6 @@ use Symfony\Component\Validator\Constraints as Assert;
* @ORM\Table( * @ORM\Table(
* name="c_quiz", * name="c_quiz",
* indexes={ * indexes={
* @ORM\Index(name="course", columns={"c_id"}),
* @ORM\Index(name="session_id", columns={"session_id"})
* } * }
* ) * )
* @ORM\Entity * @ORM\Entity
@ -42,11 +40,6 @@ class CQuiz extends AbstractResource implements ResourceInterface
*/ */
protected int $iid; protected int $iid;
/**
* @ORM\Column(name="c_id", type="integer")
*/
protected int $cId;
/** /**
* @Assert\NotBlank() * @Assert\NotBlank()
* @ORM\Column(name="title", type="text", nullable=false) * @ORM\Column(name="title", type="text", nullable=false)
@ -118,11 +111,6 @@ class CQuiz extends AbstractResource implements ResourceInterface
*/ */
protected int $expiredTime; protected int $expiredTime;
/**
* @ORM\Column(name="session_id", type="integer", nullable=true)
*/
protected ?int $sessionId = null;
/** /**
* @ORM\Column(name="propagate_neg", type="integer", nullable=false) * @ORM\Column(name="propagate_neg", type="integer", nullable=false)
*/ */
@ -401,10 +389,8 @@ class CQuiz extends AbstractResource implements ResourceInterface
/** /**
* Set maxAttempt. * Set maxAttempt.
*
* @return CQuiz
*/ */
public function setMaxAttempt(int $maxAttempt) public function setMaxAttempt(int $maxAttempt): self
{ {
$this->maxAttempt = $maxAttempt; $this->maxAttempt = $maxAttempt;
@ -421,12 +407,7 @@ class CQuiz extends AbstractResource implements ResourceInterface
return $this->maxAttempt; return $this->maxAttempt;
} }
/** public function setStartTime(?DateTime $startTime) : self
* Set startTime.
*
* @return CQuiz
*/
public function setStartTime(DateTime $startTime)
{ {
$this->startTime = $startTime; $this->startTime = $startTime;
@ -448,7 +429,7 @@ class CQuiz extends AbstractResource implements ResourceInterface
* *
* @return CQuiz * @return CQuiz
*/ */
public function setEndTime(DateTime $endTime) public function setEndTime(?DateTime $endTime)
{ {
$this->endTime = $endTime; $this->endTime = $endTime;
@ -509,28 +490,6 @@ class CQuiz extends AbstractResource implements ResourceInterface
return $this->expiredTime; return $this->expiredTime;
} }
/**
* Set sessionId.
*
* @return CQuiz
*/
public function setSessionId(int $sessionId)
{
$this->sessionId = $sessionId;
return $this;
}
/**
* Get sessionId.
*
* @return int
*/
public function getSessionId()
{
return $this->sessionId;
}
/** /**
* Set propagateNeg. * Set propagateNeg.
* *
@ -681,28 +640,6 @@ class CQuiz extends AbstractResource implements ResourceInterface
return $this->passPercentage; return $this->passPercentage;
} }
/**
* Set cId.
*
* @return CQuiz
*/
public function setCId(int $cId)
{
$this->cId = $cId;
return $this;
}
/**
* Get cId.
*
* @return int
*/
public function getCId()
{
return $this->cId;
}
public function getExerciseCategory(): ?CExerciseCategory public function getExerciseCategory(): ?CExerciseCategory
{ {
return $this->exerciseCategory; return $this->exerciseCategory;

@ -130,17 +130,12 @@ class CQuizAnswer
return $this; return $this;
} }
/** public function getComment(): ?string
* Get comment.
*
* @return string
*/
public function getComment()
{ {
return $this->comment; return $this->comment;
} }
public function setPonderation(float $weight): self public function setPonderation($weight): self
{ {
$this->ponderation = empty($weight) ? 0.0 : (float) $weight; $this->ponderation = empty($weight) ? 0.0 : (float) $weight;
@ -174,7 +169,7 @@ class CQuizAnswer
return $this->position; return $this->position;
} }
public function setHotspotCoordinates(string $hotspotCoordinates): self public function setHotspotCoordinates(?string $hotspotCoordinates): self
{ {
$this->hotspotCoordinates = $hotspotCoordinates; $this->hotspotCoordinates = $hotspotCoordinates;
@ -191,7 +186,7 @@ class CQuizAnswer
return $this->hotspotCoordinates; return $this->hotspotCoordinates;
} }
public function setHotspotType(string $hotspotType): self public function setHotspotType(?string $hotspotType): self
{ {
$this->hotspotType = $hotspotType; $this->hotspotType = $hotspotType;
@ -208,7 +203,7 @@ class CQuizAnswer
return $this->hotspotType; return $this->hotspotType;
} }
public function setDestination(string $destination) public function setDestination(?string $destination)
{ {
$this->destination = empty($destination) ? null : $destination; $this->destination = empty($destination) ? null : $destination;

@ -114,6 +114,13 @@ class CQuizQuestion extends AbstractResource implements ResourceInterface
*/ */
protected Collection $answers; protected Collection $answers;
/**
* @var Collection|CQuizQuestionOption[]
*
* @ORM\OneToMany(targetEntity="CQuizQuestionOption", mappedBy="question", cascade={"persist"})
*/
protected Collection $options;
/** /**
* @ORM\Column(name="mandatory", type="integer") * @ORM\Column(name="mandatory", type="integer")
*/ */
@ -124,6 +131,7 @@ class CQuizQuestion extends AbstractResource implements ResourceInterface
$this->categories = new ArrayCollection(); $this->categories = new ArrayCollection();
$this->relQuizzes = new ArrayCollection(); $this->relQuizzes = new ArrayCollection();
$this->answers = new ArrayCollection(); $this->answers = new ArrayCollection();
$this->options = new ArrayCollection();
$this->ponderation = 0.0; $this->ponderation = 0.0;
$this->mandatory = 0; $this->mandatory = 0;
} }
@ -318,15 +326,12 @@ class CQuizQuestion extends AbstractResource implements ResourceInterface
return $this->questionCode; return $this->questionCode;
} }
/** public function getFeedback(): ?string
* @return string
*/
public function getFeedback()
{ {
return $this->feedback; return $this->feedback;
} }
public function setFeedback(string $feedback): self public function setFeedback(?string $feedback): self
{ {
$this->feedback = $feedback; $this->feedback = $feedback;
@ -362,6 +367,24 @@ class CQuizQuestion extends AbstractResource implements ResourceInterface
return $this->mandatory; return $this->mandatory;
} }
/**
* @return CQuizQuestionOption[]|Collection
*/
public function getOptions()
{
return $this->options;
}
/**
* @param CQuizQuestionOption[]|Collection $options
*/
public function setOptions(Collection $options): self
{
$this->options = $options;
return $this;
}
/** /**
* Get iid. * Get iid.
* *

@ -7,6 +7,7 @@ declare(strict_types=1);
namespace Chamilo\CourseBundle\Entity; namespace Chamilo\CourseBundle\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/** /**
* CQuizQuestionOption. * CQuizQuestionOption.
@ -14,7 +15,6 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Table( * @ORM\Table(
* name="c_quiz_question_option", * name="c_quiz_question_option",
* indexes={ * indexes={
* @ORM\Index(name="course", columns={"c_id"})
* } * }
* ) * )
* @ORM\Entity * @ORM\Entity
@ -28,16 +28,6 @@ class CQuizQuestionOption
*/ */
protected int $iid; protected int $iid;
/**
* @ORM\Column(name="c_id", type="integer")
*/
protected int $cId;
/**
* @ORM\Column(name="question_id", type="integer", nullable=false)
*/
protected int $questionId;
/** /**
* @ORM\Column(name="name", type="string", length=255, nullable=false) * @ORM\Column(name="name", type="string", length=255, nullable=false)
*/ */
@ -49,33 +39,13 @@ class CQuizQuestionOption
protected int $position; protected int $position;
/** /**
* Set questionId. * @Assert\NotBlank()
* * @ORM\ManyToOne(targetEntity="CQuizQuestion", cascade={"persist"}, inversedBy="options")
* @return CQuizQuestionOption * @ORM\JoinColumn(name="question_id", referencedColumnName="iid", onDelete="CASCADE")
*/ */
public function setQuestionId(int $questionId) protected CQuizQuestion $question;
{
$this->questionId = $questionId;
return $this;
}
/** public function setName(string $name): self
* Get questionId.
*
* @return int
*/
public function getQuestionId()
{
return $this->questionId;
}
/**
* Set name.
*
* @return CQuizQuestionOption
*/
public function setName(string $name)
{ {
$this->name = $name; $this->name = $name;
@ -92,12 +62,7 @@ class CQuizQuestionOption
return $this->name; return $this->name;
} }
/** public function setPosition(int $position): self
* Set position.
*
* @return CQuizQuestionOption
*/
public function setPosition(int $position)
{ {
$this->position = $position; $this->position = $position;
@ -114,33 +79,15 @@ class CQuizQuestionOption
return $this->position; return $this->position;
} }
/** public function getQuestion(): CQuizQuestion
* Set cId.
*
* @return CQuizQuestionOption
*/
public function setCId(int $cId)
{ {
$this->cId = $cId; return $this->question;
return $this;
} }
/** public function setQuestion(CQuizQuestion $question): self
* Get cId.
*
* @return int
*/
public function getCId()
{ {
return $this->cId; $this->question = $question;
}
/** return $this;
* @return int
*/
public function getIid()
{
return $this->iid;
} }
} }

@ -49,12 +49,7 @@ class CQuizRelQuestion
*/ */
protected CQuiz $quiz; protected CQuiz $quiz;
/** public function setQuestionOrder(int $questionOrder): self
* Set questionOrder.
*
* @return CQuizRelQuestion
*/
public function setQuestionOrder(int $questionOrder)
{ {
$this->questionOrder = $questionOrder; $this->questionOrder = $questionOrder;

Loading…
Cancel
Save