Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require "../functions/functions.php";
- require_once "../config/db_connection.php";
- global $conn;
- $user_id = $_POST['userid'];
- $subj_id = $_POST['subjID'];
- $term = $_POST['term'];
- $sql = "SELECT sa_questionid, sa_studanswer FROM tbl_studentanswer WHERE sa_userid = '{$user_id}'";
- $studentAnswersQuery = mysql_query($sql,$conn);
- $answered = 0;
- $questions = 0;
- $total = 0;
- $finalTotal = 0;
- $today = date("F j, Y");
- while($studentAnswers = @mysql_fetch_assoc($studentAnswersQuery))
- {
- $sql = "SELECT answer_id FROM tbl_questions WHERE QUERY_ID = {$studentAnswers['sa_questionid']}";
- $questionRecordsQuery = mysql_query($sql,$conn);
- if($questionRecords = @mysql_fetch_assoc($questionRecordsQuery))
- {
- if($questionRecords['answer_id'] == $studentAnswers['sa_studanswer'])
- {
- $answered++;
- }
- }
- $questions++;
- }
- //housekeeping
- $sql = "DELETE FROM tbl_studentanswer WHERE sa_userid = '{$user_id}'";
- mysql_query($sql,$conn);
- $sql = "INSERT INTO tbl_studentgrade(g_studid, g_subjectid, g_score, g_term, g_datetaken) VALUES('$user_id', '$subj_id', $answered, $term, '$today')";
- mysql_query($sql,$conn);
- //move
- header("Location:../student/takeexam.php");
- ?>
Add Comment
Please, Sign In to add comment