Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 149
Template8IndividualResultGenerator
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 5
272.00
0.00% covered (danger)
0.00%
0 / 149
 __construct
n/a
0 / 0
1
n/a
0 / 0
 getTemplateName
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 8
 processData
0.00% covered (danger)
0.00%
0 / 1
20.00
0.00% covered (danger)
0.00%
0 / 23
 renderIndividualMarkCardResult
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 44
 processStudentData
0.00% covered (danger)
0.00%
0 / 1
30.00
0.00% covered (danger)
0.00%
0 / 46
 getExamRegistrationDetailsData
0.00% covered (danger)
0.00%
0 / 1
6.00
0.00% covered (danger)
0.00%
0 / 28
<?php
// Template Individual Generator For IIIC Colleges
namespace com\linways\ec\core\service\RegularIndividualMarkCardGenerator;
use com\linways\ec\core\service\StudentMarkListService;
use com\linways\ec\core\service\ExamRegistrationService;
use com\linways\ec\core\exception\ExamControllerException;
use com\linways\base\util\TwigRenderer;
use com\linways\core\ams\professional\util\PdfUtil;
use com\linways\core\ams\professional\util\CommonUtil;
use com\linways\ec\core\service\CommonExamService;
use com\linways\ec\core\service\RegularIndividualMarkCardGenerator\RegularIndividualMarkCardResultDataGenerator;
class Template8IndividualResultGenerator extends RegularIndividualMarkCardResultDataGenerator
{
    public function __construct(){}
     /**
     * get Template Name
     * @param $request
     * @param $templateName
     */
    protected function getTemplateName($request){
        $templateName = "Template_8";
        $examRegistrationDetails = new \stdClass;
        $examRegistrationDetailsArray = ExamRegistrationService::getInstance()->searchDetailedExamRegistrationDetails($request);
        if(empty($examRegistrationDetailsArray)){
            throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found");
        }
        return $templateName;
    }
    /**
     * Process Student data college base
     * @param $request
     */
    protected function processData($request){
        $response = new \stdClass;
        $studentsMarkDetails = [];
        $studentsMarkDetails = StudentMarkListService::getInstance()->getAllRegistredStudentMarkDetailsDummyData($request);
        if(empty($studentsMarkDetails)){
            throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found");
        }
        $responseOfStudentData = $this->processStudentData($studentsMarkDetails);
        $response->studentData = $responseOfStudentData->studentsDetails;
        $response->studentData = $responseOfStudentData->studentsDetails;
        $response->totalStudentData = $responseOfStudentData->totalStudentDetails;
        $response->examRegistrationData = $this->getExamRegistrationDetailsData($request);
        $response->collegeAndOtherData = CommonExamService::getInstance()->getCollegeDetails($request);
        if( $request->displayContentOptions->enableDateFlag == '1'){
            if(!$request->displayContentOptions->markListDate ){
                $request->displayContentOptions->markListDate = date("d/m/Y");
            }
            else{
                $request->displayContentOptions->markListDate = date("d/m/Y", strtotime($request->displayContentOptions->markListDate));
            }
        }
        $response->displayContentOptions = $request->displayContentOptions;
        return $response;
       
    }
    /**
     * Render Program Result
     *
     * @param $templateName
     * @param Object $data
     * @return Object
     */
    protected function renderIndividualMarkCardResult($templateName, $data){
        if(empty($data)){
            throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found");
        }
        else{
            $responseHtml = TwigRenderer::renderTemplateFileToHtml(realpath(DOCUMENT_ROOT."../examcontroller-api/src/com/linways/web/templates/RegularIndividualMarkCards/Template8/$templateName.twig"), [ 'data'=>$data ]);
            $prtContent = NULL;
            $responseHtml .= '<script>
                                var file1 = document.getElementById("backgroundImg").files[0];
                                var reader1 = new FileReader();
                                console.log(reader1);
                                reader1.onloadend = function() {
                                    $(".pages").css({
                                        "backgroundImage": "url(" + reader1.result + ")"
                                    });
                                }
                                if (file1) {
                                    reader1.readAsDataURL(file1);
                                } else {}
                            </script>';
            $prtContent .= '<html><head>';
            $prtContent .= "<style>
                h6 {font-size: 26px;} .text-center { text-align: center;} .align-middle {vertical-align: middle;}; 
                
                </style>";
            $prtContent .= '</head><title>Individual Mark Card</title><body>';
            $prtContent .= $responseHtml;
            $prtContent .= '</body></html>';
            $totalWidth = 210;
            $totalHeight = 297;
            $options = array(
                'page-width'     => $totalWidth."mm",
                'page-height'    => $totalHeight."mm",
                'dpi'            => 96,
                'margin-top' => "9mm",
                'margin-left' => "1mm",
                'margin-right' => "1mm",
                'margin-bottom' => "9mm",
                // 'binary' => "/usr/local/bin/wkhtmltopdf", // For Mac
                'user-style-sheet' => realpath(DOCUMENT_ROOT . "/libcommon/bootstrap/css/bootstrap.min.css")
            );
            $programResult = new \stdClass;
            $programResult->dispalyHtmlData = $prtContent;
            $programResult->printData = PdfUtil::renderPdf($prtContent, $options);
        return  $programResult;
        }
    }
    /**
     * processStudentData
     * @param $studentsMarkDetails
     * @param $studentsDetails
     */
    protected function processStudentData($studentsMarkDetails){
        $response = new \stdClass;
        $totalStudentDetails = new \stdClass;
        $totalStudentDetails->totalStudents = count($studentsMarkDetails);
        $studentsDetails = [];
        foreach($studentsMarkDetails as $student){
            $studentsDetails[$student->id]->id = $student->id;
            $studentsDetails[$student->id]->name = $student->studentDetails->name;
            $studentsDetails[$student->id]->isResultBlocked = $student->isResultBlocked;
            $studentsDetails[$student->id]->blockingMsg = $student->blockingMsg;
            $studentsDetails[$student->id]->failedStatus = $student->academicTerms[0]->isFailed;
            $studentsDetails[$student->id]->registerNo = $student->studentDetails->registerNo;
            $studentsDetails[$student->id]->rollNo = $student->studentDetails->rollNo;
            $studentsDetails[$student->id]->semesterGrade = $student->academicTerms[0]->grade;
            $studentsDetails[$student->id]->semesterSgpa = $student->academicTerms[0]->sgpa;
            $studentsDetails[$student->id]->semesterpassPercentage = $student->academicTerms[0]->passPercentage;
            $studentsDetails[$student->id]->semesterTotalMinimumMarks = $student->academicTerms[0]->totalMarks *  $student->academicTerms[0]->passPercentage / 100;
            $studentsDetails[$student->id]->semesterTotalMarks = $student->academicTerms[0]->totalMarks;
            $studentsDetails[$student->id]->semesterMarkObtained = $student->academicTerms[0]->markObtained;
            $studentsDetails[$student->id]->semesterMarkObtainedInWord = strtoupper(CommonUtil::convertNumberToWords($student->academicTerms[0]->markObtained));
            $studentsDetails[$student->id]->semesterPercentage = $student->academicTerms[0]->percentage;
            $studentsDetails[$student->id]->semesterClass = $student->academicTerms[0]->class;
            if($studentsDetails[$student->id]->failedStatus == "PASSED"){
                $totalStudentDetails->passStudents ++;
            }
            foreach($student->academicTerms[0]->subjects as $subject){
                $studentsDetails[$student->id]->subjects[$subject->id]->id = $subject->id;
                $studentsDetails[$student->id]->subjects[$subject->id]->name = $subject->name;
                $studentsDetails[$student->id]->subjects[$subject->id]->code = $subject->code;
                $studentsDetails[$student->id]->subjects[$subject->id]->class = $subject->class;
                $studentsDetails[$student->id]->subjects[$subject->id]->grade = $subject->grade;
                $studentsDetails[$student->id]->subjects[$subject->id]->percentage = $subject->percentage;
                $studentsDetails[$student->id]->subjects[$subject->id]->totalMaxMark = $subject->totalMarks;
                $studentsDetails[$student->id]->subjects[$subject->id]->markObtained = $subject->markObtained;
                $studentsDetails[$student->id]->subjects[$subject->id]->failedStatus = $subject->isFailed;
            }
            
        }
        $totalStudentDetails->passPercentage = round(100 * ( $totalStudentDetails->passStudents / $totalStudentDetails->totalStudents),2);
        $studentsDetails = array_values($studentsDetails); 
        foreach($studentsDetails as $student){
            $student->subjects = array_values($student->subjects); 
            $student->subjectCategories = array_values($student->subjectCategories);
        }
        $response->studentsDetails = $studentsDetails;
        $response->totalStudentDetails = $totalStudentDetails;
        return $response;
    }
    protected function getExamRegistrationDetailsData($request){
        $examRegistrationDetails = new \stdClass;
        $examRegistrationDetailsArray = ExamRegistrationService::getInstance()->searchDetailedExamRegistrationDetails($request);
        if(empty($examRegistrationDetailsArray)){
            throw new ExamControllerException(ExamControllerException::NO_DETAILS_FOUND,"No Details Found");
        }
        $examRegistrationDetails->name = $examRegistrationDetailsArray[0]->name;
        $examRegistrationDetails->examYear = $examRegistrationDetailsArray[0]->examYear;
        $examRegistrationDetails->examMonth = $examRegistrationDetailsArray[0]->examMonth;
        $examRegistrationDetails->examMonthName = $examRegistrationDetailsArray[0]->examMonthName;
        $examRegistrationDetails->type = $examRegistrationDetailsArray[0]->type;
        $examRegistrationDetails->groupId = $examRegistrationDetailsArray[0]->groups[0]->groupId;
        $examRegistrationDetails->groupName = $examRegistrationDetailsArray[0]->groups[0]->groupName;
        $examRegistrationDetails->courseTypeID = $examRegistrationDetailsArray[0]->groups[0]->courseTypeID;
        $examRegistrationDetails->courseTypeName = $examRegistrationDetailsArray[0]->groups[0]->courseTypeName;
        $examRegistrationDetails->academicTermName = $examRegistrationDetailsArray[0]->groups[0]->academicTermName;
        $examRegistrationDetails->academicTermYear = $examRegistrationDetailsArray[0]->groups[0]->academicTermYear;
        $examRegistrationDetails->academicTermYearRoman = strtoupper(CommonUtil::convertNumberToRoman($examRegistrationDetails->academicTermYear));
        $examRegistrationDetails->academicTermId = $examRegistrationDetailsArray[0]->groups[0]->academicTermId;
        $semesterNames = CommonExamService::getInstance()->getDifferentSemesterName($examRegistrationDetails->academicTermName);
        $examRegistrationDetails->semInRomanLetter = $semesterNames->romanLetter;
        $examRegistrationDetails->semInFullName = $semesterNames->fullName;
        $examRegistrationDetails->semInSemNumber = $semesterNames->semNumber;
        $examRegistrationDetails->batchStartYear = $examRegistrationDetailsArray[0]->groups[0]->batchStartYear;
        $examRegistrationDetails->deptID = $examRegistrationDetailsArray[0]->groups[0]->deptID;
        $examRegistrationDetails->deptName = $examRegistrationDetailsArray[0]->groups[0]->deptName;
        $examRegistrationDetails->degreeName = $examRegistrationDetailsArray[0]->groups[0]->degreeName;
        return $examRegistrationDetails;
    }
    
}