Beispiel #1
0
function checkRestriction($cid, $selectedCourse)
{
    $restriction = getRestrictionStringByCid($cid);
    $array = transRestrictionToCNF($restriction);
    $error = array();
    $count = 0;
    $error[$count] = null;
    if ($restriction != null) {
        for ($i = 0; $i < count($array); $i++) {
            $orArray = divOrStringIntoArray($array[$i]);
            if (isInStu_offering($orArray)) {
                $error[$count] = $array[$i];
                $count++;
            } else {
                if (isInSelectedCourse($orArray, $selectedCourse)) {
                    $error[$count] = $array[$i];
                    $count++;
                }
            }
        }
    }
    if ($count != 0) {
        return false;
    } else {
        return true;
    }
}
Beispiel #2
0
function checkPrerequisites($cid, $selectedCourse)
{
    $prerequisites = getPrerequisitesStringByCid($cid);
    //echo $prerequisites;
    $array = transPreToCNF($prerequisites);
    //print_r($array);
    // $error=array();
    $count = 0;
    $error = "";
    if ($prerequisites != null) {
        for ($i = 0; $i < count($array); $i++) {
            //1.将array[$i]中的or 解析出来,放在新数组中
            $orArray = divOrStringIntoArray($array[$i]);
            //2.将这个数组放入profile里面进行查询,返回T or F
            //print_r($orArray);
            //3. 返回F就给$error赋值,否则继续
            if (!isInStu_offering($orArray)) {
                if (!isInSelectedCourse($orArray, $selectedCourse)) {
                    $error .= echoOrString($orArray) . "\n";
                    $count++;
                }
            }
        }
    }
    if ($count != 0) {
        return $error;
    } else {
        return "true";
    }
}
Beispiel #3
0
function checkPrerequisites($cid)
{
    $prerequisites = getPrerequisitesStringByCid($cid);
    //echo $prerequisites;
    $array = transPreToCNF($prerequisites);
    //print_r($array);
    $error = array();
    $count = 0;
    $error[$count] = null;
    if ($prerequisites != null) {
        for ($i = 0; $i < count($array); $i++) {
            //1.将array[$i]中的or 解析出来,放在新数组中
            $orArray = divOrStringIntoArray($array[$i]);
            //2.将这个数组放入profile里面进行查询,返回T or F
            //print_r($orArray);
            //3. 返回F就给$error赋值,否则继续
            if (!isInStu_offering($orArray)) {
                $error[$count] = $array[$i];
                $count++;
            }
        }
    }
    if ($count != 0) {
        return false;
    } else {
        return true;
    }
}
session_start();
$sid = $_SESSION['sid'];
$cid = $_POST['cid'];
$lecOid = $_POST['lec'];
$labOid = $_POST['lab'];
$prerequisites = getPrerequisitesStringByCid($cid);
//echo $prerequisites;
$array = transPreToCNF($prerequisites);
//print_r($array);
$error = array();
$count = 0;
$error[$count] = null;
if ($prerequisites != null) {
    for ($i = 0; $i < count($array); $i++) {
        //1.将array[$i]中的or 解析出来,放在新数组中
        $orArray = divOrStringIntoArray($array[$i]);
        //2.将这个数组放入profile里面进行查询,返回T or F
        //print_r($orArray);
        //3. 返回F就给$error赋值,否则继续
        if (!isInStu_offering($orArray)) {
            $error[$count] = $array[$i];
            $count++;
        }
    }
}
//@如果发现error里面有值,返回select 界面(可异步) #否则check offering 是否与本人已选课程冲突
if ($error[0] != null) {
    //echo "xx";
    // print_r($error);
    ?>
<p align="center">