diff --git a/application/controllers/api/frontend/v1/notiz/NotizAnrechnung.php b/application/controllers/api/frontend/v1/notiz/NotizAnrechnung.php index 30dae9a50..e3a5ec4ea 100644 --- a/application/controllers/api/frontend/v1/notiz/NotizAnrechnung.php +++ b/application/controllers/api/frontend/v1/notiz/NotizAnrechnung.php @@ -21,7 +21,7 @@ class NotizAnrechnung extends Notiz_Controller // Load language phrases $this->loadPhrases([ - 'ui' + 'ui', 'lehre' ]); } diff --git a/application/controllers/api/frontend/v1/stv/Anrechnungen.php b/application/controllers/api/frontend/v1/stv/Anrechnungen.php index 251e2d5bd..fef90a799 100644 --- a/application/controllers/api/frontend/v1/stv/Anrechnungen.php +++ b/application/controllers/api/frontend/v1/stv/Anrechnungen.php @@ -25,7 +25,7 @@ class Anrechnungen extends FHCAPI_Controller // Load language phrases $this->loadPhrases([ - 'ui', 'lehre' + 'ui', 'lehre', 'anrechnung' ]); // Load models @@ -45,6 +45,12 @@ class Anrechnungen extends FHCAPI_Controller { $this->load->model('education/Anrechnungbegruendung_model', 'AnrechnungbegrueundungsModel'); + // Begruendung in the users language, German name if no translation exists + $language_index = getUserLanguage() == 'German' ? 1 : 2; + $this->AnrechnungbegrueundungsModel->addSelect( + 'begruendung_id, COALESCE(bezeichnung_mehrsprachig[' . $language_index . '], bezeichnung) AS bezeichnung', + false + ); $result = $this->AnrechnungbegrueundungsModel->load(); if (isError($result)) { $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); @@ -118,22 +124,22 @@ class Anrechnungen extends FHCAPI_Controller : null; $this->form_validation->set_rules('lehrveranstaltung_id', 'Lehrveranstaltung_id', 'required', [ - 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Lehrveranstaltung']) + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('lehre', 'lehrveranstaltung')]) ]); $this->form_validation->set_rules('begruendung', 'Begruendung', 'required', [ - 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Begruendung']) + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('anrechnung', 'begruendung')]) ]); if($_POST['begruendung'] == 2) { $this->form_validation->set_rules('lehrveranstaltung_id_kompatibel', 'Lehrveranstaltung_id', 'required', [ - 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Lehrveranstaltung Kompatibel']) + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('anrechnung', 'lehrveranstaltung_bez_kompatibel')]) ]); } $this->form_validation->set_rules('genehmigtVon', 'GenehmigtVon', 'required', [ - 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'GenehmigtVon']) + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('anrechnung', 'genehmigtVon')]) ]); if ($this->form_validation->run() == false) @@ -190,22 +196,22 @@ class Anrechnungen extends FHCAPI_Controller $_POST['genehmigtVon'] = (isset($formData['genehmigt_von']) && !empty($formData['genehmigt_von'])) ? $formData['genehmigt_von'] : null; $this->form_validation->set_rules('lehrveranstaltung_id', 'Lehrveranstaltung_id', 'required', [ - 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Lehrveranstaltung']) + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('lehre', 'lehrveranstaltung')]) ]); $this->form_validation->set_rules('begruendung', 'Begruendung', 'required', [ - 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Begruendung']) + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('anrechnung', 'begruendung')]) ]); if($_POST['begruendung'] == 2) { $this->form_validation->set_rules('lehrveranstaltung_id_kompatibel', 'Lehrveranstaltung_id', 'required', [ - 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Lehrveranstaltung Kompatibel']) + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('anrechnung', 'lehrveranstaltung_bez_kompatibel')]) ]); } $this->form_validation->set_rules('genehmigtVon', 'GenehmigtVon', 'required', [ - 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'GenehmigtVon']) + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('anrechnung', 'genehmigtVon')]) ]); if ($this->form_validation->run() == false) diff --git a/application/controllers/lehre/anrechnung/CreateAnrechnung.php b/application/controllers/lehre/anrechnung/CreateAnrechnung.php index bc594371d..7532bbdd5 100644 --- a/application/controllers/lehre/anrechnung/CreateAnrechnung.php +++ b/application/controllers/lehre/anrechnung/CreateAnrechnung.php @@ -76,6 +76,13 @@ class CreateAnrechnung extends Auth_Controller // Get Anrechnungsbegruendungen $this->load->model('education/Anrechnungbegruendung_model', 'AnrechnungbegruendungModel'); + + // Begruendung in the users language, German name if no translation exists + $language_index = getUserLanguage() == 'German' ? 1 : 2; + $this->AnrechnungbegruendungModel->addSelect( + 'begruendung_id, COALESCE(bezeichnung_mehrsprachig[' . $language_index . '], bezeichnung) AS bezeichnung', + false + ); $begruendung_arr = getData($this->AnrechnungbegruendungModel->load()); $viewData = array( @@ -94,6 +101,12 @@ class CreateAnrechnung extends Auth_Controller { $prestudent_id = $this->input->post('prestudent_id'); $studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz'); + + // Exit if user has no permission for the Studiengang of the student + if (!$this->anrechnunglib->isBerechtigtForPrestudent(self::BERECHTIGUNG_ANRECHNUNG_ANLEGEN, 's', $prestudent_id)) + { + $this->terminateWithJsonError($this->p->t('ui', 'keineBerechtigung')); + } // Get Student UID $student_uid = $this->StudentModel->getUID($prestudent_id); @@ -136,6 +149,19 @@ class CreateAnrechnung extends Auth_Controller { $this->terminateWithJsonError($this->p->t('ui', 'errorFelderFehlen')); } + + // Exit if user has no write permission for the Studiengang of the student + if (!$this->anrechnunglib->isBerechtigtForPrestudent(self::BERECHTIGUNG_ANRECHNUNG_ANLEGEN, 'suid', $prestudent_id)) + { + $this->terminateWithJsonError($this->p->t('ui', 'keineBerechtigung')); + } + + // Exit if the Lehrveranstaltung is not one of the LVs the form offers for this student + $result = $this->LehrveranstaltungModel->getLvsByStudent($this->StudentModel->getUID($prestudent_id), $studiensemester_kurzbz); + if (!in_array($lehrveranstaltung_id, array_column(hasData($result) ? getData($result) : array(), 'lehrveranstaltung_id'))) + { + $this->terminateWithJsonError($this->p->t('anrechnung', 'lvNichtZugeteilt')); + } // Exit if application already exists if (self::_applicationExists($lehrveranstaltung_id, $studiensemester_kurzbz, $prestudent_id)) diff --git a/application/controllers/lehre/anrechnung/RequestAnrechnung.php b/application/controllers/lehre/anrechnung/RequestAnrechnung.php index ebc272e3e..d979dd264 100644 --- a/application/controllers/lehre/anrechnung/RequestAnrechnung.php +++ b/application/controllers/lehre/anrechnung/RequestAnrechnung.php @@ -88,6 +88,10 @@ class requestAnrechnung extends Auth_Controller // Get Anrechung data $anrechnungData = $this->anrechnunglib->getAnrechnungDataByLv($lehrveranstaltung_id, $studiensemester_kurzbz, $prestudent_id); + // Check if a new Antrag is for a Lehrveranstaltung outside the Studienplan (e.g. LV of a parallel study) + $is_not_in_studienplan = !is_numeric($anrechnungData->anrechnung_id) + && !hasData($this->LehrveranstaltungModel->getLvInStudienplan($prestudent_id, $lehrveranstaltung_id)); + // Get Antrag data $antragData = $this->anrechnunglib->getAntragData($prestudent_id, $studiensemester_kurzbz, $lehrveranstaltung_id, $anrechnungData->anrechnung_id); @@ -95,7 +99,8 @@ class requestAnrechnung extends Auth_Controller 'antragData' => $antragData, 'anrechnungData' => $anrechnungData, 'is_expired' => $is_expired, - 'is_blocked' => $is_blocked + 'is_blocked' => $is_blocked, + 'is_not_in_studienplan' => $is_not_in_studienplan ); $this->load->view('lehre/anrechnung/requestAnrechnung.php', $viewData); @@ -154,7 +159,7 @@ class requestAnrechnung extends Auth_Controller // Exit if application already exists if (self::_applicationExists($lehrveranstaltung_id, $studiensemester_kurzbz, $prestudent_id)) { - return $this->outputJsonError($this->p->t('anrechnung', 'antragBereitsGestellt')); + return $this->outputJsonError($this->p->t('global', 'antragBereitsGestellt')); } // Exit if application is a past ( < actual ) studysemester @@ -162,6 +167,30 @@ class requestAnrechnung extends Auth_Controller { return $this->outputJsonError($this->p->t('anrechnung', 'antragNichtFuerVerganganeSS')); } + + // Exit if student is not assigned to the Lehrveranstaltung + if (!hasData($this->LehrveranstaltungModel->getLvByStudent($this->_uid, $studiensemester_kurzbz, $lehrveranstaltung_id))) + { + return $this->outputJsonError($this->p->t('anrechnung', 'lvNichtZugeteilt')); + } + + // Exit if Lehrveranstaltung is not in the Studienplan of the student (e.g. LV of a parallel study) + if (!hasData($this->LehrveranstaltungModel->getLvInStudienplan($prestudent_id, $lehrveranstaltung_id))) + { + return $this->outputJsonError($this->p->t('anrechnung', 'lvNichtImStudienplan')); + } + + // Exit if application deadline is expired + if ($this->_isExpired($studiensemester_kurzbz)) + { + return $this->outputJsonError($this->p->t('anrechnung', 'deadlineUeberschritten')); + } + + // Exit if Lehrveranstaltung was already graded with application blocking grades + if (self::_LVhasBlockingGrades($studiensemester_kurzbz, $lehrveranstaltung_id)) + { + return $this->outputJsonError($this->p->t('anrechnung', 'antragBenotungBlockiert')); + } // Upload document $result = self::_uploadFile(); diff --git a/application/libraries/AnrechnungLib.php b/application/libraries/AnrechnungLib.php index d119d222c..b593ce6af 100644 --- a/application/libraries/AnrechnungLib.php +++ b/application/libraries/AnrechnungLib.php @@ -59,7 +59,7 @@ class AnrechnungLib // Load LV, but check if student is assigned to that LV. Break, if not. if(!$lv = getData($this->ci->LehrveranstaltungModel->getLvByStudent($uid, $studiensemester_kurzbz, $lv_id))[0]) { - show_error('You are not assigned to this course yet.'); + show_error($this->ci->p->t('anrechnung', 'lvNichtZugeteilt')); } } @@ -788,7 +788,7 @@ class AnrechnungLib $result = $this->ci->AnrechnungModel->load($anrechnung_id); if (!hasData($result)) { - showError('Anrechnung existiert nicht'); + show_error('Failed loading Anrechnung'); } // Get lectors of lehrveranstaltung diff --git a/application/models/education/Anrechnung_model.php b/application/models/education/Anrechnung_model.php index 0b81be80c..5ca4a5ae6 100644 --- a/application/models/education/Anrechnung_model.php +++ b/application/models/education/Anrechnung_model.php @@ -61,7 +61,7 @@ class Anrechnung_model extends DB_Model if ($this->db->trans_status() === false) { $this->db->trans_rollback(); - return error('Failed inserting Anrechnung', EXIT_ERROR); + return error($this->p->t('ui', 'fehlerBeimSpeichern'), EXIT_ERROR); } return success($lastInsert_anrechnung_id); @@ -166,7 +166,7 @@ class Anrechnung_model extends DB_Model // Get last Anrechnungstatus if (!$result = getData($this->AnrechnungModel->getLastAnrechnungstatus($anrechnung_id))[0]) { - return error('Failed loading Anrechnung'); + return error($this->p->t('ui', 'fehlerBeimLesen')); } $last_status = $result->status_kurzbz; @@ -175,7 +175,7 @@ class Anrechnung_model extends DB_Model // Exit, if last status is not approved / rejected if ($last_status != self::ANRECHNUNGSTATUS_APPROVED && $last_status != self::ANRECHNUNGSTATUS_REJECTED) { - return error('Nothing to withdraw. Application is still in progress'); + return error($this->p->t('anrechnung', 'keineGenehmigungZumZuruecknehmen')); } // Start DB transaction @@ -197,7 +197,7 @@ class Anrechnung_model extends DB_Model if ($this->db->trans_status() === false) { $this->db->trans_rollback(); - return error('Failed withdrawing Genehmigung', EXIT_ERROR); + return error($this->p->t('anrechnung', 'antragNichtZurueckgenommen'), EXIT_ERROR); } return success(); @@ -211,21 +211,31 @@ class Anrechnung_model extends DB_Model */ public function getAnrechnungsData($prestudent_id) { + // Names in the users language, German if no translation exists + $english = getUserLanguage() != 'German'; + $language_index = $english ? 2 : 1; + $lv_bezeichnung = $english + ? 'COALESCE(NULLIF(lehre.tbl_lehrveranstaltung.bezeichnung_english, \'\'), lehre.tbl_lehrveranstaltung.bezeichnung)' + : 'lehre.tbl_lehrveranstaltung.bezeichnung'; + $lv_comp_bezeichnung = $english + ? 'COALESCE(NULLIF(lv_comp.bezeichnung_english, \'\'), lv_comp.bezeichnung)' + : 'lv_comp.bezeichnung'; + $qry = ' SELECT lehre.tbl_anrechnung.anrechnung_id, lehre.tbl_anrechnung.prestudent_id, lehre.tbl_anrechnung.lehrveranstaltung_id, - lehre.tbl_lehrveranstaltung.bezeichnung AS bez_lehrveranstaltung, - lehre.tbl_anrechnung_begruendung.bezeichnung AS begruendung, - lehre.tbl_anrechnung_anrechnungstatus.status_kurzbz AS status, + ' . $lv_bezeichnung . ' AS bez_lehrveranstaltung, + COALESCE(lehre.tbl_anrechnung_begruendung.bezeichnung_mehrsprachig[' . $language_index . '], lehre.tbl_anrechnung_begruendung.bezeichnung) AS begruendung, + COALESCE(lehre.tbl_anrechnungstatus.bezeichnung_mehrsprachig[' . $language_index . '], lehre.tbl_anrechnung_anrechnungstatus.status_kurzbz) AS status, genehmigt_von, lehre.tbl_anrechnung.insertamum, lehre.tbl_anrechnung.insertvon, lehre.tbl_anrechnung.updateamum, lehre.tbl_anrechnung.updatevon, lehrveranstaltung_id_kompatibel, - lv_comp.bezeichnung as lehrveranstaltung_bez_kompatibel, + ' . $lv_comp_bezeichnung . ' as lehrveranstaltung_bez_kompatibel, count(nz.notizzuordnung_id) AS notizen_anzahl FROM lehre.tbl_anrechnung diff --git a/application/models/education/Anrechnungszeitraum_model.php b/application/models/education/Anrechnungszeitraum_model.php index e6f0f13d3..0a094c314 100644 --- a/application/models/education/Anrechnungszeitraum_model.php +++ b/application/models/education/Anrechnungszeitraum_model.php @@ -31,7 +31,7 @@ class Anrechnungszeitraum_model extends DB_Model if (isError($result)) { - return error('Fehler bei Anrechnungszeitraum speichern.'); + return error($this->p->t('ui', 'fehlerBeimSpeichern')); } // Return new anrechnungszeitraum_id @@ -50,7 +50,7 @@ class Anrechnungszeitraum_model extends DB_Model if (isError($result)) { - return error('Fehler bei Anrechnungszeitraum löschen.'); + return error($this->p->t('anrechnung', 'fehlerBeimLoeschen')); } return success($result->retval); @@ -78,7 +78,7 @@ class Anrechnungszeitraum_model extends DB_Model if (isError($result)) { - return error('Fehler bei Anrechnungszeitraum update.'); + return error($this->p->t('ui', 'fehlerBeimSpeichern')); } return success($result->retval); diff --git a/application/models/education/Lehrveranstaltung_model.php b/application/models/education/Lehrveranstaltung_model.php index ffa652cbc..27f32bb1e 100644 --- a/application/models/education/Lehrveranstaltung_model.php +++ b/application/models/education/Lehrveranstaltung_model.php @@ -658,6 +658,26 @@ class Lehrveranstaltung_model extends DB_Model return $this->execQuery($query, array($uid, $studiensemester_kurzbz, $lehrveranstaltung_id)); } + /** + * Gets the Lehrveranstaltung if it is in a Studienplan of the prestudent. + * Checks the Studienplaene of all statuses, because the status of a future semester can be missing. + * @param $prestudent_id + * @param $lehrveranstaltung_id + * @return array|null + */ + public function getLvInStudienplan($prestudent_id, $lehrveranstaltung_id) + { + $query = ' + SELECT DISTINCT spl.lehrveranstaltung_id + FROM public.tbl_prestudentstatus ps + JOIN lehre.tbl_studienplan_lehrveranstaltung spl USING (studienplan_id) + WHERE ps.prestudent_id = ? + AND spl.lehrveranstaltung_id = ?; + '; + + return $this->execQuery($query, array($prestudent_id, $lehrveranstaltung_id)); + } + /** * Get Lehreinheit. * diff --git a/application/views/lehre/anrechnung/approveAnrechnungUebersicht.php b/application/views/lehre/anrechnung/approveAnrechnungUebersicht.php index 758be8474..eb32918ca 100644 --- a/application/views/lehre/anrechnung/approveAnrechnungUebersicht.php +++ b/application/views/lehre/anrechnung/approveAnrechnungUebersicht.php @@ -141,7 +141,8 @@ if (defined("CIS4")) { + class="btn btn-outline-secondary col-auto">p->t('ui', 'anzeigen')); ?> + @@ -179,9 +180,11 @@ if (defined("CIS4")) {
p->t('anrechnung', 'antragStellenText'); ?>
-