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 / 49
CRAP
0.00% covered (danger)
0.00%
0 / 1353
StudentXMLService
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 49
48180.00
0.00% covered (danger)
0.00%
0 / 1353
 __construct
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 1
 __clone
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 1
 getInstance
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 4
 getStudentDetailsByBatchID
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 12
 getSubjectDetails
0.00% covered (danger)
0.00%
0 / 1
90.00
0.00% covered (danger)
0.00%
0 / 58
 getStudentMarkDetailsByBatchId
0.00% covered (danger)
0.00%
0 / 1
1332.00
0.00% covered (danger)
0.00%
0 / 206
 getStudentFailStatus
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 13
 getStudentSupplySubjects
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 13
 getStudentSupplyStatus
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 13
 getStudentSupplyExamMarks
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 15
 getStudentSupplyExamMarksUG
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 15
 subjectDetails
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 12
 getPaperTypeDetails
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 11
 getCourseType
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 12
 getRegularExamMonthAndYear
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 12
 getSupplyExamDateDetails
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 12
 getAbsentMalDetails
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 13
 getSupplyExamId
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 14
 getExamIds
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 12
 getStudentDetails
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 12
 getSubjectIdAndSemId
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 13
 getStudentExternalMark
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 13
 getStudentExternalMarkUG
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 13
 getStudentInternalMark
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 14
 getComplementaryName
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 13
 getBatchIds
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 13
 getStudentMarkDetailsByBatchIdUG
0.00% covered (danger)
0.00%
0 / 1
2550.00
0.00% covered (danger)
0.00%
0 / 322
 getSubjectDetailsUG
0.00% covered (danger)
0.00%
0 / 1
110.00
0.00% covered (danger)
0.00%
0 / 56
 saveCourseSubjectCategoryRelation
0.00% covered (danger)
0.00%
0 / 1
20.00
0.00% covered (danger)
0.00%
0 / 20
 getCourseRelation
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 14
 checkStudentSubjects
0.00% covered (danger)
0.00%
0 / 1
156.00
0.00% covered (danger)
0.00%
0 / 74
 getIntMaxMarks
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 14
 getStudentBeforeModerationMarks
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 13
 getPracticalSubjects
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 14
 getGroupId
0.00% covered (danger)
0.00%
0 / 1
20.00
0.00% covered (danger)
0.00%
0 / 24
 getUniqueExamId
0.00% covered (danger)
0.00%
0 / 1
56.00
0.00% covered (danger)
0.00%
0 / 42
 getUniqueExamIdSupply
0.00% covered (danger)
0.00%
0 / 1
72.00
0.00% covered (danger)
0.00%
0 / 45
 getStudentGraceMarks
0.00% covered (danger)
0.00%
0 / 1
12.00
0.00% covered (danger)
0.00%
0 / 22
 getStudentRevalMarks
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 13
 getPrevSubjectsCombined
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 14
 getPrevExamDetails
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 15
 saveBatchSemWiseExamCode
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 15
 deleteExamCode
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 12
 getExamCode
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 14
 getExamCodeDetailsForAdmissionYear
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 14
 finalSubmissionOfExamCode
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 12
 getFinalSubmittedFlag
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 14
 isBatchExamCodeDefined
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 15
 isExamCodeDefined
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 15
<?php
namespace com\linways\core\ams\professional\service;
use com\linways\core\ams\professional\exception\ProfessionalException;
use com\linways\core\ams\professional\dto\StudentXMLTags;
class StudentXMLService extends BaseService 
{
    private static $_instance = null;
    
    private $mapper = [];
    
    // /Condition 2 - Locked down the constructor
    private function __construct() {
        // $this->mapper = StudentServiceMapper::getInstance()->getMapper();
        
    }
    // Prevent any oustide instantiation of this class
    
    // /Condition 3 - Prevent any object or instance of that class to be cloned
    private function __clone() {
    }
    // Prevent any copy of this object
    
    // /Condition 4 - Have a single globally accessible static method
    public static function getInstance() {
        if (! is_object ( self::$_instance )) // or if( is_null(self::$_instance) ) or if( self::$_instance == null )
            self::$_instance = new self ();
        
        return self::$_instance;
    }
    public function getStudentDetailsByBatchID($batchID)
    {
           $sql = "";
        $studentArray = [];
        
        $batchID = $this->realEscapeString($batchID);
        
        
        
        try {
           $sql = "select DATE_FORMAT(sa.studentBirthday, '%d-%m-%Y') as dob,IF(sa.studentGender='male', 'M', 'F') as sex, sa.*,ba.batchName,ba.batchDesc,ba.batchStartYear AS studentBatchStartYear,ba.batchOptionName,sca.casteName,re.religionName,rs.reservationCode,rs.reservationName,sec.secondLangaugeCode  from studentaccount sa LEFT JOIN batches ba ON sa.batchID=ba.batchID LEFT JOIN student_caste sca on sa.casteID = sca.casteID LEFT JOIN religion re ON sa.religionID = re.religionID LEFT JOIN reservation_students rs ON sa.reservationID = rs.reservationID LEFT JOIN secondLangauge sec ON sec.secondlangaugeID = sa.secondlangaugeID where sa.batchID=$batchID";
           $studentArray = $this->executeQueryForList($sql);
           
           
           
        } catch (\Exception $e) {
           throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
       
        return $studentArray;
        
    }
    public function getSubjectDetails($deptID,$courseTypeID,$batchID)
    {
           $sql = "";
        $subjectArray = [];
        $newSubjectArray = [];
    
        $emax ="";
        $deptID = $this->realEscapeString($deptID);
        $courseTypeID = $this->realEscapeString($courseTypeID);
        $batchID = $this->realEscapeString($batchID);
        
        
        try 
        {
           
            $sql = "SELECT su.*,esc.credit,sc.code as subjectcatName,sem.semID as semName,ct.typeName,ims.maxInternalMarks as imax,egs.schemeName,egs.schemeID,pd.patterncourseCode as courseCode,esc.isInternal,esc.isExternal from subjects su INNER JOIN exam_subjectcredit esc ON su.subjectID=esc.subjectID LEFT JOIN subject_category sc ON su.subjectcatID=sc.subjectcatID LEFT JOIN semesters sem ON su.semID=sem.semID LEFT JOIN course_type ct ON su.courseTypeID=ct.courseTypeID LEFT JOIN internal_marks_settings ims ON su.subjectID = ims.subjectID AND esc.batchID = ims.batchID AND su.semID=ims.semID  LEFT JOIN exam_gradingscheme egs on ct.courseTypeID = egs.courseTypeID LEFT JOIN course_pattern cp ON cp.courseTypeID = ct.courseTypeID INNER JOIN pattern_deptcourses pd ON pd.patternID = cp.patternID and pd.deptID = su.deptID where su.courseTypeID=$courseTypeID AND su.deptID=$deptID AND ims.batchID =$batchID group by su.subjectID order by su.subjectPriority";
           $subjectArray = $this->executeQueryForList($sql);
           
        } catch (\Exception $e) {
           throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        foreach($subjectArray as $subject)
        {
            $isInternal = $subject->isInternal;
            $isExternal = $subject->isExternal;
            $subjectDesc = $subject->subjectDesc;
            $subjectName = $subject->subjectName;
            $subjectDesc = html_entity_decode($subjectDesc);
            $subjectName = html_entity_decode($subjectName);
            $subject->subjectDesc = $subjectDesc;
            $subject->subjectName = $subjectName;
            $tMaxSql = "SELECT MAX(t1.percentTo) as tmax FROM exam_gradepoints t1, exam_gradingscheme t2 where t2.courseTypeID=$subject->courseTypeID and t2.schemeID=t1.schemeID";
            $subject->tmax = $this->executeQueryForObject($tMaxSql)->tmax;
            $tMinSql = "SELECT MIN(t1.percentFrom) as tmin FROM exam_gradepoints t1, exam_gradingscheme t2 where t2.courseTypeID=$subject->courseTypeID and t2.schemeID=t1.schemeID and failStatus=0";
            $subject->tmin = $this->executeQueryForObject($tMinSql)->tmin;
            //$emax = (($subject->imax)+(3*$subject->tmax))/4;
            $eMaxSql = "SELECT examTotalMarks FROM exam WHERE examregID IS NOT NULL AND batchID=$batchID and semID=$subject->semID AND subjectID=$subject->subjectID";
            $externalMAX = $this->executeQueryForObject($eMaxSql)->examTotalMarks;
            $emax = $externalMAX;
            $imax = $subject->imax;
            if(($isInternal == 1) && ($isExternal == 1))
            {
                $subject->emax=$emax;
                $subject->imax= $imax;
                $subject->emin =0;
                $subject->imin=0;
            }
            elseif(($isInternal == 1) && ($isExternal == 0))
            {
                $subject->emax=0;
                $subject->imax= $imax;
                $subject->emin =0;
                $subject->imin=0;
            }
            elseif(($isInternal == 0) && ($isExternal == 1))
            {
                $subject->emax=$emax;
                $subject->imax= 0;
                $subject->emin =0;
                $subject->imin=0;
            }
            $newSubjectArray[]=$subject;
        }
        return $newSubjectArray;
        
    }
    /**
     * Method for getting student mark details by batchId and courseTypeId (PG)
     * @param unknown $batchId
     * @throws ProfessionalException
     * @return object|array|\com\linways\base\util\$objectList[]
     * @author Ranjith Balachandran
     */
 
    public function getStudentMarkDetailsByBatchId($batchId,$courseTypeId)
    {
        $sql = '';
        
        $batchId = $this->realEscapeString($batchId);
        $courseTypeId = $this->realEscapeString($courseTypeId);
        
        $studentMarkDetails = [];
        $studentMarkArray = [];
        /** get full regular exam details for a batch **/
        $getAllExamIds = StudentXMLService::getInstance()->getExamIds($batchId);
        
        /** get full student details in that batch **/
        $studentFullDetails = StudentXMLService::getInstance()->getStudentDetails($batchId);
        foreach ($studentFullDetails as $studentDetails) 
        {
            $studentId = $studentDetails->studentId;
            foreach ($getAllExamIds as $examIds)
            {
                $studentRegularExamId = $examIds->examID;
                
                /*get ExamtotalMarks*/ $examTotalMarks = $examIds->examTotalMarks;
                $subjectIdAndSemId = StudentXMLService::getInstance()->getSubjectIdAndSemId($batchId, $studentRegularExamId);
                /*get subjectId*/ $studentSubjectId = $subjectIdAndSemId->subjectID;
                
                /*get semId*/ $studentSemId = $subjectIdAndSemId->semID;
                
                $regularMarkDetails = new StudentXMLTags();
                $subjectDetails = StudentXMLService::getInstance()->subjectDetails($studentSubjectId,$batchId);
                /*get InternalFlag*/ $isInternal = $subjectDetails->isInternal;
                /*get ExternalFlag*/ $isExternal = $subjectDetails->isExternal;
                $studentRegNo = $studentDetails->regNo;
                /* xml data */ $regularMarkDetails->studentRegNo = $studentRegNo;
                $paperName = html_entity_decode($subjectDetails->subjectDesc);
                /* xml data */ $regularMarkDetails->paperName = $paperName;
                
                /* xml data */ $regularMarkDetails->semId = $studentSemId;
                /** get student internakl mark **/
                $studentInternalMark = StudentXMLService::getInstance()->getStudentInternalMark($studentId, $batchId, $studentSemId, $studentSubjectId);
                if(($isExternal == 1) && ($isInternal == 1))
                {
                    /** get student external mark **/
                    $studentExternalMark = StudentXMLService::getInstance()->getStudentExternalMark($studentId, $studentRegularExamId);
                    
                    $studentExternalMark = round($studentExternalMark);
                    
                    if(empty($studentExternalMark))
                    {
                        $studentOtherDetails = StudentXMLService::getInstance()->getAbsentMalDetails($studentId, $studentRegularExamId);
                        
                        if($studentOtherDetails == 1){
                            $studentExternalMark = 'A';
                        }elseif($studentOtherDetails == 2){
                            $studentExternalMark = 'MAL';
                        }else{
                            $studentExternalMark = 0;
                        }
                    }
                    
                    $studentExternalMarkOutOfFour = ($studentExternalMark/$examTotalMarks)*4;
                    $studentExternalMarkOutOfFour = round($studentExternalMarkOutOfFour,2);
                    /* xml data */ $regularMarkDetails->externalMark = $studentExternalMark;
                    
                    /* xml data */ $regularMarkDetails->studentInternalMark = $studentInternalMark;
                    $totalGradePoint = ($studentInternalMark + (3*$studentExternalMarkOutOfFour))/4;
                
                    $studentPassStatus = StudentXMLService::getInstance()->getStudentFailStatus($totalGradePoint, $courseTypeId);
                }
                elseif(($isInternal == 1) && ($isExternal == 0))
                {
                    
                    /* xml data */ $regularMarkDetails->externalMark = "";
                    /* xml data */ $regularMarkDetails->studentInternalMark = $studentInternalMark;
                    $totalGradePoint = $studentInternalMark;
                
                    $studentPassStatus = StudentXMLService::getInstance()->getStudentFailStatus($totalGradePoint, $courseTypeId);
                }
                elseif(($isExternal == 1) && ($isInternal == 0))
                {
                   
                    /** get student external mark **/
                    $studentExternalMark = StudentXMLService::getInstance()->getStudentExternalMark($studentId, $studentRegularExamId);
                    $studentExternalMark = round($studentExternalMark);
                    
                    if(empty($studentExternalMark))
                    {
                        $studentOtherDetails = StudentXMLService::getInstance()->getAbsentMalDetails($studentId, $studentRegularExamId);
                        
                        if($studentOtherDetails == 1){
                            $studentExternalMark = 'A';
                        }elseif($studentOtherDetails == 2){
                            $studentExternalMark = 'MAL';
                        }else{
                            $studentExternalMark = 0;
                        }
                    }
                    
                    $studentExternalMarkOutOfFour = ($studentExternalMark/$examTotalMarks)*4;
                    $studentExternalMarkOutOfFour = round($studentExternalMarkOutOfFour,2);
                    /* xml data */ $regularMarkDetails->externalMark = $studentExternalMark;
                    
                    $studentInternalMark = "";
                    /* xml data */ $regularMarkDetails->studentInternalMark = $studentInternalMark;
                    $totalGradePoint = $studentExternalMarkOutOfFour;
                
                    $studentPassStatus = StudentXMLService::getInstance()->getStudentFailStatus($totalGradePoint, $courseTypeId);
                }
                $moderation = 0;
                /* xml data */ $regularMarkDetails->moderation = $moderation;
                
                $regularExamDateDetails = StudentXMLService::getInstance()->getRegularExamMonthAndYear($studentRegularExamId);
                
                $examDate = $regularExamDateDetails->examMonth."/".$regularExamDateDetails->examYear;
                /* xml data */ $regularMarkDetails->examDate = $examDate;
                
                $syllabusCode = $subjectDetails->subjectName;
                $syllabusCode = html_entity_decode($syllabusCode);
                
                /* xml data */ $regularMarkDetails->syllabusCode = $syllabusCode;
                
                
                if($studentPassStatus == 0){
                    $studentPassStatus = "P";
                    /* xml data */ $regularMarkDetails->studentPassStatus = $studentPassStatus;
                }else{
                    $studentPassStatus = "F";
                    /* xml data */ $regularMarkDetails->studentPassStatus = $studentPassStatus;
                }
                
                $studentSupplyStatus = "R";
                /* xml data */ $regularMarkDetails->studentSupplyStatus = $studentSupplyStatus;
                $studentMarkArray[] = $regularMarkDetails;
                
                $examSuppId = StudentXMLService::getInstance()->getStudentSupplySubjects($studentRegularExamId, $studentId);
                
                if(count($examSuppId))
                {
                    foreach ($examSuppId as $suppIdDetails)
                    {
                        $supplyMarkDetails = new StudentXMLTags();
                        $suppId = $suppIdDetails->examSuppId;
                        $studentSuppMarkDetails = StudentXMLService::getInstance()->getStudentSupplyExamMarks($studentId, $suppId, $studentSubjectId, $batchId);
                        $examTotalMarks = $studentSuppMarkDetails->examTotalMarks;
                        $studentSupplyExamId = StudentXMLService::getInstance()->getSupplyExamId($suppId, $batchId, $studentSubjectId);
                        /* xml data */ $supplyMarkDetails->studentRegNo = $studentRegNo;
                        /* xml data */ $supplyMarkDetails->paperName = $paperName;
                        /* xml data */ $supplyMarkDetails->semId = $studentSemId;
                        /* xml data */ $supplyMarkDetails->syllabusCode = $syllabusCode;
                        if(($isInternal == 1) && ($isExternal == 1))
                        {
                            /* xml data */ $supplyMarkDetails->studentInternalMark = $studentInternalMark;
                            $studentSuppMark = $studentSuppMarkDetails->studentExternalSupplyMark;
                            $studentSuppMark = round($studentSuppMark);
                            
                            if(empty($studentSuppMark))
                            {
                                if($studentSupplyExamId){
                                    $studentOtherDetails = StudentXMLService::getInstance()->getAbsentMalDetails($studentId, $studentSupplyExamId);
                                
                                    if($studentOtherDetails == 1){
                                        $studentSuppMark = 'A';
                                    }elseif($studentOtherDetails == 2){
                                        $studentSuppMark = 'A';
                                    }else{
                                        $studentSuppMark = 0;
                                    }    
                                }else{
                                    $studentSuppMark = 0;
                                }
                                
                            }
                            
                            if($examTotalMarks){
                                $studentSuppMarkOutOfFour = ($studentSuppMark/$examTotalMarks)*4;
                            }else{
                                $studentSuppMarkOutOfFour = 0;
                            }
                            
                            $studentSuppMarkOutOfFour = round($studentSuppMarkOutOfFour,2);
                            /* xml data */ $supplyMarkDetails->externalMark = $studentSuppMark;
                            
                            $totalGradePointSupp = ($studentInternalMark + (3*$studentSuppMarkOutOfFour))/4;
                            
                            $studentPassStatus = StudentXMLService::getInstance()->getStudentFailStatus($totalGradePointSupp, $courseTypeId);
                        }
                        elseif(($isExternal == 1) && ($isInternal == 0))
                        {
                            /* xml data */ $supplyMarkDetails->studentInternalMark = "";
                            $studentSuppMark = $studentSuppMarkDetails->studentExternalSupplyMark;
                            $studentSuppMark = round($studentSuppMark);
                            
                            if(empty($studentSuppMark))
                            {
                                if($studentSupplyExamId){
                                    $studentOtherDetails = StudentXMLService::getInstance()->getAbsentMalDetails($studentId, $studentSupplyExamId);
                                
                                    if($studentOtherDetails == 1){
                                        $studentSuppMark = 'A';
                                    }elseif($studentOtherDetails == 2){
                                        $studentSuppMark = 'MAL';
                                    }else{
                                        $studentSuppMark = 0;
                                    }
                                }else{
                                    $studentSuppMark = 0;
                                }
                                
                            }
                            
                            if($examTotalMarks){
                                $studentSuppMarkOutOfFour = ($studentSuppMark/$examTotalMarks)*4;
                            }else{
                                $studentSuppMarkOutOfFour = 0;
                            }
                            
                            $studentSuppMarkOutOfFour = round($studentSuppMarkOutOfFour,2);
                            /* xml data */ $supplyMarkDetails->externalMark = $studentSuppMark;
                            
                            $totalGradePointSupp = $studentSuppMarkOutOfFour;
                            
                            $studentPassStatus = StudentXMLService::getInstance()->getStudentFailStatus($totalGradePointSupp, $courseTypeId);
                        }
                        elseif(($isExternal == 0) && ($isInternal == 1))
                        {
                            /* xml data */ $supplyMarkDetails->studentInternalMark = $studentInternalMark;
                            /* xml data */ $supplyMarkDetails->externalMark = "";
                            $totalGradePointSupp = $studentInternalMark;
                            
                            $studentPassStatus = StudentXMLService::getInstance()->getStudentFailStatus($totalGradePointSupp, $courseTypeId);
                        }
                        
                        
                        $moderation = 0;
                        /* xml data */ $supplyMarkDetails->moderation = $moderation;
                        
                        
                        $studentSupplyStatus = StudentXMLService::getInstance()->getStudentSupplyStatus($suppId, $studentId);
                        
                        if($studentSupplyStatus == 0){
                            $studentSupplyStatus = "I";
                            /* xml data */ $supplyMarkDetails->studentSupplyStatus = $studentSupplyStatus;
                        }else{
                            $studentSupplyStatus = "S";
                            /* xml data */ $supplyMarkDetails->studentSupplyStatus = $studentSupplyStatus;
                        }
                        
                        
                        $supplyExamDateDetails = StudentXMLService::getInstance()->getSupplyExamDateDetails($suppId);
                        $supplyexamDate = $supplyExamDateDetails->examMonth."/".$supplyExamDateDetails->examYear;
                        
                        /* xml data */ $supplyMarkDetails->examDate = $supplyexamDate;
                        
                        
                        if($studentPassStatus == 0){
                            $studentPassStatus = "P";
                            /* xml data */ $supplyMarkDetails->studentPassStatus = $studentPassStatus;
                        }else{
                            $studentPassStatus = "F";
                            /* xml data */ $supplyMarkDetails->studentPassStatus = $studentPassStatus;
                        }
                        
                        $studentMarkArray[] = $supplyMarkDetails;
                    }
                }
            }
        }
        
        return $studentMarkArray;
    }
    /**
     * Method for getting student fail status for a totalGradePoint
     * @param unknown $totalGradePoint
     * @param unknown $courseTypeId
     * @throws ProfessionalException
     * @return NULL
     * @author Ranjith Balachandran
     */
    public function getStudentFailStatus($totalGradePoint,$courseTypeId)
    {
        $sql = '';
        $totalGradePoint = $this->realEscapeString($totalGradePoint);
        $courseTypeId = $this->realEscapeString($courseTypeId);
        $studentFailStatus = null;
        
        try{
            $sql = "SELECT egp.failStatus AS failStatus FROM exam_gradepoints egp INNER JOIN exam_gradingscheme egs ON egp.schemeID = egs.schemeID WHERE egs.courseTypeID = $courseTypeId AND $totalGradePoint BETWEEN egp.percentFrom AND egp.percentTo";
            $studentFailStatus = $this->executeQueryForObject($sql)->failStatus;
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $studentFailStatus;
    }
    /**
     * Method for getting supply exam details for an exam and studentId
     * @param unknown $regularExamId
     * @param unknown $studentId
     * @throws ProfessionalException
     * @return object|array|\com\linways\base\util\$objectList[]
     * @author Ranjith Balachandran
     */
    public function getStudentSupplySubjects($regularExamId,$studentId)
    {
        $sql = '';
        $regularExamId = $this->realEscapeString($regularExamId);
        $studentId = $this->realEscapeString($studentId);
        
        $studentSupplyExamDetails = [];
        
        try{
            $sql = "SELECT esss.exam_supplementary_id AS examSuppId FROM exam_supplementary_student_subjects esss WHERE esss.studentID = $studentId AND esss.examID = $regularExamId";
            $studentSupplyExamDetails = $this->executeQueryForList($sql);
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $studentSupplyExamDetails;
    }
    /**
     * Method for getting student supply status
     * @param unknown $examSuppId
     * @param unknown $studentId
     * @throws ProfessionalException
     * @return unknown
     * @author Ranjith Balachandran
     */
    public function getStudentSupplyStatus($examSuppId,$studentId)
    {
        $sql = '';
        $examSuppId = $this->realEscapeString($examSuppId);
        $studentId = $this->realEscapeString($studentId);
        
        $suppStatus = null;
        
        try{
            $sql = "SELECT essd.isSupply AS isSupply FROM exam_supplementary_student_details essd WHERE studentID = $studentId AND essd.exam_supplementary_id = $examSuppId";
            $suppStatus = $this->executeQueryForObject($sql)->isSupply;
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
            
        }
        
        return $suppStatus;
    }
    /**
     * Method for getting student supply exam marks PG
     * @param unknown $studentId
     * @param unknown $examSuppId
     * @param unknown $subjectId
     * @param unknown $batchId
     * @throws ProfessionalException
     * @return object|NULL|\com\linways\base\util\$objectList[]
     * @author Ranjith Balachandran 
     */
    public function getStudentSupplyExamMarks($studentId,$examSuppId,$subjectId,$batchId)
    {
        $sql = '';
        $studentId = $this->realEscapeString($studentId);
        $examSuppId = $this->realEscapeString($examSuppId);
        $subjectId = $this->realEscapeString($subjectId);
        $batchId = $this->realEscapeString($batchId);
        
        $studentSupplyExamMarks = null;
        
        try{
            $sql = "SELECT e.examID AS examId,e.examName AS examName,e.examDate AS examDate,eef.mark AS studentExternalSupplyMark,e.examTotalMarks AS examTotalMarks FROM exam e INNER JOIN externalexammarks_finalized eef ON e.examID = eef.examID WHERE e.batchID = $batchId AND eef.studentID = $studentId AND e.examregID IS NULL AND e.supply_examreg_id IS NOT NULL AND e.subjectID = $subjectId AND e.supply_examreg_id = $examSuppId";
            $studentSupplyExamMarks = $this->executeQueryForObject($sql);
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $studentSupplyExamMarks;
    }
    /**
     * Method for getting student supply exam marks UG
     * @param unknown $studentId
     * @param unknown $examSuppId
     * @param unknown $subjectId
     * @param unknown $batchId
     * @throws ProfessionalException
     * @return object|NULL|\com\linways\base\util\$objectList[]
     * @author Ranjith Balachandran 
     */
    public function getStudentSupplyExamMarksUG($studentId,$examSuppId,$subjectId,$batchId)
    {
        $sql = '';
        $studentId = $this->realEscapeString($studentId);
        $examSuppId = $this->realEscapeString($examSuppId);
        $subjectId = $this->realEscapeString($subjectId);
        $batchId = $this->realEscapeString($batchId);
        
        $studentSupplyExamMarks = null;
        
        try{
            $sql = "SELECT e.examID AS examId,e.examName AS examName,e.examDate AS examDate,eef.mark AS studentExternalSupplyMark,e.examTotalMarks AS examTotalMarks,e.examCode FROM exam e INNER JOIN exammarks_external eef ON e.examID = eef.examID WHERE e.batchID = $batchId AND eef.studentID = $studentId AND e.examregID IS NULL AND e.supply_examreg_id IS NOT NULL AND e.subjectID = $subjectId AND e.supply_examreg_id = $examSuppId";
            $studentSupplyExamMarks = $this->executeQueryForObject($sql);
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $studentSupplyExamMarks;
    }
    
    /**
     * Method for getting subject details by subjectId
     * @param unknown $subjectId
     * @throws ProfessionalException
     * @return object|NULL|\com\linways\base\util\$objectList[]
     * @author Ranjith Balachandran
     */
    
    public function subjectDetails($subjectId,$batchId)
    {
        $subjectId = $this->realEscapeString($subjectId);
        $batchId = $this->realEscapeString($batchId);
        
        $subjectDetails = null;
        
        try{
            $sql = "SELECT s.subjectName AS subjectName,s.subjectDesc AS subjectDesc,esc.isInternal,esc.isExternal,s.syllabusYear,s.paperTypeId FROM subjects s INNER JOIN exam_subjectcredit esc ON s.subjectID = esc.subjectID WHERE s.subjectID = $subjectId AND esc.batchID = $batchId";
            $subjectDetails = $this->executeQueryForObject($sql);
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $subjectDetails;
    }
    /*
        Method for getting paperTypeName for a paperTypeId
        @input $paperTypeId
        @author Ranjith Balachandran
    */
    public function getPaperTypeDetails($paperTypeId)
    {
        $paperTypeId = $this->realEscapeString($paperTypeId);
        
        $paperTypeDetails = null;
        
        try{
            $sql = "SELECT paperTypeCode FROM subjectPaperType WHERE id = $paperTypeId";
            $paperTypeDetails = $this->executeQueryForObject($sql);
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $paperTypeDetails;
    }
    
    /**
     * Method for getting extval for a course
     * @param unknown $courseTypeId
     * @throws ProfessionalException
     * @return unknown
     * @author Ranjith Balachandran
     */
    
    public function getCourseType($courseTypeId)
    {
        $sql = '';
        $courseTypeId = $this->realEscapeString($courseTypeId);
        
        $courseType = null;
        
        try{
            $sql = "SEELCT extval_required AS extVal FROM course_type WHERE courseTypeID = $courseTypeId";
            $courseType = $this->executeQueryForObject($sql)->extVal;
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $courseType;
    }
    
    /**
     * Method for getting regular exam date details
     * @param unknown $regExamId
     * @throws ProfessionalException
     * @return object|NULL|\com\linways\base\util\$objectList[]
     * @author Ranjith Balachandran
     */
    
    public function getRegularExamMonthAndYear($regExamId)
    {
        $sql = '';
        $regExamId = $this->realEscapeString($regExamId);
        
        $examDateDetails = null;
        
        try{
            $sql = "SELECT er.examMonth AS examMonth, er.examYear AS examYear FROM exam_registration er INNER JOIN exam e ON e.examregID = er.examregID WHERE e.examID = $regExamId";
            $examDateDetails = $this->executeQueryForObject($sql);
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $examDateDetails;
    }
    
    /**
     * Method for getting supply exam date details
     * @param unknown $supplyExamRegId
     * @throws ProfessionalException
     * @return unknown
     * @author Ranjith Balachandran
     */
    
    public function getSupplyExamDateDetails($supplyExamRegId)
    {
        $sql = '';
        $supplyExamRegId = $this->realEscapeString($supplyExamRegId);
        
        $supplyDateDetails = null;
        
        try{
            $sql ="SELECT es.examMonth AS examMonth, es.examYear AS examYear,es.supplyDesc AS supplyDesc FROM exam_supplementary es WHERE es.id = $supplyExamRegId";
            $supplyDateDetails = $this->executeQueryForObject($sql);
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $supplyDateDetails;
    }
    
    /**
     * Method for getting student absent or mal practice status
     * @param unknown $studentId
     * @param unknown $examId
     * @throws ProfessionalException
     * @return unknown
     * @author Ranjith Balachandran
     */
    
    public function getAbsentMalDetails($studentId,$examId)
    {
        $sql = '';
        $studentId = $this->realEscapeString($studentId);
        $examId = $this->realEscapeString($examId);
        
        $details = null;
        
        try{
            $sql = "SELECT ea.isAbsent AS absentStatus FROM exam_attendance ea WHERE ea.examID = $examId AND studentID = $studentId";
            $details = $this->executeQueryForObject($sql)->absentStatus;
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $details;
    }
    
    /**
     * Method for getting supply exam Id
     * @param unknown $suppId
     * @param unknown $batchId
     * @param unknown $subjectId
     * @throws ProfessionalException
     * @return unknown
     * @author Ranjith Balachandran
     */
    
    public function getSupplyExamId($suppId,$batchId,$subjectId)
    {
        $sql = '';
        $suppId = $this->realEscapeString($suppId);
        $batchId = $this->realEscapeString($batchId);
        $subjectId = $this->realEscapeString($subjectId);
        
        $suppExamId = null;
        
        try{
            $sql = "SELECT e.examID AS suppExamId FROM exam e WHERE supply_examreg_id = $suppId AND subjectID = $subjectId AND batchID = $batchId";
            $suppExamId = $this->executeQueryForObject($sql)->suppExamId;
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $suppExamId;
    }
    
    /**
     * Method for getting all regular examIds for a batch
     * @param unknown $batchId
     * @throws ProfessionalException
     * @return object|array|\com\linways\base\util\$objectList[]
     * @author Ranjith Balachandran
     */
    
    public function getExamIds($batchId)
    {
        $sql = '';
        $batchId = $this->realEscapeString($batchId);
        
        $examIds = [];
        
        try{
            $sql = "SELECT t1.examID,t1.examTotalMarks,t1.examDate,t1.examCode FROM exam t1, exam_registration t2 WHERE t1.examregID = t2.examregID AND t1.batchID = $batchId AND t1.examregID IS NOT NULL AND t2.shortCourse = 0";
            $examIds = $this->executeQueryForList($sql);
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $examIds;
    }
    
    /**
     * Method for getting student details by batchId
     * @param unknown $batchId
     * @throws ProfessionalException
     * @return object|array|\com\linways\base\util\$objectList[]
     * @author Ranjith Balachandran
     */
    
    public function getStudentDetails($batchId)
    {
        $sql = '';
        
        $batchId = $this->realEscapeString($batchId);
        
        $studentDetails = [];
        
        try{
            $sql = "SELECT sa.studentID AS studentId,sa.regNo AS regNo FROM studentaccount sa WHERE sa.batchID = $batchId";
            $studentDetails = $this->executeQueryForList($sql);
            
        }catch(\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $studentDetails;
    }
    
    /**
     * Method for getting subjectID AND semId corresponding to an exam and batch
     * @param unknown $batchId
     * @param unknown $examId
     * @throws ProfessionalException
     * @return object|NULL|\com\linways\base\util\$objectList[]
     * @author Ranjith Balachandran
     */
    
    public function getSubjectIdAndSemId($batchId,$examId)
    {
        $sql = '';
        
        $batchId = $this->realEscapeString($batchId);
        $examId = $this->realEscapeString($examId);
        
        $subjectIdAndSemId = null;
        
        try{
            $sql = "SELECT subjectID,semID,examregID FROM exam WHERE batchID = $batchId AND examID = $examId";
            $subjectIdAndSemId = $this->executeQueryForObject($sql);
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $subjectIdAndSemId;
    }
    
    /**
     * Method for getting student regular exam mark for an exam PG
     * @param unknown $studentId
     * @param unknown $regularExamId
     * @throws ProfessionalException
     * @return unknown
     * @author Ranjith Balachandran
     */
    
    public function getStudentExternalMark($studentId,$regularExamId)
    {
        $sql = '';
        $studentId = $this->realEscapeString($studentId);
        $regularExamId = $this->realEscapeString($regularExamId);
        
        $regularExamMark = null;
        
        try{
            $sql = "SELECT mark AS studentExternalMark FROM externalexammarks_finalized WHERE examID = $regularExamId AND studentID = $studentId";
            $regularExamMark = $this->executeQueryForObject($sql)->studentExternalMark;
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $regularExamMark;
    }
    /**
     * Method for getting student regular exam mark for an exam UG
     * @param unknown $studentId
     * @param unknown $regularExamId
     * @throws ProfessionalException
     * @return unknown
     * @author Ranjith Balachandran
     */
    
    public function getStudentExternalMarkUG($studentId,$regularExamId)
    {
        $sql = '';
        $studentId = $this->realEscapeString($studentId);
        $regularExamId = $this->realEscapeString($regularExamId);
        
        $regularExamMark = null;
        
        try{
            $sql = "SELECT mark AS studentExternalMark FROM exammarks_external WHERE examID = $regularExamId AND studentID = $studentId";
            $regularExamMark = $this->executeQueryForObject($sql)->studentExternalMark;
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $regularExamMark;
    }
    
    /**
     * Method for getting student internal mark for a subject
     * @param unknown $studentId
     * @param unknown $batchId
     * @param unknown $semId
     * @param unknown $subjectId
     * @throws ProfessionalException
     * @return unknown
     * @author Ranjith Balachandran
     */
    
    public function getStudentInternalMark($studentId,$batchId,$semId,$subjectId)
    {
        $batchId = $this->realEscapeString($batchId);
        $subjectId = $this->realEscapeString($subjectId);
        $semId = $this->realEscapeString($semId);
        $studentId = $this->realEscapeString($studentId);
        
        $studentInternalMark = null;
        
        try{
            $sql = "SELECT internalMarks AS studentInternalMark FROM internal_marks WHERE subjectID = $subjectId AND semID = $semId AND studentID = $studentId AND batchID = $batchId";
            $studentInternalMark = $this->executeQueryForObject($sql)->studentInternalMark;
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $studentInternalMark;
    }
    
    /**
     * Method for getting compName for a subject category and batchId
     * @param unknown $subjectCategoryId
     * @param unknown $batchId
     * @throws ProfessionalException
     * @return unknown
     * @author Ranjith Balachandran
     */
    
    public function getComplementaryName($subjectCategoryId,$batchId)
    {
        $sql = '';
        
        $subjectCategoryId = $this->realEscapeString($subjectCategoryId);
        $batchId = $this->realEscapeString($batchId);
        
        $compName = null;
        
        try{
            $sql = "SELECT displayName AS compName FROM marklist_categorize_subjects WHERE subject_category_id = $subjectCategoryId AND batches_id = $batchId";
            $compName = $this->executeQueryForObject($sql)->compName;
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $compName;
    }
    
    /**
     * Method for getting batchID for a particular batchStartYear and courseTypeId
     * @param unknown $batchStartYear
     * @param unknown $courseTypeId
     * @throws ProfessionalException
     * @return object|array|\com\linways\base\util\$objectList[]
     * @author Ranjith Balachandran
     */
    
    public function getBatchIds($batchStartYear,$courseTypeId)
    {
        $sql = '';
        $batchStartYear = $this->realEscapeString($batchStartYear);
        $courseTypeId = $this->realEscapeString($courseTypeId);
        $batchIds = [];
        
        try{
            $sql = "SELECT batchID AS batchId FROM batches WHERE batchStartYear = $batchStartYear AND courseTypeID = $courseTypeId";
            $batchIds = $this->executeQueryForList($sql);
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $batchIds;
    }
    /**
     * Method for getting student mark details by batchId and courseTypeId (UG)
     * @param unknown $batchId
     * @throws ProfessionalException
     * @return object|array|\com\linways\base\util\$objectList[]
     * @author Ranjith Balachandran
     */
 
    public function getStudentMarkDetailsByBatchIdUG($batchId,$courseTypeId)
    {
        $sql = '';
        
        $batchId = $this->realEscapeString($batchId);
        $courseTypeId = $this->realEscapeString($courseTypeId);
        
        $studentMarkDetails = [];
        $studentMarkArray = [];
        $subjectGroupArr = [];
        /** get full regular exam details for a batch **/
        $getAllExamIds = StudentXMLService::getInstance()->getExamIds($batchId);
        
        /** get full student details in that batch **/
        $studentFullDetails = StudentXMLService::getInstance()->getStudentDetails($batchId);
        foreach ($studentFullDetails as $studentDetails) 
        {
            $studentId = $studentDetails->studentId;
            foreach ($getAllExamIds as $examIds)
            {
                $studentCombinedMark = 0;
                $studentRegularExamId = $examIds->examID;
                
                /*get ExamtotalMarks*/ $examTotalMarks = $examIds->examTotalMarks;
                $subjectIdAndSemId = StudentXMLService::getInstance()->getSubjectIdAndSemId($batchId, $studentRegularExamId);
                /*get subjectId*/ $studentSubjectId = $subjectIdAndSemId->subjectID;
                
                /*get semId*/ $studentSemId = $subjectIdAndSemId->semID;
                // get regular exam code 
                $examSupplyId = 0;
                $examCode = StudentXMLService::getInstance()->getExamCode($batchId, $studentSemId,$examSupplyId);
                
                /* grouping paper for bmmc batch **/
                /* $subjectGroupArrDetails = StudentXMLService::getInstance()->getGroupId($studentSubjectId, $batchId, $studentSemId);
                foreach ($subjectGroupArrDetails as $groupSubject) 
                {
                    $subjectGroupArr[] = $groupSubject->subjectId;
                } */
                /*get regular exam registration id*/ $examRegistrationId = $subjectIdAndSemId->examregID;
                $regularMarkDetails = new StudentXMLTags();
                $subjectDetails = StudentXMLService::getInstance()->subjectDetails($studentSubjectId,$batchId);
                if(count($subjectDetails)){
                    /*get paperTypeId*/ $paperTypeId = $subjectDetails->paperTypeId;
                    /*get paperTypeCode*/ $paperTypeDetails = StudentXMLService::getInstance()->getPaperTypeDetails($paperTypeId);
                    $paperTypeCode = $paperTypeDetails->paperTypeCode;    
                }
                
                /*get InternalFlag*/ $isInternal = $subjectDetails->isInternal;
                /*get ExternalFlag*/ $isExternal = $subjectDetails->isExternal;
                /*get syllabusYear */ $syllabusYear = $subjectDetails->syllabusYear;
                $checkStudentSubjects = StudentXMLService::getInstance()->checkStudentSubjects($studentSubjectId,$studentId,$examRegistrationId,$batchId,$studentSemId);
                
                //$isPracticalFlag = StudentXMLService::getInstance()->getPracticalSubjects($studentSubjectId, $batchId, $studentSemId);
                if(($checkStudentSubjects == 1))
                {
                    $studentRegNo = $studentDetails->regNo;
                    /* xml data */ $regularMarkDetails->studentRegNo = $studentRegNo;
                    /* xml data */ $regularMarkDetails->syllabusYear = $syllabusYear;
                    /* xml data */ $regularMarkDetails->examCode = $examCode;
                    /* xml data */ $regularMarkDetails->paperTypeCode = $paperTypeCode;
                    $paperName = html_entity_decode($subjectDetails->subjectDesc);
                    /* xml data */ $regularMarkDetails->paperName = $paperName;
                    $syllabusCode = $subjectDetails->subjectName;
                    
                    /* xml data */ $regularMarkDetails->syllabusCode = $syllabusCode;
                    
                    /* xml data */ $regularMarkDetails->semId = $studentSemId;
                    /** get student internakl mark **/
                    /** if combine internal is present **/
                    $getPrevCombinedSubjects = StudentXMLService::getInstance()->getPrevSubjectsCombined($studentRegularExamId, $batchId, $studentSemId);
                    if(count($getPrevCombinedSubjects))
                    {
                        $intMaxMarks = StudentXMLService::getInstance()->getIntMaxMarks($studentSubjectId,$batchId,$studentSemId);
                        $studentInternalMark = StudentXMLService::getInstance()->getStudentInternalMark($studentId, $batchId, $studentSemId, $studentSubjectId);
                        $counter = 1;
                        foreach($getPrevCombinedSubjects as $prevSubjects)
                        {
                            $semIdPrev = $prevSubjects->prevSemId;
                            $subjectIdPrev = $prevSubjects->prevSubjectId;
                            //concatination of previous subject names
                            
                            $paperName = $prevSubjects->subjectDesc." & ".$subjectDetails->subjectDesc;
                            /* xml data */ $regularMarkDetails->paperName = $paperName;
                            $syllabusCode = $prevSubjects->subjectName." & ".$subjectDetails->subjectName;
                    
                            /* xml data */ $regularMarkDetails->syllabusCode = $syllabusCode;
                            $prevExamDetails = StudentXMLService::getInstance()->getPrevExamDetails($batchId,$semIdPrev,$subjectIdPrev,$studentId);
                            if($prevExamDetails)
                            {
                                $maxInternalMarks = $intMaxMarks + $prevExamDetails->maxInternalMarks;
                                $internalMarks = $studentInternalMark + $prevExamDetails->internalMarks;
                                $counter++;
                            }
                            
                        }
                        $intMaxMarks = $maxInternalMarks/$counter;
                        $studentInternalMark = round($internalMarks/$counter);
                        if(!$studentInternalMark)
                        {
                            $studentInternalMark = '0';
                        }
                    }
                    else
                    {
                        $intMaxMarks = StudentXMLService::getInstance()->getIntMaxMarks($studentSubjectId,$batchId,$studentSemId);
                        $studentInternalMark = StudentXMLService::getInstance()->getStudentInternalMark($studentId, $batchId, $studentSemId, $studentSubjectId);
                        if(!$studentInternalMark)
                        {
                            $studentInternalMark = '0';
                        }
                    }
                    
                    /** fetching revaluation marks (regular) and grace marks **/
                    $revaluationMarks = StudentXMLService::getInstance()->getStudentRevalMarks($studentRegularExamId,$studentId);
                    $studentGraceMarks = StudentXMLService::getInstance()->getStudentGraceMarks($studentSubjectId,$studentRegularExamId,$studentId,$studentSemId);
                    if(($isExternal == 1) && ($isInternal == 1))
                    {
                        
                        $totalMaxMarks = $examTotalMarks + $intMaxMarks;
                        /** get student external mark **/
                        if(in_array($studentSubjectId, $subjectGroupArr))
                        {
                            $studentExternalMark = StudentXMLService::getInstance()->getUniqueExamId($studentSubjectId,$batchId,$studentSemId,$examRegistrationId,$studentId);
                            $studentExternalMark = $studentExternalMark + $studentGraceMarks;
                        }
                        else
                        {
                            
                            if($revaluationMarks)
                            {
                                $studentExternalMark = $revaluationMarks + $studentGraceMarks;
                            }
                            else
                            {
                                $studentExternalMark = StudentXMLService::getInstance()->getStudentExternalMarkUG($studentId, $studentRegularExamId);
                                $studentExternalMark = $studentExternalMark + $studentGraceMarks;
                            }
                            
                        }
                        
                        $studentExternalMark = round($studentExternalMark);
                        
                        if(empty($studentExternalMark))
                        {
                            $studentOtherDetails = StudentXMLService::getInstance()->getAbsentMalDetails($studentId, $studentRegularExamId);
                            
                            if($studentOtherDetails == 1){
                                $studentExternalMark = 'A';
                            }elseif($studentOtherDetails == 2){
                                $studentExternalMark = 'X';
                            }else{
                                $studentExternalMark = 0;
                            }
                        }
                        
                        /* xml data */ $regularMarkDetails->externalMark = $studentExternalMark;
                        
                        /* xml data */ $regularMarkDetails->studentInternalMark = $studentInternalMark;
                        $totalPercentage = (($studentInternalMark + $studentExternalMark)/$totalMaxMarks)*100;
                    
                        $studentPassStatus = StudentXMLService::getInstance()->getStudentFailStatus($totalPercentage, $courseTypeId);
                    }
                    elseif(($isInternal == 1) && ($isExternal == 0))
                    {
                        $examTotalMarks = 0;
                        $totalMaxMarks = $examTotalMarks + $intMaxMarks;
                        /* xml data */ $regularMarkDetails->externalMark = "";
                        /* xml data */ $regularMarkDetails->studentInternalMark = $studentInternalMark;
                        $totalPercentage = (($studentInternalMark)/$totalMaxMarks)*100;
                    
                        $studentPassStatus = StudentXMLService::getInstance()->getStudentFailStatus($totalPercentage, $courseTypeId);
                    }
                    elseif(($isExternal == 1) && ($isInternal == 0))
                    {
                        $intMaxMarks = 0;
                        $totalMaxMarks = $examTotalMarks + $intMaxMarks;
                        /** get student external mark **/
                        if($revaluationMarks)
                        {
                            $studentExternalMark = $revaluationMarks + $studentGraceMarks;
                        }
                        else
                        {
                            $studentExternalMark = StudentXMLService::getInstance()->getStudentExternalMarkUG($studentId, $studentRegularExamId);
                            $studentExternalMark = $studentExternalMark + $studentGraceMarks;
                        }
                        
                        $studentExternalMark = round($studentExternalMark);
                        
                        if(empty($studentExternalMark))
                        {
                            $studentOtherDetails = StudentXMLService::getInstance()->getAbsentMalDetails($studentId, $studentRegularExamId);
                            
                            if($studentOtherDetails == 1){
                                $studentExternalMark = 'A';
                            }elseif($studentOtherDetails == 2){
                                $studentExternalMark = 'X';
                            }else{
                                $studentExternalMark = 0;
                            }
                        }
                        
                        /* xml data */ $regularMarkDetails->externalMark = $studentExternalMark;
                        
                        $studentInternalMark = "";
                        /* xml data */ $regularMarkDetails->studentInternalMark = $studentInternalMark;
                        $totalPercentage = (($studentExternalMark)/$totalMaxMarks)*100;
                    
                        $studentPassStatus = StudentXMLService::getInstance()->getStudentFailStatus($totalPercentage, $courseTypeId);
                    }
                    /* For moderation mark calculation starts */
                    $studentOldMark = StudentXMLService::getInstance()->getStudentBeforeModerationMarks($studentId,$studentRegularExamId);
                    if(count($studentOldMark))
                    {
                        $studentExternalMark = StudentXMLService::getInstance()->getStudentExternalMarkUG($studentId, $studentRegularExamId);
                        if($revaluationMarks){
                            $studentModerationMark = $studentExternalMark - $studentOldMark->revalMark;
                        }else{
                            $studentModerationMark = $studentExternalMark - $studentOldMark->studentOldMark;    
                        }
                        
                        $studentExternalMark = round($studentExternalMark);
                    }
                    else
                    {
                        $studentModerationMark = 0;
                    }
                    
                    $moderation = $studentModerationMark;
                    /* For moderation mark calculation ends */
                    /* xml data */ $regularMarkDetails->moderation = $moderation;
                    /* xml data */ $regularMarkDetails->externalMark = $studentExternalMark;
                    
                    $regularExamDateDetails = StudentXMLService::getInstance()->getRegularExamMonthAndYear($studentRegularExamId);
                    
                    $examDate = $regularExamDateDetails->examMonth."/".$regularExamDateDetails->examYear;
                    /* xml data */ $regularMarkDetails->examDate = $examDate;
                    
                    
                    if($studentPassStatus == 0){
                        $studentPassStatus = "P";
                        /* xml data */ $regularMarkDetails->studentPassStatus = $studentPassStatus;
                    }else{
                        $studentPassStatus = "F";
                        /* xml data */ $regularMarkDetails->studentPassStatus = $studentPassStatus;
                    }
                    
                    $studentSupplyStatus = "R";
                    /* xml data */ $regularMarkDetails->studentSupplyStatus = $studentSupplyStatus;
                    $studentMarkArray[] = $regularMarkDetails;
                    
                    $examSuppId = StudentXMLService::getInstance()->getStudentSupplySubjects($studentRegularExamId, $studentId);
                    
                    if(count($examSuppId))
                    {
                        foreach ($examSuppId as $suppIdDetails)
                        {
                            $supplyMarkDetails = new StudentXMLTags();
                            $suppId = $suppIdDetails->examSuppId;
                            $studentSuppMarkDetails = StudentXMLService::getInstance()->getStudentSupplyExamMarksUG($studentId, $suppId, $studentSubjectId, $batchId);
                            $examTotalMarks = $studentSuppMarkDetails->examTotalMarks;
                            //$examCode = $studentSuppMarkDetails->examCode;
                            //get supply exam code    
                            $examCode = StudentXMLService::getInstance()->getExamCode($batchId, $studentSemId,$suppId);
                            
                            /** getting supply reval marks for a student **/
                            $studentSupplyExamId = StudentXMLService::getInstance()->getSupplyExamId($suppId, $batchId, $studentSubjectId);
                            if($studentSupplyExamId)
                            {
                                $revaluationMarks = StudentXMLService::getInstance()->getStudentRevalMarks($studentSupplyExamId,$studentId);
                            }
                            /* xml data */ $supplyMarkDetails->studentRegNo = $studentRegNo;
                            /* xml data */ $supplyMarkDetails->paperName = $paperName;
                            /* xml data */ $supplyMarkDetails->semId = $studentSemId;
                            /* xml data */ $supplyMarkDetails->syllabusCode = $syllabusCode;
                            /* xml data */ $supplyMarkDetails->examCode = $examCode;
                            /* xml data */ $supplyMarkDetails->syllabusYear = $syllabusYear;
                            /* xml data */ $supplyMarkDetails->paperTypeCode = $paperTypeCode;
                            if(($isInternal == 1) && ($isExternal == 1))
                            {
                                /* xml data */ $supplyMarkDetails->studentInternalMark = $studentInternalMark;
                                if(in_array($studentSubjectId, $subjectGroupArr))
                                {
                                    $studentSuppMark = StudentXMLService::getInstance()->getUniqueExamIdSupply($studentSubjectId,$batchId,$studentSemId,$suppId,$studentId);
                                }
                                else
                                {
                                    if($revaluationMarks)
                                    {
                                        $studentSuppMark = $revaluationMarks;
                                    }
                                    else
                                    {
                                        $studentSuppMark = $studentSuppMarkDetails->studentExternalSupplyMark;    
                                    }
                                    
                                }
                                
                                $studentSuppMark = round($studentSuppMark);
                                
                                if(empty($studentSuppMark))
                                {
                                    if($studentSupplyExamId)
                                    {
                                        $studentOtherDetails = StudentXMLService::getInstance()->getAbsentMalDetails($studentId, $studentSupplyExamId);    
                                    }
                                    
                                    
                                    if($studentOtherDetails == 1){
                                        $studentSuppMark = 'A';
                                    }elseif($studentOtherDetails == 2){
                                        $studentSuppMark = 'X';
                                    }else{
                                        $studentSuppMark = 0;
                                    }
                                }
                                
                                /* xml data */ $supplyMarkDetails->externalMark = $studentSuppMark;
                                
                                $totalPercentageSupp = (($studentInternalMark + $studentSuppMark)/$totalMaxMarks)*100;
                                
                                $studentPassStatus = StudentXMLService::getInstance()->getStudentFailStatus($totalPercentageSupp, $courseTypeId);
                            }
                            elseif(($isExternal == 1) && ($isInternal == 0))
                            {
                                $intMaxMarks = 0;
                                $totalMaxMarks = $examTotalMarks + $intMaxMarks;
                                
                                /* xml data */ $supplyMarkDetails->studentInternalMark = "";
                                if($revaluationMarks)
                                {
                                    $studentSuppMark = $revaluationMarks;
                                }
                                else
                                {
                                    $studentSuppMark = $studentSuppMarkDetails->studentExternalSupplyMark;    
                                }
                                $studentSuppMark = round($studentSuppMark);
                                
                                if(empty($studentSuppMark))
                                {
                                    if($studentSupplyExamId)
                                    {
                                        $studentOtherDetails = StudentXMLService::getInstance()->getAbsentMalDetails($studentId, $studentSupplyExamId);    
                                    }
                                    
                                    
                                    if($studentOtherDetails == 1){
                                        $studentSuppMark = 'A';
                                    }elseif($studentOtherDetails == 2){
                                        $studentSuppMark = 'X';
                                    }else{
                                        $studentSuppMark = 0;
                                    }
                                }
                                /* xml data */ $supplyMarkDetails->externalMark = $studentSuppMark;
                                
                                $totalPercentageSupp = (($studentSuppMark)/$totalMaxMarks)*100;
                                
                                $studentPassStatus = StudentXMLService::getInstance()->getStudentFailStatus($totalPercentageSupp, $courseTypeId);
                            }
                            elseif(($isExternal == 0) && ($isInternal == 1))
                            {
                                $examTotalMarks = 0;
                                $totalMaxMarks = $examTotalMarks + $intMaxMarks;
                                
                                /* xml data */ $supplyMarkDetails->studentInternalMark = $studentInternalMark;
                                /* xml data */ $supplyMarkDetails->externalMark = "";
                                $totalPercentageSupp = (($studentInternalMark)/$totalMaxMarks)*100;
                                
                                $studentPassStatus = StudentXMLService::getInstance()->getStudentFailStatus($totalPercentageSupp, $courseTypeId);
                            }
                            
                            
                            $moderation = 0;
                            /* xml data */ $supplyMarkDetails->moderation = $moderation;
                            
                            
                            $studentSupplyStatus = StudentXMLService::getInstance()->getStudentSupplyStatus($suppId, $studentId);
                            
                            if($studentSupplyStatus == 0){
                                $studentSupplyStatus = "I";
                                /* xml data */ $supplyMarkDetails->studentSupplyStatus = $studentSupplyStatus;
                            }else{
                                $studentSupplyStatus = "S";
                                /* xml data */ $supplyMarkDetails->studentSupplyStatus = $studentSupplyStatus;
                            }
                            
                            
                            $supplyExamDateDetails = StudentXMLService::getInstance()->getSupplyExamDateDetails($suppId);
                            $supplyexamDate = $supplyExamDateDetails->examMonth."/".$supplyExamDateDetails->examYear;
                            
                            /* xml data */ $supplyMarkDetails->examDate = $supplyexamDate;
                            
                            
                            if($studentPassStatus == 0){
                                $studentPassStatus = "P";
                                /* xml data */ $supplyMarkDetails->studentPassStatus = $studentPassStatus;
                            }else{
                                $studentPassStatus = "F";
                                /* xml data */ $supplyMarkDetails->studentPassStatus = $studentPassStatus;
                            }
                            
                            $studentMarkArray[] = $supplyMarkDetails;
                        }
                    }
                }
                
            }
        }
        
        return $studentMarkArray;
    }
    
    /**
     * Method for getting subject details for a batch
     * @param unknown $batchId
     * @throws ProfessionalException
     * @return object|array|\com\linways\base\util\$objectList[]
     * @author Ranjith Balachandran
     */
    
    public function getSubjectDetailsUG($batchId)
    {
        $sql = '';
        
        $batchId = $this->realEscapeString($batchId);
        
        $subjectDetails = [];
        $groupId = '';
        
        try{
            $sql = "SELECT s.subjectID,s.subjectDesc,s.syllabusYear,spt.paperTypeCode,cc.categoryCode,s.subjectName,esc.credit,s.semID,pdc.patterncourseCode,sl.secondLangaugeCode,esc.isInternal,esc.isExternal,ims.maxInternalMarks AS imax,cc.subject_category_id AS subjectCatId,pdc.patterncourseID,b.batchStartYear FROM subjects s LEFT JOIN subjectPaperType spt ON s.paperTypeId = spt.id LEFT JOIN categoryCode cc ON cc.subject_category_id = s.subjectcatID INNER JOIN exam_subjectcredit esc ON esc.subjectID = s.subjectID LEFT JOIN secondLangauge sl ON s.secondLangaugeId = sl.secondlangaugeID INNER JOIN batches b ON s.deptID = b.deptID AND esc.batchID = b.batchID LEFT JOIN pattern_deptcourses pdc ON b.patterncourseID = pdc.patterncourseID LEFT JOIN internal_marks_settings ims ON s.subjectID = ims.subjectID AND esc.batchID = ims.batchID AND s.semID=ims.semID WHERE b.batchID = $batchId ORDER BY s.semID ASC";
            $subjectDetails = $this->executeQueryForList($sql);
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        foreach($subjectDetails as $subject)
        {
            $isInternal = $subject->isInternal;
            $isExternal = $subject->isExternal;
            $eMaxSql = "SELECT examTotalMarks FROM exam WHERE examregID IS NOT NULL AND batchID=$batchId and semID=$subject->semID AND subjectID=$subject->subjectID";
            $externalMAX = $this->executeQueryForObject($eMaxSql)->examTotalMarks;
            $emax = $externalMAX;
            $subjectDiv = "SELECT marklist_group_subjects_details_id AS groupId FROM marklist_group_subjects WHERE subjects_id = $subject->subjectID";
            $groupId = $this->executeQueryForObject($subjectDiv)->groupId;
            if($groupId){
                $subDivision = "T";
                $subject->subDiv = $subDivision;
            }else{
                $subDivision = "F";
                $subject->subDiv = $subDivision;
            }
            $imax = $subject->imax;
            $valueSql = "SELECT categoryValue AS value FROM courseSubjectCategoryRelation WHERE pattern_deptcourses_id = $subject->patterncourseID AND batchStartYear = $subject->batchStartYear AND subject_category_id = $subject->subjectCatId";
            $patternValue = $this->executeQueryForObject($valueSql)->value;
            $subject->patternValue = $patternValue;
            if(($isInternal == 1) && ($isExternal == 1))
            {
                $subject->emax=$emax;
                $subject->imax= $imax;
                $subject->emin =0;
                $subject->imin=0;
            }
            elseif(($isInternal == 1) && ($isExternal == 0))
            {
                $subject->emax=0;
                $subject->imax= $imax;
                $subject->emin =0;
                $subject->imin=0;
            }
            elseif(($isInternal == 0) && ($isExternal == 1))
            {
                $subject->emax=$emax;
                $subject->imax= 0;
                $subject->emin =0;
                $subject->imin=0;
            }
            $newSubjectArray[]=$subject;
        }
        
        return $newSubjectArray;
    }
    
    /**
     * Method for saving course subject category relation
     * @param unknown $patternCourseId
     * @param unknown $batchStartYear
     * @param unknown $combine
     * @throws ProfessionalException
     * @author Ranjith Balachandran
     */
    
    public function saveCourseSubjectCategoryRelation($patternCourseId, $batchStartYear, $subjectCategoryRelation)
    {
        $patternCourseId = $this->realEscapeString($patternCourseId);
        $batchStartYear = $this->realEscapeString($batchStartYear);
        
        try{
            $sql = "DELETE FROM courseSubjectCategoryRelation WHERE pattern_deptcourses_id = ".$patternCourseId." AND batchStartYear = ".$batchStartYear."";
            $this->executeQuery($sql);
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        foreach ($subjectCategoryRelation as $subCatRel) {
            
            $subjectCatId = $subCatRel['subjectCatId'];
            $patternCode = $subCatRel['patternCode'];
            
            try{
                $sql = "INSERT INTO courseSubjectCategoryRelation (subject_category_id, pattern_deptcourses_id, batchStartYear, categoryValue) VALUES (".$subjectCatId.", ".$patternCourseId.", ".$batchStartYear.",\"".$patternCode."\")";
                $this->executeQuery($sql);
                
            }catch (\Exception $e){
                throw new ProfessionalException($e->getCode(),$e->getMessage());
            }
        }
    }
    
    /**
     * Method for getting relation for a pattern course and batchStartyear
     * @param unknown $patternCourseId
     * @param unknown $batchStartYear
     * @throws ProfessionalException
     * @return unknown
     * @author Ranjith Balachandran
     */
    
    public function getCourseRelation($patternCourseId,$batchStartYear,$subCatId)
    {
        $sql = '';
        $patternCourseId = $this->realEscapeString($patternCourseId);
        $batchStartYear = $this->realEscapeString($batchStartYear);
        $subCatId = $this->realEscapeString($subCatId);
        
        $getRelation = [];
        
        try{
            $sql = "SELECT categoryValue AS value FROM courseSubjectCategoryRelation WHERE pattern_deptcourses_id = $patternCourseId AND batchStartYear = $batchStartYear AND subject_category_id = $subCatId";
            $getRelation = $this->executeQueryForObject($sql)->value;
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $getRelation;
    }
    /**
     * Method for checking this student studies this subject
     * @param unknown $subjectId
     * @param unknown $studentId
     * @param unknown $examRegistrationId
     * @throws ProfessionalException
     * @return unknown
     * @author Ranjith Balachandran
     */
    
    public function checkStudentSubjects($subjectId,$studentId,$examRegistrationId,$batchId,$semId)
    {
        $sql = '';
        $subjectId = $this->realEscapeString($subjectId);
        $studentId = $this->realEscapeString($studentId);
        $examRegistrationId = $this->realEscapeString($examRegistrationId);
        $batchId = $this->realEscapeString($batchId);
        $semId = $this->realEscapeString($semId);
        
        $checkStudentSubjects = null;
        $pseudosubjectIDArr = [];
        $studentPresent = null;
        $isPseudosubject = null;
        
        try{
            $sql = "SELECT subjectID AS studentSubjectId FROM exam_reg_studentsubject WHERE studentID = $studentId AND subjectID = $subjectId AND examregID = $examRegistrationId";
            $checkStudentSubjects = $this->executeQueryForObject($sql)->studentSubjectId;
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        if($checkStudentSubjects)
        {
            try{
                $sql = "SELECT isPseudosubject AS isPseudosubject FROM sbs_relation WHERE batchID = $batchId AND semID = $semId AND subjectID = $subjectId";
                $isPseudosubject  = $this->executeQueryForObject($sql)->isPseudosubject;
                
            }catch (\Exception $e){
                throw new ProfessionalException($e->getCode(),$e->getMessage());
            }
            
            if($isPseudosubject == 1)
            {
                try{
                    $sql = "SELECT t1.pseudosubjectID AS pseudosubjectId FROM pseudosubjects_sbs t1 INNER JOIN sbs_relation t2 ON t1.sbsID = t2.sbsID WHERE t2.batchID = $batchId AND t2.semID = $semId AND t2.subjectID = $checkStudentSubjects";
                    $pseudosubjectIDArr = $this->executeQueryForList($sql);
                    
                }catch (\Exception $e){
                    throw new ProfessionalException($e->getCode(),$e->getMessage());
                }
                
                foreach ($pseudosubjectIDArr as $pseudosubjects) 
                {
                    $pseudosubjectsArr[] =  $pseudosubjects->pseudosubjectId;
                }
                if(count($pseudosubjectsArr))
                {
                    $pseudosubjectIDSTR = implode(",", $pseudosubjectsArr);    
                }    
                
                if(count($pseudosubjectIDArr))
                {
                    try{
                        $sql = "SELECT studentID AS studentId FROM pseudosubjects_students WHERE studentID = $studentId and pseudosubjectID IN ($pseudosubjectIDSTR)";
                        $studentPresent = $this->executeQueryForObject($sql)->studentId;
                        
                    }catch (\Exception $e){
                        throw new ProfessionalException($e->getCode(),$e->getMessage());
                    }
                    
                    if($studentPresent)
                    {
                        $subjectPresent = 1;
                    }
                    else
                    {
                        $subjectPresent = 0;
                    }
                }
            }
            else
            {
                $sql = "SELECT subjectID AS subjectId FROM exam_subjectcredit WHERE subjectID = $subjectId AND batchID = $batchId AND semID = $semId";
                $correctSubject = $this->executeQueryForObject($sql)->subjectId;
                if($correctSubject)
                {
                    $subjectPresent = 1;
                }
                else{
                    $subjectPresent = 0;    
                }
                
            }
            
        }
        
        return $subjectPresent;
    }
    /**
     * Method for getting internal max marks for a subject
     * @param unknown $subjectId
     * @param unknown $batchId
     * @param unknown $semId
     * @throws ProfessionalException
     * @return unknown
     * @author Ranjith Balachandran
     */
    
    public function getIntMaxMarks($subjectId,$batchId,$semId)
    {
        $sql = '';
        $subjectId = $this->realEscapeString($subjectId);
        $batchId = $this->realEscapeString($batchId);
        $semId = $this->realEscapeString($semId);
        
        $getIntMaxMarks = null;
        
        try{
            $sql = "SELECT maxInternalMarks AS maxInternal FROM internal_marks_settings WHERE subjectID = $subjectId AND batchID = $batchId AND semID = $semId";
            $getIntMaxMarks = $this->executeQueryForObject($sql)->maxInternal;
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $getIntMaxMarks;
    }
    
    /**
     * Method for getting student marks before maoderation
     * @param unknown $studentId
     * @param unknown $regularExamId
     * @throws ProfessionalException
     * @return unknown
     * @author Ranjith Balachandran
     */
    
    public function getStudentBeforeModerationMarks($studentId,$regularExamId)
    {
        $sql = '';
        $studentId = $this->realEscapeString($studentId);
        $regularExamId = $this->realEscapeString($regularExamId);
        
        $getStudentBeforeModerationMarks = null;
        
        try{
            $sql = "SELECT oldMark AS studentOldMark, exam_revaluation_mark AS revalMark FROM student_mark_before_moderation WHERE studentID = $studentId AND examID = $regularExamId";
            $getStudentBeforeModerationMarks = $this->executeQueryForObject($sql);
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $getStudentBeforeModerationMarks;
    }
    /**
     * Method for checking whether subject is practical is not
     * @param unknown $subjectId
     * @param unknown $batchId
     * @param unknown $semId
     * @throws ProfessionalException
     * @return unknown
     * @author Ranjith Balachandran
     */
    
    public function getPracticalSubjects($subjectId,$batchId,$semId)
    {
        $sql = '';
        $subjectId = $this->realEscapeString($subjectId);
        $batchId = $this->realEscapeString($batchId);
        $semId = $this->realEscapeString($semId);
        
        $getPracticalSubjectsFlag = null;
       
        
        try{
            $sql = "SELECT isPractical AS isPracticalFlag FROM marklist_group_subjects WHERE batchID = $batchId AND semID = $semId AND subjects_id = $subjectId";
            $getPracticalSubjectsFlag = $this->executeQueryForObject($sql)->isPracticalFlag;
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $getPracticalSubjectsFlag;
    }
    
    /**
     * Method for getting grouped subjectIds
     * @param unknown $subjectId
     * @param unknown $batchId
     * @param unknown $semId
     * @throws ProfessionalException
     * @return array
     * @author Ranjith Balachandran
     */
    
    public function getGroupId($subjectId,$batchId,$semId)
    {
        $sql = '';
        $subjectId = $this->realEscapeString($subjectId);
        $batchId = $this->realEscapeString($batchId);
        $semId = $this->realEscapeString($semId);
        
        $groupId = null;
        $subjectArr = [];
        
        try{
            $sql = "SELECT marklist_group_subjects_details_id AS groupId FROM marklist_group_subjects WHERE batchID = $batchId AND semID = $semId AND subjects_id = $subjectId";
            $groupId = $this->executeQueryForObject($sql)->groupId;
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        if($groupId)
        {
            try{
                $sql = "SELECT subjects_id AS subjectId FROM marklist_group_subjects WHERE batchID = $batchId AND semID = $semId AND marklist_group_subjects_details_id = $groupId";
                $subjectArr = $this->executeQueryForList($sql);
                
            }catch (\Exception $e){
                throw new ProfessionalException($e->getCode(),$e->getMessage());
            }
            
        }
        
        return $subjectArr;
    }
    
    /**
     * Method for getting grouped subjects regular marks
     * @param unknown $subjectId
     * @param unknown $batchId
     * @param unknown $semId
     * @param unknown $examRegId
     * @param unknown $studentId
     * @throws ProfessionalException
     * @return NULL
     * @author Ranjith Balachandran
     */
    
    public function getUniqueExamId($subjectId,$batchId,$semId,$examRegId,$studentId)
    {
        $sql = '';
        $subjectId = $this->realEscapeString($subjectId);
        $batchId = $this->realEscapeString($batchId);
        $semId = $this->realEscapeString($semId);
        $examRegId = $this->realEscapeString($examRegId);
        $studentId = $this->realEscapeString($studentId);
        
        $getUniqueExamId = null;
        $studentMark = null;
        $groupId = null;
        try{
            $sql = "SELECT marklist_group_subjects_details_id AS groupId FROM marklist_group_subjects WHERE batchID = $batchId AND semID = $semId AND subjects_id = $subjectId";
            $groupId = $this->executeQueryForObject($sql)->groupId;
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        if($groupId)
        {
            try{
                $sql = "SELECT subjects_id AS subjectId FROM marklist_group_subjects WHERE batchID = $batchId AND semID = $semId AND marklist_group_subjects_details_id = $groupId";
                $subjectArr = $this->executeQueryForList($sql);
                
            }catch (\Exception $e){
                throw new ProfessionalException($e->getCode(),$e->getMessage());
            }
            foreach ($subjectArr as $hisSubjectId) 
            {
                try{
                    $sql = "SELECT examID AS examId FROM exam WHERE batchID = $batchId AND semID = $semId AND subjectID = $hisSubjectId->subjectId AND examregID = $examRegId";
                    $getUniqueExamId = $this->executeQueryForObject($sql)->examId;
                
                }catch (\Exception $e){
                    throw new ProfessionalException($e->getCode(),$e->getMessage());
                }
                
                
                try{
                    $sql = "SELECT mark AS studentMark FROM exammarks_external WHERE examID = $getUniqueExamId AND studentID = $studentId;";
                    $studentMark += $this->executeQueryForObject($sql)->studentMark;
                
                }catch (\Exception $e){
                    throw new ProfessionalException($e->getCode(),$e->getMessage());
                }
                
            }
        
            
        }
       
        return $studentMark;
    }
    
    /**
     * Method for getting grouped subjects supply marks if exist
     * @param unknown $subjectId
     * @param unknown $batchId
     * @param unknown $semId
     * @param unknown $supplyExamRegId
     * @param unknown $studentId
     * @throws ProfessionalException
     * @return NULL
     * @author Ranjith Balachandran
     */
    
    public function getUniqueExamIdSupply($subjectId,$batchId,$semId,$supplyExamRegId,$studentId)
    {
        $sql = '';
        $subjectId = $this->realEscapeString($subjectId);
        $batchId = $this->realEscapeString($batchId);
        $semId = $this->realEscapeString($semId);
        $supplyExamRegId = $this->realEscapeString($supplyExamRegId);
        $studentId = $this->realEscapeString($studentId);
        
        $getUniqueExamId = null;
        $studentMark = null;
        $groupId = null;
        try{
            $sql = "SELECT marklist_group_subjects_details_id AS groupId FROM marklist_group_subjects WHERE batchID = $batchId AND semID = $semId AND subjects_id = $subjectId";
            $groupId = $this->executeQueryForObject($sql)->groupId;
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        if($groupId)
        {
            try{
                $sql = "SELECT subjects_id AS subjectId FROM marklist_group_subjects WHERE batchID = $batchId AND semID = $semId AND marklist_group_subjects_details_id = $groupId";
                $subjectArr = $this->executeQueryForList($sql);
                
            }catch (\Exception $e){
                throw new ProfessionalException($e->getCode(),$e->getMessage());
            }
            foreach ($subjectArr as $hisSubjectId) 
            {
                try{
                    $sql = "SELECT examID AS examId FROM exam WHERE batchID = $batchId AND semID = $semId AND subjectID = $hisSubjectId->subjectId AND supply_examreg_id = $supplyExamRegId";
                    $getUniqueExamId = $this->executeQueryForObject($sql)->examId;
                
                }catch (\Exception $e){
                    throw new ProfessionalException($e->getCode(),$e->getMessage());
                }
                
                if($getUniqueExamId)
                {
                    try{
                        $sql = "SELECT mark AS studentMark FROM exammarks_external WHERE examID = $getUniqueExamId AND studentID = $studentId;";
                        $studentMark += $this->executeQueryForObject($sql)->studentMark;
                    
                    }catch (\Exception $e){
                        throw new ProfessionalException($e->getCode(),$e->getMessage());
                    }    
                }
                
                
            }
        
            
        }
       
        return $studentMark;
    }
    /**
     * Method for getting student grace marks
     * @param unknown $subjectId
     * @param unknown $examId
     * @param unknown $studentId
     * @param unknown $semId
     * @throws ProfessionalException
     * @return unknown|number
     * @author Ranjith Balachandran
     */
    
    public function getStudentGraceMarks($subjectId,$examId,$studentId,$semId)
    {
        $sql = '';
        $subjectId = $this->realEscapeString($subjectId);
        $examId = $this->realEscapeString($examId);
        $semId = $this->realEscapeString($semId);
        $studentId = $this->realEscapeString($studentId);
        
        $studentGraceMarks = null;
       
        
        try{
            $sql = "SELECT marks AS graceMark FROM gracemarks_student_marks WHERE examID = $examId AND semID = $semId AND subjectID = $subjectId AND studentID = $studentId AND approve = 1 AND fianlize = 1";
            $studentGraceMarks = $this->executeQueryForObject($sql)->graceMark;
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        if($studentGraceMarks)
        {
            return $studentGraceMarks;    
        }
        else
        {
            return 0;
        }
        
    }
    
    /**
     * Method for getting student revaluation marks
     * @param unknown $examId
     * @param unknown $studentId
     * @throws ProfessionalException
     * @return unknown
     * @author Ranjith Balachandran
     */
    
    public function getStudentRevalMarks($examId,$studentId)
    {
        $sql = '';
        $examId = $this->realEscapeString($examId);
        $studentId = $this->realEscapeString($studentId);
        
        $studentRevalMarks = null;
       
        
        try{
            $sql = "SELECT mark AS revalMark FROM revaluation_marks_finalized WHERE examID = $examId AND studentID = $studentId AND approveMark = 1";
            $studentRevalMarks = $this->executeQueryForObject($sql)->revalMark;
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $studentRevalMarks;
    }
    /**
     * Method for getting prev combined subjects
     * @param unknown $examId
     * @param unknown $batchId
     * @param unknown $semId
     * @throws ProfessionalException
     * @return unknown
     * @author Ranjith Balachandran
     */
    
    public function getPrevSubjectsCombined($examId,$batchId,$semId)
    {
        $sql = '';
        $examId = $this->realEscapeString($examId);
        $batchId = $this->realEscapeString($batchId);
        $semId = $this->realEscapeString($semId);
        
        $getPrevSubjectsCombined = [];
       
        
        try{
            $sql = "SELECT eci.combinationID AS combinationId, eci.semID_prev AS prevSemId, eci.subjectID_prev AS prevSubjectId, s.subjectName, s.subjectDesc FROM exam_combineInternals eci INNER JOIN subjects s ON eci.subjectID_prev = s.subjectID WHERE eci.batchID = $batchId AND eci.semID_curr = $semId AND eci.examID = $examId";
            $getPrevSubjectsCombined = $this->executeQueryForList($sql);
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $getPrevSubjectsCombined;
    }
    
    /**
     * Method for getting prev exam details
     * @param unknown $batchId
     * @param unknown $prevSemId
     * @param unknown $prevSubjectId
     * @param unknown $studentId
     * @throws ProfessionalException
     * @return unknown
     * @author Ranjith Balachandran
     */
    
    public function getPrevExamDetails($batchId,$prevSemId,$prevSubjectId,$studentId)
    {
        $sql = '';
        $prevSubjectId = $this->realEscapeString($prevSubjectId);
        $batchId = $this->realEscapeString($batchId);
        $prevSemId = $this->realEscapeString($prevSemId);
        $studentId = $this->realEscapeString($studentId);
        
        $getPrevExamDetails = null;
       
        
        try{
            $sql = "SELECT t1.maxInternalMarks, t2.internalMarks FROM internal_marks_settings t1, internal_marks t2, internal_marks_submitted t3 WHERE t1.batchID = $batchId AND t1.semID = $prevSemId AND t1.subjectID = $prevSubjectId AND t1.batchID = t2.batchID AND t1.semID = t2.semID AND t1.subjectID = t2.subjectID AND t2.studentID = $studentId AND t2.semID = t3.semID AND t2.subjectID = t3.subjectID AND t2.batchID = t3.batchID";
            $getPrevExamDetails = $this->executeQueryForObject($sql);
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $getPrevExamDetails;
    }
    
    /**
     * Method for saving exam code for all batches for a semester
     * @param unknown $batchId
     * @param unknown $semId
     * @param unknown $examCode
     * @throws ProfessionalException
     * @author Ranjith Balachandran
     */
    
    public function saveBatchSemWiseExamCode($batchId,$semId,$examCode,$admissionYear,$courseTypeId,$suppExamId)
    {
        $sql = '';
        $batchId = $this->realEscapeString($batchId);
        $semId = $this->realEscapeString($semId);
        $examCode = $this->realEscapeString($examCode);
        $admissionYear = $this->realEscapeString($admissionYear);
        $courseTypeId = $this->realEscapeString($courseTypeId);
        $suppExamId = $this->realEscapeString($suppExamId);
        
        try{
            $sql = "INSERT INTO batchSemWiseExamCode (batches_id,semesters_id,examCode,admissionYear,courseTypeId,submitted,exam_supplementary_id) VALUES ($batchId,$semId,'$examCode','$admissionYear',$courseTypeId,'0','$suppExamId')";
            $this->executeQuery($sql);
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
    }
    
    /**
     * Method for deleting examCode for an admission year 
     * @param unknown $admissionYear
     * @param unknown $courseTypeId
     * @throws ProfessionalException
     * @author Ranjith Balachandran
     */
    
    public function deleteExamCode($admissionYear,$courseTypeId,$suppExamId)
    {
        $sql = '';
        $admissionYear = $this->realEscapeString($admissionYear);
        $courseTypeId = $this->realEscapeString($courseTypeId);
        $suppExamId = $this->realEscapeString($suppExamId);
        
        try{
            $sql = "DELETE FROM batchSemWiseExamCode WHERE courseTypeId = $courseTypeId AND admissionYear = $admissionYear AND exam_supplementary_id = $suppExamId";
            $this->executeQuery($sql);
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
    }
    /**
     * Method for fetching examCode for a batch  and sem
     * @param unknown $batchId
     * @param unknown $semId
     * @throws ProfessionalException
     * @author Ranjith Balachandran
     */
    
    public function getExamCode($batchId,$semId,$suppExamId)
    {
        $sql = '';
        $batchId = $this->realEscapeString($batchId);
        $semId = $this->realEscapeString($semId);
        $suppExamId = $this->realEscapeString($suppExamId);
        $examCode = null;
        
        try{
            $sql = "SELECT examCode AS examCode FROM batchSemWiseExamCode WHERE batches_id = $batchId AND semesters_id = $semId AND submitted = 1 AND exam_supplementary_id = $suppExamId";
            $examCode = $this->executeQueryForObject($sql)->examCode;
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        return $examCode;
    }
    
    /**
     * Method for getting examCode details for an admission year and courseTypeId
     * @param unknown $admissionYear
     * @param unknown $courseTypeId
     * @throws ProfessionalException
     * @return object|array|\com\linways\base\util\$objectList[]
     * @author Ranjith Balachandran
     */
    
    public function getExamCodeDetailsForAdmissionYear($admissionYear,$courseTypeId,$suppExamId)
    {
        $sql = '';
        $admissionYear = $this->realEscapeString($admissionYear);
        $courseTypeId = $this->realEscapeString($courseTypeId);
        $suppExamId = $this->realEscapeString($suppExamId);
        
        $getExamCodeDetailsForAdmissionYear = [];
        
        try{
            $sql = "SELECT batches_id AS batchId,examCode,submitted FROM batchSemWiseExamCode WHERE admissionYear = $admissionYear AND courseTypeId = $courseTypeId AND exam_supplementary_id = $suppExamId";
            $getExamCodeDetailsForAdmissionYear = $this->executeQueryForList($sql);
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $getExamCodeDetailsForAdmissionYear;
    }
    
    /**
     * Method for updating final submission flag for examCode
     * @param unknown $admissionYear
     * @param unknown $courseTypeId
     * @throws ProfessionalException
     * @author Ranjith Balachandran
     */
    
    public function finalSubmissionOfExamCode($admissionYear,$courseTypeId,$suppExamId)
    {
        $sql = '';
        $admissionYear = $this->realEscapeString($admissionYear);
        $courseTypeId = $this->realEscapeString($courseTypeId);
        $suppExamId = $this->realEscapeString($suppExamId);
        
        try{
            $sql = "UPDATE batchSemWiseExamCode SET submitted = 1 WHERE admissionYear = $admissionYear AND courseTypeId = $courseTypeId AND exam_supplementary_id = $suppExamId";
            $this->executeQuery($sql);
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
         
    }
    
    /**
     * Method for getting final submitted flag
     * @param unknown $admissionYear
     * @param unknown $courseTypeId
     * @throws ProfessionalException
     * @return unknown
     * @author Ranjith Balachandran
     */
    
    public function getFinalSubmittedFlag($admissionYear,$courseTypeId,$suppExamId)
    {
        $sql = '';
        $admissionYear = $this->realEscapeString($admissionYear);
        $courseTypeId = $this->realEscapeString($courseTypeId);
        $suppExamId = $this->realEscapeString($suppExamId);
        
        $finalSubmittedFlag = null;
        
        try{
            $sql = "SELECT submitted AS finalSubmittedFlag FROM batchSemWiseExamCode WHERE admissionYear = $admissionYear AND courseTypeId = $courseTypeId AND exam_supplementary_id = $suppExamId";
            $finalSubmittedFlag = $this->executeQueryForObject($sql)->finalSubmittedFlag;
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $finalSubmittedFlag;
    }
    
    /**
     * Method for checking whether examcode is assigned for this batch 
     * @param unknown $admissionYear
     * @param unknown $courseTypeId
     * @param unknown $batchId
     * @throws ProfessionalException
     * @return unknown
     * @author Ranjith Balachandran
     */
    
    public function isBatchExamCodeDefined($admissionYear,$courseTypeId,$batchId,$suppExamId)
    {
        $sql = '';
        $admissionYear = $this->realEscapeString($admissionYear);
        $courseTypeId = $this->realEscapeString($courseTypeId);
        $batchId = $this->realEscapeString($batchId);
        $suppExamId = $this->realEscapeString($suppExamId);
        
        $isBatchExamCodeDefined = null;
        
        try{
            $sql = "SELECT batches_id AS batchId FROM batchSemWiseExamCode WHERE admissionYear = $admissionYear AND courseTypeId = $courseTypeId AND batches_id = $batchId AND exam_supplementary_id = $suppExamId";
            $isBatchExamCodeDefined = $this->executeQueryForObject($sql)->batchId;
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $isBatchExamCodeDefined;
    }
    
    public function isExamCodeDefined($admissionYear,$courseTypeId,$semId,$suppExamId)
    {
        $sql = '';
        $admissionYear = $this->realEscapeString($admissionYear);
        $courseTypeId = $this->realEscapeString($courseTypeId);
        $semId = $this->realEscapeString($semId);
        $suppExamId = $this->realEscapeString($suppExamId);
        
        $isExamCodeDefined = null;
        
        try{
            $sql = "SELECT examCode AS examCode FROM batchSemWiseExamCode WHERE admissionYear = $admissionYear AND courseTypeId = $courseTypeId AND semesters_id = $semId AND exam_supplementary_id = $suppExamId";
            $isExamCodeDefined = $this->executeQueryForObject($sql)->examCode;
            
        }catch (\Exception $e){
            throw new ProfessionalException($e->getCode(),$e->getMessage());
        }
        
        return $isExamCodeDefined;
    }
    
}