function _Course::load_course_from_data_string
Search API
4.x _Course.php | _Course::load_course_from_data_string($str) |
5.x _Course.php | _Course::load_course_from_data_string($str) |
This will take a data string, as created by the function to_data_string(), and make $this object match the original object. It is a poor man's unserialize. See to_data_string()'s description for a fuller picture of what is going on.
To use:
- $newCourse = new Course();
- $newCourse->load_course_from_data_string($data);
Parameters
string $str:
1 call to _Course::load_course_from_data_string()
- _Course::load_course_from_data_string_for_requirement_clone in classes/
_Course.php - This function uses load_course_from_data_string, but it removes any elements which might interfere with the course object then being used as a requirement. This is used specifically by the FlightPath object, when creating a clone of a repeatable course.
File
- classes/
_Course.php, line 720
Class
Code
function load_course_from_data_string($str)
{
$temp = explode("~", $str);
$this->course_id = $temp [0];
$this->load_course($this->course_id);
$this->assigned_to_semester_num = $temp [1];
$this->assigned_to_group_ids_array = fp_explode_assoc($temp [2]);
$this->bool_advised_to_take = (bool) $temp [3];
$this->specified_repeats = $temp [4];
$this->bool_specified_repeat = (bool) $temp [5];
$this->grade = $temp [6];
$this->set_hours_awarded(0, $temp [7] * 1); // *1 to force numeric, and trim extra zeros.
$this->term_id = $temp [8];
$this->advised_hours = $temp [9] * 1;
$this->bool_transfer = (bool) $temp [10];
// Was this a transfer course?
if ($this->bool_transfer == true)
{
$t_course = new Course($temp [11], true);
$t_course->term_id = $this->term_id;
$this->course_transfer = $t_course;
}
$this->bool_added_course = (bool) $temp [12];
$this->db_advised_courses_id = $temp [13];
$this->random_id = $temp [14];
//$this->bool_substitution_by_degree_array = fp_explode_assoc($temp[15]);
$this->set_degree_details_from_data_array(fp_explode_assoc($temp [15]), "bool_substitution");
// Was this a substitution course?
if (trim($temp [16]) != "")
{
$arr = fp_explode_assoc($temp [16]);
foreach ($arr as $did => $cid) {
$t_course = new Course($cid); // original course requirement.
$t_course->req_by_degree_id = $did;
$this->set_course_substitution($did, $t_course);
}
/*
$temp2 = explode(",", $temp[16]); // contains course_id,req_by_degree_id. Need to split the values up.
$t_course = new Course($temp2[0]); // original course requirement.
$t_course->req_by_degree_id = $temp2[1];
$this->course_substitution = $t_course;
*/
}
$this->db_substitution_id_array = fp_explode_assoc($temp [17]);
$this->min_hours = $temp [18] * 1;
$this->max_hours = $temp [19] * 1;
//$this->bool_substitution_new_from_split = (bool) $temp[20];
$this->set_degree_details_from_data_array(fp_explode_assoc($temp [20]), "bool_substitution_new_from_split");
//$this->bool_substitution_split = (bool) $temp[21];
$this->set_degree_details_from_data_array(fp_explode_assoc($temp [21]), "bool_substitution_split");
// No longer used. Using assigned_to_degree_ids instead.
//$this->bool_has_been_assigned = (bool) $temp[22];
$throw_away = $temp [22]; // throw-away value. Can probably just remove entirely.
$this->display_status = $temp [23];
$this->bool_ghost_hour = (bool) $temp [24];
$this->assigned_to_degree_ids_array = fp_explode_assoc($temp [25]);
$this->req_by_degree_id = intval($temp [26]);
$this->disp_for_group_id = trim($temp [27]);
}