Viewing file: View_exam.php (4.21 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
require 'connection.php';
$exam_type=array();
$exam_details=array();
$result=array();
$category=$_REQUEST['category'];
$user_id=$_REQUEST['user_id'];
$type=$_REQUEST['type'];
$course_id=$_REQUEST['course_id'];
if($type=='Multiple choice'){
$p_type=1;
}
else if($type=='Comprehensive'){
$p_type=2;
}
$view_status=0;
if($category=='srishti campus'){
$sqldata="select * from tb_user where user_id='$user_id' and delete_status=0";
$resultdata=$con_it->query($sqldata);
$countdata=$resultdata->num_rows;
$row=$resultdata->fetch_assoc();
$phone=$row['phone'];
$query="SELECT *
FROM `user_details`
INNER JOIN enrolldetails ON user_details.user_id=enrolldetails.user_id where user_details.phone='$phone'";
$queryResult=$con->query($query);
$queryCount=$queryResult->num_rows;
$queryRow=$queryResult->fetch_assoc();
$userid=$queryRow['user_id'];
//echo $userid;
$exam="SELECT * FROM `exam` where batch_id=$course_id";
$examResult=$con->query($exam);
$examCount=$examResult->num_rows;
if($examCount>0){
while($value=$examResult->fetch_assoc()){
//print_r($value);
$time_id=$value['exam_id'];
$query="select no_of_correct_answer from exam_result where stud_id= $userid and exam_id= $time_id ";
$resultQuery=$con->query($query);
$row=$resultQuery->fetch_assoc();
$score_details=$row['no_of_correct_answer'];
if($userid==""){
$loc=$value['g_status'];
}
else{
$loc=$value['stu_status'];
}
if($score_details==''){
$view_status=0;
}
else{
$view_status=1;
}
$exam_type[]=array("id"=>$value['exam_id'],
"test_name"=>$value['exam_title'],
"test_type"=>$type,
"duration"=>$value['examtime'],
"no_of_ques"=>$value['examtime'],
"exam_access_code"=>"",
"exam_level"=>"",
"exam_company_code"=>"",
"exam_college_id"=>"",
"visibility"=>"",
"score"=>($score_details==null)?"":$score_details,
"view_status"=>$view_status,
"lock_status"=>$loc);
}
$result=array('status'=>true,
'message'=>$category.' '.'Exam exist',
'Exam_details'=>$exam_type);
}
else{
$result=array('status'=>false,
'message'=>'Exam does not exist',
'Exam_details'=>$exam_type);
}
}
else{
$sql="SELECT * FROM `exam_q_details` where main_type='$category' and test_type='$p_type'";
$result=$con_it->query($sql);
$count=$result->num_rows;
if($count>0){
if($value['test_name']==1){
$type='Multiple choice';
}
else if($value['test_name']==2){
$type='Comprehensive';
}
while($value=$result->fetch_assoc()){
$time_id=$value['time_id'];
$query="select score from exam_result where user_id= $user_id and exam_details_id= $time_id ";
$resultQuery=$con_it->query($query);
$row=$resultQuery->fetch_assoc();
$score_details=$row['score'];
if($score_details==''){
$view_status=0;
}
else{
$view_status=1;
}
$exam_type[]=array("id"=>$value['time_id'],
"test_name"=>$value['test_name'],
"test_type"=>$type,
"duration"=>$value['duration'],
"no_of_ques"=>$value['no_of_ques'],
"exam_access_code"=>$value['exam_access_code'],
"exam_level"=>$value['exam_level'],
"exam_company_code"=>$value['exam_company_code'],
"exam_college_id"=>$value['exam_college_id'],
"visibility"=>$value['visibility'],
"score"=>($score_details==null)?"":$score_details,
"view_status"=>$view_status,
"lock_status"=>"");
}
$result=array('status'=>true,
'message'=>$category.' '.'Exam exist',
'Exam_details'=>$exam_type);
}
else{
$result=array('status'=>false,
'message'=>'Exam does not exist',
'Exam_details'=>$exam_type);
}
}
echo json_encode($result);
?>
|