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

This commit is contained in:
SimonGschnell
2024-06-27 15:09:09 +02:00
parent 5070353bf0
commit c34144a4e8
8 changed files with 145 additions and 12 deletions
@@ -0,0 +1,67 @@
<?php
/**
* Copyright (C) 2024 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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);
}
}
@@ -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 ]);
}
}
+2 -1
View File
@@ -13,7 +13,8 @@ $this->load->view('templates/CISHTML-Header', $includesArray);
<div id="content">
<h2>Dashboard</h2>
<hr>
<fhc-dashboard active_addons="<?php echo ACTIVE_ADDONS ?>" dashboard="CIS"/>
<fhc-dashboard active_addons="<?php echo ACTIVE_ADDONS ?>"
mail_studierende="<?php echo !defined('CIS_LEHRVERANSTALTUNG_MAILSTUDIERENDE_ANZEIGEN') || CIS_LEHRVERANSTALTUNG_MAILSTUDIERENDE_ANZEIGEN ?>" dashboard="CIS"/>
</div>
<?php $this->load->view('templates/CISHTML-Footer', $includesArray); ?>
+2
View File
@@ -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,
};
+10
View File
@@ -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 }
);
},
}
+20 -6
View File
@@ -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*/`
<bs-modal ref="modalContainer" dialogClass="modal-lg">
<bs-modal @showBsModal="showModal" ref="modalContainer" dialogClass="modal-lg">
<template #title>
<span v-if="lv ">
<p>{{JSON.stringify(event,null,2)}}</p>
<!--<span v-if="lv ">
{{lv + (stg?' / ' + stg:'')}}
</span>
<span v-else>
Lehrveranstaltungs Übersicht
</span>
</span>-->
</template>
<template #default>
<div :style="{'display':'grid', 'row-gap':'10px', 'column-gap':'10px', 'grid-template-columns':'repeat(3,minmax(100px,1fr))', 'grid-template-rows':'repeat('+Math.ceil(items.length / 3)+',minmax(100px,1fr))'} ">
@@ -10,10 +10,12 @@ export default {
props: [
"dashboard",
"active_addons",
"mail_studierende",
],
provide(){
return{
active_addons: this.active_addons,
mail_studierende: this.mail_studierende,
}
},
data: () => ({
@@ -21,8 +21,11 @@ export default {
minimized: true,
events: null,
currentDay: new Date(),
// used for contentModal
roomInfoContentID: null,
ort_kurzbz: null,
// used for LvUbersichtModal
selectedEvent: null,
}
},
computed: {
@@ -57,11 +60,9 @@ export default {
},
showLvUebersicht: function (event){
this.selectedEvent= event;
Vue.nextTick(()=>{this.$refs.lvUebersicht.show();});
this.$refs.lvUebersicht.lehreinheit = event.lehreinheit_id;
this.$refs.lvUebersicht.lv = event.title;
this.$refs.lvUebersicht.stg = event.stg_typ + event.stg_kurzbz + (event.verband?'-' + event.verband:'' );
this.$refs.lvUebersicht.show();
},
selectDay(day) {
@@ -111,7 +112,7 @@ export default {
},
template: /*html*/`
<div class="dashboard-widget-stundenplan d-flex flex-column h-100">
<lv-uebersicht ref="lvUebersicht" />
<lv-uebersicht ref="lvUebersicht" :event="selectedEvent" />
<content-modal :contentID="roomInfoContentID" :ort_kurzbz="" dialogClass="modal-lg" ref="contentModal"/>
<fhc-calendar :initial-date="currentDay" class="border-0" class-header="p-0" @select:day="selectDay" v-model:minimized="minimized" :events="events" no-week-view :show-weeks="false" />
<div v-show="minimized" class="flex-grow-1 overflow-scroll">