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 : 18.188.188.152


Current Path : /var/www/oasis/Report_details/
Upload File :
Current File : /var/www/oasis/Report_details/marksentryquestionwise.php

<?php
    function viewIAQuestionWisewise($aobj_context){
        session_start();
        $collcode=$_SESSION['collcode'];
        $teachcode = $aobj_context->mobj_data["teachcode"];
        $classid = $aobj_context->mobj_data["classid"];
        $subelement = $aobj_context->mobj_data["subelement"];
        $txtmarks = $aobj_context->mobj_data["txtmarks"];
        $txtunits = $aobj_context->mobj_data["txtunits"];
        $testName = $aobj_context->mobj_data["testName"];

        $queryView = "select * from maxmarksint 
                      where fclassid='{$classid}' and ftestname='{$testName}'";
        $resMarks=$aobj_context->mobj_db->GetAll($queryView);

        if(count($resMarks) == 0){
            $arr['msg'] = "Marks details not entered";
            echo($aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure"));  
            return;
        }

        $query = "select distinct fcollcode,fdegree,fexamno from attendsum where fclassid = '{$classid}'";
        $res=$aobj_context->mobj_db->GetRow($query);
        $collcode = $res['fcollcode'];
        $degree = $res['fdegree'];
        $exam = $res['fexamno'];

        $query = "select * from subdet 
        where fcollcode = '{$collcode}' 
        and DATE_FORMAT(NOW(),'%Y-%m-%d') between DATE_FORMAT(fiafrom,'%Y-%m-%d') 
        AND DATE_FORMAT(fiato,'%Y-%m-%d')
        and concat(fcsubcode,fsubcode) = '{$subelement}'";
        
        $res3=$aobj_context->mobj_db->GetAll($query);
        

        $query = "select * from control";
        $res9=$aobj_context->mobj_db->GetRow($query);
        $FREGROLL = $res9['FREGROLL'];

        $query1 = "select stu.FREGNO, stu.FNAME, sd.fexamno, sd.fdegree, stu.fcollcode,
                ifnull(mak.fmarks11, '-1')as fmarks11, ifnull(mak.fmarks12, '-1')as fmarks12, ifnull(mak.fmarks13, '-1')as fmarks13, ifnull(mak.fmarks14, '-1')as fmarks14,
                ifnull(mak.fmarks21, '-1')as fmarks21, ifnull(mak.fmarks22, '-1')as fmarks22, ifnull(mak.fmarks23, '-1')as fmarks23, ifnull(mak.fmarks24, '-1')as fmarks24,
                ifnull(mak.fmarks31, '-1')as fmarks31, ifnull(mak.fmarks32, '-1')as fmarks32, ifnull(mak.fmarks33, '-1')as fmarks33, ifnull(mak.fmarks34, '-1')as fmarks34,
                ifnull(mak.fmarks41, '-1')as fmarks41, ifnull(mak.fmarks42, '-1')as fmarks42, ifnull(mak.fmarks43, '-1')as fmarks43, ifnull(mak.fmarks44, '-1')as fmarks44, mak.FTOTAL,  
                mak.fsubcode, mak.fdegree, mak.fexamno, 
                fnotest as FTEST, fu1max, fu2max, fqnno 
                FROM attendsum a inner join student stu on stu.FREGNO=a.FREGNO and stu.fdegree = a.fdegree
                inner join degree d on d.FDEGREE =a.FDEGREE and d.Fexamno=a.Fexamno
                inner join subdet sd on a.fdegree = sd.fdegree and a.fexamno = sd.fexamno 
                and left(a.fsubcode,4) = left(sd.fcsubcode,4)
                left join marksint mak ON a.fdegree = mak.fdegree and a.FREGNO=mak.FREGNO 
                and mak.ftest = '{$testName}' 
                where  a.fteachcode = '{$teachcode}' and a.fclassid = '{$classid}' 
                and a.FCOLLCODE='{$collcode}'
                and left(a.fsubcode,4) = left('{$subelement}',4) 
                group by fregno order by FREGNO";

        $result=$aobj_context->mobj_db->GetAll($query1);

        $e_data.="<table id='tabledata' class='table' width='100%' align='center' cellspacing='0' cellpadding='0' border='0' >";
        $e_data.="<thead style='position:sticky; top:0; z-index:1'>";
        $e_data.="<tr><th align='left' colspan='9' class='ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper' style='font-size:12px; padding-left:6px; height:22px;'>Marks Entry (Question Wise)</th></tr>";
        $e_data.="<tr class='ui-state-default ui-jqgrid-hdiv'>";
        $e_data.="<td  rowspan='2' class='headcol' align=center style='padding:2px;  border-bottom:1px solid #C5DBEC; border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; border-bottom:1px solid #C5DBEC;position:sticky; background:white; left:0;'>Sl No</td>";
		$e_data.="<td  rowspan='2' class='headcol' align=center style='padding:2px;  border-bottom:1px solid #C5DBEC; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC;  border-bottom:1px solid #C5DBEC;position:sticky; background:white; left:47px;'>USN</td>"; 
		$e_data.="<td  rowspan='2'class='headcol' align=center style='padding:2px;  border-bottom:1px solid #C5DBEC; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC;  border-bottom:1px solid #C5DBEC;position:sticky; background:white; left:153px;'>Student Name</td>";
        $e_data.="<td  rowspan='2'  align=center style='padding:2px;  border-bottom:1px solid #C5DBEC; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC;  border-bottom:1px solid #C5DBEC;position:sticky; background:white; left:360px;'>Total</td>";
        $e_data.="<td rowspan='2'  align=center style='padding:2px;  border-bottom:1px solid #C5DBEC; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC;  border-bottom:1px solid #C5DBEC;position:sticky; background:white; left:416px;'>Absent</td>";
        
         for($m=1; $m <= 4; $m++){
            $e_data.="<td align=center style='padding:2px;  border-bottom:1px solid #C5DBEC; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC;  border-bottom:1px solid #C5DBEC;'>
                        <div style='display:flex;gap:5px; justify-content:center'>{$m} (Max. 25 marks)</div>
                    </td>";
        }
        $e_data.="</tr>";
		$e_data.="<tr class='ui-state-default ui-jqgrid-hdiv'>";
        
        foreach($resMarks as $v){
            $e_data.="<td  align=center style='padding:2px;  border-bottom:1px solid #C5DBEC; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC;  border-bottom:1px solid #C5DBEC;'>
                        <p style='width:35px'>A<br/>(<span id='a1max'>".intval($resMarks['FMARKS'])."</span>)</p> 
                    </td>";
        }
        // $e_data.="<td  align=center style='padding:2px;  border-bottom:1px solid #C5DBEC; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC;  border-bottom:1px solid #C5DBEC;'>
        //             <div style='display:flex;gap:5px; justify-content:space-between'> 
        //                 <p style='width:35px'>A<br/>(<span id='a1max'>".intval($resMarks['F1AMAX'])."</span>)</p> 
        //                 <p style='width:35px'>B<br/>(<span id='b1max'>".intval($resMarks['F1BMAX'])."</span>)</p> 
        //                 <p style='width:35px'>C<br/>(<span id='c1max'>".intval($resMarks['F1CMAX'])."</span>)</p> 
        //                 <p style='width:35px'>D<br/>(<span id='d1max'>".intval($resMarks['F1DMAX'])."</span>)</p>
        //             </div>
        //         </td>";
        // $e_data.="<td  align=center style='padding:2px;  border-bottom:1px solid #C5DBEC; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC;  border-bottom:1px solid #C5DBEC;'>
        //             <div style='display:flex;gap:5px; justify-content:space-between'> 
        //                 <p style='width:35px'>A <br/>(<span id='a2max'>".intval($resMarks['F2AMAX'])."</span>)</p> 
        //                 <p style='width:35px'>B<br/>(<span id='b2max'>".intval($resMarks['F2BMAX'])."</span>)</p> 
        //                 <p style='width:35px'>C<br/>(<span id='c2max'>".intval($resMarks['F2CMAX'])."</span>)</p> 
        //                 <p style='width:35px'>D<br/>(<span id='d2max'>".intval($resMarks['F2DMAX'])."</span>)</p>
        //             </div>
        //         </td>";
        // $e_data.="<td  align=center style='padding:2px;  border-bottom:1px solid #C5DBEC; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC;  border-bottom:1px solid #C5DBEC;'>
        //             <div style='display:flex;gap:5px; justify-content:space-between'> 
        //                 <p style='width:35px'>A <br/>(<span id='a3max'>".intval($resMarks['F3AMAX'])."</span>)</p> 
        //                 <p style='width:35px'>B<br/>(<span id='b3max'>".intval($resMarks['F3BMAX'])."</span>)</p> 
        //                 <p style='width:35px'>C<br/>(<span id='c3max'>".intval($resMarks['F3CMAX'])."</span>)</p> 
        //                 <p style='width:35px'>D<br/>(<span id='d3max'>".intval($resMarks['F3DMAX'])."</span>)</p>
        //             </div>
        //         </td>";
        // $e_data.="<td  align=center style='padding:2px;  border-bottom:1px solid #C5DBEC; border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC;  border-bottom:1px solid #C5DBEC;'>
        //             <div style='display:flex;gap:5px; justify-content:space-between'> 
        //                  <p style='width:35px'>A <br/>(<span id='a4max'>".intval($resMarks['F4AMAX'])."</span>)</p> 
        //                 <p style='width:35px'>B<br/>(<span id='b4max'>".intval($resMarks['F4BMAX'])."</span>)</p> 
        //                 <p style='width:35px'>C<br/>(<span id='c4max'>".intval($resMarks['F4CMAX'])."</span>)</p> 
        //                 <p style='width:35px'>D<br/>(<span id='d4max'>".intval($resMarks['F4DMAX'])."</span>)</p>
        //             </div>
        //         </td>";
        
		$e_data.="</tr>";
        $e_data.="</thead>";
		
        $k=1;
		for($m=0;$m<count($result);$m++)
		{	
            $fmarks11 = $result[$m]['fmarks11'] == "-1.00" ? '-1' : $result[$m]['fmarks11'];
            $fmarks12 = $result[$m]['fmarks12'] == "-1.00" ? '-1' : $result[$m]['fmarks12'];
            $fmarks13 = $result[$m]['fmarks13'] == "-1.00" ? '-1' : $result[$m]['fmarks13'];
            $fmarks14 = $result[$m]['fmarks14'] == "-1.00" ? '-1' : $result[$m]['fmarks14'];
            $fmarks21 = $result[$m]['fmarks21'] == "-1.00" ? '-1' : $result[$m]['fmarks21'];
            $fmarks22 = $result[$m]['fmarks22'] == "-1.00" ? '-1' : $result[$m]['fmarks22'];
            $fmarks23 = $result[$m]['fmarks23'] == "-1.00" ? '-1' : $result[$m]['fmarks23'];
            $fmarks24 = $result[$m]['fmarks24'] == "-1.00" ? '-1' : $result[$m]['fmarks24'];
            $fmarks31 = $result[$m]['fmarks31'] == "-1.00" ? '-1' : $result[$m]['fmarks31'];
            $fmarks32 = $result[$m]['fmarks32'] == "-1.00" ? '-1' : $result[$m]['fmarks32'];
            $fmarks33 = $result[$m]['fmarks33'] == "-1.00" ? '-1' : $result[$m]['fmarks33'];
            $fmarks34 = $result[$m]['fmarks34'] == "-1.00" ? '-1' : $result[$m]['fmarks34'];
            $fmarks41 = $result[$m]['fmarks41'] == "-1.00" ? '-1' : $result[$m]['fmarks41'];
            $fmarks42 = $result[$m]['fmarks42'] == "-1.00" ? '-1' : $result[$m]['fmarks42'];
            $fmarks43 = $result[$m]['fmarks43'] == "-1.00" ? '-1' : $result[$m]['fmarks43'];
            $fmarks44 = $result[$m]['fmarks44'] == "-1.00" ? '-1' : $result[$m]['fmarks44'];

            $e_data.="<tr class='ui-widget-content jqgrow'>";
            $e_data.="<td class='tbl_row_new' align='center' style='width:40px;border-left:1px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px;position:sticky; background:white; left:0;' >{$k}</td>";
            $e_data.="<td class='tbl_row_new' align='center' style='width:100px;border-left:0px solid #C5DBEC; border-right:1px solid #C5DBEC; padding:2px;position:sticky; background:white; left:47px;'>{$result[$m]['FREGNO']}</td>";			
            $e_data.="<td class='tbl_row_new' style='width:200px;border-right:1px solid #C5DBEC;  padding:2px;position:sticky; background:white; left:153px;'>{$result[$m]['FNAME']}</td>";
            $e_data.="<td class='tbl_row_new' align='center' style='width:50px;border-right:1px solid #C5DBEC;  padding:2px;position:sticky; background:white; left:360px;'>
                        <input type='text' class='total_{$k}' id='total_{$k}' style='width:30px;text-align: center;{$border};' value='{$result[$m]['FTOTAL']}' disabled>
                      </td>";
            $e_data.="<td class='tbl_row_new' align='center' style='width:50px;border-right:1px solid #C5DBEC;  padding:2px;position:sticky; background:white; left:416px;'>
                        <input type='checkbox' id='absent_{$k}' style='width:30px;text-align: center;{$border};' value='' onchange='frezstd($k,this)'>
                      </td>";
            
            $e_data.="<td class='tbl_row_new' align='center'  style='width:150px;border-right:1px solid #C5DBEC;  padding:2px;'>
                    <div style='display:flex; gap:1px; justify-content:space-between;'>
                        <input type='text' oninput='getTotal($k)' onkeypress='return isNumber(event)' onblur='checkValidMarks(`mark1A_`, $k, `1`, this)' class='mark1A_{$k}' id='mark1A_{$k}' style='width:35px;text-align: center;{$border};' value='{$fmarks11}'>
                        <input type='text' oninput='getTotal($k)' onkeypress='return isNumber(event)' onblur='checkValidMarks(`mark1B_`, $k, `1`)' class='mark1B_{$k}' id='mark1B_{$k}' style='width:35px;text-align: center;{$border};' value='{$fmarks12}'>
                        <input type='text' oninput='getTotal($k)' onkeypress='return isNumber(event)' onblur='checkValidMarks(`mark1C_`, $k, `1`)' class='mark1C_{$k}' id='mark1C_{$k}' style='width:35px;text-align: center;{$border};' value='{$fmarks13}'>
                        <input type='text' oninput='getTotal($k)' onkeypress='return isNumber(event)' onblur='checkValidMarks(`mark1D_`, $k, `1`)' class='mark1D_{$k}' id='mark1D_{$k}' style='width:35px;text-align: center;{$border};' value='{$fmarks14}'>
                    </div>
                    </td>";
			$e_data.="<td class='tbl_row_new' align='center'  style='width:150px;border-right:1px solid #C5DBEC;  padding:2px;'>
                    <div style='display:flex; gap:1px; justify-content:space-between;'>
                        <input type='text' oninput='getTotal($k)' onkeypress='return isNumber(event)' onblur='checkValidMarks(`mark2A_`, $k, `2`)' class='mark2A_{$k}' id='mark2A_{$k}' style='width:35px;text-align: center;{$border};' value='{$fmarks21}'>
                        <input type='text' oninput='getTotal($k)' onkeypress='return isNumber(event)' onblur='checkValidMarks(`mark2B_`, $k, `2`)' class='mark2B_{$k}' id='mark2B_{$k}' style='width:35px;text-align: center;{$border};' value='{$fmarks22}'>
                        <input type='text' oninput='getTotal($k)' onkeypress='return isNumber(event)' onblur='checkValidMarks(`mark2C_`, $k, `2`)' class='mark2C_{$k}' id='mark2C_{$k}' style='width:35px;text-align: center;{$border};' value='{$fmarks23}'>
                        <input type='text' oninput='getTotal($k)' onkeypress='return isNumber(event)' onblur='checkValidMarks(`mark2D_`, $k, `2`)' class='mark2D_{$k}' id='mark2D_{$k}' style='width:35px;text-align: center;{$border};' value='{$fmarks24}'>
                    </div>
                    </td>";
            $e_data.="<td class='tbl_row_new' align='center'  style='width:150px;border-right:1px solid #C5DBEC;  padding:2px;'>
                    <div style='display:flex; gap:1px; justify-content:space-between;'>
                        <input type='text' oninput='getTotal($k)' onkeypress='return isNumber(event)' onblur='checkValidMarks(`mark3A_`, $k, `3`)' class='mark3A_{$k}' id='mark3A_{$k}' style='width:35px;text-align: center;{$border};' value='{$fmarks31}'>
                        <input type='text' oninput='getTotal($k)' onkeypress='return isNumber(event)' onblur='checkValidMarks(`mark3B_`, $k, `3`)' class='mark3B_{$k}' id='mark3B_{$k}' style='width:35px;text-align: center;{$border};' value='{$fmarks32}'>
                        <input type='text' oninput='getTotal($k)' onkeypress='return isNumber(event)' onblur='checkValidMarks(`mark3C_`, $k, `3`)' class='mark3C_{$k}' id='mark3C_{$k}' style='width:35px;text-align: center;{$border};' value='{$fmarks33}'>
                        <input type='text' oninput='getTotal($k)' onkeypress='return isNumber(event)' onblur='checkValidMarks(`mark3D_`, $k, `3`)' class='mark3D_{$k}' id='mark3D_{$k}' style='width:35px;text-align: center;{$border};' value='{$fmarks34}'>
                    </div>
                    </td>";
            $e_data.="<td class='tbl_row_new' align='center'  style='width:150px;border-right:1px solid #C5DBEC;  padding:2px;'>
                    <div style='display:flex; gap:1px; justify-content:space-between;'>
                        <input type='text' oninput='getTotal($k)' onkeypress='return isNumber(event)' onblur='checkValidMarks(`mark4A_`, $k, `4`)' class='mark4A_{$k}' id='mark4A_{$k}' style='width:35px;text-align: center;{$border};' value='{$fmarks41}'>
                        <input type='text' oninput='getTotal($k)' onkeypress='return isNumber(event)' onblur='checkValidMarks(`mark4B_`, $k, `4`)' class='mark4B_{$k}' id='mark4B_{$k}' style='width:35px;text-align: center;{$border};' value='{$fmarks42}'>
                        <input type='text' oninput='getTotal($k)' onkeypress='return isNumber(event)' onblur='checkValidMarks(`mark4C_`, $k, `4`)' class='mark4C_{$k}' id='mark4C_{$k}' style='width:35px;text-align: center;{$border};' value='{$fmarks43}'>
                        <input type='text' oninput='getTotal($k)' onkeypress='return isNumber(event)' onblur='checkValidMarks(`mark4D_`, $k, `4`, this)' class='mark4D_{$k}' id='mark4D_{$k}' style='width:35px;text-align: center;{$border};' value='{$fmarks44}'>
                    </div>
                    </td>";
           
			$k++;
		}	
        $arr['html'] = $e_data;
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
	
    }

    function saveIAEntryQuestionwise($aobj_context){
        session_start();
		include("error_log.php");
		$collcode=$_SESSION['collcode'];
		$User_code = $_SESSION['usr']; 
		$techcode = $aobj_context->mobj_data["techcode"];
		$classid = $aobj_context->mobj_data["classid"];
		$subcode = $aobj_context->mobj_data["subelement"];
        $testName = $aobj_context->mobj_data["testName"];
		$subarry = json_decode($aobj_context->mobj_data["subarry"], true);
        
        foreach($subarry as $value){
		    $qrySelect = "select * from marksint where fregno='{$value['fregno']}' 
                          and fsubcode='{$subcode}' and ftest='{$testName}'";
            $upd = $aobj_context->mobj_db->GetRow($qrySelect);
            if($value['absent'] == 'T'){
                $fmarks1A = '-2';
                $fmarks1B = '-2';
                $fmarks1C = '-2';
                $fmarks1D = '-2';
                $fmarks2A = '-2';
                $fmarks2B = '-2';
                $fmarks2C = '-2';
                $fmarks2D = '-2';
                $fmarks3A = '-2';
                $fmarks3B = '-2';
                $fmarks3C = '-2';
                $fmarks3D = '-2';
                $fmarks4A = '-2';
                $fmarks4B = '-2';
                $fmarks4C = '-2';
                $fmarks4D = '-2';
            }else{
                $fmarks1A = "{$value['marks1A']}";
                $fmarks1B = "{$value['marks1B']}";
                $fmarks1C = "{$value['marks1C']}";
                $fmarks1D = "{$value['marks1D']}";
                $fmarks2A = "{$value['marks2A']}";
                $fmarks2B = "{$value['marks2B']}";
                $fmarks2C = "{$value['marks2C']}";
                $fmarks2D = "{$value['marks2D']}";
                $fmarks3A = "{$value['marks3A']}";
                $fmarks3B = "{$value['marks3B']}";
                $fmarks3C = "{$value['marks3C']}";
                $fmarks3D = "{$value['marks3D']}";
                $fmarks4A = "{$value['marks4A']}";
                $fmarks4B = "{$value['marks4B']}";
                $fmarks4C = "{$value['marks4C']}";
                $fmarks4D = "{$value['marks4D']}";
            }
            
            if(count($upd) > 0){
                $queryUpd = "update marksint set 
                    FMARKS11='$fmarks1A', FMARKS12='$fmarks1B', FMARKS13='$fmarks1C', FMARKS14='$fmarks1D',
                    FMARKS21='$fmarks2A', FMARKS22='$fmarks2B', FMARKS23='$fmarks2C', FMARKS24='$fmarks2D',
                    FMARKS31='$fmarks3A', FMARKS32='$fmarks3B', FMARKS33='$fmarks3C', FMARKS34='$fmarks3D',
                    FMARKS41='$fmarks4A', FMARKS42='$fmarks4B', FMARKS43='$fmarks4C', FMARKS44='$fmarks4D', 
                    FTOTAL='{$value['total']}', FCREATEUSER='{$User_code}', FCREATEDATE=now()
                    where fregno = '{$value['fregno']}'
                    and fsubcode = '{$subcode}'
                    and fcollcode = '{$collcode}'";
            }else{

                $select = "select fdegree, fexamno from attendsum where fregno='{$value['fregno']}' 
                          and fclassid='{$classid}'";
                $res = $aobj_context->mobj_db->GetRow($select);

                 $queryUpd = "insert into marksint(FREGNO, fexamno, fsubcode,  fdegree, fcollcode, ftest, 
                            fmarks11, fmarks12, fmarks13, fmarks14, 
                            fmarks21, fmarks22, fmarks23, fmarks24, 
                            fmarks31, fmarks32, fmarks33, fmarks34, 
                            fmarks41, fmarks42, fmarks43, fmarks44, 
                            ftotal, FCREATEDATE, FCREATEUSER) 
                            values('{$value['fregno']}', '{$res['fexamno']}', '{$subcode}', '{$res['fdegree']}', '{$collcode}', '{$testName}', 
                            '$fmarks1A', '$fmarks1B', '$fmarks1C', '$fmarks1D', 
                            '$fmarks2A', '$fmarks2B', '$fmarks2C', '$fmarks2D', 
                            '$fmarks3A', '$fmarks3B', '$fmarks3C', '$fmarks3D', 
                            '$fmarks4A', '$fmarks4B', '$fmarks4C', '$fmarks4D', 
                            '{$value['total']}', now(), '{$User_code}')";         
            } 
            $upd = $aobj_context->mobj_db->Execute($queryUpd);
        }
        
        if($upd){
            $rdata = "Updated Successfully.";
            echo($aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success"));
            return $rdata;
        } else {
            $rdata = "No Updation / Add..!";
            echo($aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure"));  
            return $rdata;			
        }
    }


    function saveMarksDetailsEntry($aobj_context){
        $collcode=$_SESSION['collcode'];
		$user = $_SESSION['usr'];
        $classid = $aobj_context->mobj_data["classId"];
        $testName = $aobj_context->mobj_data["testName"];
        $data = json_decode($aobj_context->mobj_data["data"], true);

        foreach($data as $val){
             $query = "INSERT INTO maxmarksint (FCLASSID, FTESTNAME, FQNNO, FMARKS, FCO, FPO, FPSO, FCUSR, FCDATE, FDELETED)
                       VALUES('{$classid}', '{$testName}', '{$val['qnno']}', '{$val['marks']}', 
                       '{$val['co']}', '{$val['po']}', '{$val['pso']}', '{$user}', now(), 'F')
                       on duplicate key update 
                       FMARKS='{$val['marks']}', FCO='{$val['co']}', FPO='{$val['po']}', 
                       FPSO='{$val['pso']}', FCUSR='{$user}', FCDATE=now(), FDELETED='F'";
            $res = $aobj_context->mobj_db->Execute($query);
        }

        if($res){
            $msg = "Updated Successfully.";
            echo($aobj_context->mobj_output->ToJSONEnvelope($msg,0,"success"));
            return $msg;
        } else {
            $msg = "No Updation / Add..!";
            echo($aobj_context->mobj_output->ToJSONEnvelope($msg,-1,"Failure"));  
            return $msg;			
        }
    }

    function editQnMarksDetails($aobj_context){
        $testName = $aobj_context->mobj_data["testName"];
        $classid = $aobj_context->mobj_data["classid"];

        $queryView = "select FCLASSID, FTESTNAME, FQNNO,
                      ifnull(FMARKS, '') as FMARKS, ifnull(FCO, '')as FCO, ifnull(FPO, '')as FPO, 
                      ifnull(FPSO, '')as FPSO 
                      from maxmarksint 
                      where fclassid='{$classid}' and ftestname='{$testName}'";
        $resMarks = $aobj_context->mobj_db->GetAll($queryView);

        if(count($resMarks) == 0){
            $arr['msg'] = "Marks details not entered";
            echo($aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure"));  
            return;
        }else{
            echo($aobj_context->mobj_output->ToJSONEnvelope($resMarks, 0, "Success"));  
            return;
        }
    }

?>