From 954c55ba3ea899a11f3ddd6d19a22f8fcb7682e4 Mon Sep 17 00:00:00 2001 From: Johann Hoffmann Date: Mon, 12 Jan 2026 17:06:35 +0100 Subject: [PATCH] finetuning --- .../controllers/api/frontend/v1/Abgabe.php | 53 +++++++++++-------- .../models/education/Projektarbeit_model.php | 15 +++++- application/views/Cis/Abgabetool.php | 6 +-- public/js/api/factory/abgabe.js | 4 +- public/js/apps/Abgabetool/Abgabetool.js | 2 +- .../Cis/Abgabetool/AbgabeMitarbeiterDetail.js | 31 ++--------- .../Cis/Abgabetool/AbgabeStudentDetail.js | 20 +------ .../Cis/Abgabetool/AbgabetoolStudent.js | 2 +- system/phrasesupdate.php | 22 +++++++- 9 files changed, 77 insertions(+), 78 deletions(-) diff --git a/application/controllers/api/frontend/v1/Abgabe.php b/application/controllers/api/frontend/v1/Abgabe.php index dc859f605..847df2c12 100644 --- a/application/controllers/api/frontend/v1/Abgabe.php +++ b/application/controllers/api/frontend/v1/Abgabe.php @@ -592,41 +592,32 @@ class Abgabe extends FHCAPI_Controller */ public function deleteProjektarbeitAbgabe() { $paabgabe_id = $this->input->post('paabgabe_id'); - $projektarbeit_id = $this->input->post('projektarbeit_id'); - if ($paabgabe_id === NULL || trim((string)$paabgabe_id) === '' - || $projektarbeit_id === NULL || trim((string)$projektarbeit_id) === '') { + if ($paabgabe_id === NULL || trim((string)$paabgabe_id) === '') { $this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general'); } - $zugeordnet = $this->checkZuordnung($projektarbeit_id, getAuthUID()); + $zugeordnet = $this->checkZuordnungByPaabgabe($paabgabe_id, getAuthUID()); if(!$zugeordnet) { $this->terminateWithError($this->p->t('abgabetool', 'c4noZuordnungBetreuerStudent')); } - - // TODO: check zuordnung paabgabe_id / projektarbeit_id - - $this->load->model('education/Paabgabe_model', 'PaabgabeModel'); + $this->load->model('education/Paabgabe_model', 'PaabgabeModel'); + $paabgabeResult = $this->PaabgabeModel->load($paabgabe_id); $paabgabeArr = $this->getDataOrTerminateWithError($paabgabeResult); - if(count($paabgabeArr) == 0) + if(count($paabgabeArr) == 0) { $this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general'); - - // TODO: diese prüfung entfernen - if($paabgabeArr[0]->insertvon === getAuthUID()) { - $result = $this->PaabgabeModel->delete($paabgabe_id); - $result = $this->getDataOrTerminateWithError($result); - - // TODO: consider this in nightly email job - - $this->logLib->logInfoDB(array($paabgabeArr[0], getAuthUID(), getAuthPersonId())); - $this->terminateWithSuccess($result); } + + $result = $this->PaabgabeModel->delete($paabgabe_id); + $result = $this->getDataOrTerminateWithError($result); - $this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general'); + // TODO: consider this in nightly email job + $this->logLib->logInfoDB(array($paabgabeArr[0], getAuthUID(), getAuthPersonId())); + $this->terminateWithSuccess($result); } /** @@ -660,7 +651,6 @@ class Abgabe extends FHCAPI_Controller // old script afterwards again queries if user is not the zweitbetreuer of any id - this is blocked in the ui // and should never unintentionally happen - $this->load->model('education/Paabgabe_model', 'PaabgabeModel'); $this->load->model('education/Projektarbeit_model', 'ProjektarbeitModel'); @@ -746,7 +736,8 @@ class Abgabe extends FHCAPI_Controller //TODO: check if private mail exists, if not take uid@domain - return $email[0]->private_email; + return $email[0]->private_email ?? $email[0]->uid.'@'.DOMAIN; + } //TODO: SWITCH TO NOTEN API ONCE NOTENTOOL IS IN MASTER TO AVOID DUPLICATE API @@ -1002,7 +993,7 @@ class Abgabe extends FHCAPI_Controller if($abgabe->paabgabetyp_kurzbz != 'end') { return; } - + $path = PAABGABE_PATH.$abgabe->paabgabe_id.'_'.$projektarbeit->student_uid.'.pdf'; $signaturVorhanden = null; // if frontend receives null -> indicates no file found at path @@ -1223,5 +1214,21 @@ class Abgabe extends FHCAPI_Controller return false; } + + private function checkZuordnungByPaabgabe($paabgabe_id, $betreuer_uid) { + $this->load->model('education/Projektarbeit_model', 'ProjektarbeitModel'); + $res = $this->ProjektarbeitModel->getProjektarbeitByPaabgabeID($paabgabe_id); + if(isError($res)) { + $this->terminateWithError($this->p->t('abgabetool', 'c4errorLoadingProjektarbeitForPaabgabeID')); + } + + if(!hasData($res)) { + $this->terminateWithError($this->p->t('abgabetool', 'c4noAssignedProjektarbeitForPaabgabeID')); + } + $data = getData($res)[0]; + $projektarbeit_id = $data->projektarbeit_id; + + return $this->checkZuordnung($projektarbeit_id, $betreuer_uid); + } } \ No newline at end of file diff --git a/application/models/education/Projektarbeit_model.php b/application/models/education/Projektarbeit_model.php index ea16b5587..e9208e51d 100644 --- a/application/models/education/Projektarbeit_model.php +++ b/application/models/education/Projektarbeit_model.php @@ -233,7 +233,7 @@ class Projektarbeit_model extends DB_Model CASE WHEN zustellung THEN 0 ELSE 1 END, insertamum DESC NULLS LAST LIMIT 1 - ) AS private_email + ) AS private_email, mitarbeiter_uid as uid FROM lehre.tbl_projektarbeit pa JOIN lehre.tbl_projektbetreuer USING (projektarbeit_id) JOIN public.tbl_person pers USING (person_id) @@ -463,4 +463,17 @@ class Projektarbeit_model extends DB_Model return false; } + + public function getProjektarbeitByPaabgabeID($paabgabe_id) { + $qry = "SELECT + projektarbeit_id + FROM + campus.tbl_paabgabe + JOIN lehre.tbl_projektarbeit USING(projektarbeit_id) + WHERE + campus.tbl_paabgabe.paabgabe_id = ?; + "; + + return $this->execReadOnlyQuery($qry, [$paabgabe_id]); + } } diff --git a/application/views/Cis/Abgabetool.php b/application/views/Cis/Abgabetool.php index 416f626e6..480116290 100644 --- a/application/views/Cis/Abgabetool.php +++ b/application/views/Cis/Abgabetool.php @@ -38,9 +38,9 @@ $includesArray = array( $this->load->view('templates/FHC-Header', $includesArray); ?>
- uid= student_uid_prop= - stg_kz_prop= + uid= + student_uid_prop="" + stg_kz_prop="" > -
load->view('templates/FHC-Footer', $includesArray); ?> diff --git a/public/js/api/factory/abgabe.js b/public/js/api/factory/abgabe.js index 950f23ea9..be03c9728 100644 --- a/public/js/api/factory/abgabe.js +++ b/public/js/api/factory/abgabe.js @@ -71,11 +71,11 @@ export default { } }; }, - deleteProjektarbeitAbgabe(paabgabe_id, projektarbeit_id) { + deleteProjektarbeitAbgabe(paabgabe_id) { return { method: 'post', url: '/api/frontend/v1/Abgabe/deleteProjektarbeitAbgabe', - params: { paabgabe_id, projektarbeit_id } + params: { paabgabe_id } }; }, postSerientermin(datum, paabgabetyp_kurzbz, bezeichnung, kurzbz, upload_allowed, projektarbeit_ids, fixtermin) { diff --git a/public/js/apps/Abgabetool/Abgabetool.js b/public/js/apps/Abgabetool/Abgabetool.js index d1c3e134c..83233ba22 100644 --- a/public/js/apps/Abgabetool/Abgabetool.js +++ b/public/js/apps/Abgabetool/Abgabetool.js @@ -29,7 +29,7 @@ const app = Vue.createApp({ return { uid: this.uid} }, student_uid_computed() { - return this.student_uid ?? null + return this.student_uid ?? this.uid }, stg_kz_computed() { return this.stg_kz ?? null diff --git a/public/js/components/Cis/Abgabetool/AbgabeMitarbeiterDetail.js b/public/js/components/Cis/Abgabetool/AbgabeMitarbeiterDetail.js index edea46535..32e763eb1 100644 --- a/public/js/components/Cis/Abgabetool/AbgabeMitarbeiterDetail.js +++ b/public/js/components/Cis/Abgabetool/AbgabeMitarbeiterDetail.js @@ -40,7 +40,6 @@ export const AbgabeMitarbeiterDetail = { }, data() { return { - activeIndexArray: null, showAutomagicModalPhrase: false, eidAkzeptiert: false, enduploadTermin: null, @@ -79,25 +78,6 @@ export const AbgabeMitarbeiterDetail = { } }, methods: { - getActiveIndexTabArray(additional = []) { - // here we try to assume which abgabetermine are the most relevant to the current user - - // lets try to take the termin with nearest date - let closestIndex = -1; - let minDiff = Infinity; - const today = new Date(); - - - this.projektarbeit.abgabetermine.forEach((obj, i) => { - const diff = Math.abs(new Date(obj.datum) - today); - if (diff < minDiff) { - minDiff = diff; - closestIndex = i; - } - }); - - return [closestIndex, ...additional] - }, getPlaceholderTermin(termin) { return termin?.bezeichnung ? this.$p.t('abgabetool/c4paatyp' + termin.paabgabetyp_kurzbz) : this.$p.t('abgabetool/abgabetypPlaceholder') }, @@ -143,7 +123,6 @@ export const AbgabeMitarbeiterDetail = { this.projektarbeit.abgabetermine.sort((a, b) =>new Date(a.datum) - new Date(b.datum)) const index = this.projektarbeit.abgabetermine.findIndex(t => termin.paabgabe_id == t.paabgabe_id) - this.activeIndexArray = this.getActiveIndexTabArray([index]) // negative abgabe -> automagically open new termin modal // really bad feature imo that will be annoying to deal with @@ -255,7 +234,7 @@ export const AbgabeMitarbeiterDetail = { } }, deleteTermin(termin) { - this.$api.call(ApiAbgabe.deleteProjektarbeitAbgabe(termin.paabgabe_id, this.projektarbeit.projektarbeit_id)).then( (res) => { + this.$api.call(ApiAbgabe.deleteProjektarbeitAbgabe(termin.paabgabe_id)).then( (res) => { if(res?.meta?.status == 'success') { this.$fhcAlert.alertSuccess(this.$p.t('ui/genericDeleted', [this.$p.t('abgabetool/abgabe')])) // this.$p.t('global/tooltipLektorDeleteKontrolle', [this.$entryParams.permissions.kontrolleDeleteMaxReach ]) @@ -372,7 +351,7 @@ export const AbgabeMitarbeiterDetail = { window.open(link, '_blank') } else if(this.projektarbeit?.abgabetermine.find(termin => termin.paabgabetyp_kurzbz == 'end' && termin.abgabedatum !== null) && this.projektarbeit?.beurteilungLinkOld) { if(await this.$fhcAlert.confirm({ - message: this.$p.t('abgabetool/c4aeltereParbeitBenoten'), + message: this.$p.t('abgabetool/c4aeltereParbeitBenotenv2'), acceptLabel: this.$capitalize(this.$p.t('abgabetool/c4AcceptAndProceed')), acceptClass: 'btn btn-danger', rejectLabel: this.$capitalize(this.$p.t('abgabetool/c4Cancel')), @@ -610,8 +589,6 @@ export const AbgabeMitarbeiterDetail = { 'projektarbeit'(newVal) { // set invertedFixtermin field for UI/UX purposes -> avoid double negation in text - this.activeIndexArray = this.getActiveIndexTabArray() - newVal?.abgabetermine?.forEach(termin => termin.invertedFixtermin = !termin.fixtermin) // default select german if projektarbeit sprache was null @@ -748,7 +725,7 @@ export const AbgabeMitarbeiterDetail = { - +