<?php
defined('BASEPATH') OR exit('No direct script access allowed');
if(!isset($this->session->userdata['logged_in']))
{
	redirect('admin','refresh');
}

?><!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Edit Tests</title>
</head>
<body>

<div id="container">
	<h3>Edit Test</h3>
	<a href="<?php echo base_url();?>dashboard/manage_tests">Cancel</a>
	<div id="body">
	<?php
	echo "<div class='error_msg'>";
	if (isset($error_message)) {
	echo $error_message;
	}
	echo validation_errors();
	echo "</div>";
	?>	
	<?php
		if(!empty($results))
		{
			foreach ($results as $result) {
	?>


		<?php echo form_open();?>
		<div>
			<?php echo form_label('Subject Name');?>
			<select name="subname">
				<option>Choose Subject</option>
				<?php
				

					foreach ($subjects as $subject) {

					if($result->subid == $subject->sub_id)
					{ 
				?>
						<option value="<?php echo $subject->sub_id; ?>" selected><?php echo $subject->sub_name;?></option>		
				<?php	
				} }
				?>
			</select>	
		</div>
		
		<div>
			<?php echo form_label('Test Name');?>
			<?php echo form_input(array('type'=>'text', 'name'=>'testname','placeholder'=>'Enter Testname','value'=>$result->testname));?>	
		</div>
		<div>
			<?php echo form_label('Test Description');?>
			<?php echo form_textarea(array('name'=>'testdesc','placeholder'=>'Enter Test description','value'=>$result->testdesc));?>	
		</div>
		<div>
			<?php echo form_label('Number of Questions');?>
			<?php echo form_input(array('type'=>'text', 'name'=>'qnum','placeholder'=>'Enter number of questions','value'=>$result->totalquestions));?>	
		</div>
		<div>
			<?php echo form_label('Duration(mins)');?>
			<?php echo form_input(array('type'=>'text', 'name'=>'mins','placeholder'=>'Enter test duration','value'=>$result->duration));?>	
		</div>
		<div>
			<?php echo form_label('Test From');?>
			<?php echo form_input(array('type'=>'date','name'=>'from','placeholder'=>'Test From', 'value'=>$result->testfrom));?>	
		</div>
		<div>
			<?php echo form_label('Test To');?>
			<?php echo form_input(array('type'=>'date','name'=>'to','placeholder'=>'Test to','value'=>$result->testto));?>	
		</div>
		<div>
			<?php echo form_label('Test Code');?>
			<?php echo form_input(array('name'=>'tcode','placeholder'=>'Enter Test code','value'=>$result->testcode));?>	
		</div>
		<div>
			
			<?php echo form_input(array('type'=>'submit','name'=>'submit','value'=>'Save'));?>	
			<input type="reset" name="reset" value="Reset">
		</div>

		<?php echo form_close();?>
		<?php } 
		}
		else
		{ ?>
			<p>No tests found</p>
		<?php 
		}
		?>
	</div>
</div>
</body>
</html>