_Student.php

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

Classes

NameDescription
_Student

File

classes/_Student.php
View source
  1. <?php
  2. class _Student extends stdClass
  3. {
  4. public $student_id, $name, $major_code_array, $major_code_csv, $gpa, $cumulative_hours, $catalog_year;
  5. public $list_courses_taken, $list_courses_advised, $list_courses_added, $db, $rank, $db_rank;
  6. public $list_standardized_tests, $list_substitutions;
  7. public $list_transfer_eqvs_unassigned;
  8. public $array_settings, $array_significant_courses, $array_hide_grades_terms;
  9. function __construct($student_id = "", DatabaseHandler $db = NULL)
  10. {
  11. $this->student_id = $student_id;
  12. $this->array_hide_grades_terms = array();
  13. $this->array_significant_courses = array(); // array of course_ids
  14. // the student has taken, or has subs for (or transfer eqv's).
  15. // used later to help speed up assignCoursesToList in FlightPath.
  16. $this->db = $db;
  17. if ($db == NULL)
  18. {
  19. $this->db = get_global_database_handler();
  20. }
  21. // Go ahead and load and assemble
  22. // all information in the database on this student.
  23. $this->load_student();
  24. }
  25. /**
  26. * This is a stub function. If you are planning on hiding course grades
  27. * for a term at a time, you should override this method in /custom/classes
  28. * and place that logic here.
  29. *
  30. * For example,
  31. * at ULM, students cannot see their final grades for a term until they
  32. * have completed their course evaluations for every course they took that
  33. * term, OR, until 2 weeks have passed.
  34. *
  35. *
  36. *
  37. */
  38. function determine_terms_to_hide_grades()
  39. {
  40. return;
  41. }
  42. function load_student()
  43. {
  44. $this->list_transfer_eqvs_unassigned = new CourseList();
  45. $this->list_courses_taken = new CourseList();
  46. $this->list_courses_added = new CourseList();
  47. $this->list_substitutions = new SubstitutionList();
  48. $this->list_standardized_tests = new ObjList();
  49. $this->array_settings = array();
  50. if ($this->student_id != "")
  51. {
  52. $this->determine_terms_to_hide_grades();
  53. $this->load_transfer_eqvs_unassigned();
  54. $this->load_courses_taken();
  55. $this->load_student_data();
  56. $this->load_test_scores();
  57. $this->load_settings();
  58. $this->load_significant_courses();
  59. //$this->load_unassignments();
  60. //$this->load_student_substitutions();
  61. // If we are supposed to set cumulative hours and gpa, perform that
  62. // operation now.
  63. if (variable_get("calculate_cumulative_hours_and_gpa", FALSE)) {
  64. $arr = $this->calculate_cumulative_hours_and_gpa();
  65. $this->cumulative_hours = $arr["cumulative_total_hours"];
  66. $this->gpa = $arr["cumulative_gpa"];
  67. }
  68. }
  69. // When we load this student, let's also check for any hooks relating
  70. // to loading this student.
  71. // Since this class might be used outside of FP, only do this if we know
  72. // that the bootstrap.inc file has been executed.
  73. if ($GLOBALS["fp_bootstrap_loaded"] == TRUE) {
  74. invoke_hook("student_load", array(&$this));
  75. }
  76. }
  77. function load_significant_courses()
  78. {
  79. // This will attempt to add as much to the array_significant_courses
  80. // as we can, which was not previously determined.
  81. // For example: courses we were advised to take and/or
  82. // substitutions.
  83. // Now, when this gets called, it's actually *before* we
  84. // write any subs or advisings to the database, so what we
  85. // actually need to do is go through the POST
  86. // and add any course_id's we find.
  87. // In the future, perhaps it would be more efficient
  88. // to have just one POST variable to look at, perhaps
  89. // comma-seperated.
  90. // Look in the database of advised courses for ANY course advised in
  91. // the range of advisingTermIDs.
  92. $advising_term_ids = variable_get("available_advising_term_ids", "0");;
  93. $temp = explode(",",$advising_term_ids);
  94. foreach ($temp as $term_id)
  95. {
  96. $term_id = trim($term_id);
  97. $res = $this->db->db_query("SELECT * FROM advising_sessions a,
  98. advised_courses b
  99. WHERE a.student_id = ?
  100. AND a.advising_session_id = b.advising_session_id
  101. AND a.term_id = ?
  102. AND a.is_draft = '0' ", $this->student_id, $term_id);
  103. while ($cur = $this->db->db_fetch_array($res))
  104. {
  105. $this->array_significant_courses[$cur["course_id"]] = true;
  106. }
  107. }
  108. // Now, look for any course which a substitution might have been
  109. // performed for...
  110. $res = $this->db->db_query("SELECT * FROM student_substitutions
  111. WHERE student_id = ? ", $this->student_id);
  112. while ($cur = $this->db->db_fetch_array($res)) {
  113. $this->array_significant_courses[$cur["required_course_id"]] = true;
  114. }
  115. }
  116. function load_significant_courses_from_list_courses_taken() {
  117. // Build the array_significant_courses
  118. // entriely from list_courses_taken.
  119. $this->list_courses_taken->reset_counter();
  120. while($this->list_courses_taken->has_more())
  121. {
  122. $c = $this->list_courses_taken->get_next();
  123. $this->array_significant_courses[$c->course_id] = true;
  124. }
  125. }
  126. function load_settings() {
  127. // This will load & set up the array_settings variable for this
  128. // student.
  129. $res = $this->db->db_query("SELECT settings FROM student_settings
  130. WHERE
  131. student_id = ? ", $this->student_id);
  132. $cur = $this->db->db_fetch_array($res);
  133. if ($arr = unserialize($cur["settings"])) {
  134. $this->array_settings = $arr;
  135. }
  136. }
  137. function load_transfer_eqvs_unassigned()
  138. {
  139. $res = $this->db->db_query("SELECT `id`, transfer_course_id FROM student_unassign_transfer_eqv
  140. WHERE
  141. student_id = ?
  142. AND delete_flag='0'
  143. ORDER BY id ", $this->student_id);
  144. while($cur = $this->db->db_fetch_array($res))
  145. {
  146. extract ($cur, 3, "db");
  147. $new_course = new Course();
  148. $new_course->bool_transfer = true;
  149. $new_course->course_id = $db_transfer_course_id;
  150. $new_course->db_unassign_transfer_id = $db_id;
  151. $this->list_transfer_eqvs_unassigned->add($new_course);
  152. }
  153. }
  154. function init_semester_courses_added()
  155. {
  156. // The "Add a Course" box on screen is really just a
  157. // semester, with the number -88, with a single group,
  158. // also numbered -88.
  159. $this->semester_courses_added = new Semester(-88);
  160. $this->semester_courses_added->title = "Courses Added by Advisor";
  161. // Now, we want to add the Add a Course group...
  162. $g = new Group();
  163. $g->group_id = -88;
  164. // Since it would take a long time during page load, we will
  165. // leave this empty of courses for now. It doesn't matter anyway,
  166. // as we will not be checking this group for course membership
  167. // anyway. We only need to load it in the popup.
  168. $g->hours_required = 99999; // Nearly infinite selections may be made.
  169. $g->assigned_to_semester_num = -88;
  170. $g->title = "Add an Additional Course";
  171. $this->semester_courses_added->list_groups->add($g);
  172. }
  173. function load_unassignments()
  174. {
  175. // Load courses which have been unassigned from groups
  176. // or the bare degree plan.
  177. $res = db_query("SELECT * FROM student_unassign_group
  178. WHERE
  179. student_id='?'
  180. AND delete_flag='0' ", $this->student_id);
  181. while($cur = db_fetch_array($res))
  182. {
  183. extract ($cur, 3, "db");
  184. if ($taken_course = $this->list_courses_taken->find_specific_course($db_course_id, $db_term_id, (bool) $db_transfer_flag, TRUE, NULL, $db_degree_id))
  185. {
  186. // Add the group_id to this courses' list of unassigned groups.
  187. $new_group = new Group();
  188. $new_group->group_id = $db_group_id;
  189. $new_group->db_unassign_group_id = $db_id;
  190. $new_group->req_by_degree_id = $db_degree_id;
  191. $taken_course->group_list_unassigned->add($new_group);
  192. }
  193. }
  194. }
  195. function load_test_scores()
  196. {
  197. // If the student has any scores (from standardized tests)
  198. // then load them here.
  199. $st = null;
  200. $c = 0;
  201. $old_row = "";
  202. $res = db_query("SELECT * FROM student_tests
  203. WHERE student_id = ?
  204. ORDER BY date_taken DESC, test_id, category_id ", $this->student_id);
  205. while($cur = db_fetch_array($res)) {
  206. $c++;
  207. extract($cur, 3, "db");
  208. if (!isset($db_position)) $db_position = 0;
  209. // Get the test's description, if available.
  210. $res2 = db_query("SELECT * FROM standardized_tests
  211. WHERE test_id = '?'
  212. AND category_id = '?'
  213. ORDER BY position", $db_test_id, $db_category_id);
  214. $cur2 = db_fetch_array($res2);
  215. $db_test_description = trim($cur2["test_description"]);
  216. $db_category_description = trim($cur2["category_description"]);
  217. // Did we find anything in the table? If not, just use the codes themselves
  218. if ($db_test_description == "") $db_test_description = t("Test code:") . " " . $db_test_id;
  219. if ($db_category_description == "") $db_category_description = $db_category_id;
  220. if (!(($db_date_taken . $db_test_id) == $old_row))
  221. {
  222. // We are at a new test. Add the old test to our list.
  223. if ($st != null) {
  224. $this->list_standardized_tests->add($st);
  225. }
  226. $st = new StandardizedTest();
  227. $st->test_id = $db_test_id;
  228. $st->date_taken = $db_date_taken;
  229. // Is the date unavailable?
  230. if ($st->date_taken == "" || $st->date_taken == NULL || strstr($st->date_taken, "0000")) {
  231. $st->bool_date_unavailable = TRUE;
  232. }
  233. $st->description = $db_test_description;
  234. $old_row = $db_date_taken . $db_test_id;
  235. }
  236. $st->categories[$db_position . $c]["description"] = $db_category_description;
  237. $st->categories[$db_position . $c]["category_id"] = $db_category_id;
  238. $st->categories[$db_position . $c]["score"] = $db_score;
  239. }
  240. // Add the last one created.
  241. if ($st != null) {
  242. $this->list_standardized_tests->add($st);
  243. }
  244. }
  245. function load_student_substitutions()
  246. {
  247. // Load the substitutions which have been made for
  248. // this student.
  249. // Meant to be called AFTER load_courses_taken.
  250. $this->list_substitutions = new SubstitutionList();
  251. $res = $this->db->db_query("SELECT * FROM
  252. student_substitutions
  253. WHERE student_id='?'
  254. AND delete_flag='0' ", $this->student_id);
  255. while($cur = $this->db->db_fetch_array($res))
  256. {
  257. $sub_id = $cur["id"];
  258. $sub_course_id = $cur["sub_course_id"];
  259. $sub_term_id = $cur["sub_term_id"];
  260. $sub_bool_transfer = (bool) $cur["sub_transfer_flag"];
  261. $sub_hours = $cur["sub_hours"] * 1;
  262. $sub_remarks = trim($cur["sub_remarks"]);
  263. $faculty_id = $cur["faculty_id"];
  264. $req_by_degree_id = $cur["required_degree_id"];
  265. $db_required_degree_id = $req_by_degree_id;
  266. $db_required_group_id = $cur["required_group_id"];
  267. if (strstr($sub_term_id, "9999"))
  268. {
  269. // was an unknown semester. Let's set it lower so
  270. // it doesn't screw up my sorting.
  271. $sub_term_id = Course::COURSE_UNKNOWN_TERM_ID;
  272. }
  273. // Okay, look to see if we can find the course specified by this
  274. // courseSubstitution within the list of courses which the student
  275. // has taken. If the subHours is less than the hours_awarded for the
  276. // particular course, it means the course has been split up!
  277. if($taken_course = $this->list_courses_taken->find_specific_course($sub_course_id, $sub_term_id, $sub_bool_transfer, true, null, $req_by_degree_id))
  278. {
  279. // If this takenCourse is a transfer credit, then we want to remove
  280. // any automatic eqv it may have set.
  281. // We can do this easily by setting its course_id to 0.
  282. if ($sub_bool_transfer == true)
  283. {
  284. $taken_course->temp_old_course_id = $taken_course->course_id;
  285. $taken_course->course_id = 0;
  286. $taken_course->course_id = 0;
  287. }
  288. if ($sub_hours == 0)
  289. { // If none specified, assume its the full amount.
  290. $sub_hours = $taken_course->get_hours_awarded($req_by_degree_id);
  291. }
  292. if (($taken_course->get_hours_awarded($req_by_degree_id) > $sub_hours))
  293. {
  294. // Okay, now this means that the course which we are
  295. // using in the substitution-- the course which the student
  296. // has actually taken-- is being split up in the substitution.
  297. // We are only using a portion of its hours.
  298. // We MUST round, because if there is a decimal place, we might run into
  299. // trouble. Because, for example, 2.001 - 2 actually gets .00009999999 instead of .001.
  300. // The most decimals we can have is 4, so let's round to 6 decimal places, just to give
  301. // us some breathing room. That should take care of us without losing too much precision.
  302. $remaining_hours = round(($taken_course->get_hours_awarded($req_by_degree_id) - $sub_hours), 6);
  303. // Create a clone of the course with the leftover hours, and add
  304. // it back into the list_courses_taken.
  305. $new_course_string = $taken_course->to_data_string();
  306. $new_course = new Course();
  307. $new_course->load_course_from_data_string($new_course_string);
  308. $new_course->random_id = mt_rand(1,9999);
  309. $new_course->set_details_by_degree($req_by_degree_id, "bool_substitution_split", TRUE);
  310. $new_course->set_details_by_degree($req_by_degree_id, "bool_substitution_new_from_split", TRUE);
  311. $new_course->subject_id = $taken_course->subject_id;
  312. $new_course->course_num = $taken_course->course_num;
  313. $new_course->set_hours_awarded($req_by_degree_id, $remaining_hours);
  314. $new_course->req_by_degree_id = $req_by_degree_id;
  315. if (is_object($new_course->course_transfer))
  316. {
  317. $new_course->course_transfer->set_hours_awarded($req_by_degree_id, $remaining_hours);
  318. }
  319. //$taken_course->bool_substitution_split = true;
  320. $taken_course->set_details_by_degree($req_by_degree_id, "bool_substitution_split", TRUE);
  321. $taken_course->set_hours_awarded($req_by_degree_id, $sub_hours);
  322. if (is_object($taken_course->course_transfer))
  323. {
  324. $taken_course->course_transfer->set_hours_awarded($req_by_degree_id, $sub_hours);
  325. }
  326. // Add the newCourse back into the student's list_courses_taken.
  327. $this->list_courses_taken->add($new_course);
  328. }
  329. // Place in details_by_degree_array...
  330. //$taken_course->substitution_hours = $sub_hours;
  331. $taken_course->set_details_by_degree($req_by_degree_id, "substitution_hours", $sub_hours);
  332. $taken_course->set_bool_substitution($req_by_degree_id, TRUE);
  333. $taken_course->display_status = "completed";
  334. $taken_course->db_substitution_id_array[$req_by_degree_id] = $sub_id;
  335. $substitution = new Substitution();
  336. if ($cur["required_course_id"] > 0)
  337. {
  338. $course_requirement = new Course($cur["required_course_id"]);
  339. $this->array_significant_courses[$course_requirement->course_id] = true;
  340. } else
  341. {
  342. // This is a group addition!
  343. $course_requirement = new Course($sub_course_id, $sub_bool_transfer);
  344. $this->array_significant_courses[$sub_course_id] = true;
  345. $substitution->bool_group_addition = true;
  346. }
  347. //$course_requirement->assigned_to_group_id = $cur["required_group_id"];
  348. $course_requirement->assigned_to_group_ids_array[$cur["required_group_id"]] = $cur["required_group_id"];
  349. $course_requirement->assigned_to_semester_num = $cur["required_semester_num"];
  350. $course_requirement->req_by_degree_id = $req_by_degree_id;
  351. //$taken_course->assigned_to_group_id = $cur["required_group_id"];
  352. $taken_course->assigned_to_group_ids_array[$cur["required_group_id"]] = $cur["required_group_id"];
  353. $taken_course->assigned_to_semester_num = $cur["required_semester_num"];
  354. $taken_course->req_by_degree_id = $req_by_degree_id;
  355. $substitution->course_requirement = $course_requirement;
  356. $substitution->course_list_substitutions->add($taken_course);
  357. $substitution->remarks = $sub_remarks;
  358. $substitution->faculty_id = $faculty_id;
  359. $substitution->db_substitution_id = $sub_id;
  360. $substitution->assigned_to_degree_id = $req_by_degree_id;
  361. $substitution->db_required_degree_id = $req_by_degree_id;
  362. $substitution->db_required_group_id = $db_required_group_id;
  363. $this->list_substitutions->add($substitution);
  364. }
  365. }
  366. } //load_student_substitutions
  367. /**
  368. * This loads a student's personal data, like name and so forth.
  369. *
  370. */
  371. function load_student_data()
  372. {
  373. $cur = null;
  374. if (isset($GLOBALS['load_student_data'][$this->student_id])) {
  375. $cur = $GLOBALS['load_student_data'][$this->student_id];
  376. }
  377. else {
  378. $res = $this->db->db_query("SELECT cumulative_hours, gpa, rank_code, catalog_year FROM students WHERE cwid='?'",$this->student_id);
  379. $cur = $this->db->db_fetch_array($res);
  380. $GLOBALS['load_student_data'][$this->student_id] = $cur;
  381. }
  382. $this->cumulative_hours = $cur['cumulative_hours'];
  383. $this->gpa = $cur['gpa'];
  384. $this->db_rank = $cur['rank_code'];
  385. $this->catalog_year = $cur['catalog_year'];
  386. $this->rank = $this->get_rank_description($this->db_rank);
  387. $this->major_code_array = fp_get_student_majors($this->student_id, FALSE);
  388. $this->major_code_csv = '';
  389. foreach ($this->major_code_array as $k => $v) {
  390. $this->major_code_csv .= $k . ',';
  391. }
  392. $this->major_code_csv = rtrim($this->major_code_csv,',');
  393. $this->name = $this->db->get_student_name($this->student_id);
  394. /*
  395. $this->cumulative_hours = $this->db->get_student_cumulative_hours($this->student_id);
  396. $this->gpa = $this->db->get_student_gpa($this->student_id);
  397. $this->db_rank = $this->db->get_student_rank($this->student_id);
  398. $this->rank = $this->get_rank_description($this->db_rank);
  399. $this->major_code_array = fp_get_student_majors($this->student_id, FALSE);
  400. $this->major_code_csv = fp_get_student_majors($this->student_id, TRUE);
  401. $this->catalog_year = $this->db->get_student_catalog_year($this->student_id);
  402. $this->name = $this->db->get_student_name($this->student_id);
  403. */
  404. }
  405. /**
  406. * This function will look at the courses which the student has taken, to calculate
  407. * the cumulative hours and gpa, rather than just load them from the db table.
  408. *
  409. * It will then return the values in an assoc array for later use. For example, you
  410. * may want to set $this->cumulative_hours and $this->gpa to them.
  411. *
  412. */
  413. function calculate_cumulative_hours_and_gpa() {
  414. $cumulative_hours = 0;
  415. $cumulative_points = 0;
  416. $cumulative_total_hours = $this->list_courses_taken->count_credit_hours("", FALSE, TRUE, FALSE);
  417. $cumulative_quality_hours = $this->list_courses_taken->count_credit_hours("", FALSE, TRUE, TRUE);
  418. $cumulative_quality_points = $this->list_courses_taken->count_credit_quality_points("", FALSE, TRUE);
  419. $cgpa = FALSE;
  420. if ($cumulative_quality_hours > 0) {
  421. $cgpa = fp_truncate_decimals($cumulative_quality_points / $cumulative_quality_hours, 3);
  422. }
  423. return array(
  424. "cumulative_total_hours" => $cumulative_total_hours,
  425. "cumulative_quality_hours" => $cumulative_quality_hours,
  426. "cumulative_quality_points" => $cumulative_quality_points,
  427. "cumulative_gpa" => $cgpa,
  428. );
  429. }
  430. /**
  431. * Given a rank_code like FR, SO, etc., get the english
  432. * description. For example: Freshman, Sophomore, etc.
  433. *
  434. */
  435. function get_rank_description($rank_code = "") {
  436. // TODO: Maybe this should be a setting somewhere instead of hard-coded?
  437. $rank_array = array(
  438. "FR"=>t("Freshman"),
  439. "SO"=>t("Sophomore"),
  440. "JR"=>t("Junior"),
  441. "SR"=>t("Senior"),
  442. "PR"=>t("Professional"),
  443. );
  444. return @$rank_array[$rank_code];
  445. }
  446. /**
  447. * Returns a student's degree plan object.
  448. *
  449. */
  450. function get_degree_plan($bool_load_full = true, $bool_ignore_settings = false)
  451. {
  452. depricated_message();
  453. $t_major_code = $this->get_major_and_track_code($bool_ignore_settings);
  454. $degree_id = $this->db->get_degree_id($t_major_code, $this->catalog_year);
  455. if ($bool_load_full)
  456. {
  457. $degree_plan = new DegreePlan($degree_id, $this->db);
  458. } else {
  459. $degree_plan = new DegreePlan();
  460. $degree_plan->degree_id = $degree_id;
  461. $degree_plan->load_descriptive_data();
  462. }
  463. return $degree_plan;
  464. }
  465. /**
  466. * Enter description here...
  467. * Returns the major code and trackCode, if it exists in this form:
  468. * MAJOR|CONC_TRACK
  469. * Though usually it will be:
  470. * MAJR|_TRCK
  471. * Asumes you have already called "load_settings()";
  472. */
  473. function get_major_and_track_code($bool_ignore_settings = false)
  474. {
  475. $rtn = "";
  476. $major_code = "";
  477. if (@$this->array_settings["major_code_csv"] != "") {
  478. $rtn = $this->array_settings["major_code_csv"];
  479. }
  480. /*
  481. if ($this->array_settings["major_code"] != "")
  482. { // If they have settings saved, use those...
  483. if ($this->array_settings["track_code"] != "")
  484. {
  485. // if it does NOT have a | in it already....
  486. if (!strstr($this->array_settings["major_code"], "|"))
  487. {
  488. $rtn = $this->array_settings["major_code"] . "|_" . $this->array_settings["track_code"];
  489. } else {
  490. // it DOES have a | already, so we join with just a _. This would
  491. // be the case if we have a track AND an concentration.
  492. $rtn = $this->array_settings["major_code"] . "_" . $this->array_settings["track_code"];
  493. }
  494. } else {
  495. $rtn = $this->array_settings["major_code"];
  496. }
  497. $major_code = $this->array_settings["major_code"];
  498. } else {
  499. $rtn = $this->major_code;
  500. }
  501. */
  502. if ($bool_ignore_settings == true) {
  503. $rtn = $this->major_code;
  504. }
  505. return $rtn;
  506. }
  507. function load_courses_taken($bool_load_transfer_credits = true)
  508. {
  509. $retake_grades = csv_to_array($GLOBALS["fp_system_settings"]["retake_grades"]);
  510. $not_released_grades_terms = csv_to_array(variable_get("not_released_grades_terms"));
  511. // This will create and load the list_courses_taken list.
  512. // contains SQL queries to fully create the list_courses_taken.
  513. $res = $this->db->db_query("SELECT * FROM student_courses
  514. WHERE
  515. student_id = ? ", $this->student_id);
  516. while($cur = $this->db->db_fetch_array($res)) {
  517. // Create a course object for this course...
  518. $is_transfer = false;
  519. $course_id = $this->db->get_course_id($cur["subject_id"], $cur["course_num"]);
  520. if (!$course_id) {
  521. fpm("Course not found while trying to load student data: {$cur["subject_id"]} {$cur["course_num"]}");
  522. continue;
  523. }
  524. // Are these grades (terms) not released yet?
  525. if (in_array($cur["term_id"], $not_released_grades_terms)) {
  526. $cur["grade"] = "";
  527. }
  528. $new_course = new Course();
  529. $new_course->course_id = $course_id;
  530. // Load descriptive data for this course from the catalog (so we can get min, max, and repeat hours)
  531. $new_course->load_descriptive_data();
  532. // Now, over-write whatever we got from the descriptive data with what the course was called
  533. // when the student took it.
  534. $new_course->subject_id = $cur["subject_id"];
  535. $new_course->course_num = $cur["course_num"];
  536. $new_course->grade = $cur["grade"];
  537. $new_course->term_id = $cur["term_id"];
  538. $new_course->level_code = $cur["level_code"];
  539. // Is this grade supposed to be hidden from students (and this user is probably
  540. // a student)
  541. if (in_array($new_course->term_id, $this->array_hide_grades_terms)
  542. && !user_has_permission("can_advise_students"))
  543. {
  544. $new_course->bool_hide_grade = true;
  545. }
  546. $new_course->set_hours_awarded(0, $cur["hours_awarded"] * 1);
  547. $new_course->display_status = "completed";
  548. $new_course->bool_taken = true;
  549. // Was this course worth 0 hours but they didn't fail it?
  550. // If so, we need to set it to actually be 1 hour, and
  551. // indicate this is a "ghost hour."
  552. if (!in_array($new_course->grade, $retake_grades)
  553. && $new_course->get_hours_awarded() == 0)
  554. {
  555. $new_course->set_hours_awarded(0, 1);
  556. $new_course->bool_ghost_hour = TRUE;
  557. }
  558. // Now, add the course to the list_courses_taken...
  559. $this->list_courses_taken->add($new_course);
  560. $this->array_significant_courses[$course_id] = true;
  561. }
  562. if ($bool_load_transfer_credits == false) {
  563. return;
  564. }
  565. ////////////////////////////////////////////////////////////
  566. // Tranfer credits? Get those too...
  567. $res = $this->db->db_query("
  568. SELECT *
  569. FROM student_transfer_courses a,
  570. transfer_courses b
  571. WHERE a.transfer_course_id = b.transfer_course_id
  572. AND a.student_id = '?' ", $this->student_id);
  573. while($cur = $this->db->db_fetch_array($res))
  574. {
  575. $transfer_course_id = $cur['transfer_course_id'];
  576. $institution_id = $cur["institution_id"];
  577. $new_course = new Course();
  578. // Find out if this course has an eqv.
  579. if ($course_id = $this->get_transfer_course_eqv($transfer_course_id, FALSE, "", $cur["hours_awarded"]))
  580. {
  581. $new_course = new Course($course_id);
  582. $this->array_significant_courses[$course_id] = true;
  583. }
  584. $t_course = new Course();
  585. $t_course->subject_id = $cur['subject_id'];
  586. $t_course->course_num = $cur['course_num'];
  587. $t_course->level_code = $cur['level_code'];
  588. $t_course->course_id = $transfer_course_id;
  589. $t_course->bool_transfer = true;
  590. $t_course->institution_id = $institution_id;
  591. $new_course->bool_transfer = true;
  592. $new_course->course_transfer = $t_course;
  593. $new_course->grade = $cur['grade'];
  594. $t_course->grade = $cur['grade'];
  595. $new_course->set_hours_awarded(0, $cur['hours_awarded'] * 1);
  596. $t_course->set_hours_awarded(0, $cur['hours_awarded'] * 1);
  597. $new_course->level_code = $t_course->level_code;
  598. // Was this course worth 0 hours but they didn't fail it?
  599. // If so, we need to set it to actually be 1 hour, and
  600. // indicate this is a "ghost hour."
  601. if (!in_array($new_course->grade, $retake_grades)
  602. && $new_course->get_hours_awarded() == 0)
  603. {
  604. $new_course->set_hours_awarded(0, 1);
  605. $new_course->bool_ghost_hour = TRUE;
  606. $t_course->set_hours_awarded(0, 1);
  607. $t_course->bool_ghost_hour = TRUE;
  608. }
  609. $new_course->bool_taken = true;
  610. $t_course->bool_taken = true;
  611. $new_course->term_id = $cur['term_id'];
  612. if (strstr($new_course->term_id, "9999")) {
  613. // was an unknown semester. Let's set it lower so
  614. // it doesn't screw up my sorting.
  615. $new_course->term_id = Course::COURSE_UNKNOWN_TERM_ID;
  616. }
  617. $t_course->term_id = $new_course->term_id;
  618. $new_course->display_status = "completed";
  619. $this->list_courses_taken->add($new_course);
  620. }
  621. // print_pre($this->list_courses_taken->to_string());
  622. }
  623. /**
  624. * This function will find the best grade the student made on a particular course, and return it.
  625. *
  626. * It will return FALSE if the student never took the course.
  627. *
  628. * @param unknown_type $course
  629. */
  630. function get_best_grade_for_course(Course $course) {
  631. $rtn = FALSE;
  632. // To help speed things up, let's see if we have cached this course already.
  633. if (isset($GLOBALS['fp_temp_cache_' . $this->student_id]['best_grade_for_course'][$course->course_id])) {
  634. return $GLOBALS['fp_temp_cache_' . $this->student_id]['best_grade_for_course'][$course->course_id];
  635. }
  636. $c = $this->list_courses_taken->find_best_grade_match($course);
  637. if ($c) {
  638. $rtn = $c->grade;
  639. }
  640. // Set into our cache
  641. $GLOBALS['fp_temp_cache_' . $this->student_id]['best_grade_for_course'][$course->course_id] = $rtn;
  642. return $rtn;
  643. }
  644. /**
  645. * Find a transfer eqv for this student, for this course in question.
  646. *
  647. */
  648. function get_transfer_course_eqv($transfer_course_id, $bool_ignore_unassigned = false, $require_valid_term_id = "", $require_hours = -1)
  649. {
  650. // First, make sure that this transfer course hasn't
  651. // been unassigned. Do this by checking through
  652. // the student's courseListUnassignedTransferEQVs.
  653. $temp_course = new Course();
  654. $temp_course->course_id = $transfer_course_id;
  655. if ($bool_ignore_unassigned == false && $this->list_transfer_eqvs_unassigned->find_match($temp_course)) {
  656. // The transfer course in question has had its eqv removed,
  657. // so skip it!
  658. return false;
  659. }
  660. $valid_term_line = "";
  661. if ($require_valid_term_id != "") {
  662. // We are requesting eqv's only from a particular valid term, so, amend
  663. // the query.
  664. $valid_term_line = "AND valid_term_id = $require_valid_term_id ";
  665. }
  666. // Does the supplied transfer course ID have an eqv?
  667. $res = $this->db->db_query("
  668. SELECT local_course_id FROM transfer_eqv_per_student
  669. WHERE transfer_course_id = ?
  670. AND student_id = ?
  671. AND broken_id = 0
  672. $valid_term_line ", $transfer_course_id, $this->student_id);
  673. if ($cur = $this->db->db_fetch_array($res)) {
  674. $local_course_id = $cur['local_course_id'];
  675. // If we require that the local course have the same number of hours
  676. // as the transfer, then check that now.
  677. if ($require_hours != -1) {
  678. $temp_course = new Course($local_course_id);
  679. if (($temp_course->max_hours*1) != ($require_hours*1)) {
  680. return FALSE;
  681. }
  682. else {
  683. return $local_course_id;
  684. }
  685. }
  686. else {
  687. return $local_course_id;
  688. }
  689. }
  690. return false;
  691. }
  692. function to_string() {
  693. $rtn = "Student Information:\n";
  694. $rtn .= " Courses Taken:\n";
  695. $rtn .= $this->list_courses_taken->to_string();
  696. return $rtn;
  697. }
  698. } // end class Student