WIP notifyBetreuerAboutNewOrChangedAbgabenForBetreuedProjektarbeiten Email Job; allowed abgabetypen & allowed noten as per config now via db primary key; new ProjektbetreuerModel method "getAllBetreuerOfProjektarbeit" to do just that;

This commit is contained in:
Johann Hoffmann
2025-12-03 16:49:49 +01:00
parent 541d6d78cc
commit 0c5af137db
10 changed files with 159 additions and 20 deletions
+4 -2
View File
@@ -14,8 +14,10 @@ $config['URL_STUDENTS'] = 'cis.php/Cis/Abgabetool/Student';
$config['URL_MITARBEITER'] = 'index.ci.php/Cis/Abgabetool/Mitarbeiter';
// lehre.tbl_paabgabetyp bezeichnung
$config['ALLOWED_ABGABETYPEN_BETREUER'] = ['Zwischenabgabe', 'Quality Gate 1', 'Quality Gate 2'];
$config['ALLOWED_NOTEN_ABGABETOOL'] = ['Bestanden', 'Nicht bestanden'];
//$config['ALLOWED_ABGABETYPEN_BETREUER'] = ['Zwischenabgabe', 'Quality Gate 1', 'Quality Gate 2'];
$config['ALLOWED_ABGABETYPEN_BETREUER'] = ['zwischen', 'qualgate1', 'qualgate2']; // tbl_paabgabetyp pk
//$config['ALLOWED_NOTEN_ABGABETOOL'] = ['Bestanden', 'Nicht bestanden'];
$config['ALLOWED_NOTEN_ABGABETOOL'] = ['10', '14']; // tbl_note pk
$config['beurteilung_link_fallback'] = 'addons/fhtw/content/projektbeurteilung/projektbeurteilungDocumentExport.php?projektarbeit_id=?&betreuerart_kurzbz=?&person_id=?';
@@ -44,7 +44,8 @@ class Abgabe extends FHCAPI_Controller
'getProjektarbeitenForStudiengang' =>array('basis/abgabe_assistenz:rw'),
'getStudiengaenge' => array('basis/abgabe_assistenz:rw'),
'getStudentProjektarbeitAbgabeFile' => array('basis/abgabe_student:rw', 'basis/abgabe_lektor:rw', 'basis/abgabe_assistenz:rw'),
'postStudentProjektarbeitZusatzdaten' => array('basis/abgabe_lektor:rw', 'basis/abgabe_assistenz:rw')
'postStudentProjektarbeitZusatzdaten' => array('basis/abgabe_lektor:rw', 'basis/abgabe_assistenz:rw'),
'notifyBetreuerAboutChangedAbgaben' => self::PERM_LOGGED
]);
$this->load->library('PhrasesLib');
@@ -1125,4 +1126,77 @@ class Abgabe extends FHCAPI_Controller
}
}
public function notifyBetreuerAboutChangedAbgaben() {
// $this->_ci->logInfo('Start job FHC-Core->notifyBetreuerAboutChangedAbgaben');
$this->_ci =& get_instance();
$this->_ci->load->model('education/Projektarbeit_model', 'ProjektarbeitModel');
$this->_ci->load->model('education/Projektbetreuer_model', 'ProjektbetreuerModel');
$this->_ci->load->model('education/Paabgabe_model', 'PaabgabeModel');
$this->_ci->load->model('crm/Student_model', 'StudentModel');
$interval = $this->_ci->config->item('PAABGABE_EMAIL_JOB_INTERVAL');
// get all new or changed termine in interval
$result = $this->_ci->PaabgabeModel->findAbgabenNewOrUpdatedSince($interval);
$retval = getData($result);
if(count($retval) == 0) {
// $this->_ci->logInfo("Keine Emails an Betreuer über neue oder veränderte Termine versandt");
return;
}
$this->addMeta('retval', $retval);
// group changed/new abgaben for projektarbeiten
$projektarbeiten = [];
foreach($retval as $newOrChangedAbgabe) {
// Check if the current item has a 'projektarbeit_id' field.
// Replace 'projektarbeit_id' with the actual key name if it's different.
if (isset($newOrChangedAbgabe->projektarbeit_id)) {
$projektarbeitId = $newOrChangedAbgabe->projektarbeit_id;
// If the 'projektarbeit_id' is not yet a key in $projektarbeiten,
// initialize it as an empty array.
if (!isset($projektarbeiten[$projektarbeitId])) {
$projektarbeiten[$projektarbeitId] = [];
}
// Add the current row to the array associated with its 'projektarbeit_id'.
$projektarbeiten[$projektarbeitId][] = $newOrChangedAbgabe;
}
}
// for each projektarbeit fetch their betreuer and save them in their own dictionary to avoid too many mails
$betreuer = [];
forEach($projektarbeiten as $projektarbeit_id => $abgaben) {
$betreuerResult = $this->_ci->ProjektbetreuerModel->getAllBetreuerOfProjektarbeit($projektarbeit_id);
// $projektarbeiten[$projektarbeit_id]['betreuer'] = $betreuerResult;
// $projektarbeit->betreuer = $betreuerResult;
forEach($betreuerResult->retval as $betreuerRow) {
}
if (isset($betreuerResult->projektarbeit_id)) {
$projektarbeitId = $newOrChangedAbgabe->projektarbeit_id;
// If the 'projektarbeit_id' is not yet a key in $projektarbeiten,
// initialize it as an empty array.
if (!isset($projektarbeiten[$projektarbeitId])) {
$projektarbeiten[$projektarbeitId] = [];
}
// Add the current row to the array associated with its 'projektarbeit_id'.
$projektarbeiten[$projektarbeitId][] = $newOrChangedAbgabe;
}
}
$this->addMeta('$projektarbeiten', $projektarbeiten);
// $result = $this->_ci->PaabgabeModel->findNewOrChangedTermineByOtherUsersSince($interval);
// $this->_ci->logInfo('End job FHC-Core->notifyBetreuerAboutChangedAbgaben');
}
}
@@ -27,7 +27,43 @@ class AbgabetoolJob extends JOB_Controller
}
public function notifyBetreuerAboutChangedAbgaben() {
$this->_ci->logInfo('Start job FHC-Core->notifyBetreuerAboutChangedAbgaben');
$interval = $this->_ci->config->item('PAABGABE_EMAIL_JOB_INTERVAL');
// get all new or changed termine in interval
$result = $this->_ci->PaabgabeModel->findAbgabenNewOrUpdatedSince($interval);
$retval = getData($result);
if(count($retval) == 0) {
$this->_ci->logInfo("Keine Emails an Betreuer über neue oder veränderte Termine versandt");
return;
}
// group changed/new abgaben for projektarbeiten, then look up their betreuer and send them email
$projektarbeiten = [];
foreach($retval as $newOrChangedAbgabe) {
// Check if the current item has a 'projektarbeit_id' field.
// Replace 'projektarbeit_id' with the actual key name if it's different.
if (isset($newOrChangedAbgabe['projektarbeit_id'])) {
$projektarbeitId = $newOrChangedAbgabe['projektarbeit_id'];
// If the 'projektarbeit_id' is not yet a key in $projektarbeiten,
// initialize it as an empty array.
if (!isset($projektarbeiten[$projektarbeitId])) {
$projektarbeiten[$projektarbeitId] = [];
}
// Add the current row to the array associated with its 'projektarbeit_id'.
$projektarbeiten[$projektarbeitId][] = $newOrChangedAbgabe;
}
}
$result = $this->_ci->PaabgabeModel->findNewOrChangedTermineByOtherUsersSince($interval);
$this->_ci->logInfo('End job FHC-Core->notifyBetreuerAboutChangedAbgaben');
}
public function notifyBetreuerMail() {
@@ -306,17 +306,7 @@ class Projektarbeit_model extends DB_Model
return $this->execReadOnlyQuery($qry, array($projektarbeit_id));
}
/**
* Prüft ob Projektarbeit aktuell ist (also zurzeit online bewertet wird).
* @param $projektarbeit_id
* @return boolean
*/
public function projektarbeitIsCurrent($projektarbeit_id) {
$version = $this->getVersion($projektarbeit_id);
// paarbeit sollte nur ab einem Studiensemester online bewertet werden
return $version === null ? null : $version->isCurrent;
}
public function getProjektarbeitenForStudiengang($studiengang_kz, $benotet) {
$new_qry = "SELECT DISTINCT ON(tmp.projektarbeit_id) *, campus.get_betreuer_details(tmp.zweitbetreuer_person_id) as zweitbetreuer_full_name, campus.get_betreuer_details(tmp.betreuer_person_id) as erstbetreuer_full_name
@@ -232,4 +232,41 @@ class Projektbetreuer_model extends DB_Model
return $this->execQuery($qry, array($projektarbeit_id, $betreuer_person_id));
}
/**
* Gets all Betreuer of a Projektarbeit.
* Returns one row for each person.
* @param int $projektarbeit_id
* @return array success with number of Betreuer or error
*/
public function getAllBetreuerOfProjektarbeit($projektarbeit_id)
{
$qry = "SELECT DISTINCT ON (pers.person_id) pers.person_id, betreuerart_kurzbz, vorname, nachname,
trim(COALESCE(titelpre,'')||' '||COALESCE(vorname,'')||' '||COALESCE(nachname,'')||' '||COALESCE(titelpost,'')) as voller_name,
anrede, titelpre, titelpost, gebdatum, geschlecht, pa.projekttyp_kurzbz,
ben.uid, ben.alias, ma.personalnummer, mitarbeiter_uid, student_uid,
(
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
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 projektarbeit_id = ?
ORDER BY pers.person_id, CASE WHEN ma.mitarbeiter_uid IS NULL THEN 1 ELSE 0 END, /*Mitarbeiter account first*/
CASE WHEN ben.uid IS NULL THEN 1 ELSE 0 END, /*user with account first*/
ben.insertamum";
return $this->execQuery($qry, array($projektarbeit_id));
}
}
@@ -487,7 +487,7 @@ export const AbgabeMitarbeiterDetail = {
if(this.assistenzMode) {
return this.abgabeTypeOptions
} else {
return this.abgabeTypeOptions.filter(opt => this.abgabetypenBetreuer.includes(opt.bezeichnung))
return this.abgabeTypeOptions.filter(opt => this.abgabetypenBetreuer.includes(opt.paabgabetyp_kurzbz))
}
},
getMessagePtStyle() {
@@ -55,7 +55,6 @@ export const AbgabeStudentDetail = {
return false
}
// TODO: define these
if(endupload) {
if(await this.$fhcAlert.confirm({
message: this.$p.t('abgabetool/confirmEnduploadSpeichern'),
@@ -341,6 +340,7 @@ export const AbgabeStudentDetail = {
<i v-else-if="termin.dateStyle == 'abzugeben'" v-tooltip.right="getTooltipAbzugeben" class="fa-solid fa-hourglass-half"></i>
<i v-else-if="termin.dateStyle == 'standard'" v-tooltip.right="getTooltipStandard" class="fa-solid fa-clock"></i>
<i v-else-if="termin.dateStyle == 'abgegeben'" v-tooltip.right="getTooltipAbgegeben" class="fa-solid fa-check"></i>
<i v-else-if="termin.dateStyle == 'beurteilungerforderlich'" v-tooltip.right="getTooltipBeurteilungerforderlich" class="fa-solid fa-list-check"></i>
</div>
<div class="col-auto text-start pl-2 pr-0 pt-0 pb-0" style="min-width: max(120px, 20%); max-width: min(300px, 30%); transform: translateX(-30px)">
<span>{{ termin?.bezeichnung }}</span>
@@ -785,7 +785,7 @@ export const AbgabetoolAssistenz = {
this.notenOptions = res.data[0]
this.allowedNotenOptions = this.notenOptions.filter(
opt => res.data[1].includes(opt.bezeichnung)
opt => res.data[1].includes(opt.note)
)
}
@@ -352,7 +352,7 @@ export const AbgabetoolMitarbeiter = {
},
computed: {
getAllowedAbgabeTypeOptions() {
return this.abgabeTypeOptions.filter(opt => this.abgabetypenBetreuer.includes(opt.bezeichnung))
return this.abgabeTypeOptions.filter(opt => this.abgabetypenBetreuer.includes(opt.paabgabetyp_kurzbz))
}
},
created() {
@@ -375,7 +375,7 @@ export const AbgabetoolMitarbeiter = {
this.notenOptions = res.data[0]
this.allowedNotenOptions = this.notenOptions.filter(
opt => res.data[1].includes(opt.bezeichnung)
opt => res.data[1].includes(opt.note)
)
}
@@ -308,7 +308,7 @@ export const AbgabetoolStudent = {
this.notenOptions = res.data[0]
this.allowedNotenOptions = this.notenOptions.filter(
opt => res.data[1].includes(opt.bezeichnung)
opt => res.data[1].includes(opt.note)
)
}
}).finally(() => {