From 367c266e2e74baa3d37515139081f01a518e88a5 Mon Sep 17 00:00:00 2001 From: KarpAlex Date: Thu, 29 Jul 2021 13:02:24 +0200 Subject: [PATCH] Zeugnisnote_model.php: added method getEctsSumsByPerson --- .../models/education/Zeugnisnote_model.php | 67 ++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/application/models/education/Zeugnisnote_model.php b/application/models/education/Zeugnisnote_model.php index 306f56e8c..2ccea3e53 100644 --- a/application/models/education/Zeugnisnote_model.php +++ b/application/models/education/Zeugnisnote_model.php @@ -14,7 +14,72 @@ class Zeugnisnote_model extends DB_Model } /** - * Gets Pruefungen of a person for a Studiensemester. + * Gets ECTS sums of completed courses (Zeugnisnoten) of a person for a Studiensemester. + * If no valid Noten for the course were entered, 0 ects is returned. + * @param int $person_id + * @param string $studiensemester_kurzbz + * @param bool $aktiv + * @param bool $lehre + * @param bool $offiziell + * @param bool $positiv + * @return object + */ + public function getEctsSumsByPerson($person_id, $studiensemester_kurzbz, $aktiv = true, $lehre = null, $offiziell = null, $positiv = null) + { + $params = array(); + + $qry = "SELECT DISTINCT ON (prst.prestudent_id) pers.matr_nr, stg.studiengang_kz, prst.prestudent_id, stg.erhalter_kz, + UPPER(stg.typ||stg.kurzbz) AS studiengang, stg.bezeichnung AS studiengang_bezeichnung, COALESCE(summen.summe_ects, 0) AS summe_ects + FROM public.tbl_person pers + JOIN public.tbl_prestudent prst USING (person_id) + JOIN public.tbl_prestudentstatus prstst USING (prestudent_id) + JOIN public.tbl_studiengang stg ON prst.studiengang_kz = stg.studiengang_kz + LEFT JOIN ( + SELECT zgnisnote.student_uid, prestudent_id, zgnisnote.studiensemester_kurzbz, sum(ects) AS summe_ects + FROM public.tbl_student + LEFT JOIN lehre.tbl_zeugnisnote zgnisnote USING(student_uid) + LEFT JOIN lehre.tbl_note note ON zgnisnote.note = note.note + LEFT JOIN lehre.tbl_lehrveranstaltung lv USING (lehrveranstaltung_id) + WHERE TRUE"; + + if (isset($aktiv)) + { + $qry .= ' AND (note.aktiv = ?)'; + $params[] = $aktiv; + } + + if (isset($lehre)) + { + $qry .= ' AND (note.lehre = ?)'; + $params[] = $lehre; + } + + if (isset($offiziell)) + { + $qry .= ' AND (note.offiziell = ?)'; + $params[] = $offiziell; + } + + if (isset($positiv)) + { + $qry .= ' AND (note.positiv = ?)'; + $params[] = $positiv; + } + + $qry .= " GROUP BY zgnisnote.studiensemester_kurzbz, zgnisnote.student_uid, prestudent_id + ) summen ON prst.prestudent_id = summen.prestudent_id AND prstst.studiensemester_kurzbz = summen.studiensemester_kurzbz + WHERE pers.person_id = ? + AND prstst.studiensemester_kurzbz = ? + ORDER BY prst.prestudent_id"; + + $params[] = $person_id; + $params[] = $studiensemester_kurzbz; + + return $this->execQuery($qry, $params); + } + + /** + * Gets courses (Zeugnisnoten) of a person for a Studiensemester. * @param int $person_id * @param string $studiensemester_kurzbz * @param bool $aktiv