SetQuery("select sum(credit1) as num from EnrollItem where studentId='$xKey' and acadYear='$yKey' and semester='$zKey'"); if ($result=$this->GetResult()) { return $result['num']; } } function GetSumCr2ByStIdAndAcYAndSe($xKey, $yKey, $zKey){ $this->SetQuery("select sum(credit2) as num from EnrollItem where studentId='$xKey' and acadYear='$yKey' and semester='$zKey'"); if ($result=$this->GetResult()) { return $result['num']; } } function RSEnrollItemByStIdAndAcYAndSe($xKey, $yKey, $zKey){ $this->SetQuery("select * from EnrollItem where studentId='$xKey' and acadYear='$yKey' and semester='$zKey'"); } function RSEnrollItemByStIdAndAcYAndSeAndCdId($wKey, $xKey, $yKey, $zKey){ $this->SetQuery("select * from EnrollItem where studentId='$wKey' and acadYear='$xKey' and semester='$yKey' and conditionId='$zKey'"); } function GetSumCrAtByStId($xKey){ $this->SetQuery("select sum(creditAttempt) as num from EnrollItem where studentId='$xKey'"); if ($result=$this->GetResult()) { return $result['num']; } } function GetSumCrAtByStIdAndAcYAndSe($xKey, $yKey, $zKey){ $this->SetQuery("select sum(creditAttempt) as num from EnrollItem where studentId='$xKey' and acadYear='$yKey' and semester='$zKey'"); if ($result=$this->GetResult()) { return $result['num']; } } function RSEnrollItemByStIdAndAcYAndSeAndClId($wKey, $xKey, $yKey, $zKey){ $this->SetQuery("select * from EnrollItem where studentId='$wKey' and acadYear='$xKey' and semester='$yKey' and classId='$zKey'"); } function RSEnrollItemByStIdAndAcYAndSeAndCoId($stId, $acY, $se, $coId){ $this->SetQuery("select e.* from EnrollItem e, Class c where e.studentId='$stId' and e.acadYear='$acY' and e.semester='$se' and e.classId=c.classId and c.courseId='$coId' and c.declareStatus='Y'"); } function GetSumCrAtByStIdAndCdIdAndCdId2($xKey, $yKey, $zKey){ $this->SetQuery("select sum(creditAttempt) as num from EnrollItem where studentId='$xKey' and conditionId='$yKey' and conditionId2='$zKey' and grade!='F'"); if ($result=$this->GetResult()) { return $result['num']; } } function RSEnrollItemByStIdAndCdIdAndCdId2($xKey, $yKey, $zKey){ $this->SetQuery("select * from EnrollItem where studentId='$xKey' and conditionId='$yKey' and conditionId2='$zKey'"); } function GetSumCrAtByStIdAndCdId($xKey, $yKey){ $this->SetQuery("select sum(creditAttempt) as num from EnrollItem where studentId='$xKey' and conditionId='$yKey' and grade!='F'"); if ($result=$this->GetResult()) { return $result['num']; } } function RSEnrollItemByStIdAndCdId($xKey, $yKey){ $this->SetQuery("select e.* from EnrollItem e, Class c where e.studentId='$xKey' and e.conditionId='$yKey' and e.classId=c.classId order by c.courseId"); } function RSEnrollItemByStIdAndGradeIsF($xKey){ $this->SetQuery("select * from EnrollItem where studentId='$xKey' and grade='F'"); } function RSEnrollItemByStId($xKey){ $this->SetQuery("select * from EnrollItem where studentId='$xKey'"); } function RSEnrollItemByClId($xKey){ $this->SetQuery("select e.* from EnrollItem e, StudentMaster s where e.classId='$xKey' and e.studentId=s.studentId order by s.studentCode"); } function RSEnrollItemByClIdAndStudying($xKey){ $this->SetQuery("select e.* from EnrollItem e, StudentMaster s where e.classId='$xKey' and e.studentId=s.studentId and s.studentStatus=1 order by s.studentCode"); } function GetCountStIdByClIdAndStSexAndStudying($xKey, $yKey){ $this->SetQuery("select count(s.studentId) as num from EnrollItem e, StudentMaster s where e.classId='$xKey' and e.studentId=s.studentId and s.studentStatus=1 and s.studentSex='$yKey'"); if ($result=$this->GetResult()) { return $result['num']; } } function SearchByStIdAndAcYAndSeAndCoId($stId, $acY, $se, $coId){ $sql = "select * from EnrollItem e, Class c where studentId='$stId' and concat($acY, $se)>concat(e.acadYear, e.semester) and e.classId=c.classId and courseId='$coId' and grade!='F'"; $this->SetQuery($sql); if ($result=$this->GetResult()) { return 1; }else { return 0; } } // Use on page classTable.php function RSEnrollItemByClassId($cKey, $dKey, $eKey){ $this->SetQuery("select classId from EnrollItem where classId='$cKey' and semester='$dKey' and acadYear='$eKey' group by classId"); } //-- The end -- function RSEnrollItemByClsIdAcySem($clId, $acY, $se){ $this->SetQuery("select ei.* from EnrollItem ei, StudentMaster s where ei.classId='$clId' and ei.acadYear='$acY' and ei.semester='$se' and ei.studentId=s.studentId and s.studentStatus=1 order by s.studentCode"); } function RSEnrollItemCountStIdByGrade($ClsId,$AcY,$SeM,$Gd){ $this->SetQuery("select count(studentId) as num from EnrollItem where classId='$ClsId' and acadYear='$AcY' and semester='$SeM' and grade='$Gd' order by studentId"); if ($result=$this->GetResult()) { return $result['num']; } } function RSEnrollItemCountStIdByAllGrade($ClsId,$AcY,$SeM){ $this->SetQuery("select count(studentId) as num from EnrollItem where classId='$ClsId' and acadYear='$AcY' and semester='$SeM' and grade!='F' and grade!='' order by studentId"); if ($result=$this->GetResult()) { return $result['num']; } } //-- The end -- // Use on page processSendGrade.php function SearchByKeyStudIdClsIdAcySem($wKey, $xKey, $yKey, $zKey){ if ($this->SetQuery("select * from EnrollItem where studentId='$wKey' and classId='$xKey' and acadYear='$yKey' and semester='$zKey' order by studentId")){ return 1; }else { return 0; } } //-- The End -- // Use on page calGradeProg.php function RSEnrollItemByAcySem($bKey,$cKey){ $this->SetQuery("select studentId from EnrollItem where acadYear='$bKey' and semester='$cKey' group by studentId"); } //-- The end -- //-- Use on page calGradeProg.php -- function RSEnrollItemGetStud($aKey, $bKey, $cKey){ $this->SetQuery("select * from EnrollItem where studentId='$aKey' and acadYear='$bKey' and semester='$cKey' and noCalGPA='N'"); } //-- The end -- function RSEnrollItemByPgIdAndAdYAndStYAndAcYAndSeAndGradeIsNotEmptyAndSendGrIsY($vKey, $wKey, $xKey, $yKey, $zKey){ $this->SetQuery("select * from EnrollItem, StudentMaster, Class where StudentMaster.programId='$vKey' and admitAcadYear='$wKey' and StudentMaster.studentYear='$xKey' and EnrollItem.acadYear='$yKey' and EnrollItem.semester='$zKey' and grade!='' and sendGradeStatus='Y' and EnrollItem.studentId=StudentMaster.studentId and EnrollItem.classId=Class.classId"); } function RSEnrollItemCountGradeByStId($StId, $AcY, $SeM){ $this->SetQuery("select count(grade) as num from EnrollItem where studentId='$StId', acadYear='$AcY' and semester='$SeM'"); if ($result=$this->GetResult()) { return $result['num']; } } function RSEnrollItemByStIdGroupAcYAndSe($xKey){ $this->SetQuery("select acadYear, semester from EnrollItem where studentId='$xKey' group by acadYear, semester"); } /****************************** Start Cal Grade ******************************/ function RSEnrollItemSemGradeCr($stId, $acY, $se, $str){ $this->SetQuery("select sum(ei.creditAttempt) as num from EnrollItem ei, Class c where ei.studentId='$stId' and ei.acadYear='$acY' and ei.semester='$se' and ei.noCalGPA='N' and ei.grade in ($str) and ei.classId=c.classId and c.declareStatus='Y'"); if ($result=$this->GetResult()) { return $result['num']; } } function RSEnrollItemCumGradeCr($stId, $acY, $se, $str){ $this->SetQuery("select sum(creditAttempt) as num from EnrollItem where studentId='$stId' and concat($acY, $se) >= concat(acadYear,semester) and noCalGPA='N' and grade in ($str)"); if ($result=$this->GetResult()) { return $result['num']; } } function RSEnrollItemCumGradeCr2($stId, $acY, $se, $str){ $this->SetQuery("select sum(ei.creditAttempt) as num from EnrollItem ei, Class c where ei.studentId='$stId' and concat($acY, $se) >= concat(ei.acadYear,ei.semester) and ei.noCalGPA='N' and ei.grade in ($str) and ei.classId=c.classId and c.declareStatus='Y'"); if ($result=$this->GetResult()) { return $result['num']; } } function calCreditSatisfy($stId, $acY, $se){ include_once "clsGradeConfig.php"; $oGc = new GradeConfig(); $sumCreditSatisfy = 0; $i = 0; $oGc->RSGradeConfig(); while($oGc->GetRecord()){ if($oGc->grade!='F' && $oGc->calCredit=='Y'){ if($i == 0) $strGnfy = "'".$oGc->grade."'"; else $strGnfy .= ",'".$oGc->grade."'"; } $i++; } $sumCreditSatisfy = $this->RSEnrollItemSemGradeCr($stId, $acY, $se, $strGnfy); return $sumCreditSatisfy; } function calCumCreditAttempt($stId, $acY, $se){ include_once "clsGradeConfig.php"; $oGc = new GradeConfig(); $cumCreditAttmp = 0; $i = 0; $oGc->RSGradeConfig(); while($oGc->GetRecord()){ if($i == 0) $strGay="'".$oGc->grade."',".$strGay; else $strGay="'".$oGc->grade."',".$strGay; $i++; } $strGay .= "''"; $cumCreditAttmp = $this->RSEnrollItemCumGradeCr($stId, $acY, $se, $strGay); return $cumCreditAttmp; } function calCumCreditSatisfy($stId, $acY, $se){ include_once "clsGradeConfig.php"; $oGc = new GradeConfig(); $cumCreditSatisfy = 0; $i = 0; $oGc->RSGradeConfig(); while($oGc->GetRecord()){ if($oGc->grade!='F' && $oGc->calCredit=='Y'){ if($i == 0) $strGnfy = "'".$oGc->grade."'"; else $strGnfy .= ",'".$oGc->grade."'"; } $i++; } $cumCreditSatisfy = $this->RSEnrollItemCumGradeCr2($stId, $acY, $se, $strGnfy); return $cumCreditSatisfy; } function GetDividendGPA($stId, $acY, $se){ $this->SetQuery("select sum(ei.creditAttempt*gc.gradePoint) as dividend from EnrollItem ei, Class c, GradeConfig gc where ei.studentId='$stId' and ei.acadYear='$acY' and ei.semester='$se' and ei.classId=c.classId and c.declareStatus='Y' and ei.grade=gc.grade"); if ($result=$this->GetResult()) { return $result['dividend']; } } function GetDividendGPAX($stId, $acY, $se){ $acYSe = $acY.$se; $this->SetQuery("select sum(ei.creditAttempt*gc.gradePoint) as dividend from EnrollItem ei, Class c, GradeConfig gc where ei.studentId='$stId' and concat(ei.acadYear, ei.semester)<='$acYSe' and ei.classId=c.classId and c.declareStatus='Y' and ei.grade=gc.grade"); if ($result=$this->GetResult()) { return $result['dividend']; } } function GetDividendAYRGPA($stId, $acY){ $this->SetQuery("select sum(ei.creditAttempt*gc.gradePoint) as dividend from EnrollItem ei, Class c, GradeConfig gc where ei.studentId='$stId' and ei.acadYear='$acY' and ei.classId=c.classId and c.declareStatus='Y' and ei.grade=gc.grade"); if ($result=$this->GetResult()) { return $result['dividend']; } } function GetAllFDivisorGPA($stId, $acY, $se){ $this->SetQuery("select sum(ei.creditAttempt) as divisor from EnrollItem ei, Class c, GradeConfig gc where ei.studentId='$stId' and ei.acadYear='$acY' and ei.semester='$se' and ei.classId=c.classId and c.declareStatus='Y' and ei.grade=gc.grade and gc.calGrade='Y'"); if ($result=$this->GetResult()) { return $result['divisor']; } } function GetAllFDivisorGPAX($stId, $acY, $se){ $acYSe = $acY.$se; $this->SetQuery("select sum(ei.creditAttempt) as divisor from EnrollItem ei, Class c, GradeConfig gc where ei.studentId='$stId' and concat(ei.acadYear, ei.semester)<='$acYSe' and ei.classId=c.classId and c.declareStatus='Y' and ei.grade=gc.grade and gc.calGrade='Y'"); if ($result=$this->GetResult()) { return $result['divisor']; } } function GetOneFDivisorGPAX($stId, $acY, $se){ $acYSe = $acY.$se; $this->SetQuery("select sum(tt) as divisor from ( select sum(ei.creditAttempt) as tt from EnrollItem ei, Class c, GradeConfig gc where ei.studentId='$stId' and concat(ei.acadYear, ei.semester)<='$acYSe' and ei.classId=c.classId and c.declareStatus='Y' and ei.grade=gc.grade and gc.gradePoint<>0 and c.courseId not in (select courseId from EnrollItem ei, Class c where studentId='$stId' and concat(ei.acadYear, ei.semester)<='$acYSe' and ei.classId=c.classId group by studentId, courseId having count(courseId)>1) union select sum(ei.creditAttempt) as tt from EnrollItem ei, Class c, GradeConfig gc where ei.studentId='$stId' and concat(ei.acadYear, ei.semester)<='$acYSe' and ei.classId=c.classId and c.declareStatus='Y' and ei.grade<>'F' and ei.grade=gc.grade and c.courseId in (select courseId from EnrollItem ei, Class c where studentId='$stId' and concat(ei.acadYear, ei.semester)<='$acYSe' and ei.classId=c.classId group by studentId, courseId having count(courseId)>1) ) aa"); if ($result=$this->GetResult()) { return $result['divisor']; } } function GetAllFDivisorAYRGPAX($stId, $acY){ $this->SetQuery("select sum(ei.creditAttempt) as divisor from EnrollItem ei, Class c, GradeConfig gc where ei.studentId='$stId' and ei.acadYear='$acY' and ei.classId=c.classId and c.declareStatus='Y' and ei.grade=gc.grade and gc.calGrade='Y'"); if ($result=$this->GetResult()) { return $result['divisor']; } } function CalGradeByStIdAndAcYAndSe($stId, $acY, $se, $createUserId, $updateUserId){ include_once "../global0.php"; include_once "../class/clsStudentStatus.php"; include_once "../class/clsStudentMaster.php"; $conn = new Connection(); $oSm = new StudentMaster(); $oSs = new StudentStatus(); if($GLOBALS["CALGRADEF"] == '1') $divisor = $this->GetAllFDivisorGPAX($stId, $acY, $se); else if($GLOBALS["CALGRADEF"] == '2') $divisor = $this->GetOneFDivisorGPAX($stId, $acY, $se); // Update StudentMaster $oSm->SearchByKey($stId); $oSm->GetRecord(); $oSm->Edit(); $oSm->creditAttempt=$this->calCumCreditAttempt($stId, $acY, $se); $oSm->creditSatisfy=$this->calCumCreditSatisfy($stId, $acY, $se); $oSm->GPA=$this->GetDividendGPAX($stId, $acY, $se) / $divisor; if(is_null($oSm->officerId1)) $oSm->officerId1 = 'NULL'; if(is_null($oSm->officerId2)) $oSm->officerId2 = 'NULL'; $oSm->updateUserId=$updateUserId; $oSm->updateDateTime=date('Y-m-d H:i:s'); if(is_null($oSm->citizenId)) $oSm->citizenId = 'NULL'; if(is_null($oSm->preAdmitPositionId)) $oSm->preAdmitPositionId = 'NULL'; if($oSm->GPA < 1.75) $oSm->studentStatusTmp = 7; else $oSm->studentStatusTmp = 1; $oSm->Save(); // StudentStatus $oSs->SearchByKey($stId, $acY, $se); if($oSs->GetRecord()) { // Update StudentStatus $oSs->Edit(); $oSs->GPA=$this->GetDividendGPA($stId, $acY, $se) / $this->GetAllFDivisorGPA($stId, $acY, $se); $oSs->creditAttempt=$this->GetSumCrAtByStIdAndAcYAndSe($stId, $acY, $se); $oSs->creditSatisfy=$this->calCreditSatisfy($stId, $acY, $se); $oSs->creditPoint=$this->GetAllFDivisorGPA($stId, $acY, $se); $oSs->GPAX=$this->GetDividendGPAX($stId, $acY, $se) / $divisor; $oSs->sumCreditAttempt=$this->calCumCreditAttempt($stId, $acY, $se); $oSs->sumCreditSatisfy=$this->calCumCreditSatisfy($stId, $acY, $se); $oSs->sumCreditPoint=$divisor; $oSs->updateDateTime=date('Y-m-d H:i:s'); $oSs->updateUserId=$updateUserId; if(is_null($oSs->approveSpe)) $oSs->approveSpe = 'NULL'; } else { // Insert StudentStatus $oSs->AddNew(); $oSs->studentId=$stId; $oSs->acadYear=$acY; $oSs->semester=$se; $oSs->studentStatus=$oSm->studentStatus; $oSs->GPA=$this->GetDividendGPA($stId, $acY, $se) / $this->GetAllFDivisorGPA($stId, $acY, $se); $oSs->creditAttempt=$this->GetSumCrAtByStIdAndAcYAndSe($stId, $acY, $se); $oSs->creditSatisfy=$this->calCreditSatisfy($stId, $acY, $se); $oSs->creditPoint=$this->GetAllFDivisorGPA($stId, $acY, $se); $oSs->GPAX=$this->GetDividendGPAX($stId, $acY, $se) / $divisor; $oSs->sumCreditAttempt=$this->calCumCreditAttempt($stId, $acY, $se); $oSs->sumCreditSatisfy=$this->calCumCreditSatisfy($stId, $acY, $se); $oSs->sumCreditPoint=$divisor; $oSs->createDateTime=date('Y-m-d H:i:s'); $oSs->createUserId=$createUserId; $oSs->updateDateTime=date('Y-m-d H:i:s'); $oSs->updateUserId=$updateUserId; if(is_null($approveSpe)) $approveSpe = 'NULL'; $oSs->approveSpe=$approveSpe; $oSs->approver=$approver; $oSs->refNo=$refNo; $oSs->approveDate=$approveDate; $oSs->passStatus=$passStatus; } $oSs->Save(); } /****************************** End Cal Grade ******************************/ /****************************** Start Pass Student ******************************/ function GetCountGradeByStIdAndAcYAndGradeIsF($xKey, $yKey){ $this->SetQuery("select count(grade) as num from EnrollItem where studentId='$xKey' and acadYear='$yKey' and noCalGPA='N' and grade='F'"); if ($result=$this->GetResult()) { return $result['num']; } } function RSEnrollItemByStIdAndAcY($xKey, $yKey){ $this->SetQuery("select * from EnrollItem where studentId='$xKey' and acadYear='$yKey'"); } function RSEnrollItemByStIdAndAcYAndSendGrIsNUnionGradeInIEPX($stId, $acY){ $sql = "select e.* from EnrollItem e, Class c where e.studentId='$stId' and e.acadYear='$acY' and e.classId=c.classId and c.sendGradeStatus='N' union select e.* from EnrollItem e where e.studentId='$stId' and e.acadYear='$acY' and e.grade in ('I', 'E', 'P', 'X', '')"; $this->SetQuery($sql); } function GetPassStatusByStIdAndAcY($stId, $acY){ include_once "../class/clsStudentMaster.php"; include_once "../class/clsProgram.php"; $conn = new Connection(); $oSm = new StudentMaster(); $oPg = new Program(); $oSm->SearchByKey($stId); $oSm->GetRecord(); $oPg->SearchByKey($oSm->programId); $oPg->GetRecord(); if($oSm->studentStatus==7 || $oSm->studentStatus==9 || intval($acY - $oSm->admitAcadYear)>$oPg->studyYearMax) return 5; else { if($oSm->totalPoint < 80) return 4; else { if($oSm->GPA >= $GLOBALS["ANNUALGPAX"]) { if($this->GetCountGradeByStIdAndAcYAndGradeIsF($stId, $acY) == 0) return 1; else return 2; } else if($oSm->GPA>=1.95 && $oSm->GPA<$GLOBALS["ANNUALGPAX"]) return 3; else return 4; } } } /****************************** End Pass Student ******************************/ // Use on page beforeShowClassTeach.php function RSEnrollItemByAcySem2($bKey,$cKey){ $this->SetQuery("select * from EnrollItem where acadYear='$bKey' and semester='$cKey' order by studentId"); } function SearchByKeyClsId($ClsId){ if($this->SetQuery("select count(classId) as num from EnrollItem where classId='$ClsId' order by classId")){ return 1; }else{ return 0; } } //-- The end -- function SearchCourseByStIdAcYSemTssDay($StId,$AcY,$SeM,$Tss,$Dy){ $this->setQuery("select cr.courseCode, e.classId, e.section, r.roomNo, t.timeSlotStart, t.timeSlotEnd from EnrollItem e, Class c, ClassTimeTable t, Course cr, Room r where e.studentId='$StId' and e.acadYear='$AcY' and e.semester='$SeM' and e.classId=c.classId and c.classId=t.classId and c.courseId=cr.courseId and t.roomId=r.roomId and t.timeSlotStart='$Tss' and t.weekDay='$Dy'"); } function ClearData(){ $this->tcourseCode =''; $this->tsection =''; $this->troomNo =''; $this->tTimeSlotStart =''; $this->tTimeSlotEnd =''; } function RSEnrollItemByAcYAndSeGroupClId($xKey, $yKey){ $this->SetQuery("select ei.classId from EnrollItem ei, Class cl, Course co where ei.acadYear='$xKey' and ei.semester='$yKey' and ei.classId=cl.classId and cl.courseId=co.courseId group by ei.classId order by cl.programId, co.courseCode, co.courseName"); } function RSEnrollItemByAcYAndSeAndPgIdGroupClId($xKey, $yKey, $zKey){ $this->SetQuery("select e.classId from EnrollItem e, Class c where e.acadYear='$xKey' and e.semester='$yKey' and e.classId=c.classId and c.programId='$zKey' group by e.classId"); } function RSEnrollItemByAcYAndSeAndPgIdIsNullGroupClId($acY, $se, $pgId){ $this->SetQuery("select e.classId from EnrollItem e, Class c, ClassOpenFor f where e.acadYear='$acY' and e.semester='$se' and e.classId=c.classId and c.programId is null and c.classId=f.classId and f.programId='$pgId' group by e.classId"); } function CountConIdIs3AndGB($StId, $AcY, $SeM){ $this->SetQuery("SELECT count(et.conditionId) as num FROM EnrollItem et, GradeConfig g WHERE et.conditionId=3 and et.grade=g.grade and g.gradePoint < 3 and et.studentId='$StId' and et.acadYear='$AcY' and et.semester='$SeM' "); if ($result=$this->GetResult()) { return $result['num']; } } function CountConIdIsNot3AndGC($StId, $AcY, $SeM){ $this->SetQuery("SELECT count(et.conditionId) as num FROM EnrollItem et, GradeConfig g WHERE et.conditionId!=3 and et.grade=g.grade and g.gradePoint < 5 and et.studentId='$StId' and et.acadYear='$AcY' and et.semester='$SeM' "); if ($result=$this->GetResult()) { return $result['num']; } } function RSEnrollItemByStIdAndAcYAndSeAndSeq($stId, $acY, $se, $seq){ $this->SetQuery("select * from EnrollItem where studentId='$stId' and acadYear='$acY' and semester='$se' and sequence='$seq'"); } function RSEnrollItemByStIdAndAcYAndClIdAndGrInAtoF($stId, $acY, $clId){ $sql = "select count(ei.grade) as num from EnrollItem ei where ei.studentId='$stId' and ei.acadYear='$acY' and ei.classId='$clId' and exists (select gc.grade from GradeConfig gc where gc.calGrade='Y' and gc.grade=ei.grade)"; $this->SetQuery($sql); if ($result=$this->GetResult()) { return $result['num']; } } } //--End class EnrollItem-- ?>