require_once "includes/setup.php"; // add this here as not required for some pages (which use Quiz.php instead) require_once $include_dir . "Quizzes.php"; // debug will prevent javascript being included in headers if ($debug) { print "Loading Quizzes \n"; } // get all the quizzes and add to object $all_quizzes = new Quizzes(); $quiz_array = $qdb->getQuizzesAll(); // add this one to allQuizzes foreach ($quiz_array as $this_quiz_array) { $all_quizzes->addQuiz(new Quiz($this_quiz_array)); } // No quizzes found - most likely not setup if ($all_quizzes->count() < 1) { header("Location: " . FIRST_FILE); exit(0); } // header template - moved to later to allow embed javascript // still use normal header / footer // it's the javascript print option where we use offline headers instead //$templates->includeTemplate('header', 'normal'); if ($debug) { print "Reading parameters \n"; } // first look for url get as expired (indicates question.php send us here due to an expired entry) // we don't do anything differently other than tell the user that's why they were redirected there if (isset($_GET['status']) && $_GET['status'] == 'expired') { // todo - make customisable $message = "Session expired";
$action = 'next'; break; } } else { $action = 'save'; } // we validate all details before storing them into an array (we then use this to save to DB) $post_details = array(); // store quizzes seperately as those are not saved in the question table in the DB $post_quizzes = array(); // Quizzes // we need to check all possible quizzes if ($debug) { print "Quizzes: "; } for ($i = 0; $i < $all_quizzes->count(); $i++) { if (isset($_POST["quiz_" . $i])) { // only add if is a valid quiz - if invalid we just ignore if ($all_quizzes->validateQuizname($_POST["quiz_" . $i])) { $post_quizzes[] = $_POST["quiz_" . $i]; if ($debug) { print $_POST["quiz_" . $i] . " "; } } } } if ($debug) { print "\n"; } // If this is just a next no save // this will redirect with a header - we do not continue after this point