_AdvisingScreenTypeView.php

Classes

NameDescription
_AdvisingScreenTypeViewThis class is the View by Type view for FlightPath. As such, it inherits most of it's classes from __advising_screen.

File

classes/_AdvisingScreenTypeView.php
View source
  1. <?php
  2. /**
  3. * This class is the View by Type view for FlightPath. As such, it
  4. * inherits most of it's classes from __advising_screen.
  5. *
  6. * The biggest difference with View by Type from the default
  7. * View by Year is that we don't care about the original semesters
  8. * that were spelled out in the degree plan. We need to re-organize them
  9. * into new semesters for Major, Core, Supporting, and Electives. So,
  10. * most of the methods here will be about doing that.
  11. *
  12. */
  13. class _AdvisingScreenTypeView extends _AdvisingScreen
  14. {
  15. /**
  16. * In __advising_screen, this method simply displays the degree plan's
  17. * semesters to the screen. But here, we need to go through the 4
  18. * type categories: Core, Major, Supporting, and Electives,
  19. * and only display courses and groups from each semester fitting
  20. * that type.
  21. *
  22. */
  23. function build_semester_list()
  24. {
  25. $list_semesters = $this->degree_plan->list_semesters;
  26. // Go through each semester and add it to the screen...
  27. $list_semesters->reset_counter();
  28. $this->add_to_screen($this->display_semester_list($list_semesters, "c", t("Core Requirements"), true));
  29. $this->add_to_screen($this->display_semester_list($list_semesters, "m", t("Major Requirements"), true));
  30. $this->add_to_screen($this->display_semester_list($list_semesters, "s", t("Supporting Requirements"), true));
  31. $this->add_to_screen($this->display_semester_list($list_semesters, "e", t("Electives"), true));
  32. $temp_d_s = new Semester(-55); // developmental requirements.
  33. if ($dev_sem = $list_semesters->find_match($temp_d_s))
  34. {
  35. $this->add_to_screen($this->display_semester($dev_sem));
  36. }
  37. }
  38. /**
  39. * Does the testType match the reqType? This function is used
  40. * to make sure that courses or groups with a certain requirement_type
  41. * are placed in the correct semester blocks on screen.
  42. *
  43. * @param string $test_type
  44. * @param string $req_type
  45. * @return bool
  46. */
  47. function match_requirement_type($test_type, $req_type)
  48. {
  49. // Does the testType match the reqType?
  50. if ($test_type == $req_type)
  51. {
  52. return true;
  53. }
  54. if ($test_type == "uc" && $req_type == "c")
  55. { // university captone core.
  56. return true;
  57. }
  58. if ($test_type == "um" && $req_type == "m")
  59. { // university captone major
  60. return true;
  61. }
  62. if ($req_type == "e")
  63. {
  64. // type "elective." test must not be c, s, or m.
  65. if ($test_type != "c" && $test_type != "s" && $test_type != "m"
  66. && $test_type != "uc" && $test_type != "um" && $test_type != "dev")
  67. {
  68. return true;
  69. }
  70. }
  71. return false;
  72. }
  73. /**
  74. * Display contents of a semester list as a single semester,
  75. * only displaying courses matching the requirement_type.
  76. * If the requirement_type is "e", then we will look for anything
  77. * not containing an m, s, uc, um, or c as a requirement_type.
  78. *
  79. * @param SemesterList $list_semesters
  80. * @param string $requirement_type
  81. * @param string $title
  82. * @param bool $bool_display_hour_count
  83. * @return string
  84. */
  85. function display_semester_list($list_semesters, $requirement_type, $title, $bool_display_hour_count = false)
  86. {
  87. // Display the contents of a semester object
  88. // on the screen (in HTML)
  89. $pC = "";
  90. $pC .= $this->draw_semester_box_top($title);
  91. $count_hours_completed = 0;
  92. $list_semesters->reset_counter();
  93. while($list_semesters->has_more())
  94. {
  95. $semester = $list_semesters->get_next();
  96. if ($semester->semester_num == -88)
  97. { // These are the "added by advisor" courses. Skip them.
  98. continue;
  99. }
  100. // First, display the list of bare courses.
  101. $semester->list_courses->sort_alphabetical_order();
  102. $semester->list_courses->reset_counter();
  103. $sem_is_empty = true;
  104. $sem_rnd = rand(0,9999);
  105. $pC .= "<tr><td colspan='4' class='tenpt'>
  106. <b><!--SEMTITLE$sem_rnd--></b></td></tr>";
  107. while($semester->list_courses->has_more())
  108. {
  109. $course = $semester->list_courses->get_next();
  110. // Make sure the requirement type matches!
  111. if (!$this->match_requirement_type($course->requirement_type, $requirement_type))
  112. {
  113. continue;
  114. }
  115. // Is this course being fulfilled by anything?
  116. //if (is_object($course->courseFulfilledBy))
  117. if (!($course->course_list_fulfilled_by->is_empty))
  118. { // this requirement is being fulfilled by something the student took...
  119. //$pC .= $this->draw_course_row($course->courseFulfilledBy);
  120. $pC .= $this->draw_course_row($course->course_list_fulfilled_by->get_first());
  121. //$count_hours_completed += $course->courseFulfilledBy->hours_awarded;
  122. $course->course_list_fulfilled_by->get_first()->bool_has_been_displayed = true;
  123. if ($course->course_list_fulfilled_by->get_first()->display_status == "completed")
  124. { // We only want to count completed hours, no midterm or enrolled courses.
  125. //$count_hours_completed += $course->course_list_fulfilled_by->get_first()->hours_awarded;
  126. $h = $course->course_list_fulfilled_by->get_first()->hours_awarded;
  127. if ($course->course_list_fulfilled_by->get_first()->bool_ghost_hour == TRUE) {
  128. $h = 0;
  129. }
  130. $count_hours_completed += $h;
  131. }
  132. } else {
  133. // This requirement is not being fulfilled...
  134. $pC .= $this->draw_course_row($course);
  135. }
  136. //$pC .= "</td></tr>";
  137. $sem_is_empty = false;
  138. }
  139. // Now, draw all the groups.
  140. $semester->list_groups->sort_alphabetical_order();
  141. $semester->list_groups->reset_counter();
  142. while($semester->list_groups->has_more())
  143. {
  144. //debug_c_t("dddd");
  145. $group = $semester->list_groups->get_next();
  146. if (!$this->match_requirement_type($group->requirement_type, $requirement_type))
  147. {
  148. continue;
  149. }
  150. $pC .= "<tr><td colspan='8'>";
  151. $pC .= $this->display_group($group);
  152. $count_hours_completed += $group->hours_fulfilled_for_credit;
  153. $pC .= "</td></tr>";
  154. $sem_is_empty = false;
  155. }
  156. if ($sem_is_empty == false)
  157. {
  158. // There WAS something in this semester, put in the title.
  159. //debugCT("replacing $sem_rnd with $semester->title");
  160. $pC = str_replace("<!--SEMTITLE$sem_rnd-->",$semester->title,$pC);
  161. }
  162. }
  163. // Add hour count to the bottom...
  164. if ($bool_display_hour_count == true && $count_hours_completed > 0)
  165. {
  166. $pC .= "<tr><td colspan='8'>
  167. <div class='tenpt' style='text-align:right; margin-top: 10px;'>
  168. Completed hours: $count_hours_completed
  169. </div>
  170. ";
  171. $pC .= "</td></tr>";
  172. }
  173. $pC .= $this->draw_semester_box_bottom();
  174. return $pC;
  175. }
  176. }