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

FEAT: Discipline.hasSubgroups in model #299

parent 276849af
Branches
No related merge requests found
......@@ -120,6 +120,24 @@ FROM subgroups
WHERE subgroups.discipline_id = pdisciplineid;
$function$;
CREATE OR REPLACE FUNCTION public.Discipline_HasSubgroups(pdisciplineid integer)
RETURNS integer
LANGUAGE plpgsql
AS $function$
declare vHasSubgroups int default 0;
vCount int default 0;
begin
SELECT COUNT(*) into vCount FROM subgroups
where subgroups.discipline_id = pdisciplineid;
if vCount > 0 then
vHasSubgroups = 1;
else
vHasSubgroups = 0;
end if;
return vHasSubgroups;
end
$function$;
CREATE OR REPLACE FUNCTION public.subgroup_bindstudent(precordbookid integer, psubgroupid integer)
RETURNS integer
LANGUAGE plpgsql
......
......@@ -45,6 +45,7 @@ class Controller_Teacher_Discipline_Rating extends Controller_Environment_Teache
}
$students = Model_Rating::GetStudentsForRating($this->id)->as_array('GroupID');
// TODO: add subgroup numbers to filter by subgroup in UI
$exams = [];
foreach ($students as &$group) {
foreach ($group as &$student) {
......
......@@ -123,6 +123,13 @@ class Model_Discipline extends Model_Container
return DB::query(Database::SELECT, $sql)->param(':id', $this->ID)->execute();
}
public function hasSubgroups() {
$sql = 'SELECT * FROM Discipline_HasSubgroups(:id) AS "res"';
return DB::query(Database::SELECT, $sql)
->param(':id', $this->ID)
->execute()->get('res');
}
/** @return Model_Student[] */
public function getStudents() {
return Model_Students::ofDiscipline($this);
......
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