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


Current Path : /var/www/oasis/src/
Upload File :
Current File : /var/www/oasis/src/updmarks.php

<?php

function saveUpdMarks($aobj_context){
    session_start();
    $univcode = $_SESSION['FUNIVCODE'];

    $degcode = $aobj_context->mobj_data["degcode"];
    $sem = $aobj_context->mobj_data["sem"];
    $semarry = explode(",",$sem);
    $semstr = "";
    foreach($semarry as $semval)
    {
        $semstr .="'".$semval."',"; 
    }
    $semfinal = rtrim($semstr, ",");


    if($univcode == '052')
    {
        $query = "select count(*) as cnt from subdet where fdegree = '{$degcode}'
        and fexamno in($semfinal) and fsubname = 'TEST 3'";
        $res = $aobj_context->mobj_db->GetRow($query);

        $query = "drop table bteach_ia1";
        $res1 =$aobj_context->mobj_db->Execute($query);

        if($res['cnt'] > 0)
        {   
            $query = "create table bteach_ia1
            select a.fdegree,left(a.fsubcode,5) as fsubcode,a.fexamno,a.fregno,
            if(a.ftest12 = 'T', ((a.test1+test2+makeup)-least(a.test1,test2,makeup)) ,((a.test1+test2+makeup+test3)-least(a.test1,test2,makeup,test3))) as finmarks,
            a.fmtype
            from (select m.fdegree,m.fexamno,s.fsubname,m.fsubcode,m.fregno,m.fmarks,s.fmtype,
            ifnull(s.ftest12,'F') as ftest12, 
            sum(if(s.fsubname = 'Test 1',if( ifnull(m.fmarks,'') ='-2.00',0,m.fmarks),0)) as test1,
            sum(if(s.fsubname = 'Test 2',if( ifnull(m.fmarks,'') ='-2.00',0,m.fmarks),0)) as test2,
            sum(if(s.fsubname = 'Test 3',if( ifnull(m.fmarks,'') ='-2.00',0,m.fmarks),0)) as test3,
            sum(if(s.fsubname = 'Makeup',if( ifnull(m.fmarks,'') ='-2.00',0,m.fmarks),0)) as makeup
            
            from marksint m 
            inner join subdet s on m.fdegree = s.fdegree 
            and m.fexamno = s.fexamno and m.fsubcode = concat(s.fcsubcode,s.fsubcode)
            where s.fsubname in('Test 1','Test 2','Test 3','Makeup')
            and m.fdegree = '{$degcode}'
            and m.fexamno in($semfinal)
            group by fregno,left(s.fcsubcode,4)
            order by fregno,left(s.fcsubcode,4)) a";
            $results =$aobj_context->mobj_db->Execute($query);

            $query = "drop table bteach_ia2";
            $res2 =$aobj_context->mobj_db->Execute($query);

            $query = "drop table bteach_ia2";
            $res3 =$aobj_context->mobj_db->Execute($query);

            $query = "create table bteach_ia2
            select m.fregno,m.fdegree,m.fexamno,m.fcollcode,left(m.fsubcode,5) as fsubcode,
            (if((sum(if(s.ftheory = 'F',if(fmarks = '-1',0,if(fmarks = '-2',0,fmarks)),0))) >0 and (sum(if(s.ftheory = 'T',if(fmarks = '-1',0,if(fmarks = '-2.00',0,fmarks)),0))) >0,((sum(if(s.ftheory = 'T',if(fmarks = '-1',0,if(fmarks = '-2.00',0,fmarks)),0)))+(sum(if(s.ftheory = 'F',if(fmarks = '-1',0,if(fmarks = '-2.00',0,fmarks)),0)))),sum(if(fmarks = '-1',0,if(fmarks = '-2.00',0,fmarks))))) as totmarks,
            s.fmtype 
            from marksint m inner join subdet s on concat(s.fcsubcode,s.fsubcode) = m.fsubcode and m.fdegree = s.fdegree 
            and m.fexamno = s.fexamno 
            inner join student st on st.fdegree = m.fdegree 
            and st.fcollcode = m.fcollcode 
            and m.fregno = st.fregno  
            where m.fregno between '0' and 'z' 
            and ifnull(st.fdeleted,'') <> 'T'  
            and m.fdegree = '{$degcode}'
            and m.fexamno in($semfinal)
            and s.fsubname in('Event 1','Event 2','EVENT')
            group by s.fdegree,m.fregno,left(m.fsubcode,5) 
            order by left(m.fsubcode,4)";
            $results =$aobj_context->mobj_db->Execute($query);
            
            $query = "drop table bteach_ia4";
            $res4 =$aobj_context->mobj_db->Execute($query);

            $query = "create table bteach_ia4
            select b.fregno,b.fdegree, b.fsubcode, b.fexamno, 
            CEILING((ifnull(b.totmarks,0)+ifnull(b1.finmarks,0))/2) as totmarks 
            from bteach_ia2 b 
            left join bteach_ia1 b1 on b.fdegree = b1.fdegree
            and b.fexamno = b1.fexamno and b.fsubcode = b1.fsubcode
            and b.fregno = b1.fregno
            where ifnull(b.fmtype,'') = ''";
            $results =$aobj_context->mobj_db->Execute($query);

            $query = "update marks m, bteach_ia4 b set m.fmarks = CEILING(b.totmarks), m.fpresent = 'P',
            FLOGDATE = now(), FLOGNAME = 'Direct'
            where m.fdegree = b.fdegree
            and m.fexamno = b.fexamno and m.fsubcode = b.fsubcode
            and m.fregno = b.fregno
            and m.fdegree = '{$degcode}'
            and m.fexamno in($semfinal)";
            $results =$aobj_context->mobj_db->Execute($query);
            

            $query = "drop table bteach_ia4";
            $res4 =$aobj_context->mobj_db->Execute($query);

            $query = "create table bteach_ia4
            select b.fregno,b.fdegree, b.fsubcode, b.fexamno, 
            CEILING((ifnull(b.totmarks,0)+ifnull(b1.finmarks,0))) as totmarks 
            from bteach_ia2 b 
            left join bteach_ia1 b1 on b.fdegree = b1.fdegree
            and b.fexamno = b1.fexamno and b.fsubcode = b1.fsubcode
            and b.fregno = b1.fregno
            where ifnull(b.fmtype,'') = 'D'";
            $results =$aobj_context->mobj_db->Execute($query);



            $query = "update marks m, bteach_ia4 b set m.fmarks = CEILING(b.totmarks), m.fpresent = 'P',
            FLOGDATE = now(), FLOGNAME = 'Direct'
            where m.fdegree = b.fdegree
            and m.fexamno = b.fexamno and m.fsubcode = b.fsubcode
            and m.fregno = b.fregno
            and m.fdegree = '{$degcode}'
            and m.fexamno in($semfinal)";
            $results =$aobj_context->mobj_db->Execute($query);

        }else
        {
            $query = "create table bteach_ia1
            select a.fdegree,left(a.fsubcode,5) as fsubcode,a.fexamno,a.fregno,
            ((a.test1+test2+makeup)-least(a.test1,test2,makeup)) as finmarks,a.fmtype
            from (select m.fdegree,m.fexamno,s.fsubname,m.fsubcode,m.fregno,m.fmarks,s.fmtype, 
            sum(if(s.fsubname = 'Test 1',if( ifnull(m.fmarks,'') ='-2.00',0,m.fmarks),0)) as test1,
            sum(if(s.fsubname = 'Test 2',if( ifnull(m.fmarks,'') ='-2.00',0,m.fmarks),0)) as test2,
            sum(if(s.fsubname = 'Makeup',if( ifnull(m.fmarks,'') ='-2.00',0,m.fmarks),0)) as makeup
            from marksint m 
            inner join subdet s on m.fdegree = s.fdegree 
            and m.fexamno = s.fexamno and m.fsubcode = concat(s.fcsubcode,s.fsubcode)
            where s.fsubname in('Test 1','Test 2','Makeup')
            and m.fdegree = '{$degcode}'
            and m.fexamno in($semfinal)
            group by fregno,left(s.fcsubcode,4)
            order by fregno,left(s.fcsubcode,4)) a";
            $results =$aobj_context->mobj_db->Execute($query);

            $query = "drop table bteach_ia2";
            $res3 =$aobj_context->mobj_db->Execute($query);

            $query = "create table bteach_ia2
            select m.fregno,m.fdegree,m.fexamno,m.fcollcode,left(m.fsubcode,5) as fsubcode,
            (if((sum(if(s.ftheory = 'F',if(fmarks = '-1',0,if(fmarks = '-2',0,fmarks)),0))) >0 and (sum(if(s.ftheory = 'T',if(fmarks = '-1',0,if(fmarks = '-2.00',0,fmarks)),0))) >0,((sum(if(s.ftheory = 'T',if(fmarks = '-1',0,if(fmarks = '-2.00',0,fmarks)),0)))+(sum(if(s.ftheory = 'F',if(fmarks = '-1',0,if(fmarks = '-2.00',0,fmarks)),0)))),sum(if(fmarks = '-1',0,if(fmarks = '-2.00',0,fmarks))))) as totmarks,
            s.fmtype 
            from marksint m inner join subdet s on concat(s.fcsubcode,s.fsubcode) = m.fsubcode and m.fdegree = s.fdegree 
            and m.fexamno = s.fexamno 
            inner join student st on st.fdegree = m.fdegree 
            and st.fcollcode = m.fcollcode 
            and m.fregno = st.fregno  
            where m.fregno between '0' and 'z' 
            and ifnull(st.fdeleted,'') <> 'T'  
            and m.fdegree = '{$degcode}'
            and m.fexamno in($semfinal)
            and s.fsubname in('EVENT')
            group by s.fdegree,m.fregno,left(m.fsubcode,5) 
            order by left(m.fsubcode,4)";
            $results =$aobj_context->mobj_db->Execute($query);

            $query = "drop table bteach_ia4";
            $res4 =$aobj_context->mobj_db->Execute($query);

            $query = "create table bteach_ia4
            select b.fregno,b.fdegree, b.fsubcode, b.fexamno, CEILING((ifnull(b.totmarks,0)+ifnull(b1.finmarks,0))/2) as totmarks 
            from bteach_ia2 b 
            left join bteach_ia1 b1 on b.fdegree = b1.fdegree
            and b.fexamno = b1.fexamno and b.fsubcode = b1.fsubcode
            and b.fregno = b1.fregno
            where ifnull(b.fmtype,'') = ''";
            $results =$aobj_context->mobj_db->Execute($query);

            $query = "update marks m, bteach_ia4 b set m.fmarks = CEILING(b.totmarks), m.fpresent = 'P',
            FLOGDATE = now(), FLOGNAME = 'Direct'
            where m.fdegree = b.fdegree
            and m.fexamno = b.fexamno and m.fsubcode = b.fsubcode
            and m.fregno = b.fregno
            and m.fdegree = '{$degcode}'
            and m.fexamno in($semfinal)";
            $results =$aobj_context->mobj_db->Execute($query);


            $query = "drop table bteach_ia4";
            $res4 =$aobj_context->mobj_db->Execute($query);

            $query = "create table bteach_ia4
            select b.fregno,b.fdegree, b.fsubcode, b.fexamno, CEILING((ifnull(b.totmarks,0)+ifnull(b1.finmarks,0))) as totmarks 
            from bteach_ia2 b 
            left join bteach_ia1 b1 on b.fdegree = b1.fdegree
            and b.fexamno = b1.fexamno and b.fsubcode = b1.fsubcode
            and b.fregno = b1.fregno
            where ifnull(b.fmtype,'') = 'D'";
            $results =$aobj_context->mobj_db->Execute($query);

            $query = "update marks m, bteach_ia4 b set m.fmarks = CEILING(b.totmarks), m.fpresent = 'P',
            FLOGDATE = now(), FLOGNAME = 'Direct'
            where m.fdegree = b.fdegree
            and m.fexamno = b.fexamno and m.fsubcode = b.fsubcode
            and m.fregno = b.fregno
            and m.fdegree = '{$degcode}'
            and m.fexamno in($semfinal)";
            $results =$aobj_context->mobj_db->Execute($query);

        }

        $query = "drop table bteach_ia3";
        $res4 =$aobj_context->mobj_db->Execute($query);

        $query = "create table bteach_ia3
        select m.fregno,m.fdegree,m.fexamno,m.fcollcode,left(m.fsubcode,5) as fsubcode,
        (if((sum(if(s.ftheory = 'F',if(fmarks = '-1',0,if(fmarks = '-2',0,fmarks)),0))) >0 and (sum(if(s.ftheory = 'T',if(fmarks = '-1',0,if(fmarks = '-2.00',0,fmarks)),0))) >0,((sum(if(s.ftheory = 'T',if(fmarks = '-1',0,if(fmarks = '-2.00',0,fmarks)),0)))+(sum(if(s.ftheory = 'F',if(fmarks = '-1',0,if(fmarks = '-2.00',0,fmarks)),0)))),sum(if(fmarks = '-1',0,if(fmarks = '-2.00',0,fmarks))))) as totmarks 
        from marksint m inner join subdet s on concat(s.fcsubcode,s.fsubcode) = m.fsubcode 
        and m.fdegree = s.fdegree and m.fexamno = s.fexamno 
        inner join student st on st.fdegree = m.fdegree 
        and st.fcollcode = m.fcollcode and m.fregno = st.fregno 
        where m.fregno between '0' and 'z' and ifnull(st.fdeleted,'') <> 'T'  
        and m.fdegree like '{$degcode}'
        and m.fexamno in($semfinal)
        and s.fsubname in('Assessment','Assessement','LAB 1','PCE','PRACTICAL','PRACTICALS','CIE')
        group by s.fdegree,m.fregno,left(m.fsubcode,5) 
        order by left(m.fsubcode,4)";
        $results =$aobj_context->mobj_db->Execute($query);

        $query = "update marks m, bteach_ia3 b set m.fmarks = CEILING(b.totmarks), m.fpresent = 'P',
        FLOGDATE = now(), FLOGNAME = 'Direct'
        where m.fdegree = b.fdegree
        and m.fexamno = b.fexamno and m.fsubcode = b.fsubcode
        and m.fregno = b.fregno
        and m.fdegree like '{$degcode}'
        and m.fexamno in($semfinal)";
        $results =$aobj_context->mobj_db->Execute($query);

    } if($univcode == '056')
    {
        $query = "drop table bteach_ia3";
        $res4 =$aobj_context->mobj_db->Execute($query);

        $query = "create table bteach_ia3
        select m.fregno,m.fdegree,m.fexamno,m.fcollcode,left(m.fsubcode,5) as fsubcode,
        sum(if(ifnull(fmarks,'-1') = '-1',0,if(ifnull(fmarks,'-1') = '-2.00',0,fmarks))) as totmarks 
        from marksint m inner join subdet s on concat(s.fcsubcode,s.fsubcode) = m.fsubcode 
        and m.fdegree = s.fdegree and m.fexamno = s.fexamno 
        inner join student st on st.fdegree = m.fdegree 
        and st.fcollcode = m.fcollcode and m.fregno = st.fregno 
        where m.fregno between '0' and 'z' and ifnull(st.fdeleted,'') <> 'T'  
        and m.fdegree like '{$degcode}'
        and m.fexamno in($semfinal)
        group by s.fdegree,m.fregno,left(m.fsubcode,5) 
        order by left(m.fsubcode,4)";
        $results =$aobj_context->mobj_db->Execute($query);

        $query = "update marks m, bteach_ia3 b set m.fmarks = CEILING(b.totmarks), m.fpresent = 'P',
        FLOGDATE = now(), FLOGNAME = 'Direct'
        where m.fdegree = b.fdegree
        and m.fexamno = b.fexamno and m.fsubcode = b.fsubcode
        and m.fregno = b.fregno
        and m.fdegree like '{$degcode}'
        and m.fexamno in($semfinal)";
        $results =$aobj_context->mobj_db->Execute($query);


    }
    else if($univcode == '049')
    {

        $query = "delete from bteach_ia1 where fdegree = '{$degcode}' and fexamno = '{$sem}'";
        $res1 =$aobj_context->mobj_db->Execute($query);


        $query = "select fdegree,fexamno,fcsubcode,concat(fcsubcode,fsubcode) as fsubcode,fformula 
        from subdet where fdegree = '{$degcode}' and fexamno = '{$sem}'";
        $results =$aobj_context->mobj_db->getAll($query);

        foreach($results as $val)
        {
            $fsubcode = $val['fsubcode'];
            $fcsubcode = $val['fcsubcode'];
            $fformula = $val['fformula'];

            $query = "insert into bteach_ia1 (fdegree,fexamno,fregno,fsubcode,fcsubcode,fmarks,fupddate,fsubtype,ftheory)
                select m.fdegree,m.fexamno,m.fregno,'{$fcsubcode}' as subcodem,m.fsubcode,
                $fformula as fmarks,
                now(),ifnull(sd.fprsub,'F'),sd.ftheory
                from marksint m inner join subdet sd on m.fdegree = sd.fdegree
                and m.fexamno = sd.fexamno and m.fsubcode = concat(sd.fcsubcode,sd.fsubcode)
                where m.fsubcode = '{$fsubcode}'
                and m.fdegree = '{$degcode}'
                and m.fexamno = '{$sem}'
                group by m.fdegree,m.fsubcode,m.fregno";
               
            $results =$aobj_context->mobj_db->Execute($query);
        }    

        $query = "update marks m, (select fdegree,fexamno,fregno,fsubcode,

        CEILING(if(fsubtype = 'T',((sum(if(fsubtype = 'T' && ftheory = 'F',if(ifnull(fmarks,'0')<0,0,fmarks),0))*.4)+(sum(if(fsubtype = 'T' && ftheory = 'T',if(ifnull(fmarks,'0')<0,0,fmarks),0))*.6)),CEILING(sum(if(ifnull(fmarks,'0')<0,0,fmarks))))) as fmarks,
        (sum(if(fsubtype = 'T' && ftheory = 'F',if(ifnull(fmarks,'0')<0,0,fmarks),0))*.4) as prmarks,
        (sum(if(fsubtype = 'T' && ftheory = 'T',if(ifnull(fmarks,'0')<0,0,fmarks),0))*.6) as thmarks
                from bteach_ia1
                where fdegree like '{$degcode}'
                and fexamno = '{$sem}'
                group by fdegree,fexamno,fregno,fsubcode) i set m.fmarks = i.fmarks,
        m.flogdate = now(),m.fthia = i.thmarks, m.factia = i.prmarks
        where m.fregno = i.fregno 
        and m.fexamno = i.fexamno
        and m.fsubcode = i.fsubcode";
        $results =$aobj_context->mobj_db->Execute($query);

    }else if($univcode == '055')
    {
        $query = "delete from bteach_ia1 where fdegree = '{$degcode}' and fexamno = '{$sem}'";
        $res1 =$aobj_context->mobj_db->Execute($query);


        $query = "select fdegree,fexamno,fcsubcode,concat(fcsubcode,fsubcode) as fsubcode,fformula 
        from subdet where fdegree = '{$degcode}' and fexamno = '{$sem}'";
        $results =$aobj_context->mobj_db->getAll($query);

        foreach($results as $val)
        {
            $fsubcode = $val['fsubcode'];
            $fcsubcode = $val['fcsubcode'];
            $fformula = $val['fformula'];

            $query = "insert into bteach_ia1 (fdegree,fexamno,fregno,fsubcode,fcsubcode,fmarks,fupddate,fsubtype,ftheory)
                select m.fdegree,m.fexamno,m.fregno,'{$fcsubcode}' as subcodem,m.fsubcode,
                $fformula as fmarks,
                now(),sd.fmtype,sd.ftheory
                from marksint m inner join subdet sd on m.fdegree = sd.fdegree
                and m.fexamno = sd.fexamno and m.fsubcode = concat(sd.fcsubcode,sd.fsubcode)
                where m.fsubcode = '{$fsubcode}'
                and m.fdegree = '{$degcode}'
                and m.fexamno = '{$sem}'
                and ifnull(m.FTEST,'') <> ''
                group by m.fdegree,m.fsubcode,m.fregno";
            $results =$aobj_context->mobj_db->Execute($query);
        }    

        $query = "update marks m, (select fdegree,fexamno,fregno,fsubcode,if(fsubtype = 'P',CEILING(
            ((sum(if(fsubtype = 'P' && ftheory = 'F',if(ifnull(fmarks,'0')<0,0,fmarks),0))/sum(if(ftheory = 'F',1,0)))+sum(if(fsubtype = 'P' && ftheory = 'T',if(ifnull(fmarks,'0')<0,0,fmarks),0))
            )/2),CEILING(sum(if(ifnull(fmarks,'0')<0,0,fmarks))/2)) as fmarks,
                (sum(if(fsubtype = 'P' && ftheory = 'F',if(ifnull(fmarks,'0')<0,0,fmarks),0))/sum(if(ftheory = 'F',1,0))) as prmarks,
                sum(if(fsubtype = 'P' && ftheory = 'T',if(ifnull(fmarks,'0')<0,0,fmarks),0)) as thmarks
        from bteach_ia1
        where fdegree like '{$degcode}'
        and fexamno = '{$sem}'
        group by fdegree,fexamno,fregno,fsubcode) i set m.fmarks = i.fmarks,
        m.flogdate = now(),m.fthia = i.thmarks, m.factia = i.prmarks
        where m.fregno = i.fregno 
        and m.fexamno = i.fexamno
        and m.fsubcode = i.fsubcode";
        $results =$aobj_context->mobj_db->Execute($query);

        // $query = "INSERT ignore INTO bteach_ia1 (fdegree, fexamno, fregno, fcsubcode, fclassid, fmarks,fupddate)
        // select m.fdegree,m.fexamno,m.fregno,su.fcsubcode,
        // '' as fclassid,
        // CEILING(sum(if(ifnull(facttotal,'0') = '-2.0','0',ifnull(facttotal,'0')))/fnotest) as fmarks,
        // now()
        // from marksint m inner join (select fdegree,fexamno,fcollcode,fcsubcode,sum(fnotest) as fnotest 
        // from subdet where fmtype = 'A' group by fdegree,fexamno,fcollcode,fcsubcode) su on m.fdegree = su.fdegree
        // and m.fexamno = su.fexamno 
        // and left(m.FSUBCODE,5) = su.fcsubcode
        // and m.fdegree = '{$degcode}'
        // group by m.fdegree,su.fcsubcode,m.fregno";
        // $results =$aobj_context->mobj_db->Execute($query);

        // $query = "update marks m, bteach_ia1 b set m.fmarks = b.fmarks, m.fpresent = 'P',
        // FLOGDATE = now(), FLOGNAME = 'Direct'
        // where m.fdegree = b.fdegree
        // and m.fexamno = b.fexamno and m.fsubcode = b.fcsubcode
        // and m.fregno = b.fregno
        // and m.fdegree like '{$degcode}'";
        // $results =$aobj_context->mobj_db->Execute($query);

        // $query = "delete from bteach_ia2 where fdegree = '{$degcode}'";
        // $res1 =$aobj_context->mobj_db->Execute($query);

        // $query = "INSERT ignore INTO bteach_ia2 (fdegree, fexamno, fregno, fcsubcode, fsubname, fclassid, fmarks,fupddate)
        // select m.fdegree,m.fexamno,m.fregno,su.fcsubcode,su.fsubname,
        // '' as fclassid,
        // CEILING(sum(if(su.fsubname = 'CIE-LAB-Test',(if(ifnull(facttotal,'0') = '-2.0','0',ifnull(facttotal,'0'))/4),0))
        // +
        // sum(if(su.fsubname = 'CIE-Lab-Assignment',(if(ifnull(facttotal,'0') = '-2.0','0',ifnull(facttotal,'0'))),0))) as fmarks,
        // now()
        // from marksint m inner join  subdet su on m.fdegree = su.fdegree
        // and m.fexamno = su.fexamno 
        // and left(m.FSUBCODE,6) = concat(su.fcsubcode,su.fsubcode)
        // where su.fmtype = 'F'
        // and m.fdegree = '{$degcode}'
        // group by m.fdegree,su.fcsubcode,m.fregno";
        // $results =$aobj_context->mobj_db->Execute($query);

        // $query = "update marks m, bteach_ia2 b set m.fmarks = b.fmarks, m.fpresent = 'P',
        // FLOGDATE = now(), FLOGNAME = 'Direct'
        // where m.fdegree = b.fdegree
        // and m.fexamno = b.fexamno and m.fsubcode = b.fcsubcode
        // and b.fdegree = '{$degcode}'
        // and m.fregno = b.fregno";
        // $results =$aobj_context->mobj_db->Execute($query);

        // $query = "delete from bteach_ia3 where fdegree = '{$degcode}'";
        // $res1 =$aobj_context->mobj_db->Execute($query);
        
        // $query = "INSERT ignore INTO bteach_ia3 (fdegree, fexamno, fregno, fcsubcode, fsubname, fclassid, fthia, factia, fmarks,fupddate)
        // select m.fdegree,m.fexamno,m.fregno,su.fcsubcode,su.fsubname,
        // '{$classid}' as fclassid,
        // ROUND((sum(if(su.fsubname = 'CIE',(if(ifnull(facttotal,'0') = '-2.0','0',ifnull(facttotal,'0'))),0))/3),2) as fthia,
        // ROUND(sum(if(su.fsubname = 'CIE-Activity 1',(if(ifnull(facttotal,'0') = '-2.0','0',ifnull(facttotal,'0'))),0)),2) as factia,
        // CEILING(((sum(if(su.fsubname = 'CIE',(if(ifnull(facttotal,'0') = '-2.0','0',if(ifnull(facttotal,'0') = '-2.0','0',ifnull(facttotal,'0')))),0))/3) + sum(if(su.fsubname = 'CIE-Activity 1',(if(ifnull(facttotal,'0') = '-2.0','0',ifnull(facttotal,'0'))),0)))/2) as fmarks,
        // now()
        // from marksint m inner join subdet su on m.fdegree = su.fdegree
        // and m.fexamno = su.fexamno 
        // and left(m.FSUBCODE,6) = concat(su.fcsubcode,su.fsubcode)
        // where fmtype = 'D'
        // and m.fdegree = '{$degcode}'
        // group by m.fdegree,su.fcsubcode,m.fregno";
        // $results =$aobj_context->mobj_db->Execute($query);

        // $query = "update marks m, bteach_ia3 b set m.fmarks = b.fmarks, m.fpresent = 'P',
        // FLOGDATE = now(), FLOGNAME = 'Direct', m.fthia = b.fthia,
        // m.factia = b.factia
        // where m.fdegree = b.fdegree
        // and m.fexamno = b.fexamno and m.fsubcode = b.fcsubcode
        // and b.fdegree = '{$degcode}'
        // and m.fregno = b.fregno";
        // $results =$aobj_context->mobj_db->Execute($query);

    }

if($results){
        $data['msg'] = 'Updated Succsufly';
		echo $aobj_context->mobj_output->ToJSONEnvelope($data,0,"success"); 
        return;
	}
	else{
		$data['msg'] = 'Failed to Update';
		echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure"); 
        return;
	}

}

?>