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.223.159.143


Current Path : /proc/thread-self/root/var/www/html/collportal/src/
Upload File :
Current File : //proc/thread-self/root/var/www/html/collportal/src/marks_entry_qnWise.php

<?php
 function meViewIaStudDet($aobj_context){
    session_start();
    $collcode=$aobj_context->mobj_data['collcode'];
    $teachcode = $aobj_context->mobj_data["teachcode"];
    $classid = $aobj_context->mobj_data["classid"];
    $subject = $aobj_context->mobj_data["subelement"];
    $txtmarks = $aobj_context->mobj_data["txtmarks"];
    $testName = $aobj_context->mobj_data["testName"];
    $sort = $aobj_context->mobj_data["fsort"];
 
    $split = explode("*", $subject);
    $subelement = $split[0];
    $subdet = $split[1];
  

    $queryView = "SELECT * FROM maxmarksint 
                  WHERE fclassid='{$classid}' AND 
                  ftestname='{$testName}'
                  AND fsubcode = '{$subject}'";
           
    $resMarks=$aobj_context->mobj_db->GetAll($queryView);

    if(count($resMarks) == 0){
        $arr['msg'] = "Questionwise maximum marks and CO 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'];

    if($testName == "Test 1"){
        $dateCond = "DATE_FORMAT(fia1from,'%Y-%m-%d') 
                     and DATE_FORMAT(fia1to,'%Y-%m-%d')";
    }else if($testName == "Test 2"){
        $dateCond = "DATE_FORMAT(fia2from,'%Y-%m-%d') 
                     and DATE_FORMAT(fia2to,'%Y-%m-%d')";
    }else if($testName == "Test 3"){
        $dateCond = "DATE_FORMAT(fia3from,'%Y-%m-%d') 
                     and DATE_FORMAT(fia3to,'%Y-%m-%d')";
    }else if($testName == "Test 4"){
        $dateCond = "DATE_FORMAT(fia4from,'%Y-%m-%d') 
                     and DATE_FORMAT(fia4to,'%Y-%m-%d')";
    }
    
    $query = "select * from subdet 
    where fcollcode = '{$collcode}' and DATE_FORMAT(NOW(),'%Y-%m-%d') between 
    {$dateCond}
    and concat(fcsubcode,fsubcode) = '{$subelement}' 
    and fdegree='{$degree}'";

    
    $res3 = $aobj_context->mobj_db->GetAll($query);

    if(count($res3) == 0){
        $arr['msg'] = "Dates not enabled";
        echo($aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "Failure"));  
        return;
    }

    $query = "SELECT stu.FREGNO, stu.FNAME, sd.fexamno, sd.fdegree, stu.fcollcode,a.fdegree,sd.fmaxmarks,
              IFNULL(ftotal, '')AS ftotal, IFNULL(facttotal, '')AS facttotal,
              fu1max 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}' AND mak.fsubcode='{$subject}' 
              WHERE a.fteachcode = '{$teachcode}' AND a.fclassid = '{$classid}' 
              AND a.FCOLLCODE='{$collcode}' 
              AND CONCAT(sd.fcsubcode,sd.fsubcode) = '{$subject}'
              AND LEFT(a.fsubcode,4) = LEFT('{$subject}',4) GROUP BY fregno ORDER BY fname";

    $result=$aobj_context->mobj_db->GetAll($query);
    if($result){
        echo($aobj_context->mobj_output->ToJSONEnvelope($result,0,"success"));
    } else {
        $msg = "Something Wrong";
        echo($aobj_context->mobj_output->ToJSONEnvelope($msg,-1,"Failure"));  
        return $msg;			
    }
    
}

function meGetStudentMarksData($aobj_context){
   
    $testname = $aobj_context->mobj_data["test"];
    $subcode = $aobj_context->mobj_data["subcode"];
    $classid = $aobj_context->mobj_data["cls"];
    $degree = $aobj_context->mobj_data["degree"];
    $sem = $aobj_context->mobj_data["sem"];
    $regno = $aobj_context->mobj_data["regno"];
    $name = $aobj_context->mobj_data["name"];
    $collcode = $aobj_context->mobj_data["collcode"];
    $maxmarks = $aobj_context->mobj_data["maxmarks"];

  
    $query1 = "select t.* from tdvs_qptemphead t inner join subdet s on s.ftempcode = t.ftempcode where concat(fcsubcode, fsubcode) = '{$subcode}' and fdegree='{$degree}' and fexamno='{$sem}'";
    $result=$aobj_context->mobj_db->GetAll($query1);

    if(count($result) == 0){
        $arr['msg'] = "Template not found";
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
        return;
    }

    $query = "select ifnull(fclassid, '')as fclassid, ifnull(fclassid, '')as fclassid,
              ifnull(fclassid, '')as fclassid, ifnull(fqn, '')as fqn, 
              ifnull(fqnno, '')as fqnno, ifnull(fmarks, '')as fmarks, ifnull(fco, '')as fco 
              from maxmarksint where fclassid='{$classid}' and ftestname='{$testname}'
              and fsubcode='{$subcode}'
              order by lpad(fqnno, 3, 0)";

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

        $newQn = "";
        $count = 0;
        $i=0;
        $newArr = [];
    foreach($result as $val){
        $obj['fclassid'] = $classid;
        $obj['subcode'] = $subcode;
        $obj['test'] = $testname;
        $obj['fco'] = $val['fco'];
        $obj['fmarks'] = $val['fmarks'];
        $obj['fqn'] = $val['fqn'];
        $obj['fqnno'] = $val['fqnno'];

        if($val['fqn'] !== $newQn){
            $query1 = "select count(*)as count, fqn from 
                       maxmarksint where fclassid='{$classid}' and ftestname='{$testname}'
                       and fsubcode='{$subcode}' and fqn = '{$val['fqn']}'";
            $result1=$aobj_context->mobj_db->GetRow($query1);
            $count = $result1['count'];
           
        }
        $col = "fmarks".$val['fqnno'];
        $tot = "ftotal".$val['fqn'];
        $qry = "select ifnull($col, '-1')as $col, ifnull($tot, '')as $tot from marksint where fregno='{$regno}' and fsubcode ='{$subcode}' and ftest='{$testname}' and fdegree='{$degree}' and fexamno='{$sem}' ";
       
        $res = $aobj_context->mobj_db->GetRow($qry);
      
        $obj['marks'] = $res[$col] == "" ? '-1': $res[$col];
        $res[$col] = $res[$col] == "" ? '-1' : $res[$col];
        $res[$col] = $res[$col] == "-2" ? 'ab' : $res[$col];
             if($val['fqn'] !== $newQn){
                $totalMarks = $res[$tot] == "-1.0" ? "" : $res[$tot];
                
            }
            $newQn = $val['fqn']; 
            array_push($newArr, $obj);
            $i++;
      
    }
    if($result){
        $arr['regno']=$regno;
        $arr['count']=$count;
        $arr['name']=$name;
        $arr['qnno']= $val['fqnno'];
        $arr['maxmarks']=$maxmarks;
        $arr['degree']=$degree;
        $arr['sem']=$sem;
        $arr['marksArr'] = $newArr;
        
        echo($aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"));
    } else {
        $msg = "Something Wrong";
        echo($aobj_context->mobj_output->ToJSONEnvelope($msg,-1,"Failure"));  
        return $msg;			
    }
    
}

    function saveMeStudenMarks($aobj_context){
        $degree = $aobj_context->mobj_data["degree"];
        $sem = $aobj_context->mobj_data["sem"];
        $regno = $aobj_context->mobj_data["regno"];
        // $data = json_decode($aobj_context->mobj_data["data"], true);
        $data = json_decode(($aobj_context->mobj_data["data"]), true);
    
        $collcode = $aobj_context->mobj_data['collcode'];
        $test =  $aobj_context->mobj_data['test'];
        $subcode =  $aobj_context->mobj_data['subcode'];
      
        $columns = "";
        $totColumns = "";
        $tot = "";

        $marksColumn = "";
        $totMarksCol = "";//20
        $totMarks = 0;//10
        $totM = $data[0]['fqn'];
        $count = 1;
        $i=1;
        foreach($data as $val){
      
            if($i == count($data)){
                $cond = "";
            }else{
                $cond = ",";
            }

            $columns.='fmarks'.$val['fqnno'].$cond;
          
            $marksColumn.= $val['marks']=="ab" ? '-2'.$cond : $val['marks'].$cond;
           
            if($totM == $val['fqn']){
                $totMarks+=($val['marks']=="-1" || $val['marks']=="ab") ? 0:$val['marks'];
             
                if($i == count($data)){
                    $totMarksCol.=$totMarks.",";
                } 
              
                $count += 1;
             
            }else{
                $totMarksCol.=$totMarks.",";
                $totM = $val['fqn'];
                $totMarks = ($val['marks']=="-1" || $val['marks']=="ab") ? 0:$val['marks'];
                $count = 1;
            }
       
            if($tot !== 'ftotal'.$val['fqn']){
                $tot = 'ftotal'.$val['fqn'];
                $totColumns.='ftotal'.$val['fqn'].',';
            }
            
            $i++;
            
        }
       
        if($count == 1){
            $totMarksCol.=$totMarks.',';
        }
      
      
        $query1 = "delete from marksint where fregno='{$regno}' and fsubcode ='{$subcode}' and ftest='{$test}' and fdegree='{$degree}' and fexamno='{$sem}'";

        $result1 = $aobj_context->mobj_db->Execute($query1);
      
        $query = "insert into marksint(fdegree, fexamno, fcollcode, fregno, fsubcode, ftest, $totColumns $columns)
                values('{$degree}', '{$sem}', '{$collcode}', '{$regno}', '{$subcode}', '{$test}', $totMarksCol $marksColumn)";
               
        $result = $aobj_context->mobj_db->Execute($query);

        $query2 = "select t.* from tdvs_qptemphead t inner join subdet s on s.ftempcode = t.ftempcode
                  where concat(fcsubcode, fsubcode) = '{$subcode}' and fdegree='{$degree}' and fexamno='{$sem}';";
    
        $result2 = $aobj_context->mobj_db->GetAll($query2);

        $total = 0;
        foreach($result2 as $val){
            $limit = $val['fmandqn'];
            $explode = explode("*", $val['fqpcodes']);
            $totCol = "ftotal".$explode[0];
            
            $query3 = "select '' as qp, cast(ifnull($totCol, 0) as decimal(6,2)) as marks from marksint a where fregno = '{$regno}'
                      and fsubcode = '{$subcode}' and ftest = '{$test}'
                      and fdegree='{$degree}' and fexamno='{$sem}'";
                   
            
            for ($i=1; $i < count($explode); $i++) { 
                $col = "ftotal".$explode[$i];
                $query3.=" union select '{$i}' as qp,cast(ifnull($col, 0) as decimal(6,2)) as marks from marksint a where fregno = '{$regno}'
                          and fsubcode = '{$subcode}' and ftest = '{$test}'
                          and fdegree='{$degree}' and fexamno='{$sem}'";

            }

            $query3.=" order by marks desc limit $limit";
         
            $result3 = $aobj_context->mobj_db->GetAll($query3);
           
            for ($i=0; $i < count($result3); $i++) { 
                $tot = $result3[$i]['marks'] == "-1" ? 0 : floatval($result3[$i]['marks']);
                $total+=$tot;
               
            }
            
        }
      
        if($result){
            $sql = "update marksint set ftotal='{$total}', facttotal='{$total}' where 
                    fdegree='{$degree}' and fexamno='{$sem}' and fcollcode='{$collcode}' and 
                    fregno='{$regno}' and fsubcode='{$subcode}' and ftest='{$test}'";

            $res = $aobj_context->mobj_db->Execute($sql);
            $arr['msg'] = "Saved Successfully";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success"); 
        }else{
            $arr['msg'] = "failed to save";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure"); 
            return;
        }
    }

    function makeStudentIaAbsent($aobj_context){
        $degree = $aobj_context->mobj_data["fdegree"];
        $sem = $aobj_context->mobj_data["fexamno"];
        $regno = $aobj_context->mobj_data["regno"];
        $classid = $aobj_context->mobj_data["fclassid"];
        $subcode = $aobj_context->mobj_data["fsubcode"];
        $testname = $aobj_context->mobj_data["ftestname"];
        $collcode = $aobj_context->mobj_data['collcode'];

        $query1 = "delete from marksint where fregno='{$regno}' and fsubcode ='{$subcode}' and ftest='{$testname}' and fdegree='{$degree}' and fexamno='{$sem}'";
        $result1 = $aobj_context->mobj_db->Execute($query1);

        $query = "insert into marksint(fdegree, fexamno, fcollcode, fregno, fsubcode, ftest, ftotal, facttotal)
                values('{$degree}', '{$sem}', '{$collcode}', '{$regno}', '{$subcode}', '{$testname}', '-2', '-2')";
        $result = $aobj_context->mobj_db->Execute($query);

        if($result){
            $arr['msg'] = "Saved Successfully";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success"); 
        }else{
            $arr['msg'] = "failed to save";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure"); 
            return;
        }
    }

    function removeAbsentHandler($aobj_context){
        $degree = $aobj_context->mobj_data["fdegree"];
        $sem = $aobj_context->mobj_data["fexamno"];
        $regno = $aobj_context->mobj_data["regno"];
        $classid = $aobj_context->mobj_data["fclassid"];
        $subcode = $aobj_context->mobj_data["fsubcode"];
        $testname = $aobj_context->mobj_data["ftestname"];
        $collcode = $aobj_context->mobj_data['collcode'];

        $query1 = "delete from marksint where fregno='{$regno}' and fsubcode ='{$subcode}' and ftest='{$testname}' and fdegree='{$degree}' and fexamno='{$sem}'";
        $result1 = $aobj_context->mobj_db->Execute($query1);

        $query = "insert into marksint(fdegree, fexamno, fcollcode, fregno, fsubcode, ftest, ftotal, facttotal)
                values('{$degree}', '{$sem}', '{$collcode}', '{$regno}', '{$subcode}', '{$testname}', '-1', '-1')";
        $result = $aobj_context->mobj_db->Execute($query);

        if($result){
            $arr['msg'] = "Saved Successfully";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success"); 
        }else{
            $arr['msg'] = "failed to save";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure"); 
            return;
        }
    }



?>