From c34144a4e8f0385d14637760151a1753e428dad5 Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Thu, 27 Jun 2024 15:09:09 +0200 Subject: [PATCH] creates sql query in the lehreinheit_model to query the studierenden Mail inside a lehrveranstaltung and creates the matching fhcapi methods / frontend/v1 api controllers --- .../controllers/api/frontend/v1/Lehre.php | 67 +++++++++++++++++++ .../models/education/Lehreinheit_model.php | 36 ++++++++++ application/views/CisHtml/Dashboard.php | 3 +- public/js/api/fhcapifactory.js | 2 + public/js/api/lehre.js | 10 +++ public/js/components/Cis/Mylv/LvUebersicht.js | 26 +++++-- public/js/components/Dashboard/Dashboard.js | 2 + .../components/DashboardWidget/Stundenplan.js | 11 +-- 8 files changed, 145 insertions(+), 12 deletions(-) create mode 100644 application/controllers/api/frontend/v1/Lehre.php create mode 100644 public/js/api/lehre.js diff --git a/application/controllers/api/frontend/v1/Lehre.php b/application/controllers/api/frontend/v1/Lehre.php new file mode 100644 index 000000000..95422142d --- /dev/null +++ b/application/controllers/api/frontend/v1/Lehre.php @@ -0,0 +1,67 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + + +class Lehre extends FHCAPI_Controller +{ + + /** + * Object initialization + */ + public function __construct() + { + parent::__construct([ + 'lvStudentenMail' => self::PERM_LOGGED, + ]); + + + + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * constructs the emails of the groups from a lehrveranstaltung + */ + public function lvStudentenMail() + { + $lehreinheit_id = $this->input->get("lehreinheit_id",TRUE); + + // return early if the required parameter is missing + if(!isset($lehreinheit_id)) + { + $this->terminateWithError('Missing required parameter', self::ERROR_TYPE_GENERAL); + } + + $this->load->model('education/Lehreinheit_model', 'LehreinheitModel'); + + $studentenMails = $this->LehreinheitModel->getStudentenMail($lehreinheit_id); + + $studentenMails = $this->getDataOrTerminateWithError($studentenMails); + + $this->terminateWithSuccess($studentenMails); + } + + + + +} + diff --git a/application/models/education/Lehreinheit_model.php b/application/models/education/Lehreinheit_model.php index 10c122b94..35281c8cc 100755 --- a/application/models/education/Lehreinheit_model.php +++ b/application/models/education/Lehreinheit_model.php @@ -113,4 +113,40 @@ class Lehreinheit_model extends DB_Model return $this->execQuery($query, array($lehreinheit_id)); } + + /** + * Gets emails of all Studierende in a lehrveranstaltung + * @param int $lehreinheit_id + * @return array + */ + public function getStudentenMail($lehreinheit_id) + { + + // logic used from cis_menu_lv.inc.php line 335 + return $this->execReadOnlyQuery(" + SELECT + CASE + WHEN gruppe_kurzbz !='' THEN LOWER(gruppe_kurzbz || '@' || ?) + ELSE LOWER(stg_typ || stg_kurzbz || semester || TRIM(verband) || TRIM(gruppe) || '@' || ?) + END AS mail + FROM + ( + SELECT + distinct vw_lehreinheit.studiensemester_kurzbz, vw_lehreinheit.stg_kurzbz, vw_lehreinheit.stg_typ, vw_lehreinheit.semester, + COALESCE(vw_lehreinheit.verband,'') as verband, COALESCE(vw_lehreinheit.gruppe,'') as gruppe, vw_lehreinheit.gruppe_kurzbz, tbl_gruppe.mailgrp + FROM campus.vw_lehreinheit + LEFT JOIN public.tbl_gruppe USING(gruppe_kurzbz) + WHERE + vw_lehreinheit.lehrveranstaltung_id= + (select distinct lehrveranstaltung_id from campus.vw_lehreinheit where lehreinheit_id=?) + AND + vw_lehreinheit.studiensemester_kurzbz = + (select distinct studiensemester_kurzbz from campus.vw_lehreinheit where lehreinheit_id=?) + AND (vw_lehreinheit.gruppe_kurzbz IS NULL OR + (vw_lehreinheit.gruppe_kurzbz IS NOT NULL AND tbl_gruppe.mailgrp = TRUE AND (SELECT COUNT(*) FROM public.tbl_benutzergruppe where gruppe_kurzbz = vw_lehreinheit.gruppe_kurzbz AND studiensemester_kurzbz = vw_lehreinheit.studiensemester_kurzbz) > 0)) + + + ) AS subquery + ",[DOMAIN,DOMAIN,$lehreinheit_id,$lehreinheit_id ]); + } } diff --git a/application/views/CisHtml/Dashboard.php b/application/views/CisHtml/Dashboard.php index 49db7ad7c..c2190620d 100755 --- a/application/views/CisHtml/Dashboard.php +++ b/application/views/CisHtml/Dashboard.php @@ -13,7 +13,8 @@ $this->load->view('templates/CISHTML-Header', $includesArray);

Dashboard


- +
load->view('templates/CISHTML-Footer', $includesArray); ?> diff --git a/public/js/api/fhcapifactory.js b/public/js/api/fhcapifactory.js index 31c6fe9ab..c2ba6b5da 100644 --- a/public/js/api/fhcapifactory.js +++ b/public/js/api/fhcapifactory.js @@ -22,6 +22,7 @@ import filter from "./filter.js"; import studstatus from "./studstatus.js"; import ort from "./ort.js"; import cms from "./cms.js"; +import lehre from "./lehre.js"; export default { search, @@ -31,4 +32,5 @@ export default { studstatus, ort, cms, + lehre, }; diff --git a/public/js/api/lehre.js b/public/js/api/lehre.js new file mode 100644 index 000000000..d3117948e --- /dev/null +++ b/public/js/api/lehre.js @@ -0,0 +1,10 @@ +export default { + getStudentenMail(lehreinheit_id) { + return this.$fhcApi.get( + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + "/api/frontend/v1/Lehre/lvStudentenMail", + { lehreinheit_id: lehreinheit_id } + ); + }, + } \ No newline at end of file diff --git a/public/js/components/Cis/Mylv/LvUebersicht.js b/public/js/components/Cis/Mylv/LvUebersicht.js index 964762698..1a5a3525d 100644 --- a/public/js/components/Cis/Mylv/LvUebersicht.js +++ b/public/js/components/Cis/Mylv/LvUebersicht.js @@ -2,7 +2,12 @@ import BsModal from "../../Bootstrap/Modal"; export default { - + props:{ + event:{ + type:Object, + required:true, + } + }, data(){ return { // reactive data @@ -14,25 +19,34 @@ export default { result: false, } }, - inject:["active_addons"], + inject:["active_addons","mail_studierende"], mixins:[BsModal], components:{ BsModal, }, + methods:{ + showModal: function(){ + + this.$fhcApi.factory.lehre.getStudentenMail(this.event.lehreinheit_id).then(res => + { + console.log(res.data,"API response"); + }); + }, + }, mounted(){ this.modal = this.$refs.modalContainer; }, - template:/*html*/` - +