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.147.69.25
<?php
function meViewIaStudDet($aobj_context){
session_start();
$collcode=$_SESSION['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 = '{$subelement}'";
$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,
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='{$subelement}'
where a.fteachcode = '{$teachcode}' and a.fclassid = '{$classid}'
and a.FCOLLCODE='{$collcode}'
and concat(sd.fcsubcode,sd.fsubcode) = '{$subelement}'
and left(a.fsubcode,4) = left('{$subelement}',4) group by fregno order by {$sort}";
$result=$aobj_context->mobj_db->GetAll($query);
$table = "<table id='tabledata' class='table' width='100%' cellspacing='0' cellpadding='0' border='0' >";
$table .= "<thead style='position:sticky; top:0; z-index:1'>";
$table .= "<tr style='position: sticky; top: 0; background: white;'>
<th colspan='7' class='ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper'>
<input type='text' style='width:96%; padding:4px;margin:2px; border-radius:20px;' id='myInput' onkeyup='searchRegCode()' placeholder='Search by Name....'></th>
</tr>";
$table .= "<tr align='center' class='ui-state-default ui-jqgrid-hdiv'>";
$table .= "<td class='column'>Sl. No.</td>";
$table .= "<td class='column'>USN</td>";
$table .= "<td class='column'>Student Name</td>";
$table .= "<td class='column'>Max Marks</td>";
$table .= "<td class='column'>Secure Marks</td>";
$table .= "<td class='column'>Action</td>";
$table .= "<td class='column'>Absent ?</td>";
$table .= "</tr></thead><tbody>";
for($i=0; $i<count($result); $i++){
$total = $result[$i]['facttotal'] == "-2" ? "Absent" : $result[$i]['facttotal'];
$ent = $total == "Absent" ? "": "<span class='btn' onclick='getStudentMarks(`{$result[$i]['FREGNO']}`, `{$testName}`, `{$subelement}`, `{$collcode}`, `{$classid}`, `{$result[$i]['fdegree']}`, `{$result[$i]['fexamno']}`, `{$result[$i]['FNAME']}`)'>Enter Marks</span>";
$style = $result[$i]['facttotal'] == "-2" ? 'color:#b62020;' : 'color:#000;';
$slno = $i + 1;
$table .= "<tr align='center' lass='ui-widget-content jqgrow'>";
$table .= "<td class='column'>". $slno ."</td>";
$table .= "<td class='column'>". $result[$i]['FREGNO'] ."</td>";
$table .= "<td class='column' style='text-align:initial;width: 200px;'>". $result[$i]['FNAME'] ."</td>";
$table .= "<td class='column'>". $result[$i]['fu1max'] ."</td>";
$table .= "<td class='column' style='{$style}'>". $total ."</td>";
$table .= "<td class='column'>". $ent ."</td>";
$table .= "<td class='column'>
<span class='btn' style='background:#b62020;' onclick='absentHandler(`{$result[$i]['FREGNO']}`, `{$testName}`, `{$subelement}`, `{$collcode}`, `{$classid}`, `{$result[$i]['fdegree']}`, `{$result[$i]['fexamno']}`)'>Absent</span>
<span class='btn' style='background:#6495ED;' onclick='removeAbsentHandler(`{$result[$i]['FREGNO']}`, `{$testName}`, `{$subelement}`, `{$collcode}`, `{$classid}`, `{$result[$i]['fdegree']}`, `{$result[$i]['fexamno']}`)'>Remove AB</span>
</td>";
$table .= "</tr>";
}
$table .= "</tbody></table>";
$arr['html'] = $table;
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
}
function meGetStudentMarksData($aobj_context){
$testname = $aobj_context->mobj_data["testname"];
$subcode = $aobj_context->mobj_data["subcode"];
$classid = $aobj_context->mobj_data["classid"];
$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 = $_SESSION['collcode'];
$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);
$table = "<table id='marksdata' style='position:sticky; top:0' class='table' width='100%' cellspacing='0' cellpadding='0'>
<thead style='position: sticky; top: 0; z-index: 1'>
<tr>
<th colspan='5' style='text-align: initial;padding:10px' class='ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper'>
Marks Entry
</th>
</tr>
<tr style='background:#fff'>
<th colspan='2' class='column'> USN: {$regno}</th>
<th colspan='2' class='column'> Name: {$name}</th>
<th colspan='2' class='column' align='center'><span class='btn' onclick='saveMarksEntryQnWiseNew()'>Save</span> </th>
</tr>
<tr class='ui-state-default ui-jqgrid-hdiv'>
<th class='column' align='center' width='20%'>Question No.</th>
<th class='column' align='center' width='20%'>Sub Qn.</th>
<th class='column' align='center' width='20%'>Max Marks</th>
<th class='column' align='center' width='20%'>Secured Marks</th>
<th class='column' align='center' width='20%'>Total</th>
</tr>
</thead><tbody>";
$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'];
$table .= "<tr>";
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'];
$table .= "<td class='column' align='center' rowspan='{$count}'>".$val['fqn']."</td>";
}
$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];
$table .= "<td class='column' align='center'>".$val['fqnno']."</td>
<td class='column' align='center'>".$val['fmarks']."</td>
<td class='column' align='center'><input type='text' style='height:100%; width:60%; padding:5px;' value='{$res[$col]}' id='marks_{$val['fqnno']}' onblur='addStMarks(`{$val['fqn']}`, `{$val['fqnno']}`, `{$val['fmarks']}`, `{$i}`, `{$testname}`, `{$subcode}`)'/></td>";
if($val['fqn'] !== $newQn){
$totalMarks = $res[$tot] == "-1.0" ? "" : $res[$tot];
$table .= "<td class='column' align='center' rowspan='{$count}'><input type='text' style='height:100%; width:60%; padding:5px;' id='total_{$val['fqn']}' value='{$totalMarks}' disabled/></td>";
}
$table .= "</tr>";
$newQn = $val['fqn'];
array_push($newArr, $obj);
$i++;
}
$table .= "</tbody></table>";
$arr['marksArr'] = $newArr;
$arr['html'] = $table;
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
}
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);
$collcode = $_SESSION['collcode'];
$test = $data[0]['ftest'];
$subcode = $data[0]['fsubcode'];
$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['fmarks']=="ab" ? '-2'.$cond : $val['fmarks'].$cond;
if($totM == $val['fqn']){
$totMarks+=($val['fmarks']=="-1" || $val['fmarks']=="ab") ? 0:$val['fmarks'];
if($i == count($data)){
$totMarksCol.=$totMarks.",";
}
$count += 1;
}else{
$totMarksCol.=$totMarks.",";
$totM = $val['fqn'];
$totMarks = ($val['fmarks']=="-1" || $val['fmarks']=="ab") ? 0:$val['fmarks'];
$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)";
//var_dump($query);die();
$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 = $_SESSION['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 = $_SESSION['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;
}
}
?>
|