diff --git a/~dev_rating/application/classes/Controller/Api/V0/Student.php b/~dev_rating/application/classes/Controller/Api/V0/Student.php index 343c25d5bae68bf16c397bec70032ac4cea42b6c..2ed58f3cfc8a3c27625f68883d7dbd0e73633118 100644 --- a/~dev_rating/application/classes/Controller/Api/V0/Student.php +++ b/~dev_rating/application/classes/Controller/Api/V0/Student.php @@ -71,10 +71,11 @@ class Controller_Api_V0_Student extends Controller_Handler_Api { if (!isset($recordBookData->planID)) { if (isset($recordBookData->planExternalID)) { - $recordBookData->planID = Model_Plan::withExternalID($recordBookData->planExternalID)->ID; - if ($recordBookData->planID == -1) { + $studyPlan = Model_Plan::withExternalID($recordBookData->planExternalID); + if (is_null($studyPlan)) { throw new InvalidArgumentException('RecordBook: plan not found'); } + $recordBookData->planID = $studyPlan->ID; } else { throw new InvalidArgumentException('RecordBook: no plan ids'); } @@ -188,7 +189,8 @@ class Controller_Api_V0_Student extends Controller_Handler_Api { } if (!isset($studentData->id) || ($studentData->id == -1)) { - $foundList = Model_Students::searchStudentsByName([$studentData->firstName, $studentData->secondName, $studentData->lastName], $facultyID); + $foundList = Model_Students::searchStudentsByName([$studentData->firstName, + $studentData->secondName, $studentData->lastName], $facultyID); $foundSet = []; foreach ($foundList as $item) { if (!in_array($item['ID'], $foundSet)) { diff --git a/~dev_rating/application/classes/Controller/Api/V0/StudyPlan.php b/~dev_rating/application/classes/Controller/Api/V0/StudyPlan.php index 7cf5899b02022904a5f2e9aaaf0aa4767adb8281..9973ceee903b591bd0066f6d4bbbc055b78254da 100644 --- a/~dev_rating/application/classes/Controller/Api/V0/StudyPlan.php +++ b/~dev_rating/application/classes/Controller/Api/V0/StudyPlan.php @@ -83,7 +83,7 @@ class Controller_Api_V0_StudyPlan extends Controller_Handler_Api { private function processStudyPlan($studyPlanData, $year, $semesterID, $facultyID) { if (!isset($studyPlanData->id) && isset($studyPlanData->externalID)) { $studyPlan = Model_Plan::withExternalID($studyPlanData->externalID); - if (!isset($studyPlan)) { + if (!is_null($studyPlan)) { $studyPlan = Model_Plan::make() ->externalID($studyPlanData->externalID) ->year($year)