Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 526
Template5SupplementaryConsolidatedResultGenerator
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 5
10100.00
0.00% covered (danger)
0.00%
0 / 526
 __construct
n/a
0 / 0
1
n/a
0 / 0
 getTemplateName
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 8
 processData
0.00% covered (danger)
0.00%
0 / 1
110.00
0.00% covered (danger)
0.00%
0 / 49
 renderConsolidatedMarkListResult
0.00% covered (danger)
0.00%
0 / 1
20.00
0.00% covered (danger)
0.00%
0 / 39
 processSupplementaryStudentData
0.00% covered (danger)
0.00%
0 / 1
4160.00
0.00% covered (danger)
0.00%
0 / 315
 processSupplementaryRegularStudentData
0.00% covered (danger)
0.00%
0 / 1
380.00
0.00% covered (danger)
0.00%
0 / 115
<?php
// Template Consilidated Generator For  MBCET Colleges
namespace com\linways\ec\core\service\SupplementaryConsolidatedMarkListGenerator;
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\ec\core\service\CommonExamService;
use com\linways\core\ams\professional\util\PdfUtil;
use com\linways\ec\core\constant\AttendanceStatusConstant;
use com\linways\ec\core\service\SupplementaryConsolidatedMarkListGenerator\SupplementaryConsolidatedMarkListResultDataGenerator;
use TCPDFBarcode;
use com\linways\core\ams\professional\util\CommonUtil;
use com\linways\core\ams\professional\service\AmsCustomFieldsService;
use com\linways\core\ams\professional\constant\AmsCustomFieldsEntities;
use com\linways\core\ams\professional\constant\examcontroller\CourseTypeConstants;
class Template5SupplementaryConsolidatedResultGenerator extends SupplementaryConsolidatedMarkListResultDataGenerator
{
    public function __construct(){}
    
    protected function getTemplateName($request){
        $templateName = "template_5";
        $examRegistrationData = new \stdClass;
        $examRegistrationDetailsArray = ExamRegistrationService::getInstance()->searchDetailedExamRegistrationDetails($request);
        if(empty($examRegistrationDetailsArray)){
            throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found");
        }
        return $templateName;
    }
     /**
     * Process Student data college base
     *
     * @param $request
     */
    protected function processData($request){
        $response = new \stdClass;
        $studentsMarkDetails = [];
        if($request->marksCardType == 'SUPPLY+REGULAR'){
            $examRegistrationData = StudentMarkListService::getInstance()->getExamRegistrationDetailsDataForConsolidatedAndIndividualReports($request);
            if(empty($examRegistrationData)){
                throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Exam Found");
            }
            $searchRequest = new \stdClass();
            $searchRequest->groupId = $request->groupId;
            $searchRequest->studentId = $request->studentId;
            $searchRequest->selectedSemesters = $examRegistrationData->academicTermId;
            $searchRequest->excludeMinorHonor = 1;
            $studentsMarkDetails = StudentMarkListService::getInstance()->getAllRegistredStudentMarkDetailsDummyData($searchRequest);
            if(empty($studentsMarkDetails)){
                throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found");
            }
        }
        else{
            $examRegistrationData = StudentMarkListService::getInstance()->getExamRegistrationDetailsDataForConsolidatedAndIndividualReports($request);
            $studentsMarkDetails = StudentMarkListService::getInstance()->getAllRegistredStudentMarkDetailsDummyData($request);
            if(empty($studentsMarkDetails)){
                throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found");
            }
        } 
        error_log("hi");
        $studentsMarkDetails = $this->processSupplementaryStudentData($studentsMarkDetails,$request,$examRegistrationData);
        $response->studentData = $studentsMarkDetails->studentsDetails;
        $response->examRegistrationData = $examRegistrationData;
        $response->examRegistrationData->subjects =  $studentsMarkDetails->displaySubjects;
        $response->examRegistrationData->subjectCategories =  $studentsMarkDetails->displaySubjectCategories;
        $response->examRegistrationData->totalColSpan = 8;
        if(!$request->hideExternalOrInternalMark){
            $response->examRegistrationData->totalColSpan = 8;
        }
        foreach($response->examRegistrationData->subjects as $subject){
            if(!$request->hideExternalOrInternalMark){
                $subject->subColSpan = 4;
                $subject->subColSpan = $subject->isInternal ? $subject->subColSpan + 1 : $subject->subColSpan;
                $subject->subColSpan = $subject->isExternal ? $subject->subColSpan + 1 : $subject->subColSpan;
            }
            else{
                $subject->subColSpan = 1;
            }
            $response->examRegistrationData->totalColSpan = $response->examRegistrationData->totalColSpan + $subject->subColSpan;
        }
        $response->collegeData = CommonExamService::getInstance()->getCollegeDetails();
        $response->hideExternalOrInternalMark = $request->hideExternalOrInternalMark;
        return $response;
    }
     /**
     * Render Program Result
     *
     * @param $templateName
     * @param Object $data
     * @return Object
     */
    protected function renderConsolidatedMarkListResult($templateName, $data){
        if(empty($data)){
            throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found");
        }
        else{
            if($data->hideExternalOrInternalMark){
                $responseHtml = "<style>
                .hideExternalOrInternalMark {display:none;} 
                </style>";
            }
            $responseHtml .= TwigRenderer::renderTemplateFileToHtml(realpath(DOCUMENT_ROOT."../examcontroller-api/src/com/linways/web/templates/SupplementaryConsolidatedMarkList/Template5/$templateName.twig"), [ 'data'=>$data ]);
            $prtContent = NULL;
            $prtContent .= '<html><head>';
            $prtContent .= "<style>
                h6 {font-size: 26px;} .text-center { text-align: center;} .alignMiddle {vertical-align: middle}; tr.noBorder td {border: 0;  border-collapse:collapse;}
                table, th, td {border: 1px solid black;border-collapse: collapse; vertical-align: middle;} th {font-weight: normal;} .bold {font-weight: bold;}
                </style>";
            $prtContent .= '</head><title>Consolidated MarkList</title><body>';
            $prtContent .= $responseHtml;
            $prtContent .= '</body></html>';
            $totalSubjectsCount =  count($data->examRegistrationData->subjects) < 5 ? 5 : count($data->examRegistrationData->subjects);
            $totalWidth = ( $totalSubjectsCount * 5 * 15 ) + 100;
            $totalHeight =  $totalWidth / 1.414;
            $options = array(
                'page-width'     => $totalWidth."mm",
                'page-height'    => $totalHeight."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);
            $programResult->isShowHideExternalOrInternalMark = true;
        return  $programResult;
        }
       
    }
    /**
     * processSupplementaryStudentData
     * @param studentDetails
     * @return studentDetails
     */
    protected function processSupplementaryStudentData($studentMarkDetails,$examRegistrationDetails,$examRegistrationData){
        $response = new \stdClass;
        $totalStudentDetails = new \stdClass;
        $totalStudentDetails->totalStudents = count($studentMarkDetails);
        $displaySubjectArray = [];
        $displaySubjectCategories = [];
        $studentsDetails = [];
        $searchRequest = new \stdClass;
        $searchRequest->groupId = $examRegistrationDetails->groupId;
        $searchRequest->isMinorOrHonorExamRegistration = 1;
        $minorHonorRegistrations = ExamRegistrationService::getInstance()->searchExamRegistrationByOtherDetails($searchRequest);
        foreach($studentMarkDetails as $student){
            $barcodeObj = new TCPDFBarcode($student->studentDetails->registerNo, 'C128');
            $studentsDetails[$student->id]->barcodeObj = $barcodeObj->getBarcodeHTML($w = 1, $h = 30, $color = 'black');
            $studentsDetails[$student->id]->id = $student->id;
            $customFields = AmsCustomFieldsService::getInstance()->getAmsCustomFieldValue(AmsCustomFieldsEntities::STUDENT, $student->id, []);
            if( $customFields ){
                $studentsDetails[$student->id]->ktuCode = CommonExamService::getInstance()->getCustomFieldObjectList($customFields)->studentData->KTU_CODE;
            }
            $studentsDetails[$student->id]->name = $student->studentDetails->name;
            $studentsDetails[$student->id]->isPG = $student->studentDetails->courseType == "PG" ? true : false;
            $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;
            $studentSubjectRequest = new \stdClass(); 
            $studentSubjectRequest->studentId = $student->id;
            $studentSubjectRequest->examMonthLimit = $examRegistrationDetails->examMonth;
            $studentSubjectRequest->examYearLimit = $examRegistrationDetails->examYear;
            $studentSubjectRequest->upToAcademicTermOrderNo = $examRegistrationData->academicOrderNo;
            $studentSubjectHistory = StudentMarkListService::getInstance()->getAllStudentSubjectMarkDetailsByRequest($studentSubjectRequest);
            $subjectHistory = [];
            $totalCredit = 0;
            $earnedCredit = 0;
            $earnedCreditPoint = 0;
            $semesterCgpa = 0;
            foreach($studentSubjectHistory as $studentHistory){
                if($subjectHistory[$studentHistory->paperSubjectId]){
                    if($subjectHistory[$studentHistory->paperSubjectId]->subjectCreditGradePoint < $studentHistory->subjectCreditGradePoint){
                        if($studentHistory->excludeSubjectFromTotal != 1){
                            if(($studentHistory->isFinalSemSubject === "true" && $studentHistory->isProjectGroupSubject  === "true") || $studentHistory->isProjectGroupSubject !== "true"){
                                $earnedCreditPoint += ($studentHistory->subjectCreditGradePoint - $subjectHistory[$studentHistory->paperSubjectId]->subjectCreditGradePoint);
                            }
                            $subjectHistory[$studentHistory->paperSubjectId] = $studentHistory;
                            if($studentHistory->subjectFailedStatus == "PASSED" && $examRegistrationData->academicTermId == $studentHistory->academicTermId ){
                                $earnedCredit += $studentHistory->credit;
                            }
                        }
                        else{
                            // if($studentHistory->subjectFailedStatus == "PASSED" && $examRegistrationData->academicTermId == $studentHistory->academicTermId ){
                                $subjectHistory[$studentHistory->paperSubjectId] = $studentHistory;
                            // }
                        }
                    }
                }
                else{ 
                    if($studentHistory->excludeSubjectFromTotal != 1){
                        if(($studentHistory->isFinalSemSubject === "true" && $studentHistory->isProjectGroupSubject  === "true") ||  $studentHistory->isProjectGroupSubject !== "true"){
                            if($studentHistory->isFinalSemSubject === "true" && $studentHistory->isProjectGroupSubject  === "true"){
                                $earnedCreditPoint += $studentHistory->creditGradePointProject;
                                $totalCredit += $studentHistory->finalSemProjectCredit;
                            } 
                            else{
                                $earnedCreditPoint += $studentHistory->subjectCreditGradePoint;
                                $totalCredit += $studentHistory->credit;
                            }
                        }
                        $subjectHistory[$studentHistory->paperSubjectId] = $studentHistory;
                        if($studentHistory->subjectFailedStatus == "PASSED" && $examRegistrationData->academicTermId == $studentHistory->academicTermId ){
                            $earnedCredit += $studentHistory->credit;
                        }
                    }
                    else{
                        // if($studentHistory->subjectFailedStatus == "PASSED" && $examRegistrationData->academicTermId == $studentHistory->academicTermId ){
                            $subjectHistory[$studentHistory->paperSubjectId] = $studentHistory;
                            // $earnedCreditForDisplay += $studentHistory->credit;
                        // }
                    }
                }
            }
            $semesterCgpa =  sprintf('%0.2f', round(($earnedCreditPoint/$totalCredit), 2));
            $overallFailedHistory = reset(array_filter($subjectHistory,function($value){
                return $value->subjectFailedStatus == "FAILED";
            }));
            $examRegistartionToFilter = $examRegistrationDetails->examRegistrationId;
            if($examRegistrationDetails->marksCardType == 'SUPPLY+REGULAR'){
                //removing minor honor registration from the mark history
                $student->academicTerms = array_map(function($academicTerm) use ($minorHonorRegistrations) {
                    $academicTerm->markHistory = array_filter($academicTerm->markHistory, function($markHistory) use ($minorHonorRegistrations) {
                        return !in_array($markHistory->examRegistrationId, array_column($minorHonorRegistrations, 'id'));
                    });
                    return $academicTerm;
                }, $student->academicTerms);
                $currentAcademicTerm = reset(array_filter(reset($student->academicTerms)->markHistory,function($value)use($examRegistrationDetails){
                    return $value->examRegistrationId == $examRegistrationDetails->examRegistrationId;
                }));
                if( empty($currentAcademicTerm)){
                    $regularExamDetails = array_filter(reset($student->academicTerms)->markHistory,function($value)use($examRegistrationDetails){
                        return $value->examYear."-".date("m", mktime(0, 0, 0, (int)$value->examMonth, 10))  <= $examRegistrationDetails->examYear."-".date("m", mktime(0, 0, 0, (int)$examRegistrationDetails->examMonth, 10)); 
                    });
                    usort($regularExamDetails, function($a, $b) {
                        return ($a->examYear."-".date("m", mktime(0, 0, 0, (int)$a->examMonth, 10))) < ($b->examYear."-".date("m", mktime(0, 0, 0, (int)$b->examMonth, 10)));
                    });
                    $examRegistartionToFilter = reset($regularExamDetails)->examRegistrationId;
                }
            }
          
            foreach($student->academicTerms as $academicTerm){
                $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;
                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterWiseFailedStatus = $academicTerm->isFailed;
                foreach($academicTerm->markHistory as $semMarkHistory){
                    if($semMarkHistory->examRegistrationId == $examRegistartionToFilter){
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->examRegistrationWiseFailedStatus = $semMarkHistory->failedStatus;
                        $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]->semesterGradePoint = $semMarkHistory->gradePoint;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterCreditGradePoint = $semMarkHistory->creditGradePoint;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterSgpa = sprintf('%0.2f', $semMarkHistory->sgpa);
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterpassPercentage = $academicTerm->passPercentage;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterTotalMinimumMarks = $academicTerm->totalMarks *  $academicTerm->passPercentage / 100;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterTotalMarks = $academicTerm->totalMarks;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterMarkObtained = $semMarkHistory->supplyMarkObtained;
                        $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]->academicTerms[$academicTerm->id]->semesterCgpa = sprintf('%0.2f', $semesterCgpa);
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->earnedCredits = $earnedCredit;
                        $studentsDetails[$student->id]->overallClass =  $semMarkHistory->class;
                        $studentsDetails[$student->id]->overallGrade= $semMarkHistory->grade;
                        $studentsDetails[$student->id]->failedStatus = $semMarkHistory->failedStatus;
                        $studentsDetails[$student->id]->overallFailedStatus = $overallFailedHistory ? "FAILED" : "PASSED";
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->examType = $semMarkHistory->historyType;
                    }
                }
                foreach( $academicTerm->subjects as $subject){
                    $displaySubjectArray[$subject->id]= $subject;
                    $displaySubjectCategories[$subject->categoryId]->categoryId = $subject->categoryId;
                    $displaySubjectCategories[$subject->categoryId]->categoryName = $subject->categoryName;
                    $displaySubjectCategories[$subject->categoryId]->subjects[$subject->id] = $subject;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->id = $subject->id;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->name = $subject->name;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->code = $subject->code;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->priority = $subject->priority;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalMaxMark = $subject->externalMaxMark;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->internalMaxMark = $subject->internalMaxMark;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->class = $subject->class;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->grade = $subject->grade;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->percentage = round($subject->percentage,2);
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->internalMark = $subject->internalMark;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalMark = $subject->externalMark;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->totalMaxMark = $subject->totalMarks;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->markObtained = $subject->markObtained;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->markObtainedInWord =  strtoupper(CommonUtil::convertNumberToWords((int)$subject->markObtained));
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->failedStatus = $subject->isFailed;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->attendanceStatus = $subject->attendanceStatus;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->credit = $subject->credit;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->creditGradePoint = $subject->credit * $subject->gradePoint;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->gradePoint = $subject->gradePoint;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->internalGrade = $subject->internalGrade;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalGrade = $subject->externalGrade;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->internalGradePoint = $subject->internalGradePoint;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalGradePoint = $subject->externalGradePoint;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->wgpa = $subject->wgpa;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->isExternalFailed = $subject->isExternalFailed;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->isInternalFailed = $subject->isInternalFailed;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->isInternal = $subject->isInternal;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->isExternal = $subject->isExternal;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->categoryId = $subject->categoryId;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->categoryName = $subject->categoryName;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->internalPassPercentage = $subject->internalPassPercentage;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalPassPercentage = $subject->externalPassPercentage;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->aggregatePassPercentage = $subject->aggregatePassPercentage;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->internalMinimumMark = $subject->internalMaxMark * $subject->internalPassPercentage / 100;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalMinimumMark = $subject->externalMaxMark * $subject->externalPassPercentage / 100;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->totalMinimumMark = $subject->totalMarks * $subject->aggregatePassPercentage / 100;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->internalLetterGrade = $subject->internalLetterGrade;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->internalAttendanceStatus = $subject->internalAttendanceStatus;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalLetterGrade = $subject->externalLetterGrade;
                    $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;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->latestExamYear = $subject->latestExamYear;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->latestExamMonth = $subject->latestExamMonth;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->latestExamMonthName = ExamRegistrationService::getInstance()->getMonthName($subject->latestExamMonth);
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->isProjectGroupSubject = $subject->consolidatedMarkDetails->isProjectGroupSubject;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->isFinalSemSubject = $subject->consolidatedMarkDetails->isFinalSemSubject;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->studentSubjectStatus = $subject->isFailed == 'FAILED' ? 'Fail': 'Pass';
                    if($subject->isFailed == 'FAILED'){
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->grade = 'F';
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->percentage = '-';
                    }
                    if($subject->internalAttendanceStatus == AttendanceStatusConstant::ABSENT){
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->internalMark = 'AB';
                    }
                    if($subject->internalAttendanceStatus == AttendanceStatusConstant::INCOMPLETE){
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->internalMark = 'I';
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->grade = 'I';
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->studentSubjectStatus = 'I';
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->percentage = '-';
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->markObtained = '-';
                        if($examRegistrationData->courseTypeName == CourseTypeConstants::PG){
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->studentSubjectStatus = 'Incomplete';
                        }
                    }
                    if($subject->attendanceStatus == AttendanceStatusConstant::MALPRACTICE){
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalMark = "MAL";
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->percentage = '-';
                    }
                    if($subject->attendanceStatus == AttendanceStatusConstant::ABSENT){
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalMark = 'AB';
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->percentage = '-';
                        if($examRegistrationData->courseTypeName == CourseTypeConstants::PG && $subject->classType == "THEORY" && $examRegistrationData->batchStartYear >= 2022){
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->grade = 'AB';
                        }
                    }
                    if($subject->attendanceStatus == AttendanceStatusConstant::INCOMPLETE){
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalMark = 'I';
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->grade = 'I';
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->percentage = '-';
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->studentSubjectStatus = 'I'; 
                    }
                    if($subject->consolidatedMarkDetails->excludeSubjectFromTotal == '1'){
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->grade = $subject->isFailed == "PASSED" ? 'P' : 'F' ;
                    }
                    if($subject->studentInternalAttendanceStatus == 'FE'){
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->grade = 'FE';
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalMark = '-';
                    }
                    
                    if($examRegistrationDetails->marksCardType == 'SUPPLY+REGULAR'){
                        $subject->markHistory = array_filter($subject->subjectMarkHistory,function($value)use($examRegistrationDetails){
                            return $value->examYear."-".date("m", mktime(0, 0, 0, (int)$value->examMonth, 10))  <= $examRegistrationDetails->examYear."-".date("m", mktime(0, 0, 0, (int)$examRegistrationDetails->examMonth, 10)); 
                        });
                        // changes to highest mark
                        // $regularHistory = array_filter($subject->markHistory,function($value){
                        //     return $value->examMarkType == "REGULAR";
                        // });
                        // $supplyHistory = array_filter($subject->markHistory,function($value){
                        //     return $value->examMarkType == "SUPPLY";
                        // });
                        usort($subject->markHistory, function($a, $b) {
                            return ($a->examYear."-".date("m", mktime(0, 0, 0, (int)$a->examMonth, 10))) < ($b->examYear."-".date("m", mktime(0, 0, 0, (int)$b->examMonth, 10)));
                        });
                        usort($subject->markHistory, function($a, $b) {
                            return ($a->externalMark < $b->externalMark); 
                        });
                        // $subject->markHistory = array_merge($supplyHistory, $regularHistory);
                        $subject->latestMarkHistory = reset($subject->markHistory);
                        
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->markObtained = $subject->latestMarkHistory->markObtained;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->percentage = round($subject->latestMarkHistory->percentage,2);
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->failedStatus = $subject->latestMarkHistory->resultStatus;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->grade = $subject->latestMarkHistory->grade;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->class = $subject->latestMarkHistory->class;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->latestExamYear = $subject->latestMarkHistory->examYear;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->latestexamMonth = $subject->latestMarkHistory->examMonth;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->latestExamMonthName = ExamRegistrationService::getInstance()->getMonthName($subject->latestMarkHistory->examMonth);
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalMark = $subject->latestMarkHistory->externalMark;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->studentSubjectStatus = $subject->latestMarkHistory->resultStatus == 'FAILED' ? 'Fail': 'Pass';
                        if($subject->latestMarkHistory->resultStatus == 'FAILED'){
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->grade = 'F';
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->percentage = '-';
                        }
                        if($subject->latestMarkHistory->internalAttendanceStatus == AttendanceStatusConstant::ABSENT){
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->internalMark = 'AB';
                        }
                        if($subject->latestMarkHistory->internalAttendanceStatus == AttendanceStatusConstant::INCOMPLETE){
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->internalMark = 'I';
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->grade = 'I';
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->studentSubjectStatus = 'I';
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->percentage = '-';
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->markObtained = '-';
                            if($examRegistrationData->courseTypeName == CourseTypeConstants::PG){
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->studentSubjectStatus = 'Incomplete';
                            }
                        }
                        if($subject->latestMarkHistory->attendanceStatus == AttendanceStatusConstant::MALPRACTICE){
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalMark = "MAL";
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->percentage = '-';
                        }
                        if($subject->latestMarkHistory->attendanceStatus == AttendanceStatusConstant::ABSENT){
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalMark = 'AB';
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->percentage = '-';
                            if($examRegistrationData->courseTypeName == CourseTypeConstants::PG && $subject->classType == "THEORY" && $examRegistrationData->batchStartYear >= 2022){
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->grade = 'AB';
                            }
                        }
                        if($subject->latestMarkHistory->attendanceStatus == AttendanceStatusConstant::INCOMPLETE){
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalMark = 'I';
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->grade = 'I';
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->percentage = '-';
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->studentSubjectStatus = 'I'; 
                        }
                        if($subject->consolidatedMarkDetails->excludeSubjectFromTotal == '1'){
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->grade = $subject->latestMarkHistory->resultStatus == "PASSED" ? 'P' : 'F' ;
                        }
                        if($subject->studentInternalAttendanceStatus == 'FE'){
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->grade = 'FE';
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalMark = '-';
                        }
                    }
                }
                // $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterCreditGradePoint = array_sum(array_column($studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects,'creditGradePoint'));
            }
            
            if(count($student->academicTerms) > 1){
                $studentsDetails[$student->id]->overallClass = $student->class;
                $studentsDetails[$student->id]->overallGrade= $student->grade;
                $studentsDetails[$student->id]->failedStatus = $student->isFailed;
            }
        }
        uasort($studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects, function($a, $b) {
            return ($a->priority > $b->priority);
        });
        $displaySubjectCategories = array_values($displaySubjectCategories); 
        foreach($displaySubjectCategories as $displaySubjectCategory){
            $displaySubjectCategory->subjects = array_values($displaySubjectCategory->subjects); 
        }
        uasort($displaySubjectArray, function($a, $b) {
            return ($a->priority > $b->priority);
        });
        $displaySubjectArray = array_values($displaySubjectArray); 
        foreach($studentsDetails as $student){
            $student->academicTerms = array_values($student->academicTerms); 
            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;
        $response->displaySubjectCategories = $displaySubjectCategories;
        return $response;
    }
        /**
     * processSupplementaryRegularStudentData
     * @param studentDetails
     * @return studentDetails
     */
    public function processSupplementaryRegularStudentData($studentMarkDetails,$examRegistrationRequest,$examRegistrationDetails){
        $response = new \stdClass;
        $totalStudentDetails = new \stdClass;
        $totalStudentDetails->totalStudents = count($studentMarkDetails);
        $displaySubjectArray = [];
        $displaySubjectCategories = [];
        $studentsDetails = [];
        foreach($studentMarkDetails as $student){
            $barcodeObj = new TCPDFBarcode($student->studentDetails->registerNo, 'C128');
            $studentsDetails[$student->id]->slNo = "";
            $studentsDetails[$student->id]->barcodeObj = $barcodeObj->getBarcodeHTML($w = 1, $h = 30, $color = 'black');
            $studentsDetails[$student->id]->id = $student->id;
            $customFields = AmsCustomFieldsService::getInstance()->getAmsCustomFieldValue(AmsCustomFieldsEntities::STUDENT, $student->id, []);
            if( $customFields ){
                $studentsDetails[$student->id]->ktuCode = CommonExamService::getInstance()->getCustomFieldObjectList($customFields)->studentData->KTU_CODE;
            }
            $studentsDetails[$student->id]->name = $student->studentDetails->name;
            $studentsDetails[$student->id]->myImage = $student->studentDetails->myImage;
            $studentsDetails[$student->id]->registerNo = $student->studentDetails->registerNo;
            $studentsDetails[$student->id]->rollNo = $student->studentDetails->rollNo;
            foreach($student->academicTerms as $academicTerm){
                $currentAcademicTerm = reset(array_filter(reset($student->academicTerms)->markHistory,function($value)use($examRegistrationRequest){
                    return $value->examRegistrationId == $examRegistrationRequest->examRegistrationId;
                }));
                $regularExamDetails = reset(array_filter(reset($student->academicTerms)->markHistory,function($value){
                    return $value->historyType == 'REGULAR';
                }));
                $studentSubjectRequest = new \stdClass(); 
                $studentSubjectRequest->studentId = $student->id;
                $studentSubjectRequest->examMonthLimit = $examRegistrationDetails->examMonth;
                $studentSubjectRequest->examYearLimit = $examRegistrationDetails->examYear;
                $studentSubjectRequest->academicTermId = $academicTerm->id;
                $studentSubjectHistory = StudentMarkListService::getInstance()->getAllStudentSubjectMarkDetailsByRequest($studentSubjectRequest);
                $earnedCredit = 0;
                foreach($studentSubjectHistory as $studentHistory){
                    if($studentHistory->subjectFailedStatus == "PASSED"){
                        $earnedCredit += $studentHistory->credit;
                    }
                }
                $studentsDetails[$student->id]->regularExamRegistrationId = $regularExamDetails->examRegistrationId;
                $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;
                $studentsDetails[$student->id]->failedStatus = $currentAcademicTerm->failedStatus;
                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterGrade = $currentAcademicTerm->grade;
                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterCredit = $academicTerm->credit;
                $studentsDetails[$student->id]->earnedCredits = $earnedCredit;
                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterGradePoint = $academicTerm->gradePoint;
                $studentsDetails[$student->id]->semesterSgpa = sprintf('%0.2f', $currentAcademicTerm->sgpa);
                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterSgpa =sprintf('%0.2f', $currentAcademicTerm->sgpa);
                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->latestExamMonth = $currentAcademicTerm->examMonth;
                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->latestExamYear = $currentAcademicTerm->examYear;
                foreach( $academicTerm->subjects as $subject){
                    $subject->markHistory = array_filter($subject->subjectMarkHistory,function($value)use($examRegistrationDetails){
                        return $value->examYear."-".date("m", mktime(0, 0, 0, (int)$value->examMonth, 10))  <= $examRegistrationDetails->examYear."-".date("m", mktime(0, 0, 0, (int)$examRegistrationDetails->examMonth, 10)); 
                    });
                    usort($subject->markHistory, function($a, $b) {
                        return ($a->examYear."-".date("m", mktime(0, 0, 0, (int)$a->examMonth, 10))) < ($b->examYear."-".date("m", mktime(0, 0, 0, (int)$b->examMonth, 10)));
                    });
                    usort($subject->markHistory, function($a, $b) {
                        return ($a->externalMark < $b->externalMark); 
                    });
                    $subject->latestMarkHistory = reset($subject->markHistory);
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id] = $subject;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->id = $subject->id;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->totalMaxMark = $subject->totalMarks;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->percentage = round($subject->latestMarkHistory->percentage,2);
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->failedStatus = $subject->latestMarkHistory->resultStatus;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->grade = $subject->latestMarkHistory->grade;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->class = $subject->latestMarkHistory->class;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->latestExamYear = $subject->latestMarkHistory->examYear;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->latestexamMonth = $subject->latestMarkHistory->examMonth;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->latestExamMonthName = ExamRegistrationService::getInstance()->getMonthName($subject->latestMarkHistory->examMonth);
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->isProjectGroupSubject = $subject->consolidatedMarkDetails->isProjectGroupSubject;
                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->isFinalSemSubject = $subject->consolidatedMarkDetails->isFinalSemSubject;
                    if($subject->consolidatedMarkDetails->excludeSubjectFromTotal == '1'){
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->grade = $subject->latestMarkHistory->resultStatus == "PASSED" ? 'P' : 'F' ;
                    }
                    if($subject->latestMarkHistory->attendanceStatus == 'ABSENT'){
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalMark = $examRegistrationDetails->courseTypeName != 'MBA' ? 'I' : 'AB';
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->grade = $examRegistrationDetails->courseTypeName != 'MBA' ? 'I' : 'AB';
                    }
                    else if($subject->latestMarkHistory->attendanceStatus == 'MALPRACTICE'){
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalMark = 'MAL';
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->grade = 'MAL';
                    }
                    else if($subject->latestMarkHistory->resultStatus == 'FAILED'){
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->grade = 'F';
                    }
                }
                // $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterCreditGradePoint = array_sum(array_column($studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects,'creditGradePoint'));
            }
            if($studentsDetails[$student->id]->failedStatus  == 'PASSED'){
                $slNoRequest =  new \stdClass;
                $slNoRequest->studentId = $student->id;
                $slNoRequest->examRegistrationId = $studentsDetails[$student->id]->regularExamRegistrationId;
                $studentsDetails[$student->id]->slNo = CommonExamService::getInstance()->getStudentExamMarkListSerialNumber($slNoRequest)->markListSerialNo;
                if ($studentsDetails[$student->id]->slNo) {
                    $studentsDetails[$student->id]->slNo = str_pad($studentsDetails[$student->id]->slNo, 6, "0", STR_PAD_LEFT);
                }
            }
            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->certicifateNo = 'No:GC/'.reset($studentsDetails[$student->id]->academicTerms)->latestExamYear.'/S'.reset($studentsDetails[$student->id]->academicTerms)->semInSemNumber.'/'.$studentsDetails[$student->id]->slNo;
        }
        uasort($studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects, function($a, $b) {
            return ($a->priority > $b->priority);
        });
        $displaySubjectCategories = array_values($displaySubjectCategories); 
        foreach($displaySubjectCategories as $displaySubjectCategory){
            $displaySubjectCategory->subjects = array_values($displaySubjectCategory->subjects); 
        }
        uasort($displaySubjectArray, function($a, $b) {
            return ($a->priority > $b->priority);
        });
        foreach($studentsDetails as $student){
            $student->academicTerms = array_values($student->academicTerms); 
            foreach($student->academicTerms as $academicTerm){
                $academicTerm->subjects = array_values($academicTerm->subjects); 
            } 
        }
        $response->studentsDetails = $studentsDetails;
        return $response;
    }
}