diff --git a/class.schedule.php b/class.schedule.php --- a/class.schedule.php +++ b/class.schedule.php @@ -15,624 +15,623 @@ include_once 'inc/class.page.php'; class Schedule { - private $classStorage; // Classes array of classes - private $nclasses; // Integer number of classes - private $nPermutations = 0; // Integer number of real permutations - private $possiblePermutations; // Integer number of possible permutations - private $scheduleName; // String name of schedule - private $storage; // Integer array of valid schedules - private $title; - /** - * The input format of the sections. Only used for the UI. Valid - * values are 'numerous' for custom, 'numbered' for numeric, and 'lettered' for - * alphabetical. - */ - public $section_format; + private $classStorage; // Classes array of classes + private $nclasses; // Integer number of classes + private $nPermutations = 0; // Integer number of real permutations + private $possiblePermutations; // Integer number of possible permutations + private $scheduleName; // String name of schedule + private $storage; // Integer array of valid schedules + private $title; + /** + * The input format of the sections. Only used for the UI. Valid + * values are 'numerous' for custom, 'numbered' for numeric, and 'lettered' for + * alphabetical. + */ + public $section_format; - /** - * \brief - * Create a schedule with the given name. - */ - function __construct($name) - { - $this->classStorage = array(); - $this->nclasses = 0; - $this->scheduleName = $name; - $this->storage = array(); - $this->title = "SlatePermutate - Scheduler"; - $this->section_format = 'numerous'; - } + /** + * \brief + * Create a schedule with the given name. + */ + function __construct($name) + { + $this->classStorage = array(); + $this->nclasses = 0; + $this->scheduleName = $name; + $this->storage = array(); + $this->title = "SlatePermutate - Scheduler"; + $this->section_format = 'numerous'; + } - //-------------------------------------------------- - // Mutators and Accessors - //-------------------------------------------------- - public function getName() - { - return $this->scheduleName; - } + //-------------------------------------------------- + // Mutators and Accessors + //-------------------------------------------------- + public function getName() + { + return $this->scheduleName; + } - //-------------------------------------------------- - // Adds a new class to the schedule. - //-------------------------------------------------- - function addClass($n) - { - $this->classStorage[$this->nclasses] = new Classes($n); - $this->nclasses++; - } + //-------------------------------------------------- + // Adds a new class to the schedule. + //-------------------------------------------------- + function addClass($n) + { + $this->classStorage[$this->nclasses] = new Classes($n); + $this->nclasses++; + } - //-------------------------------------------------- - // Adds a section to the desired class. - //-------------------------------------------------- - function addSection($n, $l, $s, $e, $d) - { - $found = false; - $counter = 0; + //-------------------------------------------------- + // Adds a section to the desired class. + //-------------------------------------------------- + function addSection($n, $l, $s, $e, $d) + { + $found = false; + $counter = 0; - while(!$found && ($counter < $this->nclasses)) - { - $temp = $this->classStorage[$counter]->getName(); + while(!$found && ($counter < $this->nclasses)) + { + $temp = $this->classStorage[$counter]->getName(); - if((strcmp($temp,$n)) == 0) - { - $found = true; - } else { - $counter++; - } - } + if((strcmp($temp,$n)) == 0) + { + $found = true; + } else { + $counter++; + } + } - if($counter == $this->nclasses) - { - echo "Could not find class: " . $n . "
"; - } else { - $p = "unknown prof"; - $this->classStorage[$counter]->addSection($l, $p, $s, $e, $d); - } + if($counter == $this->nclasses) + { + echo "Could not find class: " . $n . "
"; + } else { + $p = "unknown prof"; + $this->classStorage[$counter]->addSection($l, $p, $s, $e, $d); } + } - //-------------------------------------------------- - // Finds all of the possible permutations and stores - // the results in the storage array. - //-------------------------------------------------- - function findPossibilities() - { - $this->possiblePermutations = 1; - /* special case: there is nothing entered into the schedule and thus there is one, NULL permutation */ - if (!$this->nclasses) - { - /* have an empty schedule */ - $this->classStorage[0] = array(); - $this->nPermutations = 1; - return; - } + //-------------------------------------------------- + // Finds all of the possible permutations and stores + // the results in the storage array. + //-------------------------------------------------- + function findPossibilities() + { + $this->possiblePermutations = 1; + /* special case: there is nothing entered into the schedule and thus there is one, NULL permutation */ + if (!$this->nclasses) + { + /* have an empty schedule */ + $this->classStorage[0] = array(); + $this->nPermutations = 1; + return; + } - $position = 0; - $counter = 0; + $position = 0; + $counter = 0; - for($i = 0; $i < $this->nclasses; $i++) - { - $this->possiblePermutations = $this->possiblePermutations * $this->classStorage[$i]->getnsections(); - $cs[$i] = 0; // Sets the counter array to all zeroes. - } + for($i = 0; $i < $this->nclasses; $i++) + { + $this->possiblePermutations = $this->possiblePermutations * $this->classStorage[$i]->getnsections(); + $cs[$i] = 0; // Sets the counter array to all zeroes. + } - // Checks for conflicts in given classes, stores if none found - do - { - $conflict = false; - $upCounter = 0; + // Checks for conflicts in given classes, stores if none found + do + { + $conflict = false; + $upCounter = 0; - // Get first class to compare - while($upCounter < $this->nclasses) - { - $downCounter = $this->nclasses-1; - while($downCounter > $upCounter) - { - $start1 = $this->classStorage[$upCounter]->getSection($cs[$upCounter])->getStartTime(); - $end1 = $this->classStorage[$upCounter]->getSection($cs[$upCounter])->getEndTime(); - $start2 = $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getStartTime(); - $end2 = $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getEndTime(); + // Get first class to compare + while($upCounter < $this->nclasses) + { + $downCounter = $this->nclasses-1; + while($downCounter > $upCounter) + { + $start1 = $this->classStorage[$upCounter]->getSection($cs[$upCounter])->getStartTime(); + $end1 = $this->classStorage[$upCounter]->getSection($cs[$upCounter])->getEndTime(); + $start2 = $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getStartTime(); + $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)))) - { - // Monday - if(!$conflict && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getM() == $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getM())) - { - $conflict = true; - } + // If the two times overlap, then check if days overlap. + if(!$conflict && ((($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())) + { + $conflict = true; + } - // Tuesday - if(!$conflict && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getTu() == $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getTu())) - { - $conflict = true; - } + // Tuesday + if(!$conflict && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getTu() == $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getTu())) + { + $conflict = true; + } - // Wednesday - if(!$conflict && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getW() == $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getW())) - { - $conflict = true; - } + // Wednesday + if(!$conflict && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getW() == $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getW())) + { + $conflict = true; + } - // Thursday - if(!$conflict && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getTh() == $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getTh())) - { - $conflict = true; - } + // Thursday + if(!$conflict && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getTh() == $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getTh())) + { + $conflict = true; + } - // Friday - if(!$conflict && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getF() == $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getF())) - { - $conflict = true; - } - } + // Friday + if(!$conflict && ($this->classStorage[$upCounter]->getSection($cs[$upCounter])->getF() == $this->classStorage[$downCounter]->getSection($cs[$downCounter])->getF())) + { + $conflict = true; + } + } - $downCounter--; - } + $downCounter--; + } - $upCounter++; - } + $upCounter++; + } - // Store to storage if no conflict is found. - if(!$conflict) - { - for($i = 0; $i < $this->nclasses; $i++) - { - $this->storage[$this->nPermutations][$i] = $cs[$i]; - } - $this->nPermutations++; - } + // Store to storage if no conflict is found. + if(!$conflict) + { + for($i = 0; $i < $this->nclasses; $i++) + { + $this->storage[$this->nPermutations][$i] = $cs[$i]; + } + $this->nPermutations++; + } - // Increase the counter by one to get the next combination of class sections. - $cs[$position] = $cs[$position] + 1; + // Increase the counter by one to get the next combination of class sections. + $cs[$position] = $cs[$position] + 1; - // Check to make sure the counter is still valid. - $valid = false; - while(!$valid) - { - if($cs[$position] == $this->classStorage[$position]->getnsections()) - { - $cs[$position] = 0; + // Check to make sure the counter is still valid. + $valid = false; + while(!$valid) + { + if($cs[$position] == $this->classStorage[$position]->getnsections()) + { + $cs[$position] = 0; - $position++; + $position++; - // This is for the very last permutation. Even - // though the combination is not actually true - // the larger while loop will end before any - // new combinations are performed. - if($position == $this->nclasses) - { - $valid = true; - } else { - $cs[$position]++; - } - } else { - $valid = true; - $position = 0; - } - } + // This is for the very last permutation. Even + // though the combination is not actually true + // the larger while loop will end before any + // new combinations are performed. + if($position == $this->nclasses) + { + $valid = true; + } else { + $cs[$position]++; + } + } else { + $valid = true; + $position = 0; + } + } - $counter++; - } while($counter < $this->possiblePermutations); - } + $counter++; + } while($counter < $this->possiblePermutations); + } - //-------------------------------------------------- - // Prints out the possible permutations in tables. - //-------------------------------------------------- - function writeoutTables() - { - $table = ""; - $header = ""; - $footer = ""; - $M = -1; - $Tu = -1; - $W = -1; - $Th = -1; - $F = -1; - $filled = false; - $time = array(700,730,800,830,900,930,1000,1030,1100,1130,1200,1230,1300,1330,1400,1430,1500,1530,1600,1630,1700,1730,1800,1830,1900,1930,2000,2030,2100,2130, 2200); + //-------------------------------------------------- + // Prints out the possible permutations in tables. + //-------------------------------------------------- + function writeoutTables() + { + $table = ""; + $header = ""; + $footer = ""; + $M = -1; + $Tu = -1; + $W = -1; + $Th = -1; + $F = -1; + $filled = false; + $time = array(700,730,800,830,900,930,1000,1030,1100,1130,1200,1230,1300,1330,1400,1430,1500,1530,1600,1630,1700,1730,1800,1830,1900,1930,2000,2030,2100,2130, 2200); - // Reminder: - // border-style:top right bottom left - /* $header .= "" . $this->getName() . " :: " . $this->title . "\n\n". + "\n". - "\n". - "\n". + "\n". + "\n". - "\n". + "\n". - "\n". - "\n". - "\n". - "\n". + "\n". + "\n". + "\n". + "\n". - "\n". + "\n". - "\n\n
\n

SlatePermutate - Scheduler

Schedule name: " . $this->getName() . "

\n
". + "\n\n
\n

SlatePermutate - Scheduler

Schedule name: " . $this->getName() . "

\n
". - */ - $footcloser = ''; + */ + $footcloser = ''; - if(isset($_REQUEST['print']) && $_REQUEST['print'] != ''){ - $headcode = array('jQuery', 'outputStyle', 'outputPrintStyle'); - } - else { - $footcloser .=""; - $headcode = array('outputStyle', 'gliderHeadcode'); - } - $outputPage = new page($this->getName(), $headcode); + if(isset($_REQUEST['print']) && $_REQUEST['print'] != ''){ + $headcode = array('jQuery', 'outputStyle', 'outputPrintStyle'); + } + else { + $footcloser .=""; + $headcode = array('outputStyle', 'gliderHeadcode'); + } + $outputPage = new page($this->getName(), $headcode); - if(isset($_REQUEST['print'])){ - echo ''; - echo '

Select Schedules to Print :: Return to normal view :: Home

'; - echo '


'; - } - else { - echo '

Print :: Home

'; - } + echo '

Select Schedules to Print :: Return to normal view :: Home

'; + echo '


'; + } + else { + echo '

Print :: Home

'; + } - echo "

There were a total of " . $this->possiblePermutations . " possible permutations. Only " . $this->nPermutations . " permutations had no class conflicts.

"; - - - if($this->nPermutations > 0) - { - $table .= "
\n" - . "
\n"; + if($this->nPermutations > 0) + { + $table .= "
\n" + . "
\n"; - for($nn = 1; $nn <= $this->nPermutations; $nn++) - { - $table .= " " . $nn . " "; - } + for($nn = 1; $nn <= $this->nPermutations; $nn++) + { + $table .= " " . $nn . " "; + } - $table .= "
\n" - . "
" - . "
"; + $table .= "
\n" + . "
" + . "
"; - for($i = 0; $i < $this->nPermutations; $i++) - { - $table .= "
"; + for($i = 0; $i < $this->nPermutations; $i++) + { + $table .= "
"; - // Beginning of table - $table .= ""; + // Beginning of table + $table .= "
"; - // Header row - $table .= "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t"; + // Header row + $table .= "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t"; - for($r = 0; $r < (count($time)-1); $r++) - { - // Beginning of new row - $temp = $time[$r]; - if($temp > 1259) - { - $temp = $temp-1200; - } + for($r = 0; $r < (count($time)-1); $r++) + { + // Beginning of new row + $temp = $time[$r]; + if($temp > 1259) + { + $temp = $temp-1200; + } - $table .= "\n\t\n\t\t"; + $table .= "\n\t\n\t\t"; - //---------------MONDAY--------------- - for($j = 0; $j < $this->nclasses; $j++) - { - if($M == -1) - { - if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getM()) - { - if(($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() >= $time[$r]) && ($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() < $time[$r+1])) - { - if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1]) - { - $table .= "\n\t\t"; - $M = $j; - $filled = true; - } else { - $table .= "\n\t\t"; - $filled = true; - } - } - } - } else { - if($j == $M) - { - if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1]) - { - $table .= "\n\t\t"; - $filled = true; - } else { - $table .= "\n\t\t"; - $M = -1; - $filled = true; - } - } - } - } + //---------------MONDAY--------------- + for($j = 0; $j < $this->nclasses; $j++) + { + if($M == -1) + { + if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getM()) + { + if(($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() >= $time[$r]) && ($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() < $time[$r+1])) + { + if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1]) + { + $table .= "\n\t\t"; + $M = $j; + $filled = true; + } else { + $table .= "\n\t\t"; + $filled = true; + } + } + } + } else { + if($j == $M) + { + if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1]) + { + $table .= "\n\t\t"; + $filled = true; + } else { + $table .= "\n\t\t"; + $M = -1; + $filled = true; + } + } + } + } - // If the cell was not filled, fill it with an empty cell. - if(!$filled) - { - $table .= "\n\t\t"; - } - $filled = false; + // If the cell was not filled, fill it with an empty cell. + if(!$filled) + { + $table .= "\n\t\t"; + } + $filled = false; - //---------------TUESDAY--------------- - for($j = 0; $j < $this->nclasses; $j++) - { - if($Tu == -1) - { - if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getTu()) - { - if(($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() >= $time[$r]) && ($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() < $time[$r+1])) - { - if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1]) - { - $table .= "\n\t\t"; - $Tu = $j; - $filled = true; - } else { - $table .= "\n\t\t"; - $filled = true; - } - } - } - } else { - if($j == $Tu) - { - if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1]) - { - $table .= "\n\t\t"; - $filled = true; - } else { - $table .= "\n\t\t"; - $Tu = -1; - $filled = true; - } - } - } - } + //---------------TUESDAY--------------- + for($j = 0; $j < $this->nclasses; $j++) + { + if($Tu == -1) + { + if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getTu()) + { + if(($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() >= $time[$r]) && ($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() < $time[$r+1])) + { + if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1]) + { + $table .= "\n\t\t"; + $Tu = $j; + $filled = true; + } else { + $table .= "\n\t\t"; + $filled = true; + } + } + } + } else { + if($j == $Tu) + { + if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1]) + { + $table .= "\n\t\t"; + $filled = true; + } else { + $table .= "\n\t\t"; + $Tu = -1; + $filled = true; + } + } + } + } - // If the cell was not filled, fill it with an empty cell. - if(!$filled) - { - $table .= "\n\t\t"; - } - $filled = false; + // If the cell was not filled, fill it with an empty cell. + if(!$filled) + { + $table .= "\n\t\t"; + } + $filled = false; - //---------------WEDNESDAY--------------- - for($j = 0; $j < $this->nclasses; $j++) - { - if($W == -1) - { - if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getW()) - { - if(($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() >= $time[$r]) && ($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() < $time[$r+1])) - { - if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1]) - { - $table .= "\n\t\t"; - $W = $j; - $filled = true; - } else { - $table .= "\n\t\t"; - $filled = true; - } - } - } - } else { - if($j == $W) - { - if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1]) - { - $table .= "\n\t\t"; - $filled = true; - } else { - $table .= "\n\t\t"; - $W = -1; - $filled = true; - } - } - } - } + //---------------WEDNESDAY--------------- + for($j = 0; $j < $this->nclasses; $j++) + { + if($W == -1) + { + if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getW()) + { + if(($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() >= $time[$r]) && ($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() < $time[$r+1])) + { + if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1]) + { + $table .= "\n\t\t"; + $W = $j; + $filled = true; + } else { + $table .= "\n\t\t"; + $filled = true; + } + } + } + } else { + if($j == $W) + { + if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1]) + { + $table .= "\n\t\t"; + $filled = true; + } else { + $table .= "\n\t\t"; + $W = -1; + $filled = true; + } + } + } + } - // If the cell was not filled, fill it with an empty cell. - if(!$filled) - { - $table .= "\n\t\t"; - } - $filled = false; + // If the cell was not filled, fill it with an empty cell. + if(!$filled) + { + $table .= "\n\t\t"; + } + $filled = false; - //---------------THURSDAY--------------- - for($j = 0; $j < $this->nclasses; $j++) - { - if($Th == -1) - { - if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getTh()) - { - if(($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() >= $time[$r]) && ($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() < $time[$r+1])) - { - if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1]) - { - $table .= "\n\t\t"; - $Th = $j; - $filled = true; - } else { - $table .= "\n\t\t"; - $filled = true; - } - } - } - } else { - if($j == $Th) - { - if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1]) - { - $table .= "\n\t\t"; - $filled = true; - } else { - $table .= "\n\t\t"; - $Th = -1; - $filled = true; - } - } - } - } + //---------------THURSDAY--------------- + for($j = 0; $j < $this->nclasses; $j++) + { + if($Th == -1) + { + if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getTh()) + { + if(($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() >= $time[$r]) && ($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() < $time[$r+1])) + { + if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1]) + { + $table .= "\n\t\t"; + $Th = $j; + $filled = true; + } else { + $table .= "\n\t\t"; + $filled = true; + } + } + } + } else { + if($j == $Th) + { + if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1]) + { + $table .= "\n\t\t"; + $filled = true; + } else { + $table .= "\n\t\t"; + $Th = -1; + $filled = true; + } + } + } + } - // If the cell was not filled, fill it with an empty cell. - if(!$filled) - { - $table .= "\n\t\t"; - } - $filled = false; + // If the cell was not filled, fill it with an empty cell. + if(!$filled) + { + $table .= "\n\t\t"; + } + $filled = false; - //---------------FRIDAY--------------- - for($j = 0; $j < $this->nclasses; $j++) - { - if($F == -1) - { - if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getF()) - { - if(($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() >= $time[$r]) && ($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() < $time[$r+1])) - { - if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1]) - { - $table .= "\n\t\t"; - $F = $j; - $filled = true; - } else { - $table .= "\n\t\t"; - $filled = true; - } - } - } - } else { - if($j == $F) - { - if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1]) - { - $table .= "\n\t\t"; - $filled = true; - } else { - $table .= "\n\t\t"; - $F = -1; - $filled = true; - } - } - } - } + //---------------FRIDAY--------------- + for($j = 0; $j < $this->nclasses; $j++) + { + if($F == -1) + { + if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getF()) + { + if(($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() >= $time[$r]) && ($this->classStorage[$j]->getSection($this->storage[$i][$j])->getStartTime() < $time[$r+1])) + { + if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1]) + { + $table .= "\n\t\t"; + $F = $j; + $filled = true; + } else { + $table .= "\n\t\t"; + $filled = true; + } + } + } + } else { + if($j == $F) + { + if($this->classStorage[$j]->getSection($this->storage[$i][$j])->getEndTime() > $time[$r+1]) + { + $table .= "\n\t\t"; + $filled = true; + } else { + $table .= "\n\t\t"; + $F = -1; + $filled = true; + } + } + } + } - // If the cell was not filled, fill it with an empty cell. - if(!$filled) - { - $table .= "\n\t\t"; - } - $filled = false; + // If the cell was not filled, fill it with an empty cell. + if(!$filled) + { + $table .= "\n\t\t"; + } + $filled = false; - // End of row - $table .= "\n\t"; - } + // End of row + $table .= "\n\t"; + } - // End of table - $table .= '
" . ($i+1) . "MondayTuesdayWednesdayThursdayFriday
" . ($i+1) . "MondayTuesdayWednesdayThursdayFriday
" . $this->prettyTime($time[$r]) . "
" . $this->prettyTime($time[$r]) . "" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "  " . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "    " . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "  " . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "    " . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "  " . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "    " . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "  " . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "    " . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "  " . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "" . $this->classStorage[$j]->getName() . " " . $this->classStorage[$j]->getSection($this->storage[$i][$j])->getLetter() . "    
\n"; - } + // End of table + $table .= '
\n"; + } - echo $table - . "
\n" - . "
\n" - . "
\n" - . $footcloser; // Closes off the content div - } else { - echo '

There are no possible schedules. Please try again.

'; - } + echo $table + . "
\n" + . "
\n" + . "
\n" + . $footcloser; // Closes off the content div + } else { + echo '

There are no possible schedules. Please try again.

'; + } - /* edit button */ - if (!isset($savedkey)) - { - if (isset($_REQUEST['savedkey'])) - $savedkey = (int)$_REQUEST['savedkey']; - else - /* - * if this is a new saved schedule, it'll be the - * next item added to $_SESSION['saved'] - */ - $savedkey = max(array_keys($_SESSION['saved'])) + 1; - } - echo '

'; + /* edit button */ + if (!isset($savedkey)) + { + if (isset($_REQUEST['savedkey'])) + $savedkey = (int)$_REQUEST['savedkey']; + else + /* + * if this is a new saved schedule, it'll be the + * next item added to $_SESSION['saved'] + */ + $savedkey = max(array_keys($_SESSION['saved'])) + 1; + } + echo '

'; - $outputPage->foot(); - } + echo "

There were a total of " . $this->possiblePermutations . " possible permutations. Only " . $this->nPermutations . " permutations had no class conflicts.

"; + + $outputPage->foot(); + } - /** - * \brief - * Render the input table form for editing a saved schedule in input.php. - * - * This function's output must be synchronized with the - * associated javascript in scripts/scheduleInput.js. - */ - function input_form_render() - { - $out = ''; - static $n = "\n"; + /** + * \brief + * Render the input table form for editing a saved schedule in input.php. + * + * This function's output must be synchronized with the + * associated javascript in scripts/scheduleInput.js. + */ + function input_form_render() + { + $out = ''; + static $n = "\n"; - foreach ($this->classStorage as $class_key => $class) - $out .= $class->input_form_render($class_key); + foreach ($this->classStorage as $class_key => $class) + $out .= $class->input_form_render($class_key); - return $out; - } + return $out; + } - //-------------------------------------------------- - // Changes the title of the page. - //-------------------------------------------------- - function changeTitle($t) - { - $this->title = $t; - } + //-------------------------------------------------- + // Changes the title of the page. + //-------------------------------------------------- + function changeTitle($t) + { + $this->title = $t; + } - //-------------------------------------------------- - // Make the time "pretty." - //-------------------------------------------------- - function prettyTime($t){ - if($t > 1259) - { - $t = ($t-1200); - return substr($t, 0, strlen($t)-2) . ":" . substr($t, strlen($t)-2, strlen($t)) . " PM"; - } else { - return substr($t, 0, strlen($t)-2) . ":" . substr($t, strlen($t)-2, strlen($t)) . " AM"; - } - } + //-------------------------------------------------- + // Make the time "pretty." + //-------------------------------------------------- + function prettyTime($t){ + if($t > 1259) + { + $t = ($t-1200); + return substr($t, 0, strlen($t)-2) . ":" . substr($t, strlen($t)-2, strlen($t)) . " PM"; + } else { + return substr($t, 0, strlen($t)-2) . ":" . substr($t, strlen($t)-2, strlen($t)) . " AM"; + } + } /** * \brief