Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 271 |
Template5FCMC | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
4160.00 | |
0.00% |
0 / 271 |
__construct | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getTemplateName | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 22 |
|||
processData | |
0.00% |
0 / 1 |
2450.00 | |
0.00% |
0 / 173 |
|||
renderTemplate | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 40 |
|||
getsecondLanguageName | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
getopenCourseName | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 27 |
<?php | |
// MBCET College | |
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\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\ec\core\service\StudentMarkListService; | |
class Template5FCMC extends FCMGenerator | |
{ | |
public function __construct(){} | |
protected function getTemplateName($request){ | |
$query = "SELECT | |
ct.course_Type AS courseType, | |
g.properties->>'$.startYear' AS batchStartYear | |
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')"; | |
$courseDetails = $this->executeQueryForObject($query); | |
$courseType = $courseDetails->courseType; | |
$batchStartYear = $courseDetails->batchStartYear; | |
$templateName = 'Template5FCMC'; | |
if ($courseType=="PG" && $batchStartYear >= 2022) { | |
$templateName = "Template5FCMC_PG_2022"; | |
} | |
elseif ($courseType=="PG") { | |
$templateName = "Template5FCMC_PG_2020"; | |
} | |
return $templateName; | |
} | |
/** | |
* Process Student data college base | |
* @param $request | |
*/ | |
protected function processData($request){ | |
$response = new \stdClass; | |
$searchRequest = new \stdClass; | |
$request->considerRegularSubjectsExcludingMinorHonours = 1; | |
$response->studentData = reset(MarksCardService::getInstance()->getConsoliidatedMarksCardData($request))->students; | |
$response->studentMoocData = MarksCardService::getInstance()->getStudentRegisteredMoocSubject($request); | |
uasort($response->studentData, function ($a, $b) { | |
return $a->regNo > $b->regNo; | |
}); | |
$courseType = reset($response->studentData)->courseType; | |
$batchStartYear = reset($response->studentData)->admissionYear; | |
foreach ($response->studentData as $studentId => $student){ | |
$student->studentImage = StudentService::getInstance()->getStudentProfilePic($student->studentId)->docpath; | |
$student->dob = $student->dob ? date("d/m/Y", strtotime($student->dob)) : ''; | |
$batchDetails = json_decode($student->properties); | |
$uniqueNoReq = new \stdClass; | |
$uniqueNoReq->studentId = $student->studentId; | |
$uniqueNoReq->groupId = $student->groupsId; | |
if ( $student->courseType == 'PG'){ | |
$uniqueNoReq->type = 'FINAL_CONSOLIDATED_CERTIFICATE'; | |
} | |
else{ | |
$uniqueNoReq->type = 'FINAL_CONSOLIDATED_CERTIFICATE_UG'; | |
} | |
$student->slNo = CommonExamService::getInstance()->getStudentBatchUniqueNumber($uniqueNoReq)->uniqueNo; | |
if ($student->slNo) { | |
$student->slNo = str_pad($student->slNo, 4, "0", STR_PAD_LEFT); | |
} | |
if ($student->courseType != 'PG' ) { | |
$student->slNo = substr($batchDetails->endYear, -2)."/".$student->slNo; | |
} | |
$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; | |
}); | |
} | |
ksort($semMark); | |
} | |
foreach ($response->studentData as $student) { | |
$customFields = AmsCustomFieldsService::getInstance()->getAmsCustomFieldValue(AmsCustomFieldsEntities::STUDENT, $student->studentId, []); | |
if( $customFields ){ | |
$student->ktuCode = CommonExamService::getInstance()->getCustomFieldObjectList($customFields)->studentData->KTU_CODE; | |
} | |
$studentSubjectRequest = new \stdClass(); | |
$studentSubjectRequest->studentId = $student->studentId; | |
$studentSubjectRequest->examRegistrationType = "REGULAR"; | |
$studentSubjectRequest->isMinorCourse = 1; | |
$minorStudentSubjectHistory = StudentMarkListService::getInstance()->getAllStudentSubjectMarkDetailsByRequest($studentSubjectRequest); | |
$minorSubjectHistory = []; | |
$minorEarnedCredit = 0; | |
foreach($minorStudentSubjectHistory as $studentHistory){ | |
if($minorSubjectHistory[$studentHistory->paperSubjectId]){ | |
if($minorSubjectHistory[$studentHistory->paperSubjectId]->subjectCreditGradePoint < $studentHistory->subjectCreditGradePoint){ | |
if($studentHistory->excludeSubjectFromTotal != 1){ | |
$minorSubjectHistory[$studentHistory->paperSubjectId] = $studentHistory; | |
if($studentHistory->subjectFailedStatus == "PASSED"){ | |
$minorEarnedCredit += $studentHistory->credit; | |
} | |
} | |
else{ | |
// if($studentHistory->subjectFailedStatus == "PASSED"){ | |
$minorSubjectHistory[$studentHistory->paperSubjectId] = $studentHistory; | |
// } | |
} | |
} | |
} | |
else{ | |
if($studentHistory->excludeSubjectFromTotal != 1){ | |
$minorSubjectHistory[$studentHistory->paperSubjectId] = $studentHistory; | |
if($studentHistory->subjectFailedStatus == "PASSED"){ | |
$minorEarnedCredit += $studentHistory->credit; | |
} | |
} | |
else{ | |
// if($studentHistory->subjectFailedStatus == "PASSED"){ | |
$minorSubjectHistory[$studentHistory->paperSubjectId] = $studentHistory; | |
// $earnedCreditForDisplay += $studentHistory->credit; | |
// } | |
} | |
} | |
} | |
$studentSubjectRequest = new \stdClass(); | |
$studentSubjectRequest->studentId = $student->studentId; | |
$studentSubjectRequest->examRegistrationType = "REGULAR"; | |
$studentSubjectRequest->isHonorCourse = 1; | |
$honorStudentSubjectHistory = StudentMarkListService::getInstance()->getAllStudentSubjectMarkDetailsByRequest($studentSubjectRequest); | |
$honorSubjectHistory = []; | |
$honorEarnedCredit = 0; | |
foreach($honorStudentSubjectHistory as $studentHistory){ | |
if($honorSubjectHistory[$studentHistory->paperSubjectId]){ | |
if($honorSubjectHistory[$studentHistory->paperSubjectId]->subjectCreditGradePoint < $studentHistory->subjectCreditGradePoint){ | |
if($studentHistory->excludeSubjectFromTotal != 1){ | |
$honorSubjectHistory[$studentHistory->paperSubjectId] = $studentHistory; | |
if($studentHistory->subjectFailedStatus == "PASSED"){ | |
$honorEarnedCredit += $studentHistory->credit; | |
} | |
} | |
else{ | |
// if($studentHistory->subjectFailedStatus == "PASSED"){ | |
$honorSubjectHistory[$studentHistory->paperSubjectId] = $studentHistory; | |
// } | |
} | |
} | |
} | |
else{ | |
if($studentHistory->excludeSubjectFromTotal != 1){ | |
$honorSubjectHistory[$studentHistory->paperSubjectId] = $studentHistory; | |
if($studentHistory->subjectFailedStatus == "PASSED"){ | |
$honorEarnedCredit += $studentHistory->credit; | |
} | |
} | |
else{ | |
// if($studentHistory->subjectFailedStatus == "PASSED"){ | |
$honorSubjectHistory[$studentHistory->paperSubjectId] = $studentHistory; | |
// $earnedCreditForDisplay += $studentHistory->credit; | |
// } | |
} | |
} | |
} | |
if( $minorEarnedCredit && $student->failedStatus == "PASSED" && $minorEarnedCredit >= 20 && $student->cgpa ){ | |
$student->minorHonours->minor->details->totalCredit = 20;//$studentM->credit; | |
$student->minorHonours->minor->details->creditEarned = $minorEarnedCredit; | |
} | |
if( $honorEarnedCredit && $student->failedStatus == "PASSED" && $honorEarnedCredit >= 20 && $student->cgpa >= 8.5 ){ | |
$student->minorHonours->honours->details->totalCredit = 20;//$studentM->credit; | |
$student->minorHonours->honours->details->creditEarned = $honorEarnedCredit; | |
} | |
$additionalCreditRequest = new \stdClass; | |
$additionalCreditRequest->studentId = $student->studentId; | |
$additionalCreditRequest->academicTermId = $student->finalSem; | |
$additionalCreditRequest->creditType = "ACTIVITY_CREDIT"; | |
$additionalCredit = CommonExamService::getInstance()->getStudentAdditionalCredits($additionalCreditRequest); | |
$student->activityCredit = (int)$additionalCredit->credit ? (int)$additionalCredit->credit : 0; | |
$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->periodOfStudy = $batchDetails->startYear." - ".$batchDetails->endYear; | |
// $student->cgpa = round($student->cgpa, $student->roundOff); | |
$student->cgpa = sprintf('%0.2f', round(($student->markDetails->rawCgpa), 2)); | |
$student->cgpaInWords = ucwords(CommonUtil::convertNumberToWords($student->cgpa)); | |
$student->class = $student->markDetails->class; | |
$student->creditInWords = CommonUtil::convertNumberToWords($student->markDetails->credit); | |
foreach ($student->academicTerms as $term) { | |
$term->credit = $term->markDetails->credit; | |
foreach ($term->subjects as $subject) { | |
if ( $response->studentMoocData[$student->studentId]->subjects[$subject->paperSubjetId] && $response->studentMoocData[$student->studentId]->subjects[$subject->paperSubjetId]->moocCertificateStatus == "APPROVED" ){ | |
$subject->name = $response->studentMoocData[$student->studentId]->subjects[$subject->paperSubjetId]->moocSubjectName ? $response->studentMoocData[$student->studentId]->subjects[$subject->paperSubjetId]->moocSubjectName : $subject->name; | |
$subject->code = $response->studentMoocData[$student->studentId]->subjects[$subject->paperSubjetId]->moocSubjectCode ? $response->studentMoocData[$student->studentId]->subjects[$subject->paperSubjetId]->moocSubjectCode : $subject->code; | |
if( $response->studentMoocData[$student->studentId]->subjects[$subject->paperSubjetId]->moocSubjectMonthYear ){ | |
list($subject->markDetails->latestExamMonth, $subject->markDetails->latestExamYear) = explode('/', $response->studentMoocData[$student->studentId]->subjects[$subject->paperSubjetId]->moocSubjectMonthYear); | |
} | |
} | |
$subject->examMonthYear = date('M Y',strtotime($subject->markDetails->latestExamYear."-".$subject->markDetails->latestExamMonth."-01")); | |
$subject->credit = $subject->markDetails->credit; | |
$subject->attendanceStatus = $subject->markDetails->attendanceStatus; | |
if($subject->excludeSubjectFromTotal == '1'){ | |
$subject->grade = $subject->failedStatus == "PASSED" ? 'P' : 'F' ; | |
} | |
$subject->isElective = $subject->subjectCategoryCode == 'ELECTIVE' ? 1 : 0; | |
if ($subject->isTheory && $student->admissionYear >= 2022) { | |
$subject->showAb = 1; | |
} | |
if ( $response->studentMoocData[$student->studentId]->subjects[$subject->paperSubjetId] && $response->studentMoocData[$student->studentId]->subjects[$subject->paperSubjetId]->moocCertificateStatus != "APPROVED" ){ | |
$subject->credit = ''; | |
} | |
} | |
} | |
} | |
$response->collegeData = CommonExamService::getInstance()->getCollegeDetails(); | |
$response->dateOfIssue = $request->filterSettings['markListDate']?: date("d-m-Y"); | |
$response->dateOfIssue = date("d.m.Y", strtotime($response->dateOfIssue)); | |
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/Template5/$templateName.twig"), [ 'data'=>$data ]); | |
$prtContent = NULL; | |
$prtContent .= '<html><head>'; | |
$prtContent .= "<style> | |
.footer-class div { | |
margin-left: -20mm!important; | |
margin-right: -20mm!important; | |
} | |
</style>"; | |
$prtContent .= '</head><title>Consolidated Marks Card</title><body>'; | |
$prtContent .= $responseHtml; | |
$prtContent .= '</body></html>'; | |
$width = 210; | |
$height = 297; | |
$footerHtml = ""; | |
if (reset($data->studentData)->courseType != 'PG') { | |
$footerHtml = TwigRenderer::renderTemplateFileToHtml(realpath(DOCUMENT_ROOT."../examcontroller-api/src/com/linways/web/templates/FinalConsolidatedMarksCard/Template5/Template5FCMC_footer.twig"), []); | |
$marginBottom = "7mm"; | |
} | |
$options = array( | |
'page-width' => $width."mm", | |
'page-height' => $height."mm", | |
'dpi' => 96, | |
'margin-top' => "5mm", | |
'margin-left' => "10mm", | |
'margin-right' => "10mm", | |
'margin-bottom' => $marginBottom ? $marginBottom :"10mm", | |
'footer-html' => $footerHtml, | |
// '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; | |
} | |
} |