function getMajorProfileByMajor($major) { $result = getAllSubjectsByMajor($major); $returnValue = array(); $i = 1; while ($row = mysql_fetch_array($result)) { // print_r($row); $returnSubValue = array(); $returnSubValue[0] = $row; $j = 1; $listID = $row['listid']; // $r = getListByListID($listID); while ($tempRow = mysql_fetch_array($r)) { $returnSubValue[$j] = $tempRow; $j++; } if ($row['component'] == "required") { $returnValue[0] = $returnSubValue; } else { $returnValue[$i] = $returnSubValue; $i++; } } return $returnValue; }
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"; } }
function getUntakenCourses($sid) { $result = getStudentById($sid); $row = mysql_fetch_array($result); $major = $row['major']; $result = getAllSubjectsByMajor($major); $father = array(); $son = array(); while ($row = mysql_fetch_array($result)) { array_push($father, $row); $subResult = getCoursesExceptTaken($sid, $row['listid']); $subSon = array(); while ($subRow = mysql_fetch_array($subResult)) { array_push($subSon, $subRow); } array_push($son, $subSon); } $returnValue = array(); array_push($returnValue, $father); array_push($returnValue, $son); return $returnValue; }