From 379880aef8e67191d8fff2fe77e2340bd0e1a45b Mon Sep 17 00:00:00 2001 From: Johann Hoffmann Date: Wed, 25 Feb 2026 13:10:30 +0100 Subject: [PATCH] filter paabgabe uploads from newOrChanged job, since uploading a file still writes updateamum/updatevon fields -> compare student_uid with updatevon; when logging new paabgabe termine insert the whole paabgabe object into the logs, not just the result id; --- .../controllers/api/frontend/v1/Abgabe.php | 24 +++++++++++++++++-- .../controllers/jobs/AbgabetoolJob.php | 19 ++++++++++----- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/application/controllers/api/frontend/v1/Abgabe.php b/application/controllers/api/frontend/v1/Abgabe.php index eb841f050..d976cea15 100644 --- a/application/controllers/api/frontend/v1/Abgabe.php +++ b/application/controllers/api/frontend/v1/Abgabe.php @@ -599,7 +599,18 @@ class Abgabe extends FHCAPI_Controller 'insertamum' => date('Y-m-d H:i:s') ) ); - $this->logLib->logInfoDB(array('paabgabe created',$result, getAuthUID(), getAuthPersonId())); + $this->logLib->logInfoDB(array('paabgabe created',array( + 'projektarbeit_id' => $projektarbeit_id, + 'paabgabetyp_kurzbz' => $paabgabetyp_kurzbz, + 'fixtermin' => $fixtermin, + 'datum' => $datum, + 'kurzbz' => $kurzbz, + 'note' => $note, + 'beurteilungsnotiz' => $beurteilungsnotiz, + 'upload_allowed' => $upload_allowed, + 'insertvon' => getAuthUID(), + 'insertamum' => date('Y-m-d H:i:s') + ), getAuthUID(), getAuthPersonId())); } else { // load existing entry of paabgabe and check if note has changed to negativ, to avoid sending when // only notiz has changed. @@ -773,7 +784,16 @@ class Abgabe extends FHCAPI_Controller $abgaben[]= getData($this->PaabgabeModel->load($dataAbgabe))[0]; } - $this->logLib->logInfoDB(array('serientermin angelegt',$res, getAuthUID(), getAuthPersonId())); + $this->logLib->logInfoDB(array('serientermin angelegt',array( + 'projektarbeit_id' => $projektarbeit_id, + 'paabgabetyp_kurzbz' => $paabgabetyp_kurzbz, + 'fixtermin' => $fixtermin, + 'datum' => $datum, + 'kurzbz' => $kurzbz, + 'upload_allowed' => $upload_allowed, + 'insertvon' => getAuthUID(), + 'insertamum' => date('Y-m-d H:i:s') + ), getAuthUID(), getAuthPersonId())); $this->terminateWithSuccess($abgaben); } diff --git a/application/controllers/jobs/AbgabetoolJob.php b/application/controllers/jobs/AbgabetoolJob.php index 3e0774538..a053b2472 100644 --- a/application/controllers/jobs/AbgabetoolJob.php +++ b/application/controllers/jobs/AbgabetoolJob.php @@ -495,11 +495,6 @@ class AbgabetoolJob extends JOB_Controller // get all new or changed termine in interval $result = $this->_ci->PaabgabeModel->findAbgabenNewOrUpdatedSince($interval, $relevantTypes); $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 $projektarbeiten = []; @@ -509,17 +504,29 @@ class AbgabetoolJob extends JOB_Controller if (isset($newOrChangedAbgabe->projektarbeit_id)) { $projektarbeitId = $newOrChangedAbgabe->projektarbeit_id; + // check if the updatevon field is NOT the same as the student the projektarbeit is assigned to + // since uploading a file to a paabgabe is also putting updateamum & updatevon + // we have our own "student has uploaded a file" emailjob anyways + if($newOrChangedAbgabe->student_uid === $newOrChangedAbgabe->updatevon) { + continue; + } + // 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; } } + if(count($projektarbeiten) == 0) { + $this->_ci->logInfo("Keine Emails an Betreuer über neue oder veränderte Termine versandt"); + return; + } + // for each projektarbeit fetch their betreuer and save them in their own dictionary to avoid too many mails $betreuerMap = []; forEach($projektarbeiten as $projektarbeit_id => $abgaben) {