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

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

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

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

@ -24,6 +24,13 @@ use Doctrine\ORM\Mapping as ORM;
*/
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)
*/
@ -54,13 +61,6 @@ class TrackEOnline
*/
protected int $accessUrlId;
/**
* @ORM\Column(name="login_id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected int $loginId;
/**
* Set loginUserId.
*

@ -38,9 +38,10 @@ class UserRelUser
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)
@ -52,34 +53,32 @@ class UserRelUser
*/
protected ?DateTime $lastEdit = null;
/**
* Set friendUserId.
*
* @return UserRelUser
*/
public function setFriendUserId(int $friendUserId)
public function getUser(): User
{
return $this->user;
}
public function setUser(User $user): self
{
$this->friendUserId = $friendUserId;
$this->user = $user;
return $this;
}
/**
* Get friendUserId.
*
* @return int
*/
public function getFriendUserId()
public function getFriend(): User
{
return $this->friendUserId;
return $this->friend;
}
/**
* Set relationType.
*
* @return UserRelUser
*/
public function setRelationType(int $relationType)
public function setFriend(User $friend): self
{
$this->friend = $friend;
return $this;
}
public function setRelationType(int $relationType): self
{
$this->relationType = $relationType;
@ -96,12 +95,7 @@ class UserRelUser
return $this->relationType;
}
/**
* Set lastEdit.
*
* @return UserRelUser
*/
public function setLastEdit(DateTime $lastEdit)
public function setLastEdit(DateTime $lastEdit): self
{
$this->lastEdit = $lastEdit;

@ -149,7 +149,16 @@ class Version20170626122900 extends AbstractMigrationChamilo
}
$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 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')) {
$this->addSql(

@ -54,6 +54,14 @@ class Version20170904145500 extends AbstractMigrationChamilo
$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')) {
$this->addSql(
'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');
}
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');
$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\JoinColumn(name="forum_last_post", referencedColumnName="iid")
*/
protected CForumPost $forumLastPost;
protected ?CForumPost $forumLastPost = null;
/**
* @Gedmo\SortableGroup
@ -531,12 +531,7 @@ class CForumForum extends AbstractResource implements ResourceInterface
return $this->forumImage;
}
/**
* Set startTime.
*
* @return CForumForum
*/
public function setStartTime(DateTime $startTime)
public function setStartTime(?DateTime $startTime): self
{
$this->startTime = $startTime;
@ -553,12 +548,7 @@ class CForumForum extends AbstractResource implements ResourceInterface
return $this->startTime;
}
/**
* Set endTime.
*
* @return CForumForum
*/
public function setEndTime(DateTime $endTime)
public function setEndTime(?DateTime $endTime): self
{
$this->endTime = $endTime;

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

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

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

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

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

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

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

Loading…
Cancel
Save