From 182c6531fa9bb5a615d93d00edf7f5cee0216170 Mon Sep 17 00:00:00 2001 From: ma0068 Date: Mon, 9 Oct 2023 10:58:11 +0200 Subject: [PATCH] Insert Note 7 in Projektarbeite, Projektarbeit kopieren --- .../controllers/jobs/ProjektarbeitJob.php | 112 +++++++++++++++++- .../models/education/Projektarbeit_model.php | 10 +- 2 files changed, 115 insertions(+), 7 deletions(-) diff --git a/application/controllers/jobs/ProjektarbeitJob.php b/application/controllers/jobs/ProjektarbeitJob.php index d66bffbcc..b8a261855 100644 --- a/application/controllers/jobs/ProjektarbeitJob.php +++ b/application/controllers/jobs/ProjektarbeitJob.php @@ -48,16 +48,120 @@ class ProjektarbeitJob extends JOB_Controller //get all missed Projektarbeiten $result = $this->ProjektarbeitModel->getMissedProjektarbeiten(); -/* if(isError($result)) - return $this->logError(getError($result)); + /* if(isError($result)) + return $this->logError(getError($result)); + + if(!hasData($result)) + return $this->logInfo('End Job Projektarbeit Update: 0 Mails sent'); + */ + if(isError($result)) + echo $nl . $result; if(!hasData($result)) - return $this->logInfo('End Job sendStglSammelmail: 0 Mails sent'); - */ + echo $nl . 'End Job Projektarbeit Update: 0 Mails sent'; + $projektarbeiten = getData($result); var_dump($projektarbeiten); + //note auf 7 setzen + foreach ($projektarbeiten as $projekt) { + + $this->db->where('projektarbeit_id', $projekt->projektarbeit_id); + + $result = $this->ProjektarbeitModel->update([ + 'projektarbeit_id' => $projekt->projektarbeit_id + ], [ + 'note' => 7 + ]); + + if (isError($result)) + echo "error: " . getError($result); + else + echo $nl . " erfolgreiches update von projektarbeit_id " . $projekt->projektarbeit_id; + + //copy Projektarbeit + $result = $this->ProjektarbeitModel->load($projekt->projektarbeit_id); + if (isError($result)) + { + echo "error: " . getError($result); + continue; + } + if(!hasData($result)) + { + echo $nl . 'Keine Projektarbeit für projektarbeit_id ' . $projekt->projektarbeit_id . 'gefunden'; + continue; + } + $projektarbeit = getData($result)[0]; + var_dump($projektarbeit); + + $result = $this->ProjektarbeitModel->insert([ + 'projekttyp_kurzbz' => $projektarbeit->projekttyp_kurzbz, + 'titel' => $projektarbeit->titel, + 'insertvon' => 'Projektjob', + 'note' => NULL, + 'lehreinheit_id' => $projektarbeit->lehreinheit_id, + 'student_uid' => $projektarbeit->student_uid + + ]); + if (isError($result)) + echo "error: " . getError($result); + + //Betreuungen kopieren + + //get bestehende Betreuungen + $result = $this->ProjektbetreuerModel->loadWhere([ + 'projektarbeit_id' => $projekt->projektarbeit_id, + //'betreuerart_kurzbz' => $projekt->betreuerart_kurzbz + ]); + if (isError($result)) + //$this->logError(getError($result)); + echo "error: " . getError($result); + elseif (!hasData($result)) + { + echo $nl . 'Keine Projektarbeit für' . $projekt->projektarbeit_id . 'gefunden'; + } + else + { + $betreuung = getData($result); + var_dump($betreuung); + + foreach($betreuung as $bet) + { + echo $nl . $bet->person_id . " " . $bet->projektarbeit_id . " Art: " . $bet->betreuerart_kurzbz; + } + + //var_dump($projektarbeit_copy); + //$projekt_id_copy = $projektarbeit_copy->projektarbeit_id; + //echo "Projektarbeit alt " . $projekt->projektarbeit_id . " Projektarbeit neu: " . $projekt_id_copy; + } + + + $result = $this->ProjektarbeitModel->loadWhere([ + 'student_uid' => $projektarbeit->student_uid, + 'insertvon' => 'Projektjob', + 'note' => NULL + ]); + if (isError($result)) + //$this->logError(getError($result)); + echo "error: " . getError($result); + elseif (!hasData($result)) + { + echo $nl . 'Keine neu angelegte projektarbeit_id für StudentId' . $projektarbeit->student_uid . 'gefunden'; + } + else + { + $projektarbeit_copy = getData($result)[0]; + //var_dump($projektarbeit_copy); + $projekt_id_copy = $projektarbeit_copy->projektarbeit_id; + echo $nl . "Projektarbeit alt " . $projekt->projektarbeit_id . " Projektarbeit neu: " . $projekt_id_copy; + } + + + + + } + } diff --git a/application/models/education/Projektarbeit_model.php b/application/models/education/Projektarbeit_model.php index 3086ab2eb..39db79da1 100644 --- a/application/models/education/Projektarbeit_model.php +++ b/application/models/education/Projektarbeit_model.php @@ -10,6 +10,8 @@ class Projektarbeit_model extends DB_Model parent::__construct(); $this->dbTable = 'lehre.tbl_projektarbeit'; $this->pk = 'projektarbeit_id'; + + $this->load->model('education/Projektarbeit_model', 'ProjektarbeitModel'); } /** @@ -79,8 +81,6 @@ class Projektarbeit_model extends DB_Model $now = new DateTime(); - - //$this->addSelect($this->dbTable.'.*'); $this->addSelect($this->dbTable.'.projektarbeit_id'); $this->addSelect($this->dbTable.'.titel'); $this->addSelect($this->dbTable.'.student_uid'); @@ -104,10 +104,14 @@ class Projektarbeit_model extends DB_Model $this->db->where('pa.datum >', '2022-09-01'); //$this->db->where('pa.fixtermin', 'TRUE'); $this->db->where('pa.abgabedatum', NULL); + //TODO(MANU) get date with NOW $this->db->where('pa.datum < ', '2023-10-04'); - $this->addLimit(10); + //TODO(MANU) check if note null: ausreichend? + $this->db->where($this->dbTable. '.note', NULL); + + $this->addLimit(1); return $this->loadWhere([ 'pa.fixtermin' => 'TRUE',