Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 229 |
Template2SupplementaryTabulationRegisterGenerator | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
1190.00 | |
0.00% |
0 / 229 |
__construct | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getTemplateName | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 18 |
|||
processData | |
0.00% |
0 / 1 |
72.00 | |
0.00% |
0 / 52 |
|||
renderSupplementaryTabulationRegisterResult | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 29 |
|||
processStudentDataForTabulationRegister | |
0.00% |
0 / 1 |
380.00 | |
0.00% |
0 / 130 |
<?php | |
// Template Supply TR Generator For MES VIMALA STJOSEPH Collages | |
namespace com\linways\ec\core\service\SupplementaryTabulationRegisterGenerator; | |
use com\linways\ec\core\service\StudentMarkListService; | |
use com\linways\ec\core\service\TabulationRegisterService; | |
use com\linways\ec\core\service\ExamRegistrationService; | |
use com\linways\ec\core\exception\ExamControllerException; | |
use com\linways\base\util\TwigRenderer; | |
use com\linways\core\ams\professional\util\PdfUtil; | |
use com\linways\ec\core\service\CommonExamService; | |
use com\linways\ec\core\service\GradeSchemeService; | |
use com\linways\core\ams\professional\util\CommonUtil; | |
use com\linways\ec\core\service\SupplementaryTabulationRegisterGenerator\SupplementaryTabulationRegisterResultDataGenerator; | |
class Template2SupplementaryTabulationRegisterGenerator extends SupplementaryTabulationRegisterResultDataGenerator{ | |
public function __construct(){} | |
protected function getTemplateName($request){ | |
$templateName = "template_1_ug"; | |
$examRegistrationDetails = new \stdClass; | |
$examRegistrationDetailsArray = ExamRegistrationService::getInstance()->searchDetailedExamRegistrationDetails($request); | |
if(empty($examRegistrationDetailsArray)){ | |
throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
} | |
$examRegistrationDetails->courseTypeName = $examRegistrationDetailsArray[0]->groups[0]->courseTypeName; | |
if($examRegistrationDetails->courseTypeName == "UG"){ | |
$templateName = "template_2_ug"; | |
} | |
else if($examRegistrationDetails->courseTypeName == "PG"){ | |
$templateName = "template_2_pg"; | |
} | |
else{ | |
$templateName = "template_2_ug"; | |
} | |
return $templateName; | |
} | |
/** | |
* Process Student data college base | |
* | |
* @param $request | |
*/ | |
protected function processData($request){ | |
$response = new \stdClass; | |
$studentsMarkDetails = []; | |
$examRegistrationData = TabulationRegisterService::getInstance()->getExamRegistrationDetailsForTabulationRegisterReports($request); | |
$examRegistrationData->totalCredit = 0; | |
$examRegistrationData->programName = $examRegistrationData->degreeName.' '.$examRegistrationData->streamName; | |
$examRegistrationData->academicExamYear = ( $examRegistrationData->examYear - 1) . "-" . $examRegistrationData->examYear; | |
if((int)$examRegistrationData->semInSemNumber % 2){ | |
$examRegistrationData->academicExamYear = $examRegistrationData->examYear . "-" . ( $examRegistrationData->examYear + 1); | |
} | |
$searchRequest = new \stdClass; | |
$searchRequest->fetchAllSemesterDetails = $examRegistrationData->isFinalSemester ? true : false; | |
$searchRequest->considerSupplementary = true; | |
$searchRequest->studentId = $request->studentId; | |
$searchRequest->groupId = $request->groupId; | |
$searchRequest->examRegistrationId = $request->examRegistrationId; | |
$searchRequest->academicTermId = $request->academicTermId; | |
$searchRequest->considerGraceMark = true; | |
$searchRequest->supplementaryMonthUpperLimit = $examRegistrationData->examMonth; | |
$searchRequest->supplementaryYearUpperLimit = $examRegistrationData->examYear; | |
if($examRegistrationData->isFinalSemester){ | |
$allSemesterDetails = CommonExamService::getInstance()->getAllAcademicTermsDetailsByBatch($searchRequest); | |
$allSemesterDetails = array_filter($allSemesterDetails,function($academicTerm)use($examRegistrationData) { | |
if($examRegistrationData->academicTermId != $academicTerm->id){ | |
return $academicTerm; | |
} | |
}); | |
uasort($allSemesterDetails, function($a, $b) { | |
return ($a->orderNo > $b->orderNo); | |
}); | |
$response->allSemesterDetails = $allSemesterDetails; | |
} | |
$studentsMarkDetails = TabulationRegisterService::getInstance()->getAllRegistredStudentMarkDetailsForTabulationRegister($searchRequest); | |
if(empty($studentsMarkDetails)){ | |
throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
} | |
$gradeSchemes = GradeSchemeService::getInstance()->getAllExamRegistrationGradeSchemes($request); | |
array_walk($gradeSchemes,function($gradeScheme,$key){ | |
$gradeScheme->properties = json_decode($gradeScheme->properties); | |
$gradeScheme->rangeFrom = $gradeScheme->range_from; | |
$gradeScheme->rangeTo = $gradeScheme->range_to; | |
$gradeScheme->className = $gradeScheme->properties->class; | |
}); | |
$response->gradeSchemes = $gradeSchemes; | |
$studentsMarkDetails = $this->processStudentDataForTabulationRegister($studentsMarkDetails,$searchRequest,$examRegistrationData); | |
$response->studentData = $studentsMarkDetails->studentsDetails; | |
foreach($studentsMarkDetails->displaySubjects as $subject){ | |
$examRegistrationData->totalCredit += (int)$subject->credit; | |
} | |
$response->examRegistrationData = $examRegistrationData ; | |
$response->examRegistrationData->subjects = $studentsMarkDetails->displaySubjects; | |
$response->collegeData = CommonExamService::getInstance()->getCollegeDetails(); | |
$response->displayContentOptions = $request->displayContentOptions; | |
$response->isPrint = $request->isPrint ? true : false; | |
return $response; | |
} | |
/** | |
* Render Program Result | |
* | |
* @param $templateName | |
* @param Object $data | |
* @return Object | |
*/ | |
protected function renderSupplementaryTabulationRegisterResult($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/TablationRegister/SupplyTR/Template2/$templateName.twig"), [ 'data'=>$data ]); | |
$prtContent = NULL; | |
$prtContent .= '<html><head>'; | |
$prtContent .= ""; | |
$prtContent .= '</head><title>Consolidated MarkList</title><body>'; | |
$prtContent .= $responseHtml; | |
$prtContent .= '</body></html>'; | |
$totalWidth = 210; | |
$totalHeight = 297; | |
$options = array( | |
'page-width' => $totalHeight."mm", | |
'page-height' => $totalWidth."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; | |
} | |
} | |
/** | |
* processStudentDataForTabulationRegister | |
* @param studentDetails | |
* @return studentDetails | |
* @author Krishnajith | |
*/ | |
public function processStudentDataForTabulationRegister($studentMarkDetails,$request,$examRegistrationDetails = null){ | |
try{ | |
$response = new \stdClass; | |
$displaySubjectArray = []; | |
$studentsDetails = []; | |
$isCurrentSemester = true; | |
foreach($studentMarkDetails as $student){ | |
$studentsDetails[$student->id]->id = $student->id; | |
$studentsDetails[$student->id]->name = $student->studentDetails->name; | |
$studentsDetails[$student->id]->cgpa = $student->cgpa; | |
$studentsDetails[$student->id]->grade = $student->grade; | |
$studentsDetails[$student->id]->myImage = $student->studentDetails->myImage; | |
$studentsDetails[$student->id]->registerNo = $student->studentDetails->registerNo; | |
$studentsDetails[$student->id]->rollNo = $student->studentDetails->rollNo; | |
$studentsDetails[$student->id]->roundOff = $student->studentDetails->academicYear < 2019 ? 2 : 3; | |
foreach($student->academicTerms as $academicTerm){ | |
if($request->fetchAllSemesterDetails){ | |
$isCurrentSemester = $examRegistrationDetails->academicTermId == $academicTerm->id ? true : false; | |
} | |
if($isCurrentSemester){ | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->id = $academicTerm->id; | |
$semesterNames = CommonExamService::getInstance()->getDifferentSemesterName($academicTerm->name); | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semInRomanLetter = $semesterNames->romanLetter; | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semInFullName = $semesterNames->fullName; | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semInSemNumber = $semesterNames->semNumber; | |
array_walk($academicTerm->markHistory,function($semMarkHistory) use($studentsDetails,$request,$student,$academicTerm){ | |
if($semMarkHistory->examRegistrationId == $request->examRegistrationId){ | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->failedStatus = $semMarkHistory->failedStatus; | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterGrade = $semMarkHistory->grade; | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterCredit = $academicTerm->credit; | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterCreditGradePoint = $semMarkHistory->creditGradePoint; | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->examMonth = $semMarkHistory->examMonth; | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->examYear = $semMarkHistory->examYear; | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterCreditPoint = $semMarkHistory->creditPoint; | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterSgpa = round($semMarkHistory->sgpa, $studentsDetails[$student->id]->roundOff); | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterTotalMarks = $academicTerm->totalMarks; | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterMarkObtained = $semMarkHistory->totalMark; | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterMarkObtainedInWord = strtoupper(CommonUtil::convertNumberToWords($semMarkHistory->totalMark))." ONLY"; | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterPercentage = round($semMarkHistory->percentage,2); | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterClass = $semMarkHistory->class; | |
$studentsDetails[$student->id]->overallClass = $semMarkHistory->class; | |
$studentsDetails[$student->id]->overallGrade= $semMarkHistory->grade; | |
$studentsDetails[$student->id]->failedStatus = $semMarkHistory->failedStatus; | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->examType = $semMarkHistory->historyType; | |
} | |
}); | |
foreach($academicTerm->subjects as $subject){ | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id] = $subject; | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->percentage = round($subject->percentage,2); | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->totalMaxMark = $subject->totalMarks; | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->markObtainedInWord = strtoupper(CommonUtil::convertNumberToWords((int)$subject->markObtained)); | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjectCategories[$subject->categoryId]->categoryId = $subject->categoryId; | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjectCategories[$subject->categoryId]->categoryName = $subject->categoryName; | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjectCategories[$subject->categoryId]->subjects[$subject->id] = $subject; | |
$displaySubjectArray[$subject->id] = $subject; | |
} | |
$studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterCreditGradePoint = array_sum(array_column($studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects,'creditGradePoint')); | |
} | |
else{ | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->id = $academicTerm->id; | |
$semesterNames = CommonExamService::getInstance()->getDifferentSemesterName($academicTerm->name); | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semInRomanLetter = $semesterNames->romanLetter; | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semInFullName = $semesterNames->fullName; | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semInSemNumber = $semesterNames->semNumber; | |
if($request->supplementaryMonthUpperLimit && $request->supplementaryYearUpperLimit){ | |
$lastSemMonthYear = date("Y-m", strtotime($request->supplementaryYearUpperLimit . "-" . $request->supplementaryMonthUpperLimit)); | |
$tempMonthYear = ""; | |
$currentMonthYear = ""; | |
array_walk($academicTerm->markHistory,function($term,$key)use($student,$academicTerm,$studentsDetails,$lastSemMonthYear,$tempMonthYear,$currentMonthYear){ | |
if($lastSemMonthYear > date("Y-m", strtotime($term->examYear . "-" . $term->examMonth))){ | |
$currentMonthYear = date("Y-m", strtotime($term->examYear . "-" . $term->examMonth)); | |
if($currentMonthYear > $tempMonthYear){ | |
$tempMonthYear = $currentMonthYear; | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->failedStatus = $term->failedStatus; | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->examMonth = $term->examMonth; | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->examYear = $term->examYear; | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterGrade = $term->grade; | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterCredit = $term->credit; | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterCreditGradePoint = $term->gradePoint; | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterSgpa = round($term->sgpa, $studentsDetails[$student->id]->roundOff); | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterMarkObtained = $term->markObtained; | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterMarkObtainedInWord = strtoupper(CommonUtil::convertNumberToWords($term->markObtained))." ONLY"; | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterPercentage = round($term->percentage,2); | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterClass = $term->class; | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->examType = $term->historyType; | |
} | |
} | |
}); | |
} | |
else{ | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->failedStatus = $academicTerm->isFailed; | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterGrade = $academicTerm->grade; | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterCredit = $academicTerm->credit; | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterCreditGradePoint = $academicTerm->gradePoint; | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterSgpa = round($academicTerm->sgpa, $studentsDetails[$student->id]->roundOff); | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterMarkObtained = $academicTerm->markObtained; | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterMarkObtainedInWord = strtoupper(CommonUtil::convertNumberToWords($academicTerm->markObtained))." ONLY"; | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterPercentage = round($academicTerm->percentage,2); | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterClass = $academicTerm->class; | |
$studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->examType = $academicTerm->historyType; | |
} | |
} | |
} | |
if(count($student->academicTerms) > 1){ | |
$studentsDetails[$student->id]->overallClass = $student->class; | |
$studentsDetails[$student->id]->overallGrade= $student->grade; | |
$studentsDetails[$student->id]->failedStatus = $student->isFailed; | |
} | |
} | |
$displaySubjectArray = array_values($displaySubjectArray); | |
foreach($studentsDetails as $student){ | |
$student->academicTerms = array_values($student->academicTerms); | |
$student->otherAcademicTerms = array_values($student->otherAcademicTerms); | |
foreach($student->academicTerms as $academicTerm){ | |
$academicTerm->subjects = array_values($academicTerm->subjects); | |
$academicTerm->subjectCategories = array_values($academicTerm->subjectCategories); | |
foreach($academicTerm->subjectCategories as $subCategory){ | |
$subCategory->subjects = array_values($subCategory->subjects); | |
$subCategory->totaCategoryAwardedMark = 0; | |
foreach($subCategory->subjects as $subject){ | |
$subCategory->totaCategoryAwardedMark += $subject->internalMark + $subject->externalMark; | |
} | |
} | |
} | |
} | |
$response->studentsDetails = $studentsDetails; | |
$response->displaySubjects = $displaySubjectArray; | |
return $response; | |
} | |
catch (\Exception $e){ | |
throw new ExamControllerException($e->getCode(),$e->getMessage()); | |
} | |
} | |
} | |