Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 306 |
Template6TranscriptResultGenerator | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
5256.00 | |
0.00% |
0 / 306 |
__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 |
4692.00 | |
0.00% |
0 / 265 |
|||
renderTranscriptMarkCardResult | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 38 |
<?php | |
// Template For SCEK Colleges | |
namespace com\linways\ec\core\service\TranscriptMarkCardGenerator; | |
use com\linways\ec\core\service\StudentMarkListService; | |
use com\linways\ec\core\service\TranscriptMarkCardGenerator\TranscriptMarkCardResultDataGenerator; | |
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\core\ams\professional\service\StudentService; | |
use com\linways\core\ams\professional\constant\examcontroller\CourseTypeConstants; | |
use com\linways\ec\core\service\ExamRegistrationService; | |
use com\linways\ec\core\request\SearchExamRegistrationRequest; | |
use com\linways\ec\core\service\ExamRegistrationBatchService; | |
use com\linways\ec\core\request\SearchExamRegistrationBatchRequest; | |
use com\linways\core\ams\professional\constant\ExamType; | |
use com\linways\core\ams\professional\service\AmsCustomFieldsService; | |
use com\linways\core\ams\professional\constant\AmsCustomFieldsEntities; | |
use com\linways\core\ams\professional\service\academic\AcademicTermService; | |
use com\linways\core\ams\professional\request\academic\SearchAcademicTermRequest; | |
use com\linways\ec\core\service\GradeSchemeService; | |
class Template6TranscriptResultGenerator extends TranscriptMarkCardResultDataGenerator | |
{ | |
public function __construct(){} | |
/** | |
* get Template Name | |
* @param $request | |
* @param $templateName | |
*/ | |
protected function getTemplateName($request){ | |
$templateName = "template_6_BTECH_Transcript"; | |
return $templateName; | |
} | |
/** | |
* Process Student data college base | |
* @param $request | |
*/ | |
protected function processData($request){ | |
// to fetch all Special exam assigned for this batch | |
$requestForSpecialExam = new \stdClass; | |
$requestForSpecialExam->isSpecialExamRegistration = true; | |
$requestForSpecialExam->groupId = $request->groupId; | |
$allSupplementaryExamRegistrations = (array) ExamRegistrationService::getInstance()->searchExamRegistrationByOtherDetails($requestForSpecialExam); | |
$allSupplementaryExamRegistrationIds = array_column($allSupplementaryExamRegistrations,'id'); | |
// get all students credit points | |
$requestForActivityPoints = new \stdClass; | |
$requestForActivityPoints->groupId = $request->groupId; | |
$requestForActivityPoints->studentId = $request->studentId; | |
$studentActivityPoints = CommonExamService::getInstance()->getStudentsActivityPoints($requestForActivityPoints); | |
$response = new \stdClass; | |
$searchRequest = new \stdClass; | |
$request->excludeMinorHonor = 1; | |
$response->studentData = reset(MarksCardService::getInstance()->getConsoliidatedMarksCardData($request))->students; | |
uasort($response->studentData, function ($a, $b) { | |
return $a->regNo > $b->regNo; | |
}); | |
// to fetch Mionor Subject Details | |
$request->excludeMinorHonor = false; | |
$request->consoiderHonoursSubjects = false; | |
$request->consoiderMinorSubjects = 1; | |
$response->minorStudentData = reset(MarksCardService::getInstance()->getConsoliidatedMarksCardData($request))->students; | |
// to fetch Honour Subject Details | |
$request->excludeMinorHonor = false; | |
$request->consoiderMinorSubjects = false; | |
$request->consoiderHonoursSubjects = 1; | |
$response->honoursStudentData = reset(MarksCardService::getInstance()->getConsoliidatedMarksCardData($request))->students; | |
$courseType = reset($response->studentData)->courseType; | |
$batchStartYear = reset($response->studentData)->admissionYear; | |
foreach ($response->studentData as $studentId => $student){ | |
$uniqueNoReq = new \stdClass; | |
$uniqueNoReq->studentId = $student->studentId; | |
$uniqueNoReq->groupId = $student->groupsId; | |
$uniqueNoReq->type = 'TRANSCRIPT'; | |
$student->slNo = CommonExamService::getInstance()->getStudentBatchUniqueNumber($uniqueNoReq)->uniqueNo; | |
if ($student->slNo) { | |
$student->slNo = str_pad($student->slNo, 3, "0", STR_PAD_LEFT); | |
} | |
$student->serialNo = "SCE/COE/".date('y').'/'.date('m').'/'.$student->slNo; | |
if ($student->gender == "MALE"){ | |
$student->salutation = "Mr."; | |
} | |
else{ | |
$student->salutation = "Ms."; | |
} | |
$student->properties = json_decode($student->properties); | |
$student->batchEndYear = $student->properties->endYear; | |
$student->batchStartYear = $student->properties->startYear; | |
$student->studentImage = StudentService::getInstance()->getStudentProfilePic($student->studentId)->docpath; | |
$student->dobFullName = $student->dob ? date('d-F-Y',strtotime($student->dob)) : ''; | |
$student->dob = $student->dob ? date("d/m/Y", strtotime($student->dob)) : ''; | |
$batchDetails = json_decode($student->properties); | |
$student->courseCompleteWithinYear = 1; | |
$finalSem = $batchDetails->finalTermId; | |
$student->finalSem = $batchDetails->finalTermId; | |
$lastAcademicTerm = reset(array_filter( $student->academicTerms ,function($value)use($finalSem){ | |
return $value->termId == $finalSem; | |
})); | |
foreach ($student->academicTerms as $key => $semMark){ | |
$totalMarkMinimum = 0; | |
$semesterNames = CommonExamService::getInstance()->getDifferentSemesterName($semMark->termName); | |
$semMark->semInRomanLetter = $semesterNames->romanLetter; | |
$semMark->semInFullName = $semesterNames->fullName; | |
if ($semMark->failedStatus != 'FAILED') { | |
$sgpa = round($semMark->sgpa, 2); | |
$sgpa = sprintf('%0.2f', $sgpa); | |
} | |
$semMark->sgpa = $sgpa; | |
uasort($semMark->subject, function ($a, $b) { | |
return $a->subjectOrder > $b->subjectOrder; | |
}); | |
} | |
$student->minorSubjects = []; | |
$student->honoursSubjects = []; | |
$student->isPassAllMinorSubjects = true; | |
$student->studentMinorCredits = 0; | |
$student->studentHonoursCredits = 0; | |
$minorDetails = $response->minorStudentData[$studentId]; | |
$student->isPassAllHonourSubjects = true; | |
$honoursDetails = $response->honoursStudentData[$studentId]; | |
// check conditions for eligible minor certificate and eligible minor subjects | |
// if the certificate is verified then that subject become passed (Grade P )in case of MOOC subject | |
foreach ($minorDetails->academicTerms as $minorTermId) { | |
foreach ($minorTermId->subjects as $minorSubject) { | |
if($minorSubject->isMoocSubject == '1'){ | |
if($minorSubject->moocVerificationStatus == 'APPROVED'){ | |
$minorSubject->examMonthYearFormat2 = date('M Y',strtotime($minorSubject->markDetails->latestExamYear."-".$minorSubject->markDetails->latestExamMonth."-01")); | |
$minorSubject->credit = $minorSubject->markDetails->credit; | |
$student->studentMinorCredits = $student->studentMinorCredits + (float)$minorSubject->credit; | |
$minorSubject->isMooc = $minorSubject->isMoocSubject == '1' ? 1 : 0; | |
$minorSubject->grade = "P"; | |
$minorSubject->failedStatus = "PASSED"; | |
$student->minorSubjects[] = $minorSubject; | |
} | |
else{ | |
$student->isPassAllMinorSubjects = false; | |
} | |
} | |
else{ | |
if($minorSubject->failedStatus == 'FAILED'){ | |
$student->isPassAllMinorSubjects = false; | |
} | |
else{ | |
$minorSubject->examMonthYearFormat2 = date('M Y',strtotime($minorSubject->markDetails->latestExamYear."-".$minorSubject->markDetails->latestExamMonth."-01")); | |
$minorSubject->credit = $minorSubject->markDetails->credit; | |
$student->studentMinorCredits = $student->studentMinorCredits + (float)$minorSubject->credit; | |
$minorSubject->isMooc = $minorSubject->isMoocSubject == '1' ? 1 : 0; | |
$student->minorSubjects[] = $minorSubject; | |
} | |
} | |
} | |
} | |
// check conditions for eligible honours certificate and eligible honours subjects | |
// check all with exclude mooc subject having gradepont greate than or egual to 6.5 then will be pass otherwise not eligible for Honours degree | |
// if subject is passed then get credit of the subject | |
// if the certificate is verified then that subject become passed (Grade P ) in case of MOOC subject | |
// 6.5 -> grade pont of C grade (as per college rule) | |
foreach ($honoursDetails->academicTerms as $honoursTermId) { | |
foreach ($honoursTermId->subjects as $honoursSubject) { | |
if($honoursSubject->isMoocSubject == '1'){ | |
if($honoursSubject->moocVerificationStatus == 'APPROVED'){ | |
$honoursSubject->examMonthYearFormat2 = date('M Y',strtotime($honoursSubject->markDetails->latestExamYear."-".$honoursSubject->markDetails->latestExamMonth."-01")); | |
$honoursSubject->credit = $honoursSubject->markDetails->credit; | |
$student->studentHonoursCredits = $student->studentHonoursCredits + (float)$honoursSubject->credit; | |
$honoursSubject->isMooc = $honoursSubject->isMoocSubject == '1' ? 1 : 0; | |
$honoursSubject->grade = "P"; | |
$honoursSubject->failedStatus = "PASSED"; | |
$student->honoursSubjects[] = $honoursSubject; | |
} | |
else{ | |
$student->isPassAllHonourSubjects = false; | |
} | |
} | |
else{ | |
if((float)$honoursSubject->markDetails->gradePoint >= 6.5){ | |
$honoursSubject->examMonthYearFormat2 = date('M Y',strtotime($honoursSubject->markDetails->latestExamYear."-".$honoursSubject->markDetails->latestExamMonth."-01")); | |
$honoursSubject->credit = $honoursSubject->markDetails->credit; | |
$student->studentHonoursCredits = $student->studentHonoursCredits + (float)$honoursSubject->credit; | |
$student->honoursSubjects[] = $honoursSubject; | |
} | |
else{ | |
$student->isPassAllHonourSubjects = false; | |
if($honoursSubject->failedStatus == "PASSED"){ | |
$honoursSubject->examMonthYearFormat2 = date('M Y',strtotime($honoursSubject->markDetails->latestExamYear."-".$honoursSubject->markDetails->latestExamMonth."-01")); | |
$honoursSubject->credit = $honoursSubject->markDetails->credit; | |
$student->studentHonoursCredits = $student->studentHonoursCredits + (float)$honoursSubject->credit; | |
$student->honoursSubjects[] = $honoursSubject; | |
} | |
} | |
} | |
} | |
} | |
} | |
foreach ($response->studentData as $studentId => $student) { | |
$student->nonAcademicsCredits = 0; | |
$student->totalEarnedCredit = 0; | |
if(!empty($studentActivityPoints[$student->studentId])){ | |
if($studentActivityPoints[$student->studentId]->activityPoint >= 100){ | |
$student->nonAcademicsCredits = '2.00'; | |
$student->totalEarnedCredit = 2; | |
} | |
} | |
$customFields = AmsCustomFieldsService::getInstance()->getAmsCustomFieldValue(AmsCustomFieldsEntities::STUDENT, $student->studentId, []); | |
if( $customFields ){ | |
$student->ktuCode = CommonExamService::getInstance()->getCustomFieldObjectList($customFields)->studentData->KTU_CODE; | |
} | |
$student->lastExamMonthYear = $student->markDetails->latestExamMonth ? date("F Y", strtotime("01-". $student->markDetails->latestExamMonth."-".$student->markDetails->latestExamYear)) : ""; | |
$student->credit = $student->markDetails->credit; | |
$student->roundOff = 2; | |
$student->cgpa = round($student->markDetails->rawCgpa, $student->roundOff); | |
$student->class = $student->markDetails->class; | |
$student->cgpaInWords = CommonUtil::convertNumberToWords($student->cgpa); | |
$student->cgpa = sprintf('%0.2f', $student->cgpa); | |
$student->creditInWords = CommonUtil::convertNumberToWords($student->markDetails->credit); | |
foreach ($student->academicTerms as $term) { | |
$term->credit = $term->markDetails->credit; | |
$additionalCreditRequest = new \stdClass; | |
$additionalCreditRequest->studentId = $student->studentId; | |
$additionalCreditRequest->academicTermId = $term->termId; | |
$additionalCreditRequest->groupId = $student->groupsId; | |
$additionalCreditRequest->creditType = "CREDIT_TRANSFERED"; | |
$additionalCredit = CommonExamService::getInstance()->getStudentAdditionalCredits($additionalCreditRequest); | |
$term->semCredit = 0; | |
$term->transferredCredit = (int)$additionalCredit->credit ? $additionalCredit->credit : 0; | |
$term->semCredit += $term->transferredCredit; | |
$student->totalEarnedCredit += $term->transferredCredit; | |
foreach ($term->subjects as $subject) { | |
$subject->examMonthYear = date('F Y',strtotime($subject->markDetails->latestExamYear."-".$subject->markDetails->latestExamMonth."-01")); | |
$subject->examMonthYearFormat2 = date('M Y',strtotime($subject->markDetails->latestExamYear."-".$subject->markDetails->latestExamMonth."-01")); | |
$subject->credit = $subject->markDetails->credit; | |
$subject->isElective = $subject->subjectCategoryCode == 'ELECTIVE' ? 1 : 0; | |
if( $subject->failedStatus == "PASSED" ){ | |
$term->semCredit += $subject->credit; | |
$student->totalEarnedCredit += $subject->credit; | |
} | |
if($subject->markDetails->excludeSubjectFromTotal == '1'){ | |
$subject->grade = $subject->failedStatus == "PASSED" ? 'P' : 'F' ; | |
} | |
} | |
} | |
//For QR code generation | |
if($student->failedStatus == 'FAILED'){ | |
$student->qrData = $student->regNo . " | " . $student->name; | |
}else{ | |
$student->qrData = $student->regNo . " | " . $student->name . " | CGPA - " . $student->cgpa; | |
} | |
if( $student->isPassAllMinorSubjects){ | |
if(empty($student->minorSubjects)){ | |
$student->isPassAllMinorSubjects = false; | |
} | |
elseif($student->studentMinorCredits < 20){ | |
$student->isPassAllMinorSubjects = false; | |
} | |
} | |
if( $student->isPassAllHonourSubjects){ | |
// ---------------- Check Honour Passing Criteria -------------------- | |
// 1.Currently Pass OverAll Subject And get cgpa >= 8.5 | |
// 2.Pass All Subjects in honurs with credit atleast 20 | |
// 3.No backlogs (Supply) not consider backlog as special and revaluation | |
if(empty($student->honoursSubjects)){ | |
$student->isPassAllHonourSubjects = false; | |
} | |
elseif($student->studentHonoursCredits < 20){ | |
$student->isPassAllHonourSubjects = false; | |
} | |
else if($student->failedStatus == 'FAILED' || ($student->cgpa < 8.5)){ | |
$student->isPassAllHonourSubjects = false; | |
} | |
else{ | |
foreach ($student->academicTerms as $term) { | |
foreach ($term->subjects as $subject) { | |
if(count($subject->markHistory) >= 2 && !empty($allSupplementaryExamRegistrationIds)){ | |
$specialExamSubject = reset(array_filter($subject->markHistory,function($value)use($allSupplementaryExamRegistrationIds){ | |
return in_array($value->examRegistrationId, $allSupplementaryExamRegistrationIds); | |
})); | |
$revaluationExamHistory = reset(array_filter($subject->markHistory,function($value)use($allSupplementaryExamRegistrationIds){ | |
return $value->examMarkType == 'REVALUATION'; | |
})); | |
if(!empty($specialExamSubject)){ | |
$subject->markHistory = array_filter($subject->markHistory,function($value)use($allSupplementaryExamRegistrationIds){ | |
return $value->examMarkType != 'REGULAR'; | |
}); | |
} | |
if(!empty($revaluationExamHistory)){ | |
$subject->markHistory = array_filter($subject->markHistory,function($value)use($allSupplementaryExamRegistrationIds){ | |
return $value->examMarkType != 'REGULAR'; | |
}); | |
} | |
if (count($subject->markHistory) >= 2) { | |
$student->isPassAllHonourSubjects = false; | |
break; | |
} | |
} | |
} | |
} | |
} | |
} | |
if ( $request->filterSettings['showMinorMarksCard'] && $request->filterSettings['showHonoursMarksCard']){ | |
if(empty($student->minorSubjects) || empty($student->honoursSubjects) || !$student->isPassAllHonourSubjects || !$student->isPassAllMinorSubjects){ | |
unset($response->studentData[$studentId]); | |
} | |
} | |
else if ( $request->filterSettings['showMinorMarksCard'] ){ | |
if( empty($student->minorSubjects) || !$student->isPassAllMinorSubjects || !empty($student->honoursSubjects)){ | |
unset($response->studentData[$studentId]); | |
} | |
} | |
else if ( $request->filterSettings['showHonoursMarksCard'] ){ | |
if( empty($student->honoursSubjects) || !$student->isPassAllHonourSubjects || !empty($student->minorSubjects)){ | |
unset($response->studentData[$studentId]); | |
} | |
} | |
} | |
if(empty($response->studentData)){ | |
throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
} | |
$response->showHonoursMarksCard = $request->filterSettings['showHonoursMarksCard']; | |
$response->showMinorMarksCard = $request->filterSettings['showMinorMarksCard']; | |
$response->disableCollegeRegisterNumber = false; | |
if($batchStartYear >= '2023'){ | |
$response->disableCollegeRegisterNumber = true; | |
} | |
$response->collegeData = CommonExamService::getInstance()->getCollegeDetails(); | |
$response->dateOfIssue = $request->filterSettings['markListDate']?: date("d/m/Y"); | |
$response->dateOfIssueWithMonthName = $request->filterSettings['markListDate'] ? date('d-F-Y',strtotime($request->filterSettings['markListDate'])) : date("d-F-Y"); | |
return $response; | |
} | |
/** | |
* Render Program Result | |
* | |
* @param $templateName | |
* @param Object $data | |
* @return Object | |
*/ | |
protected function renderTranscriptMarkCardResult($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/Transcript/Template6/$templateName.twig"), [ 'data'=>$data ]); | |
$footerHtml = TwigRenderer::renderTemplateFileToHtml(realpath(DOCUMENT_ROOT."../examcontroller-api/src/com/linways/web/templates/Transcript/Template6/template_6_footer.twig"),[]); | |
$prtContent = NULL; | |
$prtContent .= '<html><head>'; | |
$prtContent .= "<style> | |
.extraStyle{ | |
margin-top:0px; | |
} | |
.page-a4 { | |
margin-right:10mm !important; | |
} | |
</style>"; | |
$prtContent .= '</head><title>Consolidated Marks Card</title><body>'; | |
$prtContent .= $responseHtml; | |
$prtContent .= '</body></html>'; | |
$width = 210; | |
$height = 297; | |
$options = array( | |
'page-width' => $width."mm", | |
'page-height' => $height."mm", | |
'dpi' => 490, | |
'margin-top' => "10mm", | |
'margin-left' => "0mm", | |
'margin-right' => "0mm", | |
'margin-bottom' => "30mm", | |
'footer-html' => $footerHtml, | |
// '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; | |
} | |
} | |
} |