Ejemplo n.º 1
0
 /**
  * static method to enable an AssignmentHistory to be created by means of passing an
  * assignment and reason only
  *
  * @param HMS_Assignment $assignment HMS_Assignment object from which to pull data
  * @param String $reason A defined reason for assignment if not wishing to use one in assignment (see definitions)
  * @return boolean true if success, false if failure
  */
 public static function makeAssignmentHistory(HMS_Assignment $assignment, $reason = null)
 {
     if (is_null($assignment)) {
         throw new InvalidArgumentException('Missing HMS_Assignment object.');
     }
     if (is_null($reason)) {
         $reason = $assignment->reason;
     }
     // check if an open-ended assignment exists for the term sent.  If so, unassign with reason "AUTO"
     if (AssignmentHistory::historyExists($assignment)) {
         AssignmentHistory::makeUnassignmentHistory($assignment, UNASSIGN_REASSIGN);
     }
     $ah = new AssignmentHistory();
     $ah->setBanner($assignment->banner_id);
     $ah->setBedId($assignment->bed_id);
     $ah->setTerm($assignment->term);
     $ah->setAssign($reason);
     // set all the assignment data
     $ah->setApplicationTerm($assignment->application_term);
     $ah->setClass($assignment->class);
     $ah->save();
     return true;
 }