diff --git a/application/config/abgabe.php b/application/config/abgabe.php index f9b043a34..5cf3042ed 100644 --- a/application/config/abgabe.php +++ b/application/config/abgabe.php @@ -36,3 +36,6 @@ $config['SIGNATUR_CHECK_PAABGABETYPEN'] = ['end']; // to be used as "https://moodle.technikum-wien.at/course/view.php?idnumber=dl{$stg_kz}" for stg specific moodle routing $config['STG_MOODLE_LINK'] = 'https://moodle.technikum-wien.at/course/view.php?idnumber=dl'; + +$config['ASSISTENZ_SAMMELMAIL_BUTTON_STUDENT'] = true; +$config['ASSISTENZ_SAMMELMAIL_BUTTON_BETREUER'] = true; diff --git a/application/controllers/api/frontend/v1/Abgabe.php b/application/controllers/api/frontend/v1/Abgabe.php index 39c7ebae6..c8f48b9df 100644 --- a/application/controllers/api/frontend/v1/Abgabe.php +++ b/application/controllers/api/frontend/v1/Abgabe.php @@ -87,11 +87,15 @@ class Abgabe extends FHCAPI_Controller $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'); + $ASSISTENZ_SAMMELMAIL_BUTTON_STUDENT = $this->config->item('ASSISTENZ_SAMMELMAIL_BUTTON_STUDENT'); + $ASSISTENZ_SAMMELMAIL_BUTTON_BETREUER = $this->config->item('ASSISTENZ_SAMMELMAIL_BUTTON_BETREUER'); $ret = array( 'old_abgabe_beurteilung_link' => $old_abgabe_beurteilung_link, 'turnitin_link' => $turnitin_link, - 'abgabetypenBetreuer' => $abgabetypenBetreuer + 'abgabetypenBetreuer' => $abgabetypenBetreuer, + 'ASSISTENZ_SAMMELMAIL_BUTTON_STUDENT' => $ASSISTENZ_SAMMELMAIL_BUTTON_STUDENT, + 'ASSISTENZ_SAMMELMAIL_BUTTON_BETREUER' => $ASSISTENZ_SAMMELMAIL_BUTTON_BETREUER ); $this->terminateWithSuccess($ret); @@ -762,7 +766,7 @@ class Abgabe extends FHCAPI_Controller /** * helper function to fetch the correct email for a projektarbeits erstbetreuer */ - private function getProjektbetreuerEmail($projektarbeit_id) { + private function getProjektbetreuerEmailByProjektarbeitID($projektarbeit_id) { $this->load->model('education/Projektarbeit_model', 'ProjektarbeitModel'); $result = $this->ProjektarbeitModel->getProjektbetreuerEmail($projektarbeit_id); $email = $this->getDataOrTerminateWithError($result, 'general'); @@ -771,6 +775,18 @@ class Abgabe extends FHCAPI_Controller } + /** + * helper function to fetch the correct email for a projektarbeits zweitbetreuer by their person id + * can be used for erstbetreuer aswell if necessary + */ + private function getProjektbetreuerEmailByPersonID($person_id) { + $this->load->model('education/Projektarbeit_model', 'ProjektarbeitModel'); + $result = $this->ProjektarbeitModel->getProjektbetreuerEmailByPersonID($person_id); + $email = $this->getDataOrTerminateWithError($result, 'general'); + + return $email[0]->uid ? $email[0]->uid.'@'.DOMAIN : $email[0]->private_email; + } + //TODO: SWITCH TO NOTEN API ONCE NOTENTOOL IS IN MASTER TO AVOID DUPLICATE API /** @@ -887,6 +903,12 @@ class Abgabe extends FHCAPI_Controller // map the abgaben into projektarbeiten foreach($projektarbeiten as $projektarbeit) { + $projektarbeit->betreuer_mail = $this->getProjektbetreuerEmailByProjektarbeitID($projektarbeit->projektarbeit_id); + + if($projektarbeit->zweitbetreuer_person_id !== null) { + $projektarbeit->zweitbetreuer_mail = $this->getProjektbetreuerEmailByPersonID($projektarbeit->zweitbetreuer_person_id); + } + $filterFunc = function($projektabgabe) use ($projektarbeit) { return $projektabgabe->projektarbeit_id == $projektarbeit->projektarbeit_id; }; @@ -1140,7 +1162,7 @@ class Abgabe extends FHCAPI_Controller $maildata['bewertunglink'] = $projektarbeitIsCurrent && $paabgabetyp_kurzbz == 'end' ? "

Zur Beurteilung der Arbeit

" : ""; $maildata['token'] = ""; - $email = $this->getProjektbetreuerEmail($projektarbeit_id); + $email = $this->getProjektbetreuerEmailByProjektarbeitID($projektarbeit_id); if(!$email) $this->terminateWithError($this->p->t('abgabetool', 'c4fehlerMailBegutachter'), 'general'); diff --git a/application/models/education/Projektarbeit_model.php b/application/models/education/Projektarbeit_model.php index d80878f6d..e2d4d1b70 100644 --- a/application/models/education/Projektarbeit_model.php +++ b/application/models/education/Projektarbeit_model.php @@ -244,6 +244,28 @@ class Projektarbeit_model extends DB_Model return $this->execReadOnlyQuery($qry, [$projektarbeit_id]); } + + public function getProjektbetreuerEmailByPersonID($person_id) { + $qry = "SELECT ( + SELECT kontakt + FROM public.tbl_kontakt + WHERE kontakttyp = 'email' + AND person_id = pers.person_id + ORDER BY + CASE WHEN zustellung THEN 0 ELSE 1 END, + insertamum DESC NULLS LAST + LIMIT 1 + ) AS private_email, mitarbeiter_uid as uid + FROM lehre.tbl_projektarbeit pa + JOIN lehre.tbl_projektbetreuer USING (projektarbeit_id) + JOIN public.tbl_person pers USING (person_id) + LEFT JOIN public.tbl_benutzer ben USING (person_id) + LEFT JOIN public.tbl_mitarbeiter ma ON ben.uid = ma.mitarbeiter_uid + WHERE (ben.aktiv OR ben.aktiv IS NULL) + AND person_id = ?"; + + return $this->execReadOnlyQuery($qry, [$person_id]); + } public function getProjektarbeitBenutzer($uid) { $qry="SELECT * FROM campus.vw_benutzer where uid=?"; diff --git a/public/js/components/Cis/Abgabetool/AbgabetoolAssistenz.js b/public/js/components/Cis/Abgabetool/AbgabetoolAssistenz.js index 4c4485fb4..20333ba41 100644 --- a/public/js/components/Cis/Abgabetool/AbgabetoolAssistenz.js +++ b/public/js/components/Cis/Abgabetool/AbgabetoolAssistenz.js @@ -77,6 +77,8 @@ export const AbgabetoolAssistenz = { phrasenResolved: false, turnitin_link: null, old_abgabe_beurteilung_link: null, + ASSISTENZ_SAMMELMAIL_BUTTON_STUDENT: null, + ASSISTENZ_SAMMELMAIL_BUTTON_BETREUER: null, saving: false, loading: false, abgabeTypeOptions: null, @@ -221,6 +223,32 @@ export const AbgabetoolAssistenz = { ]}; }, methods: { + sammelMailStudent() { + const emails = this.selectedData + .map(row => `${row.student_uid}@${this.domain}`) + .join(','); + + const subject = this.$p.t('abgabetool/c4sammelmailStudentBetreff', [this.selectedStudiengangOption?.bezeichnung]); + + const href = `mailto:${emails}?subject=${subject}`; + + window.location.href = href + }, + sammelMailBetreuer() { + const recipientList = []; + this.selectedData.forEach(row => { + if (row.betreuer_mail) recipientList.push(row.betreuer_mail); + if (row.zweitbetreuer_mail) recipientList.push(row.zweitbetreuer_mail); + }); + + // actually not necessary for email clients but looks better for assistenz if we avoid duplicates here + const uniqueRecipients = [...new Set(recipientList)]; + + const subject = this.$p.t('abgabetool/c4sammelmailBetreuerBetreff', [this.selectedStudiengangOption?.bezeichnung]); + const href = `mailto:${uniqueRecipients.join(',')}?subject=${encodeURIComponent(subject)}`; + + window.location.href = href; + }, selectHandler(e, cell) { const row = cell.getRow(); @@ -620,9 +648,8 @@ export const AbgabetoolAssistenz = { const mappedData = this.mapProjekteToTableData(this.projektarbeiten) - this.$refs.abgabeTable.tabulator.setColumns(this.abgabeTableOptions.columns) this.$refs.abgabeTable.tabulator.setData(mappedData) - + this.$refs.abgabeTable.tabulator.redraw(true) }).finally(()=>{ this.saving = false }) @@ -867,8 +894,8 @@ export const AbgabetoolAssistenz = { tableResolve(resolve) { this.tableBuiltResolve = resolve }, - buildMailToLink(abgabe) { - return 'mailto:' + abgabe.student_uid +'@'+ this.domain + buildMailToLink(projekt) { + return 'mailto:' + projekt.student_uid +'@'+ this.domain }, buildPKZ(projekt) { return `${projekt.student_uid} / ${projekt.matrikelnr}` @@ -941,6 +968,29 @@ export const AbgabetoolAssistenz = { this.calcMaxTableHeight() } }, + computed: { + uniqueBetreuerEmailCount() { + const emails = new Set(); + + this.selectedData.forEach(row => { + if (row.betreuer_mail) emails.add(row.betreuer_mail); + if (row.zweitbetreuer_mail) emails.add(row.zweitbetreuer_mail); + }); + + return emails.size; + }, + uniqueStudentEmailCount() { + const emails = new Set(); + + this.selectedData.forEach(row => { + if (row.student_uid) { + emails.add(row.student_uid); // actually dont need domain for this + } + }); + + return emails.size; + } + }, watch: { 'serienTermin.bezeichnung'(newVal) { if(newVal?.paabgabetyp_kurzbz === 'qualgate1' || newVal?.paabgabetyp_kurzbz === 'qualgate2') { @@ -987,6 +1037,8 @@ export const AbgabetoolAssistenz = { const res = results[0].value; this.turnitin_link = res.data?.turnitin_link; this.old_abgabe_beurteilung_link = res.data?.old_abgabe_beurteilung_link; + this.ASSISTENZ_SAMMELMAIL_BUTTON_STUDENT = res.data?.ASSISTENZ_SAMMELMAIL_BUTTON_STUDENT; + this.ASSISTENZ_SAMMELMAIL_BUTTON_BETREUER = res.data?.ASSISTENZ_SAMMELMAIL_BUTTON_BETREUER; } // 2. Studiengänge @@ -1292,6 +1344,16 @@ export const AbgabetoolAssistenz = { :useSelectionSpan="false" >