From 24ff474caddb7b47eee90b1411e4da3a044ed41f Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Thu, 12 Dec 2024 13:31:06 +0100 Subject: [PATCH] update(MyLv/Lv.js):the user can only click on the grade of an lv if the lv had multiple pruefungen otherwise the grade is not clickable --- .../controllers/api/frontend/v1/Lehre.php | 18 +++++++ public/js/api/lehre.js | 6 +++ .../Cis/Mylv/Semester/Studiengang/Lv.js | 50 ++++++++++++------- .../Semester/Studiengang/Lv/Pruefungen.js | 17 ++----- 4 files changed, 59 insertions(+), 32 deletions(-) diff --git a/application/controllers/api/frontend/v1/Lehre.php b/application/controllers/api/frontend/v1/Lehre.php index c25dc1986..f079a5b37 100644 --- a/application/controllers/api/frontend/v1/Lehre.php +++ b/application/controllers/api/frontend/v1/Lehre.php @@ -30,6 +30,7 @@ class Lehre extends FHCAPI_Controller parent::__construct([ 'lvStudentenMail' => self::PERM_LOGGED, 'LV' => self::PERM_LOGGED, + 'Pruefungen' => self::PERM_LOGGED, ]); @@ -76,6 +77,23 @@ class Lehre extends FHCAPI_Controller $this->terminateWithSuccess($result); } + + /** + * fetches all Pruefungen of a student for a specific lehrveranstaltung + * if the student passed the Pruefung on the first attempt, no information about the Pruefungen is stored in the database + * @param mixed $lehrveranstaltung_id + * @return void + */ + public function Pruefungen($lehrveranstaltung_id) + { + $this->load->model('education/Pruefung_model', 'PruefungModel'); + + $result = $this->PruefungModel->getByStudentAndLv(getAuthUID(), $lehrveranstaltung_id, getUserLanguage()); + + $result = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($result); + } diff --git a/public/js/api/lehre.js b/public/js/api/lehre.js index 743439722..cd7129d61 100644 --- a/public/js/api/lehre.js +++ b/public/js/api/lehre.js @@ -13,4 +13,10 @@ export default { , {} ); }, + getStudentPruefungen(lehrveranstaltung_id){ + return this.$fhcApi.get( + `/api/frontend/v1/Lehre/Pruefungen/${lehrveranstaltung_id}` + , {} + ); + } } \ No newline at end of file diff --git a/public/js/components/Cis/Mylv/Semester/Studiengang/Lv.js b/public/js/components/Cis/Mylv/Semester/Studiengang/Lv.js index dcc18bbb0..36dcda331 100644 --- a/public/js/components/Cis/Mylv/Semester/Studiengang/Lv.js +++ b/public/js/components/Cis/Mylv/Semester/Studiengang/Lv.js @@ -32,7 +32,7 @@ export default { }, data: () => { return { - pruefungen: null, + pruefungenData: null, info: null, menu: null, preselectedMenuItem: null, @@ -47,7 +47,10 @@ export default { }, grade() { return this.benotung ? this.znote || this.lvnote || null : null; - } + }, + LvHasPruefungenInformation(){ + return this.pruefungenData && this.pruefungenData.length > 0; + }, }, methods: { c4_link(menuItem) { @@ -72,13 +75,13 @@ export default { } }, openPruefungen() { - if (!this.pruefungen) { - this.pruefungen = true; - LvPruefungen.popup({ - lehrveranstaltung_id: this.lehrveranstaltung_id, - bezeichnung: this.bezeichnung - }).then(() => this.pruefungen = false).catch(() => this.pruefungen = false); - } + // early return if the pruefungenData is empty or not set + if (!this.LvHasPruefungenInformation) return; + + LvPruefungen.popup({ + pruefungenData: this.pruefungenData, + bezeichnung: this.bezeichnung + }); }, openInfos() { if (!this.info) { @@ -107,6 +110,14 @@ export default { .catch((error) => this.$fhcAlert.handleSystemError); } }, + created(){ + this.$fhcApi.factory.lehre.getStudentPruefungen(this.lehrveranstaltung_id) + .then(res => res.data) + .then(pruefungen =>{ + this.pruefungenData = pruefungen; + }); + + }, mounted() { this.$fhcApi.factory.addons.getLvMenu(this.lehrveranstaltung_id, this.studien_semester) .then(res => { @@ -153,17 +164,18 @@ export default { ` diff --git a/public/js/components/Cis/Mylv/Semester/Studiengang/Lv/Pruefungen.js b/public/js/components/Cis/Mylv/Semester/Studiengang/Lv/Pruefungen.js index b41b58664..d2d1a240a 100644 --- a/public/js/components/Cis/Mylv/Semester/Studiengang/Lv/Pruefungen.js +++ b/public/js/components/Cis/Mylv/Semester/Studiengang/Lv/Pruefungen.js @@ -10,7 +10,7 @@ export default { BsModal ], props: { - lehrveranstaltung_id: Number, + pruefungenData: Array|null, bezeichnung: String, /* * NOTE(chris): @@ -26,16 +26,7 @@ export default { }, data: () => ({ result: true, - pruefungen: null }), - created() { - if (pruefungen[this.lehrveranstaltung_id]) - this.pruefungen = pruefungen[this.lehrveranstaltung_id]; - else - axios.get(FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/components/Cis/Mylv/Pruefungen/' + this.lehrveranstaltung_id).then(res => { - this.pruefungen = pruefungen[this.lehrveranstaltung_id] = res.data.retval || []; - }); - }, mounted() { this.modal = this.$refs.modalContainer.modal; }, @@ -47,10 +38,10 @@ export default { Prüfungen: {{bezeichnung}}