Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 176 |
| Template15RevaluationMemoResultGenerator | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
812.00 | |
0.00% |
0 / 176 |
| __construct | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| getTemplateName | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| processData | |
0.00% |
0 / 1 |
72.00 | |
0.00% |
0 / 44 |
|||
| renderRevaluationMemoResult | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 30 |
|||
| processStudentData | |
0.00% |
0 / 1 |
210.00 | |
0.00% |
0 / 92 |
|||
| getExamRegistrationDetailsData | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 7 |
|||
| <?php | |
| // Template Revaluation Memo | |
| namespace com\linways\ec\core\service\RevaluationMemoGenerator; | |
| use com\linways\ec\core\service\StudentMarkListService; | |
| use com\linways\ec\core\service\ExamRegistrationService; | |
| use com\linways\ec\core\request\SearchExamRegistrationRequest; | |
| use com\linways\ec\core\exception\ExamControllerException; | |
| use com\linways\base\util\TwigRenderer; | |
| use com\linways\core\ams\professional\util\PdfUtil; | |
| use com\linways\core\ams\professional\util\CommonUtil; | |
| use com\linways\ec\core\service\CommonExamService; | |
| use com\linways\ec\core\service\GradeSchemeService; | |
| use com\linways\ec\core\service\RevaluationMemoGenerator\RevaluationMemoResultDataGenerator; | |
| use com\linways\ec\core\service\RuleService; | |
| use com\linways\ec\core\request\SearchRuleRequest; | |
| use com\linways\ec\core\request\SearchExamRegistrationBatchRequest; | |
| use com\linways\ec\core\service\ExamRegistrationBatchService; | |
| class Template15RevaluationMemoResultGenerator extends RevaluationMemoResultDataGenerator | |
| { | |
| public function __construct(){} | |
| /** | |
| * get Template Name | |
| * @param $request | |
| * @param $templateName | |
| */ | |
| protected function getTemplateName($request){ | |
| $templateName = "template_15"; | |
| // $examRegistrationDetails = new \stdClass; | |
| // $requestForRevaluationDetails = new \stdClass; | |
| // $requestForRevaluationDetails->id = $request->examRegistrationId; | |
| // $revaluationDetails = ExamRegistrationService::getInstance()->getCurrentExamRevaluationDetails($requestForRevaluationDetails); | |
| // if($revaluationDetails){ | |
| // $requestForRegistrationDetails = new \stdClass; | |
| // $requestForRegistrationDetails->examRegistrationId = $revaluationDetails->parentExamRegstrationId; | |
| // $examRegistrationDetailsArray = ExamRegistrationService::getInstance()->searchDetailedExamRegistrationDetails($requestForRegistrationDetails); | |
| // $examRegistrationDetails->courseTypeName = $examRegistrationDetailsArray[0]->groups[0]->courseTypeName; | |
| // if($examRegistrationDetails->courseTypeName == "PG"){ | |
| // $templateName = "template_15_PG"; | |
| // } | |
| // } | |
| return $templateName; | |
| } | |
| /** | |
| * Process Student data college base | |
| * @param $request | |
| */ | |
| protected function processData($request){ | |
| $response = new \stdClass; | |
| $studentsMarkDetails = []; | |
| $studentsMarkDetails = StudentMarkListService::getInstance()->getAllRegistredStudentRevaluationMarkDetails($request); | |
| if(empty($studentsMarkDetails)){ | |
| throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
| } | |
| $responseOfStudentData = $this->processStudentData($studentsMarkDetails, $request); | |
| $response->studentData = $responseOfStudentData->studentsDetails; | |
| $response->examRegistrationData = $this->getExamRegistrationDetailsData($request); | |
| $response->collegeAndOtherData = CommonExamService::getInstance()->getCollegeDetails($request); | |
| $searchRuleRequest = new SearchRuleRequest; | |
| $searchRuleRequest->name = "PRINCIPAL_SIGNATURE_CONDITION"; | |
| $ruleSettings = reset(RuleService::getInstance()->searchRule($searchRuleRequest))->rule; | |
| $batchSearchRequest = new SearchExamRegistrationBatchRequest(); | |
| $batchSearchRequest->examRegistrationId = $request->examRegistrationId; | |
| $batchSearchRequest->groupId = reset($studentsMarkDetails)->studentDetails->batchId; | |
| $batchDetails = reset(ExamRegistrationBatchService::getInstance()->searchExamRegistrationBatch($batchSearchRequest)); | |
| $baseUrl = "http://".$_SERVER['HTTP_HOST']; | |
| $collegeCode = $GLOBALS['COLLEGE_CODE']; | |
| $response->collegeAndOtherData->principalVar = "Principal-in-Charge"; | |
| $response->collegeAndOtherData->hideSealAndSign = false; | |
| if( $batchDetails->properties->publishingStartDate){ | |
| foreach($ruleSettings->principalNames as $principalName){ | |
| if($principalName->fromDate <= $batchDetails->properties->publishingStartDate && $principalName->toDate >= $batchDetails->properties->publishingStartDate){ | |
| $response->collegeAndOtherData->principalName = $principalName->principalName; | |
| $response->collegeAndOtherData->principalSign = "$baseUrl/libcommon/images/college/$collegeCode/$principalName->principalSign.png"; | |
| $response->collegeAndOtherData->principalVar = $principalName->principalVarName ?? 'Principal'; | |
| } | |
| } | |
| if( $ruleSettings->hideSealSignDate < $batchDetails->properties->publishingStartDate){ | |
| $response->collegeAndOtherData->hideSealAndSign = true; | |
| } | |
| } | |
| if(!$request->displayContentOptions->markListDate ){ | |
| $request->displayContentOptions->markListDate = date("d-m-Y"); | |
| } | |
| else{ | |
| $request->displayContentOptions->markListDate = date("d-m-Y", strtotime($request->displayContentOptions->markListDate)); | |
| } | |
| $response->displayContentOptions = $request->displayContentOptions; | |
| // $response->isShowMarkAndGradeInRevaluation = $request->isShowMarkAndGradeInRevaluation ? true : false; | |
| // check only grade change in revaluation | |
| $response->isShowMarkAndGradeInRevaluation = false; | |
| $response->collegeAndOtherData->isHeaderEnabled = CommonExamService::getInstance()->isValidURL($response->collegeAndOtherData->collegeHeader); | |
| return $response; | |
| } | |
| /** | |
| * Render Program Result | |
| * | |
| * @param $templateName | |
| * @param Object $data | |
| * @return Object | |
| */ | |
| protected function renderRevaluationMemoResult($templateName, $data){ | |
| if(empty($data)){ | |
| throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
| } | |
| else{ | |
| $responseHtml = TwigRenderer::renderTemplateFileToHtml(realpath(DOCUMENT_ROOT."../examcontroller-api/src/com/linways/web/templates/RevaluationMemo/Template15/$templateName.twig"), [ 'data'=>$data ]); | |
| $prtContent = NULL; | |
| $responseHtml .= ''; | |
| $prtContent .= '<html><head>'; | |
| $prtContent .= "<link href='https://fonts.googleapis.com/css2?family=Times New Roman:ital,wght@0,400;0,700;1,400;1,700&display=swap' rel='stylesheet'>"; | |
| $prtContent .= '</head><title>Revaluation Memo</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 = $prtContent; | |
| $programResult->printData = PdfUtil::renderPdf($prtContent, $options); | |
| return $programResult; | |
| } | |
| } | |
| /** | |
| * processStudentData | |
| * @param $studentsMarkDetails | |
| * @param $studentsDetails | |
| */ | |
| protected function processStudentData($studentsMarkDetails, $request = null){ | |
| $response = new \stdClass; | |
| $studentsDetails = []; | |
| // $isShowMarkAndGradeInRevaluation = $request->isShowMarkAndGradeInRevaluation ? true : false; | |
| // check only grade change in revaluation | |
| $isShowMarkAndGradeInRevaluation = false; | |
| foreach($studentsMarkDetails as $student){ | |
| // $isShowMarkAndGradeInRevaluation = $student->studentDetails->courseTypeName == 'PG' ? false : $isShowMarkAndGradeInRevaluation; | |
| $studentsDetails[$student->id]->id = $student->id; | |
| $studentsDetails[$student->id]->registerNo = $student->studentDetails->registerNo; | |
| $studentsDetails[$student->id]->rollNo = $student->studentDetails->rollNo; | |
| $studentsDetails[$student->id]->degreeName = $student->studentDetails->degree; | |
| $studentsDetails[$student->id]->name = $student->studentDetails->name; | |
| $student->academicTerm = reset($student->academicTerms); | |
| foreach($student->academicTerm->subjects as $subject){ | |
| $studentsDetails[$student->id]->subjects[$subject->id]->id = $subject->id; | |
| $studentsDetails[$student->id]->subjects[$subject->id]->name = $subject->name; | |
| $studentsDetails[$student->id]->subjects[$subject->id]->code = $subject->code; | |
| $studentsDetails[$student->id]->subjects[$subject->id]->externalMaxMark = $subject->externalMaxMark; | |
| $studentsDetails[$student->id]->subjects[$subject->id]->internalMaxMark = $subject->internalMaxMark; | |
| $studentsDetails[$student->id]->subjects[$subject->id]->internalMark = $subject->internalMark; | |
| $currentExamRegistrationDetails = ""; | |
| $currentExamRegistrationDetails = reset(array_filter($subject->subjectMarkHistory,function($value)use($student){ | |
| return $value->examRegistrationId == $student->studentDetails->parentExamRegistrationId; | |
| })); | |
| $searchRequestForGradeScheme = new \stdClass(); | |
| $searchRequestForGradeScheme->groupId = $student->studentDetails->batchId; | |
| $searchRequestForGradeScheme->academicTermId = $student->academicTerm->id; | |
| $searchRequestForGradeScheme->academicPaperSubjectId = $subject->id; | |
| $subjectGradeSchemeArray = GradeSchemeService::getInstance()->getAllSubjectGradeSchemesByRequest($searchRequestForGradeScheme); | |
| $subjectGradeKey = array_search($subject->id, array_column( $subjectGradeSchemeArray, "id")); | |
| $gradeDetails = []; | |
| if($subjectGradeKey || $subjectGradeKey === 0){ | |
| $gradeDetails = $subjectGradeSchemeArray[$subjectGradeKey]->grades; | |
| } | |
| $maxGradePercent = max(array_column($gradeDetails,"rangeTo")); | |
| $schemeType = "PERCENTAGE"; | |
| $passCriteriaArray[$subject->id] = GradeSchemeService::getInstance()->getSubjectPassCriteriaByAcademicPaperSubject($subject->id, $schemeType); | |
| $studentsDetails[$student->id]->subjects[$subject->id]->isChangeMarkByRevaluation = false; | |
| $studentsDetails[$student->id]->subjects[$subject->id]->isChangeMarkByRevaluation = false; | |
| $studentsDetails[$student->id]->subjects[$subject->id]->revaluationGrade = $currentExamRegistrationDetails->revaluationGrade; | |
| $studentsDetails[$student->id]->subjects[$subject->id]->revaluationMark = $currentExamRegistrationDetails->revaluationMark; | |
| $studentsDetails[$student->id]->subjects[$subject->id]->externalMarkObtainedInExam = $currentExamRegistrationDetails->externalMarkObtainedInExam; | |
| $studentsDetails[$student->id]->subjects[$subject->id]->externalMarkObtainedInExamGrade = $currentExamRegistrationDetails->externalMarkObtainedInExamGrade; | |
| if((int)$currentExamRegistrationDetails->externalMarkObtainedInExam < (int)$currentExamRegistrationDetails->revaluationMark){ | |
| $checkPassPercentCriteria = new \stdClass(); | |
| $checkPassPercentCriteria->courseTypeMethod = $student->studentDetails->courseType; | |
| $checkPassPercentCriteria->schemeType = $subjectGradeSchemeArray[$subjectGradeKey]->schemeType ? $subjectGradeSchemeArray[$subjectGradeKey]->schemeType : "PERCENTAGE"; | |
| $checkPassPercentCriteria->isInternal = $subject->isInternal; | |
| $checkPassPercentCriteria->internalMaxMark = $subject->internalMaxMark; | |
| $checkPassPercentCriteria->isExternal = $subject->isExternal; | |
| $checkPassPercentCriteria->externalMaxMark = $subject->externalMaxMark; | |
| $checkPassPercentCriteria->internalMark = round($subject->internalMark, 2 ); | |
| $checkPassPercentCriteria->passPercentConfig = $passCriteriaArray[$subject->id]; | |
| $checkPassPercentCriteria->externalMark = round ( $studentsDetails[$student->id]->subjects[$subject->id]->externalMarkObtainedInExam, 2 ); | |
| $checkPassPercentCriteria->maxGradePercent = $maxGradePercent; | |
| $checkPassPercentCriteria->gradeDetails = $gradeDetails; | |
| $externalMarkObtainedInExamPassCriteria = CommonExamService::getInstance()->checkIsFailedByPassPercentCreditCriteria ( $checkPassPercentCriteria ); | |
| $studentsDetails[$student->id]->subjects[$subject->id]->externalMarkObtainedInExamUpdated = $externalMarkObtainedInExamPassCriteria->grade->totalExternalMark; | |
| $studentsDetails[$student->id]->subjects[$subject->id]->externalMarkObtainedInExamGradeUpdated = $externalMarkObtainedInExamPassCriteria->grade->letterGrade; | |
| $checkPassPercentCriteria = new \stdClass(); | |
| $checkPassPercentCriteria->courseTypeMethod = $student->studentDetails->courseType; | |
| $checkPassPercentCriteria->schemeType = $subjectGradeSchemeArray[$subjectGradeKey]->schemeType ? $subjectGradeSchemeArray[$subjectGradeKey]->schemeType : "PERCENTAGE"; | |
| $checkPassPercentCriteria->isInternal = $subject->isInternal; | |
| $checkPassPercentCriteria->internalMaxMark = $subject->internalMaxMark; | |
| $checkPassPercentCriteria->isExternal = $subject->isExternal; | |
| $checkPassPercentCriteria->externalMaxMark = $subject->externalMaxMark; | |
| $checkPassPercentCriteria->internalMark = round($subject->internalMark, 2 ); | |
| $checkPassPercentCriteria->passPercentConfig = $passCriteriaArray[$subject->id]; | |
| $checkPassPercentCriteria->externalMark = round ( $studentsDetails[$student->id]->subjects[$subject->id]->revaluationMark, 2 ); | |
| $checkPassPercentCriteria->maxGradePercent = $maxGradePercent; | |
| $checkPassPercentCriteria->gradeDetails = $gradeDetails; | |
| $revaluationMarkPassCriteria = CommonExamService::getInstance()->checkIsFailedByPassPercentCreditCriteria ( $checkPassPercentCriteria ); | |
| $studentsDetails[$student->id]->subjects[$subject->id]->revaluationMarkUpdated = $revaluationMarkPassCriteria->grade->totalExternalMark; | |
| $studentsDetails[$student->id]->subjects[$subject->id]->revaluationGradeUpdated = $revaluationMarkPassCriteria->grade->letterGrade; | |
| if(($studentsDetails[$student->id]->subjects[$subject->id]->externalMarkObtainedInExamUpdated < $studentsDetails[$student->id]->subjects[$subject->id]->revaluationMarkUpdated )){ | |
| if(!$isShowMarkAndGradeInRevaluation){ | |
| if($studentsDetails[$student->id]->subjects[$subject->id]->revaluationGradeUpdated && $studentsDetails[$student->id]->subjects[$subject->id]->externalMarkObtainedInExamGradeUpdated ){ | |
| if($studentsDetails[$student->id]->subjects[$subject->id]->revaluationGradeUpdated != $studentsDetails[$student->id]->subjects[$subject->id]->externalMarkObtainedInExamGradeUpdated ){ | |
| $studentsDetails[$student->id]->subjects[$subject->id]->isChangeMarkByRevaluation = true; | |
| } | |
| } | |
| } | |
| else{ | |
| $studentsDetails[$student->id]->subjects[$subject->id]->isChangeMarkByRevaluation = true; | |
| } | |
| } | |
| } | |
| } | |
| } | |
| $studentsDetails = array_values($studentsDetails); | |
| foreach($studentsDetails as $student){ | |
| $student->subjects = array_values($student->subjects); | |
| } | |
| $response->studentsDetails = $studentsDetails; | |
| return $response; | |
| } | |
| protected function getExamRegistrationDetailsData($request){ | |
| $examRegistrationDetails = new \stdClass; | |
| $requestForExamRegistration = new SearchExamRegistrationRequest; | |
| $requestForExamRegistration->id = $request->examRegistrationId; | |
| $examRegistrationDetails = reset(ExamRegistrationService::getInstance()->searchExamRegistration($requestForExamRegistration)); | |
| $examRegistrationDetails->properties->memoDate = $examRegistrationDetails->properties->memoDate ? date("d-m-Y", strtotime($examRegistrationDetails->properties->memoDate)) : ""; | |
| return $examRegistrationDetails; | |
| } | |
| } |