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.144.6.9
<?php
function getTdvsValType($aobj_context){
$univcode = $aobj_context->mobj_data["univcode"];
$qpcode = $aobj_context->mobj_data["qpcode"];
$query = "select ifnull(d.fverval, 'F')as fverval from tdvs_deggrp d inner join tdvs_masqp m on
m.fdeggrp = d.fdeggrp where m.fqpcode='{$qpcode}'";
// var_dump($query);die();
$result = $aobj_context->pobj_db->GetRow($query);
if($result){
echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
}else{
$arr['msg'] = 'No data found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function getEvaluationImages($aobj_context){
// require 'phpseclib3/phpseclib/Net/SFTP.php';
// require 'phpseclib3/phpseclib/Crypt/DSA.php';
// require 'phpseclib3/phpseclib/Crypt/EC.php';
// require 'phpseclib3/phpseclib/Crypt/RSA.php';
// require 'phpseclib3/phpseclib/Crypt/Common/AsymmetricKey.php';
// require 'phpseclib3/phpseclib/Crypt/Common/PrivateKey.php';
// require 'phpseclib3/phpseclib/Crypt/Common/PublicKey.php';
// use phpseclib3\phpseclib\Net\SFTP;
// // use phpseclib3\phpseclib\Crypt\PublicKeyLoader;
// // require '../vendor/phpseclib3/phpseclib/Crypt/PublicKeyLoader.php';
// $host = '65.2.72.238'; // Replace with your server's IP address
// $username = 'ubuntu'; // Replace with the correct username
// $keyfile = 'static/lightsail.pem'; // Replace with the path to your keyfile
// $key = PublicKeyLoader::loadPrivateKey(file_get_contents($keyfile));
// $sftp = new SFTP($host);
// if (!$sftp->login($username, $key)) {
// exit('Login Failed');
// }
// var_dump('hsgjhsd');die();
$univcode = $aobj_context->mobj_data["univcode"];
$qpcode = $aobj_context->mobj_data["qpcode"];
$regcode = $aobj_context->mobj_data["regcode"];
$valno = $aobj_context->mobj_data["valno"];
$query1 = "select ifnull(fregcode, '')as fregcode from tdvs_tabsum where
fqpcode='{$qpcode}' and fdummyno='{$regcode}'";
$result1 = $aobj_context->pobj_db->GetRow($query1);
$regCodeno = $result1['fregcode'];
$query2 = "select ifnull(ffilepath, '')as ffilepath,
ifnull(fregcode, '')as fregcode , fyear, fexamtype
from tdvs_tabhead
where ifnull(fregcode,'') = '{$regCodeno}' and fqpcode='{$qpcode}'";
$result2 = $aobj_context->pobj_db->GetRow($query2);
// $folder = 'https://app.universitysolutions.in/eval-img/'.$result2['ffilepath'];
if($result2){
echo $aobj_context->mobj_output->ToJSONEnvelope($result2, 0, "success");
}else{
$arr['msg'] = 'No data found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function getAnsBookImagesTrans($aobj_context){
$univcode = $aobj_context->mobj_data["univcode"];
$qpcode = $aobj_context->mobj_data["qpcode"];
$regcode = $aobj_context->mobj_data["regcode"];
$valno = $aobj_context->mobj_data["valno"];
$yearmode = $aobj_context->mobj_data["yearmode"];
$split = explode("*", $yearmode);
$year = $split[0];
$examtype = $split[1];
$query = "select ifnull(FFILFRMSER, 'F')as FFILFRMSER from tdvs_tabhead where
fqpcode='{$qpcode}' and fregcode='{$regcode}'
and fyear='{$year}' and fexamtype='{$examtype}'";
// var_dump($query);die();
$result = $aobj_context->pobj_db->GetRow($query);
if($result){
echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
}else{
$arr['msg'] = 'Something went wrong try again later!!';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function saveEvalReject($aobj_context){
$univcode = $aobj_context->mobj_data["univcode"];
$qpcode = $aobj_context->mobj_data["qpcode"];
$dummyno = $aobj_context->mobj_data["dummyno"];
$valno = $aobj_context->mobj_data["valno"];
$reason = $aobj_context->mobj_data["rejReason"];
$comment = $aobj_context->mobj_data["rejComment"];
$query = "select fbatchno, fteachcode, fcollcode from tdvs_tabsum where
fqpcode = '{$qpcode}' and fdummyno = '{$dummyno}'";
$res = $aobj_context->pobj_db->GetRow($query);
if($res){
$batchno = $res['fbatchno'];
$teachcode = $res['fteachcode'];
$collcode = $res['fcollcode'];
$query1 = "update tdvs_tabsum set fstatus = 'REJECTED', frejreason = '{$reason}',
frejremarks = '{$comment} - batchno - {$batchno} - rejected by - {$teachcode}', fteachcode = NULL, fbatchno = NULL
where fqpcode = '{$qpcode}' and fdummyno = '{$dummyno}'
and fvalno = '{$valno}'";
$res1 = $aobj_context->pobj_db->Execute($query1);
if($res1){
$query2 = "update tdvs_tabpkt set FNOSCRIPT = (FNOSCRIPT - 1)
where FBATCHNO = '{$batchno}' and fqpcode = '{$qpcode}'";
$res2 = $aobj_context->pobj_db->Execute($query2);
if($res2){
$arr['msg'] = "Updated successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
}else{
$arr['msg'] = "Error while rejecting scripts";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}else{
$arr['msg'] = "Error while rejecting scripts";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}else{
$arr['msg'] = "Something went wrong";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function getEvalMarksStatus($aobj_context){
$univcode = $aobj_context->mobj_data["univcode"];
$qpcode = $aobj_context->mobj_data["qpcode"];
$dummyno = $aobj_context->mobj_data["dummyno"];
$valno = $aobj_context->mobj_data["valno"];
$query = "select fregcode, fdummyno from tdvs_tabsum where fdummyno = '{$dummyno}'";
$res = $aobj_context->pobj_db->GetRow($query);
$regcode = $res['fregcode'];
$m_field = "";
if ($valno == "1") {
$m_field = "fmarks11";
} else if ($valno == "2") {
$m_field = "fmarks21";
} else if ($valno == "3") {
$m_field = "fmarks31";
} else if ($valno == "4") {
$m_field = "fmarks41";
} else if ($valno == "5") {
$m_field = "fmarks51";
} else if ($valno == "R") {
$m_field = "fmarksr1";
} else if ($valno == "D") {
$m_field = "fmarksd1";
} else if ($valno == "W") {
$m_field = "fmarksv1";
}
if ($m_field == "") {
$arr['msg'] = "Invalid valuation number";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
$s_field = "";
if ($valno == "1") {
$s_field = "fmarks12";
} else if ($valno == "2") {
$s_field = "fmarks22";
} else if ($valno == "3") {
$s_field = "fmarks32";
} else if ($valno == "4") {
$s_field = "fmarks42";
} else if ($valno == "5") {
$s_field = "fmarks52";
} else if ($valno == "R") {
$s_field = "fmarksr2";
} else if ($valno == "D") {
$s_field = "fmarksd2";
} else if ($valno == "W") {
$s_field = "fmarksv2";
}
$query1 = "select a.fqpcode, m.fsubname, c.ftempname, b.fpartcode, c.fpartdesc,
'{$dummyno}' as fregcode, b.fqncode, b.fqnparent,
b.fsubqp as fsubqn, b.fqnno, ifnull(a.{$m_field},'') as fmarks11, ifnull(a.{$s_field},'')as fmarks12, b.fmaxmarks,
c.fmaxmarks as fpartmaxmarks, c.ftempmax
from tdvs_tabdetl a inner join tdvs_masqp m on a.fqpcode = m.fqpcode
inner join tdvs_qptempdetl b
on m.ftempcode = b.ftempcode and a.fqnno = b.fqncode
inner join tdvs_qptemphead c on b.ftempcode = c.ftempcode
and b.fpartcode = c.fpartcode
where fregcode = '{$regcode}' and a.fqpcode = '{$qpcode}'";
$res1 = $aobj_context->pobj_db->GetAll($query1);
if(count($res1) > 0){
$query2 = "select a.fqpcode, m.fsubname, c.ftempname, b.fpartcode, c.fpartdesc,
sum(if(ifnull(a.{$m_field},0) < 0, 0, a.{$m_field})) as fmarks11,
sum(if(ifnull(a.{$s_field},0) < 0, 0, a.{$s_field})) as fmarks12,
c.fmaxmarks, c.ftempmax, c.fmaxqn, c.fmandqn
from tdvs_tabdetl a inner join tdvs_masqp m
on a.fqpcode = m.fqpcode inner join
tdvs_qptempdetl b on m.ftempcode = b.ftempcode and a.fqnno = b.fqncode
inner join tdvs_qptemphead c on b.ftempcode = c.ftempcode and b.fpartcode = c.fpartcode
where fregcode = '{$regcode}' and a.fqpcode = '{$qpcode}'
and b.fqncode = b.fqnparent
group by c.ftempname, b.fpartcode";
$res2 = $aobj_context->pobj_db->GetAll($query2);
$sum = [];
if ($valno == "W") {
$ftotmarks = "ftotmarksv";
$fsysmarks = "fsysmarksv";
$query3 = "select b.fteachcode, b.fteachname, a.fqpcode, a.fdummyno as fregcode,
ifnull({$ftotmarks},0) as ftotmarks,
ifnull({$fsysmarks},0) as fsysmarks
from tdvs_tabsum a inner join tdvs_masteach b
on a.frevcode = b.fteachcode
where a.fqpcode = '{$qpcode}' and a.fregcode = '{$regcode}'
and a.fvalno = '1'";
$res3 = $aobj_context->pobj_db->GetAll($query3);
$sum = $res3;
}else{
$ftotmarks = "ftotmarks";
$fsysmarks = "fsysmarks";
$query3 = "select b.fteachcode, b.fteachname, a.fqpcode, a.fdummyno as fregcode, ifnull({$ftotmarks},0) as ftotmarks,
ifnull({$fsysmarks},0) as fsysmarks
from tdvs_tabsum a inner join tdvs_masteach b
on a.fteachcode = b.fteachcode
where a.fqpcode = '{$qpcode}'
and a.fregcode = '{$regcode}'
and a.fvalno = '{$valno}'";
// if($qpcode == 'BTC503A')
// var_dump($query3);
$res3 = $aobj_context->pobj_db->GetAll($query3);
$sum = $res3;
}
$arr['sdata'] = $res1;
$arr['pdata'] = $res2;
$arr['sum'] = $sum;
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
return;
}else {
$arr['msg'] = "Data not found";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function finalEvalMarks($aobj_context){
$univcode = $aobj_context->mobj_data["univcode"];
$qpcode = $aobj_context->mobj_data["qpcode"];
$dummyno = $aobj_context->mobj_data["dummyno"];
$valno = $aobj_context->mobj_data["valno"];
$fteachcode = $aobj_context->mobj_data["fteachcode"];
$remarks = $aobj_context->mobj_data["remarks"];
$query = "select m.fqpcode, ifnull(m.fnoval, '1') as fnoval,
d.fdeggrp, d.FSCNDVALCND1, d.FSCNDVALCND2,
ifnull(d.FDEVSTATUS,'F') as FDEVSTATUS,
ifnull(d.FDEVIATION,'') as FDEVIATION,
ifnull(fhours,3) as fhours
from tdvs_masqp m
inner join tdvs_deggrp d on m.fdeggrp = d.fdeggrp
where m.fqpcode = '{$qpcode}'";
$res = $aobj_context->pobj_db->GetRow($query);
$fnoval = $res['fnoval'];
$FSCNDVALCND2 = $res['FSCNDVALCND2'];
$FSCNDVALCND1 = $res['FSCNDVALCND1'];
$FDEVSTATUS = $res['FDEVSTATUS'];
$FDEVIATION = $res['FDEVIATION'];
$fhours = $res['fhours'];
$query = "select TIMESTAMPDIFF(SECOND,FSTDATE,now()) as fsec
from tdvs_tabsum where fdummyno = '{$dummyno}'";
$res10 = $aobj_context->pobj_db->GetRow($query);
$fsec = $res10['fsec'];
$true = false;
if($univcode == '040')
{
if($fhours == '3')
{
if($fsec < 240)
$true = true;
}
if($fhours < '3')
{
if($fsec < 180)
$true = true;
}
// if($true)
// {
// $arr['msg'] = "Minimum 4 minutes need to evaluate a script";
// echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
// return;
// }
}
$query1 = "select ifnull(fsysmarks,'') as fsysmarks, ifnull(fsysmarksv,'') as fsysmarksv,
fbatchno, fregcode, fdummyno
from tdvs_tabsum where fdummyno = '{$dummyno}'";
$res1 = $aobj_context->pobj_db->GetRow($query1);
$fregcode = $res1['fregcode'];
$fbatchno = $res1['fbatchno'];
if ($valno == "W") {
if ($res1['fsysmarks'] == "") {
$arr['msg'] = "Evaluator total marks not updated !!!";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
if ($res1['fsysmarksv'] == "") {
$arr['msg'] = "Reviewer total marks not updated !!!";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
$query2 = "update tdvs_tabsum set frevstatus = 'FINAL', fendatev = now(), fremarks='{$remarks}'
where fqpcode = '{$qpcode}' and fregcode = '{$fregcode}'";
$res2 = $aobj_context->pobj_db->Execute($query2);
$query3 = "update tdvs_tabsum set frevcode = '{$fteachcode}'
where fbatchno = '{$fbatchno}' and fqpcode = '{$qpcode}'";
$res3 = $aobj_context->pobj_db->Execute($query3);
$query4 = "select sum(if(ifnull(fstatus,'') = 'FINAL',1,0)) as ffscriptcnt,
sum(if(ifnull(frevstatus,'') = 'FINAL',1,0)) as frscriptcnt
from tdvs_tabsum where fbatchno = '{$fbatchno}'";
$res4 = $aobj_context->pobj_db->GetRow($query4);
$frscriptcnt = $res4['frscriptcnt'];
$query5 = "update tdvs_tabpkt set frevscript = '{$frscriptcnt}', frevdate = now() where fbatchno = '{$fbatchno}'";
$res5 = $aobj_context->pobj_db->Execute($querwy5);
if($res5){
$arr['msg'] = 'Updation successful !!!';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
return;
}else{
$arr['msg'] = 'Updation failed !!!';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}else
{
if ($res1['fsysmarks'] == "") {
$arr['msg'] = "Evaluator total marks not updated !!!";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
$query2 = "update tdvs_tabsum set fstatus = 'FINAL', fendate = now(), fremarks='{$remarks}'
where fqpcode = '{$qpcode}' and fregcode = '{$fregcode}' and fvalno = '{$valno}'";
$res2 = $aobj_context->pobj_db->Execute($query2);
$query3 = "select sum(if(ifnull(fstatus,'') = 'FINAL',1,0)) as ffscriptcnt,
sum(if(ifnull(frevstatus,'') = 'FINAL',1,0)) as frscriptcnt
from tdvs_tabsum where fbatchno = '{$fbatchno}'";
$res3 = $aobj_context->pobj_db->GetRow($query3);
$ffscriptcnt = $res3['ffscriptcnt'];
$query4 = "update tdvs_tabpkt set fvalscript = '{$ffscriptcnt}', fvaldate = now()
where fbatchno = '{$fbatchno}'";
$res4 = $aobj_context->pobj_db->Execute($query4);
// if($res4){
// $arr['msg'] = 'Updation successful !!!';
// echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
// return;
// }else{
// $arr['msg'] = 'Updation failed !!!';
// echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
// return;
// }
}
if ($fnoval == "2") {
if($univcode == "051")
{
$cnd = "(ABS(t1.fsysmarks-t2.fsysmarks)) > (((m.fsmaxmarks/100)*dg.FDEVIATION)";
if ($FDEVSTATUS == "T"){
$cnd = "(ABS(t1.fsysmarks-t2.fsysmarks)) >= (((m.fsmaxmarks/100)*dg.FDEVIATION)";
}
}else
{
$cnd = "round(ABS(t1.fsysmarks-t2.fsysmarks)) > round(((m.fsmaxmarks/100)*dg.FDEVIATION)";
if ($FDEVSTATUS == "T"){
$cnd = "round(ABS(t1.fsysmarks-t2.fsysmarks)) >= round(((m.fsmaxmarks/100)*dg.FDEVIATION)";
}
}
// $query6 = "insert ignore into tdvs_tabsum (fqpcode,fpacket,fregcode,fvalno,fyear,fexamtype,FUPDDATE)
// select t1.fqpcode, t1.fpacket, t1.fregcode, 'D', t1.fyear, t1.fexamtype, NOW()
// from tdvs_masqp m
// inner join tdvs_deggrp dg on m.fdeggrp = dg.fdeggrp
// inner join tdvs_tabsum t1 on m.fqpcode = t1.fqpcode and t1.fvalno = '1'
// and t1.fregcode = '{$fregcode}' and t1.fstatus = 'FINAL'
// inner join tdvs_tabsum t2 on t1.fregcode = t2.fregcode
// and t1.fqpcode = t2.fqpcode
// and m.fqpcode = t2.fqpcode and t2.fvalno = '2'
// and t2.fregcode = '{$fregcode}' and t2.fstatus = 'FINAL'
// where t1.fregcode = '{$fregcode}'
// and t2.fregcode = '{$fregcode}'
// and {$cnd})";
// //var_dump($query6);
// //die();
// $res6 = $aobj_context->pobj_db->Execute($query6);
}
if ($univcode == "051" || $univcode == "098") {
// $query8 = "insert ignore into tdvs_tabsum (fqpcode,fpacket,fregcode,fvalno,fyear,fexamtype,FUPDDATE)
// select t.fqpcode,'1001',t.fregcode,'5',t.fyear,t.fexamtype,now()
// from tdvs_tabsum t inner join tdvs_tabulate td on t.fregcode = td.fregcode
// and t.fqpcode = td.fqpcode
// inner join subject s on t.fqpcode = s.fqpcode
// and s.fqpcode = td.fqpcode
// inner join resmarksdet r on td.fregno = r.fregno
// and r.fsubcode = s.fcsubcode
// and r.fdegree = s.fdegree
// and r.fexamno = s.fexamno
// and t.fyear = r.fyear and t.fexamtype = r.fexamtype
// inner join tdvs_masqp m on s.fqpcode = m.fqpcode
// inner join tdvs_deggrp dg on m.fdeggrp = dg.fdeggrp
// left join tdvs_tabsum t2 on t.fregcode = t2.fregcode
// and t2.fvalno= '5'
// where t.fvalno = 'R'
// and ABS(if(ifnull(r.fvalsec,'') = '',r.fmarks, r.fvalsec)-t.fsysmarks) > ((m.fsmaxmarks/100)*dg.FDEVIATION)
// and t.fstatus = 'FINAL'
// and t2.fregcode is null";
// $res8 = $aobj_context->pobj_db->Execute($query8);
if($univcode == "051")
{
$cnd = "(ABS(t1.fsysmarks-t2.fsysmarks)) > (((m.fsmaxmarks/100)*dg.FDEVIATION)";
if ($FDEVSTATUS == "T"){
$cnd = "(ABS(t1.fsysmarks-t2.fsysmarks)) >= (((m.fsmaxmarks/100)*dg.FDEVIATION)";
}
}else
{
$cnd = "round(ABS(t1.fsysmarks-t2.fsysmarks)) > round(((m.fsmaxmarks/100)*dg.FDEVIATION)";
if ($FDEVSTATUS == "T"){
$cnd = "round(ABS(t1.fsysmarks-t2.fsysmarks)) >= round(((m.fsmaxmarks/100)*dg.FDEVIATION)";
}
}
// $query6 = "insert ignore into tdvs_tabsum (fqpcode,fpacket,fregcode,fvalno,fyear,fexamtype,FUPDDATE)
// select t1.fqpcode, t1.fpacket, t1.fregcode, 'D', t1.fyear, t1.fexamtype, NOW()
// from tdvs_masqp m
// inner join tdvs_deggrp dg on m.fdeggrp = dg.fdeggrp
// inner join tdvs_tabsum t1 on m.fqpcode = t1.fqpcode and t1.fvalno = '1'
// and t1.fregcode = '{$fregcode}' and t1.fstatus = 'FINAL'
// inner join tdvs_tabsum t2 on t1.fregcode = t2.fregcode
// and t1.fqpcode = t2.fqpcode
// and m.fqpcode = t2.fqpcode and t2.fvalno = '2'
// and t2.fregcode = '{$fregcode}' and t2.fstatus = 'FINAL'
// where t1.fregcode = '{$fregcode}'
// and t2.fregcode = '{$fregcode}'
// and {$cnd})";
// // //var_dump($query6);
// // //die();
// $res6 = $aobj_context->pobj_db->Execute($query6);
if ($fnoval == "1") {
$query6 = "insert ignore into tdvs_tabsum (fqpcode, fpacket, fregcode, fvalno, fyear, fexamtype, FUPDDATE)
select t.fqpcode, t.fpacket, t.fregcode, '2', t.fyear, t.fexamtype, NOW()
from tdvs_tabsum t inner join tdvs_masqp m on t.fqpcode = m.fqpcode
inner join tdvs_deggrp dg on m.fdeggrp = dg.fdeggrp
where round((fsysmarks/m.fsmaxmarks*100)) < '{$FSCNDVALCND1}'
and t.fregcode = '{$fregcode}'
and t.fvalno = '1'
and ifnull(t.fstatus,'') = 'FINAL'";
$res6 = $aobj_context->pobj_db->Execute($query6);
$query7 = "insert ignore into tdvs_tabsum (fqpcode, fpacket, fregcode, fvalno, fyear, fexamtype, FUPDDATE)
select t.fqpcode, t.fpacket, t.fregcode, '2', t.fyear, t.fexamtype, NOW()
from tdvs_tabsum t inner join tdvs_masqp m on t.fqpcode = m.fqpcode
inner join tdvs_deggrp dg on m.fdeggrp = dg.fdeggrp
where round((fsysmarks/m.fsmaxmarks*100)) > '{$FSCNDVALCND2}'
and t.fregcode = '{$fregcode}'
and t.fvalno = '1'
and ifnull(t.fstatus,'') = 'FINAL'";
$res7 = $aobj_context->pobj_db->Execute($query7);
if($res2){
$arr['msg'] = 'Updation successful !!!';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
return;
}else{
$arr['msg'] = 'Updation failed !!!';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
}
if($res2){
$arr['msg'] = 'Updation successful !!!';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
return;
}else{
$arr['msg'] = 'Updation failed !!!';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function saveEvaluationMarks($aobj_context){
$univcode = $aobj_context->mobj_data["univcode"];
$qpcode = $aobj_context->mobj_data["qpcode"];
$dummyno = $aobj_context->mobj_data["dummyno"];
$valno = $aobj_context->mobj_data["valno"];
$fteachcode = $aobj_context->mobj_data["fteachcode"];
$ip = $_SERVER['REMOTE_ADDR'];
$data = $aobj_context->req_body;
$query1 = "select ifnull(fregcode, '')as fregcode, fyear,
fexamtype from tdvs_tabsum where fqpcode='{$qpcode}'
and fdummyno='{$dummyno}'";
$res1 = $aobj_context->pobj_db->GetRow($query1);
$regcode = $res1["fregcode"];
$year = $res1["fyear"];
$examtype = $res1["fexamtype"];
$tabdetl_obj = "";
for ($i=0; $i < count($data); $i++) {
$fmarks = $data[$i]['fmarks'] === "N" ? -2 : $data[$i]['fmarks'];
$remarks = $data[$i]['fremarks'] == 'undefined' ? "" : $data[$i]['fremarks'];
$tabdetl_obj .= "('1001', '{$qpcode}','{$regcode}','{$data[$i]['fqncode']}','{$fmarks}', '{$year}','{$examtype}', '{$remarks}',''),";
}
$tabdetl_obj = rtrim($tabdetl_obj, ",");
$m_field = "";
if ($valno == "1") {
$m_field = "fmarks11";
} else if ($valno == "2") {
$m_field = "fmarks21";
} else if ($valno == "3") {
$m_field = "fmarks31";
} else if ($valno == "4") {
$m_field = "fmarks41";
} else if ($valno == "5") {
$m_field = "fmarks51";
} else if ($valno == "R") {
$m_field = "fmarksr1";
} else if ($valno == "D") {
$m_field = "fmarksd1";
} else if ($valno == "W") {
$m_field = "fmarksv1";
}
if ($m_field == "") {
$arr['msg'] = 'Invalid Valuation number !!!';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
$s_field = "";
if ($valno == "1") {
$s_field = "fmarks12";
} else if ($valno == "2") {
$s_field = "fmarks22";
} else if ($valno == "3") {
$s_field = "fmarks32";
} else if ($valno == "4") {
$s_field = "fmarks42";
} else if ($valno == "5") {
$s_field = "fmarks52";
} else if ($valno == "R") {
$s_field = "fmarksr2";
} else if ($valno == "D") {
$s_field = "fmarksd2";
} else if ($valno == "W") {
$s_field = "fmarksv2";
}
$query2 = "insert ignore into tdvs_tabdetl( fcollcode, fqpcode,
fregcode, fqnno, {$m_field}, fyear, fexamtype, fremarks,{$s_field}) values
{$tabdetl_obj}
on duplicate key update {$m_field} = values({$m_field}),{$s_field} = NULL";
$res2 = $aobj_context->pobj_db->Execute($query2);
//var_dump($query2);die();
$query3 = "select a.ftempcode, a.ftempname, a.fpartcode, b.fboard,
ifnull(a.ftotmandqn,0) as ftotmandqn, ifnull(a.fminqn,0) as fminqn,
a.fmaxqn, a.fmandqn, a.fmaxmarks, a.ftempmax from tdvs_qptemphead a
inner join tdvs_masqp b on a.ftempcode = b.ftempcode
where b.fqpcode = '{$qpcode}'";
//if($univcode == '098')
//var_dump($query3);die();
$res3 = $aobj_context->pobj_db->GetAll($query3);
$ftempcode = $res3[0]['ftempcode'];
$fboard = $res3[0]['fboard'];
$fminqn = $res3[0]['fminqn'];
$ftotmandqn = $res3[0]['ftotmandqn'];
foreach ($res3 as $value) {
$query4 = "insert into tdvs_tabdetl(fqpcode, fregcode, fqnno, {$m_field})
select a.fqpcode, a.fregcode, a.fqnno, a.{$m_field} from tdvs_tabdetl a
inner join tdvs_qptempdetl b inner join tdvs_masqp c on a.fqpcode = c.fqpcode
and c.ftempcode = b.ftempcode and a.fqnno = b.fqncode
and b.fqncode = b.fqnparent
where a.fregcode = '{$regcode}' and b.fpartcode = '{$value['fpartcode']}'
and a.fqpcode = '{$qpcode}'
order by {$m_field} desc limit {$value['fmandqn']}
on duplicate key update {$s_field} = values({$m_field})";
// if($univcode == '098')
// var_dump($query4);
$res4 = $aobj_context->pobj_db->Execute($query4);
$query5 = "select a.fqpcode, a.fregcode, a.fqnno, a.{$m_field} from tdvs_tabdetl a
inner join tdvs_qptempdetl b inner join tdvs_masqp c on a.fqpcode = c.fqpcode
and c.ftempcode = b.ftempcode
and a.fqnno = b.fqncode
and b.fqncode = b.fqnparent
where a.fregcode = '{$regcode}' and b.fpartcode = '{$value['fpartcode']}' and fsubqp='T'
and a.fqpcode = '{$qpcode}'";
$res5 = $aobj_context->pobj_db->GetAll($query5);
if (count($res5) > 0) {
$query6 = "select fqncode as fqnno from tdvs_qptempdetl where ftempcode='{$ftempcode}' and fsubqp='T'";
$res6 = $aobj_context->pobj_db->GetAll($query6);
for ($index = 0; $index < count($res6); $index++) {
$qnno = $res6[$index]["fqnno"];
$query7 = "select sum(if(${m_field} = -2, 0, ${m_field}))as sum
from tdvs_tabdetl where fqnno in (select fqncode from tdvs_qptempdetl
where ftempcode='{$value["ftempcode"]}' and fqnparent='{$qnno}'
and ifnull(fsubqp, '') <> 'T')
and fqpcode='{$qpcode}' and fregcode='{$regcode}'";
$res7 = $aobj_context->pobj_db->GetRow($query7);
$sum = $res7["sum"];
$query8 = "update tdvs_tabdetl set ${m_field}='{$sum}'
where fqpcode='{$qpcode}' and fregcode='{$regcode}' and fqnno='{$qnno}'";
//var_dump($query8);
$res8 = $aobj_context->pobj_db->Execute($query8);
}
}
$query4 = "insert into tdvs_tabdetl(fqpcode, fregcode, fqnno, {$m_field})
select a.fqpcode, a.fregcode, a.fqnno, a.{$m_field} from tdvs_tabdetl a
inner join tdvs_qptempdetl b inner join tdvs_masqp c on a.fqpcode = c.fqpcode
and c.ftempcode = b.ftempcode and a.fqnno = b.fqncode
and b.fqncode = b.fqnparent
where a.fregcode = '{$regcode}' and b.fpartcode = '{$value['fpartcode']}'
and a.fqpcode = '{$qpcode}'
order by {$m_field} desc limit {$value['fmandqn']}
on duplicate key update {$s_field} = values({$m_field})";
$res4 = $aobj_context->pobj_db->Execute($query4);
}
if($fboard == "PGMAT" && $univcode == '033')
{
$mandans = $ftotmandqn;
$parts = [];
$totans = 0;
$po1 = 0;
$p02 = 0;
$i = 0;
$queru = "select a.fqpcode, a.fregcode, b.fpartcode,sum( if(ifnull({$s_field},-2) = '-2',0,1)) as marks
from tdvs_tabdetl a
inner join tdvs_qptempdetl b on a.fqnno = b.fqncode
and b.fqncode = b.fqnparent
inner join tdvs_masqp c on a.fqpcode = c.fqpcode
and c.ftempcode = b.ftempcode
where fregcode = '{$regcode}'
and a.fqpcode = '{$qpcode}'
group by b.fpartcode";
$res9 = $aobj_context->pobj_db->GetAll($queru);
foreach($res9 as $val)
{
if ($val['marks'] == 0)
{
$mandans--;
}
if ($i == 0) $po1 = $val['marks'];
if ($i == 1) $po2 = $val['marks'];
$parts[$val['fpartcode']] = $val['marks'];
$totans = (int)$totans + (int)$val['marks'];
$i++;
}
$xtotans = $totans;
if ($totans > $mandans) {
$queru = "select a.fqpcode, a.fregcode,a.fqnno, b.fqnparent,b.fpartcode,${s_field} as allotmarks
from tdvs_tabdetl a
inner join tdvs_qptempdetl b on a.fqnno = b.fqncode
and b.fqncode = b.fqnparent
inner join tdvs_masqp c on a.fqpcode = c.fqpcode
and c.ftempcode = b.ftempcode
where fregcode = '{$regcode}'
and a.fqpcode = '{$qpcode}'
and ifnull({$s_field},'') <> ''
order by {$s_field}";
$res10 = $aobj_context->pobj_db->GetAll($queru);
foreach ($res10 as $value) {
if ($value['allotmarks'] == -2) {
} else {
$partcode = $value['fpartcode'];
$fqnno = $value['fqnno'];
$fqpcode = $value['fqpcode'];
if ($xtotans > $mandans) {
if ($parts[$partcode] > $fminqn) {
$query = "update tdvs_tabdetl set {$s_field} = NULL
where fregcode = '{$regcode}'
and fqpcode = '{$fqpcode}'
and fqnno = '{$fqnno}'";
$res8 = $aobj_context->pobj_db->Execute($query);
$xtotans--;
$parts[$partcode] = $parts[$partcode] - 1;
}
}
// if($totans > $mandans) {
// $query = "update tdvs_tabdetl set {$s_field} = NULL
// where fregcode = '{$regcode}'
// and fqpcode = '{$fqpcode}'
// and fqnno = '{$fqnno}'";
// $res8 = $aobj_context->pobj_db->Execute($query);
// //var_dump($query);
// $totans--;
// }
}
}
}
}
$query9 = "select fqncode from tdvs_qptempdetl where ftempcode = '{$ftempcode}'
and fqncode <> fqnparent and fqnparent in (select a.fqnno
from tdvs_tabdetl a inner join tdvs_masqp c on
a.fqpcode = c.fqpcode inner join tdvs_qptempdetl b
on c.ftempcode = b.ftempcode
and a.fqnno = b.fqncode and ifnull(a.{$m_field}, '') <> ''
where fregcode = '{$regcode}')";
$res9 = $aobj_context->pobj_db->GetAll($query9);
// $query11 = "update tdvs_tabdetl set {$s_field} = NULL
// where fregcode = '{$regcode}'
// and fqpcode = '{$qpcode}'";
// var_dump($query11);die();
// $res11 = $aobj_context->pobj_db->Execute($query11);
$qnno_arr = [];
for ($i=0; $i < count($res9); $i++) {
array_push($qnno_arr, $res9[$i]['fqncode']);
}
$qnno_str = implode("','", $qnno_arr);
$query10 = "update tdvs_tabdetl set {$s_field} = {$m_field}
where fqnno in ('{$qnno_str}') and fregcode = '{$regcode}'
and fqpcode = '{$qpcode}'";
$res10 = $aobj_context->pobj_db->Execute($query10);
if($fboard == "PGMAT" && $univcode == '033')
{
$mandans = $ftotmandqn;
$parts = [];
$totans = 0;
$po1 = 0;
$p02 = 0;
$i = 0;
$queru = "select a.fqpcode, a.fregcode, b.fpartcode,sum( if(ifnull({$s_field},-2) = '-2',0,1)) as marks
from tdvs_tabdetl a
inner join tdvs_qptempdetl b on a.fqnno = b.fqncode
and b.fqncode = b.fqnparent
inner join tdvs_masqp c on a.fqpcode = c.fqpcode
and c.ftempcode = b.ftempcode
where fregcode = '{$fregcode}'
and a.fqpcode = '{$fqpcode}'
group by b.fpartcode";
$res9 = $aobj_context->pobj_db->GetAll($queru);
foreach($res9 as $val) {
$totans = (int)$totans + (int)$val['marks'];
$i++;
}
if ($totans > $mandans) {
$queru = "select a.fqpcode, a.fregcode,a.fqnno, b.fqnparent,b.fpartcode,${s_field} as allotmarks
from tdvs_tabdetl a
inner join tdvs_qptempdetl b on a.fqnno = b.fqncode
and b.fqncode = b.fqnparent
inner join tdvs_masqp c on a.fqpcode = c.fqpcode
and c.ftempcode = b.ftempcode
where fregcode = '{$fregcode}'
and a.fqpcode = '{$fqpcode}'
and ifnull({$s_field},'') <> ''
order by {$s_field}";
$res10 = $aobj_context->pobj_db->GetAll($queru);
foreach ($res10 as $value) {
if ($value['allotmarks'] == -2) {
} else {
$partcode = $value['fpartcode'];
$fqnno = $value['fqnno'];
$fqpcode = $value['fqpcode'];
if($totans > $mandans) {
$query = "update tdvs_tabdetl set {$s_field} = NULL
where fregcode = '{$fregcode}'
and fqpcode = '{$fqpcode}'
and fqnno = '{$fqnno}'";
$totans--;
}
}
}
}
}
$query11 = "select ifnull(sum(ifnull({$m_field},0)),0) as ftotmarks,
ifnull(sum(ifnull({$s_field},0)),0) as fsysmarks from tdvs_tabdetl a
inner join tdvs_masqp m on a.fqpcode = m.fqpcode
inner join tdvs_qptempdetl b on m.ftempcode = b.ftempcode
and a.fqnno = b.fqncode
where fregcode = '{$regcode}' and b.fqncode = b.fqnparent
and ifnull({$m_field}, 0) >= 0 and ifnull({$s_field}, 0) >= 0
and a.fqpcode = '{$qpcode}'";
//var_dump($query11);
$res11 = $aobj_context->pobj_db->GetRow($query11);
$sysmarks = $res11["fsysmarks"];
$totalmarks = $res11["ftotmarks"];
if ($valno == "W") {
$query12 = "update tdvs_tabsum set ftotmarksv = '{$totalmarks}', fsysmarksv = '{$sysmarks}',
frevstatus = 'DRAFT', frevcode = '{$fteachcode}', frevdate = now()
where fdummyno = '{$dummyno}' and fvalno = '1'";
$res = $aobj_context->pobj_db->Execute($query12);
} else {
$query13 = "update tdvs_tabsum set fstatus = 'DRAFT', ftotmarks='{$totalmarks}', fsysmarks='{$sysmarks}', fvalip='{$ip}'
where fdummyno = '{$dummyno}'";
$res = $aobj_context->pobj_db->Execute($query13);
}
$query = "select fvalmax from subject where fqpcode = '{$qpcode}'";
$res12 = $aobj_context->pobj_db->getRow($query);
//var_dump($query);
//$res12['fvalmax'] = 10;
//var_dump($sysmarks,'',$res12['fvalmax']);
if($sysmarks > $res12['fvalmax'])
{
$arr['msg'] = 'Error while Marks Calculation. Contact Admin !!!';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
if($res){
$arr['msg'] = 'Updation successful';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
return;
}else{
$arr['msg'] = 'Error while saving marks details !!!';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function getRVPCAnsView($aobj_context){
$univcode = $aobj_context->mobj_data["univcode"];
$regno = $aobj_context->mobj_data["regno"];
$query = "select tab.FDUMMYNO,concat(tab.fyear,'*',tab.fexamtype) as yearmode, s.fdegree, ifnull(t.fansbook,'') as fansbook,ifnull(t.fregcode,'') as fregcode,ifnull(t.fregno,'') as fregno,
ifnull(m.fsubname,'') as fsubname, concat(s.fssubname,' - ',fsubshort)as fsubshort, ifnull(m.fsmaxmarks,'') as fsmaxmarks,
ifnull(m.fqpcode,'') as fqpcode,ifnull(m.fexamno,'') as fexamno, tab.fvalno, ifnull(tab.FSYSMARKS, '')as fsysmarks,
ifnull(m.fsmaxmarks,'') as fsmaxmarks from tdvs_tabulate t
inner join tdvs_masqp m on t.fqpcode = m.fqpcode
inner join tdvs_tabsum tab on tab.fqpcode = t.fqpcode and tab.fregcode = t.fregcode
inner join subject s on s.fqpcode = m.fqpcode and s.fexamno = m.fexamno
inner join res_stud ru on s.fdegree = ru.fdegree and s.fexamno = ru.fexamno
and left(ru.fsubcode,4) = s.fsubcode and t.fregno = ru.fregno
and ru.fyear = t.fyear and ru.fexamtype = t.fexamtype
and ifnull(ru.fpaymentconfirm,'') = 'success'
and ru.fcorrtype in('PC','RT')
where t.fregno = '{$regno}' group by tab.fregcode, tab.fqpcode, tab.fvalno,tab.fyear,tab.fexamtype
union
select tab.FDUMMYNO,concat(tab.fyear,'*',tab.fexamtype) as yearmode, s.fdegree, ifnull(t.fansbook,'') as fansbook,ifnull(t.fregcode,'') as fregcode,ifnull(t.fregno,'') as fregno,
ifnull(m.fsubname,'') as fsubname, concat(s.fssubname,' - ',fsubshort)as fsubshort, ifnull(m.fsmaxmarks,'') as fsmaxmarks,
ifnull(m.fqpcode,'') as fqpcode,ifnull(m.fexamno,'') as fexamno, tab.fvalno, ifnull(tab.FSYSMARKS, '')as fsysmarks,
ifnull(m.fsmaxmarks,'') as fsmaxmarks from tdvs_tabulate_bkp t
inner join tdvs_masqp m on t.fqpcode = m.fqpcode
inner join tdvs_tabsum_bkp tab on tab.fqpcode = t.fqpcode and tab.fregcode = t.fregcode
inner join subject s on s.fqpcode = m.fqpcode and s.fexamno = m.fexamno
inner join res_stud ru on s.fdegree = ru.fdegree and s.fexamno = ru.fexamno
and left(ru.fsubcode,4) = s.fsubcode and t.fregno = ru.fregno
and ru.fyear = t.fyear and ru.fexamtype = t.fexamtype
and ifnull(ru.fpaymentconfirm,'') = 'success'
where t.fregno = '{$regno}' and ru.fcorrtype in('PC','RT')
group by tab.fregcode, tab.fqpcode, tab.fvalno,tab.fyear,tab.fexamtype
order by yearmode desc,fqpcode,FDUMMYNO";
$result = $aobj_context->pobj_db->GetAll($query);
$stdName = "select ifnull(fname,'') as fname from student
where fregno = '{$regno}'";
$res = $aobj_context->pobj_db->GetRow($stdName);
if($result){
$arr['data'] = $result;
$arr['stdname'] = $res;
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
}else{
$arr['msg'] = 'No data found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
?>
|