function endexam()
 {
     $db = new MYSQLDB();
     $_SESSION['isWritingExam'] = false;
     $res = $db->query("INSERT INTO exam_res (`exam_id`, `result`, `for`, `timestamp`, `top_id`, `username`) VALUES (NULL, '" . $_SESSION['corcount'] . "', '" . $_SESSION['for'] . "', '" . $_SESSION['time'] . "', '" . $_SESSION['top_id'] . "', '" . $this->username . "')");
     unset($_SESSION['currentqarray']);
     unset($_SESSION['corcount']);
     unset($_SESSION['currentqkey']);
     if (!$res) {
         echo "error submiting";
     }
 }