Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 204 |
Template15FCMC | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
812.00 | |
0.00% |
0 / 204 |
__construct | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getTemplateName | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 13 |
|||
processData | |
0.00% |
0 / 1 |
306.00 | |
0.00% |
0 / 99 |
|||
renderTemplate | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 56 |
|||
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; | |
use com\linways\ec\core\service\GradeSchemeService; | |
use com\linways\ec\core\request\SearchRuleRequest; | |
use com\linways\ec\core\service\RuleService; | |
use com\linways\ec\core\service\ExamRegistrationService; | |
use TCPDFBarcode; | |
class Template15FCMC 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; | |
$templateName = "PGTemplate15FCMC"; | |
// if ($courseType=="UG") { | |
// $templateName = "UGTemplate15FCMC"; | |
// } | |
// else if ($courseType=="PG") { | |
// $templateName = "PGTemplate15FCMC"; | |
// } | |
return $templateName; | |
} | |
/** | |
* Process Student data college base | |
* @param $request | |
*/ | |
protected function processData($request){ | |
$response = new \stdClass; | |
$response->isStudentSideExamResult = $request->isStudentSideExamResult == '1' ? true : false; | |
$response->maximumSemResultInOnePaper = $request->isStudentSideExamResult == '1' ? 4 : 3; | |
$requestForSpecialExam = new \stdClass; | |
$requestForSpecialExam->groupId = $request->groupId; | |
$requestForSpecialExam->isSpecialExamRegistration = true; | |
$specialExams = ExamRegistrationService::getInstance()->searchExamRegistrationByOtherDetails($requestForSpecialExam); | |
$specialExamIds = []; | |
foreach($specialExams as $specialExam){ | |
$specialExamIds[] = $specialExam->id; | |
} | |
$searchRequest = new \stdClass; | |
$searchRuleRequest = new SearchRuleRequest; | |
$searchRuleRequest->name = "XML_SETTINGS_RULE"; | |
$ruleObj = reset(RuleService::getInstance()->searchRule($searchRuleRequest))->rule; | |
$includedSubjectTypes = $ruleObj->includedSubjectTypes; | |
$response->studentData = reset(MarksCardService::getInstance()->getConsoliidatedMarksCardData($request))->students; | |
usort($response->studentData, function($a, $b) { | |
return $a->regNo > $b->regNo; | |
}); | |
$markListSubjectCategories = MarksCardService::getInstance()->getMarkListSubjectCategories($request->groupId); | |
$searchRequest->groupId = $request->groupId; | |
// $CGPAgradeDetails = FinalConsolidatedReportService::getInstance()->getAllGradeScemesByCurriculum($searchRequest); | |
// $gradeDetails = FinalConsolidatedReportService::getInstance()->getCGPAGradeScemesByCurriculum($searchRequest); | |
$searchRequest->requestType = "CURRICULAM"; | |
$cgpaGradeSchemeArray = GradeSchemeService::getInstance()->getAllSubjectGradeSchemesByRequest($searchRequest); | |
$gradeDetails = reset($cgpaGradeSchemeArray)->grades; | |
$markListSubjectCategories = call_user_func_array('array_merge', array_map( | |
function ($key, $value) {return array("SC$key" => $value);}, | |
array_column($markListSubjectCategories, "subjectCategoryId"), | |
$markListSubjectCategories) | |
); | |
foreach ($response->studentData as $student) { | |
$markListSubjectCategoriesData = $markListSubjectCategories; | |
array_walk($markListSubjectCategoriesData,function($category,$key){ | |
$category->credit = 0; | |
$category->gradePoint = 0; | |
$category->creditPoint = 0; | |
}); | |
$student->studentImage = CommonExamService::getInstance()->getStudentProfilePic($student->studentId); | |
$student->roundOff = 2; | |
$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->markDetails->rawCgpa, $student->roundOff); | |
// $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->cgpa * 20, 2); | |
foreach ($student->academicTerms as $term) { | |
$term->auditCources = []; | |
$term->remainingSubjects = []; | |
$termSubjectCategories = []; | |
foreach ($term->subjects as $subject) { | |
$subject->regularMarkDetails = reset(array_filter($subject->markHistory,function($value){ | |
return $value->examMarkType == "REGULAR"; | |
})); | |
// this case to handle both regular and special supply have same month and year | |
usort($subject->markHistory, function($a, $b) { | |
return ($a->examYear."-".date("m", mktime(0, 0, 0, (int)$a->examMonth, 10))."-".$a->examMarkType) < ($b->examYear."-".date("m", mktime(0, 0, 0, (int)$b->examMonth, 10))."-".$b->examMarkType); | |
}); | |
$latestMarkDetails = reset($subject->markHistory); | |
if(in_array($latestMarkDetails->examRegistrationId,$specialExamIds)){ | |
$subject->RSI = "R"; | |
} | |
$subject->markDetails->internalGrade = $subject->regularMarkDetails->internalGrade; | |
if( $subject->excludeSubjectFromTotal == "1" && $subject->subjectTypeCode == "AUDIT_COURSE"){ | |
$subject->subjectTypeCodeConst = "A"; | |
$term->auditCources[] = $subject; | |
} | |
else{ | |
$subject->subjectTypeCodeConst = in_array($subject->subjectTypeCode,$includedSubjectTypes) ? substr($subject->subjectTypeCode,0,1) : ''; | |
$term->remainingSubjects[] = $subject; | |
} | |
$termSubjectCategories["SC$subject->categoryId"]->name = $subject->displayCategoryName; | |
$termSubjectCategories["SC$subject->categoryId"]->credit += $subject->markDetails->credit; | |
$termSubjectCategories["SC$subject->categoryId"]->gradePoint += $subject->markDetails->gradePoint; | |
$termSubjectCategories["SC$subject->categoryId"]->creditPoint += $subject->creditPoint; | |
$markListSubjectCategoriesData["SC$subject->categoryId"]->id = $subject->categoryId; | |
$markListSubjectCategoriesData["SC$subject->categoryId"]->name = $subject->displayCategoryName; | |
$markListSubjectCategoriesData["SC$subject->categoryId"]->credit += $subject->markDetails->credit; | |
$markListSubjectCategoriesData["SC$subject->categoryId"]->gradePoint += $subject->markDetails->gradePoint; | |
$markListSubjectCategoriesData["SC$subject->categoryId"]->creditPoint += $subject->creditPoint; | |
if ($student->courseType == 'PG') { | |
$subject->examMonthYear = date('M Y',strtotime($subject->markDetails->latestExamYear."-".$subject->markDetails->latestExamMonth."-01")); | |
} | |
} | |
$term->subjects = $term->remainingSubjects; | |
$term->sgpa = round($term->markDetails->rawSgpa, $student->roundOff); | |
$term->sgpa = sprintf('%0.2f', $term->sgpa); | |
$term->termSubjectCategories = $termSubjectCategories; | |
} | |
$barcodeVar =$student->regNo; | |
$barcodeObj = new TCPDFBarcode($barcodeVar, 'C128'); | |
$student->barcodeObj = $barcodeObj->getBarcodeHTML($w = 1, $h = 30, $color = 'black'); | |
$student->markListSubjectCategories = $markListSubjectCategoriesData; | |
} | |
// 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/Template15/$templateName.twig"), [ 'data'=>$data ]); | |
$prtContent = NULL; | |
if($response->isStudentSideExamResult){ | |
$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' => "5mm", | |
'margin-left' => "15mm", | |
'margin-right' => "15mm", | |
'margin-bottom' => "5mm", | |
// 'binary' => "/usr/local/bin/wkhtmltopdf", // For Mac | |
'user-style-sheet' => realpath(DOCUMENT_ROOT . "/libcommon/bootstrap/css/bootstrap.min.css") | |
); | |
} | |
else{ | |
$prtContent .= '<html><head>'; | |
$prtContent .= "<style> | |
.subpage-1 {padding-top:5cm;} | |
.subpage-2 {padding-top:2cm;} | |
</style>"; | |
$prtContent .= '</head><title>Consolidated Marks Card</title><body>'; | |
$prtContent .= $responseHtml; | |
$prtContent .= '</body></html>'; | |
$totalWidth = 210; | |
$totalHeight = 300; | |
$options = array( | |
'page-width' => $totalWidth."mm", | |
'page-height' => $totalHeight."mm", | |
'dpi' => 96, | |
'margin-top' => "5mm", | |
'margin-left' => "0.7cm", | |
'margin-right' => "0.7cm", | |
'margin-bottom' => "5mm", | |
// 'binary' => "/usr/local/bin/wkhtmltopdf", // For Mac | |
'user-style-sheet' => realpath(DOCUMENT_ROOT . "/libcommon/bootstrap/css/bootstrap.min.css") | |
); | |
} | |
$responseHtml .= "<style> | |
.print-footer { position: absolute;bottom: 0cm; }</style>"; | |
$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; | |
} | |
} |