Changeset - eee24913c197
[Not reviewed]
default
0 2 0
Nathan Brink (binki) - 15 years ago 2010-10-02 22:52:07
ohnobinki@ohnopublishing.net
Fix a false-positive in the conflict tests where two sections are said to conflict if 1. their times overlap and 2. they both share a day where neither class meets.
2 files changed with 29 insertions and 20 deletions:
0 comments (0 inline, 0 general)
class.schedule.php
Show inline comments
 
@@ -123,13 +123,16 @@ class Schedule
 
    do
 
      {
 
	$conflict = false;
 
	$upCounter = 0;
 
         
 
	// Get first class to compare
 
	while($upCounter < $this->nclasses)
 
	for ($upCounter = 0;
 
	     $upCounter < $this->nclasses && !$conflict;
 
	     $upCounter ++)
 
	  {
 
	    $downCounter = $this->nclasses-1;
 
	    while($downCounter > $upCounter)
 
	    
 
	    for ($downCounter = $this->nclasses - 1;
 
		 $downCounter > $upCounter && !$conflict;
 
		 $downCounter --)
 
	      {
 
		$start1 = $this->classStorage[$upCounter]->getSection($cs[$upCounter])->getStartTime();
 
		$end1 = $this->classStorage[$upCounter]->getSection($cs[$upCounter])->getEndTime();
 
@@ -137,43 +140,49 @@ class Schedule
 
		$end2 = $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getEndTime();
 
					
 
		// If the two times overlap, then check if days overlap.
 
		if(!$conflict && ((($start1 >= $start2) && ($start1 <= $end2)) || (($start2 >= $start1) && ($start2 <= $end1))))
 
		if ((($start1 >= $start2) && ($start1 <= $end2)) || (($start2 >= $start1) && ($start2 <= $end1)))
 
		  {
 
		    // Monday
 
		    if(!$conflict && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getM() == $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getM()))
 
		    if(!$conflict
 
		       && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getM()
 
			   && $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getM()))
 
		      {
 
			$conflict = true;
 
			$conflict = TRUE;
 
		      }
 
						
 
		    // Tuesday
 
		    if(!$conflict && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getTu() == $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getTu()))
 
		    if(!$conflict
 
		       && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getTu()
 
			   && $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getTu()))
 
		      {
 
			$conflict = true;
 
			$conflict = TRUE;
 
		      }
 
						
 
		    // Wednesday
 
		    if(!$conflict && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getW() == $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getW()))
 
		    if(!$conflict
 
		       && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getW()
 
			   && $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getW()))
 
		      {
 
			$conflict = true;
 
			$conflict = TRUE;
 
		      }
 
						
 
		    // Thursday
 
		    if(!$conflict && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getTh() == $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getTh()))
 
		    if(!$conflict
 
		       && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getTh()
 
			   && $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getTh()))
 
		      {
 
			$conflict = true;
 
			$conflict = TRUE;
 
		      }
 
						
 
		    // Friday
 
		    if(!$conflict && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getF() == $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getF()))
 
		    if(!$conflict
 
		       && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getF()
 
			   && $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getF()))
 
		      {
 
			$conflict = true;
 
			$conflict = TRUE;
 
		      }
 
		  }
 
               
 
		$downCounter--;
 
	      }
 
				
 
	    $upCounter++;
 
	  }
 
            
 
	// Store to storage if no conflict is found.
class.section.php
Show inline comments
 
@@ -28,7 +28,7 @@ class Section
 

	
 
  function setbdays()
 
  {
 
    $result;
 
    $result = array(FALSE, FALSE, FALSE, FALSE, FALSE);
 

	
 
    if($this->idays == 12345)
 
      {$result[0] = true; $result[1] = true; $result[2] = true; $result[3] = true; $result[4] = true;}
0 comments (0 inline, 0 general)