From 758b9991d539ebc7611a04d82a6c8c3ec675a0a9 Mon Sep 17 00:00:00 2001 From: cris-technikum Date: Wed, 19 May 2021 16:18:04 +0200 Subject: [PATCH] Added Antragssperre for Noten, when STGL wants to create Anrechnung Added check, if LV was already graded and if grades are defined in configs 'blocking grades array'. If so, Anrechnung is not allowed. Signed-off-by: cris-technikum --- .../lehre/anrechnung/CreateAnrechnung.php | 37 +++++++++++++++++++ system/phrasesupdate.php | 20 ++++++++++ 2 files changed, 57 insertions(+) diff --git a/application/controllers/lehre/anrechnung/CreateAnrechnung.php b/application/controllers/lehre/anrechnung/CreateAnrechnung.php index 1b52dddf5..bc594371d 100644 --- a/application/controllers/lehre/anrechnung/CreateAnrechnung.php +++ b/application/controllers/lehre/anrechnung/CreateAnrechnung.php @@ -47,6 +47,9 @@ class CreateAnrechnung extends Auth_Controller ) ); + // Load configs + $this->load->config('anrechnung'); + $this->_setAuthUID(); $this->setControllerId(); @@ -140,6 +143,12 @@ class CreateAnrechnung extends Auth_Controller $this->terminateWithJsonError($this->p->t('global', 'antragBereitsGestellt')); } + // Exit if Lehrveranstaltung was already graded with application blocking grades + if (self::_LVhasBlockingGrades($studiensemester_kurzbz, $lehrveranstaltung_id, $prestudent_id)) + { + $this->terminateWithJsonError($this->p->t('anrechnung', 'antragBenotungBlockiert')); + } + // Upload document $result = self::_uploadFile(); @@ -231,4 +240,32 @@ class CreateAnrechnung extends Auth_Controller return $this->dmslib->upload($dms, 'uploadfile', array('pdf')); } + private function _LVhasBlockingGrades($studiensemester_kurzbz, $lehrveranstaltung_id, $prestudent_id) + { + // Get Student UID + $student_uid = $this->StudentModel->getUID($prestudent_id); + + // Get Note of Lehrveranstaltung + $this->load->model('education/Lvgesamtnote_model', 'LvgesamtnoteModel'); + $result = $this->LvgesamtnoteModel->load(array( + 'student_uid' => $student_uid, + 'studiensemester_kurzbz' => $studiensemester_kurzbz, + 'lehrveranstaltung_id' => $lehrveranstaltung_id + ) + ); + + // If Lehrveranstaltung has Note + if (hasData($result)) + { + $note = getData($result)[0]->note; + + // Check if Note is a blocking grade + if (in_array($note, $this->config->item('grades_blocking_application'))) + { + return true; + } + } + return false; + } + } \ No newline at end of file diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index c1f96974c..3326f81f9 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -12232,6 +12232,26 @@ array( ) ) ), + array( + 'app' => 'core', + 'category' => 'anrechnung', + 'phrase' => 'antragBenotungBlockiert', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => "Antrag kann aufgrund der vorhandenen Benotung nicht erstellt werden.", + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => "Application can not be created due to existing grade.", + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), );