<?php
	
	require "../commonincludefiles.php";
	
	$subject_id = Escape($_POST['subject_id']);	
	$employee_id= Escape($_POST['employee_id']);
	if($_SESSION['f_student_id']==""){
		$_SESSION['f_student_id']=$_SESSION['student_id'];
	}
	$qry="";
	$qry = "select * From feedback_que_result  Where subject_id ='$subject_id' and employee_id='$employee_id' and student_id = '".$_SESSION['f_student_id']."' ";
	$rs = dbQuery($qry);
	if(dbRows($rs) > 0){
		$total = dbRows($rs);
		$SubjectData = array("count" => $total, "data" => array());
		echo json_encode($SubjectData);
	}
	else
	{
	
	$qry = "select * From feedback_que_master  Where 1=1 ";
	$rs = dbQuery($qry);
	$i=0;
	$total = dbRows($rs);
	$SubjectData = array("count" => $total, "data" => array());
	if(dbRows($rs) > 0){
		while($row = dbArray($rs)){
					$temparray["que_id"] = $row["que_id"];			
					$temparray["chapter_added"] = '../images/fail.png';		
					$temparray["question"] = stripcslashes($row["question"]);
					$temparray["ans_a"] = stripcslashes($row["ans_a"]);
					$temparray["ans_b"] = stripcslashes($row["ans_b"]);
					$temparray["ans_c"] = stripcslashes($row["ans_c"]);
					$temparray["ans_d"] = stripcslashes($row["ans_d"]);
					$SubjectData["data"][$i] = $temparray;   
					$i++;
				
	}
	}
	echo json_encode($SubjectData);
	
	}
?>