Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 20 |
CRAP | |
0.00% |
0 / 394 |
| SspService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 20 |
4032.00 | |
0.00% |
0 / 394 |
| __construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
| __clone | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
| getInstance | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 5 |
|||
| SspCourses | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
| SspCourseUpdate | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
| getAllCourseNamesByPatternID | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
| getAllDisciplines | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| getAllDisciplinesForPatternID | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 16 |
|||
| updateDisciplineByPatternID | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 12 |
|||
| getAllSspManagementSettings | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 16 |
|||
| updateParameterById | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 14 |
|||
| getSspDynamicParameters | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 29 |
|||
| getPreviousInstitutionDetailsByBatch | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 47 |
|||
| getPreviousCollegeWithSspData | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 13 |
|||
| checkBatchPresentYearForSsp | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 15 |
|||
| getStudentPreviousDetailsForSsp | |
0.00% |
0 / 1 |
272.00 | |
0.00% |
0 / 88 |
|||
| getDisciplineCourseStudent | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 24 |
|||
| getSeatTypeFromStudentAccount | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 16 |
|||
| getLateralEntryStatus | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 16 |
|||
| generateReportFromSspStudentLog | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 41 |
|||
| <?php | |
| namespace com\linways\core\ams\professional\service; | |
| use com\linways\core\ams\professional\exception\ProfessionalException; | |
| use com\linways\base\util\RequestUtil; | |
| use com\linways\core\ams\professional\service\examcontroller\CommonExamService; | |
| class SspService extends BaseService | |
| { | |
| private static $_instance = null; | |
| // /Condition 2 - Locked down the constructor | |
| private function __construct() | |
| { | |
| } | |
| // Prevent any oustide instantiation of this class | |
| // /Condition 3 - Prevent any object or instance of that class to be cloned | |
| private function __clone() | |
| { | |
| } | |
| // Prevent any copy of this object | |
| // /Condition 4 - Have a single globally accessible static method | |
| public static function getInstance() | |
| { | |
| if (!is_object(self::$_instance)) // or if( is_null(self::$_instance) ) or if( self::$_instance == null ) | |
| self::$_instance = new self (); | |
| return self::$_instance; | |
| } | |
| /** | |
| * @return Object | |
| * @throws ProfessionalException | |
| */ | |
| public function SspCourses() | |
| { | |
| $sql = "SELECT Course_Code as code ,Course_Name as name,Course_Long_Name as `desc` from ssp_course"; | |
| try { | |
| return $this->executeQueryForList($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function SspCourseUpdate($coursePattern, $sspCourseId) | |
| { | |
| $coursePattern = $this->realEscapeString($coursePattern); | |
| $sspCourseId = $this->realEscapeString($sspCourseId); | |
| $sql = "UPDATE course_pattern SET ssp_course_id = '$sspCourseId' WHERE patternID = $coursePattern"; | |
| try { | |
| $this->executeQuery($sql); | |
| return true; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function getAllCourseNamesByPatternID($coursePatternID) | |
| { | |
| $coursePatternID = $this->realEscapeString($coursePatternID); | |
| try { | |
| $sql = "SELECT patterncourseID ,patterncourseName , ssp_discipline_id ,patternID from pattern_deptcourses pd WHERE patternID = $coursePatternID"; | |
| $courseNames = $this->executeQueryForList($sql); | |
| return $courseNames; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function getAllDisciplines() | |
| { | |
| try { | |
| $sql = "SELECT Discipline_Code,Course_Code ,Discipline_name ,Remarks from ssp_discipline"; | |
| $sspDisciplines = $this->executeQueryForList($sql); | |
| return $sspDisciplines; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function getAllDisciplinesForPatternID($coursePatternID) | |
| { | |
| $coursePatternID = $this->realEscapeString($coursePatternID); | |
| $sql = "SELECT patternID ,ssp_course_id from course_pattern cp WHERE patternID = $coursePatternID"; | |
| try { | |
| $sspCourseId = $this->executeQueryForObject($sql)->ssp_course_id; | |
| if(!$sspCourseId) | |
| { | |
| return ; | |
| }else{ | |
| $sqlGetDisciplines = "SELECT id,Discipline_Code,Discipline_name from ssp_discipline sd where Course_Code =$sspCourseId order by Discipline_name"; | |
| return $this->executeQueryForList($sqlGetDisciplines); | |
| } | |
| }catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function updateDisciplineByPatternID($coursePatternID,$disciplineID) | |
| { | |
| try{ | |
| $coursePatternID = $this->realEscapeString($coursePatternID); | |
| $disciplineID = $this->realEscapeString($disciplineID); | |
| $sql = "UPDATE pattern_deptcourses SET ssp_discipline_id = '$disciplineID' WHERE patternCourseID = '$coursePatternID'"; | |
| $this->executeQuery($sql); | |
| return true; | |
| } | |
| catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function getAllSspManagementSettings($type = null) | |
| { | |
| if($type) | |
| { | |
| $condition = " AND `type` = '$type' "; | |
| } | |
| else{ | |
| $condition = ""; | |
| } | |
| $sql = "SELECT * from ssp_management WHERE 1=1 $condition"; | |
| try | |
| { | |
| return $this->executeQueryForList($sql); | |
| }catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function updateParameterById($entry,$id, $isCustom = false) | |
| { | |
| $entry = $this->realEscapeString($entry); | |
| $id = $this->realEscapeString($id); | |
| $additionalcolumn = $isCustom ? ", additionalSettings = '$isCustom' ":""; | |
| try{ | |
| $sql = "UPDATE ssp_management SET value= '$entry' $additionalcolumn WHERE id = '$id'"; | |
| $this->executeQuery($sql); | |
| return true; | |
| } | |
| catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| return false; | |
| } | |
| } | |
| public function getSspDynamicParameters() | |
| { | |
| try { | |
| $result = []; | |
| $sql = "SELECT * from ssp_management"; | |
| $parameters = $this->executeQueryForList($sql); | |
| $nonMandatory = []; | |
| foreach ($parameters as $param) { | |
| if($param->isMandatory != "1") | |
| { | |
| $nonMandatory[] = $param->type; | |
| } | |
| $result[$param->type] = html_entity_decode($param->value); | |
| if($param->additionalSettings) | |
| { | |
| $obj = new \stdClass(); | |
| $obj->addittionalSettings = json_decode($param->additionalSettings); | |
| $obj->data[$param->type] = html_entity_decode($param->value); | |
| $result[$param->type] = $obj; | |
| } | |
| } | |
| $response = new \stdClass(); | |
| $response->data = $result; | |
| $response->nonMandatory = $nonMandatory; | |
| return $response; | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| return false; | |
| } | |
| } | |
| public function getPreviousInstitutionDetailsByBatch($request) | |
| { | |
| try { | |
| $result = []; | |
| $request = $this->realEscapeObject($request); | |
| (int) $request->batchId?$where[] = " s.batchID = ".$request->batchId:null; | |
| if($request->batchId) | |
| { | |
| $sqlgetStudentIds = "SELECT GROUP_CONCAT(studentID) as studentID from studentaccount s WHERE s.batchID = '$request->batchId' GROUP by batchID"; | |
| $studentIds = $this->executeQueryForObject($sqlgetStudentIds)->studentID; | |
| } | |
| if(trim($studentIds) != "") | |
| { | |
| $sql = "SELECT | |
| s.studentID, | |
| aasd.extraDetails->>'$.eleventhAllInstitutionId' AS AdmEleventInstitution, | |
| aasd.extraDetails->>'$.twelfthAllInstitutionId' AS AdmTwelfthInstitution, | |
| aasd.extraDetails->>'$.ugAllInstitutionId' AS admUgInstitution, | |
| asmTwelfth.processed_mark_details->>'$.totalMaxMark' AS twelthMax, | |
| asmTwelfth.processed_mark_details->>'$.totalMark' AS twelthObtained, | |
| asmUg.processed_mark_details->>'$.totalMaxMark' AS ugMax, | |
| asmUg.processed_mark_details->>'$.totalMark' AS ugObtained | |
| FROM | |
| adm_admission_student_details aasd | |
| INNER JOIN | |
| adm_admission_admitted_student_details aaasd ON (aasd.id = aaasd.studentId | |
| AND aasd.admission_applicant_id = aaasd.applicantId | |
| AND aasd.admission_form_id = aaasd.formId) | |
| INNER JOIN | |
| studentaccount s ON (aaasd.studentAccountId = s.studentID) | |
| INNER JOIN | |
| studentaccount_extras se ON (se.studentID = s.studentID) | |
| LEFT JOIN | |
| adm_student_mark asmTwelfth ON (asmTwelfth.studentId = aasd.id and asmTwelfth.`type` = 'TWELFTH') | |
| LEFT JOIN | |
| adm_student_mark asmUg ON (asmUg.studentId = aasd.id and asmUg.`type` = 'UG') | |
| WHERE | |
| aaasd.studentAccountId IN ($studentIds);"; | |
| return $this->executeQueryForList($sql); | |
| } | |
| else{ | |
| return $result; | |
| } | |
| }catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| return false; | |
| } | |
| } | |
| public function getPreviousCollegeWithSspData($collegeId){ | |
| $sql = "SELECT sc.University_Code AS Previous_Year_SSP_University_Code, | |
| sc.University_Name AS Previous_Year_SSP_University_Name, | |
| sc.College_Code AS Previous_Year_SSP_College_Code, | |
| sc.College_Name AS Previous_Year_SSP_College_Name | |
| from ssp_institutions si | |
| left join ssp_colleges sc on sc.College_AISHE_Code = si.College_AISHE_Code | |
| where si.id = '$collegeId' and sc.University_Code IS NOT NULL"; | |
| try { | |
| return $this->executeQueryForObject($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| } | |
| public function checkBatchPresentYearForSsp($groupId) | |
| { | |
| $groupId = $this->realEscapeString($groupId); | |
| $sql = "SELECT | |
| at2.properties->>'$.year' as year, | |
| at2.properties->>'$.orderNo' as semester | |
| from | |
| batches b | |
| inner join `groups` g on | |
| g.id = b.groups_id | |
| inner join academic_term at2 on | |
| at2.id = g.properties->>'$.currentTermId' | |
| WHERE | |
| b.groups_id = '$groupId' "; | |
| return $this->executeQueryForObject($sql); | |
| } | |
| public function getStudentPreviousDetailsForSsp($request, $parameter) | |
| { | |
| $request = $this->realEscapeObject($request); | |
| $responseArr = []; | |
| $sqlGetAllPossibleTerms = "SELECT id from academic_term at2 WHERE at2.properties->>'$.year' =$request->year and `type` ='Semester'"; | |
| $terms = $this->executeQueryForList($sqlGetAllPossibleTerms); | |
| $allTerms = []; | |
| foreach ($terms as $key => $t) { | |
| $allTerms[] = $t->id; | |
| } | |
| $sql = "SELECT | |
| spa.student_id as studentId,g.id as groupId | |
| from | |
| batches b | |
| inner join `groups` g on g.id = b.groups_id | |
| inner join student_program_account spa on spa.current_batch_id = g.id | |
| where | |
| b.batchID = $request->batchId"; | |
| $students = $this->executeQueryForList($sql); | |
| foreach ($students as $key => $student) | |
| { | |
| $req = new \stdClass(); | |
| $req->studentId = $student->studentId; | |
| // $req->groupId = $student->groupId; | |
| $result = (Object) CommonExamService::getInstance()->getConsolidatedStudentData($req); | |
| $returningStudent = null; | |
| if(is_object($result)){ | |
| foreach ($result as $program){ | |
| foreach($program->students as $student){ | |
| if ($returningStudent == null) { | |
| $returningStudent = $student; | |
| } | |
| if(is_object($student->academicTerms)){ | |
| $student->academicTerms = (array)$student->academicTerms; | |
| } | |
| foreach($student->academicTerms as $term){ | |
| if(is_object($term->subjects)){ | |
| $term->subjects = (array)$term->subjects; | |
| } | |
| } | |
| } | |
| } | |
| } | |
| if($returningStudent) | |
| { | |
| $academicTerms = $returningStudent->academicTerms; | |
| $maxMarks = 0; | |
| $marksObtained = 0; | |
| $PASS_or_FAIL = "P"; | |
| $promoted = "Y"; | |
| foreach ($academicTerms as $key => $term) { | |
| if(in_array($term->termId, $allTerms)) | |
| { | |
| $maxMarks = $maxMarks + $term->markDetails->totalMark; | |
| $marksObtained = $marksObtained + $term->markDetails->markObtained; | |
| if($term->failedStatus != "PASSED") | |
| { | |
| $PASS_or_FAIL = "F"; | |
| $promoted = "N"; | |
| } | |
| } | |
| } | |
| } | |
| $previousStudentsDetail = new \stdClass(); | |
| $previousStudentsDetail->studentID = $student->studentId; | |
| $previousStudentsDetail->Previous_Year_Max_Marks = $maxMarks; | |
| $previousStudentsDetail->Previous_Year_Obtained_Marks = $marksObtained; | |
| $previousStudentsDetail->PASS_or_FAIL = $PASS_or_FAIL; | |
| $previousStudentsDetail->Promoted = $promoted; | |
| $previousStudentsDetail->Previous_Course_Passed_Year = $student->markDetails->latestExamYear; | |
| $previousStudentsDetail->Previous_Year_Course_Year = $request->year; | |
| $previousStudentsDetail->Previous_Year_SSP_University_Code = $parameter['UNIVERSITY_SSP_CODE']; | |
| $previousStudentsDetail->Previous_Year_SSP_University_Name = $parameter['UNIVERSITY_NAME']; | |
| $previousStudentsDetail->Previous_Year_SSP_College_Code = $parameter['COLLEGE_SSP_CODE']; | |
| $previousStudentsDetail->Previous_Year_SSP_College_Name = $parameter['COLLEGE_NAME']; | |
| $previousStudentsDetail->Previous_Year_SSP_Seat_Type_Code = $parameter['SEAT_TYPE_SSP_CODE']; | |
| $previousStudentsDetail->Previous_Year_SSP_Seat_Type_Name = $parameter['SEAT_TYPE_NAME']; | |
| $courseAndDiscipline = $this->getDisciplineCourseStudent($student->studentId); | |
| $previousStudentsDetail->Previous_Year_SSP_Course_Code = $courseAndDiscipline->Course_Code; | |
| $previousStudentsDetail->Previous_Year_SSP_Course_Name = $courseAndDiscipline->Course_Name; | |
| $previousStudentsDetail->Previous_Year_SSP_Discipline_Code = $courseAndDiscipline->Discipline_Code; | |
| $previousStudentsDetail->Previous_Year_SSP_Discipline_Name = $courseAndDiscipline->Discipline_name; | |
| if($maxMarks && $marksObtained) | |
| { | |
| $previousStudentsDetail->Previous_Year_Percentage_Obtained = round(($marksObtained / $maxMarks) * 100,2); | |
| } | |
| $responseArr[] = $previousStudentsDetail; | |
| } | |
| return $responseArr; | |
| } | |
| public function getDisciplineCourseStudent($studentId) | |
| { | |
| try{ | |
| $studentId = $this->realEscapeString($studentId); | |
| $sql = " SELECT | |
| b.batchID , | |
| sc.Course_Code , | |
| sc.Course_Name , | |
| sd.Discipline_Code , | |
| sd.Discipline_name | |
| from | |
| batches b | |
| inner join course_pattern cp on cp.patternID = b.patternID | |
| inner join pattern_deptcourses pd on pd.patterncourseID = b.patterncourseID | |
| inner join ssp_course sc on cp.ssp_course_id = sc.Course_Code | |
| inner join ssp_discipline sd on sd.id = pd.ssp_discipline_id | |
| inner join studentaccount s on s.batchID = b.batchID | |
| WHERE s.studentID = '$studentId' "; | |
| return $this->executeQueryForObject($sql); | |
| } | |
| catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| return false; | |
| } | |
| } | |
| /** | |
| * get student seat type for ssp | |
| * | |
| * get student seat type ssp code generation for data transfer | |
| * | |
| * @param Integer $studentID unique studentID from studentaccount | |
| * @return Object | |
| * @throws ProfessionalException | |
| **/ | |
| public function getSeatTypeFromStudentAccount($studentID) | |
| { | |
| try{ | |
| $sql = "SELECT | |
| s.studentID ,aq.quotaID ,aq.quotaName ,sst.Seat_Type_Code as seatCode,sst.Seat_Type_Name as seatName | |
| from | |
| studentaccount s | |
| inner join admission_quotas aq on aq.quotaID = s.quotaID | |
| inner join ssp_seattypes sst on sst.Seat_Type_Code = aq.Seat_Type_Code | |
| WHERE | |
| s.studentID = $studentID"; | |
| return $this->executeQueryForObject($sql); | |
| }catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| return false; | |
| } | |
| } | |
| /** | |
| * get lateral entry status of student | |
| * | |
| * get lateral entry status for students for ssp Y-->lateral Entry, N --> regular entry | |
| * | |
| * @param Integer $studentID unique studentId from student account | |
| * @return String | |
| * @throws ProfessionalException | |
| **/ | |
| public function getLateralEntryStatus($studentID) | |
| { | |
| try { | |
| $sql = "SELECT `lateral` from studentaccount s WHERE studentID = $studentID "; | |
| $studentDetail = $this->executeQueryForObject($sql); | |
| if($studentDetail->lateral == "0") | |
| { | |
| return "N"; | |
| } | |
| else{ | |
| return "Y"; | |
| } | |
| //code... | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| return false; | |
| } | |
| } | |
| /** | |
| * generate report from ssp log | |
| * | |
| * generate report from ssp log with details like message and other data | |
| * | |
| * @param Array $batchIds Array of batchIds | |
| * @return Array | |
| * @throws ProfessionalException | |
| **/ | |
| public function generateReportFromSspStudentLog($batchIDs, $yearCode) | |
| { | |
| $batchIDs = $this->realEscapeArray($batchIDs); | |
| if(count($batchIDs) > 0) | |
| { | |
| $batchId = implode(",",$batchIDs); | |
| $batchIdCondition = " AND b.batchID IN ( $batchId ) "; | |
| } | |
| else{ | |
| $batchIdCondition = ""; | |
| } | |
| if($yearCode) | |
| { | |
| $yearCondition = " AND ssl2.academic_year_code = $yearCode"; | |
| } | |
| else{ | |
| $yearCondition = ""; | |
| } | |
| try{ | |
| $sql = "SELECT | |
| s.studentID , | |
| s.student_aadhar_name , | |
| s.studentName , | |
| s.regNo , | |
| s.batchID, | |
| b.batchName , | |
| ssl2.academic_year_code , | |
| ssl2.log , | |
| s.ssp_id , | |
| ct.typeName | |
| FROM | |
| studentaccount s | |
| INNER JOIN batches b ON b.batchID = s.batchID | |
| INNER JOIN course_type ct ON ct.courseTypeID = b.courseTypeID | |
| INNER JOIN ssp_student_log ssl2 ON ssl2.student_id = s.studentID | |
| WHERE 1=1 $batchIdCondition $yearCondition"; | |
| return $this->executeQueryForList($sql); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| return false; | |
| } | |
| } | |
| } |