src/Core/Entity/Estudiante.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Core\Entity;
  3. use App\Core\Entity\Subscripciones\HistorialPagoSubscripcion;
  4. use App\Core\Entity\Subscripciones\PagoSubscripcion;
  5. use App\Entity\EstudianteCursoNotaFinal;
  6. use App\Entity\FichaEstudiantil;
  7. use App\Entity\NotaFinal;
  8. use App\Entity\TareaEstudiante;
  9. use App\Entity\TareaEstudianteArchivo;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Symfony\Component\Serializer\Annotation\Groups;
  14. /**
  15. * @ORM\Entity(repositoryClass="App\Core\Repository\EstudianteRepository")
  16. */
  17. class Estudiante
  18. {
  19. /**
  20. * @ORM\Id()
  21. * @ORM\GeneratedValue()
  22. * @ORM\Column(type="integer")
  23. * @Groups("main")
  24. */
  25. private $id;
  26. /**
  27. * @ORM\OneToOne(targetEntity="App\Core\Entity\User", inversedBy="estudiante", cascade={"persist", "remove"})
  28. * @ORM\JoinColumn(nullable=false)
  29. */
  30. private $user;
  31. /**
  32. * @ORM\OneToMany(targetEntity="App\Core\Entity\EstudianteCurso", mappedBy="estudiante")
  33. */
  34. private $estudianteCursos;
  35. /**
  36. * @ORM\OneToMany(targetEntity=PuntuacionEstudiante::class, mappedBy="estudiante", orphanRemoval=true)
  37. */
  38. private $puntuaciones;
  39. /**
  40. * @ORM\Column(type="float", nullable=true)
  41. */
  42. private $puntuacionPromedio;
  43. /**
  44. * @ORM\OneToMany(targetEntity=PagoSubscripcion::class, mappedBy="estudiante")
  45. */
  46. private $pagosSubscripcion;
  47. /**
  48. * @ORM\OneToMany(targetEntity=HistorialPagoSubscripcion::class, mappedBy="estudiante")
  49. */
  50. private $historialPagosSubscripcion;
  51. /**
  52. * @ORM\OneToMany(targetEntity=EstudianteCursoRol::class, mappedBy="estudiante")
  53. */
  54. private $estudianteCursoRols;
  55. /**
  56. * @ORM\OneToMany(targetEntity=TareaEstudiante::class, mappedBy="estudiante")
  57. */
  58. private $tareaEstudiantes;
  59. /**
  60. * @ORM\OneToMany(targetEntity=EstudianteCursoNotaFinal::class, mappedBy="estudiante")
  61. */
  62. private $estudianteCursoNotaFinals;
  63. /**
  64. * @ORM\OneToOne(targetEntity=FichaEstudiantil::class, mappedBy="estudiante", cascade={"persist", "remove"})
  65. */
  66. private $fichaEstudiantil;
  67. public function __construct()
  68. {
  69. $this->estudianteCursos = new ArrayCollection();
  70. $this->puntuaciones = new ArrayCollection();
  71. $this->pagosSubscripcion = new ArrayCollection();
  72. $this->historialPagosSubscripcion = new ArrayCollection();
  73. $this->estudianteCursoRols = new ArrayCollection();
  74. $this->tareaEstudiantes = new ArrayCollection();
  75. $this->estudianteCursoNotaFinals = new ArrayCollection();
  76. }
  77. public function getId(): ?int
  78. {
  79. return $this->id;
  80. }
  81. public function getUser(): ?User
  82. {
  83. return $this->user;
  84. }
  85. public function setUser(User $user): self
  86. {
  87. $this->user = $user;
  88. return $this;
  89. }
  90. /**
  91. * @return Collection|EstudianteCurso[]
  92. */
  93. public function getEstudianteCursos(): Collection
  94. {
  95. return $this->estudianteCursos;
  96. }
  97. public function addEstudianteCurso(EstudianteCurso $estudianteCurso): self
  98. {
  99. if (!$this->estudianteCursos->contains($estudianteCurso)) {
  100. $this->estudianteCursos[] = $estudianteCurso;
  101. $estudianteCurso->setEstudiante($this);
  102. }
  103. return $this;
  104. }
  105. public function removeEstudianteCurso(EstudianteCurso $estudianteCurso): self
  106. {
  107. if ($this->estudianteCursos->contains($estudianteCurso)) {
  108. $this->estudianteCursos->removeElement($estudianteCurso);
  109. // set the owning side to null (unless already changed)
  110. if ($estudianteCurso->getEstudiante() === $this) {
  111. $estudianteCurso->setEstudiante(null);
  112. }
  113. }
  114. return $this;
  115. }
  116. public function getCantidadCursosActivos() {
  117. $relaciones = $this->getEstudianteCursos();
  118. $cantidad = 0;
  119. for ($i = 0; $i < count($relaciones); $i++) {
  120. $curso = $relaciones[$i]->getCurso();
  121. if($curso->getEstado()) {
  122. $cantidad++;
  123. }
  124. }
  125. return $cantidad;
  126. }
  127. public function getCantidadCursosActivosPrivados() {
  128. $relaciones = $this->getEstudianteCursos();
  129. $cantidad = 0;
  130. for ($i = 0; $i < count($relaciones); $i++) {
  131. $curso = $relaciones[$i]->getCurso();
  132. if($curso->getEstado() && $curso->getPrivado()) {
  133. $cantidad++;
  134. }
  135. }
  136. return $cantidad;
  137. }
  138. public function getCantidadCursosActivosAbiertos() {
  139. $relaciones = $this->getEstudianteCursos();
  140. $cantidad = 0;
  141. for ($i = 0; $i < count($relaciones); $i++) {
  142. $curso = $relaciones[$i]->getCurso();
  143. if($curso->getEstado() && !$curso->getPrivado()) {
  144. $cantidad++;
  145. }
  146. }
  147. return $cantidad;
  148. }
  149. public function getCantidadCursosArchivados() {
  150. return count($this->getEstudianteCursos()) - $this->getCantidadCursosActivos();
  151. }
  152. /**
  153. * @return Collection|PuntuacionEstudiante[]
  154. */
  155. public function getPuntuaciones(): Collection
  156. {
  157. return $this->puntuaciones;
  158. }
  159. public function addPuntuacione(PuntuacionEstudiante $puntuacion): self
  160. {
  161. if (!$this->puntuaciones->contains($puntuacion)) {
  162. $this->puntuaciones[] = $puntuacion;
  163. $puntuacion->setEstudiante($this);
  164. }
  165. return $this;
  166. }
  167. public function removePuntuacione(PuntuacionEstudiante $puntuacion): self
  168. {
  169. if ($this->puntuaciones->contains($puntuacion)) {
  170. $this->puntuaciones->removeElement($puntuacion);
  171. // set the owning side to null (unless already changed)
  172. if ($puntuacion->getEstudiante() === $this) {
  173. $puntuacion->setEstudiante(null);
  174. }
  175. }
  176. return $this;
  177. }
  178. /**
  179. * @return Collection|PagoSubscripcion[]
  180. */
  181. public function getPagosSubscripcion(): Collection
  182. {
  183. return $this->pagosSubscripcion;
  184. }
  185. public function addPagosSubscripcion(PagoSubscripcion $pagosSubscripcion): self
  186. {
  187. if (!$this->pagosSubscripcion->contains($pagosSubscripcion)) {
  188. $this->pagosSubscripcion[] = $pagosSubscripcion;
  189. $pagosSubscripcion->setEstudiante($this);
  190. }
  191. return $this;
  192. }
  193. public function removePagosSubscripcion(PagoSubscripcion $pagosSubscripcion): self
  194. {
  195. if ($this->pagosSubscripcion->removeElement($pagosSubscripcion)) {
  196. // set the owning side to null (unless already changed)
  197. if ($pagosSubscripcion->getEstudiante() === $this) {
  198. $pagosSubscripcion->setEstudiante(null);
  199. }
  200. }
  201. return $this;
  202. }
  203. /**
  204. * @return Collection|HistorialPagoSubscripcion[]
  205. */
  206. public function getHistorialPagosSubscripcion(): Collection
  207. {
  208. return $this->historialPagosSubscripcion;
  209. }
  210. /**
  211. * @return ?float
  212. */
  213. public function getPuntuacionPromedio(): ?float
  214. {
  215. return $this->puntuacionPromedio;
  216. }
  217. /**
  218. * @param float $puntuacionPromedio
  219. */
  220. public function setPuntuacionPromedio(float $puntuacionPromedio): void
  221. {
  222. $this->puntuacionPromedio = $puntuacionPromedio;
  223. }
  224. /**
  225. * @return Collection<int, EstudianteCursoRol>
  226. */
  227. public function getEstudianteCursoRols(): Collection
  228. {
  229. return $this->estudianteCursoRols;
  230. }
  231. public function addEstudianteCursoRol(EstudianteCursoRol $estudianteCursoRol): self
  232. {
  233. if (!$this->estudianteCursoRols->contains($estudianteCursoRol)) {
  234. $this->estudianteCursoRols[] = $estudianteCursoRol;
  235. $estudianteCursoRol->setEstudiante($this);
  236. }
  237. return $this;
  238. }
  239. public function removeEstudianteCursoRol(EstudianteCursoRol $estudianteCursoRol): self
  240. {
  241. if ($this->estudianteCursoRols->removeElement($estudianteCursoRol)) {
  242. // set the owning side to null (unless already changed)
  243. if ($estudianteCursoRol->getEstudiante() === $this) {
  244. $estudianteCursoRol->setEstudiante(null);
  245. }
  246. }
  247. return $this;
  248. }
  249. /**
  250. * @return Collection<int, TareaEstudiante>
  251. */
  252. public function getTareaEstudiantes(): Collection
  253. {
  254. return $this->tareaEstudiantes;
  255. }
  256. public function addTareaEstudiante(TareaEstudiante $tareaEstudiante): self
  257. {
  258. if (!$this->tareaEstudiantes->contains($tareaEstudiante)) {
  259. $this->tareaEstudiantes[] = $tareaEstudiante;
  260. $tareaEstudiante->setEstudiante($this);
  261. }
  262. return $this;
  263. }
  264. public function removeTareaEstudiante(TareaEstudiante $tareaEstudiante): self
  265. {
  266. if ($this->tareaEstudiantes->removeElement($tareaEstudiante)) {
  267. // set the owning side to null (unless already changed)
  268. if ($tareaEstudiante->getEstudiante() === $this) {
  269. $tareaEstudiante->setEstudiante(null);
  270. }
  271. }
  272. return $this;
  273. }
  274. /**
  275. * @return Collection<int, EstudianteCursoNotaFinal>
  276. */
  277. public function getEstudianteCursoNotaFinals(): Collection
  278. {
  279. return $this->estudianteCursoNotaFinals;
  280. }
  281. public function addEstudianteCursoNotaFinal(EstudianteCursoNotaFinal $estudianteCursoNotaFinal): self
  282. {
  283. if (!$this->estudianteCursoNotaFinals->contains($estudianteCursoNotaFinal)) {
  284. $this->estudianteCursoNotaFinals[] = $estudianteCursoNotaFinal;
  285. $estudianteCursoNotaFinal->setEstudiante($this);
  286. }
  287. return $this;
  288. }
  289. public function removeEstudianteCursoNotaFinal(EstudianteCursoNotaFinal $estudianteCursoNotaFinal): self
  290. {
  291. if ($this->estudianteCursoNotaFinals->removeElement($estudianteCursoNotaFinal)) {
  292. // set the owning side to null (unless already changed)
  293. if ($estudianteCursoNotaFinal->getEstudiante() === $this) {
  294. $estudianteCursoNotaFinal->setEstudiante(null);
  295. }
  296. }
  297. return $this;
  298. }
  299. public function getNotaFinalCurso(Curso $curso, NotaFinal $notaFinal){
  300. }
  301. public function getFichaEstudiantil(): ?FichaEstudiantil
  302. {
  303. return $this->fichaEstudiantil;
  304. }
  305. public function setFichaEstudiantil(?FichaEstudiantil $fichaEstudiantil): self
  306. {
  307. // unset the owning side of the relation if necessary
  308. if ($fichaEstudiantil === null && $this->fichaEstudiantil !== null) {
  309. $this->fichaEstudiantil->setEstudiante(null);
  310. }
  311. // set the owning side of the relation if necessary
  312. if ($fichaEstudiantil !== null && $fichaEstudiantil->getEstudiante() !== $this) {
  313. $fichaEstudiantil->setEstudiante($this);
  314. }
  315. $this->fichaEstudiantil = $fichaEstudiantil;
  316. return $this;
  317. }
  318. }