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"; } }
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; } }