Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 442 |
Template16IndividualResultGenerator | |
0.00% |
0 / 1 |
|
0.00% |
0 / 6 |
7310.00 | |
0.00% |
0 / 442 |
__construct | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getTemplateName | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 18 |
|||
processData | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 29 |
|||
renderIndividualMarkCardResult | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 34 |
|||
processStudentData | |
0.00% |
0 / 1 |
3306.00 | |
0.00% |
0 / 250 |
|||
getExamRegistrationDetailsData | |
0.00% |
0 / 1 |
240.00 | |
0.00% |
0 / 96 |
|||
getSgpaByMonthYear | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 15 |
<?php | |
// Template Individual Generator For VS Colleges | |
namespace com\linways\ec\core\service\RegularIndividualMarkCardGenerator; | |
use com\linways\ec\core\service\StudentMarkListService; | |
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\core\ams\professional\util\CommonUtil; | |
use com\linways\ec\core\service\CommonExamService; | |
use com\linways\ec\core\service\GradeSchemeService; | |
use com\linways\ec\core\service\MarksCardService; | |
use com\linways\core\ams\professional\service\academic\AcademicTermService; | |
use com\linways\core\ams\professional\request\academic\SearchAcademicTermRequest; | |
use com\linways\ec\core\service\RegularIndividualMarkCardGenerator\RegularIndividualMarkCardResultDataGenerator; | |
use com\linways\core\ams\professional\service\StudentService; | |
use com\linways\ec\core\service\ExamValuationService; | |
use TCPDFBarcode; | |
class Template16IndividualResultGenerator extends RegularIndividualMarkCardResultDataGenerator | |
{ | |
public function __construct(){} | |
/** | |
* get Template Name | |
* @param $request | |
* @param $templateName | |
*/ | |
protected function getTemplateName($request){ | |
$examRegistrationDetails = new \stdClass; | |
$examRegistrationDetailsArray = ExamRegistrationService::getInstance()->searchDetailedExamRegistrationDetails($request); | |
if(empty($examRegistrationDetailsArray)){ | |
throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
} | |
$examRegistrationDetails->name = $examRegistrationDetailsArray[0]->name; | |
$examRegistrationDetails->type = $examRegistrationDetailsArray[0]->type; | |
$examRegistrationDetails->groupId = $examRegistrationDetailsArray[0]->groups[0]->groupId; | |
$examRegistrationDetails->groupName = $examRegistrationDetailsArray[0]->groups[0]->groupName; | |
$examRegistrationDetails->courseTypeID = $examRegistrationDetailsArray[0]->groups[0]->courseTypeID; | |
$examRegistrationDetails->courseTypeName = $examRegistrationDetailsArray[0]->groups[0]->courseTypeName; | |
$examRegistrationDetails->batchStartYear = $examRegistrationDetailsArray[0]->groups[0]->batchStartYear; | |
$examRegistrationDetails->deptID = $examRegistrationDetailsArray[0]->groups[0]->deptID; | |
$examRegistrationDetails->deptName = $examRegistrationDetailsArray[0]->groups[0]->deptName; | |
$examRegistrationDetails->degreeName = $examRegistrationDetailsArray[0]->groups[0]->degreeName; | |
$templateName = "template_16"; | |
return $templateName; | |
} | |
/** | |
* Process Student data college base | |
* @param $request | |
*/ | |
protected function processData($request){ | |
$response = new \stdClass; | |
$studentsMarkDetails = []; | |
$studentsMarkDetails = StudentMarkListService::getInstance()->getAllRegistredStudentMarkDetailsDummyData($request); | |
if(empty($studentsMarkDetails)){ | |
throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
} | |
if( $request->isStudentSideExamResult == '1' && !$request->groupId){ | |
$request->groupId = reset($studentsMarkDetails)->studentDetails->batchId; | |
} | |
$response->examRegistrationData = $this->getExamRegistrationDetailsData($request); | |
$request->finalTermId = $response->examRegistrationData->finalTermId; | |
$request->examMonth = $response->examRegistrationData->examMonth; | |
$request->examYear = $response->examRegistrationData->examYear; | |
$responseOfStudentData = $this->processStudentData($studentsMarkDetails, $request); | |
$response->studentData = $responseOfStudentData->studentsDetails; | |
$response->totalStudentData = $responseOfStudentData->totalStudentDetails; | |
$request->groupId = $request->groupId ?? reset($response->studentData)->groupId; | |
$response->collegeAndOtherData = CommonExamService::getInstance()->getCollegeDetails($request); | |
if( $request->displayContentOptions->enableDateFlag == '1'){ | |
if(!$request->displayContentOptions->markListDate ){ | |
$request->displayContentOptions->markListDate = date("d-m-Y"); | |
} | |
else{ | |
$request->displayContentOptions->markListDate = date("d-m-Y", strtotime($request->displayContentOptions->markListDate)); | |
} | |
} | |
$response->displayContentOptions = $request->displayContentOptions; | |
return $response; | |
} | |
/** | |
* Render Program Result | |
* | |
* @param $templateName | |
* @param Object $data | |
* @return Object | |
*/ | |
protected function renderIndividualMarkCardResult($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/RegularIndividualMarkCards/Template16/$templateName.twig"), [ 'data'=>$data ]); | |
$prtContent = NULL; | |
$responseHtml .= '<script> | |
</script>'; | |
$prtContent .= '<html><head>'; | |
$prtContent .= "<style> | |
</style>"; | |
$prtContent .= '</head><title>Individual Mark Card</title><body>'; | |
$prtContent .= $responseHtml; | |
$prtContent .= '</body></html>'; | |
$totalWidth = 29.5; | |
$totalHeight = 21; | |
$options = array( | |
'page-width' => $totalWidth."cm", | |
'page-height' => $totalHeight."cm", | |
'dpi' => 96, | |
'margin-top' => "4cm", | |
'margin-left' => "1cm", | |
'margin-right' => "1cm", | |
'margin-bottom' => "0.5cm", | |
'disable-smart-shrinking', | |
'orientation'=> "portrait", | |
// 'binary' => "/usr/local/bin/wkhtmltopdf", // For Mac | |
'user-style-sheet' => realpath(DOCUMENT_ROOT . "/libcommon/bootstrap/css/bootstrap.min.css") | |
); | |
$programResult = new \stdClass; | |
$programResult->dispalyHtmlData = $prtContent; | |
$programResult->printData = PdfUtil::renderPdf($prtContent, $options); | |
return $programResult; | |
} | |
} | |
/** | |
* processStudentData | |
* @param $studentsMarkDetails | |
* @param $studentsDetails | |
*/ | |
protected function processStudentData($studentsMarkDetails, $request = null){ | |
$response = new \stdClass; | |
$totalStudentDetails = new \stdClass; | |
$totalStudentDetails->totalStudents = count($studentsMarkDetails); | |
$studentsDetails = []; | |
$getAcademicTermRequest = new SearchAcademicTermRequest(); | |
$getAcademicTermRequest->id = $request->finalTermId; | |
$getAcademicTermRequest->type = "SEMESTER"; | |
$finalSemDetails = reset(AcademicTermService::getInstance()->searchAcademicTerm($getAcademicTermRequest)); | |
foreach($studentsMarkDetails as $student){ | |
$studentsDetails[$student->id]->id = $student->id; | |
$studentsDetails[$student->id]->name = $student->studentDetails->name; | |
$studentsDetails[$student->id]->isResultBlocked = $student->isResultBlocked; | |
$studentsDetails[$student->id]->blockingMsg = $student->blockingMsg; | |
$studentsDetails[$student->id]->studentImage = StudentService::getInstance()->getStudentProfilePic($student->id)->docpath; | |
$academicTerm = reset(array_filter(reset($student->academicTerms)->markHistory,function($value)use($request){ | |
return $value->examRegistrationId == $request->examRegistrationId; | |
})); | |
$examTermOrderNo = reset($student->academicTerms)->academicOrderNo; | |
$examTermId = reset($student->academicTerms)->academicTermId; | |
$studentsDetails[$student->id]->failedStatus = $academicTerm->failedStatus; | |
$studentsDetails[$student->id]->registerNo = $student->studentDetails->registerNo; | |
$studentsDetails[$student->id]->groupId = $student->studentDetails->batchId; | |
$studentsDetails[$student->id]->rollNo = $student->studentDetails->rollNo; | |
$studentsDetails[$student->id]->universityExamSeatNo = $student->universityExamSeatNo; | |
$studentsDetails[$student->id]->gender = $student->studentDetails->gender; | |
$studentsDetails[$student->id]->motherName = $student->studentDetails->motherName; | |
$studentsDetails[$student->id]->degreeName = $student->studentDetails->degree; | |
$studentsDetails[$student->id]->semesterGrade = $academicTerm->grade; | |
$studentsDetails[$student->id]->semesterClass = $academicTerm->class; | |
$studentsDetails[$student->id]->semesterCredit = (int)$student->academicTerms[0]->credit; | |
$studentsDetails[$student->id]->creditGradePoint = $academicTerm->creditGradePoint; | |
$studentsDetails[$student->id]->passPercentageDisplay = $student->studentDetails->academicYear < 2019 ? 40 : 40; | |
$studentsDetails[$student->id]->passPercentageDisplayMessage = $student->studentDetails->academicYear < 2019 ? "For a pass in each course 35% mark or P grade is necessary." : "For a pass in each course 35% mark or P grade is necessary."; | |
$studentsDetails[$student->id]->roundOff = $student->studentDetails->academicYear < 2019 ? 2 : 3; | |
if ($student->studentDetails->courseTypeName == 'PG_DIPLOMA') { | |
$studentsDetails[$student->id]->roundOff = $student->studentDetails->academicYear >= 2019 ? 2 : $studentsDetails[$student->id]->roundOff; | |
} | |
$studentsDetails[$student->id]->semesterSgpa = sprintf('%0.2f', $academicTerm->sgpa); | |
$studentsDetails[$student->id]->semesterTotalMarks = $academicTerm->totalMarks; | |
$studentsDetails[$student->id]->semesterMarkObtained = $academicTerm->markObtained; | |
$studentsDetails[$student->id]->semesterPercentage = round($academicTerm->percentage,2); | |
$studentsDetails[$student->id]->semesterGradeUpgradedMark = round($academicTerm->semesterGradeUpgradedMark); | |
$studentsDetails[$student->id]->hashTotalGraceMark = round($academicTerm->hashTotalGraceMark); | |
$studentsDetails[$student->id]->semesterGraceMark = round($academicTerm->semesterGraceMark); | |
$studentsDetails[$student->id]->sgpaAddonMark = $academicTerm->sgpaAddonMark ? sprintf('%0.2f', $academicTerm->sgpaAddonMark) : ""; | |
if($studentsDetails[$student->id]->failedStatus == "PASSED"){ | |
$totalStudentDetails->passStudents ++; | |
} | |
$studentsDetails[$student->id]->gradeUpgradedMark = 0; | |
foreach($student->academicTerms[0]->subjects as $subject){ | |
if ($student->studentDetails->degree == "BSC"){ | |
$subjectClassType = $subject->classType == "THEORY" ? "(TH)" : ( $subject->classType == "PRACTICAL" ? "(PR)" : ""); | |
$subject->name = $subject->name.$subjectClassType; | |
} | |
$studentsDetails[$student->id]->subjects[$subject->id]->id = $subject->id; | |
$studentsDetails[$student->id]->subjects[$subject->id]->name = $subject->name; | |
$subject->code = $subject->courseCode ? $subject->courseCode : $subject->code; | |
$studentsDetails[$student->id]->subjects[$subject->id]->code = $subject->code; | |
$studentsDetails[$student->id]->subjects[$subject->id]->externalMaxMark = $subject->externalMaxMark; | |
$studentsDetails[$student->id]->subjects[$subject->id]->internalMaxMark = $subject->internalMaxMark; | |
$studentsDetails[$student->id]->subjects[$subject->id]->priority = intval($subject->priority); | |
$studentsDetails[$student->id]->subjects[$subject->id]->class = $subject->class; | |
$studentsDetails[$student->id]->subjects[$subject->id]->grade = $subject->grade; | |
$studentsDetails[$student->id]->subjects[$subject->id]->percentage = $subject->percentage; | |
$studentsDetails[$student->id]->subjects[$subject->id]->internalMark = $subject->internalMark; | |
$studentsDetails[$student->id]->subjects[$subject->id]->externalMark = $subject->externalMark + $subject->graceMark; | |
$studentsDetails[$student->id]->subjects[$subject->id]->totalMaxMark = $subject->totalMarks; | |
$studentsDetails[$student->id]->subjects[$subject->id]->markObtained = $subject->markObtained; | |
$studentsDetails[$student->id]->subjects[$subject->id]->failedStatus = $subject->isFailed; | |
$studentsDetails[$student->id]->subjects[$subject->id]->attendanceStatus = $subject->attendanceStatus; | |
$studentsDetails[$student->id]->subjects[$subject->id]->credit = (int)$subject->credit; | |
$studentsDetails[$student->id]->subjects[$subject->id]->earnedCredit = $subject->isFailed == 'FAILED' ? 0 : (int)$subject->credit; | |
$studentsDetails[$student->id]->subjects[$subject->id]->creditGradePoint = $subject->subGradePoint * $subject->credit; | |
$studentsDetails[$student->id]->subjects[$subject->id]->gradePoint = $subject->subGradePoint; | |
$studentsDetails[$student->id]->subjects[$subject->id]->internalGrade = $subject->isInternal ? $subject->internalGrade : "-"; | |
$studentsDetails[$student->id]->subjects[$subject->id]->externalGrade = $subject->externalGrade; | |
$studentsDetails[$student->id]->subjects[$subject->id]->internalGradePoint = $subject->isInternal ? $subject->internalGradePoint : "-"; | |
$studentsDetails[$student->id]->subjects[$subject->id]->externalGradePoint = $subject->externalGradePoint; | |
$studentsDetails[$student->id]->subjects[$subject->id]->wgpa = $subject->wgpa; | |
$studentsDetails[$student->id]->subjects[$subject->id]->isExternalFailed = $subject->isExternalFailed; | |
$studentsDetails[$student->id]->subjects[$subject->id]->isInternalFailed = $subject->isInternalFailed; | |
$studentsDetails[$student->id]->subjects[$subject->id]->isInternal = $subject->isInternal; | |
$studentsDetails[$student->id]->subjects[$subject->id]->isExternal = $subject->isExternal; | |
$studentsDetails[$student->id]->subjects[$subject->id]->categoryId = $subject->categoryId; | |
$studentsDetails[$student->id]->subjects[$subject->id]->internalAttendanceStatus = $subject->internalAttendanceStatus; | |
$studentsDetails[$student->id]->subjects[$subject->id]->categoryName = $subject->categoryName; | |
$studentsDetails[$student->id]->subjects[$subject->id]->internalPassPercentage = $subject->internalPassPercentage; | |
$studentsDetails[$student->id]->subjects[$subject->id]->externalPassPercentage = $subject->externalPassPercentage; | |
$studentsDetails[$student->id]->subjects[$subject->id]->aggregatePassPercentage = $subject->aggregatePassPercentage; | |
$studentsDetails[$student->id]->subjects[$subject->id]->internalMinimumMark = $subject->internalMaxMark * $subject->internalPassPercentage / 100; | |
$studentsDetails[$student->id]->subjects[$subject->id]->externalMinimumMark = $subject->externalMaxMark * $subject->externalPassPercentage / 100; | |
$studentsDetails[$student->id]->subjects[$subject->id]->totalMinimumMark = $subject->totalMarks * $subject->aggregatePassPercentage / 100; | |
$studentsDetails[$student->id]->subjects[$subject->id]->externalMarkObtainedInExam = reset($subject->subjectMarkHistory)->externalMarkObtainedInExam; | |
$studentsDetails[$student->id]->subjects[$subject->id]->internalGraceMark = reset($subject->subjectMarkHistory)->internalGraceMark; | |
$studentsDetails[$student->id]->subjects[$subject->id]->internalHashGraceMark = reset($subject->subjectMarkHistory)->internalHashGraceMark; | |
$studentsDetails[$student->id]->subjects[$subject->id]->externalMarkObtainedInExam = sprintf('%02d', $studentsDetails[$student->id]->subjects[$subject->id]->externalMarkObtainedInExam); | |
$studentsDetails[$student->id]->subjects[$subject->id]->graceMark = round(reset($subject->subjectMarkHistory)->graceMark); | |
$studentsDetails[$student->id]->subjects[$subject->id]->gradeUpgradedMark = round(reset($subject->subjectMarkHistory)->gradeUpgradedMark); | |
$studentsDetails[$student->id]->subjects[$subject->id]->externalGraceMark = round(reset($subject->subjectMarkHistory)->externalGraceMark); | |
$studentsDetails[$student->id]->subjects[$subject->id]->hasCondonationGraceMark = reset($subject->subjectMarkHistory)->hasCondonationGraceMark; | |
if( $studentsDetails[$student->id]->subjects[$subject->id]->hasCondonationGraceMark ){ | |
$studentsDetails[$student->id]->subjects[$subject->id]->totalGraceMarkToDisplay = $studentsDetails[$student->id]->subjects[$subject->id]->externalGraceMark + $studentsDetails[$student->id]->subjects[$subject->id]->internalGraceMark; | |
} | |
$studentsDetails[$student->id]->subjects[$subject->id]->hashGraceMark = round(reset($subject->subjectMarkHistory)->hashGraceMark); | |
$studentsDetails[$student->id]->subjects[$subject->id]->revaluationMark = round(reset($subject->subjectMarkHistory)->revaluationMark); | |
$studentsDetails[$student->id]->subjects[$subject->id]->moderationMark = round(reset($subject->subjectMarkHistory)->moderationMark); | |
if($studentsDetails[$student->id]->subjects[$subject->id]->totalGraceMarkToDisplay){ | |
$studentsDetails[$student->id]->subjects[$subject->id]->totalGraceMarkToDisplay += $studentsDetails[$student->id]->subjects[$subject->id]->hashGraceMark ; | |
} | |
if($studentsDetails[$student->id]->subjects[$subject->id]->internalGraceMark){ | |
$studentsDetails[$student->id]->subjects[$subject->id]->internalMark = $studentsDetails[$student->id]->subjects[$subject->id]->internalMark - $studentsDetails[$student->id]->subjects[$subject->id]->internalGraceMark; | |
} | |
if($studentsDetails[$student->id]->subjects[$subject->id]->internalHashGraceMark){ | |
$studentsDetails[$student->id]->subjects[$subject->id]->internalMark = $studentsDetails[$student->id]->subjects[$subject->id]->internalMark - $studentsDetails[$student->id]->subjects[$subject->id]->internalHashGraceMark; | |
} | |
if($studentsDetails[$student->id]->subjects[$subject->id]->graceMark){ | |
$studentsDetails[$student->id]->subjects[$subject->id]->markObtained -= $studentsDetails[$student->id]->subjects[$subject->id]->graceMark; | |
} | |
if($studentsDetails[$student->id]->subjects[$subject->id]->gradeUpgradedMark){ | |
$studentsDetails[$student->id]->subjects[$subject->id]->markObtained -= $studentsDetails[$student->id]->subjects[$subject->id]->gradeUpgradedMark; | |
} | |
if($studentsDetails[$student->id]->subjects[$subject->id]->internalGraceMark && $studentsDetails[$student->id]->subjects[$subject->id]->hasCondonationGraceMark){ | |
$studentsDetails[$student->id]->subjects[$subject->id]->markObtained -= $studentsDetails[$student->id]->subjects[$subject->id]->internalGraceMark; | |
} | |
if($studentsDetails[$student->id]->subjects[$subject->id]->externalGraceMark && $studentsDetails[$student->id]->subjects[$subject->id]->hasCondonationGraceMark){ | |
$studentsDetails[$student->id]->subjects[$subject->id]->markObtained -= $studentsDetails[$student->id]->subjects[$subject->id]->externalGraceMark; | |
} | |
if($studentsDetails[$student->id]->subjects[$subject->id]->hashGraceMark){ | |
$studentsDetails[$student->id]->subjects[$subject->id]->markObtained -= $studentsDetails[$student->id]->subjects[$subject->id]->hashGraceMark; | |
if($studentsDetails[$student->id]->subjects[$subject->id]->externalGraceMark && $studentsDetails[$student->id]->subjects[$subject->id]->hasCondonationGraceMark){ | |
$studentsDetails[$student->id]->subjects[$subject->id]->markObtained += $studentsDetails[$student->id]->subjects[$subject->id]->totalGraceMarkToDisplay; | |
$studentsDetails[$student->id]->subjects[$subject->id]->totalGraceMarkToDisplay = ''; | |
} | |
} | |
$studentsDetails[$student->id]->subjects[$subject->id]->externalMark = sprintf('%02d', $studentsDetails[$student->id]->subjects[$subject->id]->externalMark); | |
$studentsDetails[$student->id]->subjects[$subject->id]->internalMark = sprintf('%02d', $studentsDetails[$student->id]->subjects[$subject->id]->internalMark); | |
$studentsDetails[$student->id]->subjects[$subject->id]->markObtained = sprintf('%02d', $studentsDetails[$student->id]->subjects[$subject->id]->markObtained); | |
$studentsDetails[$student->id]->subjects[$subject->id]->creditGradePoint = sprintf('%02d', $studentsDetails[$student->id]->subjects[$subject->id]->creditGradePoint); | |
if($studentsDetails[$student->id]->subjects[$subject->id]->attendanceStatus == 'ABSENT'){ | |
$studentsDetails[$student->id]->subjects[$subject->id]->externalMarkObtainedInExam = 'AB'; | |
$studentsDetails[$student->id]->subjects[$subject->id]->grade = 'F'; | |
$studentsDetails[$student->id]->subjects[$subject->id]->externalGrade = 'F(Ab)'; | |
} | |
if($studentsDetails[$student->id]->subjects[$subject->id]->internalAttendanceStatus == 'ABSENT'){ | |
$studentsDetails[$student->id]->subjects[$subject->id]->internalMark = 'AB'; | |
$studentsDetails[$student->id]->subjects[$subject->id]->internalGrade = 'F(Ab)'; | |
} | |
if($studentsDetails[$student->id]->subjects[$subject->id]->attendanceStatus == 'MALPRACTICE'){ | |
$studentsDetails[$student->id]->subjects[$subject->id]->externalMarkObtainedInExam = '00'; | |
$studentsDetails[$student->id]->subjects[$subject->id]->grade = 'F'; | |
$studentsDetails[$student->id]->subjects[$subject->id]->externalGrade = 'F'; | |
} | |
if($studentsDetails[$student->id]->subjects[$subject->id]->gradeUpgradedMark){ | |
$studentsDetails[$student->id]->gradeUpgradedMark += $studentsDetails[$student->id]->subjects[$subject->id]->gradeUpgradedMark; | |
} | |
} | |
if($studentsDetails[$student->id]->gradeUpgradedMark){ | |
$studentsDetails[$student->id]->semesterMarkObtained -= $studentsDetails[$student->id]->gradeUpgradedMark; | |
} | |
uasort($studentsDetails[$student->id]->subjects, function($a, $b) { | |
return ($a->priority > $b->priority); | |
}); | |
$studentsDetails[$student->id]->semesterEarnedCredit = array_sum(array_column($studentsDetails[$student->id]->subjects,'earnedCredit')); | |
$sgpaSearchReq = new \stdClass(); | |
// $sgpaSearchReq->groupId = $student->studentDetails->batchId; | |
$sgpaSearchReq->studentWithSgpa = 1; | |
$sgpaSearchReq->sgpaStudentId = $student->id; | |
$sgpaStudentList = ExamValuationService::getInstance()->getStudentDetailsForSgpaDirectEntry($sgpaSearchReq); | |
$semesterMarksRequest = new \stdClass; | |
// $semesterMarksRequest->groupId = $student->studentDetails->batchId; for student study diff batches | |
$semesterMarksRequest->studentId = $student->id; | |
$semesterMarks = MarksCardService::getInstance()->getStudentSemesterMarkDetails($semesterMarksRequest); | |
foreach($semesterMarks as $semKey => $semester){ | |
if($examTermOrderNo < $semester->orderNo){ | |
unset($semesterMarks[$semKey]); | |
continue; | |
} | |
$currentHistory = $this->getSgpaByMonthYear($semester->markHistory, $request, false); | |
$semesterNames = new \stdClass; | |
$semesterNames = CommonExamService::getInstance()->getDifferentSemesterName($semester->name); | |
$semester->sgpa =sprintf('%0.2f', ($currentHistory->sgpa + $currentHistory->sgpaAddonMark)); | |
$semester->semInRomanLetter = $semesterNames->romanLetter; | |
$semester->totalCredit = $semester->markDetails->credit; | |
$semester->markDetails->isFailed = $currentHistory->failedStatus == "FAILED" ? 1 : 0; | |
$semester->markDetails->arrearCount = 0; | |
foreach($semester->subjects as $subject){ | |
$currentSubject = $this->getSgpaByMonthYear($subject->subjectMarkHistory, $request, 1); | |
if (count($subject->subjectMarkHistory) > 1){ | |
$regularStudentHistory = reset(array_filter($subject->subjectMarkHistory,function($value){ | |
return $value->examMarkType == "REGULAR"; | |
})); | |
if( $regularStudentHistory && ($currentSubject->internalMark != $regularStudentHistory->internalMark) ){ | |
if( empty($currentSubject->externalMarkObtainedInExam ) && !$regularStudentHistory->isExternalFailed ){ | |
$currentSubject->resultStatus = $subject->markDetails->isFailed ? 'FAILED' : 'PASSED'; | |
} | |
} | |
} | |
$subject->earnedCredit = $currentSubject->resultStatus == "FAILED" ? 0 : $subject->markDetails->credit; | |
$semester->markDetails->arrearCount = $currentSubject->resultStatus == "FAILED" ? $semester->markDetails->arrearCount+1 : $semester->markDetails->arrearCount; | |
} | |
$semester->totalEarnedCredit = array_sum(array_column($semester->subjects,'earnedCredit')); | |
} | |
$semArray = []; | |
$barcodeVar = $student->studentDetails->rollNo.", SGPA-"; | |
foreach($semesterMarks as $semester){ | |
$semArray[$semester->orderNo] = $semester; | |
} | |
for($i=1; $i <= $finalSemDetails->properties->orderNo; $i++){ | |
if( empty( $semArray[$i])){ | |
$semesterNames = CommonExamService::getInstance()->getDifferentSemesterName($i); | |
$semArray[$i]->semInRomanLetter = $semesterNames->romanLetter; | |
$semArray[$i]->noDetails = 1; | |
} | |
$studentEnteredSgpa = reset(array_filter($sgpaStudentList,function($value)use($i){ | |
return $value->academicTermId == $i; | |
})); | |
if(round($studentEnteredSgpa->sgpa)){ | |
$semArray[$i]->sgpa =sprintf('%0.2f', ($studentEnteredSgpa->sgpa)); | |
$semArray[$i]->markDetails->isFailed = 0; | |
$semArray[$i]->noDetails = 0; | |
} | |
if(round($studentEnteredSgpa->totalCredit)){ | |
$semArray[$i]->totalCredit = $studentEnteredSgpa->totalCredit; | |
$semArray[$i]->noDetails = 0; | |
} | |
if(round($studentEnteredSgpa->earnedCredit)){ | |
$semArray[$i]->totalEarnedCredit = $studentEnteredSgpa->earnedCredit; | |
$semArray[$i]->noDetails = 0; | |
} | |
$barcodeVar .= $semArray[$i]->name.":"; | |
if( $semArray[$i]->markDetails->isFailed){ | |
$barcodeVar .= "-, "; | |
} | |
else if ($semArray[$i]->markDetails){ | |
$barcodeVar .= $semArray[$i]->sgpa.", "; | |
} | |
} | |
$barcodeVar .= $studentsDetails[$student->id]->semesterGrade.", "; | |
$barcodeVar .= $studentsDetails[$student->id]->failedStatus == 'FAILED'? 'Fail' : 'Pass'; | |
$barcodeObj = new TCPDFBarcode($barcodeVar, 'C128'); | |
$studentsDetails[$student->id]->barcodeObj = $barcodeObj->getBarcodeHTML($w = 1, $h = 30, $color = 'black'); | |
ksort($semArray); | |
$semesterMarks = array_slice($semArray, 0, 4); | |
$studentsDetails[$student->id]->semesters = $semesterMarks; | |
} | |
uasort($studentsDetails, function($a, $b) { | |
return ($a->rollNo > $b->rollNo); | |
}); | |
$totalStudentDetails->passPercentage = round(100 * ( $totalStudentDetails->passStudents / $totalStudentDetails->totalStudents),2); | |
$studentsDetails = array_values($studentsDetails); | |
foreach($studentsDetails as $student){ | |
$student->subjects = array_values($student->subjects); | |
} | |
$response->studentsDetails = $studentsDetails; | |
$response->totalStudentDetails = $totalStudentDetails; | |
return $response; | |
} | |
protected function getExamRegistrationDetailsData($request){ | |
$examRegistrationDetails = new \stdClass; | |
$examRegistrationDetailsArray = ExamRegistrationService::getInstance()->searchDetailedExamRegistrationDetails($request); | |
if(empty($examRegistrationDetailsArray)){ | |
throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found"); | |
} | |
$examRegistrationDetails->name = $examRegistrationDetailsArray[0]->name; | |
$examRegistrationDetails->examYear = $examRegistrationDetailsArray[0]->examYear; | |
$examRegistrationDetails->examMonth = $examRegistrationDetailsArray[0]->examMonth; | |
$examRegistrationDetails->examMonthName = $examRegistrationDetailsArray[0]->examMonthName; | |
$examRegistrationDetails->type = $examRegistrationDetailsArray[0]->type; | |
$examRegistrationDetails->groupId = $examRegistrationDetailsArray[0]->groups[0]->groupId; | |
$examRegistrationDetails->groupName = $examRegistrationDetailsArray[0]->groups[0]->groupName; | |
$examRegistrationDetails->courseTypeID = $examRegistrationDetailsArray[0]->groups[0]->courseTypeID; | |
$examRegistrationDetails->courseTypeName = $examRegistrationDetailsArray[0]->groups[0]->courseTypeName; | |
$examRegistrationDetails->academicTermName = $examRegistrationDetailsArray[0]->groups[0]->academicTermName; | |
$examRegistrationDetails->academicTermYear = $examRegistrationDetailsArray[0]->groups[0]->academicTermYear; | |
$examRegistrationDetails->academicTermYearRoman = strtoupper(CommonUtil::convertNumberToRoman($examRegistrationDetails->academicTermYear)); | |
$examRegistrationDetails->academicTermId = $examRegistrationDetailsArray[0]->groups[0]->academicTermId; | |
$examRegistrationDetails->finalTermId = $examRegistrationDetailsArray[0]->groups[0]->properties->finalTermId; | |
$semesterNames = CommonExamService::getInstance()->getDifferentSemesterName($examRegistrationDetails->academicTermName); | |
$examRegistrationDetails->semInRomanLetter = $semesterNames->romanLetter; | |
$examRegistrationDetails->semInFullName = $semesterNames->fullName; | |
$examRegistrationDetails->semInSemNumber = $semesterNames->semNumber; | |
$examRegistrationDetails->batchStartYear = $examRegistrationDetailsArray[0]->groups[0]->batchStartYear; | |
$examRegistrationDetails->publishingStartDate = $examRegistrationDetailsArray[0]->groups[0]->examBatchProperties->publishingStartDate; | |
$examRegistrationDetails->resultDeclaredDate = $examRegistrationDetails->publishingStartDate ? date("d M Y", strtotime( $examRegistrationDetails->publishingStartDate)) : ""; | |
if( $request->displayContentOptions->enableDateFlag == '1'){ | |
if($request->displayContentOptions->markListDate ){ | |
$examRegistrationDetails->resultDeclaredDate = date("d M Y", strtotime($request->displayContentOptions->markListDate)); | |
} | |
} | |
$examRegistrationDetails->deptID = $examRegistrationDetailsArray[0]->groups[0]->deptID; | |
$examRegistrationDetails->deptName = $examRegistrationDetailsArray[0]->groups[0]->deptName; | |
$examRegistrationDetails->degreeName = $examRegistrationDetailsArray[0]->groups[0]->degreeName; | |
$examRegistrationDetails->degreeDescription = reset($examRegistrationDetailsArray)->groups[0]->degreeDescription; | |
$examRegistrationDetails->programName = reset($examRegistrationDetailsArray)->groups[0]->programName; | |
foreach($examRegistrationDetailsArray[0]->groups[0]->subjects as $subject){ | |
$examRegistrationDetails->subjects[$subject->id]->id = $subject->id; | |
$subject->code = $subject->courseCode ? $subject->courseCode : $subject->code; | |
$examRegistrationDetails->subjects[$subject->id]->code = $subject->code; | |
$examRegistrationDetails->subjects[$subject->id]->name = $subject->name; | |
$examRegistrationDetails->subjects[$subject->id]->isInternal = 1; | |
$examRegistrationDetails->subjects[$subject->id]->isExternal = 1; | |
$examRegistrationDetails->subjects[$subject->id]->credit = $subject->credit; | |
$examRegistrationDetails->subjects[$subject->id]->id = $subject->id; | |
$examRegistrationDetails->subjects[$subject->id]->externalMaxMark = $subject->externalMaxMark; | |
$examRegistrationDetails->subjects[$subject->id]->internalMaxMark = $subject->internalMaxMark; | |
$examRegistrationDetails->subjects[$subject->id]->totalSubjectMark = $subject->totalSubjectMark; | |
if(!$request->hideExternalOrInternalMark){ | |
$examRegistrationDetails->subjects[$subject->id]->subColSpan = 4; | |
$examRegistrationDetails->subjects[$subject->id]->subColSpan = $examRegistrationDetails->subjects[$subject->id]->isInternal ? $examRegistrationDetails->subjects[$subject->id]->subColSpan + 1 : $examRegistrationDetails->subjects[$subject->id]->subColSpan; | |
$examRegistrationDetails->subjects[$subject->id]->subColSpan = $examRegistrationDetails->subjects[$subject->id]->isExternal ? $examRegistrationDetails->subjects[$subject->id]->subColSpan + 1 : $examRegistrationDetails->subjects[$subject->id]->subColSpan; | |
} | |
else{ | |
$examRegistrationDetails->subjects[$subject->id]->subColSpan = 1; | |
} | |
} | |
$examRegistrationDetails->totalColSpan = 5; | |
if(!$request->hideExternalOrInternalMark){ | |
$examRegistrationDetails->totalColSpan = 4; | |
} | |
foreach($examRegistrationDetails->subjects as $subject){ | |
$examRegistrationDetails->totalColSpan = $examRegistrationDetails->totalColSpan + $subject->subColSpan; | |
} | |
$examRegistrationDetails->subjects = array_values($examRegistrationDetails->subjects); | |
$gradeSchemeRequest = new \stdClass; | |
$gradeSchemeRequest->groupId = $examRegistrationDetails->groupId; | |
$gradeSchemeRequest->orderBy = "ASC"; | |
$subjectGrades = GradeSchemeService::getInstance()->getAllSubjectGradeSchemes($gradeSchemeRequest); | |
array_walk($subjectGrades, function($grade){ | |
$grade->properties = json_decode($grade->properties); | |
$grade->percentTo = $grade->range_to; | |
$grade->percentFrom = $grade->range_from; | |
$grade->class = $grade->properties->class; | |
$grade->gradePoint = $grade->properties->gradePoint; | |
}); | |
$minPercentTo = min(array_column($subjectGrades, "percentTo")); | |
$maxPercentTo = max(array_column($subjectGrades, "percentTo")); | |
$gradeDiplayArray = []; | |
foreach ($subjectGrades as $key => $subjectGrade) { | |
if ($subjectGrade->percentTo == $maxPercentTo) { | |
$gradeDiplayArray[$subjectGrade->percentTo]->name = sprintf('%0.2f', floor($subjectGrade->percentFrom * 100) /100) . " and above"; | |
} | |
else if($subjectGrade->percentTo == $minPercentTo) { | |
$gradeDiplayArray[$subjectGrade->percentTo]->name = "Below " . round($subjectGrade->percentTo); | |
} | |
else { | |
$gradeDiplayArray[$subjectGrade->percentTo]->name = sprintf('%0.2f', floor($subjectGrade->percentFrom * 100) /100) . " to " . sprintf('%0.2f', floor($subjectGrade->percentTo * 100) /100); | |
} | |
$gradeDiplayArray[$subjectGrade->percentTo]->grade = "$subjectGrade->name"; | |
$gradeDiplayArray[$subjectGrade->percentTo]->gradePoint = "$subjectGrade->gradePoint"; | |
} | |
krsort($gradeDiplayArray); | |
$gradeDiplayArray = array_values($gradeDiplayArray); | |
$examRegistrationDetails->grades = $gradeDiplayArray; | |
return $examRegistrationDetails; | |
} | |
protected function getSgpaByMonthYear($markHistory, $request, $subjectRequest){ | |
$currentHistory = ''; | |
if( $subjectRequest ){ | |
$currentHistory = array_filter($markHistory,function($value)use($request){ | |
return $value->examYear."-".date("m", mktime(0, 0, 0, (int)$value->examMonth, 10)) <= $request->examYear."-".date("m", mktime(0, 0, 0, (int)$request->examMonth, 10)); | |
}); | |
usort($currentHistory, 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); | |
}); | |
} | |
else{ | |
$currentHistory = array_filter($markHistory,function($value)use($request){ | |
return $value->examYear."-".date("m", mktime(0, 0, 0, (int)$value->examMonth, 10)) <= $request->examYear."-".date("m", mktime(0, 0, 0, (int)$request->examMonth, 10)); | |
}); | |
usort($currentHistory, function($a, $b) { | |
return ($a->examYear."-".date("m", mktime(0, 0, 0, (int)$a->examMonth, 10))."-".$a->historyType) < ($b->examYear."-".date("m", mktime(0, 0, 0, (int)$b->examMonth, 10))."-".$b->historyType); | |
}); | |
} | |
return reset($currentHistory); | |
} | |
} |