function getKasiPlan($semesters, $sid) { //$plannerId = 1; //echo $semesters; //echo $sid; $AllCourse = array(); $selectedCourse = array(); $creditsList = array(); //$result=getPlannerBySid($sid,$plannerId); //while($row=mysql_fetch_array($result)){ // array_push($AllCourse,$row); //} $major = mysql_fetch_array(getStudentById($sid))['major']; $result = getAllSubjectsByMajor($major); while ($row = mysql_fetch_array($result)) { array_push($creditsList, $row); $listid = $row['listid']; $subResult = getListByListID($listid); while ($subRow = mysql_fetch_array($subResult)) { array_push($AllCourse, $subRow); } } // return $AllCourse; session_start(); $_SESSION['creditsList'] = $creditsList; $returnResult = array(); for ($i = 0; $i < $semesters; $i++) { $eachLevel = array(); // echo "xx<br>"; foreach ($AllCourse as $key => $value) { $row = mysql_fetch_array(getCourseById($value['cid'])); $value['offerTime'] = $row['offerTime']; if (checkPrerequisites($value['cid'], $selectedCourse)) { if ($i == 0) { $value[5] = "true"; $value['available'] = "true"; } else { $value[5] = "false"; $value['available'] = "false"; } array_push($eachLevel, $value); //array_push($selectedCourse, $value['cid']); unset($AllCourse[$key]); } } foreach ($eachLevel as $value) { array_push($selectedCourse, $value['cid']); for ($ii = 0; $ii < count($creditsList); $ii++) { if ($creditsList[$ii]['listid'] == $value['listid']) { $creditsList[$ii]['credits'] -= $value['credits']; break; } } } // print_r($eachLevel); array_push($returnResult, $eachLevel); // echo "<br>"; } $flag = true; for ($i = 0; $i < count($creditsList); $i++) { // echo $creditsList[$i]['credits']."<br>"; if ($creditsList[$i]['credits'] > 0) { $flag = false; } } if ($flag == true) { session_start(); $_SESSION['semesters'] = $returnResult; // $_SESSION['creditsList']=$creditsList; return $returnResult; } else { session_start(); $_SESSION['semesters'] = "error"; // $_SESSION['creditsList']=$creditsList; return "error"; } }
$m = checkPrerequisites($value['cid'], $array); if ($m == "true") { // $semesterCourses[$currentSemester][$key]['available'] = "true"; $value['available'] = "true"; } else { // $semesterCourses[$currentSemester][$key]['available'] = "required:\n" . $m; $value['available'] = "required:\n" . $m; } } //$_SESSION['semesters']=$semesterCourses; array_push($unselectedCourse, $value); } } } foreach ($semesterCourses[$currentSemester] as $key => $value) { $m = checkPrerequisites($value['cid'], $array); if ($m == "true") { $semesterCourses[$currentSemester][$key]['available'] = "true"; $value['available'] = "true"; } else { $semesterCourses[$currentSemester][$key]['available'] = "required:\n" . $m; $value['available'] = "required:\n" . $m; } array_push($unselectedCourse, $value); } // $_SESSION['semesters']=$semesterCourses; echo json_encode($unselectedCourse); } else { if ($method = "generate") { session_start(); $sid = $_SESSION['sid'];
function getMajorOverView($sid, $plannerId) { $result = getStudentById($sid); $row = mysql_fetch_array($result); $major = $row['major']; $courseTakenOrPlanArray = getCidFromPlannerAndStu_OfferingBySid($sid, $plannerId); // print_r($courseTakenOrPlanArray); $result = getAllSubjectsByMajor($major); //echo $major; $father = array(); $son = array(); while ($row = mysql_fetch_array($result)) { // print_r($row['listid']); array_push($father, $row); $subResult = getListByListID($row['listid']); $subSon = array(); while ($subRow = mysql_fetch_array($subResult)) { // print_r($subRow); $temp = array(); $temp['cid'] = $subRow['cid']; $temp['credits'] = $subRow['credits']; if (in_array($subRow['cid'], $courseTakenOrPlanArray)) { $temp['term'] = getTermByCid($subRow['cid'], $plannerId); } else { if (checkPrerequisites($subRow['cid'])) { $temp['term'] = "true"; } else { if (checkPrerequisitesOnPlanner($subRow['cid'], $plannerId)) { $temp['term'] = "true"; } else { $temp['term'] = "false"; } } } array_push($subSon, $temp); } array_push($son, $subSon); } $returnValue = array(); array_push($returnValue, $father); array_push($returnValue, $son); return $returnValue; }