function _Student::load_courses_taken
Search API
4.x _Student.php | _Student::load_courses_taken($bool_load_transfer_credits = true) |
5.x _Student.php | _Student::load_courses_taken($bool_load_transfer_credits = true) |
1 call to _Student::load_courses_taken()
- _Student::load_student in classes/
_Student.php
File
- classes/
_Student.php, line 671
Class
Code
function load_courses_taken($bool_load_transfer_credits = true)
{
$retake_grades = csv_to_array($GLOBALS ["fp_system_settings"]["retake_grades"]);
$not_released_grades_terms = csv_to_array(variable_get("not_released_grades_terms"));
// This will create and load the list_courses_taken list.
// contains SQL queries to fully create the list_courses_taken.
$res = $this->db->db_query("SELECT * FROM student_courses
WHERE
student_id = ? ", $this->student_id);
while ($cur = $this->db->db_fetch_array($res)) {
// Create a course object for this course...
$is_transfer = false;
$course_id = $this->db->get_course_id($cur ["subject_id"], $cur ["course_num"]);
if (!$course_id) {
fpm("Course not found while trying to load student data: {$cur ["subject_id"]} {$cur ["course_num"]}");
continue;
}
// Are these grades (terms) not released yet?
if (in_array($cur ["term_id"], $not_released_grades_terms)) {
$cur ["grade"] = "";
}
$new_course = new Course();
$new_course->course_id = $course_id;
// Load descriptive data for this course from the catalog (so we can get min, max, and repeat hours)
$new_course->load_descriptive_data();
// Now, over-write whatever we got from the descriptive data with what the course was called
// when the student took it.
$new_course->subject_id = $cur ["subject_id"];
$new_course->course_num = $cur ["course_num"];
$new_course->grade = $cur ["grade"];
$new_course->term_id = $cur ["term_id"];
$new_course->level_code = $cur ["level_code"];
// Is this grade supposed to be hidden from students (and this user is probably
// a student)
if (in_array($new_course->term_id, $this->array_hide_grades_terms)
&& !user_has_permission("can_advise_students"))
{
$new_course->bool_hide_grade = true;
}
$new_course->set_hours_awarded(0, $cur ["hours_awarded"] * 1);
$new_course->display_status = "completed";
$new_course->bool_taken = true;
// Was this course worth 0 hours but they didn't fail it?
// If so, we need to set it to actually be 1 hour, and
// indicate this is a "ghost hour."
if (!in_array($new_course->grade, $retake_grades)
&& $new_course->get_hours_awarded() == 0)
{
$new_course->set_hours_awarded(0, 1);
$new_course->bool_ghost_hour = TRUE;
}
// Now, add the course to the list_courses_taken...
$this->list_courses_taken->add($new_course);
$this->array_significant_courses [$course_id] = true;
}
if ($bool_load_transfer_credits == false) {
return;
}
////////////////////////////////////////////////////////////
// Tranfer credits? Get those too...
$res = $this->db->db_query("
SELECT *
FROM student_transfer_courses a,
transfer_courses b
WHERE a.transfer_course_id = b.transfer_course_id
AND a.student_id = '?' ", $this->student_id);
while ($cur = $this->db->db_fetch_array($res))
{
$transfer_course_id = $cur ['transfer_course_id'];
$institution_id = $cur ["institution_id"];
$new_course = new Course();
// Find out if this course has an eqv.
if ($course_id = $this->get_transfer_course_eqv($transfer_course_id, FALSE, "", $cur ["hours_awarded"]))
{
$new_course = new Course($course_id);
$this->array_significant_courses [$course_id] = true;
}
$t_course = new Course();
$t_course->subject_id = $cur ['subject_id'];
$t_course->course_num = $cur ['course_num'];
$t_course->level_code = $cur ['level_code'];
$t_course->course_id = $transfer_course_id;
$t_course->bool_transfer = true;
$t_course->institution_id = $institution_id;
$new_course->bool_transfer = true;
$new_course->course_transfer = $t_course;
$new_course->grade = $cur ['grade'];
$t_course->grade = $cur ['grade'];
$new_course->set_hours_awarded(0, $cur ['hours_awarded'] * 1);
$t_course->set_hours_awarded(0, $cur ['hours_awarded'] * 1);
$new_course->level_code = $t_course->level_code;
// Was this course worth 0 hours but they didn't fail it?
// If so, we need to set it to actually be 1 hour, and
// indicate this is a "ghost hour."
if (!in_array($new_course->grade, $retake_grades)
&& $new_course->get_hours_awarded() == 0)
{
$new_course->set_hours_awarded(0, 1);
$new_course->bool_ghost_hour = TRUE;
$t_course->set_hours_awarded(0, 1);
$t_course->bool_ghost_hour = TRUE;
}
$new_course->bool_taken = true;
$t_course->bool_taken = true;
$new_course->term_id = $cur ['term_id'];
if (strstr($new_course->term_id, "9999")) {
// was an unknown semester. Let's set it lower so
// it doesn't screw up my sorting.
$new_course->term_id = Course::COURSE_UNKNOWN_TERM_ID;
}
$t_course->term_id = $new_course->term_id;
$new_course->display_status = "completed";
$this->list_courses_taken->add($new_course);
}
// print_pre($this->list_courses_taken->to_string());
}