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 / 16
CRAP
0.00% covered (danger)
0.00%
0 / 882
TabulationRegisterService
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 16
14762.00
0.00% covered (danger)
0.00%
0 / 882
 __construct
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 2
 getRegularTabulationRegisterReport
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 15
 getAllRegistredStudentMarkDetailsForTabulationRegister
0.00% covered (danger)
0.00%
0 / 1
182.00
0.00% covered (danger)
0.00%
0 / 195
 processStudentDataForRegularTabulationRegister
0.00% covered (danger)
0.00%
0 / 1
552.00
0.00% covered (danger)
0.00%
0 / 150
 getExamRegistrationDetailsForTabulationRegisterReports
0.00% covered (danger)
0.00%
0 / 1
72.00
0.00% covered (danger)
0.00%
0 / 48
 getTrDatesAndModerationMark
0.00% covered (danger)
0.00%
0 / 1
12.00
0.00% covered (danger)
0.00%
0 / 22
 getTrDatesAndModeration
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 17
 saveTrDatesAndModeration
0.00% covered (danger)
0.00%
0 / 1
56.00
0.00% covered (danger)
0.00%
0 / 35
 getLastSemesterRegularExamRegistrationId
0.00% covered (danger)
0.00%
0 / 1
20.00
0.00% covered (danger)
0.00%
0 / 23
 insertTrDatesAndModeration
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 11
 getSupplyTabulationRegisterReport
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 16
 getAllRegistredStudentIdsForSupplemenaryTabulationRegister
0.00% covered (danger)
0.00%
0 / 1
156.00
0.00% covered (danger)
0.00%
0 / 54
 processStudentDataForSupplyTabulationRegister
0.00% covered (danger)
0.00%
0 / 1
420.00
0.00% covered (danger)
0.00%
0 / 126
 getConsolidatedTabulationRegisterReport
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 11
 processStudentDataForConsolidatedTabulationRegister
0.00% covered (danger)
0.00%
0 / 1
306.00
0.00% covered (danger)
0.00%
0 / 148
 getTabulationRegisterSettings
0.00% covered (danger)
0.00%
0 / 1
12.00
0.00% covered (danger)
0.00%
0 / 9
<?php
namespace com\linways\ec\core\service;
use com\linways\ec\core\dto\ExamRegistrationBatch;
use com\linways\ec\core\request\SearchRuleRequest;
use com\linways\ec\core\service\RuleService;
use com\linways\base\util\MakeSingletonTrait;
use com\linways\base\util\SecurityUtils;
use com\linways\ec\core\constant\StatusConstants;
use com\linways\ec\core\exception\ExamControllerException;
use com\linways\ec\core\mapper\TabulationRegisterServiceMapper;
use com\linways\ec\core\request\SearchExamRegistrationBatchRequest;
use com\linways\core\ams\professional\service\CommonService;
use com\linways\core\ams\professional\constant\SettingsConstants;
use com\linways\ec\core\service\ExamRegistrationService;
use com\linways\ec\core\service\CommonExamService;
use com\linways\core\ams\professional\util\CommonUtil;
use com\linways\ec\core\service\RegularTabulationRegisterGenerator\RegularTabulationRegisterGenerator;
use com\linways\ec\core\service\SupplementaryTabulationRegisterGenerator\SupplementaryTabulationRegisterGenerator;
use com\linways\ec\core\service\ConsolidatedTabulationRegisterGenerator\ConsolidatedTabulationRegisterGenerator;
use phpDocumentor\Reflection\PseudoTypes\True_;
use TCPDFBarcode;
class TabulationRegisterService extends BaseService
{
    use MakeSingletonTrait;
    private function __construct() {
        $this->mapper = TabulationRegisterServiceMapper::getInstance()->getMapper();
    }
    public function getRegularTabulationRegisterReport($searchRequest){
        try{ 
            $searchRequest = $this->realEscapeObject($searchRequest);
            $request = new \stdClass;
            $request->groupId = $searchRequest->groupId;
            $request->examRegistrationId = $searchRequest->examRegistrationId;
            $request->academicTermId = $searchRequest->academicTermId;
            $request->studentId = $searchRequest->studentId;
            $request->isPrint = $searchRequest->isPrint;
            $programResult = RegularTabulationRegisterGenerator::getInstance()->getRegularTabulationRegisterResultData($request);
            return $programResult;
        }
        catch (\Exception $e){
            throw new ExamControllerException($e->getCode(),$e->getMessage());
        }
    }
     /**
     * get All Registered Students Details
     * @param $searchRequest 
     */
    public function getAllRegistredStudentMarkDetailsForTabulationRegister($searchRequest) {
        $searchRequest = $this->realEscapeObject($searchRequest);
        try
        {
            $joinQuery = "";
            $orderBy = " ORDER BY spa.properties->>'$.registerNumber' ASC , CAST(ap.properties ->> '$.order' AS UNSIGNED) ASC , CAST(aps.properties ->> '$.order' AS UNSIGNED) ASC ";
            $whereQuery = "";
            if(!empty($searchRequest->studentId)) {
                $studentIdString = is_array($searchRequest->studentId) ? "'" . implode("','",$searchRequest->studentId) . "'" : "'".$searchRequest->studentId."'";
                $whereQuery .= " AND sa.studentID IN ( $studentIdString )";
            }
            if(!empty($searchRequest->groupId)) {
                $groupIdString = is_array($searchRequest->groupId) ? "'" . implode("','",$searchRequest->groupId) . "'" : "'".$searchRequest->groupId."'";
                $whereQuery .= " AND g.id IN ( $groupIdString )";
            }
            if(! $searchRequest->isSupplyTR){
                if(!empty($searchRequest->examRegistrationId)) {
                    $examRegistrationIdString = is_array($searchRequest->examRegistrationId) ? "'" . implode("','",$searchRequest->examRegistrationId) . "'" : "'".$searchRequest->examRegistrationId."'";
                    $whereQuery .= " AND eer.id IN ( $examRegistrationIdString )";
                }
            }
            if($searchRequest->isSupplyTR){
                $joinQuery .= " INNER JOIN ec_subject_mark_details esmdsub ON
                                    esmdsub.groups_id = eerb.groups_id AND 
                                    esmdsub.cm_academic_paper_subjects_id = eers.cm_academic_paper_subjects_id AND 
                                    esmdsub.student_id = sa.studentID ";
            }
            else{
                $joinQuery .= " INNER JOIN ec_subject_mark_details esmdsub ON
                                    esmdsub.ec_exam_registration_id = eerb.ec_exam_registration_id AND 
                                    esmdsub.groups_id = eerb.groups_id AND 
                                    esmdsub.cm_academic_paper_subjects_id = eers.cm_academic_paper_subjects_id AND 
                                    esmdsub.student_id = sa.studentID ";
            }
            if($searchRequest->fetchAllSemesterDetails){
                $joinQuery .= " INNER JOIN  academic_term act ON 
                                    act.type = 'SEMESTER'";
            }
            else{
                if(!empty($searchRequest->academicTermId)) {
                    $semesterIdString = is_array($searchRequest->academicTermId) ? "'" . implode("','",$searchRequest->academicTermId) . "'" : "'".$searchRequest->academicTermId."'";
                    $whereQuery .= " AND act.id IN ( $semesterIdString )";
                }
                $joinQuery .= " INNER JOIN  academic_term act ON 
                                    act.id = CAST(eerb.properties ->> '$.academicTermId'AS CHAR) AND 
                                    act.type = 'SEMESTER'";
            }
            $query = "SELECT DISTINCT
                        sa.studentID AS id,
                        sa.studentID AS studentId,
                        sa.studentName,
                        spa.properties->>'$.registerNumber' AS regNo,
                        efn.folio_number as folioNumber,
                        sa.rollNo,
                        sa.admissionNo,
                        sa.myImage,
                        sa.studentGender,
                        g.id AS groupId,
                        g.name AS groupName,
                        act.id AS academicTermId,
                        act.name AS academicTermName,
                        act.properties ->> '$.orderNo' AS academicTermOrderNo,
                        dept.deptID,
                        deg.name AS degreeName,
                        deg.id AS degreeId,
                        dept.deptName,
                        ct.courseTypeID,
                        ct.typeName AS courseTypeName,
                        g.properties ->> '$.startYear' AS academicYear,
                        g.properties ->> '$.finalTermId' AS finalTermId,
                        eer.type AS latestExamType,
                        eer.properties ->> '$.examYear' AS latestExamYear,
                        eer.properties ->> '$.examMonth' AS latestExamMonth,
                        aps.properties->>'$.categoryId' AS subjectCategoryId,
                        sc.subjectcatName AS subjectCategoryName,
                        sc.code AS subjectCategoryCode,
                        esmdsem.mark_details ->>'$.sgpa' AS semesterSgpa,
                        esmdsem.mark_details ->>'$.rawSgpa' AS semesterRawSgpa,
                        esmdsem.mark_details ->>'$.percentage' AS semesterPercentage,
                        esmdsem.mark_details ->>'$.grade' AS semesterGrade,
                        esmdsem.mark_details ->>'$.markObtained' AS semesterMarkObtained,
                        esmdsem.mark_details ->>'$.class' AS semesterClass,
                        esmdsem.mark_details ->>'$.totalMarks' AS semesterTotalMarks,
                        esmdsem.mark_details ->>'$.credit' AS semesterCredit,
                        esmdsem.mark_details ->>'$.gradePoint' AS semesterGradePoint,
                        esmdsem.mark_details ->>'$.creditGradePoint' AS semesterCreditGradePoint,
                        esmdsem.mark_history AS semesterMarkHistory,
                        esmdsem.failed_status AS semesterFailedStatus,
                        s.code AS subjectCode,
                        ap.properties ->> '$.order' AS subjectPriority,
                        aps.properties ->> '$.syllabusName' AS syllabusName,
                        aps.properties ->> '$.classType' AS classType,
                        s.name AS subjectName,
                        eers.cm_academic_paper_subjects_id AS academicPaperSubjectId,
                        esmdsub.mark_details ->>'$.markObtained' AS subjectMarkObtained,
                        esmdsub.mark_details ->>'$.isExternalFailed' AS isExternalFailed,
                        esmdsub.mark_details ->>'$.externalGrade' AS subjectExtrenalGrade,
                        esmdsub.mark_details ->>'$.externalGradePoint' AS subjectExternalGradePoint,
                        esmdsub.mark_details ->>'$.wgpa' AS subjectWgpa,
                        esmdsub.mark_details->>'$.attendanceStatus' AS subjectAttendanceStatus,
                        esmdsub.mark_details->>'$.internalAttendanceStatus' AS internalAttendanceStatus,
                        esmdsub.mark_details ->>'$.internalMark' AS internalMark,
                        esar.properties ->>'$.studentAttendanceStatus' AS studentInternalAttendanceStatus,
                        
                        esmdsub.class AS subjectClass,
                        esmdsub.percentage AS subjectPercentage,
                        esmdsub.grade AS subjectGrade,
                        esmdsub.failed_status AS subjectFailedStatus,
                        CAST(esmdsub.mark_details ->>'$.externalMark' AS DECIMAL(8,2)) AS externalMark,
                        esmdsub.mark_details ->>'$.gradePoint' AS subGradePoint,
                        esmdsub.mark_details ->>'$.gradePoint' AS subjectGradePoint,
                        esmdsub.mark_details ->>'$.creditGradePoint' AS subCreditGradePoint,
                        esmdsub.mark_details ->>'$.creditGradePoint' AS subjectCreditGradePoint,
                        esmdsubcon.mark_details ->>'$.internalResultStatus' AS subjectInternalResultStatus,
                        esmdsub.mark_details ->>'$.internalAttendance' AS subjectInternalAttendance,
                        esmdsub.mark_details ->>'$.internalGrade' AS subjectInternalGrade,
                        esmdsub.mark_details ->>'$.internalGradePoint' AS subjectInternalGradePoint,
                        esmdsubcon.mark_details ->>'$.credit' AS subjectCredit,
                        esmdsubcon.mark_details ->>'$.externalMaxMark' AS externalMaxMark,
                        esmdsubcon.mark_details ->>'$.internalMaxMark' AS internalMaxMark,
                        esmdsubcon.mark_details ->>'$.totalMarks' AS subjectTotalMarks,
                        esmdsubcon.mark_details ->>'$.isExternal' AS isExternal,
                        esmdsubcon.mark_details ->>'$.isInternal' AS isInternal,
                        esmdsubcon.mark_details ->>'$.isInternalFailed' AS isInternalFailed,
                        esmdsubcon.mark_details ->>'$.internalPassPercentage' AS subjectInternalPassPercentage,
                        esmdsubcon.mark_details ->>'$.externalPassPercentage' AS subjectExternalPassPercentage,
                        esmdsubcon.mark_details ->>'$.aggregatePassPercentage' AS subjectAggregatePassPercentage,
                        esmdsubcon.mark_details AS subjectConsolidatedMarkDetails,
                        esmdsubcon.mark_history AS subjectMarkHistory,
                       
                        ecmdcourse.mark_details ->>'$.cgpa' AS cgpa,
                        ecmdcourse.percentage AS overallPercentage,
                        ecmdcourse.mark_details ->>'$.grade' AS overallGrade,
                        ecmdcourse.mark_details ->>'$.class' AS overallClass,
                        ecmdcourse.mark_details ->>'$.markObtained' AS courseObtainedMark,
                        ecmdcourse.mark_details ->>'$.totalMarks' AS courseTotalMark,
                        ecmdcourse.mark_details ->>'$.creditxMark' AS courseCreditxMark,
                        ecmdcourse.mark_details ->>'$.creditGradePoint' AS courseCreditGradePoint,
                        ecmdcourse.mark_details ->>'$.credit' AS courseTotalCredit,
                        ecmdcourse.mark_details ->>'$.wgp' AS courseWgp,
                        ecmdcourse.mark_details ->>'$.wgpa' AS courseWgpa,
                        ecmdcourse.mark_details ->>'$.gradePoint' AS courseGradePoint,
                        ecmdcourse.failed_status AS courseFailedStatus
                        
                    FROM
                        `groups` g
                    INNER JOIN ec_exam_registration_batch eerb ON
                        eerb.groups_id = g.id
                    INNER JOIN ec_exam_registration_subject eers ON
                        eers.ec_exam_registration_batch_id = eerb.id
                    INNER JOIN  cm_academic_paper_subjects aps ON 
                        eers.cm_academic_paper_subjects_id = aps.id
                    INNER JOIN cm_academic_paper ap ON 
                        aps.cm_academic_paper_id = ap.id
                    INNER JOIN  v4_ams_subject s ON 
                        aps.ams_subject_id = s.id
                    INNER JOIN ec_exam_registration eer ON
                        eer.id = eerb.ec_exam_registration_id
                    INNER JOIN ec_student_assessment_registration esar ON
                        esar.am_assessment_id = eers.am_assessment_id AND 
                        esar.ec_exam_registration_type = eer.type AND
                        ((CAST(esar.properties ->> '$.registrationStatus' AS CHAR) = 'REGISTERED' AND 
                            CAST(esar.properties ->> '$.feeStatus' AS CHAR) = 'PAID' ) OR 
                            CAST(esar.properties->>'$.studentAttendanceStatus' AS CHAR) = 'FE' AND
                            CAST(esar.properties->>'$.registrationStatus' AS CHAR) ='NOT_REGISTERED')
                    INNER JOIN studentaccount sa ON 
                        sa.studentID = esar.student_id
                    INNER JOIN program p ON
                        p.id = g.properties ->> '$.programId'
                    INNER JOIN student_program_account spa ON 
                        spa.student_id  = esar.student_id  AND
                        spa.current_program_id = p.id
                    INNER JOIN department dept ON
                        dept.deptID = g.properties ->> '$.departmentId'
                    INNER JOIN degree deg ON
                        deg.id = p.degree_id
                    INNER JOIN `course_type` ct ON
                        ct.courseTypeID = p.course_type_id
                    ".$joinQuery."
                    INNER JOIN ec_semester_mark_details esmdsem ON
                        esmdsem.groups_id = eerb.groups_id AND 
                        esmdsem.academic_term_id = act.id AND 
                        esmdsem.student_id = sa.studentID 
                    INNER JOIN ec_consolidated_subject_mark_details esmdsubcon ON
                        esmdsubcon.groups_id = eerb.groups_id AND esmdsubcon.cm_academic_paper_subjects_id = eers.cm_academic_paper_subjects_id AND esmdsubcon.student_id = sa.studentID 
                    LEFT JOIN subject_category sc ON
                        sc.subjectcatID = aps.properties->>'$.categoryId'
                    LEFT JOIN  ec_course_mark_details ecmdcourse ON
                        ecmdcourse.groups_id = eerb.groups_id AND ecmdcourse.student_id = sa.studentID 
                    LEFT JOIN ec_folio_number efn ON efn.student_id = esar.student_id AND efn.groups_id = g.id
                    WHERE 1=1";
            $studentMarkDetails = $this->executeQueryForList($query.$whereQuery.$orderBy, $this->mapper[TabulationRegisterServiceMapper::OVER_ALL_MARK_DETAILS]);
        }
        catch (\Exception $e)
        {
            throw new ExamControllerException($e->getCode(),$e->getMessage());
        }
        return $studentMarkDetails;
    }
    
    /**
     * processStudentDataForRegularTabulationRegister
     * @param studentDetails
     * @return studentDetails
     * @author Krishnajith
     */
    public function processStudentDataForRegularTabulationRegister($studentMarkDetails,$request,$examRegistrationDetails = null){
        try{ 
            $response = new \stdClass;
            $displaySubjectArray = [];
            $studentsDetails = [];
            $isCurrentSemester = true;
            foreach($studentMarkDetails as $student){
                $student->roundOff = 2;
                $studentsDetails[$student->id]->id = $student->id;
                $studentsDetails[$student->id]->name = $student->studentDetails->name;
                $studentsDetails[$student->id]->cgpa = $student->cgpa;
                $studentsDetails[$student->id]->grade = $student->grade;
                
                $studentsDetails[$student->id]->myImage = $student->studentDetails->myImage;
                $studentsDetails[$student->id]->registerNo = $student->studentDetails->registerNo;
                $studentsDetails[$student->id]->rollNo = $student->studentDetails->rollNo;
                $studentsDetails[$student->id]->roundOff = $student->studentDetails->academicYear < 2019 ?  2 : 3;
                foreach($student->academicTerms as $academicTerm){
                    if($request->fetchAllSemesterDetails){
                        $isCurrentSemester = $examRegistrationDetails->academicTermId == $academicTerm->id ? true : false;
                    }
                    if($isCurrentSemester){
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->id = $academicTerm->id;
                        $semesterNames = CommonExamService::getInstance()->getDifferentSemesterName($academicTerm->name);
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semInRomanLetter = $semesterNames->romanLetter;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semInFullName = $semesterNames->fullName;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semInSemNumber = $semesterNames->semNumber;
                        foreach($academicTerm->markHistory as $semMarkHistory){
                            if($semMarkHistory->examRegistrationId == $request->examRegistrationId){
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->failedStatus = $semMarkHistory->failedStatus;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterGrade = $semMarkHistory->grade;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterCredit = $academicTerm->credit;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterCreditGradePoint = $semMarkHistory->gradePoint;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->examMonth = $semMarkHistory->examMonth;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->examYear = $semMarkHistory->examYear;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterCreditPoint = $semMarkHistory->creditPoint;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterSgpa = round($semMarkHistory->sgpa, $studentsDetails[$student->id]->roundOff);
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterTotalMarks = $academicTerm->totalMarks;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterMarkObtained = $semMarkHistory->totalMark;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterMarkObtainedInWord = strtoupper(CommonUtil::convertNumberToWords($semMarkHistory->totalMark))." ONLY";
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterPercentage = round($semMarkHistory->percentage,2);
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterClass = $semMarkHistory->class;
                                $studentsDetails[$student->id]->overallClass =  $semMarkHistory->class;
                                $studentsDetails[$student->id]->overallGrade= $semMarkHistory->grade;
                                $studentsDetails[$student->id]->failedStatus = $semMarkHistory->failedStatus;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->examType = $semMarkHistory->historyType;
                            }
                        }
                        foreach( $academicTerm->subjects as $subject){
                            $displaySubjectArray[$subject->id]= $subject;
                            $subject->internalMaxMark = $subject->isInternal ? $subject->internalMaxMark : '-';
                            $subject->externalMaxMark = $subject->isExternal ? $subject->externalMaxMark : '-';
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id] = $subject;
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->percentage = round($subject->percentage,2);
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->markObtainedInWord =  strtoupper(CommonUtil::convertNumberToWords((int)$subject->markObtained));
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjectCategories[$subject->categoryId]->categoryId = $subject->categoryId;
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjectCategories[$subject->categoryId]->categoryName = $subject->categoryName;
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjectCategories[$subject->categoryId]->subjects[$subject->id] = $subject;
                        }
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterCreditGradePoint = array_sum(array_column($studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects,'creditGradePoint'));
                    }
                    else{
                        $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->id = $academicTerm->id;
                        $semesterNames = CommonExamService::getInstance()->getDifferentSemesterName($academicTerm->name);
                        $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semInRomanLetter = $semesterNames->romanLetter;
                        $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semInFullName = $semesterNames->fullName;
                        $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semInSemNumber = $semesterNames->semNumber;
                        if($request->considerSupplementary){
                            if($request->supplementaryMonthUpperLimit && $request->supplementaryYearUpperLimit){
                                $lastSemMonthYear = date("Y-m", strtotime($request->supplementaryYearUpperLimit . "-" . $request->supplementaryMonthUpperLimit));
                                $tempMonthYear = "";
                                $currentMonthYear = "";
                                array_walk($academicTerm->markHistory,function($term,$key)use($student,$academicTerm,$studentsDetails,$lastSemMonthYear,$tempMonthYear,$currentMonthYear){
                                    if($lastSemMonthYear > date("Y-m", strtotime($term->examYear . "-" . $term->examMonth))){
                                        $currentMonthYear = date("Y-m", strtotime($term->examYear . "-" . $term->examMonth)); 
                                        if($currentMonthYear > $tempMonthYear){
                                            $tempMonthYear = $currentMonthYear;
                                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->failedStatus = $term->failedStatus;
                                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->examMonth = $term->examMonth;
                                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->examYear = $term->examYear;
                                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterGrade = $term->grade;
                                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterCredit = $term->credit;
                                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterCreditGradePoint = $term->gradePoint;
                                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterSgpa = round($term->sgpa, $studentsDetails[$student->id]->roundOff);
                                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterMarkObtained = $term->markObtained;
                                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterMarkObtainedInWord = strtoupper(CommonUtil::convertNumberToWords($term->markObtained))." ONLY";
                                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterPercentage = round($term->percentage,2);
                                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterClass = $term->class;
                                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->examType = $term->historyType;
                                        }
                                    }
                                });
                            }
                            else{
                                $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->failedStatus = $academicTerm->isFailed;
                                $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterGrade = $academicTerm->grade;
                                $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterCredit = $academicTerm->credit;
                                $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterCreditGradePoint = $academicTerm->gradePoint;
                                $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterSgpa = round($academicTerm->sgpa, $studentsDetails[$student->id]->roundOff);
                                $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterMarkObtained = $academicTerm->markObtained;
                                $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterMarkObtainedInWord = strtoupper(CommonUtil::convertNumberToWords($academicTerm->markObtained))." ONLY";
                                $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterPercentage = round($academicTerm->percentage,2);
                                $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterClass = $academicTerm->class;
                                $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->examType = $academicTerm->historyType;
                            }
                        }
                        else{
                            $semMarkHistory = reset(array_filter($academicTerm->markHistory,function($semMarkHistory){
                                return $semMarkHistory->historyType == "REGULAR";
                            }));
                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->failedStatus = $semMarkHistory->failedStatus;
                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterGrade = $semMarkHistory->grade;
                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterCredit = $academicTerm->credit;
                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterCreditGradePoint = $semMarkHistory->gradePoint;
                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterSgpa = round($semMarkHistory->sgpa, $studentsDetails[$student->id]->roundOff);
                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterTotalMarks = $academicTerm->totalMarks;
                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterMarkObtained = $semMarkHistory->markObtained;
                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterMarkObtainedInWord = strtoupper(CommonUtil::convertNumberToWords($semMarkHistory->markObtained))." ONLY";
                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterPercentage = round($semMarkHistory->percentage,2);
                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterClass = $semMarkHistory->class;
                            $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->examType = $semMarkHistory->historyType;
                        }
                    }
                }
                if(count($student->academicTerms) > 1){
                    $studentsDetails[$student->id]->overallClass = $student->class;
                    $studentsDetails[$student->id]->overallGrade= $student->grade;
                    $studentsDetails[$student->id]->failedStatus = $student->isFailed;
                }
            }
            $displaySubjectArray = array_values($displaySubjectArray); 
            foreach($studentsDetails as $student){
                $student->academicTerms = array_values($student->academicTerms); 
                $student->otherAcademicTerms = array_values($student->otherAcademicTerms);
                foreach($student->academicTerms as $academicTerm){
                    $academicTerm->subjects = array_values($academicTerm->subjects); 
                    $academicTerm->subjectCategories = array_values($academicTerm->subjectCategories); 
                    foreach($academicTerm->subjectCategories as $subCategory){
                        $subCategory->subjects = array_values($subCategory->subjects); 
                        $subCategory->totaCategoryAwardedMark = 0;
                        foreach($subCategory->subjects as $subject){
                            $subCategory->totaCategoryAwardedMark += $subject->internalMark + $subject->externalMark;
                        }
                    }
                } 
            }
            $response->studentsDetails = $studentsDetails;
            $response->displaySubjects = $displaySubjectArray;
            return $response;
        }
        catch (\Exception $e){
            throw new ExamControllerException($e->getCode(),$e->getMessage());
        }
    }
     /**
     * getExamRegistrationDetailsForTabulationRegisterReports
     * @param searchRequest
     * @return examRegistrationDetails
     * @author Krishnajith
     */
    public function getExamRegistrationDetailsForTabulationRegisterReports($searchRequest){
        try{ 
            $searchRequest = $this->realEscapeObject($searchRequest);
            $request = new \stdClass;
            $request->examRegistrationId = $searchRequest->examRegistrationId;
            $request->groupId = $searchRequest->groupId;
            $finalTermId = CommonExamService::getInstance()->getFinalAcademicTermDetails($request); 
            $trDate = $this->getTrDatesAndModerationMark($request);
            $examRegistrationDetails = new \stdClass;
            $examRegistrationDetailsArray = ExamRegistrationService::getInstance()->searchDetailedExamRegistrationDetails($searchRequest);
            if(empty($examRegistrationDetailsArray)){
                throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found");
            }
            $examRegistrationDetails->isSpecialExam = reset($examRegistrationDetailsArray)->properties->isSpecialExam == '1' ? true : false;
            $examRegistrationDetails->name = reset($examRegistrationDetailsArray)->name;
            $examRegistrationDetails->examYear = reset($examRegistrationDetailsArray)->examYear;
            $examRegistrationDetails->examMonth = reset($examRegistrationDetailsArray)->examMonth;
            $examRegistrationDetails->examMonthName = reset($examRegistrationDetailsArray)->examMonthName;
            $examRegistrationDetails->type = reset($examRegistrationDetailsArray)->type;
            $examRegistrationDetails->groupId = reset($examRegistrationDetailsArray)->groups[0]->groupId;
            $examRegistrationDetails->groupName = reset($examRegistrationDetailsArray)->groups[0]->groupName;
            $examRegistrationDetails->courseTypeID = reset($examRegistrationDetailsArray)->groups[0]->courseTypeID;
            $examRegistrationDetails->courseTypeName = reset($examRegistrationDetailsArray)->groups[0]->courseTypeName;
            $examRegistrationDetails->academicTermName = reset($examRegistrationDetailsArray)->groups[0]->academicTermName;
            $examRegistrationDetails->academicTermYear = reset($examRegistrationDetailsArray)->groups[0]->academicTermYear;
            $examRegistrationDetails->academicTermYearRoman = strtoupper(CommonUtil::convertNumberToRoman($examRegistrationDetails->academicTermYear));
            $examRegistrationDetails->academicTermId = reset($examRegistrationDetailsArray)->groups[0]->academicTermId;
            $examRegistrationDetails->isFinalSemester = $examRegistrationDetails->academicTermId == $finalTermId ? true : false;
            $semesterNames = CommonExamService::getInstance()->getDifferentSemesterName($examRegistrationDetails->academicTermName);
            $examRegistrationDetails->semInRomanLetter = $semesterNames->romanLetter;
            $examRegistrationDetails->semInFullName = $semesterNames->fullName;
            $examRegistrationDetails->semInSemNumber = $semesterNames->semNumber;
            $examRegistrationDetails->batchStartYear = reset($examRegistrationDetailsArray)->groups[0]->batchStartYear;
            $examRegistrationDetails->batchEndYear = reset($examRegistrationDetailsArray)->groups[0]->properties->endYear;
            $examRegistrationDetails->deptID = reset($examRegistrationDetailsArray)->groups[0]->deptID;
            $examRegistrationDetails->deptName = reset($examRegistrationDetailsArray)->groups[0]->deptName;
            $examRegistrationDetails->degreeName = reset($examRegistrationDetailsArray)->groups[0]->degreeName;
            $examRegistrationDetails->degreeDescription = reset($examRegistrationDetailsArray)->groups[0]->degreeDescription;
            $examRegistrationDetails->streamName = reset($examRegistrationDetailsArray)->groups[0]->streamName;
            $examRegistrationDetails->supplyOrImprove = reset($examRegistrationDetailsArray)->type;
            $examRegistrationDetails->boardMeatingDate = $trDate->boardMeatingDate ? date("d-m-Y", strtotime( $trDate->boardMeatingDate)) : "-";
            $examRegistrationDetails->resultPublishDate = $trDate->resultPublishDate ? date("d-m-Y", strtotime( $trDate->resultPublishDate)) : "-";
            $examRegistrationDetails->moderation = $trDate->moderation ? $trDate->moderation : "-";
            return $examRegistrationDetails;
        }
        catch (\Exception $e){
            throw new ExamControllerException($e->getCode(),$e->getMessage());
        }
    }
      /**
     * getTrDatesAndModerationMark
     * @param searchRequest
     * @return response
     * @author Krishnajith
     */
    public function getTrDatesAndModerationMark($searchRequest){
        try {
            $searchRequest = $this->realEscapeObject($searchRequest);
            $response = new \stdClass;
            $groupId = $searchRequest->groupId;
            $request = new \stdClass;
            $request->groupId = $searchRequest->groupId;
            if($searchRequest->isConsolidated){
                $examRegistrationId = $this->getLastSemesterRegularExamRegistrationId($request);
            }
            else{
                $examRegistrationId = $searchRequest->examRegistrationId;
            }
            $trDate = $this->getTrDatesAndModeration($examRegistrationId,$groupId);
            $response->boardMeatingDate = $trDate->boardMeatingDate;
            $response->resultPublishDate = $trDate->resultPublishDate;
            $response->moderation = $trDate->moderation;
            return $response;
        }
        catch (\Exception $e){
            throw new ExamControllerException($e->getCode(),$e->getMessage());
        }
    }
    /**
     * get Tr Dates And Moderation
     * @param $examRegistrationId , $groupId
     * @return $trDate 
     */
    public function getTrDatesAndModeration($examRegistrationId,$groupId){
        $groupId = $this->realEscapeString($groupId);
        $examRegistrationId = $this->realEscapeString($examRegistrationId);
        try{
            $query = "SELECT etd.board_meating_date AS boardMeatingDate,
                            etd.result_publish_date AS resultPublishDate,
                            etd.moderation AS moderation
                        FROM 
                            ec_tr_dates etd 
                        WHERE 
                            etd.ec_exam_registration_id = '$examRegistrationId' AND etd.groups_id = '$groupId'"; 
            $trDate = $this->executeQueryForObject($query);
        }
        catch (\Exception $e){
            throw new ExamControllerException($e->getCode(),$e->getMessage());
        }
        return $trDate;
        
    }
    /**
     * save Tr Dates And Moderation
     * @param  $insertionValues
     */
    public function saveTrDatesAndModeration($searchRequest){
        try {
            $searchRequest = $this->realEscapeObject($searchRequest);
            $request = new \stdClass;
            $insertionRequest = new \stdClass;
            $request->groupId = $searchRequest->groupId;
            if($searchRequest->isConsolidated){
                $insertionRequest->examRegistrationId = $this->getLastSemesterRegularExamRegistrationId($request);
            }
            else{
                $insertionRequest->examRegistrationId = $searchRequest->examRegistrationId;
            }
            
            $insertionRequest->groupId = $searchRequest->groupId;
            if(!empty($searchRequest->boardMeatingDate)){
                $insertionRequest->boardMeatingDate = date("Y-m-d", strtotime($searchRequest->boardMeatingDate));
            }
            else{
                $insertionRequest->boardMeatingDate = date("Y-m-d");
            }
            if(!empty($searchRequest->resultPublishDate)){
                $insertionRequest->resultPublishDate = date("Y-m-d", strtotime($searchRequest->resultPublishDate));
            }
            else{
                $insertionRequest->resultPublishDate = date("Y-m-d");
            }
            $insertionRequest->moderation = $searchRequest->moderation;
            $insertionRequest->staffId = $GLOBALS['userId'];
            if(empty($insertionRequest->groupId) || empty($insertionRequest->examRegistrationId)){
                throw new ExamControllerException(ExamControllerException::EMPTY_PARAMETERS_TR_DATES_AND_MODERATION," Invailed Parameter ! We Can't Save TR Dates");
            }
            $this->insertTrDatesAndModeration($insertionRequest);
        }
        catch (\Exception $e){
            throw new ExamControllerException($e->getCode(),$e->getMessage());
        } 
    }
     /**
     * getLastSemesterRegularExamRegistrationId
     * @param $searchRequest 
     */
    public function getLastSemesterRegularExamRegistrationId($searchRequest) {
        $searchRequest = $this->realEscapeObject($searchRequest);
        try{
            $whereQuery = "";
            if(!empty($searchRequest->groupId)) {
                $groupIdString = is_array($searchRequest->groupId) ? "'" . implode("','",$searchRequest->groupId) . "'" : "'".$searchRequest->groupId."'";
                $whereQuery .= " AND g.id IN ( $groupIdString )";
            }
            $query = "SELECT DISTINCT
                        eer.id AS id
                    FROM
                        `groups` g
                    INNER JOIN ec_exam_registration_batch eerb ON
                        eerb.groups_id = g.id
                    INNER JOIN ec_exam_registration eer ON
                        eer.id = eerb.ec_exam_registration_id
                    WHERE CAST(eerb.properties ->> '$.academicTermId' AS CHAR) = g.properties ->> '$.finalTermId' AND eer.type ='REGULAR' ";
            $examRegistrationId = $this->executeQueryForObject($query.$whereQuery);
        }
        catch (\Exception $e){
            throw new ExamControllerException($e->getCode(),$e->getMessage());
        }
        return $examRegistrationId->id;
    }
      /**
     * insert Tr Dates And Moderation
     * @param  $insertionValues
     */
    public function insertTrDatesAndModeration($insertionValuesObj){
        try {
            $insert_query = "INSERT INTO ec_tr_dates
                                (groups_id,ec_exam_registration_id,board_meating_date,result_publish_date,moderation,created_by,created_date)
                                VALUES ('$insertionValuesObj->groupId','$insertionValuesObj->examRegistrationId','$insertionValuesObj->boardMeatingDate','$insertionValuesObj->resultPublishDate','$insertionValuesObj->moderation','$insertionValuesObj->staffId',now())
                                 ON DUPLICATE KEY UPDATE board_meating_date = VALUES(board_meating_date) , result_publish_date = VALUES(result_publish_date) , moderation = VALUES(moderation), updated_by = VALUES(created_by)" ;
            $this->executeQuery($insert_query);
        }
        catch (\Exception $e){
            throw new ExamControllerException($e->getCode(),$e->getMessage());
        }
    }
    public function getSupplyTabulationRegisterReport($searchRequest){
        try{ 
            $searchRequest = $this->realEscapeObject($searchRequest);
            $request = new \stdClass;
            $request->groupId = $searchRequest->groupId;
            $request->examRegistrationId = $searchRequest->examRegistrationId;
            $request->isSupplyTR = true;
            $request->studentId = $searchRequest->studentId;
            $request->isPrint = $searchRequest->isPrint;
            $request->academicTermId = $searchRequest->academicTermId;
            $programResult = SupplementaryTabulationRegisterGenerator::getInstance()->getSupplementaryTabulationRegisterResultData($request);
            return $programResult;
        }
        catch (\Exception $e){
            throw new ExamControllerException($e->getCode(),$e->getMessage());
        }
    }
    /**
     * get All Registered Students Details For Supplemenary Tabulation Register
     * @param $searchRequest 
     */
    public function getAllRegistredStudentIdsForSupplemenaryTabulationRegister($searchRequest) {
        $searchRequest = $this->realEscapeObject($searchRequest);
        try{
            $orderBy = " ORDER BY sa.regNo ASC";
            $whereQuery = "";
            if(!empty($searchRequest->groupId)) {
                $groupIdString = is_array($searchRequest->groupId) ? "'" . implode("','",$searchRequest->groupId) . "'" : "'".$searchRequest->groupId."'";
                $whereQuery .= " AND g.id IN ( $groupIdString )";
            }
            if(!empty($searchRequest->isLastSemsterOnly)){
                $whereQuery .= " AND CAST(eerb.properties ->> '$.academicTermId' AS CHAR) = g.properties ->> '$.finalTermId'";
            }
            else if(!empty($searchRequest->academicTermId)) {
                $semesterIdString = is_array($searchRequest->academicTermId) ? "'" . implode("','",$searchRequest->academicTermId) . "'" : "'".$searchRequest->academicTermId."'";
                $whereQuery .= " AND CAST(eerb.properties ->> '$.academicTermId'AS CHAR) IN ( $semesterIdString )";
            }
            if(!empty($searchRequest->examRegistrationId)) {
                $examRegistrationIdString = is_array($searchRequest->examRegistrationId) ? "'" . implode("','",$searchRequest->examRegistrationId) . "'" : "'".$searchRequest->examRegistrationId."'";
                $whereQuery .= " AND eerb.ec_exam_registration_id IN ( $examRegistrationIdString )";
            }
            if(!empty($searchRequest->studentId)) {
                $studentIdString = is_array($searchRequest->studentId) ? "'" . implode("','",$searchRequest->studentId) . "'" : "'".$searchRequest->studentId."'";
                $whereQuery .= " AND esar.student_id IN ( $studentIdString )";
            }
            $query = "SELECT DISTINCT
                        esar.student_id AS id
                    FROM
                        `groups` g
                    INNER JOIN ec_exam_registration_batch eerb ON
                        eerb.groups_id = g.id
                    INNER JOIN ec_exam_registration eer
                        ON eer.id = eerb.ec_exam_registration_id 
                    INNER JOIN ec_exam_registration_subject eers ON
                        eers.ec_exam_registration_batch_id = eerb.id
                    INNER JOIN  cm_academic_paper_subjects aps ON 
                        eers.cm_academic_paper_subjects_id = aps.id
                    INNER JOIN ec_student_assessment_registration esar ON
                        esar.am_assessment_id = eers.am_assessment_id AND 
                        esar.ec_exam_registration_type = eer.type AND
                        CAST(esar.properties ->> '$.registrationStatus' AS CHAR) = 'REGISTERED' AND 
                        CAST(esar.properties ->> '$.feeStatus' AS CHAR) = 'PAID'
                    INNER JOIN studentaccount sa ON 
                        sa.studentID = esar.student_id
                    WHERE 1=1";
            $registredStudentIds = $this->executeQueryForList($query.$whereQuery.$orderBy);
        }
        catch (\Exception $e)
        {
            throw new ExamControllerException($e->getCode(),$e->getMessage());
        }
        foreach($registredStudentIds as $student){
            $registredStudentIdArray[] = $student->id;
        }
        return $registredStudentIdArray;
    }
   
     /**
     * processStudentDataForSupplyTabulationRegister
     * @param studentDetails
     * @return studentDetails
     * @author Krishnajith
     */
    public function processStudentDataForSupplyTabulationRegister($studentMarkDetails,$request){
        try{ 
            $examRegistrationData = $this->getExamRegistrationDetailsForTabulationRegisterReports($request);
            $examYear = $examRegistrationData->examYear;
            $examMonth = $examRegistrationData->examMonth;
            $currentMonthYear = $examYear."-".$examMonth;
            $studentsDetailsObj = new \stdClass;
            $response = new \stdClass;
            $displaySubjectArray = [];
            $supplimentaryStudentIds = [];
            $improvementStudentIds = [];
            $studentsDetails = [];
            foreach($studentMarkDetails as $student){
                $studentsDetails[$student->id]->id = $student->id;
                $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;
                $studentsDetails[$student->id]->roundOff = $student->studentDetails->academicYear < 2019 ?  2 : 3;;
                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;
                    foreach($academicTerm->markHistory as $semMarkHistory){
                        $historyExamYear = $semMarkHistory->examYear;
                        $historyExamMonth = $semMarkHistory->examMonth;
                        $historyMonthYear = $historyExamYear."-".$historyExamMonth;
                        if($currentMonthYear >= $historyMonthYear){
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$historyMonthYear]->failedStatus = $semMarkHistory->failedStatus;
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$historyMonthYear]->semesterGrade = $semMarkHistory->grade;
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$historyMonthYear]->semesterCredit = $academicTerm->credit;
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$historyMonthYear]->semesterCreditGradePoint = $semMarkHistory->gradePoint;
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$historyMonthYear]->semesterSgpa = round($semMarkHistory->sgpa, $studentsDetails[$student->id]->roundOff);
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$historyMonthYear]->semesterTotalMarks = $academicTerm->totalMarks;
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$historyMonthYear]->semesterMarkObtained = $semMarkHistory->markObtained;
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$historyMonthYear]->semesterMarkObtainedInWord = strtoupper(CommonUtil::convertNumberToWords($semMarkHistory->markObtained))." ONLY";
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$historyMonthYear]->semesterPercentage = round($semMarkHistory->percentage,2);
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$historyMonthYear]->semesterClass = $semMarkHistory->class;
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$historyMonthYear]->semesterClass = $semMarkHistory->class;
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$historyMonthYear]->overallGrade = $semMarkHistory->grade;
                            $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$historyMonthYear]->examType = $semMarkHistory->historyType;
                            
                        }
                    }
                    foreach( $academicTerm->subjects as $subject){
                        foreach($subject->markHistory as $subMarkHistory){
                            $subHistoryExamYear = $subMarkHistory->examYear;
                            $subHistoryExamMonth = $subMarkHistory->examMonth;
                            $subHistoryMonthYear = $subHistoryExamYear."-".$subHistoryExamMonth;
                            $examTypesArray = ["REGULAR","SUPPLY","IMPROVEMENT"];
                            if($subMarkHistory->examMarkType != 'REGULAR'){
                                if($subMarkHistory->examMarkType == 'SUPPLY' ){
                                    $supplimentaryStudentIds[] = $student->id;
                                }
                                elseif($subMarkHistory->examMarkType == 'IMPROVEMENT'){
                                    $improvementStudentIds[] = $student->id;
                                }
                            }
                            if($currentMonthYear >= $subHistoryMonthYear && in_array ( $subMarkHistory->examMarkType, $examTypesArray )){
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->id = $subject->id;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->name = $subject->name;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->code = $subject->code;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->externalMaxMark = $subject->externalMaxMark;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->internalMaxMark = $subject->internalMaxMark;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->class = $subMarkHistory->class;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->grade = $subMarkHistory->grade;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->percentage = round($subMarkHistory->percentage,2);
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->internalMark = $subject->internalMark;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->externalMark = $subMarkHistory->externalMark;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->markObtained = $subMarkHistory->markObtained;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->totalMaxMark = $subject->totalMaxMark;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->markObtainedInWord = strtoupper(CommonUtil::convertNumberToWords((int)$subMarkHistory->markObtained));
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->failedStatus = $subMarkHistory->resultStatus;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->attendanceStatus = $subMarkHistory->attendanceStatus;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->credit = $subject->credit;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->creditGradePoint =  $subject->credit * $subMarkHistory->gradePoint;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->gradePoint = $subMarkHistory->gradePoint;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->internalGrade = $subject->internalGrade;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->externalGrade = $subMarkHistory->externalGrade;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->internalGradePoint = $subject->internalGradePoint;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->externalGradePoint = $subMarkHistory->externalGradePoint;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->wgpa = $subMarkHistory->wgpa;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->isExternalFailed = $subMarkHistory->isExternalFailed;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->internalGrade = $subject->internalGrade;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->isInternalFailed = $subject->isInternalFailed;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->isInternal = $subject->isInternal;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->isExternal = $subject->isExternal;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->categoryId = $subject->categoryId;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->categoryName = $subject->categoryName;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->internalGrade = $subject->internalGrade;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->internalLetterGrade = $subject->internalLetterGrade;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->externalLetterGrade = $subMarkHistory->externalLetterGrade;
                                $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->markHistory[$subHistoryMonthYear]->subjects[$subject->id]->examType = $subMarkHistory->examMarkType;
                            }
                        }
                        $displaySubjectArray[$subject->id]= $subject;
                    }
                }
            }
            $displaySubjectArray = array_values($displaySubjectArray); 
            foreach($studentsDetails as $student){
                $student->academicTerms = array_values($student->academicTerms); 
                foreach($student->academicTerms as $academicTerm){
                    ksort($academicTerm->markHistory);
                    $academicTerm->markHistory = array_values($academicTerm->markHistory); 
                    foreach($academicTerm->markHistory as $subMarkHistory){
                        $subMarkHistory->subjects = array_values($subMarkHistory->subjects);
                    }
                } 
            }
            foreach($studentsDetails as $student){
                if ( in_array ( $student->id, $supplimentaryStudentIds ) ) {
                    $studentsDetailsObj->supplementaryStudents[] = $student;
                }
                if ( in_array ( $student->id, $improvementStudentIds ) ) {
                    $studentsDetailsObj->improvementStudents[] = $student;
                }
            }
            $response->studentsDetails = $studentsDetailsObj;
            $response->displaySubjects = $displaySubjectArray;
            return $response;
        }
        catch (\Exception $e){
            throw new ExamControllerException($e->getCode(),$e->getMessage());
        }
    }
    public function getConsolidatedTabulationRegisterReport($searchRequest){
        try{ 
            $searchRequest = $this->realEscapeObject($searchRequest);
            $request = new \stdClass;
            $request->groupId = $searchRequest->groupId;
            $programResult = ConsolidatedTabulationRegisterGenerator::getInstance()->getConsolidatedTabulationRegisterResultData($request);
            return $programResult;
        }
        catch (\Exception $e){
            throw new ExamControllerException($e->getCode(),$e->getMessage());
        }
    }
     /**
     * processStudentDataForConsolidatedTabulationRegister
     * @param studentDetails
     * @return studentDetails
     * @author Krishnajith
     */
    public function processStudentDataForConsolidatedTabulationRegister($studentMarkDetails,$request){
        try{ 
            $response = new \stdClass;
            $displaySubjectArray = [];
            $displayOtherAcademicTermArray = [];
            $studentsDetails = [];
            foreach($studentMarkDetails as $student){
                $studentsDetails[$student->id]->id = $student->id;
                $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;
                $studentsDetails[$student->id]->failedStatus = $student->isFailed;
                $studentsDetails[$student->id]->cgpa = $student->cgpa;
                $studentsDetails[$student->id]->grade = $student->grade;
                $studentsDetails[$student->id]->finalTermId = $student->studentDetails->finalTermId;
                $studentsDetails[$student->id]->roundOff = $student->studentDetails->academicYear < 2019 ?  2 : 3;;
                foreach($student->academicTerms as $academicTerm){
                    if($academicTerm->id  == $studentsDetails[$student->id]->finalTermId){
                        $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;
                        foreach($academicTerm->markHistory as $semMarkHistory){
                            if($semMarkHistory->historyType == "REGULAR"){
                                $examRegistrationId = $semMarkHistory->examRegistrationId;
                            }
                        }
                        $academicTermId = $studentsDetails[$student->id]->finalTermId;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->failedStatus = $academicTerm->isFailed;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterGrade = $academicTerm->grade;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterCredit = $academicTerm->credit;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterCreditGradePoint = $academicTerm->gradePoint;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterSgpa = round($academicTerm->sgpa, $studentsDetails[$student->id]->roundOff);
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterTotalMarks = $academicTerm->totalMarks;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterMarkObtained = $academicTerm->totalMark;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterMarkObtainedInWord = strtoupper(CommonUtil::convertNumberToWords($semMarkHistory->totalMark))." ONLY";
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterPercentage = round($academicTerm->percentage,2);
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->semesterClass = $academicTerm->class;
                        $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->examType = $academicTerm->historyType;
                        foreach( $academicTerm->subjects as $subject){
                            $displaySubjectArray[$subject->id]= $subject;
                            foreach($subject->markHistory as $subMarkHistory){
                                if($subMarkHistory->examMarkType == "REGULAR"){
                                    $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]->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 = $subMarkHistory->class;
                                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->grade = $subMarkHistory->grade;
                                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->percentage = round($subMarkHistory->percentage,2);
                                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->internalMark = $subject->internalMark;
                                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalMark = $subMarkHistory->externalMark;
                                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->totalMaxMark = $subject->totalMaxMark;
                                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->markObtained = $subMarkHistory->markObtained;
                                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->markObtainedInWord =  strtoupper(CommonUtil::convertNumberToWords((int)$subMarkHistory->markObtained));
                                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->failedStatus = $subMarkHistory->resultStatus;
                                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->attendanceStatus =  $subMarkHistory->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 * $subMarkHistory->gradePoint;
                                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->gradePoint = $subMarkHistory->gradePoint;
                                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->internalGrade = $subject->internalGrade;
                                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalGrade = $subMarkHistory->externalGrade;
                                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->internalGradePoint = $subject->internalGradePoint;
                                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalGradePoint = $subMarkHistory->externalGradePoint;
                                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->wgpa = $subMarkHistory->wgpa;
                                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->isExternalFailed = $subMarkHistory->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]->internalLetterGrade = $subject->internalLetterGrade;
                                    $studentsDetails[$student->id]->academicTerms[$academicTerm->id]->subjects[$subject->id]->externalLetterGrade = $subMarkHistory->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;  
                                }
                            }
                        }
                    }
                    else{
                        $latestExamMonthYear = "";
                        foreach($academicTerm->markHistory as $semMarkHistory){
                            $historyExamYear = $semMarkHistory->examYear;
                            $historyExamMonth = $semMarkHistory->examMonth;
                            $historyMonthYear = $historyExamYear."-".$historyExamMonth;
                            if($historyMonthYear > $latestExamMonthYear){
                                $latestExamMonthYear = $historyMonthYear;
                                $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->latestExamYear = $semMarkHistory->examYear;
                                $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->latestExamMonth = $semMarkHistory->examMonth;
                            }
                        }
                        $displayOtherAcademicTermArray[$academicTerm->id]->id= $academicTerm->id;
                        $displayOtherAcademicTermArray[$academicTerm->id]->name= $academicTerm->name;
                        $displayOtherAcademicTermArray[$academicTerm->id]->academicTermOrderNo= $academicTerm->academicTermOrderNo;
                        $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->id = $academicTerm->id;
                        $semesterNames = CommonExamService::getInstance()->getDifferentSemesterName($academicTerm->name);
                        $displayOtherAcademicTermArray[$academicTerm->id]->semInRomanLetter= $semesterNames->romanLetter;
                        $displayOtherAcademicTermArray[$academicTerm->id]->semInFullName= $semesterNames->fullName;
                        $displayOtherAcademicTermArray[$academicTerm->id]->semInSemNumber = $semesterNames->semNumber;
                        $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semInRomanLetter = $semesterNames->romanLetter;
                        $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semInFullName = $semesterNames->fullName;
                        $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semInSemNumber = $semesterNames->semNumber;
                        $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->failedStatus = $academicTerm->isFailed;
                        $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterGrade = $academicTerm->grade;
                        $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterCredit = $academicTerm->credit;
                        $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterCreditGradePoint = $academicTerm->gradePoint;
                        $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterSgpa = round($academicTerm->sgpa, $studentsDetails[$student->id]->roundOff);
                        $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterTotalMarks = $academicTerm->totalMarks;
                        $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterMarkObtained = $academicTerm->totalMark;
                        $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterMarkObtainedInWord = strtoupper(CommonUtil::convertNumberToWords($academicTerm->totalMark))." ONLY";
                        $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterPercentage = round($academicTerm->percentage,2);
                        $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->semesterClass = $academicTerm->class;
                        $studentsDetails[$student->id]->otherAcademicTerms[$academicTerm->id]->examType = $academicTerm->historyType;
                    }
                }
            }
            $displaySubjectArray = array_values($displaySubjectArray);
            $displayOtherAcademicTermArray = array_values($displayOtherAcademicTermArray);  
            usort($displayOtherAcademicTermArray,function($a,$b){
                return (int)$a->academicTermOrderNo > (int)$b->academicTermOrderNo;
            });
            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->displaySemesters = $displayOtherAcademicTermArray;
            $response->examRegistrationId = $examRegistrationId;
            $response->academicTermId = $academicTermId;
            return $response;
        }
        catch (\Exception $e){
            throw new ExamControllerException($e->getCode(),$e->getMessage());
        }
    }
      /**
     * getTabulationRegisterSettings
     * @author Krishnajith
     */
    public function getTabulationRegisterSettings(){
        $response = new \stdClass;
        $searchRuleRequest = new SearchRuleRequest;
        $searchRuleRequest->name = "TABULATION_REGISTER_SETTINGS";
        $trSettingsObj = RuleService::getInstance()->searchRule($searchRuleRequest);
        $response = new \stdClass;
        $response->printForSelectedStudents = reset($trSettingsObj)->rule->printForSelectedStudents ? true : false;
        $response->isShowFilter = reset($trSettingsObj)->rule->isShowFilter =='1' ? true : false;
        return $response;
    }
    
     
    
    
    
    
    
    
    
}