auth(); //print_array($_SESSION);die(); // initialize variables needed on this page $username = $_SESSION['name']; $course = getCourse($_SESSION['courseId'])[0]; if (isset($_SESSION['start'], $_SESSION['active_test_id'])) { $testId = $_SESSION['active_test_id']; list($score, $numQuestions, $percent) = markTest($testId); } elseif (isset($_SESSION['prev_test_id'])) { $testId = $_SESSION['prev_test_id']; } else { redirect('resource/error2'); exit; } // remove all session variables created for the active test list($score, $numQuestions, $percent) = markTest($testId); unset($_SESSION['start']); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> <title>Grading Page</title> <!-- Bootstrap --> <link href="css/bootstrap.min.css" rel="stylesheet"> <link rel="stylesheet" type="text/css" href="css/grading.css">
if ($count == 0) { $output = "<span style='margin-left:20px'>Nothing found</span>"; } else { while ($row = mysql_fetch_array($result)) { $name = $row['name']; $output .= '<a href="department.php?collegeid=' . numEncrypt($row['college_id']) . '"style="font-size:14px; color:white; margin-bottom: -20px;">' . $name . '</a>'; } } echo $output; } } elseif (isset($_POST['save'])) { if (isset($_SESSION['active_test_id'])) { $testId = $_SESSION['active_test_id']; $feedback = ''; //$feedback['testid'] = $_SESSION['active_test_id']; list($numCorrect, $numQuestions, $percent) = markTest($testId); $score = "You scored " . $numCorrect . " out of " . $numQuestions . " representing " . $percent . "%"; // save score and related information $courseId = $_SESSION['courseId']; $userId = $_SESSION['user_id']; $query = select("SELECT * FROM test_info WHERE test_id ='{$testId}'")[0]; if ($query['course_id'] == 0) { $queryRun = mysql_query("UPDATE test_info SET course_id = '{$courseId}', score = '{$percent}' WHERE test_id = '{$testId}'") or die(mysql_error()); $queryRun2 = mysql_query("UPDATE users SET tests_taken = tests_taken + 1 WHERE id = '{$userId}'"); if ($queryRun == true && $queryRun2 == true) { $feedback = "Your test information has been saved"; } else { $feedback = "Sorry. Could not save test information"; } } elseif ($query['course_id'] != 0 && $query['paused'] == 0) { $queryRun = mysql_query("UPDATE test_info SET course_id = '{$courseId}', score = '{$percent}' WHERE test_id = '{$testId}'") or die(mysql_error());