From 5d1e99a222621326daebe05af084de0fcb738a7b Mon Sep 17 00:00:00 2001 From: KarpAlex Date: Wed, 21 Sep 2022 19:54:20 +0200 Subject: [PATCH] Plausichecks: enabled passing of params to plausi issue checkers, created first checker StgPrestudentUngleichStgStudent --- .../controllers/jobs/PlausiIssueProducer.php | 30 +++++++------ .../StgPrestudentUngleichStgStudent.php | 43 +++++++++++++++++++ 2 files changed, 59 insertions(+), 14 deletions(-) diff --git a/application/controllers/jobs/PlausiIssueProducer.php b/application/controllers/jobs/PlausiIssueProducer.php index d67c8693b..39fff1c72 100644 --- a/application/controllers/jobs/PlausiIssueProducer.php +++ b/application/controllers/jobs/PlausiIssueProducer.php @@ -6,9 +6,9 @@ class PlausiIssueProducer extends JOB_Controller { const PLAUSI_ISSUES_FOLDER = 'issues/plausichecks'; - const EXECUTE_PLAUSI_CHECK_METHOD_NAME = 'executePlausiCheck' + const EXECUTE_PLAUSI_CHECK_METHOD_NAME = 'executePlausiCheck'; - private _fehlerLibMappings; + private $_fehlerLibMappings; public function __construct() { @@ -17,7 +17,7 @@ class PlausiIssueProducer extends JOB_Controller // set fehler which can be produced by the job // structure: fehler_kurzbz => class (library) name for resolving $this->_fehlerLibMappings = array( - '' => '' + 'StgPrestudentUngleichStgStudent' => 'StgPrestudentUngleichStgStudent' //'zgvDatumInZukunft' => 'ZgvDatumInZukunft', //'zgvDatumVorGeburtsdatum' => 'ZgvDatumVorGeburtsdatum', //'zgvMasterDatumInZukunft' => 'ZgvMasterDatumInZukunft', @@ -47,20 +47,17 @@ class PlausiIssueProducer extends JOB_Controller if (isError($studiensemesterRes)) $this->logError(getError($studiensemesterRes)); - if (hasData($studiensemesterRes)) - { - $studiensemester_kurzbz = getData($studiensemesterRes); - } + if (hasData($studiensemesterRes)) $studiensemester_kurzbz = getData($studiensemesterRes); } - $this->logInfo("Plausicheck issue producer job started"); foreach ($this->_fehlerLibMappings as $fehler_kurzbz => $libName) { // get path of library for issue to be produced - $issuesLibPath = DOC_ROOT . 'application/libraries' . self::PLAUSI_ISSUES_FOLDER; - $issuesLibFilePath = $issuesLibPath . '/' . $libName . '.php'; + $issuesLibPath = DOC_ROOT . 'application/libraries/' . self::PLAUSI_ISSUES_FOLDER . '/'; + //$issuesLibPath = base_url('application/libraries/' . self::PLAUSI_ISSUES_FOLDER . '/'); + $issuesLibFilePath = $issuesLibPath . $libName . '.php'; // check if library file exists if (!file_exists($issuesLibFilePath)) @@ -71,7 +68,7 @@ class PlausiIssueProducer extends JOB_Controller } // load library connected to fehlercode - $this->load->library($issuesLibPath . $libName); + $this->load->library(self::PLAUSI_ISSUES_FOLDER . '/'.$libName); $lowercaseLibName = mb_strtolower($libName); @@ -83,8 +80,13 @@ class PlausiIssueProducer extends JOB_Controller continue; } + // get the data needed for issue check + $paramsForCheck = array( + 'studiensemester_kurzbz' => $studiensemester_kurzbz + ); + // call the function for checking for issue production - $executePlausiRes = $this->{$lowercaseLibName}->{self::EXECUTE_PLAUSI_CHECK_METHOD_NAME}(); + $executePlausiRes = $this->{$lowercaseLibName}->{self::EXECUTE_PLAUSI_CHECK_METHOD_NAME}($paramsForCheck); if (isError($executePlausiRes)) { @@ -106,10 +108,10 @@ class PlausiIssueProducer extends JOB_Controller $resolution_params = isset($plausiData['resolution_params']) ? $plausiData['resolution_params'] : null; // write the issue - $addIssueRes = $this->IssuesLib->addFhcIssue($fehler_kurzbz, $person_id, $oe_kurzbz, $fehlertext_params, $resolution_params); + $addIssueRes = $this->issueslib->addFhcIssue($fehler_kurzbz, $person_id, $oe_kurzbz, $fehlertext_params, $resolution_params); if (isError($addIssueRes)) - $this->logError(getError($behobenRes)); + $this->logError(getError($addIssueRes)); else $this->logInfo("Plausicheck issue " . $fehler_kurzbz . " successfully produced"); } diff --git a/application/libraries/issues/plausichecks/StgPrestudentUngleichStgStudent.php b/application/libraries/issues/plausichecks/StgPrestudentUngleichStgStudent.php index e69de29bb..2092ab602 100644 --- a/application/libraries/issues/plausichecks/StgPrestudentUngleichStgStudent.php +++ b/application/libraries/issues/plausichecks/StgPrestudentUngleichStgStudent.php @@ -0,0 +1,43 @@ +_ci =& get_instance(); // get code igniter instance + + $this->_ci->load->library('issues/PlausicheckLib'); // load plausicheck library + + // get all students failing the plausicheck + $prestudentRes = $this->_ci->plausichecklib->getPrestudentenStgUngleichStgStudent(); + + if (isError($prestudentRes)) return $prestudentRes; + + if (hasData($prestudentRes)) + { + $prestudents = getData($prestudentRes); + + // populate results with data necessary for writing issues + foreach ($prestudents as $prestudent) + { + $results[] = array( + 'person_id' => $prestudent->person_id, + 'oe_kurzbz' => $prestudent->prestudent_stg_oe_kurzbz, + 'fehlertext_params' => array('prestudent_id' => $prestudent->prestudent_id), + 'resolution_params' => array('prestudent_id' => $prestudent->prestudent_id) + ); + } + } + + return success($results); + } +}