<?php require "_header.php";?>
<script language="javascript" type="text/javascript">
document.getElementById("main-content").style.display = 'none';
</script>
<style type="text/css">
	.table-report{
		font-family:Verdana, Geneva, sans-serif;
		font-size:12px;
		text-align:left;
		border-right:0px none;
		border-bottom:0px none;
	}
	.table-report-inner{
		font-family:Verdana, Geneva, sans-serif;
		font-size:12px;
	}
	.table-report tr{
		padding:2px 2px 2px 2px;
	}
	.table-report td{
		padding:2px 2px 2px 2px;
		border-top:0px none;
		border-left:0px none;
	}
	.table-report th{
		padding:2px 2px 2px 2px;
		font-weight:bold;
		text-align:left;
		border-top:0px none;
		border-left:0px none;
	}	
	.break { page-break-before: always; }
</style>
<div id="main-report">
<?php
if($_SESSION['aCollegeId']!="" && isset($_SESSION['aCollegeId'])) 
{ 	
	$student_id 	= $_SESSION['student_id'];
?>
<center><h4>Faculty Feedback Report</h4></center>
<br /><br/>
    <?php 
	   		$qry ="SELECT 
							que_ids,
							group_concat(answer_arr SEPARATOR '|||') as all_answer,
							sub.subject_name,
							emp.employee_name,
							count(*)as total_row
							
						FROM 
							`feedback_que_result` fb,
							`cms_subjectmaster` sub,
							`cms_employeemaster` emp
						WHERE 
							fb.employee_id = emp.employee_id AND
							fb.subject_id = sub.subject_id 
							and emp.employee_active='Yes' 
							group by fb.subject_id,fb.`employee_id` ";
//				AND fb.`employee_id`='73'
				$result1=dbQuery($qry);
				if(dbRows($result1)>0) {
					?>
	<table class="table-report" border="1" cellpadding="0" cellspacing="0" width="100%" >
		<tr style="background-color:#CCC;">
        	<th width="07%" style="text-align:center; font-weight:bold;font-size:12px ">SrNo.</th>
            <th width="54%" style="text-align:center; font-weight:bold;font-size:12px ">Questions</th>
            <th width="18%" style="text-align:center; font-weight:bold;font-size:12px ">Answer</th>
        </tr>
					<?php 
					while($row=dbArray($result1))
					{	$srno = 1;
						$all_student_answer=explode('|||',$row['all_answer']);
						$Questions = explode(",", $row['que_ids']);
						$Answers = explode(",", $row['answer_arr']);
						?>
		<tr>
        	<th colspan="4" style="font-weight:bold;font-size:10px;font-size:12px; " ><?php echo $row['subject_name'].'  -  '.$row['employee_name']; ?></th>
        </tr>
         <?php $que = "SELECT que_id,question,ans_a,ans_b,ans_c,ans_d
						FROM `feedback_que_master` ORDER BY que_id" ;
				$res_ques=  dbQuery($que); 
				$i=0;
				while($row_ques=dbArray($res_ques))
				{	
				
		?>
		<tr>
        	<td style="text-align:center;"><?php echo $srno; ?></td>
          	<td style="text-align:left;">&nbsp;&nbsp;<?php echo $row_ques['question']; ?></td>
          	<?php if($Questions[$i] == $row_ques['que_id']){ 
			?>
            <td>
            <?php
				$string="";
				for($k=0;$k<count($all_student_answer);$k++){
						$saprate_array=explode(',',$all_student_answer[$k]);
						$string.=$saprate_array[$i].',';
				}
			?>
             <table width="100%" >
               	<tr>
                        <td>A:</td><td><?php echo $row_ques['ans_a'];?></td><td><?php echo substr_count($string, 'a');?></td>
                    </tr>
                    <tr>
                        <td>B:</td><td><?php echo $row_ques['ans_b'];?></td><td><?php echo substr_count($string, 'b');?></td>
                    </tr>
                    <tr>
                        <td>C:</td><td><?php echo $row_ques['ans_c'];?></td><td><?php echo substr_count($string, 'c');?></td>
                    </tr>
                    <tr>
                    	<td>D:</td><td><?php echo $row_ques['ans_d'];?></td><td><?php echo substr_count($string, 'd');?></td>
                   </tr> 
                </table>
				</td>
           	<?php  } ?>
       	</tr>
            <?php $srno ++; 
					$i++;
			
			} } ?>
	</table>
<?php
	}
	else{
		echo "NO DATA FOUND!";	
	}
}
	?>
</div>
<?php 
	require "_footer.php";
?>