Internal - Add UserTrait.php, replace userId(int) with User entity

Add Timestampable trait
pull/3543/head
Julio Montoya 4 years ago
parent c9546d79b5
commit 1c84aade8f
  1. 4
      public/main/gradebook/lib/be/abstractlink.class.php
  2. 2
      public/main/gradebook/lib/be/evaluation.class.php
  3. 15
      src/CoreBundle/Entity/GradebookCategory.php
  4. 41
      src/CoreBundle/Entity/GradebookCertificate.php
  5. 33
      src/CoreBundle/Entity/GradebookEvaluation.php
  6. 33
      src/CoreBundle/Entity/GradebookLink.php
  7. 54
      src/CoreBundle/Entity/GradebookLinkevalLog.php
  8. 50
      src/CoreBundle/Entity/GradebookResult.php
  9. 36
      src/CoreBundle/Entity/GradebookResultLog.php
  10. 18
      src/CoreBundle/Entity/GradebookScoreDisplay.php
  11. 34
      src/CoreBundle/Entity/GradebookScoreLog.php
  12. 25
      src/CoreBundle/Traits/UserTrait.php

@ -398,7 +398,7 @@ abstract class AbstractLink implements GradebookItem
->setType($this->get_type())
->setVisible($this->is_visible())
->setWeight(api_float_val($this->get_weight()))
->setUserId($this->get_user_id())
->setUser(api_get_user_entity($this->get_user_id()))
->setRefId($this->get_ref_id())
->setCategoryId($this->get_category_id())
->setCourse(api_get_course_entity())
@ -433,7 +433,7 @@ abstract class AbstractLink implements GradebookItem
$link
->setType($this->get_type())
->setRefId($this->get_ref_id())
->setUserId($this->get_user_id())
->setUser(api_get_user_entity($this->get_user_id()))
->setCourse($course)
->setCategoryId($this->get_category_id())
->setWeight($this->get_weight())

@ -320,7 +320,7 @@ class Evaluation implements GradebookItem
->setCourse(api_get_course_entity())
->setName($this->get_name())
->setCategoryId($this->get_category_id())
->setUserId($this->get_user_id())
->setUser(api_get_user_entity($this->get_user_id()))
->setWeight(api_float_val($this->get_weight()))
->setMax($this->get_max())
->setVisible($this->is_visible())

@ -4,6 +4,7 @@
namespace Chamilo\CoreBundle\Entity;
use Chamilo\CoreBundle\Traits\UserTrait;
use Doctrine\ORM\Mapping as ORM;
/**
@ -17,6 +18,8 @@ use Doctrine\ORM\Mapping as ORM;
*/
class GradebookCategory
{
use UserTrait;
/**
* @var int
*
@ -522,16 +525,4 @@ class GradebookCategory
return $this;
}
public function getUser(): User
{
return $this->user;
}
public function setUser(User $user): self
{
$this->user = $user;
return $this;
}
}

@ -4,6 +4,7 @@
namespace Chamilo\CoreBundle\Entity;
use Chamilo\CoreBundle\Traits\UserTrait;
use Doctrine\ORM\Mapping as ORM;
/**
@ -20,6 +21,8 @@ use Doctrine\ORM\Mapping as ORM;
*/
class GradebookCertificate
{
use UserTrait;
/**
* @var int
*
@ -37,11 +40,19 @@ class GradebookCertificate
protected $catId;
/**
* @var int
* @var User
*
* @ORM\Column(name="user_id", type="integer", nullable=false)
* @ORM\ManyToOne(
* targetEntity="Chamilo\CoreBundle\Entity\User",
* inversedBy="gradebookCertificates"
* )
* @ORM\JoinColumn(
* name="user_id",
* referencedColumnName="id",
* onDelete="CASCADE"
* )
*/
protected $userId;
protected $user;
/**
* @var float
@ -95,30 +106,6 @@ class GradebookCertificate
return $this->catId;
}
/**
* Set userId.
*
* @param int $userId
*
* @return GradebookCertificate
*/
public function setUserId($userId)
{
$this->userId = $userId;
return $this;
}
/**
* Get userId.
*
* @return int
*/
public function getUserId()
{
return $this->userId;
}
/**
* Set scoreCertificate.
*

@ -5,6 +5,7 @@
namespace Chamilo\CoreBundle\Entity;
use Chamilo\CoreBundle\Traits\CourseTrait;
use Chamilo\CoreBundle\Traits\UserTrait;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
@ -20,6 +21,7 @@ use Gedmo\Mapping\Annotation as Gedmo;
class GradebookEvaluation
{
use CourseTrait;
use UserTrait;
/**
* @var int
@ -45,11 +47,12 @@ class GradebookEvaluation
protected $description;
/**
* @var int
* @var User
*
* @ORM\Column(name="user_id", type="integer", nullable=false)
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User", inversedBy="gradeBookEvaluations")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")
*/
protected $userId;
protected $user;
/**
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course", inversedBy="gradebookEvaluations")
@ -192,30 +195,6 @@ class GradebookEvaluation
return $this->description;
}
/**
* Set userId.
*
* @param int $userId
*
* @return GradebookEvaluation
*/
public function setUserId($userId)
{
$this->userId = $userId;
return $this;
}
/**
* Get userId.
*
* @return int
*/
public function getUserId()
{
return $this->userId;
}
/**
* Set categoryId.
*

@ -5,6 +5,7 @@
namespace Chamilo\CoreBundle\Entity;
use Chamilo\CoreBundle\Traits\CourseTrait;
use Chamilo\CoreBundle\Traits\UserTrait;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
@ -21,6 +22,7 @@ use Gedmo\Mapping\Annotation as Gedmo;
class GradebookLink
{
use CourseTrait;
use UserTrait;
/**
* @var int
@ -46,11 +48,12 @@ class GradebookLink
protected $refId;
/**
* @var int
* @var User
*
* @ORM\Column(name="user_id", type="integer", nullable=false)
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User", inversedBy="gradeBookLinks")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")
*/
protected $userId;
protected $user;
/**
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course", inversedBy="gradebookLinks")
@ -179,30 +182,6 @@ class GradebookLink
return $this->refId;
}
/**
* Set userId.
*
* @param int $userId
*
* @return GradebookLink
*/
public function setUserId($userId)
{
$this->userId = $userId;
return $this;
}
/**
* Get userId.
*
* @return int
*/
public function getUserId()
{
return $this->userId;
}
/**
* Set categoryId.
*

@ -4,7 +4,9 @@
namespace Chamilo\CoreBundle\Entity;
use Chamilo\CoreBundle\Traits\UserTrait;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* GradebookLinkevalLog.
@ -14,6 +16,17 @@ use Doctrine\ORM\Mapping as ORM;
*/
class GradebookLinkevalLog
{
use UserTrait;
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
/**
* @var int
*
@ -38,6 +51,7 @@ class GradebookLinkevalLog
/**
* @var \DateTime
*
* @Gedmo\Timestampable(on="create")
* @ORM\Column(name="created_at", type="datetime", nullable=false)
*/
protected $createdAt;
@ -64,20 +78,12 @@ class GradebookLinkevalLog
protected $type;
/**
* @var int
* @var User
*
* @ORM\Column(name="user_id_log", type="integer", nullable=false)
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User", inversedBy="gradebookLinkevalLogs")
* @ORM\JoinColumn(name="user_id_log", referencedColumnName="id", onDelete="CASCADE")
*/
protected $userIdLog;
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
protected $user;
/**
* Set idLinkevalLog.
@ -247,30 +253,6 @@ class GradebookLinkevalLog
return $this->type;
}
/**
* Set userIdLog.
*
* @param int $userIdLog
*
* @return GradebookLinkevalLog
*/
public function setUserIdLog($userIdLog)
{
$this->userIdLog = $userIdLog;
return $this;
}
/**
* Get userIdLog.
*
* @return int
*/
public function getUserIdLog()
{
return $this->userIdLog;
}
/**
* Get id.
*

@ -4,7 +4,9 @@
namespace Chamilo\CoreBundle\Entity;
use Chamilo\CoreBundle\Traits\UserTrait;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* GradebookResult.
@ -18,12 +20,16 @@ use Doctrine\ORM\Mapping as ORM;
*/
class GradebookResult
{
use UserTrait;
/**
* @var int
*
* @ORM\Column(name="user_id", type="integer", nullable=false)
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $userId;
protected $id;
/**
* @var int
@ -32,13 +38,6 @@ class GradebookResult
*/
protected $evaluationId;
/**
* @var \DateTime
*
* @ORM\Column(name="created_at", type="datetime", nullable=false)
*/
protected $createdAt;
/**
* @var float
*
@ -47,37 +46,20 @@ class GradebookResult
protected $score;
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
/**
* Set userId.
*
* @param int $userId
* @var \DateTime
*
* @return GradebookResult
* @Gedmo\Timestampable(on="create")
* @ORM\Column(name="created_at", type="datetime", nullable=false)
*/
public function setUserId($userId)
{
$this->userId = $userId;
return $this;
}
protected $createdAt;
/**
* Get userId.
* @var User
*
* @return int
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User", inversedBy="gradebookResults")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")
*/
public function getUserId()
{
return $this->userId;
}
protected $user;
/**
* Set evaluationId.

@ -4,7 +4,9 @@
namespace Chamilo\CoreBundle\Entity;
use Chamilo\CoreBundle\Traits\UserTrait;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* GradebookResultLog.
@ -14,6 +16,8 @@ use Doctrine\ORM\Mapping as ORM;
*/
class GradebookResultLog
{
use UserTrait;
/**
* @var int
*
@ -30,13 +34,6 @@ class GradebookResultLog
*/
protected $resultId;
/**
* @var int
*
* @ORM\Column(name="user_id", type="integer", nullable=false)
*/
protected $userId;
/**
* @var int
*
@ -47,6 +44,7 @@ class GradebookResultLog
/**
* @var \DateTime
*
* @Gedmo\Timestampable(on="create")
* @ORM\Column(name="created_at", type="datetime", nullable=false)
*/
protected $createdAt;
@ -59,28 +57,12 @@ class GradebookResultLog
protected $score;
/**
* Set userId.
*
* @param int $userId
* @var User
*
* @return GradebookResultLog
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User", inversedBy="gradebookResultLogs")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")
*/
public function setUserId($userId)
{
$this->userId = $userId;
return $this;
}
/**
* Get userId.
*
* @return int
*/
public function getUserId()
{
return $this->userId;
}
protected $user;
/**
* Set evaluationId.

@ -14,6 +14,15 @@ use Doctrine\ORM\Mapping as ORM;
*/
class GradebookScoreDisplay
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
/**
* @var float
*
@ -42,15 +51,6 @@ class GradebookScoreDisplay
*/
protected $scoreColorPercent;
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
/**
* Set score.
*

@ -4,6 +4,7 @@
namespace Chamilo\CoreBundle\Entity;
use Chamilo\CoreBundle\Traits\UserTrait;
use Doctrine\ORM\Mapping as ORM;
/**
@ -19,6 +20,8 @@ use Doctrine\ORM\Mapping as ORM;
*/
class GradebookScoreLog
{
use UserTrait;
/**
* @var int
*
@ -36,11 +39,12 @@ class GradebookScoreLog
protected $categoryId;
/**
* @var int
* @var User
*
* @ORM\Column(name="user_id", type="integer", nullable=false)
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User", inversedBy="gradebookScoreLogs")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")
*/
protected $userId;
protected $user;
/**
* @var float
@ -66,16 +70,6 @@ class GradebookScoreLog
return $this->categoryId;
}
/**
* Get the user id.
*
* @return int
*/
public function getUserId()
{
return $this->userId;
}
/**
* Get the achieved score.
*
@ -120,20 +114,6 @@ class GradebookScoreLog
return $this;
}
/**
* Set the user id.
*
* @param int $userId
*
* @return $this
*/
public function setUserId($userId)
{
$this->userId = $userId;
return $this;
}
/**
* Set the achieved score.
*

@ -0,0 +1,25 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Traits;
use Chamilo\CoreBundle\Entity\User;
trait UserTrait
{
/**
* @return User
*/
public function getUser()
{
return $this->user;
}
public function setUser(User $user): self
{
$this->user = $user;
return $this;
}
}
Loading…
Cancel
Save