
<?php

$con = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

 $course_id = $request->getAttribute('course_id');
  $season_id=$request->getAttribute('season_id');
   $exams_id=$request->getAttribute('exams_id');
    $date_time=$request->getAttribute('date_time');
     $proctor_id=$request->getAttribute('proctor_id');


$response=array();

///absent

if ($absent=="") {
  $absent="0";
 }
 if ($Present=="") {
  $Present="0";
 }
 if ($Malpractice=="") {
  $Malpractice="0";
 }
 
if(isset($course_id)&&isset($season_id)&&isset($exams_id)&&isset($date_time)&&isset($proctor_id)){
$sql="(SELECT status from submit_answer_script where status='absent' AND course_id='$course_id' AND season_id='$season_id' 
	AND exams_id='$exams_id' AND date_time='$date_time' AND proctor_id='$proctor_id')";
	}

elseif(isset($course_id)&&isset($season_id)&&isset($exams_id)&&isset($date_time)){
	$sql="(SELECT status from submit_answer_script where status='absent' AND course_id='$course_id' AND season_id='$season_id' 
	AND exams_id='$exams_id' AND date_time='$date_time')";
}
elseif(isset($course_id)&&isset($season_id)&&isset($exams_id)){
		$sql="(SELECT status from submit_answer_script where status='absent' AND course_id='$course_id' AND season_id='$season_id' AND exams_id='$exams_id')";
}
elseif(isset($course_id)&&isset($season_id)){
	$sql="(SELECT status from submit_answer_script where status='absent' AND course_id='$course_id' AND season_id='$season_id')";
}
elseif(isset($course_id)){
$sql="(SELECT status from submit_answer_script where status='absent' AND course_id='$course_id')";
}
else{
	$sql="(select status from submit_answer_script where status='absent' )";
}

$result=mysqli_query($con,$sql);

    while ($row1[]=mysqli_fetch_assoc($result)) {  

      $absent=count($row1);

	}
//present
if(isset($course_id)&&isset($season_id)&&isset($exams_id)&&isset($date_time)&&isset($proctor_id)){
$sql="(SELECT status from submit_answer_script where status='Present' AND course_id='$course_id' AND season_id='$season_id' 
	AND exams_id='$exams_id' AND date_time='$date_time' AND proctor_id='$proctor_id')";
	}

elseif(isset($course_id)&&isset($season_id)&&isset($exams_id)&&isset($date_time)){
	$sql="(SELECT status from submit_answer_script where status='Present' AND course_id='$course_id' AND season_id='$season_id' 
	AND exams_id='$exams_id' AND date_time='$date_time')";
}
elseif(isset($course_id)&&isset($season_id)&&isset($exams_id)){
		$sql="(SELECT status from submit_answer_script where status='Present' AND course_id='$course_id' AND season_id='$season_id' AND exams_id='$exams_id')";
}
elseif(isset($course_id)&&isset($season_id)){
	$sql="(SELECT status from submit_answer_script where status='Present' AND course_id='$course_id' AND season_id='$season_id')";
}
elseif(isset($course_id)){
$sql="(SELECT status from submit_answer_script where status='Present' AND course_id='$course_id')";
}
else{
	$sql="(select status from submit_answer_script where status='Present' )";
}

$result=mysqli_query($con,$sql);

    while ($row2[]=mysqli_fetch_assoc($result)) {  

      $Present=count($row2);

	}
	//Malpractice
	if(isset($course_id)&&isset($season_id)&&isset($exams_id)&&isset($date_time)&&isset($proctor_id)){
$sql="(SELECT status from submit_answer_script where status='Malpractice' AND course_id='$course_id' AND season_id='$season_id' 
	AND exams_id='$exams_id' AND date_time='$date_time' AND proctor_id='$proctor_id')";
	}

elseif(isset($course_id)&&isset($season_id)&&isset($exams_id)&&isset($date_time)){
	$sql="(SELECT status from submit_answer_script where status='Malpractice' AND course_id='$course_id' AND season_id='$season_id' 
	AND exams_id='$exams_id' AND date_time='$date_time')";
}
elseif(isset($course_id)&&isset($season_id)&&isset($exams_id)){
		$sql="(SELECT status from submit_answer_script where status='Malpractice' AND course_id='$course_id' AND season_id='$season_id' AND exams_id='$exams_id')";
}
elseif(isset($course_id)&&isset($season_id)){
	$sql="(SELECT status from submit_answer_script where status='Malpractice' AND course_id='$course_id' AND season_id='$season_id')";
}
elseif(isset($course_id)){
$sql="(SELECT status from submit_answer_script where status='Malpractice' AND course_id='$course_id')";
}
else{
	$sql="(select status from submit_answer_script where status='Malpractice' )";
}

$result=mysqli_query($con,$sql);

    while ($row3[]=mysqli_fetch_assoc($result)) {  

      $Malpractice=count($row3);

	}


	echo '[{"absent":"'.$absent.'","Present":"'.$Present.'","Malpractice":"'.$Malpractice.'"}]';
?>
