function _Group::load_group
Search API
4.x _Group.php | _Group::load_group($bool_load_significant_only = true, $array_significant_courses = false, $bool_reload_missing_only = false) |
5.x _Group.php | _Group::load_group($bool_load_significant_only = true, $array_significant_courses = false, $bool_reload_missing_only = false) |
2 calls to _Group::load_group()
- _Group::reload_missing_courses in classes/
_Group.php - _Group::__construct in classes/
_Group.php
File
- classes/
_Group.php, line 115
Class
Code
function load_group($bool_load_significant_only = true, $array_significant_courses = false, $bool_reload_missing_only = false)
{
$group_id = $this->group_id;
$this->load_descriptive_data();
if ($this->db_delete_flag == 1)
{
return;
}
$bool_significant_courses_empty = true;
if (is_array($array_significant_courses))
{
$bool_significant_courses_empty = false;
}
if ($bool_reload_missing_only == true)
{
// We are only going to load the *missing* courses from
// this group. So, begin by getting an array of what is
// not missing.
$array_group_requirement_ids = $this->list_courses->get_group_requirement_id_array();
//var_dump($array_group_requirement_ids);
}
$table_name = "group_requirements";
if ($this->bool_use_draft) {
$table_name = "draft_$table_name";
}
$res = $this->db->db_query("SELECT * FROM $table_name
WHERE group_id = '?' ", $this->group_id);
while ($cur = $this->db->db_fetch_array($res))
{
$id = $cur ["id"];
$course_id = $cur ["course_id"] * 1;
if ($cur ["course_id"] * 1 > 0)
{
if ($bool_load_significant_only == true && $bool_significant_courses_empty == false)
{
// If this course_id is NOT in the array of significant courses
// (that the student took or has transfer credit or subs for)
// then skip it. Never add it to the group.
if ($array_significant_courses [$cur ["course_id"]] != true)
{ // course was not in there, so skip!
continue;
}
}
// A course is the next requirement.
for ($t = 0; $t <= $cur ["course_repeats"]; $t++)
{ // Add in the specified repeats for this group...
// This will usually only go through the loop once.
$use_id = $id . "_rep_$t";
if ($bool_reload_missing_only == true)
{
// Only load this course if it is missing from the group.
// Read the reload_missing_courses() method for an explanation
// of why we should want to do this.
// Basically, check all the courses in the current
// list_courses object for a db_group_requirement_id of $id.
// Only proceed if $id was NOT found.
if ($array_group_requirement_ids [$use_id] == true)
{
continue;
}
}
$course_c = new Course();
$course_c->bool_use_draft = $this->bool_use_draft;
$course_c->course_id = $cur ["course_id"];
$course_c->db_group_requirement_id = $use_id;
$course_c->db = $this->db;
$course_c->catalog_year = $this->catalog_year;
$course_c->assigned_to_group_id = $group_id;
$course_c->assigned_to_semester_num = $this->assigned_to_semester_num;
$course_c->specified_repeats = $cur ["course_repeats"];
if ($cur ["course_repeats"] > 0)
{
$course_c->bool_specified_repeat = true;
}
$course_c->min_grade = trim(strtoupper($cur ["course_min_grade"]));
if ($course_c->min_grade == "")
{ // By default, all courses have a
// min grade requirement of D.
$course_c->min_grade = "D";
}
$this->list_courses->add($course_c);
}
}
if ($cur ["child_group_id"] * 1 > 0)
{
// Another group is the next requirement (its a branch)
if ($bool_reload_missing_only == true)
{ // Since we are reloading courses, this subgroup is already
// part of this group, so do not re-create it, just find it
// and reload it's missing courses.
$temp_g = new Group();
$temp_g->bool_use_draft = $this->bool_use_draft;
$temp_g->group_id = $cur ["child_group_id"];
if ($group_g = $this->list_groups->find_match($temp_g))
{
$group_g->reload_missing_courses();
}
else {
fpm("could not find sub group to reload!");
}
}
else {
// This is a brand-new sub group, so create it
// and add it to this group.
$group_g = new Group($cur ["child_group_id"], null, $this->assigned_to_semester_num, $array_significant_courses, $this->bool_use_draft);
$this->list_groups->add($group_g);
}
}
}
}