Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 167 |
| Template10FCMC | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
1056.00 | |
0.00% |
0 / 167 |
| __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 |
420.00 | |
0.00% |
0 / 83 |
|||
| renderTemplate | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 30 |
|||
| getsecondLanguageName | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| getopenCourseName | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 27 |
|||
| <?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\core\ams\professional\util\CommonUtil; | |
| use com\linways\ec\core\exception\ExamControllerException; | |
| use com\linways\ec\core\service\FinalConsolidatedReportService; | |
| use com\linways\ec\core\service\FinalConsolidatdMarksCardGenerator\FCMGenerator; | |
| class Template10FCMC 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 = "UGTemplate10FCMC"; | |
| } | |
| else if ($courseType=="PG") { | |
| $templateName = "PGTemplate10FCMC"; | |
| } | |
| return $templateName; | |
| } | |
| /** | |
| * Process Student data college base | |
| * @param $request | |
| */ | |
| protected function processData($request){ | |
| $response = new \stdClass; | |
| $searchRequest = new \stdClass; | |
| $response->studentData = reset(MarksCardService::getInstance()->getConsoliidatedMarksCardData($request))->students; | |
| $markListSubjectCategories = MarksCardService::getInstance()->getMarkListSubjectCategories($request->groupId); | |
| $searchRequest->groupId = $request->groupId; | |
| $CGPAgradeDetails = FinalConsolidatedReportService::getInstance()->getAllGradeScemesByCurriculum($searchRequest); | |
| $gradeDetails = FinalConsolidatedReportService::getInstance()->getCGPAGradeScemesByCurriculum($searchRequest); | |
| $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) { | |
| $student->roundOff = $student->admissionYear < 2019 ? 2 : 3; | |
| $student->minimumPass = $student->admissionYear >= 2019 ? number_format(2,2, '.', '') : 1.5; | |
| $student->minimumPassGrade = $student->admissionYear >= 2019 ? "P Grade" : "C Grade"; | |
| $student->percentageValue = $student->admissionYear >= 2019 ? 20 : 25; | |
| $student->cgpa = round($student->cgpa, $student->roundOff); | |
| $student->cgpaInWords = CommonUtil::convertNumberToWords($student->cgpa); | |
| $student->creditInWords = CommonUtil::convertNumberToWords($student->markDetails->credit); | |
| // 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; | |
| // } | |
| $student->cgpaPercentage = round($student->cgpaPercentage, 2); | |
| foreach ($student->academicTerms as $term) { | |
| $termSubjectCategories = []; | |
| foreach ($term->subjects as $subject) { | |
| $termSubjectCategories["SC$subject->categoryId"]->name = $subject->categoryName; | |
| $termSubjectCategories["SC$subject->categoryId"]->credit += $subject->markDetails->credit; | |
| $termSubjectCategories["SC$subject->categoryId"]->gradePoint += $subject->markDetails->gradePoint; | |
| $termSubjectCategories["SC$subject->categoryId"]->creditPoint += $subject->creditPoint; | |
| $markListSubjectCategories["SC$subject->categoryId"]->id = $subject->categoryId; | |
| $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; | |
| if ($student->courseType == 'PG') { | |
| $subject->examMonthYear = date('M Y',strtotime($subject->markDetails->latestExamYear."-".$subject->markDetails->latestExamMonth."-01")); | |
| } | |
| } | |
| $term->sgpa = round($term->sgpa, $student->roundOff); | |
| $term->termSubjectCategories = $termSubjectCategories; | |
| } | |
| } | |
| foreach ($markListSubjectCategories as $category) { | |
| $category->cgpaPercentage = 0; | |
| $category->cgpa = round($category->creditPoint / $category->credit,2); | |
| $categoryGrade = reset(array_filter($CGPAgradeDetails, function($elem)use($category){ | |
| return $category->cgpa >= $elem->rangeFrom && $category->cgpa <= $elem->rangeTo; | |
| })); | |
| $category->grade = $categoryGrade->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 = $this->getsecondLanguageName($student->studentId); | |
| } | |
| else | |
| { | |
| $displayName = $this->getopenCourseName($student->studentId); | |
| } | |
| $category->displayName = ucwords(strtolower($displayName)); | |
| $category->cgpaPercentage = round($category->cgpaPercentage, 2); | |
| } | |
| $maxRangeTo = max(array_column($gradeDetails,"rangeTo")); | |
| foreach ($gradeDetails as $grade) { | |
| $grade->maxRangeTo = $maxRangeTo; | |
| $grade->percentageFrom = ($grade->rangeFrom / $grade->maxRangeTo) * 100; | |
| $grade->percentageTo = ($grade->rangeTo / $grade->maxRangeTo) * 100; | |
| } | |
| $response->collegeData = CommonExamService::getInstance()->getCollegeDetails(); | |
| $response->dateOfIssue = $request->filterSettings['markListDate']?: date("d-m-Y"); | |
| $response->markListSubjectCategories = $markListSubjectCategories; | |
| $response->gradeDetails = $gradeDetails; | |
| 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; | |
| } | |
| } | |
| private function getsecondLanguageName($studentId) | |
| { | |
| try { | |
| $query = "SELECT t1.secondLangaugeName FROM secondLangauge t1,studentaccount t2 WHERE t1.secondlangaugeID = t2.secondlangaugeID AND t2.studentID = ".$studentId.""; | |
| $displayName = $this->executeQueryForObject($query)->secondLangaugeName;; | |
| } catch (\Exception $e) { | |
| throw $e; | |
| } | |
| return $displayName; | |
| } | |
| private function getopenCourseName($studentID) | |
| { | |
| try { | |
| $sql_check33 = "SELECT t1.pseudosubjectID FROM pseudosubjects t1,pseudosubjects_students t2 WHERE t1.pseudosubjectID = t2.pseudosubjectID AND t2.studentID = ".$studentID." AND t1.isOpencourse = 1"; | |
| $pseudosubjectID = $this->executeQueryForObject($sql_check33)->pseudosubjectID; | |
| if($pseudosubjectID) | |
| { | |
| $query1 = "SELECT t1.subjectID FROM sbs_relation t1,pseudosubjects_sbs t2 WHERE t1.sbsID = t2.sbsID AND t2.pseudosubjectID = ".$pseudosubjectID.""; | |
| $subjectID = $this->executeQueryForObject($query1)->subjectID; | |
| if($subjectID) | |
| { | |
| $sql ="SELECT code as subjectName, name as subjectDesc from v4_ams_subject where id=\"".$subjectID."\""; | |
| $subjectDesc = $this->executeQueryForObject($sql)->subjectDesc; | |
| } | |
| else | |
| { | |
| $subjectDesc = '-'; | |
| } | |
| } | |
| else | |
| { | |
| $subjectDesc = '-'; | |
| } | |
| } catch (\Exception $e) { | |
| throw $e; | |
| } | |
| return $subjectDesc; | |
| } | |
| } |