_Student.php

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

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. // Get our rank descriptions from our setting.
  437. $temp = variable_get("rank_descriptions", "FR ~ Freshman\nSO ~ Sophomore\nJR ~ Junior\nSR ~ Senior\nPR ~ Professional\nGR ~ Graduate");
  438. $lines = explode("\n", $temp);
  439. foreach ($lines as $line) {
  440. $temp = explode("~", $line);
  441. $rank_array[trim($temp[0])] = trim($temp[1]);
  442. }
  443. $rank_desc = @$rank_array[$rank_code];
  444. // If a description isn't found, just return the code itself.
  445. if ($rank_desc == '') $rank_desc = $rank_code;
  446. return $rank_desc;
  447. }
  448. /**
  449. * Returns a student's degree plan object.
  450. *
  451. */
  452. function get_degree_plan($bool_load_full = true, $bool_ignore_settings = false)
  453. {
  454. depricated_message();
  455. $t_major_code = $this->get_major_and_track_code($bool_ignore_settings);
  456. $degree_id = $this->db->get_degree_id($t_major_code, $this->catalog_year);
  457. if ($bool_load_full)
  458. {
  459. $degree_plan = new DegreePlan($degree_id, $this->db);
  460. } else {
  461. $degree_plan = new DegreePlan();
  462. $degree_plan->degree_id = $degree_id;
  463. $degree_plan->load_descriptive_data();
  464. }
  465. return $degree_plan;
  466. }
  467. /**
  468. * Enter description here...
  469. * Returns the major code and trackCode, if it exists in this form:
  470. * MAJOR|CONC_TRACK
  471. * Though usually it will be:
  472. * MAJR|_TRCK
  473. * Asumes you have already called "load_settings()";
  474. */
  475. function get_major_and_track_code($bool_ignore_settings = false)
  476. {
  477. $rtn = "";
  478. $major_code = "";
  479. if (@$this->array_settings["major_code_csv"] != "") {
  480. $rtn = $this->array_settings["major_code_csv"];
  481. }
  482. /*
  483. if ($this->array_settings["major_code"] != "")
  484. { // If they have settings saved, use those...
  485. if ($this->array_settings["track_code"] != "")
  486. {
  487. // if it does NOT have a | in it already....
  488. if (!strstr($this->array_settings["major_code"], "|"))
  489. {
  490. $rtn = $this->array_settings["major_code"] . "|_" . $this->array_settings["track_code"];
  491. } else {
  492. // it DOES have a | already, so we join with just a _. This would
  493. // be the case if we have a track AND an concentration.
  494. $rtn = $this->array_settings["major_code"] . "_" . $this->array_settings["track_code"];
  495. }
  496. } else {
  497. $rtn = $this->array_settings["major_code"];
  498. }
  499. $major_code = $this->array_settings["major_code"];
  500. } else {
  501. $rtn = $this->major_code;
  502. }
  503. */
  504. if ($bool_ignore_settings == true) {
  505. $rtn = $this->major_code;
  506. }
  507. return $rtn;
  508. }
  509. function load_courses_taken($bool_load_transfer_credits = true)
  510. {
  511. $retake_grades = csv_to_array($GLOBALS["fp_system_settings"]["retake_grades"]);
  512. $not_released_grades_terms = csv_to_array(variable_get("not_released_grades_terms"));
  513. // This will create and load the list_courses_taken list.
  514. // contains SQL queries to fully create the list_courses_taken.
  515. $res = $this->db->db_query("SELECT * FROM student_courses
  516. WHERE
  517. student_id = ? ", $this->student_id);
  518. while($cur = $this->db->db_fetch_array($res)) {
  519. // Create a course object for this course...
  520. $is_transfer = false;
  521. $course_id = $this->db->get_course_id($cur["subject_id"], $cur["course_num"]);
  522. if (!$course_id) {
  523. fpm("Course not found while trying to load student data: {$cur["subject_id"]} {$cur["course_num"]}");
  524. continue;
  525. }
  526. // Are these grades (terms) not released yet?
  527. if (in_array($cur["term_id"], $not_released_grades_terms)) {
  528. $cur["grade"] = "";
  529. }
  530. $new_course = new Course();
  531. $new_course->course_id = $course_id;
  532. // Load descriptive data for this course from the catalog (so we can get min, max, and repeat hours)
  533. $new_course->load_descriptive_data();
  534. // Now, over-write whatever we got from the descriptive data with what the course was called
  535. // when the student took it.
  536. $new_course->subject_id = $cur["subject_id"];
  537. $new_course->course_num = $cur["course_num"];
  538. $new_course->grade = $cur["grade"];
  539. $new_course->term_id = $cur["term_id"];
  540. $new_course->level_code = $cur["level_code"];
  541. // Is this grade supposed to be hidden from students (and this user is probably
  542. // a student)
  543. if (in_array($new_course->term_id, $this->array_hide_grades_terms)
  544. && !user_has_permission("can_advise_students"))
  545. {
  546. $new_course->bool_hide_grade = true;
  547. }
  548. $new_course->set_hours_awarded(0, $cur["hours_awarded"] * 1);
  549. $new_course->display_status = "completed";
  550. $new_course->bool_taken = true;
  551. // Was this course worth 0 hours but they didn't fail it?
  552. // If so, we need to set it to actually be 1 hour, and
  553. // indicate this is a "ghost hour."
  554. if (!in_array($new_course->grade, $retake_grades)
  555. && $new_course->get_hours_awarded() == 0)
  556. {
  557. $new_course->set_hours_awarded(0, 1);
  558. $new_course->bool_ghost_hour = TRUE;
  559. }
  560. // Now, add the course to the list_courses_taken...
  561. $this->list_courses_taken->add($new_course);
  562. $this->array_significant_courses[$course_id] = true;
  563. }
  564. if ($bool_load_transfer_credits == false) {
  565. return;
  566. }
  567. ////////////////////////////////////////////////////////////
  568. // Tranfer credits? Get those too...
  569. $res = $this->db->db_query("
  570. SELECT *
  571. FROM student_transfer_courses a,
  572. transfer_courses b
  573. WHERE a.transfer_course_id = b.transfer_course_id
  574. AND a.student_id = '?' ", $this->student_id);
  575. while($cur = $this->db->db_fetch_array($res))
  576. {
  577. $transfer_course_id = $cur['transfer_course_id'];
  578. $institution_id = $cur["institution_id"];
  579. $new_course = new Course();
  580. // Find out if this course has an eqv.
  581. if ($course_id = $this->get_transfer_course_eqv($transfer_course_id, FALSE, "", $cur["hours_awarded"]))
  582. {
  583. $new_course = new Course($course_id);
  584. $this->array_significant_courses[$course_id] = true;
  585. }
  586. $t_course = new Course();
  587. $t_course->subject_id = $cur['subject_id'];
  588. $t_course->course_num = $cur['course_num'];
  589. $t_course->level_code = $cur['level_code'];
  590. $t_course->course_id = $transfer_course_id;
  591. $t_course->bool_transfer = true;
  592. $t_course->institution_id = $institution_id;
  593. $new_course->bool_transfer = true;
  594. $new_course->course_transfer = $t_course;
  595. $new_course->grade = $cur['grade'];
  596. $t_course->grade = $cur['grade'];
  597. $new_course->set_hours_awarded(0, $cur['hours_awarded'] * 1);
  598. $t_course->set_hours_awarded(0, $cur['hours_awarded'] * 1);
  599. $new_course->level_code = $t_course->level_code;
  600. // Was this course worth 0 hours but they didn't fail it?
  601. // If so, we need to set it to actually be 1 hour, and
  602. // indicate this is a "ghost hour."
  603. if (!in_array($new_course->grade, $retake_grades)
  604. && $new_course->get_hours_awarded() == 0)
  605. {
  606. $new_course->set_hours_awarded(0, 1);
  607. $new_course->bool_ghost_hour = TRUE;
  608. $t_course->set_hours_awarded(0, 1);
  609. $t_course->bool_ghost_hour = TRUE;
  610. }
  611. $new_course->bool_taken = true;
  612. $t_course->bool_taken = true;
  613. $new_course->term_id = $cur['term_id'];
  614. if (strstr($new_course->term_id, "9999")) {
  615. // was an unknown semester. Let's set it lower so
  616. // it doesn't screw up my sorting.
  617. $new_course->term_id = Course::COURSE_UNKNOWN_TERM_ID;
  618. }
  619. $t_course->term_id = $new_course->term_id;
  620. $new_course->display_status = "completed";
  621. $this->list_courses_taken->add($new_course);
  622. }
  623. // print_pre($this->list_courses_taken->to_string());
  624. }
  625. /**
  626. * This function will find the best grade the student made on a particular course, and return it.
  627. *
  628. * It will return FALSE if the student never took the course.
  629. *
  630. * @param unknown_type $course
  631. */
  632. function get_best_grade_for_course(Course $course) {
  633. $rtn = FALSE;
  634. // To help speed things up, let's see if we have cached this course already.
  635. if (isset($GLOBALS['fp_temp_cache_' . $this->student_id]['best_grade_for_course'][$course->course_id])) {
  636. return $GLOBALS['fp_temp_cache_' . $this->student_id]['best_grade_for_course'][$course->course_id];
  637. }
  638. $c = $this->list_courses_taken->find_best_grade_match($course);
  639. if ($c) {
  640. $rtn = $c->grade;
  641. }
  642. // Set into our cache
  643. $GLOBALS['fp_temp_cache_' . $this->student_id]['best_grade_for_course'][$course->course_id] = $rtn;
  644. return $rtn;
  645. }
  646. /**
  647. * Find a transfer eqv for this student, for this course in question.
  648. *
  649. */
  650. function get_transfer_course_eqv($transfer_course_id, $bool_ignore_unassigned = false, $require_valid_term_id = "", $require_hours = -1)
  651. {
  652. // First, make sure that this transfer course hasn't
  653. // been unassigned. Do this by checking through
  654. // the student's courseListUnassignedTransferEQVs.
  655. $temp_course = new Course();
  656. $temp_course->course_id = $transfer_course_id;
  657. if ($bool_ignore_unassigned == false && $this->list_transfer_eqvs_unassigned->find_match($temp_course)) {
  658. // The transfer course in question has had its eqv removed,
  659. // so skip it!
  660. return false;
  661. }
  662. $valid_term_line = "";
  663. if ($require_valid_term_id != "") {
  664. // We are requesting eqv's only from a particular valid term, so, amend
  665. // the query.
  666. $valid_term_line = "AND valid_term_id = $require_valid_term_id ";
  667. }
  668. // Does the supplied transfer course ID have an eqv?
  669. $res = $this->db->db_query("
  670. SELECT local_course_id FROM transfer_eqv_per_student
  671. WHERE transfer_course_id = ?
  672. AND student_id = ?
  673. AND broken_id = 0
  674. $valid_term_line ", $transfer_course_id, $this->student_id);
  675. if ($cur = $this->db->db_fetch_array($res)) {
  676. $local_course_id = $cur['local_course_id'];
  677. // If we require that the local course have the same number of hours
  678. // as the transfer, then check that now.
  679. if ($require_hours != -1) {
  680. $temp_course = new Course($local_course_id);
  681. if (($temp_course->max_hours*1) != ($require_hours*1)) {
  682. return FALSE;
  683. }
  684. else {
  685. return $local_course_id;
  686. }
  687. }
  688. else {
  689. return $local_course_id;
  690. }
  691. }
  692. return false;
  693. }
  694. function to_string() {
  695. $rtn = "Student Information:\n";
  696. $rtn .= " Courses Taken:\n";
  697. $rtn .= $this->list_courses_taken->to_string();
  698. return $rtn;
  699. }
  700. } // end class Student

Classes

Namesort descending Description
_Student