Student.php

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

Classes

Namesort descending Description
Student