src/CoreBundle/Entity/PeerMathproblem.php line 15

Open in your IDE?
  1. <?php
  2. namespace CoreBundle\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use JsonSerializable;
  7. /**
  8. * @ORM\Table("peer_mathproblem")
  9. * @ORM\Entity(repositoryClass="CoreBundle\Entity\PeerMathproblemRepository")
  10. */
  11. class PeerMathproblem implements JsonSerializable
  12. {
  13. /**
  14. * @ORM\Column(type="integer")
  15. * @ORM\Id
  16. * @ORM\GeneratedValue
  17. */
  18. private int $id;
  19. /**
  20. * @ORM\ManyToOne(targetEntity="PeerTheme", inversedBy="peerMathproblems")
  21. * @ORM\JoinColumn(name="peer_theme_id")
  22. */
  23. private PeerTheme $peerTheme;
  24. /**
  25. * @ORM\OneToMany(targetEntity="PeerUnit", mappedBy="peerMathproblem")
  26. */
  27. private Collection $peerUnits;
  28. /**
  29. * @ORM\Column(type="text")
  30. */
  31. private string $title;
  32. /**
  33. * @ORM\Column(type="text")
  34. */
  35. private string $description;
  36. /**
  37. * @ORM\Column(nullable=true)
  38. */
  39. private ?string $image;
  40. /**
  41. * @ORM\Column(name="student_hint", type="text", nullable=true)
  42. */
  43. private ?string $studentHint;
  44. /**
  45. * @ORM\Column(name="teacher_hint", type="text", nullable=true)
  46. */
  47. private ?string $teacherHint;
  48. /**
  49. * @ORM\Column(name="feedback_stage1", type="text", nullable=true)
  50. */
  51. private ?string $feedbackStage1;
  52. /**
  53. * @ORM\Column(name="feedback_stage2", type="text", nullable=true)
  54. */
  55. private ?string $feedbackStage2;
  56. /**
  57. * @ORM\Column(name="feedback_stage3", type="text", nullable=true)
  58. */
  59. private ?string $feedbackStage3;
  60. /**
  61. * level 1 = 7th grade, level 2 = 8th grade, level3 = 9+10th grade
  62. *
  63. * @ORM\Column(type="integer")
  64. */
  65. private int $level;
  66. /**
  67. * @ORM\Column(name="teacher_hint_image", type="text", nullable=true)
  68. */
  69. private ?string $teacherHintImage;
  70. /**
  71. * @ORM\Column(name="student_hint_image", type="text", nullable=true)
  72. */
  73. private ?string $studentHintImage;
  74. /**
  75. * @ORM\Column(name="student_hint_video", type="text", nullable=true)
  76. */
  77. private ?string $studentHintVideo;
  78. /**
  79. * The new image layout for CMS and API.
  80. *
  81. * @ORM\OneToOne(targetEntity="ImageReference")
  82. * @ORM\JoinColumn(name="image_reference", referencedColumnName="id", nullable=true)
  83. */
  84. private ?ImageReference $imageReference;
  85. /**
  86. * The new image layout for CMS and API.
  87. *
  88. * @ORM\OneToOne(targetEntity="ImageReference")
  89. * @ORM\JoinColumn(name="teacher_hint_image_reference", referencedColumnName="id", nullable=true)
  90. */
  91. private ?ImageReference $teacherHintImageReference;
  92. /**
  93. * The new image layout for CMS and API.
  94. *
  95. * @ORM\OneToOne(targetEntity="ImageReference")
  96. * @ORM\JoinColumn(name="student_hint_image_reference", referencedColumnName="id", nullable=true)
  97. */
  98. private ?ImageReference $studentHintImageReference;
  99. public function __construct()
  100. {
  101. $this->peerUnits = new ArrayCollection();
  102. $this->imageReference = null;
  103. }
  104. /**
  105. * @return ImageReference|null
  106. */
  107. public function getTeacherHintImageReference(): ?ImageReference
  108. {
  109. return $this->teacherHintImageReference;
  110. }
  111. /**
  112. * @param ImageReference|null $teacherHintImageReference
  113. * @return void
  114. */
  115. public function setTeacherHintImageReference(?ImageReference $teacherHintImageReference): void
  116. {
  117. $this->teacherHintImageReference = $teacherHintImageReference;
  118. }
  119. /**
  120. * @return ImageReference|null
  121. */
  122. public function getStudentHintImageReference(): ?ImageReference
  123. {
  124. return $this->studentHintImageReference;
  125. }
  126. /**
  127. * @param ImageReference|null $studentHintImageReference
  128. * @return void
  129. */
  130. public function setStudentHintImageReference(?ImageReference $studentHintImageReference): void
  131. {
  132. $this->studentHintImageReference = $studentHintImageReference;
  133. }
  134. public function getImageReference(): ?ImageReference
  135. {
  136. return $this->imageReference;
  137. }
  138. public function setImageReference(?ImageReference $imageReference): void
  139. {
  140. $this->imageReference = $imageReference;
  141. }
  142. public function getId(): int
  143. {
  144. return $this->id;
  145. }
  146. public function getPeerTheme(): PeerTheme
  147. {
  148. return $this->peerTheme;
  149. }
  150. public function setPeerTheme(PeerTheme $peerTheme)
  151. {
  152. $this->peerTheme = $peerTheme;
  153. }
  154. public function getDescription(): string
  155. {
  156. return $this->description;
  157. }
  158. public function setDescription(string $description)
  159. {
  160. $this->description = $description;
  161. }
  162. public function setImage(string $image)
  163. {
  164. $this->image = $image;
  165. }
  166. /**
  167. * @return ArrayCollection | PeerUnit[]
  168. */
  169. public function getPeerUnits(): Collection
  170. {
  171. return $this->peerUnits;
  172. }
  173. public function getTitle(): string
  174. {
  175. return $this->title;
  176. }
  177. public function setTitle(string $title): void
  178. {
  179. $this->title = $title;
  180. }
  181. public function getStudentHint(): ?string
  182. {
  183. return $this->studentHint;
  184. }
  185. public function setStudentHint(string $studentHint): void
  186. {
  187. $this->studentHint = $studentHint;
  188. }
  189. public function getTeacherHint(): ?string
  190. {
  191. return $this->teacherHint;
  192. }
  193. public function setTeacherHint(string $teacherHint): void
  194. {
  195. $this->teacherHint = $teacherHint;
  196. }
  197. public function getLevel(): int
  198. {
  199. return $this->level;
  200. }
  201. public function setLevel(int $level): void
  202. {
  203. $this->level = $level;
  204. }
  205. public function jsonSerialize(): mixed
  206. {
  207. return [
  208. "id" => $this->id,
  209. "title" => $this->title,
  210. "description" => $this->description,
  211. "image" => $this->getImage(),
  212. "studentHint" => $this->studentHint,
  213. "teacherHint" => $this->teacherHint,
  214. "studentHintImage" => $this->getStudentHintImage(),
  215. "teacherHintImage" => $this->getTeacherHintImage(),
  216. "studentHintVideo" => $this->studentHintVideo,
  217. "level" => $this->level,
  218. ];
  219. }
  220. /**
  221. * @param string|null $teacherHintImage
  222. */
  223. public function setTeacherHintImage(?string $teacherHintImage): void
  224. {
  225. $this->teacherHintImage = $teacherHintImage;
  226. }
  227. /**
  228. * @param string|null $studentHintImage
  229. */
  230. public function setStudentHintImage(?string $studentHintImage): void
  231. {
  232. $this->studentHintImage = $studentHintImage;
  233. }
  234. /**
  235. * @return string|null
  236. */
  237. public function getFeedbackStage1(): ?string
  238. {
  239. return $this->feedbackStage1;
  240. }
  241. /**
  242. * @param string|null $feedbackStage1
  243. */
  244. public function setFeedbackStage1(?string $feedbackStage1): void
  245. {
  246. $this->feedbackStage1 = $feedbackStage1;
  247. }
  248. /**
  249. * @return string|null
  250. */
  251. public function getFeedbackStage2(): ?string
  252. {
  253. return $this->feedbackStage2;
  254. }
  255. /**
  256. * @param string|null $feedbackStage2
  257. */
  258. public function setFeedbackStage2(?string $feedbackStage2): void
  259. {
  260. $this->feedbackStage2 = $feedbackStage2;
  261. }
  262. /**
  263. * @return string|null
  264. */
  265. public function getFeedbackStage3(): ?string
  266. {
  267. return $this->feedbackStage3;
  268. }
  269. /**
  270. * @param string|null $feedbackStage3
  271. */
  272. public function setFeedbackStage3(?string $feedbackStage3): void
  273. {
  274. $this->feedbackStage3 = $feedbackStage3;
  275. }
  276. public function getStudentHintVideo(): ?string
  277. {
  278. return $this->studentHintVideo;
  279. }
  280. /**
  281. * @param string|null $studentHintVideo
  282. */
  283. public function setStudentHintVideo(?string $studentHintVideo): void
  284. {
  285. $this->studentHintVideo = $studentHintVideo;
  286. }
  287. /** helper functions **/
  288. public function getImagePath(): string
  289. {
  290. return $this->imageReference?->getFullMediaPath() ?? $this->fallbackToOldImagePath('image') ?? '';
  291. }
  292. public function getStudentHintImagePath(): string
  293. {
  294. return $this->studentHintImageReference?->getFullMediaPath() ?? $this->fallbackToOldImagePath('studentHintImage') ?? '';
  295. }
  296. public function getTeacherHintImagePath(): string
  297. {
  298. return $this->teacherHintImageReference?->getFullMediaPath() ?? $this->fallbackToOldImagePath('teacherHintImage') ?? '';
  299. }
  300. public function getImage(){
  301. return $this->getImagePath();
  302. }
  303. public function getStudentHintImage(){
  304. return $this->getStudentHintImagePath();
  305. }
  306. public function getTeacherHintImage(){
  307. return $this->getTeacherHintImagePath();
  308. }
  309. //TODO: Image migration - Remove after all migrations has been run.
  310. private function fallbackToOldImagePath(string $propertyName): ?string
  311. {
  312. if ($this->$propertyName)
  313. return '/bundles/abacuscore/' . $this->$propertyName;
  314. return null;
  315. }
  316. }