Skip to content
Snippets Groups Projects
Commit 0a168cd7 authored by Anton Bagliy's avatar Anton Bagliy
Browse files

FIX: adding grading_credit disciplines #362

parent 4bd1e5e1
Branches
No related merge requests found
-- НЕ ДОБАВЛЯЙТЕ ЭТИ ФУНКЦИИ В БАЗУ !!!!
CREATE OR REPLACE FUNCTION public.discipline_find(pstudyplanid integer, psemesterid integer, psubjectid integer, pexamtype exam_credit_grading_credit)
RETURNS SETOF integer
LANGUAGE sql
AS $function$
--select public.discipline_find(
-- :pstudyplanid, -- put the pstudyplanid parameter value instead of 'pstudyplanid' (int4)
-- :psemesterid, -- put the psemesterid parameter value instead of 'psemesterid' (int4)
-- :psubjectid, -- put the psubjectid parameter value instead of 'psubjectid' (int4)
-- :pexamtype -- put the pexamtype parameter value instead of 'pexamtype' (exam_credit_grading_credit)
--);
SELECT disciplines.ID
FROM disciplines
INNER JOIN disciplines_study_plans ON disciplines.ID = disciplines_study_plans.DisciplineID
WHERE disciplines_study_plans.StudyPlanID = pStudyPlanID AND
disciplines.SemesterID = pSemesterID AND
disciplines.SubjectID = pSubjectID AND
(disciplines.ExamType = pExamType or
(disciplines.ExamType = 'credit' and pExamType = 'grading_credit'));
$function$;
-- НЕ ДОБАВЛЯЙТЕ ЭТИ ФУНКЦИИ В БАЗУ !!!!
CREATE OR REPLACE FUNCTION public.discipline_settypeunsafe(pdisciplineid integer, ptype exam_credit_grading_credit)
RETURNS integer
LANGUAGE plpgsql
AS $function$
declare vRow int;
begin
UPDATE disciplines
SET examtype = ptype
WHERE ID = pDisciplineID ;
get diagnostics vRow = ROW_COUNT;
RETURN vRow-1;
EXCEPTION
when others then RETURN -1;
END
$function$
;
......@@ -57,9 +57,6 @@ class Controller_Api_V0_StudyPlan extends Controller_Handler_Api
if (isset($disciplineData->gradeID)) {
$discipline->changeGradeUnsafe($disciplineData->gradeID);
}
if (isset($disciplineData->type) && $disciplineData->type === 'grading_credit') {
$discipline->changeTypeUnsafe($disciplineData->type);
}
} else {
if (empty($disciplineData->teacherIDs)) {
throw new InvalidArgumentException('Cannot create discipline without teachers');
......
......@@ -186,18 +186,6 @@ class Model_Discipline extends Model_Container
])->execute()->get('"ErrorCode"');
}
public function changeTypeUnsafe($type) {
if ($this->Type == $type)
return 0;
$sql = 'SELECT * FROM Discipline_SetTypeUnsafe(:discipline, :type) AS "ErrorCode"';
return DB::query(Database::SELECT, $sql)
->parameters([
':discipline' => $this->ID,
':type' => $type,
])->execute()->get('"ErrorCode"');
}
public function changeGrade($teacherID, $grade) {
if (($this->AuthorID == $teacherID) && $this->IsLocked !== true){
return $this->changeGradeUnsafe($grade);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment