Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 16 |
CRAP | |
0.00% |
0 / 954 |
| ExamRevaluationService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 16 |
18090.00 | |
0.00% |
0 / 954 |
| __construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 4 |
|||
| saveExamRevaluationFeeForGroup | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 23 |
|||
| deleteExamRevaluationBatchGroup | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 13 |
|||
| getRevaluationRegisterdStudentDetails | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 24 |
|||
| getRevaluationStudentSubjects | |
0.00% |
0 / 1 |
506.00 | |
0.00% |
0 / 88 |
|||
| getStudentsRegisteredSubjectsForRevaluation | |
0.00% |
0 / 1 |
90.00 | |
0.00% |
0 / 112 |
|||
| getAllRevaluationsByParentRegistrations | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 27 |
|||
| saveStudentRevaluationMarks | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 51 |
|||
| getRevaluationReport | |
0.00% |
0 / 1 |
56.00 | |
0.00% |
0 / 57 |
|||
| getRevaluatedStudentDetails | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 100 |
|||
| getRevaluationExamRegistrationCount | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 29 |
|||
| getRevaluationBlankReport | |
0.00% |
0 / 1 |
210.00 | |
0.00% |
0 / 67 |
|||
| getNearestMarks | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 14 |
|||
| getRevaluationReportWithNoImprovementStudent | |
0.00% |
0 / 1 |
870.00 | |
0.00% |
0 / 150 |
|||
| getAllStudentsMarksForRevaluation | |
0.00% |
0 / 1 |
90.00 | |
0.00% |
0 / 116 |
|||
| getRevaluationDigitalValuationReport | |
0.00% |
0 / 1 |
182.00 | |
0.00% |
0 / 79 |
|||
| <?php | |
| namespace com\linways\ec\core\service; | |
| use com\linways\base\util\MakeSingletonTrait; | |
| use com\linways\ec\core\exception\ExamControllerException; | |
| use com\linways\ec\core\mapper\ExamRevaluationServiceMapper; | |
| use com\linways\ec\core\mapper\ExamRegistrationServiceMapper; | |
| use com\linways\core\ams\professional\logging\AMSLogger; | |
| use com\linways\ec\core\logging\Events; | |
| use com\linways\ec\core\logging\entities\Staff; | |
| use com\linways\core\ams\professional\service\CommonService; | |
| use com\linways\ec\core\request\SearchExamRegistrationRequest; | |
| use com\linways\ec\core\service\ExamRegistrationService; | |
| use com\linways\base\util\TwigRenderer; | |
| use com\linways\core\ams\professional\util\PdfUtil; | |
| use com\linways\ec\core\service\GradeSchemeService; | |
| use com\linways\ec\core\service\ExamValuationService; | |
| use com\linways\core\ams\professional\service\StaffService; | |
| use com\linways\core\ams\professional\request\api\GetAllFacultiesRequest; | |
| use com\linways\ec\core\service\RuleService; | |
| use com\linways\ec\core\request\SearchRuleRequest; | |
| use com\linways\core\ams\professional\constant\StatusConstants; | |
| class ExamRevaluationService extends BaseService | |
| { | |
| use MakeSingletonTrait; | |
| private function __construct() { | |
| $this->mapper = ExamRevaluationServiceMapper::getInstance()->getMapper(); | |
| $this->mapper2 = ExamRegistrationServiceMapper::getInstance()->getMapper(); | |
| $this->logger = AMSLogger::getLogger('exam-controller-log'); | |
| } | |
| /** | |
| * Save exam revaluation batch group fee | |
| * @return $id | |
| */ | |
| public function saveExamRevaluationFeeForGroup ( $revaluationFee ) | |
| { | |
| $revaluationFee = $this->realEscapeObject($revaluationFee); | |
| $revaluationFee->createdBy = $GLOBALS['userId'] ?? $revaluationFee->createdBy; | |
| $revaluationFee->updatedBy = $GLOBALS['userId'] ?? $revaluationFee->updatedBy; | |
| $feeObj = new \stdClass(); | |
| $feeObj->revaluationFee = $revaluationFee->revaluationFee; | |
| $feeObj->feeTemplateId = $revaluationFee->feeTemplateId; | |
| $feeObj->paymentMethods = $revaluationFee->paymentMethods; | |
| $feeJson = json_encode($feeObj); | |
| $query = "UPDATE | |
| exam_revaluation_batch_groups | |
| SET | |
| fee_properties = '$feeJson', | |
| updated_by = '$revaluationFee->updatedBy' | |
| WHERE | |
| id = '$revaluationFee->batchGroupId'"; | |
| try{ | |
| $this->executeQuery($query); | |
| }catch(\Exception $e) { | |
| throw new ExamControllerException ($e->getCode(),$e->getMessage()); | |
| } | |
| return $revaluationFee->batchGroupId; | |
| } | |
| /** | |
| * Delete exam revaluation batch group | |
| * @return $id | |
| */ | |
| public function deleteExamRevaluationBatchGroup ( $groupId ) | |
| { | |
| $groupId = $this->realEscapeString($groupId); | |
| $query = "DELETE | |
| FROM | |
| exam_revaluation_batch_groups | |
| WHERE | |
| id = '$groupId'"; | |
| try{ | |
| return $this->executeQuery($query); | |
| }catch(\Exception $e) { | |
| throw new ExamControllerException ($e->getCode(),$e->getMessage()); | |
| } | |
| } | |
| /** | |
| * Get Revaluation Registered Student Details | |
| * @params examRegistrationId | |
| * @return studentList | |
| */ | |
| public function getRevaluationRegisterdStudentDetails($request){ | |
| $request = $this->realEscapeObject($request); | |
| $limitQuerry = "Limit 1"; | |
| $whereQuery = ''; | |
| $query = " SELECT | |
| esar.student_id as studentId, | |
| esar.am_assessment_id as assessmentId | |
| FROM | |
| ec_exam_registration_batch eerb | |
| INNER JOIN ec_exam_registration_subject eers ON | |
| eers.ec_exam_registration_batch_id = eerb.id | |
| INNER JOIN ec_student_assessment_registration esar ON | |
| esar.am_assessment_id = eers.am_assessment_id | |
| INNER JOIN ec_exam_registration eer ON | |
| eer.id = eerb.ec_exam_registration_id AND eer.type = esar.ec_exam_registration_type | |
| INNER JOIN exam_revaluation_batch_groups erbg ON | |
| erbg.ec_exam_revaluation_id = eerb.ec_exam_registration_id AND FIND_IN_SET(eerb.groups_id, erbg.group_ids->'$.groupIds') | |
| WHERE eerb.ec_exam_registration_id = '$request->examRegistrationId' AND erbg.id = '$request->batchGroupId'"; | |
| try { | |
| $studentList = $this->executeQueryForList($query. $whereQuery.$limitQuerry); | |
| } catch (\Exception $e) { | |
| throw new ExamControllerException($e->getCode(),$e->getMessage()); | |
| } | |
| return $studentList; | |
| } | |
| /** | |
| * get Internal Mark Subject List | |
| * @param $searchRequest | |
| * @return $response | |
| */ | |
| public function getRevaluationStudentSubjects($searchRequest) { | |
| $searchRequest = $this->realEscapeObject($searchRequest); | |
| try{ | |
| $response = new \stdClass; | |
| $request = new \stdClass; | |
| $request->revaluationId = $searchRequest->revaluationId; | |
| $request->revaluationType = $searchRequest->revaluationType; | |
| $request->assessmentId = $searchRequest->assessmentId; | |
| $request->assessmentIds = $searchRequest->assessmentIds; | |
| // $request->groupId = $searchRequest->groupId; | |
| $subjectList = []; | |
| $subjects = $this->getStudentsRegisteredSubjectsForRevaluation($request); | |
| // grouping same subject code | |
| foreach($subjects as $subject){ | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->id = $subject->id; | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->academicTermId = $subject->academicTermId; | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->academicTermName = $subject->academicTermName; | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->academicPaperSubjectId = $subject->academicPaperSubjectId; | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->groupId = $subject->groupId; | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->programId = $subject->programId; | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->groupName = $subject->groupName; | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->subjectId = $subject->subjectId; | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->subjectCode = $subject->subjectCode; | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->subjectName = $subject->subjectName; | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->assessmentId = $subject->assessmentId; | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->assessmentIds = $subjectList[$subject->subjectCode.$subject->revaluationType]->assessmentIds ? array_merge($subjectList[$subject->subjectCode.$subject->revaluationType]->assessmentIds, array_column( $subject->assessmentIds, "assessmentId")) : array_column( $subject->assessmentIds, "assessmentId"); | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->revaluationType = $subject->revaluationType; | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->revaluationTypeName = $subject->revaluationTypeName; | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->isInternal = $subject->isInternal; | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->isExternal = $subject->isExternal; | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->externalMaxMark = $subject->externalMaxMark; | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->internalMaxMark = $subject->internalMaxMark; | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->courseTypeId = $subject->courseTypeId; | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->revaluationProperty = $subject->revaluationProperty; | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->valuationRule = $subject->valuationRule; | |
| $subjectList[$subject->subjectCode.$subject->revaluationType]->students = $subjectList[$subject->subjectCode.$subject->revaluationType]->students ? array_merge($subjectList[$subject->subjectCode.$subject->revaluationType]->students,$subject->students) : $subject->students; | |
| } | |
| $subjectList = array_values($subjectList); | |
| foreach($subjectList as $subject){ | |
| $subject->isError = $subject->internalMaxMark ? false : true; | |
| $subject->markEnteredStudentCount = 0; | |
| $subject->revaluationId = $searchRequest->revaluationId; | |
| array_walk($subject->students,function($student,$key) use($subject, $response){ | |
| $student->revaluationMark = $student->revaluationMark ? round($student->revaluationMark, 2) : $student->revaluationMark ; | |
| $student->valuationMark2 = $student->valuationMark2 ? round($student->valuationMark2, 2) : $student->valuationMark2 ; | |
| $student->internalMark = $student->internalMark ? round($student->internalMark, 2) : $student->internalMark ; | |
| $student->valuationMark3 = $student->valuationMark3 ? round($student->valuationMark3, 2) : $student->valuationMark3 ; | |
| $student->externalMark = $student->externalMark ? round($student->externalMark, 2) : $student->externalMark ; | |
| $student->oldRevaluationMark = $student->revaluationMark; | |
| $student->revaluationId = $subject->revaluationId; | |
| if($student->finalizeVal2 && $student->hasEligibleThirdVal){ | |
| $subject->hasThirdValuation = true; | |
| } | |
| if($student->finalizeVal2){ | |
| $subject->hasFinalizedVal2 = true; | |
| } | |
| if($student->finalizeVal3){ | |
| $subject->hasFinalizedVal3 = true; | |
| } | |
| if($student->finalizeRevaluation){ | |
| $subject->hasFinalizedRevaluation = true; | |
| } | |
| }); | |
| $subject->totalStudentCount = count($subject->students); | |
| } | |
| $valuationSettings = CommonService::getInstance()->getSettings("EXAM_REVALUATION", "ENABLE_VALUATION_BASE_MARK_ENTRY_FOR_REVALUATION"); | |
| $valuationSettings = json_decode($valuationSettings); | |
| $response->enableValuation = false; | |
| if($valuationSettings->enableValuation == 1){ | |
| if($valuationSettings->considerAllCourses){ | |
| $response->enableValuation = true; | |
| } | |
| else if(!empty($valuationSettings->courseTypeId)){ | |
| $sampleStudentCourseType = current($subjectList)->courseTypeId; | |
| if(in_array($sampleStudentCourseType, $valuationSettings->courseTypeId)){ | |
| $response->enableValuation = true; | |
| } | |
| } | |
| } | |
| if( reset($subjectList)->courseTypeId ){ | |
| $markDiffDetails = ExamValuationService::getInstance()->getExternalValuationMarkDifference(reset($subjectList)->courseTypeId); | |
| $markDiff = $markDiffDetails->markDiff; | |
| } | |
| $response->subjectList = $subjectList; | |
| $response->thirdValuationMargin = (integer)$markDiff; | |
| $response->scheme = $markDiffDetails->scheme; | |
| } | |
| catch (\Exception $e){ | |
| throw new ExamControllerException($e->getCode(),$e->getMessage()); | |
| } | |
| return $response; | |
| } | |
| /** | |
| * get Assigned Subject Students Details For Internal Mark Entry | |
| * @param $searchRequest | |
| * @return $subjectWiseInternalMarkDetails | |
| */ | |
| public function getStudentsRegisteredSubjectsForRevaluation($searchRequest) { | |
| $searchRequest = $this->realEscapeObject($searchRequest); | |
| try | |
| { | |
| $orderBy = " ORDER BY s.name ASC , sa.regNo ASC"; | |
| $whereQuery = ""; | |
| if(!empty($searchRequest->revaluationId)) { | |
| $whereQuery .= " AND eer.id IN ( '$searchRequest->revaluationId' )"; | |
| } | |
| if(!empty($searchRequest->revaluationType)) { | |
| $whereQuery .= " AND esar.identifying_context->>'$.revaluationType' IN ( '$searchRequest->revaluationType' )"; | |
| } | |
| if(!empty($searchRequest->studentId)) { | |
| $whereQuery .= " AND esar.student_id IN ( '$searchRequest->studentId' )"; | |
| } | |
| if(!empty($searchRequest->assessmentId)) { | |
| $whereQuery .= " AND esar.am_assessment_id IN ( '$searchRequest->assessmentId' )"; | |
| } | |
| if(!empty($searchRequest->assessmentIds)) { | |
| $assessmentIdsString = is_array($searchRequest->assessmentIds) ? "'" . implode("','",$searchRequest->assessmentIds) . "'" : "'".$searchRequest->assessmentIds."'"; | |
| $whereQuery .= " AND esar.am_assessment_id IN ( $assessmentIdsString )"; | |
| } | |
| if(!empty($searchRequest->orderByHighestMark)){ | |
| $orderBy = " ORDER BY ostm.mark_obtained DESC"; | |
| } | |
| $query = "SELECT | |
| g.id AS groupId, | |
| g.name AS groupName, | |
| g.properties ->>'$.programId' AS programId, | |
| caps.id AS academicPaperSubjectId, | |
| caps.properties ->> '$.isInternal' as isInternal, | |
| caps.properties ->> '$.isExternal' as isExternal, | |
| caps.properties ->> '$.externalMaxMark' as externalMaxMark, | |
| caps.properties ->> '$.internalMaxMark' as internalMaxMark, | |
| s.id AS subjectId, | |
| s.code AS subjectCode, | |
| s.name AS subjectName, | |
| spa.student_id AS studentId, | |
| sa.studentName AS studentName, | |
| spa.properties->>'$.rollNumber' AS studentRollNo, | |
| spa.properties->>'$.registerNumber' AS studentRegisterNo, | |
| p.course_type_id as courseTypeId, | |
| esar.am_assessment_id AS assessmentId, | |
| oe.id AS oeExamId, | |
| esar.identifying_context->>'$.revaluationType' AS revaluationType, | |
| CONCAT( caps.id, CAST(esar.identifying_context->>'$.revaluationType'AS CHAR) ) as revalPaperSubjectId, | |
| ef.examFeesName AS revaluationTypeName, | |
| im.internal_mark AS internalMark, | |
| erm.mark_obtained AS revaluationMark, | |
| erm2.mark_obtained AS valuationMark2, | |
| erm3.mark_obtained AS valuationMark3, | |
| ostm2.attendance_status AS isAbsent, | |
| ostm2.mark_obtained AS externalMark, | |
| erm2.properties ->> '$.finalizedMark' as finalizeVal2, | |
| erm3.properties ->> '$.finalizedMark' as finalizeVal3, | |
| erm.properties ->> '$.finalizedMark' as finalizeRevaluation, | |
| erm2.properties ->> '$.hasEligibleThirdValuation' as hasEligibleThirdVal, | |
| eer.properties as revaluationProperty, | |
| eerb.properties ->> '$.valuationRule' as valuationRule | |
| FROM | |
| ec_student_assessment_registration esar | |
| INNER JOIN ec_exam_registration eer ON | |
| eer.`type` = esar.ec_exam_registration_type AND eer.id = CAST(esar.identifying_context->>'$.examRegistrationId' AS CHAR) | |
| INNER JOIN ec_exam_registration_batch eerb ON | |
| eerb.ec_exam_registration_id = eer.id | |
| INNER JOIN ec_exam_registration eer2 ON | |
| eer2.id = eer.properties->>'$.parentExamRegistrationId' AND | |
| eer2.trashed IS NULL | |
| INNER JOIN ec_exam_registration_batch eerbParent ON | |
| eerbParent.ec_exam_registration_id = eer2.id AND | |
| eerb.groups_id = eerbParent.groups_id | |
| INNER JOIN ec_exam_registration_subject eers2 ON | |
| eers2.ec_exam_registration_batch_id = eerbParent.id | |
| INNER JOIN cm_academic_paper_subjects caps ON | |
| caps.id = eers2.cm_academic_paper_subjects_id AND eers2.am_assessment_id = esar.am_assessment_id | |
| INNER JOIN oe_exams oe ON | |
| oe.assessment_id = esar.am_assessment_id AND oe.is_deleted = 0 | |
| INNER JOIN v4_ams_subject s ON | |
| s.id = caps.ams_subject_id | |
| INNER JOIN `groups` g ON | |
| g.id = eerb.groups_id | |
| AND g.`type` = 'BATCH' | |
| INNER JOIN department d ON | |
| d.deptID = g.properties ->> '$.departmentId' | |
| INNER JOIN studentaccount sa ON | |
| sa.studentID = esar.student_id | |
| INNER JOIN program p ON | |
| p.id = g.properties->>'$.programId' | |
| INNER JOIN student_program_account spa ON | |
| spa.current_program_id = p.id AND | |
| spa.student_id = esar.student_id | |
| INNER JOIN exam_feestype ef ON | |
| ef.examfeesID = CAST(esar.identifying_context->>'$.revaluationType' AS CHAR) | |
| LEFT JOIN ec_internal_marks im ON | |
| im.groups_id = eerb.groups_id AND | |
| im.academic_paper_subjects_id = caps.id AND | |
| im.academic_term_id = CAST(eerb.properties ->> '$.academicTermId' AS CHAR) AND im.student_id = sa.studentID | |
| LEFT JOIN ec_revaluation_mark erm ON | |
| erm.student_id = sa.studentID AND erm.am_assessment_id = esar.am_assessment_id AND erm.revaluation_type = CAST(esar.identifying_context->>'$.revaluationType'AS CHAR) AND erm.valuation_count = 'FINALIZED' | |
| LEFT JOIN ec_revaluation_mark erm2 ON | |
| erm2.student_id = sa.studentID AND erm2.am_assessment_id = esar.am_assessment_id AND erm2.revaluation_type = CAST(esar.identifying_context->>'$.revaluationType'AS CHAR) AND erm2.valuation_count = '2' | |
| LEFT JOIN ec_revaluation_mark erm3 ON | |
| erm3.student_id = sa.studentID AND erm3.am_assessment_id = esar.am_assessment_id AND erm3.revaluation_type = CAST(esar.identifying_context->>'$.revaluationType'AS CHAR) AND erm3.valuation_count = '3' | |
| LEFT JOIN oe_student_total_mark ostm2 ON | |
| ostm2.student_id = sa.studentID AND ostm2.am_assessment_id = esar.am_assessment_id AND (ostm2.valuation_type IS NULL OR ostm2.valuation_type = '') AND ostm2.valuation_count = 'FINALIZED' | |
| WHERE eer.type = 'REVALUATION' AND esar.properties ->>'$.feeStatus' = 'PAID' AND esar.properties ->>'$.registrationStatus' = 'REGISTERED' AND eer.trashed IS NULL "; | |
| $subjectWiseMarkDetails = $this->executeQueryForList($query.$whereQuery.$orderBy, $this->mapper[ExamRevaluationServiceMapper::GET_REVALUATION_STUDENT_SUBJETCS]); | |
| } | |
| catch (\Exception $e){ | |
| throw new ExamControllerException($e->getCode(),$e->getMessage()); | |
| } | |
| return $subjectWiseMarkDetails; | |
| } | |
| /** | |
| * Get ALl Revaluation By Parent Registration | |
| * @params examRegistrationId | |
| * @return studentList | |
| */ | |
| public function getAllRevaluationsByParentRegistrations($request){ | |
| $request = $this->realEscapeObject($request); | |
| $whereQuery = ""; | |
| if(!empty($request->revaluationId)) { | |
| $whereQuery .= " AND eer.id NOT IN ( '$request->revaluationId' )"; | |
| } | |
| if(!empty($request->examRegistrationId)) { | |
| $whereQuery .= " AND eer.properties->>'$.parentExamRegistrationId' IN ( '$request->examRegistrationId' )"; | |
| } | |
| $query = " SELECT | |
| eer.id, | |
| eer.identifying_context, | |
| eer.name, | |
| eer.type, | |
| eer.properties, | |
| eer.fees_properties, | |
| eer.trashed | |
| FROM | |
| ec_exam_registration eer | |
| WHERE | |
| eer.type = 'REVALUATION' AND eer.trashed IS NULL"; | |
| try { | |
| $registrations = $this->executeQueryForList($query. $whereQuery,$this->mapper2[ExamRegistrationServiceMapper::SEARCH_CURRENT_EXAM_REVALUATION]); | |
| } catch (\Exception $e) { | |
| throw new ExamControllerException($e->getCode(),$e->getMessage()); | |
| } | |
| return $registrations; | |
| } | |
| /** | |
| * Save online exam users' total mark | |
| * @param ObjectArray $examUserMarks | |
| * @return Boolean true | |
| * @throws OnlineExamException | |
| * @author Vishnu M | |
| */ | |
| public function saveStudentRevaluationMarks ($revaluationMarks) { | |
| $revaluationMarks = $this->realEscapeArray($revaluationMarks); | |
| $values = []; | |
| if ( empty ( $revaluationMarks ) ) { | |
| throw new ExamControllerException (ExamControllerException::EMPTY_PARAMETERS, "Empty Parameters! Please specify marks to save"); | |
| } | |
| foreach ( $revaluationMarks as $revaluationMark ) { | |
| $revaluationMark->properties = $revaluationMark->properties ? json_encode($revaluationMark->properties) : "{}"; | |
| $values[] = "( | |
| '$revaluationMark->studentId', | |
| '$revaluationMark->revaluationId', | |
| '$revaluationMark->assessmentId', | |
| '$revaluationMark->revaluationType', | |
| '$revaluationMark->valuationCount', | |
| '$revaluationMark->markObtained', | |
| '$revaluationMark->properties', | |
| '$revaluationMark->createdBy' | |
| )"; | |
| $staffId = $revaluationMark->createdBy; | |
| } | |
| try { | |
| $sql = "INSERT INTO `ec_revaluation_mark` ( | |
| `student_id`, | |
| `ec_exam_registration_id`, | |
| `am_assessment_id`, | |
| `revaluation_type`, | |
| `valuation_count`, | |
| `mark_obtained`, | |
| `properties`, | |
| `created_by` | |
| ) VALUES " . implode(', ', $values). " ON DUPLICATE KEY UPDATE | |
| `mark_obtained` = VALUES(mark_obtained), | |
| `properties` = VALUES(properties), | |
| `updated_by` = VALUES(created_by)"; | |
| $this->executeQuery($sql); | |
| AMSLogger::log_info($this->logger,Events::EC_SAVE_REVALUATION_MARK, [ | |
| "staff" => new Staff(["id" => $staffId]), | |
| "request" => $revaluationMarks, | |
| "status" => StatusConstants::SUCCESS | |
| ]); | |
| } catch (\Exception $e) { | |
| AMSLogger::log_error($this->logger,Events::EC_SAVE_REVALUATION_MARK, [ | |
| "staff" => new Staff(["id" => $staffId]), | |
| "request" => $revaluationMarks, | |
| "errorCode" => $e->getCode(), | |
| "errorMessage" => $e->getMessage(), | |
| "status" => StatusConstants::FAILED | |
| ]); | |
| throw new ExamControllerException ($e->getCode(), $e->getMessage()); | |
| } | |
| return true; | |
| } | |
| /** | |
| * Get Revaluation Report | |
| * @param $searchRequest | |
| * @return $programResult | |
| */ | |
| public function getRevaluationReport($searchRequest) { | |
| $searchRequest = $this->realEscapeObject($searchRequest); | |
| $request = new \stdClass; | |
| $request->revaluationId = $searchRequest->revaluationId; | |
| $request->revaluationType = $searchRequest->revaluationType; | |
| $resultData = new \stdClass; | |
| $templateName = "revaluation-report-template-1"; | |
| if(empty($request->revaluationId)){ | |
| throw new ExamControllerException(ExamControllerException::EMPTY_PARAMETERS,"Invailed Request"); | |
| } | |
| $requestForExamRegistration = new SearchExamRegistrationRequest; | |
| $requestForExamRegistration->id = $request->revaluationId; | |
| $examRegistration = reset(ExamRegistrationService::getInstance()->searchExamRegistration($requestForExamRegistration)); | |
| $resultData = $this->getRevaluatedStudentDetails($request); | |
| $collegeData = CommonExamService::getInstance()->getCollegeDetails(); | |
| $searchRuleRequest = new SearchRuleRequest; | |
| $searchRuleRequest->name = "REVALUATION_SETTINGS_RULE"; | |
| $revaluationRule = reset(RuleService::getInstance()->searchRule($searchRuleRequest))->rule; | |
| $settings = new \stdClass; | |
| $settings->enableFalseNo = 0; | |
| $settings->hideEmailAndType = 0; | |
| $settings->displayMaxMark = 0; | |
| $settings->displayAllValuationMarks = 0; | |
| $settings->enableRevaluationMark = 1; | |
| $settings->displayExamRegName = 1; | |
| if($revaluationRule->revaluationReportSettings){ | |
| $settings->enablePacketNo = $revaluationRule->revaluationReportSettings->enablePacketNo ? 1 : 0; | |
| $settings->enableFalseNo = $revaluationRule->revaluationReportSettings->enableFalseNo ? 1 : 0; | |
| $settings->enableRevaluationMark = $revaluationRule->revaluationReportSettings->enableRevaluationMark ? 1 : 0; | |
| } | |
| if(empty($resultData)){ | |
| throw new ExamControllerException(ExamControllerException::NO_REPORTS_DETAILS_FOUND,"No details found."); | |
| } | |
| $responseHtml = TwigRenderer::renderTemplateFileToHtml(realpath(DOCUMENT_ROOT."../examcontroller-api/src/com/linways/web/templates/revaluationReport/$templateName.twig"), [ 'students'=>$resultData,'college'=>$collegeData,'examRegistration'=>$examRegistration,'settings'=>$settings]); | |
| $prtContent = NULL; | |
| $prtContent .= '<html><head>'; | |
| $prtContent .= "<style> | |
| </style>"; | |
| $prtContent .= '</head><title>Moderation Report</title><body>'; | |
| $prtContent .= $responseHtml; | |
| $prtContent .= '</body></html>'; | |
| $totalWidth = 297; | |
| $totalHeight = 210; | |
| $options = array( | |
| 'page-width' => $totalWidth."mm", | |
| 'page-height' => $totalHeight."mm", | |
| 'dpi' => 96, | |
| 'margin-top' => "9mm", | |
| 'margin-left' => "1mm", | |
| 'margin-right' => "1mm", | |
| 'margin-bottom' => "9mm", | |
| // 'binary' => "/usr/local/bin/wkhtmltopdf", // For Mac | |
| 'user-style-sheet' => realpath(DOCUMENT_ROOT . "/libcommon/bootstrap/css/bootstrap.min.css") | |
| ); | |
| $programResult = new \stdClass; | |
| $programResult->dispalyHtmlData = $responseHtml; | |
| $programResult->printData = PdfUtil::renderPdf($prtContent, $options); | |
| return $programResult; | |
| } | |
| /** | |
| * get Revaluated Student Details | |
| * @param $searchRequest | |
| * @return $subjectWiseInternalMarkDetails | |
| */ | |
| public function getRevaluatedStudentDetails($searchRequest) { | |
| $searchRequest = $this->realEscapeObject($searchRequest); | |
| try | |
| { | |
| $orderBy = " ORDER BY s.name ASC , spa.properties->>'$.registerNumber' ASC"; | |
| $whereQuery = ""; | |
| if(!empty($searchRequest->revaluationId)) { | |
| $whereQuery .= " AND eer.id IN ( '$searchRequest->revaluationId' )"; | |
| } | |
| if(!empty($searchRequest->revaluationType)) { | |
| $whereQuery .= " AND esar.identifying_context->>'$.revaluationType' IN ( '$searchRequest->revaluationType' )"; | |
| } | |
| if(!empty($searchRequest->academicPaperSubjectId)) { | |
| $academicPaperSubjectIdString = is_array($searchRequest->academicPaperSubjectId) ? "'" . implode("','",$searchRequest->academicPaperSubjectId) . "'" : "'".$searchRequest->academicPaperSubjectId."'"; | |
| $whereQuery .= " AND caps.id IN ( $academicPaperSubjectIdString )"; | |
| } | |
| $query = "SELECT | |
| g.id AS groupId, | |
| g.name AS groupName, | |
| caps.id AS academicPaperSubjectId, | |
| caps.properties ->> '$.isInternal' as isInternal, | |
| caps.properties ->> '$.isExternal' as isExternal, | |
| caps.properties ->> '$.externalMaxMark' as externalMaxMark, | |
| caps.properties ->> '$.internalMaxMark' as internalMaxMark, | |
| s.id AS subjectId, | |
| s.code AS subjectCode, | |
| s.name AS subjectName, | |
| spa.student_id AS studentId, | |
| sa.studentName AS studentName, | |
| sa.studentEmail AS studentEmail, | |
| spa.properties->>'$.rollNumber' AS studentRollNo, | |
| spa.properties->>'$.registerNumber' AS studentRegisterNo, | |
| esar.am_assessment_id AS assessmentId, | |
| esarparent.properties->>'$.falseNo' AS falseNo, | |
| oe.id AS oeExamId, | |
| esar.identifying_context->>'$.revaluationType' AS revaluationType, | |
| CONCAT( caps.id, CAST(esar.identifying_context->>'$.revaluationType'AS CHAR) ) as revalPaperSubjectId, | |
| ef.examFeesName AS revaluationTypeName, | |
| im.internal_mark AS internalMark, | |
| erm.mark_obtained AS revaluationMark, | |
| erm2.mark_obtained AS mark2, | |
| erm3.mark_obtained AS mark3, | |
| ostm2.attendance_status AS isAbsent, | |
| ostm2.mark_obtained AS externalMark, | |
| erm.properties ->> '$.finalizedMark' as finalizeRevaluation | |
| FROM | |
| ec_student_assessment_registration esar | |
| INNER JOIN ec_exam_registration eer ON | |
| eer.`type` = esar.ec_exam_registration_type AND eer.id = CAST(esar.identifying_context->>'$.examRegistrationId' AS CHAR) | |
| INNER JOIN ec_exam_registration_batch eerb ON | |
| eerb.ec_exam_registration_id = eer.id | |
| INNER JOIN ec_exam_registration eer2 ON | |
| eer2.id = eer.properties->>'$.parentExamRegistrationId' AND | |
| eer2.trashed IS NULL | |
| INNER JOIN ec_exam_registration_batch eerbParent ON | |
| eerbParent.ec_exam_registration_id = eer2.id AND | |
| eerb.groups_id = eerbParent.groups_id | |
| INNER JOIN ec_exam_registration_subject eers2 ON | |
| eers2.ec_exam_registration_batch_id = eerbParent.id | |
| INNER JOIN cm_academic_paper_subjects caps ON | |
| caps.id = eers2.cm_academic_paper_subjects_id AND eers2.am_assessment_id = esar.am_assessment_id | |
| INNER JOIN oe_exams oe ON | |
| oe.assessment_id = esar.am_assessment_id AND oe.is_deleted = 0 | |
| INNER JOIN v4_ams_subject s ON | |
| s.id = caps.ams_subject_id | |
| INNER JOIN `groups` g ON | |
| g.id = eerb.groups_id | |
| AND g.`type` = 'BATCH' | |
| INNER JOIN studentaccount sa ON | |
| sa.studentID = esar.student_id | |
| INNER JOIN program p ON | |
| p.id = g.properties->>'$.programId' | |
| INNER JOIN student_program_account spa ON | |
| spa.current_program_id = p.id AND | |
| spa.student_id = esar.student_id | |
| INNER JOIN exam_feestype ef ON | |
| ef.examfeesID = CAST(esar.identifying_context->>'$.revaluationType' AS CHAR) | |
| LEFT JOIN ec_internal_marks im ON | |
| im.groups_id = eerb.groups_id AND | |
| im.academic_paper_subjects_id = caps.id AND | |
| im.academic_term_id = CAST(eerb.properties ->> '$.academicTermId' AS CHAR) AND im.student_id = sa.studentID | |
| LEFT JOIN ec_revaluation_mark erm ON | |
| erm.student_id = sa.studentID AND erm.am_assessment_id = esar.am_assessment_id AND erm.revaluation_type = CAST(esar.identifying_context->>'$.revaluationType'AS CHAR) AND erm.valuation_count = 'FINALIZED' | |
| LEFT JOIN ec_revaluation_mark erm2 ON | |
| erm2.student_id = sa.studentID AND erm2.am_assessment_id = esar.am_assessment_id AND erm2.revaluation_type = CAST(esar.identifying_context->>'$.revaluationType'AS CHAR) AND erm2.valuation_count = '2' | |
| LEFT JOIN ec_revaluation_mark erm3 ON | |
| erm3.student_id = sa.studentID AND erm3.am_assessment_id = esar.am_assessment_id AND erm3.revaluation_type = CAST(esar.identifying_context->>'$.revaluationType'AS CHAR) AND erm3.valuation_count = '3' | |
| LEFT JOIN oe_student_total_mark ostm2 ON | |
| ostm2.student_id = sa.studentID AND ostm2.am_assessment_id = esar.am_assessment_id AND (ostm2.valuation_type IS NULL OR ostm2.valuation_type = '') AND ostm2.valuation_count = 'FINALIZED' | |
| INNER JOIN ec_student_assessment_registration esarparent ON | |
| esarparent.student_id = esar.student_id AND | |
| esarparent.am_assessment_id = esar.am_assessment_id AND | |
| esarparent.ec_exam_registration_type = eer2.type | |
| WHERE eer.type = 'REVALUATION' AND esar.properties ->>'$.feeStatus' = 'PAID' AND esar.properties ->>'$.registrationStatus' = 'REGISTERED' AND eer.trashed IS NULL "; | |
| $revaluatedStudentDetails = $this->executeQueryForList($query.$whereQuery.$orderBy); | |
| } | |
| catch (\Exception $e){ | |
| throw new ExamControllerException($e->getCode(),$e->getMessage()); | |
| } | |
| return $revaluatedStudentDetails; | |
| } | |
| /** | |
| * Get all exam registation count | |
| * Features : Dashboard | |
| */ | |
| public function getRevaluationExamRegistrationCount($request) | |
| { | |
| $request = $this->realEscapeObject($request); | |
| try { | |
| $sql = "SELECT | |
| eer.id, | |
| eer.name, | |
| MIN(erbg.startDate) AS startDate, | |
| MAX(erbg.endDate) AS endDate, | |
| eer.properties | |
| FROM | |
| ec_exam_registration eer | |
| INNER JOIN exam_revaluation_batch_groups erbg ON | |
| erbg.ec_exam_revaluation_id = eer.id | |
| WHERE | |
| `type` = '$request->examType' AND trashed IS NULL GROUP BY eer.id"; | |
| $examRegistrationList = $this->executeQueryForList($sql); | |
| $examRegistrationDetails = new \stdClass; | |
| $examRegistrationDetails->totalCount = count($examRegistrationList); | |
| $today = date("Y-m-d H:i"); | |
| foreach ($examRegistrationList as $examRegistrationDetail ){ | |
| if((strtotime($today) <= strtotime($examRegistrationDetail->endDate)) && (strtotime($today) >= strtotime($examRegistrationDetail->startDate))){ | |
| $examRegistrationDetails->onGoingCount++; | |
| } | |
| } | |
| } catch (\Exception $e) { | |
| throw new ExamControllerException($e->getCode(),$e->getMessage()); | |
| } | |
| return $examRegistrationDetails; | |
| } | |
| /** | |
| * Get Revaluation Blank Report | |
| * @param $searchRequest | |
| * @return $programResult | |
| */ | |
| public function getRevaluationBlankReport($searchRequest) { | |
| $searchRequest = $this->realEscapeObject($searchRequest); | |
| $request = new \stdClass; | |
| $request->revaluationId = $searchRequest->revaluationId; | |
| $request->academicPaperSubjectId = $searchRequest->academicPaperSubjectId; | |
| $additionalInfo = new \stdClass; | |
| $subjects = []; | |
| $resultData = new \stdClass; | |
| $templateName = "revaluation-blank-report-template-1"; | |
| if(empty($request->revaluationId)){ | |
| throw new ExamControllerException(ExamControllerException::EMPTY_PARAMETERS,"Invailed Request"); | |
| } | |
| $revaluatedStudents = $this->getRevaluatedStudentDetails($request); | |
| if(empty($revaluatedStudents)){ | |
| throw new ExamControllerException(ExamControllerException::NO_REPORTS_DETAILS_FOUND,"No students found."); | |
| } | |
| foreach($revaluatedStudents as $student){ | |
| $subjects[$student->subjectId]->id = $student->subjectId; | |
| $subjects[$student->subjectId]->subjectCode = $student->subjectCode; | |
| $subjects[$student->subjectId]->subjectName = $student->subjectName; | |
| $student->mark1 = $student->externalMark ? round($student->externalMark) :""; | |
| $student->mark2 = $student->mark2 ? round($student->mark2) :""; | |
| $student->mark3 = $student->mark3 ? round($student->mark3) :""; | |
| if($student->mark1 && $student->mark2 && $student->mark3){ | |
| $student->nearestMarks = $this->getNearestMarks($student); | |
| if($student->nearestMarks){ | |
| if(in_array($student->mark1,$student->nearestMarks)){ | |
| $student->considerMark1 = true; | |
| } | |
| if(in_array($student->mark2,$student->nearestMarks)){ | |
| $student->considerMark2 = true; | |
| } | |
| if(in_array($student->mark3,$student->nearestMarks)){ | |
| $student->considerMark3 = true; | |
| } | |
| } | |
| } | |
| $subjects[$student->subjectId]->students[] = $student; | |
| } | |
| $requestForExamRegistration = new SearchExamRegistrationRequest; | |
| $requestForExamRegistration->id = $request->revaluationId; | |
| $additionalInfo->examRegistration = reset(ExamRegistrationService::getInstance()->searchExamRegistration($requestForExamRegistration)); | |
| $additionalInfo->collegeData = CommonExamService::getInstance()->getCollegeDetails(); | |
| $responseHtml = TwigRenderer::renderTemplateFileToHtml(realpath(DOCUMENT_ROOT."../examcontroller-api/src/com/linways/web/templates/revaluationReport/$templateName.twig"), [ 'subjects'=>$subjects,'additionalInfo'=>$additionalInfo]); | |
| $prtContent = NULL; | |
| $prtContent .= '<html><head>'; | |
| $prtContent .= "<style> | |
| </style>"; | |
| $prtContent .= '</head><title>Moderation Report</title><body>'; | |
| $prtContent .= $responseHtml; | |
| $prtContent .= '</body></html>'; | |
| $totalWidth = 210; | |
| $totalHeight = 297; | |
| $options = array( | |
| 'page-width' => $totalWidth."mm", | |
| 'page-height' => $totalHeight."mm", | |
| 'dpi' => 96, | |
| 'margin-top' => "9mm", | |
| 'margin-left' => "1mm", | |
| 'margin-right' => "1mm", | |
| 'margin-bottom' => "9mm", | |
| // 'binary' => "/usr/local/bin/wkhtmltopdf", // For Mac | |
| 'user-style-sheet' => realpath(DOCUMENT_ROOT . "/libcommon/bootstrap/css/bootstrap.min.css") | |
| ); | |
| $programResult = new \stdClass; | |
| $programResult->dispalyHtmlData = $responseHtml; | |
| $programResult->printData = PdfUtil::renderPdf($prtContent, $options); | |
| return $programResult; | |
| } | |
| function getNearestMarks($student){ | |
| $arr = [$student->mark1, $student->mark2, $student->mark3]; | |
| $keys = array_keys($arr); | |
| $nearest = max($arr) - min($arr) + 1; | |
| $result = []; | |
| for ($key = 0, $length = count($arr); $key < $length; $key++) { | |
| for ($innerKey = $key + 1; $innerKey < $length; $innerKey++) { | |
| if (($diff = abs($arr[$keys[$key]] - $arr[$keys[$innerKey]])) < $nearest) { | |
| $result = [$arr[$keys[$key]], $arr[$keys[$innerKey]]]; | |
| $nearest = $diff; | |
| } | |
| } | |
| } | |
| return $result; | |
| } | |
| /** | |
| * Get Revaluation Report | |
| * @param $searchRequest | |
| * @return $programResult | |
| */ | |
| public function getRevaluationReportWithNoImprovementStudent($searchRequest) { | |
| $searchRequest = $this->realEscapeObject($searchRequest); | |
| $request = new \stdClass; | |
| $request->examRevaluationId = $searchRequest->revaluationId; | |
| $request->academicPaperSubjectIds = $searchRequest->academicPaperSubjectId; | |
| $request->groupId = $searchRequest->groupId; | |
| $request->isShowStudentWithNoImprovement = $searchRequest->isShowStudentWithNoImprovement == 'true' ? true : false; | |
| $resultData = new \stdClass; | |
| $templateName = "revaluation-report-template-2"; | |
| if(empty($request->examRevaluationId)){ | |
| throw new ExamControllerException(ExamControllerException::EMPTY_PARAMETERS,"Invailed Request"); | |
| } | |
| $requestForExamRegistration = new SearchExamRegistrationRequest; | |
| $requestForExamRegistration->id = $request->examRevaluationId; | |
| $examRegistration = reset(ExamRegistrationService::getInstance()->searchExamRegistration($requestForExamRegistration)); | |
| $request->currentRevaluationType = reset($examRegistration->properties->revaluationFeeTypeIds); | |
| $studentSubjects = []; | |
| $students = $this->getAllStudentsMarksForRevaluation($request); | |
| if(empty($students)){ | |
| throw new ExamControllerException(ExamControllerException::EMPTY_PARAMETERS,"No Students."); | |
| } | |
| if(!empty($examRegistration->properties->parentRevaluationRegistrationIds)){ | |
| $parentRequest = new \stdClass; | |
| $requestForParentExamRegistration = new SearchExamRegistrationRequest; | |
| $requestForParentExamRegistration->id = reset($examRegistration->properties->parentRevaluationRegistrationIds); | |
| $parentExamRegistration = reset(ExamRegistrationService::getInstance()->searchExamRegistration($requestForParentExamRegistration)); | |
| $parentRequest->currentRevaluationType = reset($parentExamRegistration->properties->revaluationFeeTypeIds); | |
| $parentRequest->examRevaluationId = $parentExamRegistration->id; | |
| $parentRequest->academicPaperSubjectIds = $searchRequest->academicPaperSubjectId; | |
| $parentRequest->groupId = $searchRequest->groupId; | |
| $parentRevaluatedStudents = $this->getAllStudentsMarksForRevaluation($parentRequest); | |
| } | |
| foreach($students as $student){ | |
| $studentSubjects[$student->subjectId]->id = $student->subjectId; | |
| $studentSubjects[$student->subjectId]->name = $student->subjectName; | |
| $studentSubjects[$student->subjectId]->code = $student->subjectCode; | |
| $studentSubjects[$student->subjectId]->students[$student->id]->id = $student->id; | |
| $studentSubjects[$student->subjectId]->students[$student->id]->name = $student->studentName; | |
| $studentSubjects[$student->subjectId]->students[$student->id]->regNo = $student->regNo; | |
| $studentSubjects[$student->subjectId]->students[$student->id]->falseNo = $student->falseNo; | |
| $studentSubjects[$student->subjectId]->students[$student->id]->groupName = $student->groupName; | |
| $studentSubjects[$student->subjectId]->students[$student->id]->internalMark = $student->internalMark; | |
| if(empty($examRegistration->properties->parentRevaluationRegistrationIds)){ | |
| $studentSubjects[$student->subjectId]->students[$student->id]->oldMark = $student->parentExamMark + 0; | |
| } | |
| else{ | |
| foreach($parentRevaluatedStudents as $parentRevaluatedStudent){ | |
| if($parentRevaluatedStudent->subjectId == $student->subjectId && $student->id == $parentRevaluatedStudent->id){ | |
| $studentSubjects[$student->subjectId]->students[$student->id]->oldMark = $parentRevaluatedStudent->parentExamMark > $parentRevaluatedStudent->revaluationMark ? $parentRevaluatedStudent->parentExamMark : $parentRevaluatedStudent->revaluationMark; | |
| } | |
| } | |
| } | |
| $studentSubjects[$student->subjectId]->students[$student->id]->isThirdValMark = $student->thirdValReq =='1' ? true : false; | |
| $studentSubjects[$student->subjectId]->students[$student->id]->finalizedMark = $studentSubjects[$student->subjectId]->students[$student->id]->oldMark >= $student->revaluationMark + 0 ? null : $student->revaluationMark + 0; | |
| $studentSubjects[$student->subjectId]->students[$student->id]->totalMark = $studentSubjects[$student->subjectId]->students[$student->id]->finalizedMark ? $student->internalMark + $studentSubjects[$student->subjectId]->students[$student->id]->finalizedMark : $studentSubjects[$student->subjectId]->students[$student->id]->oldMark + $student->internalMark; | |
| $studentSubjects[$student->subjectId]->students[$student->id]->isActiveStudent = true; | |
| if(($studentSubjects[$student->subjectId]->students[$student->id]->finalizedMark > $studentSubjects[$student->subjectId]->students[$student->id]->oldMark)){ | |
| $studentSubjects[$student->subjectId]->students[$student->id]->isActiveStudent = false; | |
| } | |
| if($studentSubjects[$student->subjectId]->students[$student->id]->isActiveStudent && !$request->isShowStudentWithNoImprovement){ | |
| $studentSubjects[$student->subjectId]->students[$student->id]->isThirdValMark = false; | |
| } | |
| if($request->isShowStudentWithNoImprovement){ | |
| $studentSubjects[$student->subjectId]->students[$student->id]->finalizedMark = $student->revaluationMark + 0; | |
| } | |
| $searchRequestForGradeScheme = new \stdClass(); | |
| $searchRequestForGradeScheme->groupId = $student->groupId; | |
| $searchRequestForGradeScheme->academicTermId = $student->academicTermId; | |
| $searchRequestForGradeScheme->academicPaperSubjectId = $student->academicPaperSubjectId; | |
| $subjectGradeSchemeArray = GradeSchemeService::getInstance()->getAllSubjectGradeSchemesByRequest($searchRequestForGradeScheme); | |
| $subjectGradeKey = array_search($student->academicPaperSubjectId, array_column( $subjectGradeSchemeArray, "id")); | |
| $gradeDetails = []; | |
| if($subjectGradeKey || $subjectGradeKey === 0){ | |
| $gradeDetails = $subjectGradeSchemeArray[$subjectGradeKey]->grades; | |
| } | |
| $maxGradePercent = max(array_column($gradeDetails,"rangeTo")); | |
| $schemeType = "PERCENTAGE"; | |
| $passCriteriaArray[$student->academicTermId] = GradeSchemeService::getInstance()->getSubjectPassCriteriaByAcademicPaperSubject($student->academicTermId, $schemeType); | |
| $checkPassPercentCriteria = new \stdClass(); | |
| $checkPassPercentCriteria->courseTypeMethod = $student->courseTypeMethod; | |
| $checkPassPercentCriteria->schemeType = $subjectGradeSchemeArray[$subjectGradeKey]->schemeType ? $subjectGradeSchemeArray[$subjectGradeKey]->schemeType : "PERCENTAGE"; | |
| $checkPassPercentCriteria->isInternal = $student->isInternal; | |
| $checkPassPercentCriteria->internalMaxMark = $student->internalMaxMark; | |
| $checkPassPercentCriteria->isExternal = $student->isExternal; | |
| $checkPassPercentCriteria->externalMaxMark = $student->externalMaxMark; | |
| $checkPassPercentCriteria->internalMark = round($student->internalMark, 2 ); | |
| $checkPassPercentCriteria->passPercentConfig = $passCriteriaArray[$student->academicTermId]; | |
| $checkPassPercentCriteria->externalMark = round ( $studentSubjects[$student->subjectId]->students[$student->id]->oldMark, 2 ); | |
| $checkPassPercentCriteria->maxGradePercent = $maxGradePercent; | |
| $checkPassPercentCriteria->gradeDetails = $gradeDetails; | |
| $subjectPassCriteriaOld = CommonExamService::getInstance()->checkIsFailedByPassPercentCreditCriteria ( $checkPassPercentCriteria ); | |
| $studentSubjects[$student->subjectId]->students[$student->id]->oldGrade = $subjectPassCriteriaOld->grade->letterGrade; | |
| if($studentSubjects[$student->subjectId]->students[$student->id]->finalizedMark && !$request->isShowStudentWithNoImprovement){ | |
| $checkPassPercentCriteria = new \stdClass(); | |
| $checkPassPercentCriteria->courseTypeMethod = $student->courseTypeMethod; | |
| $checkPassPercentCriteria->schemeType = $subjectGradeSchemeArray[$subjectGradeKey]->schemeType ? $subjectGradeSchemeArray[$subjectGradeKey]->schemeType : "PERCENTAGE"; | |
| $checkPassPercentCriteria->isInternal = $student->isInternal; | |
| $checkPassPercentCriteria->internalMaxMark = $student->internalMaxMark; | |
| $checkPassPercentCriteria->isExternal = $student->isExternal; | |
| $checkPassPercentCriteria->externalMaxMark = $student->externalMaxMark; | |
| $checkPassPercentCriteria->internalMark = round($student->internalMark, 2 ); | |
| $checkPassPercentCriteria->passPercentConfig = $passCriteriaArray[$student->academicTermId]; | |
| $checkPassPercentCriteria->externalMark = round ($studentSubjects[$student->subjectId]->students[$student->id]->finalizedMark, 2 ); | |
| $checkPassPercentCriteria->maxGradePercent = $maxGradePercent; | |
| $checkPassPercentCriteria->gradeDetails = $gradeDetails; | |
| $subjectPassCriteriaNew = CommonExamService::getInstance()->checkIsFailedByPassPercentCreditCriteria ( $checkPassPercentCriteria ); | |
| $studentSubjects[$student->subjectId]->students[$student->id]->newGrade = $subjectPassCriteriaNew->grade->letterGrade; | |
| } | |
| else if($request->isShowStudentWithNoImprovement){ | |
| $studentSubjects[$student->subjectId]->students[$student->id]->newGrade = $subjectPassCriteriaOld->grade->letterGrade; | |
| } | |
| } | |
| if($request->isShowStudentWithNoImprovement){ | |
| foreach($studentSubjects as $key => $subject){ | |
| $subject->students = (array_filter($subject->students ,function($value){ | |
| return $value->isActiveStudent == true; | |
| })); | |
| if(empty($subject->students)){ | |
| unset($studentSubjects[$key]); | |
| } | |
| } | |
| } | |
| // $resultData = $this->processRevaluationReportWithNoImprovementStudent($students,$request); | |
| $collegeData = CommonExamService::getInstance()->getCollegeDetails(); | |
| $settings = new \stdClass; | |
| if(empty($studentSubjects)){ | |
| throw new ExamControllerException(ExamControllerException::NO_REPORTS_DETAILS_FOUND,"No details found."); | |
| } | |
| $responseHtml = TwigRenderer::renderTemplateFileToHtml(realpath(DOCUMENT_ROOT."../examcontroller-api/src/com/linways/web/templates/revaluationReport/$templateName.twig"), [ 'studentsDetails'=>$studentSubjects,'college'=>$collegeData,'examRegistration'=>$examRegistration,'settings'=>$settings]); | |
| $prtContent = NULL; | |
| $prtContent .= '<html><head>'; | |
| $prtContent .= "<style> | |
| </style>"; | |
| $prtContent .= '</head><title>Moderation Report</title><body>'; | |
| $prtContent .= $responseHtml; | |
| $prtContent .= '</body></html>'; | |
| $totalWidth = 297; | |
| $totalHeight = 210; | |
| $options = array( | |
| 'page-width' => $totalWidth."mm", | |
| 'page-height' => $totalHeight."mm", | |
| 'dpi' => 96, | |
| 'margin-top' => "9mm", | |
| 'margin-left' => "1mm", | |
| 'margin-right' => "1mm", | |
| 'margin-bottom' => "9mm", | |
| // 'binary' => "/usr/local/bin/wkhtmltopdf", // For Mac | |
| 'user-style-sheet' => realpath(DOCUMENT_ROOT . "/libcommon/bootstrap/css/bootstrap.min.css") | |
| ); | |
| $programResult = new \stdClass; | |
| $programResult->dispalyHtmlData = $responseHtml; | |
| $programResult->printData = PdfUtil::renderPdf($prtContent, $options); | |
| return $programResult; | |
| } | |
| /** | |
| * get AllStudent By ExamRegistrationSubject For Digital Valuation | |
| * @param request $request | |
| */ | |
| public function getAllStudentsMarksForRevaluation($request){ | |
| $request = $this->realEscapeObject($request); | |
| try { | |
| $joinQuery = null; | |
| $orderBy = null; | |
| $whereQuery = null; | |
| if(!empty($request->currentRevaluationType)) { | |
| $whereQuery .= " AND esar.identifying_context->>'$.revaluationType' IN ( '$request->currentRevaluationType' )"; | |
| } | |
| if(!empty($request->academicPaperSubjectIds)) { | |
| $academicPaperSubjectIdsString = is_array($request->academicPaperSubjectIds) ? "'" . implode("','",$request->academicPaperSubjectIds) . "'" : "'".$request->academicPaperSubjectIds."'"; | |
| $whereQuery .= " AND eers.cm_academic_paper_subjects_id IN ( $academicPaperSubjectIdsString )"; | |
| } | |
| if(!empty($request->examRevaluationId)) { | |
| $examRevaluationIdString = is_array($request->examRevaluationId) ? "'" . implode("','",$request->examRevaluationId) . "'" : "'".$request->examRevaluationId."'"; | |
| $whereQuery .= " AND eer.id IN ( $examRevaluationIdString )"; | |
| } | |
| if(!empty($request->groupId)) { | |
| $groupIdString = is_array($request->groupId) ? "'" . implode("','",$request->groupId) . "'" : "'".$request->groupId."'"; | |
| $whereQuery .= " AND g.id IN ( $groupIdString )"; | |
| } | |
| $query = "SELECT | |
| DISTINCT sa.studentID as id, | |
| sa.studentID , | |
| sa.studentName, | |
| spa.properties->>'$.registerNumber' AS regNo, | |
| oe.id as onlineExamId, | |
| s.id as subjectId, | |
| s.name as subjectName, | |
| s.code as subjectCode, | |
| g.name as groupName, | |
| g.id as groupId, | |
| act.id as academicTermId, | |
| ct.course_Type AS courseTypeMethod, | |
| esar.am_assessment_id as assessmentId, | |
| eers.cm_academic_paper_subjects_id as academicPaperSubjectId, | |
| esarParent.properties ->> '$.falseNo' as falseNo, | |
| esarParent.properties ->> '$.alphaNumericCode' as alphaNumericCode, | |
| esar.valuation_details as valuationDetails, | |
| erm.id AS finalizedValuationId, | |
| erm.mark_obtained AS revaluationMark, | |
| ostmf.attendance_status AS isAbsent, | |
| ostmf.mark_obtained AS oldRevaluationMark, | |
| ostmf.properties AS finalizedMarkProperties, | |
| esmdsubcon.mark_details ->>'$.externalMark' AS firstValuationMark, | |
| esmdsubcon.mark_details ->>'$.internalMark' AS internalMark, | |
| esmdsubcon.mark_details ->>'$.isExternal' AS isExternal, | |
| esmdsubcon.mark_details ->>'$.isInternal' AS isInternal, | |
| esmdsubcon.mark_details ->>'$.externalMaxMark' AS externalMaxMark, | |
| esmdsubcon.mark_details ->>'$.internalMaxMark' AS internalMaxMark, | |
| ostmParent.mark_obtained as parentExamMark, | |
| erm2.mark_obtained as secondValuationMark, | |
| erm3.mark_obtained as thirdValuationMark, | |
| erm2.properties ->> '$.hasEligibleThirdValuation' as thirdValReq | |
| FROM | |
| ec_student_assessment_registration esar | |
| INNER JOIN studentaccount sa ON | |
| sa.studentID = esar.student_id | |
| INNER JOIN am_assessment aa ON | |
| aa.id = esar.am_assessment_id | |
| INNER JOIN oe_exams oe ON | |
| oe.identifying_context ->> '$.assessmentId' = aa.id AND oe.is_deleted = 0 | |
| INNER JOIN ec_exam_registration_subject eers ON | |
| eers.am_assessment_id = aa.id | |
| INNER JOIN ec_exam_registration_batch eerb ON | |
| eerb.id = eers.ec_exam_registration_batch_id | |
| INNER JOIN ec_exam_registration eerp ON | |
| eerp.id = eerb.ec_exam_registration_id AND | |
| eerp.trashed IS NULL | |
| INNER JOIN ec_exam_registration eer ON | |
| eer.properties->>'$.parentExamRegistrationId' = eerp.id AND | |
| eer.trashed IS NULL | |
| INNER JOIN `groups` g ON | |
| g.id = eerb.groups_id | |
| INNER JOIN program p ON | |
| p.id = g.properties->>'$.programId' | |
| INNER JOIN `course_type` ct ON | |
| ct.courseTypeID = p.course_type_id | |
| INNER JOIN student_program_account spa ON | |
| spa.student_id = esar.student_id AND | |
| spa.current_program_id = p.id | |
| INNER JOIN cm_academic_paper_subjects caps ON | |
| caps.id = eers.cm_academic_paper_subjects_id | |
| INNER JOIN v4_ams_subject s ON | |
| s.id = caps.ams_subject_id | |
| INNER JOIN academic_term act ON | |
| act.id = CAST(eerb.properties ->> '$.academicTermId'AS CHAR) | |
| LEFT JOIN ec_student_assessment_registration esarParent ON | |
| esar.student_id = esarParent.student_id AND | |
| esar.am_assessment_id = esarParent.am_assessment_id AND | |
| eerp.type = esarParent.ec_exam_registration_type | |
| LEFT JOIN ec_revaluation_mark erm ON | |
| erm.student_id = sa.studentID AND erm.am_assessment_id = esar.am_assessment_id AND erm.revaluation_type = CAST(esar.identifying_context->>'$.revaluationType'AS CHAR) AND erm.valuation_count = 'FINALIZED' | |
| LEFT JOIN oe_student_total_mark ostmf ON | |
| ostmf.student_id = sa.studentID AND ostmf.am_assessment_id = esar.am_assessment_id AND ostmf.valuation_count = 'FINALIZED' AND (ostmf.valuation_type = 'REVALUATION') | |
| LEFT JOIN oe_student_total_mark ostmParent ON | |
| ostmParent.student_id = sa.studentID AND ostmParent.am_assessment_id = esar.am_assessment_id AND ostmParent.valuation_count = 'FINALIZED' AND (ostmParent.valuation_type = '' OR ostmParent.valuation_type IS NULL) | |
| LEFT JOIN ec_revaluation_mark erm3 ON | |
| erm3.student_id = sa.studentID AND erm3.am_assessment_id = esar.am_assessment_id AND erm3.revaluation_type = CAST(esar.identifying_context->>'$.revaluationType'AS CHAR) AND erm3.valuation_count = '3' | |
| INNER JOIN ec_consolidated_subject_mark_details esmdsubcon ON | |
| esmdsubcon.groups_id = eerb.groups_id AND esmdsubcon.cm_academic_paper_subjects_id = eers.cm_academic_paper_subjects_id AND esmdsubcon.student_id = sa.studentID | |
| LEFT JOIN ec_revaluation_mark erm2 ON | |
| erm2.student_id = sa.studentID AND erm2.am_assessment_id = esar.am_assessment_id AND erm2.revaluation_type = CAST(esar.identifying_context->>'$.revaluationType'AS CHAR) AND erm2.valuation_count = '2' | |
| $joinQuery | |
| WHERE | |
| esar.ec_exam_registration_type = eer.type AND | |
| CAST(esar.properties ->> '$.registrationStatus' AS CHAR) = 'REGISTERED' AND | |
| CAST(esar.properties ->> '$.feeStatus' AS CHAR) = 'PAID' | |
| $whereQuery "; | |
| $studentsMarkDetails = $this->executeQueryForList($query); | |
| } | |
| catch (\Exception $e) | |
| { | |
| throw new ExamControllerException($e->getCode(),$e->getMessage()); | |
| } | |
| return $studentsMarkDetails; | |
| } | |
| /** | |
| * Get Revaluation Report (Digital Valuation) | |
| * @param $searchRequest | |
| * @return $programResult | |
| */ | |
| public function getRevaluationDigitalValuationReport($searchRequest) { | |
| $searchRequest = $this->realEscapeObject($searchRequest); | |
| $request = new \stdClass; | |
| $request->examRevaluationId = $searchRequest->revaluationId; | |
| $request->isShowMark = $searchRequest->isShowMark == 'true' ? true : false; | |
| $templateName = "revaluation-digital-valuation-report-template"; | |
| if(empty($request->examRevaluationId)){ | |
| throw new ExamControllerException(ExamControllerException::EMPTY_PARAMETERS,"Invailed Request"); | |
| } | |
| $requestForExamRegistration = new SearchExamRegistrationRequest; | |
| $requestForExamRegistration->id = $request->examRevaluationId; | |
| $examRegistration = reset(ExamRegistrationService::getInstance()->searchExamRegistration($requestForExamRegistration)); | |
| $request->currentRevaluationType = reset($examRegistration->properties->revaluationFeeTypeIds); | |
| $request->examRegistrationId = $searchRequest->revaluationId; | |
| $students = ExamValuationService::getInstance()->getAllStudentByRevaluationRegistrationSubjectForDigitalValuation($request); | |
| if(empty($students)){ | |
| throw new ExamControllerException(ExamControllerException::EMPTY_PARAMETERS,"No Students."); | |
| } | |
| $getAllFacultiesRequest = new GetAllFacultiesRequest; | |
| $staffs = StaffService::getInstance()->getAllFacultiesForApi($getAllFacultiesRequest); | |
| $staffsArray = []; | |
| foreach($staffs as $staff){ | |
| $staffsArray[$staff->id] = $staff; | |
| } | |
| usort($students, function($a, $b) { | |
| return $a->regNo <=> $b->regNo; | |
| }); | |
| foreach($students as $student){ | |
| $student->valuationDetails = json_decode($student->valuationDetails); | |
| if(!empty($student->valuationDetails->assignedValuationStaffs)){ | |
| foreach($student->valuationDetails->assignedValuationStaffs as $valuationStaff){ | |
| if($valuationStaff->count == '1'){ | |
| $student->firstValuationStaffs = $valuationStaff->addiitonalExamniners; | |
| } | |
| if($valuationStaff->count == '2'){ | |
| $student->secondValuationStaffs = $valuationStaff->addiitonalExamniners; | |
| } | |
| } | |
| if(!empty( $student->firstValuationStaffs )){ | |
| $student->firstValuationStaffDetails = array_map(function($staff) use ($staffsArray){ | |
| return $staffsArray[$staff]; | |
| },$student->firstValuationStaffs); | |
| $student->firstValuationStaffNames = implode("," ,array_column($student->firstValuationStaffDetails,"name")); | |
| $student->valuatedStaffs[] = "Valuation 1 : ".$student->firstValuationStaffNames; | |
| } | |
| if(!empty( $student->secondValuationStaffs )){ | |
| $student->secondValuationStaffDetails = array_map(function($staff) use ($staffsArray){ | |
| return $staffsArray[$staff]; | |
| },$student->secondValuationStaffs); | |
| $student->secondValuationStaffNames = implode("," ,array_column($student->secondValuationStaffDetails,"name")); | |
| $student->valuatedStaffs[] = "Valuation 2 : ".$student->secondValuationStaffNames; | |
| } | |
| } | |
| } | |
| $settings = new \stdClass; | |
| $settings->isShowMark = $request->isShowMark; | |
| $settings->previousMarkHead = $examRegistration->parentExamRegistrationType == 'REGULAR' ? 'Regular' : 'Supply'; | |
| $responseHtml = TwigRenderer::renderTemplateFileToHtml(realpath(DOCUMENT_ROOT."../examcontroller-api/src/com/linways/web/templates/revaluationReport/$templateName.twig"), [ 'students'=>$students,'examRegistration'=>$examRegistration,'settings'=>$settings]); | |
| $prtContent = NULL; | |
| $prtContent .= '<html><head>'; | |
| $prtContent .= "<style> | |
| </style>"; | |
| $prtContent .= '</head><title>Moderation Report</title><body>'; | |
| $prtContent .= $responseHtml; | |
| $prtContent .= '</body></html>'; | |
| $totalWidth = 297; | |
| $totalHeight = 210; | |
| $options = array( | |
| 'page-width' => $totalWidth."mm", | |
| 'page-height' => $totalHeight."mm", | |
| 'dpi' => 96, | |
| 'margin-top' => "9mm", | |
| 'margin-left' => "10mm", | |
| 'margin-right' => "10mm", | |
| 'margin-bottom' => "9mm", | |
| 'binary' => "/usr/local/bin/wkhtmltopdf", // For Mac | |
| 'user-style-sheet' => realpath(DOCUMENT_ROOT . "/libcommon/bootstrap/css/bootstrap.min.css") | |
| ); | |
| $programResult = new \stdClass; | |
| $programResult->dispalyHtmlData = $responseHtml; | |
| $programResult->printData = PdfUtil::renderPdf($prtContent, $options); | |
| return $programResult; | |
| } | |
| } |