<?php
	class cExamDetailPage extends cStudentPage
	{  	 
    function Process()
    {
      return true;
    }

		function Draw()
    {
      if ( !$this->bLoggedIn )
      {
        $this->smarty->display("login.tpl");
      }
      else
      {
	      $examId = $this->getParams["itemId"];
	
				// naplnit exam hodnotami ako nazov predmetu, datum skusky, bodmi spolu, finalnou znamkou, poznamkou k terminu, pozn. k studentovi
	      $query = "SELECT C.id AS courseId, C.name, E.date, T.mark, T.comment AS userComment, E.comment AS examComment, T.points
									FROM tExam AS E 
									INNER JOIN tCourse AS C ON C.id = E.id_course
									INNER JOIN tScale AS S ON S.id = C.id_scale
									INNER JOIN tTest AS T ON T.id_exam = E.id
									WHERE T.id_user='".$_SESSION['userId']."' AND E.id='$examId';";
	      $this->AssignQueryResult($query,'exam','noarray');
	
				// naplnit points hodnotami bodov dosiahnutych v teste !!! TODO: pozor na index a na poradie otazok !!!
	      $query = "SELECT TA.points, TA.answerType
									FROM tExam AS E 
									INNER JOIN tTest AS T ON T.id_exam = E.id
									INNER JOIN tTestAnswer AS TA ON TA.id_test = T.id
									WHERE T.id_user='".$_SESSION['userId']."' AND E.id='$examId';";
	      $this->AssignQueryResult($query,'points','array');
	
	      $this->smarty->assign("content", "examDetail.tpl");
	      parent::Draw();
	    }
    }
	}
?>
