_GroupList.php

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

File

classes/_GroupList.php
View source
  1. <?php
  2. require_once("ObjList.php");
  3. class _GroupList extends ObjList
  4. {
  5. /*
  6. This class inherits mosts of its classes from ObjList
  7. in a similar fashion as CourseList.
  8. */
  9. function reset_list_counters()
  10. {
  11. $this->reset_counter();
  12. // Also, go through all groups in the list and call
  13. // their "reset_list_counters" method.
  14. for ($t = 0; $t < $this->count; $t++)
  15. {
  16. $group = $this->array_list[$t];
  17. $group->reset_list_counters();
  18. }
  19. }
  20. function contains_group_requirement_id($group_requirement_id)
  21. {
  22. // Returns true if any of the lists of courses in these groups
  23. // contain the group requirement ID.
  24. for ($t = 0; $t < count($this->array_list); $t++)
  25. {
  26. $group = $this->array_list[$t];
  27. if ($group->list_courses->contains_group_requirement_id($group_requirement_id))
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. function get_advised_courses_list()
  35. {
  36. // Return a courseList object of courses in THIS
  37. // group which have boolAdvisedToTake == true.
  38. $rtn_list = new CourseList();
  39. for ($t = 0; $t < count($this->array_list); $t++)
  40. {
  41. $group = $this->array_list[$t];
  42. $rtn_list->add_list($group->list_courses->get_advised_courses_list());
  43. $group->list_groups->reset_counter();
  44. while($group->list_groups->has_more())
  45. {
  46. $gg = $group->list_groups->get_next();
  47. $rtn_list->add_list($gg->list_courses->get_advised_courses_list());
  48. }
  49. }
  50. $rtn_list->remove_duplicates();
  51. return $rtn_list;
  52. }
  53. function assign_min_grade($min_grade)
  54. {
  55. // Assign a min grade to every group in this grouplist.
  56. for ($t = 0; $t < count($this->array_list); $t++)
  57. {
  58. $group = $this->array_list[$t];
  59. $group->assign_min_grade($min_grade);
  60. }
  61. }
  62. function sort_priority()
  63. {
  64. /*
  65. Sort this list of groups by their priority number.
  66. Higher priorities should appear at the
  67. top of the list.
  68. */
  69. $tarray = array();
  70. // Since I need the indexes, I will have to go through the array
  71. // myself...
  72. for ($t = 0; $t < count($this->array_list); $t++)
  73. {
  74. $g = $this->array_list[$t];
  75. $g->load_descriptive_data();
  76. $pri = "" . ($g->priority*1) . "";
  77. if (strlen($pri) == 1)
  78. {
  79. $pri = "0" . $pri; // padd with 0 on the front.
  80. // This fixes a sorting problem, because priorities
  81. // were being evaluated as text, not nums, so "5" seemed
  82. // larger than "15" (because it was comparing the 5 to the 1).
  83. }
  84. $str = "$pri ~~ $t";
  85. array_push($tarray,$str);
  86. }
  87. rsort($tarray);
  88. // Now, convert the array back into a list of groups.
  89. $new_list = new GroupList();
  90. for($t = 0; $t < count($tarray); $t++)
  91. {
  92. $temp = explode(" ~~ ",$tarray[$t]);
  93. $i = $temp[1];
  94. $new_list->add($this->array_list[$i]);
  95. }
  96. // Okay, now $new_list should contain the correct values.
  97. // We will transfer over the reference.
  98. $this->array_list = $new_list->array_list;
  99. }
  100. function sort_alphabetical_order($bool_reverse_order = false)
  101. {
  102. $tarray = array();
  103. // Since I need the indexes, I will have to go through the array
  104. // myself...
  105. for ($t = 0; $t < count($this->array_list); $t++)
  106. {
  107. $g = $this->array_list[$t];
  108. $g->load_descriptive_data();
  109. $str = "$g->title ~~ $t";
  110. array_push($tarray,$str);
  111. }
  112. if ($bool_reverse_order == true)
  113. {
  114. rsort($tarray);
  115. } else {
  116. sort($tarray);
  117. }
  118. // Now, convert the array back into a list of groups.
  119. $new_list = new GroupList();
  120. for($t = 0; $t < count($tarray); $t++)
  121. {
  122. $temp = explode(" ~~ ",$tarray[$t]);
  123. $i = $temp[1];
  124. $new_list->add($this->array_list[$i]);
  125. }
  126. // Okay, now $new_list should contain the correct values.
  127. // We will transfer over the reference.
  128. $this->array_list = $new_list->array_list;
  129. }
  130. }

Classes

Namesort descending Description
_GroupList