Exemple #1
0
 function getLabs()
 {
     $db = new DataBase("SchedulerDatabase");
     $labs = new SectionList();
     $subID = $this->subjectID;
     $CN = $this->courseNum;
     $term = $this->term;
     $sectionLetter = trim($this->sectionCode);
     $sqlquery = "SELECT * FROM Section\n\t\t\t\t\t\t\tWHERE SubjectID LIKE '%{$subID}%'\n\t\t\t\t\t\t\t\t  AND CourseNumber LIKE '%{$CN}%'\n\t\t\t\t\t\t\t\t  AND Term LIKE '%{$term}%'\n\t\t\t\t\t\t\t\t  AND (SectionCode LIKE '%" . $sectionLetter . "_%' OR SectionCode LIKE '%L_%')\n\t\t\t\t\t\t\t\t  AND (NumberOfStudents < Capacity);";
     $rows = $db->execute($sqlquery);
     while ($row = $rows->fetch_object()) {
         $newItem = new Section($row->SubjectID, $row->CourseNumber, $row->Year, $row->Term, $row->Title, $row->Credits, $row->ScheduleCode, $row->SectionCode, $row->Time, $row->Days, $row->Capacity, $row->NumberOfStudents);
         $labs->addItem($newItem);
     }
     return $labs;
 }
Exemple #2
0
            $result = $sec->Capacity <= $sec->NumberOfStudents;
            //ensure its not full
        } else {
            $result = false;
            //if it doesn't it can be updated
        }
        if ($result == false) {
            //if the section can be updated, update it
            //Query to increment given course
            $incrementSection = "UPDATE Section \n\t\t\t\t\t\t\t\t\t SET NumberOfStudents = NumberOfStudents + 1 \n\t\t\t\t\t\t\t\t\t WHERE SubjectID LIKE '%{$subID}%' AND \n\t\t\t\t\t\t\t\t\t CourseNumber LIKE '%{$CN}%' AND \n\t\t\t\t\t\t\t\t\t SectionCode = '{$SC}' AND\n\t\t\t\t\t\t\t\t\t Year = {$year} AND\n\t\t\t\t\t\t\t\t\t Term LIKE '%{$term}%';";
            $incrementresult = $db->execute($incrementSection);
            if ($incrementresult != 1) {
                //if increment failed
                $revert = true;
            } else {
                $SectionsUpdated->addItem($Sections->itemAt($i));
                //else add to list of updated sections
            }
        } else {
            $revert = true;
        }
    }
}
if ($revert) {
    //if revert is true, run through list of courses already updated and undo update
    for ($i = 0; $i < count($SectionsUpdated->SectionItems); $i = $i + 1) {
        $subID = $Sections->itemAt($i)->subjectID;
        $CN = $Sections->itemAt($i)->courseNum;
        $SC = $Sections->itemAt($i)->sectionCode;
        $year = $Sections->itemAt($i)->year;
        $term = $Sections->itemAt($i)->term;
 function calculateConflictFreeSchedules()
 {
     //break apart courses into lists per course
     $classlist1 = null;
     if (count($this->courses->SectionItems) > 0) {
         $classlist1 = new SectionList();
         $classlist1->addItem($this->courses->itemAt(0));
         //Add first course to list (this will be what will be matched in loop)
         $this->courses->removeItem(0);
         //Delete that item from original list
         for ($i = 0; $i < count($this->courses->SectionItems); $i = $i + 1) {
             //go through rest of list
             //If course is of same type as on in classlist then add it
             if ($this->courses->itemAt($i)->subjectID == $classlist1->itemAt(0)->subjectID && $this->courses->itemAt($i)->courseNum == $classlist1->itemAt(0)->courseNum) {
                 $classlist1->addItem($this->courses->itemAt($i));
                 //add to class list
                 $this->courses->removeItem($i);
                 //remove from original list
                 $i = $i - 1;
                 //set i back 1 to accomidate deleted item
             }
         }
     }
     $classlist2 = null;
     if (count($this->courses->SectionItems) > 0) {
         $classlist2 = new SectionList();
         $classlist2->addItem($this->courses->itemAt(0));
         $this->courses->removeItem(0);
         for ($i = 0; $i < count($this->courses->SectionItems); $i = $i + 1) {
             if ($this->courses->itemAt($i)->subjectID == $classlist2->itemAt(0)->subjectID && $this->courses->itemAt($i)->courseNum == $classlist2->itemAt(0)->courseNum) {
                 $classlist2->addItem($this->courses->itemAt($i));
                 $this->courses->removeItem($i);
                 $i = $i - 1;
             }
         }
     }
     $classlist3 = null;
     if (count($this->courses->SectionItems) > 0) {
         $classlist3 = new SectionList();
         $classlist3->addItem($this->courses->itemAt(0));
         $this->courses->removeItem(0);
         for ($i = 0; $i < count($this->courses->SectionItems); $i = $i + 1) {
             if ($this->courses->itemAt($i)->subjectID == $classlist3->itemAt(0)->subjectID && $this->courses->itemAt($i)->courseNum == $classlist3->itemAt(0)->courseNum) {
                 $classlist3->addItem($this->courses->itemAt($i));
                 $this->courses->removeItem($i);
                 $i = $i - 1;
             }
         }
     }
     $classlist4 = null;
     if (count($this->courses->SectionItems) > 0) {
         $classlist4 = new SectionList();
         $classlist4->addItem($this->courses->itemAt(0));
         $this->courses->removeItem(0);
         for ($i = 0; $i < count($this->courses->SectionItems); $i = $i + 1) {
             if ($this->courses->itemAt($i)->subjectID == $classlist4->itemAt(0)->subjectID && $this->courses->itemAt($i)->courseNum == $classlist4->itemAt(0)->courseNum) {
                 $classlist4->addItem($this->courses->itemAt($i));
                 $this->courses->removeItem($i);
                 $i = $i - 1;
             }
         }
     }
     $classlist5 = null;
     if (count($this->courses->SectionItems) > 0) {
         $classlist5 = new SectionList();
         $classlist5->addItem($this->courses->itemAt(0));
         $this->courses->removeItem(0);
         for ($i = 0; $i < count($this->courses->SectionItems); $i = $i + 1) {
             if ($this->courses->itemAt($i)->subjectID == $classlist5->itemAt(0)->subjectID && $this->courses->itemAt($i)->courseNum == $classlist5->itemAt(0)->courseNum) {
                 $classlist5->addItem($this->courses->itemAt($i));
                 $this->courses->removeItem($i);
                 $i = $i - 1;
             }
         }
     }
     $classlist6 = null;
     if (count($this->courses->SectionItems) > 0) {
         $classlist6 = new SectionList();
         $classlist6->addItem($this->courses->itemAt(0));
         $this->courses->removeItem(0);
         for ($i = 0; $i < count($this->courses); $i = $i + 1) {
             if ($this->courses->itemAt($i)->subjectID == $classlist6->itemAt(0)->subjectID && $this->courses->itemAt($i)->courseNum == $classlist6->itemAt(0)->courseNum) {
                 $classlist6->addItem($this->courses->itemAt($i));
                 $this->courses->removeItem($i);
                 $i = $i - 1;
             }
         }
     }
     //Create arrays to keep track of what times are booked
     $this->monday = array("8:00-8:30" => 0, "8:30-9:00" => 0, "9:00-9:30" => 0, "9:30-10:00" => 0, "10:00-10:30" => 0, "10:30-11:00" => 0, "11:00-11:30" => 0, "11:30-12:00" => 0, "12:00-12:30" => 0, "12:30-13:00" => 0, "13:00-13:30" => 0, "13:30-14:00" => 0, "14:00-14:30" => 0, "14:30-15:00" => 0, "15:00-15:30" => 0, "15:30-16:00" => 0, "16:00-16:30" => 0, "16:30-17:00" => 0, "17:00-17:30" => 0, "17:30-18:00" => 0, "18:00-18:30" => 0, "18:30-19:00" => 0, "19:00-19:30" => 0, "19:30-20:00" => 0, "20:00-20:30" => 0, "20:30-21:00" => 0, "21:00-21:30" => 0, "21:30-22:00" => 0, "22:00-22:30" => 0, "22:30-23:00" => 0, "23:00-23:30" => 0, "23:30-24:00" => 0);
     $this->tuesday = array("8:00-8:30" => 0, "8:30-9:00" => 0, "9:00-9:30" => 0, "9:30-10:00" => 0, "10:00-10:30" => 0, "10:30-11:00" => 0, "11:00-11:30" => 0, "11:30-12:00" => 0, "12:00-12:30" => 0, "12:30-13:00" => 0, "13:00-13:30" => 0, "13:30-14:00" => 0, "14:00-14:30" => 0, "14:30-15:00" => 0, "15:00-15:30" => 0, "15:30-16:00" => 0, "16:00-16:30" => 0, "16:30-17:00" => 0, "17:00-17:30" => 0, "17:30-18:00" => 0, "18:00-18:30" => 0, "18:30-19:00" => 0, "19:00-19:30" => 0, "19:30-20:00" => 0, "20:00-20:30" => 0, "20:30-21:00" => 0, "21:00-21:30" => 0, "21:30-22:00" => 0, "22:00-22:30" => 0, "22:30-23:00" => 0, "23:00-23:30" => 0, "23:30-24:00" => 0);
     $this->wednesday = array("8:00-8:30" => 0, "8:30-9:00" => 0, "9:00-9:30" => 0, "9:30-10:00" => 0, "10:00-10:30" => 0, "10:30-11:00" => 0, "11:00-11:30" => 0, "11:30-12:00" => 0, "12:00-12:30" => 0, "12:30-13:00" => 0, "13:00-13:30" => 0, "13:30-14:00" => 0, "14:00-14:30" => 0, "14:30-15:00" => 0, "15:00-15:30" => 0, "15:30-16:00" => 0, "16:00-16:30" => 0, "16:30-17:00" => 0, "17:00-17:30" => 0, "17:30-18:00" => 0, "18:00-18:30" => 0, "18:30-19:00" => 0, "19:00-19:30" => 0, "19:30-20:00" => 0, "20:00-20:30" => 0, "20:30-21:00" => 0, "21:00-21:30" => 0, "21:30-22:00" => 0, "22:00-22:30" => 0, "22:30-23:00" => 0, "23:00-23:30" => 0, "23:30-24:00" => 0);
     $this->thursday = array("8:00-8:30" => 0, "8:30-9:00" => 0, "9:00-9:30" => 0, "9:30-10:00" => 0, "10:00-10:30" => 0, "10:30-11:00" => 0, "11:00-11:30" => 0, "11:30-12:00" => 0, "12:00-12:30" => 0, "12:30-13:00" => 0, "13:00-13:30" => 0, "13:30-14:00" => 0, "14:00-14:30" => 0, "14:30-15:00" => 0, "15:00-15:30" => 0, "15:30-16:00" => 0, "16:00-16:30" => 0, "16:30-17:00" => 0, "17:00-17:30" => 0, "17:30-18:00" => 0, "18:00-18:30" => 0, "18:30-19:00" => 0, "19:00-19:30" => 0, "19:30-20:00" => 0, "20:00-20:30" => 0, "20:30-21:00" => 0, "21:00-21:30" => 0, "21:30-22:00" => 0, "22:00-22:30" => 0, "22:30-23:00" => 0, "23:00-23:30" => 0, "23:30-24:00" => 0);
     $this->friday = array("8:00-8:30" => 0, "8:30-9:00" => 0, "9:00-9:30" => 0, "9:30-10:00" => 0, "10:00-10:30" => 0, "10:30-11:00" => 0, "11:00-11:30" => 0, "11:30-12:00" => 0, "12:00-12:30" => 0, "12:30-13:00" => 0, "13:00-13:30" => 0, "13:30-14:00" => 0, "14:00-14:30" => 0, "14:30-15:00" => 0, "15:00-15:30" => 0, "15:30-16:00" => 0, "16:00-16:30" => 0, "16:30-17:00" => 0, "17:00-17:30" => 0, "17:30-18:00" => 0, "18:00-18:30" => 0, "18:30-19:00" => 0, "19:00-19:30" => 0, "19:30-20:00" => 0, "20:00-20:30" => 0, "20:30-21:00" => 0, "21:00-21:30" => 0, "21:30-22:00" => 0, "22:00-22:30" => 0, "22:30-23:00" => 0, "23:00-23:30" => 0, "23:30-24:00" => 0);
     //Now create possible schedules
     if (!is_null($classlist1)) {
         $nextclassesarray = array();
         if (!is_null($classlist2)) {
             array_push($nextclassesarray, $classlist2);
         }
         if (!is_null($classlist3)) {
             array_push($nextclassesarray, $classlist3);
         }
         if (!is_null($classlist4)) {
             array_push($nextclassesarray, $classlist4);
         }
         if (!is_null($classlist5)) {
             array_push($nextclassesarray, $classlist5);
         }
         if (!is_null($classlist6)) {
             array_push($nextclassesarray, $classlist6);
         }
         $this->generateSchedules($classlist1, new SectionList(), $nextclassesarray);
     }
     //Now have a list of all possible schedules for given courses
 }