_AdvisingScreenTypeView.php

  1. 5.x classes/_AdvisingScreenTypeView.php
  2. 4.x classes/_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
  18. * type categories: ex: 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. // We want to go through our requirement types, and create a box for each one, if available.
  29. $types = fp_get_requirement_types();
  30. foreach ($types as $code => $desc) {
  31. $temp = $this->display_semester_list($list_semesters, $code, $desc, TRUE);
  32. if ($temp) {
  33. $this->add_to_screen($temp, "SEMESTER_TYPE_" . $code);
  34. }
  35. }
  36. $temp_d_s = new Semester(DegreePlan::SEMESTER_NUM_FOR_DEVELOPMENTALS); // developmental requirements.
  37. if ($dev_sem = $list_semesters->find_match($temp_d_s))
  38. {
  39. $this->add_to_screen($this->display_semester($dev_sem), "SEMESTER_" . DegreePlan::SEMESTER_NUM_FOR_DEVELOPMENTALS);
  40. }
  41. }
  42. /**
  43. * Does the testType match the reqType? This function is used
  44. * to make sure that courses or groups with a certain requirement_type
  45. * are placed in the correct semester blocks on screen.
  46. *
  47. * @param string $test_type
  48. * @param string $req_type
  49. * @return bool
  50. */
  51. function match_requirement_type($test_type, $req_type)
  52. {
  53. // Does the testType match the reqType?
  54. if ($test_type == $req_type)
  55. {
  56. return true;
  57. }
  58. // Does it match if there's a u in front?
  59. if ($test_type == ("u" . $req_type))
  60. { // university captone type.
  61. return true;
  62. }
  63. if ($req_type == "e")
  64. {
  65. // type "elective." We will make sure the test_type isn't in
  66. // one of our defined types already.
  67. // Also, make sure it doesn't begin with a 'u'. Ex: um, for University Capstone + m. That would be undefined as well.
  68. $no_u_test_type = ltrim($test_type, 'u');
  69. $types = fp_get_requirement_types();
  70. if (!isset($types[$test_type]) && !isset($types[$no_u_test_type])) {
  71. // Yes-- the user is using a code NOT defined, so let's just call it
  72. // an "elective" type.
  73. return TRUE;
  74. }
  75. }
  76. return false;
  77. }
  78. /**
  79. * Display contents of a semester list as a single semester,
  80. * only displaying courses matching the requirement_type.
  81. * If the requirement_type is "e", then we will also look for anything
  82. * not containing a defined requirement_type.
  83. *
  84. * @param SemesterList $list_semesters
  85. * @param string $requirement_type
  86. * @param string $title
  87. * @param bool $bool_display_hour_count
  88. * @return string
  89. */
  90. function display_semester_list($list_semesters, $requirement_type, $title, $bool_display_hour_count = false)
  91. {
  92. // Display the contents of a semester object
  93. // on the screen (in HTML)
  94. $pC = "";
  95. $pC .= $this->draw_semester_box_top($title);
  96. $is_empty = TRUE;
  97. $count_hours_completed = 0;
  98. $list_semesters->reset_counter();
  99. while($list_semesters->has_more())
  100. {
  101. $semester = $list_semesters->get_next();
  102. if ($semester->semester_num == -88)
  103. { // These are the "added by advisor" courses. Skip them.
  104. continue;
  105. }
  106. $last_req_by_degree_id = -1;
  107. // First, display the list of bare courses.
  108. $semester->list_courses->sort_alphabetical_order();
  109. $semester->list_courses->reset_counter();
  110. $sem_is_empty = true;
  111. $html = array();
  112. $sem_rnd = rand(0,9999);
  113. $pC .= "<tr><td colspan='4' class='tenpt'>
  114. <span class='advise-type-view-sem-title'><!--SEMTITLE$sem_rnd--></span></td></tr>";
  115. while($semester->list_courses->has_more())
  116. {
  117. $course = $semester->list_courses->get_next();
  118. // Make sure the requirement type matches!
  119. if (!$this->match_requirement_type($course->requirement_type, $requirement_type))
  120. {
  121. continue;
  122. }
  123. $is_empty = FALSE;
  124. if (!isset($html[$course->req_by_degree_id])) {
  125. $html[$course->req_by_degree_id] = "";
  126. }
  127. // Is this course being fulfilled by anything?
  128. //if (is_object($course->courseFulfilledBy))
  129. if (!($course->course_list_fulfilled_by->is_empty))
  130. { // this requirement is being fulfilled by something the student took...
  131. $c = $course->course_list_fulfilled_by->get_first();
  132. $c->req_by_degree_id = $course->req_by_degree_id; // make sure we assign it to the current degree_id.
  133. $html[$course->req_by_degree_id] .= $this->draw_course_row($c);
  134. $c->set_has_been_displayed($course->req_by_degree_id);
  135. if ($c->display_status == "completed")
  136. { // We only want to count completed hours, no midterm or enrolled courses.
  137. $h = $c->get_hours_awarded();
  138. if ($c->bool_ghost_hour == TRUE) {
  139. $h = 0;
  140. }
  141. $count_hours_completed += $h;
  142. }
  143. } else {
  144. // This requirement is not being fulfilled...
  145. $html[$course->req_by_degree_id] .= $this->draw_course_row($course);
  146. }
  147. $sem_is_empty = false;
  148. } //while list_courses
  149. // Now, draw all the groups.
  150. $semester->list_groups->sort_alphabetical_order();
  151. $semester->list_groups->reset_counter();
  152. while($semester->list_groups->has_more())
  153. {
  154. $group = $semester->list_groups->get_next();
  155. if (!$this->match_requirement_type($group->requirement_type, $requirement_type))
  156. {
  157. continue;
  158. }
  159. if (!isset($html[$group->req_by_degree_id])) {
  160. $html[$group->req_by_degree_id] = "";
  161. }
  162. $html[$group->req_by_degree_id] .= "<tr><td colspan='8'>";
  163. $html[$group->req_by_degree_id] .= $this->display_group($group);
  164. $count_hours_completed += $group->hours_fulfilled_for_credit;
  165. $html[$group->req_by_degree_id] .= "</td></tr>";
  166. $sem_is_empty = false;
  167. $is_empty = FALSE;
  168. } // while list_groups
  169. if ($sem_is_empty == false)
  170. {
  171. // There WAS something in this semester, put in the title.
  172. //debugCT("replacing $sem_rnd with $semester->title");
  173. $pC = str_replace("<!--SEMTITLE$sem_rnd-->",$semester->title,$pC);
  174. }
  175. // Okay, let's plan to put it all on the screen for this semester....
  176. // Sort by degree's advising weight
  177. $new_html = array();
  178. foreach($html as $req_by_degree_id => $content) {
  179. $dtitle = @$GLOBALS["fp_temp_degree_titles"][$req_by_degree_id];
  180. $dweight = intval(@$GLOBALS["fp_temp_degree_advising_weights"][$req_by_degree_id]);
  181. if ($dtitle == "") {
  182. $t_degree_plan = new DegreePlan();
  183. $t_degree_plan->degree_id = $req_by_degree_id;
  184. $dtitle = $t_degree_plan->get_title2(TRUE, TRUE);
  185. $dweight = $t_degree_plan->db_advising_weight;
  186. $dtype = $t_degree_plan->degree_type;
  187. $dclass = $t_degree_plan->degree_class;
  188. $dlevel = $t_degree_plan->degree_level;
  189. $GLOBALS["fp_temp_degree_types"][$req_by_degree_id] = $dtype; //save for next time.
  190. $GLOBALS["fp_temp_degree_classes"][$req_by_degree_id] = $dclass; //save for next time.
  191. $GLOBALS["fp_temp_degree_levels"][$req_by_degree_id] = $dlevel; //save for next time.
  192. $GLOBALS["fp_temp_degree_titles"][$req_by_degree_id] = $dtitle . " "; //save for next time.
  193. $GLOBALS["fp_temp_degree_advising_weights"][$req_by_degree_id] = $dweight . " "; //save for next time.
  194. }
  195. $degree_title = fp_get_machine_readable($dtitle); // make it machine readable. No funny characters.
  196. $degree_advising_weight = str_pad($dweight, 4, "0", STR_PAD_LEFT);
  197. $new_html[$degree_advising_weight . "__" . $degree_title][$req_by_degree_id] = $content;
  198. }
  199. // Sort by the first index, the advising weight.
  200. //fpm($new_html);
  201. ksort($new_html);
  202. //fpm($new_html);
  203. //////////////////////////
  204. // Okay, now let's go through our HTML array and add to the screen....
  205. foreach ($new_html as $w => $html) {
  206. foreach($html as $req_by_degree_id => $content) {
  207. // Get the degree title...
  208. $dtitle = @$GLOBALS["fp_temp_degree_titles"][$req_by_degree_id];
  209. $css_dtitle = @$GLOBALS["fp_temp_degree_css_titles"][$req_by_degree_id];
  210. $dtype = @$GLOBALS["fp_temp_degree_types"][$req_by_degree_id];
  211. $dclass = @$GLOBALS["fp_temp_degree_classes"][$req_by_degree_id];
  212. $dlevel = @$GLOBALS["fp_temp_degree_levels"][$req_by_degree_id];
  213. if ($dtitle == "" || $css_dtitle == "") {
  214. $t_degree_plan = new DegreePlan();
  215. $t_degree_plan->degree_id = $req_by_degree_id;
  216. $dtitle = $t_degree_plan->get_title2(TRUE, TRUE);
  217. $css_dtitle = $t_degree_plan->get_title2(TRUE, TRUE, FALSE);
  218. $dtype = $t_degree_plan->degree_type;
  219. $dclass = $t_degree_plan->degree_class;
  220. $dlevel = $t_degree_plan->degree_level;
  221. $GLOBALS["fp_temp_degree_types"][$req_by_degree_id] = $dtype; //save for next time.
  222. $GLOBALS["fp_temp_degree_classes"][$req_by_degree_id] = $dclass; //save for next time.
  223. $GLOBALS["fp_temp_degree_levels"][$req_by_degree_id] = $dlevel; //save for next time.
  224. $GLOBALS["fp_temp_degree_titles"][$req_by_degree_id] = $dtitle; //save for next time.
  225. $GLOBALS["fp_temp_degree_css_titles"][$req_by_degree_id] = $css_dtitle; //save for next time.
  226. }
  227. $css_dtitle = fp_get_machine_readable($css_dtitle);
  228. $theme = array(
  229. 'classes' => array('tenpt', 'required-by-degree',
  230. "required-by-degree-$css_dtitle",
  231. "required-by-degree-type-" . fp_get_machine_readable($dtype),
  232. "required-by-degree-class-" . fp_get_machine_readable($dclass),
  233. "required-by-degree-level-" . fp_get_machine_readable($dlevel),
  234. ),
  235. 'css_dtitle' => $css_dtitle,
  236. 'degree_id' => $req_by_degree_id,
  237. 'html' => "<span class='req-by-label'>" . t("Required by") . "</span> <span class='req-by-degree-title'>$dtitle</span>",
  238. 'view_by' => 'type',
  239. );
  240. invoke_hook("theme_advise_degree_header_row", array(&$theme));
  241. // TODO: Possibly don't display this if we only have one degree chosen?
  242. $pC .= "<tr><td colspan='8'>
  243. <div class='" . implode(' ',$theme['classes']) ."'>{$theme['html']}</div>
  244. </td></tr>";
  245. $pC .= $content;
  246. }
  247. }
  248. } // while list_semester
  249. if ($is_empty == TRUE) {
  250. // There was nothing in this box. Do not return anything.
  251. return FALSE;
  252. }
  253. // Add hour count to the bottom...
  254. if ($bool_display_hour_count == true && $count_hours_completed > 0)
  255. {
  256. $pC .= "<tr><td colspan='8'>
  257. <div class='tenpt advise-completed-hours' style='text-align:right; margin-top: 10px;'>
  258. <span class='completed-hours-label'>Completed hours:</span> <span class='count-hours-completed'>$count_hours_completed</span>
  259. </div>
  260. ";
  261. $pC .= "</td></tr>";
  262. }
  263. $pC .= $this->draw_semester_box_bottom();
  264. return $pC;
  265. }
  266. } //class