Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 176 |
| Template1FCMC | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
1122.00 | |
0.00% |
0 / 176 |
| __construct | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| getTemplateName | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 18 |
|||
| processData | |
0.00% |
0 / 1 |
756.00 | |
0.00% |
0 / 128 |
|||
| renderTemplate | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 30 |
|||
| <?php | |
| // MES VIMALA STJOSEPH STTHOMAS Collages | |
| namespace com\linways\ec\core\service\FinalConsolidatdMarksCardGenerator; | |
| use com\linways\base\util\TwigRenderer; | |
| use com\linways\ec\core\service\MarksCardService; | |
| use com\linways\ec\core\service\CommonExamService; | |
| use com\linways\core\ams\professional\util\PdfUtil; | |
| use com\linways\ec\core\exception\ExamControllerException; | |
| use com\linways\ec\core\service\FinalConsolidatdMarksCardGenerator\FCMGenerator; | |
| use com\linways\ec\core\service\GradeSchemeService; | |
| use com\linways\core\ams\professional\util\CommonUtil; | |
| class Template1FCMC extends FCMGenerator | |
| { | |
| public function __construct(){} | |
| protected function getTemplateName($request){ | |
| $query = "SELECT | |
| ct.course_Type AS courseType | |
| FROM | |
| `groups` g | |
| INNER JOIN program p ON | |
| p.id = CAST(g.properties->>'$.programId' AS CHAR) | |
| INNER JOIN course_type ct ON | |
| ct.courseTypeID = p.course_type_id | |
| WHERE g.id IN ('$request->groupId')"; | |
| $courseType = $this->executeQueryForObject($query)->courseType; | |
| if ($courseType=="UG") { | |
| $templateName = "UGTemplate1FCMC"; | |
| } | |
| else if ($courseType=="PG") { | |
| $templateName = "PGTemplate1FCMC"; | |
| } | |
| return $templateName; | |
| } | |
| /** | |
| * Process Student data college base | |
| * @param $request | |
| */ | |
| protected function processData($request){ | |
| $response = new \stdClass; | |
| $response->studentData = reset(MarksCardService::getInstance()->getConsoliidatedMarksCardData($request))->students; | |
| $markListSubjectCategories = MarksCardService::getInstance()->getMarkListSubjectCategories($request->groupId); | |
| $markListSubjectCategories = call_user_func_array('array_merge', array_map( | |
| function ($key, $value) {return array("SC$key" => $value);}, | |
| array_column($markListSubjectCategories, "subjectCategoryId"), | |
| $markListSubjectCategories) | |
| ); | |
| array_walk($markListSubjectCategories,function($category,$key){ | |
| $category->credit = 0; | |
| $category->gradePoint = 0; | |
| $category->creditPoint = 0; | |
| }); | |
| foreach ($response->studentData as $student) { | |
| $showNote = $student->admissionYear >= 2019 && $student->courseType == 'PG' ? true : false ; | |
| $student->roundOff = 2; | |
| $student->cgpaInWords = CommonUtil::convertNumberToWords(round($student->cgpa, $student->roundOff)); | |
| // If 0.5 < CGPA ≤ 5.5, % = 40 + (CGPA - 0.5) x 10 If CGPA > 5.5, % = 90 + (CGPA - 5.5) x 20 | |
| if (0.5 < $student->cgpa && $student->cgpa <= 5.5) { | |
| $student->cgpaPercentage = 40 + ($student->cgpa - 0.5) * 10; | |
| } | |
| else if ($student->cgpa > 5.5) { | |
| $student->cgpaPercentage = 90 + ($student->cgpa - 5.5) * 20; | |
| } | |
| foreach ($student->academicTerms as $term) { | |
| foreach ($term->subjects as $subject) { | |
| if( $subject->markDetails->isInternalNull == true && empty($subject->markDetails->internalMark)){ | |
| $subject->markDetails->internalMark = '-'; | |
| $subject->markDetails->gradePoint = '-'; | |
| $subject->markDetails->markObtained = '-'; | |
| $subject->grade = '-'; | |
| $subject->creditPoint = '-'; | |
| } | |
| $term->markListSubjectCategories["SC$subject->categoryId"]->name = $subject->categoryName; | |
| $term->markListSubjectCategories["SC$subject->categoryId"]->credit += $subject->markDetails->credit; | |
| $markListSubjectCategories["SC$subject->categoryId"]->name = $subject->categoryName; | |
| $markListSubjectCategories["SC$subject->categoryId"]->credit += $subject->markDetails->credit; | |
| $markListSubjectCategories["SC$subject->categoryId"]->gradePoint += $subject->markDetails->gradePoint; | |
| $markListSubjectCategories["SC$subject->categoryId"]->creditPoint += $subject->creditPoint; | |
| } | |
| } | |
| } | |
| $gradeSchemeRequest = new \stdClass; | |
| $gradeSchemeRequest->groupId = $request->groupId; | |
| $gradeSchemeRequest->orderBy = "ASC"; | |
| $semesterGrades = GradeSchemeService::getInstance()->getAllExamRegistrationGradeSchemes($gradeSchemeRequest); | |
| array_walk($semesterGrades, function($semGrade){ | |
| $semGrade->properties = json_decode($semGrade->properties); | |
| $semGrade->percentTo = $semGrade->range_to; | |
| $semGrade->percentFrom = $semGrade->range_from; | |
| $semGrade->class = $semGrade->properties->class; | |
| $semGrade->gradePoint = $semGrade->properties->gradePoint; | |
| }); | |
| foreach ($markListSubjectCategories as $category) { | |
| $category->cgpaPercentage = 0; | |
| $category->cgpa = $category->credit ? round($category->creditPoint / $category->credit,2) : 0; | |
| $cgpaGradeDetails = CommonExamService::getInstance()->getGradeByPercentage($category->cgpa,$semesterGrades); | |
| $category->grade = $cgpaGradeDetails->name; | |
| if (0.5 < $category->cgpa && $category->cgpa <= 5.5) { | |
| $category->cgpaPercentage = 40 + ($category->cgpa - 0.5) * 10; | |
| } | |
| else if ($category->cgpa > 5.5) { | |
| $category->cgpaPercentage = 90 + ($category->cgpa - 5.5) * 20; | |
| } | |
| if(($category->openCourseFlag == 0) && ($category->secondLangFlag == 0)){ | |
| $displayName = $category->displayName; | |
| } | |
| elseif(($category->secondLangFlag) && ($category->openCourseFlag == 0)){ | |
| // $displayName = getsecondLanguageName($studentID); | |
| } | |
| else{ | |
| // $displayName = getopenCourseName($studentID); | |
| } | |
| $displayName = ucfirst($displayName); | |
| } | |
| $gradeDiplayArray = []; | |
| $gradeDiplayArray[0][0] = "Marks(%)"; | |
| $gradeDiplayArray[1][0] = "Grade"; | |
| $gradeDiplayArray[2][0] = "Grade Point"; | |
| $gradeDiplayArray[3][0] = "Grade Range"; | |
| $gradeDiplayArray[4][0] = "Class"; | |
| if(reset($response->studentData)->admissionYear >= 2015 && reset($response->studentData)->admissionYear <= 2018){ | |
| $gradeDiplayArray[4][0] = "Interpretation"; | |
| $gradeDiplayArray[5][0] = "Class"; | |
| } | |
| $subjectGrades = GradeSchemeService::getInstance()->getAllSubjectGradeSchemes($gradeSchemeRequest); | |
| array_walk($subjectGrades, function($grade){ | |
| $grade->properties = json_decode($grade->properties); | |
| $grade->percentTo = $grade->range_to; | |
| $grade->percentFrom = $grade->range_from; | |
| $grade->class = $grade->properties->class; | |
| $grade->gradePoint = $grade->properties->gradePoint; | |
| }); | |
| $minPercentTo = min(array_column($subjectGrades, "percentTo")); | |
| $maxPercentTo = max(array_column($subjectGrades, "percentTo")); | |
| foreach ($subjectGrades as $key => $subjectGrade) { | |
| if ($subjectGrade->percentTo == $maxPercentTo) { | |
| $gradeDiplayArray[0][$subjectGrade->percentTo] = round($subjectGrade->percentFrom) . " and above"; | |
| } | |
| else if($subjectGrade->percentTo == $minPercentTo) { | |
| $gradeDiplayArray[0][$subjectGrade->percentTo] = "Below " . round($subjectGrade->percentTo); | |
| } | |
| else { | |
| $gradeDiplayArray[0][$subjectGrade->percentTo] = round($subjectGrade->percentFrom) . " to below " . round($subjectGrade->percentTo); | |
| } | |
| $gradeDiplayArray[1][$subjectGrade->percentTo] = "$subjectGrade->name"; | |
| $gradeDiplayArray[2][$subjectGrade->percentTo] = "$subjectGrade->gradePoint"; | |
| $gradeDiplayArray[3][$subjectGrade->percentTo] = sprintf("%.02f",round($semesterGrades[$key]->range_from, 2))."-".sprintf("%.02f",round($semesterGrades[$key]->range_to, 2)); | |
| $gradeDiplayArray[4][$subjectGrade->percentTo] = $semesterGrades[$key]->class; | |
| if(reset($response->studentData)->admissionYear >= 2015 && reset($response->studentData)->admissionYear <= 2018){ | |
| $gradeDiplayArray[4][$subjectGrade->percentTo] = $subjectGrade->class; | |
| $gradeDiplayArray[5][$subjectGrade->percentTo] = $semesterGrades[$key]->class; | |
| } | |
| } | |
| $cgpaGradeSchemeRequest = new \stdClass; | |
| $cgpaGradeSchemeRequest->groupId = $request->groupId; | |
| $cgpaGradeSchemeRequest->orderBy = "DESC"; | |
| $cgpaGrades = GradeSchemeService::getInstance()->getAllCGPAGradeSchemes($cgpaGradeSchemeRequest); | |
| $maxCgpaRange = max(array_column($cgpaGrades, "range_to")); | |
| array_walk($cgpaGrades, function($grade) use($maxCgpaRange){ | |
| $grade->properties = json_decode($grade->properties); | |
| $grade->percentageFrom = round(sprintf("%.02f", round($grade->range_from, 2)) * 100 / $maxCgpaRange,2); | |
| $grade->percentageTo = round(sprintf("%.02f", round($grade->range_to, 2)) * 100 / $maxCgpaRange,2); | |
| $grade->rangeFrom = $grade->range_from; | |
| $grade->rangeTo = $grade->range_to; | |
| $grade->class = $grade->properties->class; | |
| $grade->gradePoint = $grade->properties->gradePoint; | |
| }); | |
| $response->gradeDiplayArray = $gradeDiplayArray; | |
| $response->cgpaGrades = $cgpaGrades; | |
| $response->collegeData = CommonExamService::getInstance()->getCollegeDetails(); | |
| $response->dateOfIssue = date("d-m-Y"); | |
| $response->markListSubjectCategories = $markListSubjectCategories; | |
| $response->showNote = $showNote; | |
| return $response; | |
| } | |
| /** | |
| * Render Program Result | |
| * @param $templateName | |
| * @param Object $data | |
| * @return Object | |
| */ | |
| protected function renderTemplate($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/FinalConsolidatedMarksCard/$templateName.twig"), [ 'data'=>$data ]); | |
| $prtContent = NULL; | |
| $prtContent .= '<html><head>'; | |
| $prtContent .= "<style> | |
| </style>"; | |
| $prtContent .= '</head><title>Consolidated Marks Card</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' => "7.5mm", | |
| 'margin-left' => "7.5mm", | |
| 'margin-right' => "7.5mm", | |
| 'margin-bottom' => "7.5mm", | |
| // 'binary' => "/usr/local/bin/wkhtmltopdf", // For Mac | |
| 'user-style-sheet' => realpath(DOCUMENT_ROOT . "/libcommon/bootstrap/css/bootstrap.min.css") | |
| ); | |
| $finalCMC = new \stdClass; | |
| $finalCMC->htmlData = $responseHtml; | |
| $finalCMC->printData = PdfUtil::renderPdf($prtContent, $options); | |
| return $finalCMC; | |
| } | |
| } | |
| } |