<?php
ob_start();
require_once('operations.php');
session_start();
//require_once("include/initialize.php");  
error_reporting (E_ALL ^ E_NOTICE); 
 
 $db = new Operations();
//$admissionno =  $_SESSION["admissionno"];
//$examcode = $_SESSION['examcode'];

echo $admissionno.'<br>';

if(isset($_POST['choices'])) {
$choices = $_POST['choices'];
}
// $lessonid = $_POST['LessonID'];
$examcode = $_POST['examcode'];
$lname = $_POST['lname'];
$fname = $_POST['fname'];
$admissionno = $_POST['admissionno'];
$class2 = $_POST['class2'];

  $id = $_POST['id'];
    $chkcount = count($id);

//$myanswer = "";
$score = 0;
$date = date('Y-m-d');

for($k=1; $k<=$chkcount; $k++){
//echo $choices[$k].'<br>';

 // $exam->single_exercise($id[$k]);

 $db->getQuestionByID($id[$k]);



if(trim($choices[$k]) == trim($db->answer)){
	$score = $score + 1;
	//echo "answer ". $res->Answer.'<br>';
//echo "choices ".$choices[$k].'<br>';
	}

  $db->addExamAudit($examcode,$admissionno,$id[$k],$choices[$k],$date);	
	
}
//echo $score;
 //$stud = new Score();
 /*
 
 $stud->StudentID = $_SESSION['StudentID'];
 $stud->lname = $_SESSION['Lname'];
 $stud->fname = $_SESSION['Fname'];
 $stud->studusername = $_SESSION['USERNAME'];
 $stud->Score = $score;
 $stud->Score1 = $score;
$stud->LessonID = $lessonid;
$stud->Submitted = 1;
 $stud->create();


*/
$db->findExamsById($examcode);
 
//$db->updateScores($examcode,$admissionno,$score);

$db->addScores($db->subject_id,$examcode,$lname,$fname,$db->class,$admissionno,$score,$class2);


?>
  <h1 style="color:blue; font:bold">Exams Submitted successfully <span style="color:red"><strong> <?php // echo "  ". $score  ?></strong></span></h1>
  <a href="studentLogin.php">GO BACK</a>
  
  