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.145.92.96
<?php
function compileQpIndent($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS')
return;
$deggrp = $aobj_context->mobj_data["deggrp"];
$query = "DROP TABLE IF EXISTS qpmaster, tmpqpindsum,tmpqpindtot,tmpqpinddeg";
$result = $aobj_context->pobj_db->Execute($query);
$query = "select fyear, fexamtype, fexamdate from deggrp where fdeggrp ='{$deggrp}'";
$results = $aobj_context->pobj_db->GetRow($query);
$fyear = $results['fyear'];
$fexamtype = $results['fexamtype'];
$query = "select * from degcntr where fdeggrp = '{$deggrp}' and fyear = '{$fyear}'
and fexamtype = '{$fexamtype}'";
$results = $aobj_context->pobj_db->GetAll($query);
if(count($results)==0) {
$arr['msg'] = 'Exam centres not identified for current exam.';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
return;
}
$query = "CREATE TABLE qpmaster
SELECT DISTINCT fdegree, fexamno, fsubcode, fqpcode, d.fdate AS fdoe, fsessiont AS fsession
FROM subject s left join masdate d on s.fdatecodet = d.fdatecode
and d.fdeggrp = '{$deggrp}' and d.fyear = '{$fyear}' and d.fexamtype = '{$fexamtype}' WHERE IFNULL(fqpcode,'') <> '' AND ftheory = 'T'
AND IFNULL(fintass,'') <> 'T'
AND fdegree in( select distinct fdegree from degree where fdeggrp = '{$deggrp}') ";
// var_dump($query);
$result = $aobj_context->pobj_db->Execute($query);
//var_dump($aobj_context->pobj_db);
$query = "create index qpmaster_inx on qpmaster(fqpcode)";
$result = $aobj_context->pobj_db->Execute($query);
$query = "create index qpmaster_inx1 on qpmaster(fdegree, fexamno, fsubcode)";
$result = $aobj_context->pobj_db->Execute($query);
$query = "alter table qpmaster add column fsubname varchar(200)";
$result = $aobj_context->pobj_db->Execute($query);
$query = "update qpmaster q, subject s
set q.fsubname = s.fsubname
where q.fqpcode = s.fqpcode
and ifnull(s.fqpcode,'') <> ''";
$result = $aobj_context->pobj_db->Execute($query);
$query = "CREATE TABLE tmpqpindsum
SELECT m.fexamcodet as fcntrcode, CONCAT(TRIM(g.fcollname), ', ', g.ftown) AS fcntrname, s.fqpcode,
s.fsubname, s.fdoe, s.fsession, COUNT(c.fregno) AS fcnt,
(FLOOR((COUNT(c.fregno) * (10/100)) / 5) * 5) + IF((COUNT(c.fregno) * (10/100)) MOD 5 = 0, 0, 5) AS fextra,
COUNT(c.fregno) + (FLOOR((COUNT(c.fregno) * (10/100)) / 5) * 5) + IF((COUNT(c.fregno) * (10/100)) MOD 5 = 0, 0, 5) AS ftotal,
(FLOOR((COUNT(c.fregno) + (FLOOR((COUNT(c.fregno) * (10/100)) / 5) * 5) + IF((COUNT(c.fregno) * (10/100)) MOD 5 = 0, 0, 5)) / 10) * 10) +
IF((COUNT(c.fregno) + (FLOOR((COUNT(c.fregno) * (10/100)) / 5) * 5) +
IF((COUNT(c.fregno) * (10/100)) MOD 5 = 0, 0, 5)) MOD 10 = 0, 0, 10) AS frounded,
GROUP_CONCAT(DISTINCT s.fdegree ORDER BY s.fdegree) AS fdegree
FROM qpmaster s, canddet c, degcntr m, college g
WHERE s.fdegree = c.fdegree
AND s.fexamno = c.fexamno
AND s.fsubcode = c.fsubcode
AND c.fcollcode = m.fcollcode
AND m.fexamcodet = g.fcollcode and ifnull(c.fpresent,'') = 'P' and ifnull(c.fpassmth,'') = ''
and ifnull(fthpr,'') <> 'T'
and m.fyear = '{$fyear}' and m.fexamtype = '{$fexamtype}'
and m.fdeggrp = '{$deggrp}' and c.fdegree in(select fdegree from degree where fdeggrp = '{$deggrp}')
GROUP BY s.fqpcode, s.fsubname, m.fexamcodet, g.fcollname, g.ftown
ORDER BY m.fexamcodet, s.fqpcode";
$result1 = $aobj_context->pobj_db->Execute($query);
$query = "CREATE TABLE tmpqpindtot
SELECT q.fdoe, q.fsession, q.fqpcode, q.fsubname, '' AS fdeg,
SUM(q.frounded) AS fforcoll
FROM tmpqpindsum q
GROUP BY q.fdoe, q.fsession, q.fqpcode, q.fsubname
ORDER BY q.fdoe, q.fsession, q.fqpcode";
$result2 = $aobj_context->pobj_db->Execute($query);
$query = "CREATE TABLE tmpqpinddeg
SELECT fqpcode, GROUP_CONCAT(DISTINCT fdegree ORDER BY fdegree) AS fdegree
FROM qpmaster
GROUP BY fqpcode
ORDER BY fqpcode";
$result3 = $aobj_context->pobj_db->Execute($query);
if($result1 && $result2 && $result3)
{
$arr['msg'] = 'QP Indent compiled successfully.';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0,"success");
}
else
{
$arr['msg'] = 'Error While QP Indent Compilation.';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
|