<?php
namespace CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Model\UserInterface;
use UserBundle\Entity\User;
/**
* @ORM\Table("self_study_topic_student_difficulty")
* @ORM\Entity(repositoryClass="SelfStudyTopicStudentDifficultyRepository")
*/
class SelfStudyTopicStudentDifficulty
{
const DEFAULT_DIFFICULTY = 1;
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="UserBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity="Topic")
* @ORM\JoinColumn(name="topic_id", referencedColumnName="id")
*/
private $topic;
/**
* @ORM\Column(name="resp_array", type="array", nullable=true)
*/
private $respArray = [0, 0, 0, 0];
/**
* @ORM\Column(name="difficulty", type="integer")
*/
private $difficulty = self::DEFAULT_DIFFICULTY;
/**
* @ORM\Column(name="repetition_flag", type="boolean", nullable=true)
*/
private $repetitionFlag;
public function __construct(User $user, Topic $topic)
{
$this->user = $user;
$this->topic = $topic;
}
public function getId()
{
return $this->id;
}
public function setUser(UserInterface $user)
{
$this->user = $user;
}
public function getUser()
{
return $this->user;
}
public function setTopic(Topic $topic)
{
$this->topic = $topic;
return $this;
}
public function getTopic()
{
return $this->topic;
}
/**
* @param int $difficulty
* @return $this
*/
public function setDifficulty(int $difficulty)
{
$this->difficulty = $difficulty;
return $this;
}
public function getDifficulty()
{
return $this->difficulty;
}
/**
* @return mixed
*/
public function getRespArray()
{
return $this->respArray;
}
/**
* @param $value
* @return $this
*/
public function addResponse(int $value)
{
$responseArray = $this->getRespArray();
array_unshift($responseArray, $value);
$this->respArray = array_slice($responseArray, 0, 4);
return $this;
}
/**
* @param mixed $respArray
* @return $this
*/
public function setRespArray(array $respArray)
{
$this->respArray = array_slice($respArray, 0, 4);
return $this;
}
/**
* @return bool|null
*/
public function getRepetitionFlag(): ?bool
{
return $this->repetitionFlag;
}
/**
* @param mixed $repetitionFlag
*/
public function setRepetitionFlag($repetitionFlag)
{
$this->repetitionFlag = $repetitionFlag;
}
}