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.220.194.29
<?php
function getOnlineTestList($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$user = json_decode($aobj_context->mobj_data["user"]);
$query = "select t.ftestid, t.ftestname, t.fgrpid, g.ftitle, ifnull(t.fstudcnt,'') as fstudcnt, t.fduration,
date_format(t.ftestdate, '%d/%m/%Y %h:%i %p') as ftestdate from testhead t
inner join grphead g on t.fgrpid = g.fgrpid where t.fcreatedby = '{$user->fuserid}'";
$result = $aobj_context->pobj_db->GetAll($query);
if (!$result && gettype($result) == 'boolean') {
$arr['msg'] = "Error while fetching tests.";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "Failure");
return;
}
if (count($result) > 0) {
$res['tests'] = $result;
echo $aobj_context->mobj_output->ToJSONEnvelope($res, 0, "success");
return;
} else {
$arr['msg'] = 'No tests found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function getOnlineTestIndividual($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$ftestid = $aobj_context->mobj_data["ftestid"];
$query = "select t.ftestid, t.ftestname, t.fgrpid, ifnull(t.fstudcnt,'') as fstudcnt, t.fduration,
date_format(t.ftestdate, '%d/%m/%Y %h:%i %p') as ftestdate, t.fqcnt, t.fqmarks, t.fmaxmarks,
t.fpassmarks from testhead t
where t.ftestid = '{$ftestid}'";
$result = $aobj_context->pobj_db->GetRow($query);
if (!$result && gettype($result) == 'boolean') {
$arr['msg'] = "Error while fetching test details.";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "Failure");
return;
}
if (count($result) > 0) {
$res['test'] = $result;
echo $aobj_context->mobj_output->ToJSONEnvelope($res, 0, "success");
return;
} else {
$arr['msg'] = 'Test Details not found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function saveOnlineTest($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$test = $aobj_context->req_body['test'];
$user = $aobj_context->req_body['user'];
// var_dump($test);
// var_dump($user);
// return;
// var_dump($group); date_format(str_to_date('{$group['fexpdate']}'
if($test['mode'] == "add") {
$query = $aobj_context->pobj_db->prepare( "INSERT INTO testhead (ftestname, fgrpid, fstudcnt, ftestdate,
fduration, fqcnt, fqmarks, fmaxmarks, fpassmarks, fcreatedby, fcreatedate, fdeleted)
values
(?, ?, ?, date_format(str_to_date('{$test['ftestdate']}', '%d/%m/%Y %h:%i %p'), '%Y-%m-%d %H:%i'),
?, ?, ?, ?, ?, ?, now(), 'F')");
$bind_vars = array($test['ftestname'], $test['fgrpid'], $test['fstudcnt'],
$test['fduration'], $test['fqcnt'], $test['fqmarks'], $test['fmaxmarks'], $test['fpassmarks'],
$user['fuserid']);
$result = $aobj_context->pobj_db->Execute($query, $bind_vars);
// var_dump($query);
}
else if($test['mode'] == "edit") {
$query = "update testhead set ftestname = ?,
fgrpid = ?, ftestdate = date_format(str_to_date('{$test['ftestdate']}', '%d/%m/%Y %h:%i %p'), '%Y-%m-%d %H:%i'),
fduration = ?, fqcnt = ?, fqmarks= ?, fmaxmarks = ?, fpassmarks = ?
where ftestid = '{$test['ftestid']}'";
$bind_vars = array($test['ftestname'], $test['fgrpid'],
$test['fduration'], $test['fqcnt'], $test['fqmarks'], $test['fmaxmarks'], $test['fpassmarks']);
$result = $aobj_context->pobj_db->Execute($query, $bind_vars);
}
if (!$result && gettype($result) == 'boolean') {
$arr['msg'] = "Error while sending message";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "Failure");
return;
}
// var_dump($result);
if ($result) {
if($test['mode'] == "edit"){
$arr['ftestid'] = $test['ftestid'];
$arr['msg'] = "Updation Successful.";
}
else if($test['mode'] == "add") {
$arr['ftestid'] = $aobj_context->pobj_db->insert_Id();
$arr['msg'] = "Test created successfully. Proceed to add questions.";
}
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
return;
} else {
$arr['msg'] = 'Error while saving group details';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
// select t.ftestid, t.ftestname, t.fgrpid, g.ftitle, ifnull(t.fstudcnt,'') as fstudcnt, t.fduration,
// date_format(t.ftestdate, '%d/%m/%Y %h:%i %p') as ftestdate from testhead t
// inner join grphead g on t.fgrpid = g.fgrpid
function getOnlineTestQuestionsCnt($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$ftestid = $aobj_context->mobj_data["ftestid"];
$query = "select ftestname,fqcnt as fqcount from testhead
where ftestid = '{$ftestid}'";
$res = $aobj_context->pobj_db->GetRow($query);
$query = "select fqno from testqp where ftestid = '{$ftestid}'";
$result = $aobj_context->pobj_db->GetAll($query);
if($res)
{
$arr['qps'] = $result;
$arr['ftestname'] = $res['ftestname'];
$arr['fqcount'] = $res['fqcount'];
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
return;
}else
{
$arr['msg'] = "Invlaid Test";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function getOnlineTestQuestion($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$ftestid = $aobj_context->mobj_data["ftestid"];
$fqno = $aobj_context->mobj_data["fqno"];
$query = "select fquestion, fopta, foptb, foptc, foptd, fans
from testqp where ftestid = '{$ftestid}' and fqno = '{$fqno}'";
$result = $aobj_context->pobj_db->GetRow($query);
if ($result) {
$arr['fopta'] = $result['fopta'];
$arr['fquestion'] = $result['fquestion'];
$arr['fopta'] = $result['fopta'];
$arr['foptb'] = $result['foptb'];
$arr['foptc'] = $result['foptc'];
$arr['foptd'] = $result['foptd'];
$arr['fans'] = $result['fans'];
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
return;
} else {
$arr['qpdet'] = "No Deatils Found";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function getOnlineTestQutSave($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$ftestid = $aobj_context->req_body["ftestid"];
$fqno = $aobj_context->req_body["fqno"];
$fopta = $aobj_context->req_body["fopta"];
$foptb = $aobj_context->req_body["foptb"];
$foptc = $aobj_context->req_body["foptc"];
$foptd = $aobj_context->req_body["foptd"];
$fans = $aobj_context->req_body["fans"];
$fquestion = $aobj_context->req_body["fquestion"];
$query = "select fquestion, fopta, foptb, foptc, foptd, fans
from testqp where ftestid = '{$ftestid}' and fqno = '{$fqno}'";
$result = $aobj_context->pobj_db->GetRow($query);
if ($result) {
$query = "update testqp set fopta = '{$fopta}',fquestion = '{$fquestion}',
foptb = '{$foptb}', foptc = '{$foptc}', foptd = '{$foptd}', fans = '{$fans}',fmoddate = now()
where ftestid = '{$ftestid}' and fqno = '{$fqno}'";
$result = $aobj_context->pobj_db->Execute($query);
if($result)
{
$arr['msg'] = "Updation Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
return;
}else
{
$arr['msg'] = "Updation Failure. Please Try After Sometime";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
} else {
$query = "insert into testqp(ftestid,fqno,fquestion,fopta,foptb,foptc,foptd,fans,fcreatedate)values('{$ftestid}','{$fqno}','{$fquestion}','{$fopta}','{$foptb}','{$foptc}','{$foptd}','{$fans}',now())";
$result = $aobj_context->pobj_db->Execute($query);
if($result)
{
$arr['msg'] = "Updation Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
return;
}else
{
$arr['msg'] = "Updation Failure. Please Try After Sometime";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
}
function previewOnlineTest($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$ftestid = $aobj_context->mobj_data["ftestid"];
$query = "select ftestname, fqid,fqno,fquestion, fopta, foptb, foptc, foptd, fans
from testhead th inner join testqp tq
on th.ftestid = tq.ftestid
where th.ftestid = '{$ftestid}'";
$result = $aobj_context->pobj_db->GetAll($query);
if ($result) {
$arr['test'] = $result;
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
return;
} else {
$arr['msg'] = "No Deatils Found";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function releaseOnlineTest($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$ftestid = $aobj_context->mobj_data["ftestid"];
$query = "select ftestname, fqcnt, count(fqid) as fcount,
if(ftestdate > now(), 'T', 'F') as testdate, date_format(ftestdate, '%d/%m/%Y %h:%i %p') as ftestdate
from testhead th inner join testqp tq
on th.ftestid = tq.ftestid
where th.ftestid = '{$ftestid}'
group by th.ftestid";
$result = $aobj_context->pobj_db->GetRow($query);
// var_dump($result);
if($result['fqcnt'] != $result['fcount']) {
$arr['msg'] = "Questions spcified ".$result['fqcnt'].". But questions entered ".$result['fcount']
.". Enter All the questions to continue.";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
if($result['testdate'] == "T"){
$arr['msg'] = "Test date is past. You cannot release now.";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
$query = "select fqid, fqno from testqp where ftestid = '{$ftestid}'
and (ifnull(fquestion,'') = '' or ifnull(fopta,'') = ''
or ifnull(foptb,'') = '' or ifnull(foptc,'') = '' or ifnull(foptd,'') = '')";
$result = $aobj_context->pobj_db->GetAll($query);
if(count($result) > 0) {
$arr['msg'] = "Q. No.". (int)$result[0]['fqno'] ." is incomplete";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
$query = "update testhead set fstatus = 'Released',
freleased = 'T', freleasedate = now()
where ftestid = '{$ftestid}'";
$result = $aobj_context->pobj_db->Execute($query);
if($result)
{
$arr['msg'] = "Test released successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
return;
}else
{
$arr['msg'] = "Updation Failure. Please Try After Sometime";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function studOnlineTestList($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$user = json_decode($aobj_context->mobj_data["user"]);
$univcode = $aobj_context->mobj_data["univcode"];
$query = "select fgrp from logisys3_comexam.masuser where fregno = '{$user->fuserid}' and funivcode = '{$univcode}'";
$res = $aobj_context->mobj_db->GetRow($query);
$fgrp = $res['fgrp'];
if (count($res) > 0) {
$query = "select ftestid, ftestname, g.ftitle, date_format(ftestdate, '%d/%m/%Y %h:%i %p') as ftestdate,
fduration, fqcnt, fmaxmarks, fpassmarks
from testhead t inner join grphead g on t.fgrpid = g.fgrpid
where instr('{$fgrp}',t.fgrpid) > 0
and ifnull(freleased,'') = 'T'
and date_format(ftestdate,'%Y-%m-%d') >= date_format(now(),'%Y-%m-%d')
order by ftestdate desc";
$res = $aobj_context->pobj_db->GetAll($query);
$arr['cur_test'] = $res;
$query = "select ftestid, ftestname, g.ftitle, date_format(ftestdate, '%d/%m/%Y %h:%i %p') as ftestdate,
fduration, fqcnt, fmaxmarks, fpassmarks from testhead t inner join grphead g on t.fgrpid = g.fgrpid
where instr('{$fgrp}',t.fgrpid) > 0
and ifnull(freleased,'') = 'T'
and date_format(ftestdate,'%Y-%m-%d') < date_format(now(),'%Y-%m-%d')
order by ftestdate";
$res = $aobj_context->pobj_db->GetAll($query);
$arr['past_test'] = $res;
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
return;
} else {
$arr['test'] = "No Deatils Found";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function getOnlineTestStudntQuestionsCnt($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$ftestid = $aobj_context->mobj_data["ftestid"];
$query = "select h.ftestid, ftestname, fqid, fqno from testhead h
inner join testqp q on h.ftestid = q.ftestid
where h.ftestid = '{$ftestid}' order by fqno";
$result = $aobj_context->pobj_db->GetAll($query);
if(count($result) > 0)
{
$arr['qps'] = $result;
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
return;
}else
{
$arr['msg'] = "Invlaid Test";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
|