Student.php

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

Classes

Namesort descending Description
Student