function fetchcourse($code)
 {
     $code = Course::code_normalize($code);
     if (isset($coursecache[$code])) {
         return $coursecache[$code];
     }
     return $coursecache[$code] = Course::fetch($code);
 }
Goal is to find 5 courses that they haven't taken, and for which they have satisfied the prerequisites
Electives count as one course found, these are added to a list of electives but not scheduled
Courses for which the prerequisites are satisfied but are not immediately considered for scheduling are added to a list of alternatives
This algorithm also attempts to schedule concurrent prerequisites together
*/
for ($i = 0; $i < count($pattern); $i++) {
    if ($found == 5) {
        break;
    }
    if ($pattern[$i][1] != '0') {
        array_push($electives, $pattern[$i]);
        $found++;
        continue;
    }
    $course = Course::fetch($pattern[$i][0]);
    if (count($course->unsatisfied_prerequisites($completed_as_courses, $scheduling)) == 0) {
        array_push($scheduling, $course);
        $found++;
    } else {
        array_push($discarded, $course);
        continue;
    }
    //Check and see if we can fit the discarded courses in now
    foreach ($discarded as $key => $tryagain) {
        if (isset($tryagain)) {
            if (count($tryagain->unsatisfied_prerequisites($completed_as_courses, $scheduling)) == 0) {
                array_push($scheduling, $tryagain);
                $found++;
                unset($discarded[$key]);
            }
<?php

session_start();
define("CONST_FILE_PATH", "../includes/constants.php");
include '../classes/WebPage.php';
//Set up page as a web page
$thisPage = new WebPage();
//Create new instance of webPage class
$dbObj = new Database();
//Instantiate database
$courseObj = new Course($dbObj);
// Create an object of Course class
$errorArr = array();
//Array of errors
//fetch all courses
header('Content-type: application/json');
echo $courseObj->fetch();