<?php
namespace App\Entity\Core\SelfStudy;
use App\Entity\Core\Topic\Topic;
use App\Entity\User\User;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Table('self_study_topic_student_difficulty')]
#[ORM\Entity(repositoryClass: SelfStudyTopicStudentDifficultyRepository::class)]
class SelfStudyTopicStudentDifficulty
{
const DEFAULT_DIFFICULTY = 1;
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private $id;
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id')]
#[ORM\ManyToOne(targetEntity: User::class)]
private $user;
#[ORM\JoinColumn(name: 'topic_id', referencedColumnName: 'id')]
#[ORM\ManyToOne(targetEntity: Topic::class)]
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;
}
/**
* @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;
}
public function getRepetitionFlag(): ?bool
{
return $this->repetitionFlag;
}
/**
* @param mixed $repetitionFlag
*/
public function setRepetitionFlag($repetitionFlag)
{
$this->repetitionFlag = $repetitionFlag;
}
}