function _CourseList::exclude_all_subjects_except

4.x _CourseList.php _CourseList::exclude_all_subjects_except($subject, $bool_reassign_valid_name = true)
5.x _CourseList.php _CourseList::exclude_all_subjects_except($subject, $bool_reassign_valid_name = true)

Go through the courseList and take out any course which does not have the $subject as its subject_id.

Parameters

string $subject:

bool $bool_reassign_valid_name:

  • If set to TRUE, we will look at other possible valid names for this course. If we find one, we will reassign the course's subject_id and course_num to the new valid name.

File

classes/_CourseList.php, line 931

Class

_CourseList

Code

function exclude_all_subjects_except($subject, $bool_reassign_valid_name = true) 
 {

  $new_course_list = new CourseList();

  for ($t = 0; $t < $this->count; $t++) 
   {
    $course = $this->array_list [$t];
    if ($course->subject_id == $subject) 
     {
      $new_course_list->add($course);
      continue;
    }

    // Not the right subject-- but perhaps the course has another
    // valid name with this subject?  Ex: CSCI 373 and MATH 373.

    if ($bool_reassign_valid_name == true && count($course->array_valid_names) > 1) 
     {
      for ($x = 0; $x < count($course->array_valid_names); $x++) 
       {
        if (strstr($course->array_valid_names [$x], $subject)) 
         {
          $temp = explode("~", $course->array_valid_names [$x]);
          $course->subject_id = $temp [0];
          $course->course_num = $temp [1];

          $new_course_list->add($course);
          continue;
        }
      }

    }


  }

  // Now, transfer ownership of the arraylist.
  $this->array_list = $new_course_list->array_list;

}