<?php
namespace CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use JsonSerializable;
/**
* @ORM\Table("session")
* @ORM\Entity(repositoryClass="CoreBundle\Entity\SessionRepository")
*/
class Session extends SessionType implements SessionInterface, JsonSerializable
{
/**
* @var Classroom
*
* @ORM\ManyToOne(targetEntity="Classroom", inversedBy="sessions")
* @ORM\JoinColumn(name="classroom", referencedColumnName="id", onDelete="CASCADE")
*/
private $classroom;
/**
* @var ArrayCollection|Topic[]
*
* @ORM\ManyToMany(targetEntity="Topic", inversedBy="sessions")
* @ORM\JoinTable(name="session_topic",
* joinColumns={@ORM\JoinColumn(name="session", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="topic", referencedColumnName="id")})
*/
private $topics;
/**
* @var ArrayCollection
*
* @ORM\ManyToMany(targetEntity="TagMathproblem")
* @ORM\JoinTable(name="session_tag",
* joinColumns={@ORM\JoinColumn(name="session", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="tag", referencedColumnName="id")})
*/
private $tags;
/**
* @var bool
*
* @ORM\Column(name="dormant", type="boolean")
*/
private $dormant = false;
/**
* @var Pretest
*
* @ORM\ManyToOne(targetEntity="Pretest")
* @ORM\JoinColumn(name="pretest", referencedColumnName="id", nullable=true, onDelete="CASCADE")
*/
private $pretest;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $pretestDuration;
/**
* @ORM\Column(type="integer", nullable=true, options={"default"=1})
*/
private $groupSize = 1;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $usePretest;
/**
* @ORM\OneToMany(targetEntity="TrainingUnit",
* mappedBy="session", cascade={"persist","remove"})
*/
private Collection $TrainingUnits;
/**
* @var PretestResponse[]
*
* @ORM\OneToMany(targetEntity="PretestResponse",
* mappedBy="session", cascade={"persist","remove"})
*/
private $PretestResponses;
/**
* @var ArrayCollection|SessionStudent[]
*
* @ORM\OneToMany(targetEntity="SessionStudent",
* mappedBy="session", cascade={"persist","remove"})
*/
private $students;
/**
* @ORM\Column(type="integer", nullable=true, options={"default"=0})
*/
private $status = 0;
/**
* @ORM\Column(type="integer")
*/
private $templateCount;
/**
* @ORM\Column(type="integer")
*
* assistance = 1 (both CAS and no CAS)
* assistance = 2 (no CAS)
*/
private $assistance;
/**
* @var bool
* @ORM\Column(name="is_self_study", type="boolean", nullable=true, options={"default":false})
*/
private $isSelfStudy;
/**
* @ORM\Column(name="has_many_topics", type="integer", nullable=true, options={"default"=0})
*
* hasManyTopics = 0 (count of topics <= 3)
* hasManyTopics = 1 (count of topics > 3)
*/
private $hasManyTopics = 0;
/**
* @var SelfStudyTopic
*
* @ORM\ManyToOne(targetEntity="SelfStudyTopic")
* @ORM\JoinColumn(name="self_study_topic", referencedColumnName="id")
*/
private $selfStudyTopic = null;
/**
* @ORM\Column(name="start_difficulty", type="integer", nullable=true)
*/
private $startDifficulty;
public function __construct()
{
$this->TrainingUnits = new ArrayCollection();
$this->PretestResponses = new ArrayCollection();
$this->topics = new ArrayCollection();
$this->tags = new ArrayCollection();
$this->students = new ArrayCollection();
}
/**
* Set classroom.
*
* @param Classroom $classroom
*
* @return Session
*/
public function setClassroom($classroom)
{
$this->classroom = $classroom;
return $this;
}
/**
* Get classroom.
*
* @return Classroom
*/
public function getClassroom()
{
return $this->classroom;
}
/**
* @param Topic[] $topics
*/
public function setTopics(array $topics)
{
$this->topics = $topics;
}
public function getTopics(): Collection
{
return $this->topics;
}
/**
* @param Topic $topic
*
* @return Session
*/
public function addTopic(Topic $topic)
{
$this->topics->add($topic);
return $this;
}
/**
* @param Topic $topic
*
* @return bool
*/
public function removeTopic(Topic $topic)
{
return $this->topics->removeElement($topic);
}
/**
* @return Collection
*/
public function getTags(): Collection
{
return $this->tags;
}
/**
* @param TagMathproblem $tag
*
* @return Session
*/
public function addTag(TagMathproblem $tag)
{
$this->tags->add($tag);
return $this;
}
/**
* @param TagMathproblem[] $tags
*/
public function setTags(array $tags)
{
$this->tags = $tags;
}
/**
* @param TagMathproblem $tag
*
* @return bool
*/
public function removeTag(TagMathproblem $tag)
{
return $this->tags->removeElement($tag);
}
public function isDormant()
{
return $this->dormant;
}
public function setDormant($dormant)
{
$this->dormant = $dormant;
}
/**
* Set pretest.
*
* @param Pretest $pretest
*
* @return Session
*/
public function setPretest($pretest)
{
$this->pretest = $pretest;
return $this;
}
/**
* Get pretest.
*
* @return Pretest
*/
public function getPretest()
{
return $this->pretest;
}
/**
* Set Duration.
*
* @param int $duration
*
* @return Session
*/
public function setDuration($duration)
{
$this->duration = $duration;
return $this;
}
/**
* Get duration.
*
* @return int
*/
public function getDuration()
{
return $this->duration;
}
/**
* Set groupSize.
*
* @param int $groupSize
*
* @return Session
*/
public function setGroupSize($groupSize)
{
$this->groupSize = $groupSize;
return $this;
}
/**
* Get groupSize.
*
* @return int
*/
public function getGroupSize()
{
return $this->groupSize;
}
/**
* Set pretestDuration.
*
* @param int $pretestDuration
*
* @return Session
*/
public function setPretestDuration($pretestDuration)
{
$this->pretestDuration = $pretestDuration;
return $this;
}
/**
* Get pretestDuration
*
* @return int
*/
public function getPretestDuration()
{
return $this->pretestDuration;
}
/**
* Set usePretest.
*
* @param int $usePretest
*
* @return Session
*/
public function setUsePretest($usePretest)
{
$this->usePretest = $usePretest;
return $this;
}
/**
* Get usePretest.
*
* @return boolean
*/
public function getUsePretest()
{
return $this->usePretest;
}
/**
* @return ArrayCollection|TrainingUnit[]
*/
public function getTrainingUnits(): Collection
{
return $this->TrainingUnits;
}
/**
* @param TrainingUnit $TrainingUnit
*
* @return Session
*/
public function addTrainingUnit(TrainingUnit $TrainingUnit)
{
$TrainingUnit->setSession($this);
$this->TrainingUnits->add($TrainingUnit);
return $this;
}
/**
* @param TrainingUnit $TrainingUnit
*
* @return bool
*/
public function removeTrainingUnit(TrainingUnit $TrainingUnit)
{
$TrainingUnit->setSession(null);
return $this->TrainingUnits->removeElement($TrainingUnit);
}
/**
* @return PretestResponse[]
*/
public function getPretestResponses()
{
return $this->PretestResponses;
}
/**
* @param PretestResponse $PretestResponse
*
* @return Session
*/
public function addPretestResponse(PretestResponse $PretestResponse)
{
$PretestResponse->setSession($this);
$this->PretestResponses->add($PretestResponse);
return $this;
}
/**
* @param PretestResponse $PretestResponse
*
* @return bool
*/
public function removePretestResponse(PretestResponse $PretestResponse)
{
$PretestResponse->setSession(null);
return $this->PretestResponses->removeElement($PretestResponse);
}
/**
* @return SessionStudent[]
*/
public function getStudents()
{
return $this->students;
}
/**
* @param SessionStudent $student
*
* @return Session
*/
public function addStudent(SessionStudent $student)
{
$this->students->add($student);
return $this;
}
/**
* @param SessionStudent $student
*
* @return bool
*/
public function removeStudent(SessionStudent $student)
{
$student->setSession(null);
return $this->students->removeElement($student);
}
/**
* @return int|null
*/
public function getStatus(): ?int
{
return $this->status;
}
/**
* @param mixed $status
*/
public function setStatus($status)
{
$this->status = $status;
}
public function getTemplateCount()
{
return $this->templateCount;
}
public function setTemplateCount($count)
{
$this->templateCount = $count;
}
public function getAssistance()
{
return $this->assistance;
}
/**
* @param mixed $assistance
*/
public function setAssistance($assistance)
{
$this->assistance = $assistance;
}
/**
* @return bool | null
*/
public function isSelfStudy()
{
return $this->isSelfStudy;
}
/**
* @param bool $isSelfStudy
*/
public function setIsSelfStudy(bool $isSelfStudy)
{
$this->isSelfStudy = $isSelfStudy;
}
/**
* @return int
*/
public function hasManyTopics(): int
{
return $this->hasManyTopics;
}
/**
* @param int $hasManyTopics
*/
public function setHasManyTopics(int $hasManyTopics): void
{
$this->hasManyTopics = $hasManyTopics;
}
/**
* @return mixed
*/
public function getStartDifficulty()
{
return $this->startDifficulty;
}
/**
* @param mixed $startDifficulty
*/
public function setStartDifficulty($startDifficulty): void
{
$this->startDifficulty = $startDifficulty;
}
public function getSelfStudyTopic(): ?SelfStudyTopic
{
return $this->selfStudyTopic;
}
public function setSelfStudyTopic(?SelfStudyTopic $selfStudyTopic): void
{
$this->selfStudyTopic = $selfStudyTopic;
}
public function jsonSerialize(): mixed
{
return [
"id" => $this->getId(),
"duration" => $this->getDuration(),
"tags" => $this->getTags()->toArray(),
"status" => $this->getStatus(),
"name" => $this->getName(),
"deadline" => $this->getDeadline(),
"classroom" => $this->getClassroom(),
"startTime" => $this->getStartTime(),
"assistance" => $this->getAssistance(),
"groupSize" => $this->getGroupSize(),
"pretest" => $this->getPretest(),
"pretestDuration" => $this->getPretestDuration(),
"startDifficulty" => $this->getStartDifficulty(),
"students" => $this->getStudents()->toArray(),
// "pretestResponses" => $this->getPretestResponses()->toArray(),
"templateCount" => $this->getTemplateCount(),
"topics" => $this->getTopics()->toArray(),
"trainingUnits" => $this->getTrainingUnits()->toArray(),
"usePretest" => $this->getUsePretest(),
];
}
}