_SubstitutionList.php

  1. 5.x classes/_SubstitutionList.php
  2. 4.x classes/_SubstitutionList.php

Classes

NameDescription
_SubstitutionList

File

classes/_SubstitutionList.php
View source
  1. <?php
  2. class _SubstitutionList extends ObjList
  3. {
  4. function find_requirement($course_requirement, $bool_exclude_has_been_applied = false, $group_id = 0, $degree_id = 0, $exclude_ids = array()) {
  5. // Look through the array for a substitution which has this
  6. // course requirement.
  7. // If group_id == -1, no particular group is required.
  8. for ($t = 0; $t < count($this->array_list); $t++)
  9. {
  10. $substitution = $this->array_list[$t];
  11. // Skip if this substitution id is in our list to exclude.
  12. if (in_array($substitution->db_substitution_id,$exclude_ids)) continue;
  13. if ($bool_exclude_has_been_applied == true && $substitution->bool_has_been_applied == true)
  14. {
  15. // Skip substitutions which we have already applied.
  16. continue;
  17. }
  18. if ($degree_id != 0 && $substitution->db_required_degree_id != $degree_id) {
  19. // Skip substitutions which are for a different degree_id than the one supplied.
  20. continue;
  21. }
  22. $cr = $substitution->course_requirement;
  23. //adminDebug($cr->course_id . " " . $course_requirement->course_id);
  24. if ($group_id == -1)
  25. { // No particular group_id is required...
  26. if ($cr->course_id == $course_requirement->course_id)
  27. {
  28. return $substitution;
  29. }
  30. } else {
  31. // ONLY check if it's in the supplied group_id...
  32. if ($cr->course_id == $course_requirement->course_id && $cr->get_bool_assigned_to_group_id($group_id))
  33. {
  34. return $substitution;
  35. }
  36. }
  37. }
  38. return false;
  39. }
  40. function find_group_additions(Group $group)
  41. {
  42. $group_id = $group->group_id;
  43. $rtn_list = new CourseList();
  44. // Find additions for this group_id and return them.
  45. for ($t = 0; $t < count($this->array_list); $t++)
  46. {
  47. $substitution = $this->array_list[$t];
  48. if ($substitution->bool_group_addition == true)
  49. {
  50. $c = $substitution->course_requirement;
  51. if ($c->get_bool_assigned_to_group_id($group_id))
  52. {
  53. $cc = $substitution->course_list_substitutions->get_first();
  54. //adminDebug("~~ $cc->course_id");
  55. $rtn_list->add($cc);
  56. }
  57. }
  58. }
  59. if (!$rtn_list->is_empty)
  60. {
  61. return $rtn_list;
  62. } else {
  63. return false;
  64. }
  65. }
  66. } // class SubstitutionList