<?php
namespace CoreBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table("reading_test")
* @ORM\Entity(repositoryClass="CoreBundle\Entity\ReadingTestRepository")
*/
class ReadingTest
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=255, nullable=true)
*/
private $title;
/**
* @var string
*
* @ORM\Column(name="text", type="text", length=65000, nullable=false)
*/
private $text;
/**
* @var ClassroomType
*
* @ORM\ManyToOne(targetEntity="CoreBundle\Entity\ClassroomType")
* @ORM\JoinColumn(name="classroom_type", referencedColumnName="id")
*/
private $classroomType;
/**
* @ORM\ManyToMany(targetEntity="Mathproblem")
* @ORM\JoinTable(name="reading_test_mathproblem",
* joinColumns={@ORM\JoinColumn(name="reading_test_id")},
* inverseJoinColumns={@ORM\JoinColumn(name="mathproblem_id")})
*/
private Collection $mathproblems;
/**
* @var array
*
* @ORM\Column(name="problem_order", type="simple_array", nullable=true)
*/
private $problemOrder;
/**
* @var array
*
* @ORM\Column(name="color_wrong_count_threshold", type="simple_array", nullable=true)
*/
private $colorWrongCountThreshold;
/**
* @var array
*
* @ORM\Column(name="color_wrong_word_per_minute_threshold", type="simple_array", nullable=true)
*/
private $colorWrongWordPerMinuteThreshold;
public function __construct()
{
$this->mathproblems = new ArrayCollection();
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
*/
public function setId(int $id): void
{
$this->id = $id;
}
/**
* @return string
*/
public function getTitle(): string
{
return $this->title;
}
/**
* @param string $title
*/
public function setTitle(string $title): void
{
$this->title = $title;
}
/**
* @return string
*/
public function getText(): string
{
return $this->text;
}
/**
* @param string $text
*/
public function setText(string $text): void
{
$this->text = $text;
}
/**
* @return ClassroomType
*/
public function getClassroomType()
{
return $this->classroomType;
}
/**
* @param ClassroomType $classroomType
*/
public function setClassroomType(ClassroomType $classroomType): void
{
$this->classroomType = $classroomType;
}
/**
* @return ArrayCollection|Mathproblem[]
*/
public function getMathproblems(): Collection
{
return $this->mathproblems;
}
/**
* @param Mathproblem[]
* @return ReadingTest
*/
public function setMathproblems(array $mathproblems): self
{
$this->mathproblems = new ArrayCollection($mathproblems);
return $this;
}
/**
* @return array|null
*/
public function getProblemOrder(): ?array
{
return $this->problemOrder;
}
/**
* @param array $problemOrder
*/
public function setProblemOrder(array $problemOrder)
{
$this->problemOrder = $problemOrder;
}
/**
* @return array|null
*/
public function getColorWrongCountThreshold(): ?array
{
return $this->colorWrongCountThreshold;
}
/**
* @param array|null $colorWrongCountThreshold
* @return $this
*/
public function setColorWrongCountThreshold(?array $colorWrongCountThreshold): self
{
$this->colorWrongCountThreshold = $colorWrongCountThreshold;
return $this;
}
/**
* @return array|null
*/
public function getColorWrongWordPerMinuteThreshold(): ?array
{
return $this->colorWrongWordPerMinuteThreshold;
}
/**
* @param array|null $colorWrongWordPerMinuteThreshold
* @return $this
*/
public function setColorWrongWordPerMinuteThreshold(?array $colorWrongWordPerMinuteThreshold): self
{
$this->colorWrongWordPerMinuteThreshold = $colorWrongWordPerMinuteThreshold;
return $this;
}
/**
* @return array
*/
public function getSortedMathproblems()
{
$problemOrder = $this->problemOrder;
$mathproblems = $this->mathproblems;
if ($problemOrder && count($problemOrder) == count($mathproblems)) {
$newmathproblems = [];
foreach ($mathproblems as $mp) {
$newkey = array_search($mp->getId(), $problemOrder);
$newmathproblems[$newkey] = $mp;
}
ksort($newmathproblems);
return $newmathproblems;
} else {
return $this->mathproblems->toArray();
}
}
}