예제 #1
0
 function checkPref($con1, $con2, $time, $days)
 {
     foreach ($con1 as $a) {
         if (convertToMin($a->time_start) < $time * 60) {
             return 0;
         }
         //checks required days with days in classes
         foreach (str_split($a->days) as $day) {
             foreach (str_split($days) as $day2) {
                 if ($day == $day2) {
                     return 0;
                 }
             }
         }
     }
     foreach ($con2 as $b) {
         if (convertToMin($b->time_start) < $time * 60) {
             return 0;
         }
         //checks required days with days in classes
         foreach (str_split($b->days) as $day) {
             foreach (str_split($days) as $day2) {
                 if ($day == $day2) {
                     return 0;
                 }
             }
         }
     }
     return 1;
 }
예제 #2
0
function checkConflict($t1_start, $t1_end, $t2_start, $t2_end)
{
    if (convertToMin($t1_start) < convertToMin($t2_start)) {
        if (convertToMin($t1_end) > convertToMin($t2_start)) {
            return true;
        } else {
            return false;
        }
    } else {
        checkConflict($t2_start, $t2_end, $t1_start, $t1_end);
    }
}
예제 #3
0
include 'func/db.php';
include 'func/generator.php';
include 'coursematch.php';
$courselist = array("BUAD-306", "BUAD-302", "PHYS-151Lg", "BISC-220Lg");
$coursematch = coursematch($courselist, $conn);
$colorarr = array("EF5350", "AB47BC", "5C6BC0", "039BE5", "009688", "689F38", "EF6C00", "795548", "EC407A");
$golden = $coursematch[5][0];
//print_r($golden);
$queue = array("U" => array(), "M" => array(), "T" => array(), "W" => array(), "H" => array(), "F" => array(), "S" => array(), "A" => array());
$listq = array();
foreach ($golden as $key) {
    foreach (str_split($key->days) as $jack) {
        if ($jack == "" || $key->time_start == "") {
            $jack = "A";
        }
        $top = $key->time_start == "" ? 0 : (convertToMin($key->time_start) / 60 - 6) * 50;
        $size = (strtotime($key->time_end) - strtotime($key->time_start)) / 60 / 60 * 50;
        $html = "<li class=\"event\" data-class=\"" . $key->class_id . "\" style=\"top:" . $top . "px;background-color:#" . $colorarr[array_search($key->class_id, $courselist)] . ";min-height:" . $size . "px\"><span><i>" . $key->type . "</i><br><b>" . $key->class_id . "</b></span><p>" . ($key->instructor != "" ? $key->instructor . "<br>" : "") . ($key->room != "" ? $key->room . "<br>" : "") . $key->section . ($key->time_start != "" ? "<br>" . $key->time_start . "-" . $key->time_end : "") . "</p></li>";
        $queue[$jack][] = $html;
    }
    $listq[$key->class_id][] = "<tr><td>" . $key->section . "</td><td>" . $key->type . "</td><td>" . $key->units . "</td><td>" . $key->time_start . "-" . $key->time_end . "</td><td>" . $key->days . "</td><td>" . $key->instructor . "</td><td>" . $key->room . "</td></tr>";
}
?>

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<link rel="stylesheet" type="text/css" href="wwe.css">
	<meta name="viewport" content="width=device-width, initial-scale=1">
예제 #4
0
include 'func/db.php';
include 'func/generator.php';
include 'coursematch.php';
$num = $_GET["time"];
//$num = 0;
$darr = $_GET["days"];
//$darr = "";
/*$num = 8;
$darr = "";*/
//$courselist = array("CSCI-103L","CSCI-109");
$courselist = $_GET["courselist"];
$coursematch = coursematch($courselist, $num, $darr, $conn);
$colorarr = array("EF5350", "AB47BC", "5C6BC0", "039BE5", "009688", "689F38", "EF6C00", "795548", "EC407A");
$queue = array();
foreach ($coursematch as $key => $possibility) {
    foreach ($possibility as $h => $s) {
        foreach ($s as $k) {
            if (count($courselist) > 1) {
                $z = $key;
            } else {
                if (count($courselist) == 1) {
                    $z = $h;
                }
            }
            $queue[$z][] = array("id" => $k->id, "class_id" => $k->class_id, "title" => $k->title, "type" => $k->type, "section" => $k->section, "time_start" => $k->time_start, "time_end" => $k->time_end, "days" => $k->days, "instructor" => $k->instructor, "room" => $k->room, "units" => $k->units, "top" => $k->time_start == "" ? 0 : (convertToMin($k->time_start) / 60 - 6) * 50, "size" => (strtotime($k->time_end) - strtotime($k->time_start)) / 60 / 60 * 50, "color" => $colorarr[array_search($k->class_id, $courselist)]);
        }
    }
    //if($key > 10) break;
}
echo json_encode($queue);
$conn->close();