From 7747857583cbecf1b601017c4343113445bf92d2 Mon Sep 17 00:00:00 2001 From: Johann Hoffmann Date: Tue, 2 Dec 2025 16:07:26 +0100 Subject: [PATCH] AbgabetoolStudent beurteilung erstbetreuer/zweitbetreuer switch + get the actual link from the projektarbeitsbeurteilung extension via event 'projektbeurteilung_download_link' + fallback from config in case that fails; WIP implementing the switch for lektor beurteilungstemplate based on isCurrent/Semester etc in an Event in the pabu extension; --- application/config/abgabe.php | 4 +- .../controllers/api/frontend/v1/Abgabe.php | 69 ++++++++++++++++++- .../Cis/Abgabetool/AbgabetoolStudent.js | 19 ++--- system/phrasesupdate.php | 26 ++++++- 4 files changed, 99 insertions(+), 19 deletions(-) diff --git a/application/config/abgabe.php b/application/config/abgabe.php index 6a91a4d12..64cffbd30 100644 --- a/application/config/abgabe.php +++ b/application/config/abgabe.php @@ -15,4 +15,6 @@ $config['URL_MITARBEITER'] = 'index.ci.php/Cis/Abgabetool/Mitarbeiter'; // lehre.tbl_paabgabetyp bezeichnung $config['ALLOWED_ABGABETYPEN_BETREUER'] = ['Zwischenabgabe', 'Quality Gate 1', 'Quality Gate 2']; -$config['ALLOWED_NOTEN_ABGABETOOL'] = ['Bestanden', 'Nicht bestanden']; \ No newline at end of file +$config['ALLOWED_NOTEN_ABGABETOOL'] = ['Bestanden', 'Nicht bestanden']; + +$config['beurteilung_link_fallback'] = 'addons/fhtw/content/projektbeurteilung/projektbeurteilungDocumentExport.php?projektarbeit_id=?&betreuerart_kurzbz=?&person_id=?'; \ No newline at end of file diff --git a/application/controllers/api/frontend/v1/Abgabe.php b/application/controllers/api/frontend/v1/Abgabe.php index 708f7f692..4a0e6dea7 100644 --- a/application/controllers/api/frontend/v1/Abgabe.php +++ b/application/controllers/api/frontend/v1/Abgabe.php @@ -18,6 +18,8 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); +use CI3_Events as Events; + class Abgabe extends FHCAPI_Controller { @@ -80,7 +82,6 @@ class Abgabe extends FHCAPI_Controller * loads config related to abgabetool, found in application/config/abgabe */ public function getConfig() { - $this->load->config('abgabe'); $old_abgabe_beurteilung_link =$this->config->item('old_abgabe_beurteilung_link'); $turnitin_link = $this->config->item('turnitin_link'); $abgabetypenBetreuer = $this->config->item('ALLOWED_ABGABETYPEN_BETREUER'); @@ -152,6 +153,38 @@ class Abgabe extends FHCAPI_Controller if(count($projektarbeiten)) { foreach($projektarbeiten as $pa) { + + if($pa->babgeschickt) { + $downloadLink1 = ''; + $downloadLinkFunc1 = function ($link) use (&$downloadLink1) { + $downloadLink1 = $link; + }; + + Events::trigger('projektbeurteilung_download_link', $pa->projektarbeit_id, $pa->betreuerart_kurzbz, $pa->bperson_id, $downloadLinkFunc1); + + // use config fallback in case the event fails + if($downloadLink1 == '') { + $fallback = $this->config->item('beurteilung_link_fallback'); + + $search = array( + 'betreuerart_kurzbz=?', + 'projektarbeit_id=?', + 'person_id=?' + ); + + $replace = array( + 'betreuerart_kurzbz=' . $pa->betreuerart_kurzbz, + 'projektarbeit_id=' . $pa->projektarbeit_id, + 'person_id=' . $pa->bperson_id + ); + + $fallback = str_replace($search, $replace, $fallback); + $downloadLink1 = APP_ROOT.$fallback; + + } + $pa->downloadLink1 = $downloadLink1; + } + $result = $this->ProjektarbeitModel->getProjektbetreuerEmail($pa->projektarbeit_id); $data = getData($result); @@ -159,6 +192,39 @@ class Abgabe extends FHCAPI_Controller $pa->email = $data[0]->private_email; } if($pa->zweitbetreuer_person_id !== null) { + + if($pa->zweitbetreuer_abgeschickt) { + $downloadLink2 = ''; + $downloadLinkFunc2 = function ($link) use (&$downloadLink2) { + $downloadLink2 = $link; + }; + + Events::trigger('projektbeurteilung_download_link', $pa->projektarbeit_id, $pa->zweitbetreuer_betreuerart_kurzbz, $pa->zweitbetreuer_person_id, $downloadLinkFunc2); + + // use config fallback in case the event fails + if($downloadLink2 == '') { + $fallback = $this->config->item('beurteilung_link_fallback'); + + $search = array( + 'betreuerart_kurzbz=?', + 'projektarbeit_id=?', + 'person_id=?' + ); + + $replace = array( + 'betreuerart_kurzbz=' . $pa->zweitbetreuer_betreuerart_kurzbz, + 'projektarbeit_id=' . $pa->projektarbeit_id, + 'person_id=' . $pa->zweitbetreuer_person_id + ); + + $fallback = str_replace($search, $replace, $fallback); + $downloadLink2 = APP_ROOT.$fallback; + + } + + $pa->downloadLink2 = $downloadLink2; + } + // TODO: see assistenz query in projektarbeit_model @@ -1026,4 +1092,5 @@ class Abgabe extends FHCAPI_Controller } } } + } \ No newline at end of file diff --git a/public/js/components/Cis/Abgabetool/AbgabetoolStudent.js b/public/js/components/Cis/Abgabetool/AbgabetoolStudent.js index 1c9dae63c..774f089c8 100644 --- a/public/js/components/Cis/Abgabetool/AbgabetoolStudent.js +++ b/public/js/components/Cis/Abgabetool/AbgabetoolStudent.js @@ -223,15 +223,6 @@ export const AbgabetoolStudent = { this.projektarbeiten = projektarbeiten.map(projekt => { let mode = 'detailTermine' - if (projekt.babgeschickt || projekt.zweitbetreuer_abgeschickt) { - // mode = 'beurteilungDownload' // build dl link for both betreuer documents - - // TODO: if switch zweitbetreuer beurteilung / erstbetreuer beurteilung download - projekt.beurteilungLink1 = FHC_JS_DATA_STORAGE_OBJECT.app_root + 'cis/private/pdfExport.php?xml=projektarbeitsbeurteilung.xml.php&xsl=Projektbeurteilung&betreuerart_kurzbz='+projekt.betreuerart_kurzbz+'&projektarbeit_id='+projekt.projektarbeit_id+'&person_id=' + projekt.bperson_id - if(projekt.zweitbetreuer_abgeschickt && projekt.zweitbetreuer_betreuerart_kurzbz && projekt.zweitbetreuer_person_id) { - projekt.beurteilungLink2 = FHC_JS_DATA_STORAGE_OBJECT.app_root + 'cis/private/pdfExport.php?xml=projektarbeitsbeurteilung.xml.php&xsl=Projektbeurteilung&betreuerart_kurzbz='+projekt.zweitbetreuer_betreuerart_kurzbz+'&projektarbeit_id='+projekt.projektarbeit_id+'&person_id=' + projekt.zweitbetreuer_person_id - } - } return { ...projekt, @@ -242,8 +233,8 @@ export const AbgabetoolStudent = { betreuerart_kurzbz: projekt.betreuerart_kurzbz, mode }, - beurteilung1: projekt.beurteilungLink1 ?? null, - beurteilung2: projekt.beurteilungLink2 ?? null, + beurteilung1: projekt.downloadLink1 ?? null, + beurteilung2: projekt.downloadLink2 ?? null, sem: projekt.studiensemester_kurzbz, stg: projekt.kurzbzlang, mail: this.buildMailToLink(projekt), @@ -378,11 +369,11 @@ export const AbgabetoolStudent = {
{{$capitalize( $p.t('abgabetool/c4beurteilung') )}}
{{$capitalize( $p.t('abgabetool/c4nobeurteilungVorhanden') )}} -
diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index ab93b2234..bf5267e1c 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -44096,18 +44096,38 @@ array( array( 'app' => 'core', 'category' => 'abgabetool', - 'phrase' => 'c4downloadBeurteilung', + 'phrase' => 'c4downloadBeurteilungErstbetreuer', 'insertvon' => 'system', 'phrases' => array( array( 'sprache' => 'German', - 'text' => "Beurteilung herunterladen", + 'text' => "Erstbetreuer Beurteilung herunterladen", 'description' => '', 'insertvon' => 'system' ), array( 'sprache' => 'English', - 'text' => 'Download Evaluation', + 'text' => 'Download evaluation of first assesor', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'abgabetool', + 'phrase' => 'c4downloadBeurteilungZweitbetreuer', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => "Zweitbetreuer Beurteilung herunterladen", + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Download evaluation of second assesor', 'description' => '', 'insertvon' => 'system' )