}
// get mode from the post - popup we don't show menus - otherwise we do
// also show offline header / footer for popup - but normal for basic
// The type can be either on post or get
if (isset($_POST['type']) && $_POST['type'] == 'popup' || isset($_GET['type']) && $_GET['type'] == 'popup') {
    $mode = 'popup';
    $template_mode = 'offline';
} else {
    $template_mode = 'normal';
}
// Pull in templates
$templates->includeTemplate('header', $template_mode);
$quiz_info = $quiz_session->getSessionInfo();
// print titles
// could get quizname from $quiz_session, but we've already got it from before into quiz_info array
print "<h1>" . $this_quiz->getTitle() . "</h1>\n";
print "<h1>Answers " . $quiz_session->getOfflineId() . "</h1>\n";
print "<p>Please ensure that the serial number above matches the question sheet.</p>\n";
// load and print the questions
for ($i = 0; $i < count($questions_array); $i++) {
    // load this question - note -1 used to select array position (ie. question 1 = array 0)
    $question = new Question($qdb->getQuestion($questions_array[$i]));
    print "<h2>Question " . ($i + 1) . "</h2>\n";
    if ($show_question) {
        print $question->getOfflineHtmlString();
    }
    print "<p class=\"" . CSS_CLASS_ANSWER_REASON . "\">\n";
    print $question->getReason();
    print "</p>\n";
}
// add navigation buttons - if we are not in popup mode (move to answers)
 public function CreateAQuiz($data)
 {
     // denna skapar quizen
     $title = "";
     // sätter titeln till tom
     $description = "no description";
     if (isset($data["title"]) && trim($data["title"]) != "") {
         $title = $data["title"];
     }
     if (isset($data["description"]) && trim($data["description"]) != "") {
         $description = $data["description"];
     }
     $quiz = new Quiz($title, $description);
     if ($data["questions"] == null || $title == "") {
         throw new Exception("No questions in quiz");
     }
     if (strip_tags($title) != $title || strip_tags($description) != $description) {
         throw new Exception("No tags in my quiz");
     }
     $questioncount = 0;
     foreach ($data["questions"] as $q) {
         if (strip_tags($q["title"]) != $q["title"]) {
             throw new Exception("No tags in questions in my quiz");
         }
         if (!isset($q["options"])) {
             continue;
         }
         $options = array();
         $correcModifier = 0;
         $currentOption = 1;
         foreach ($q["options"] as $o) {
             if (trim($o) == "") {
                 if ($q["correct"] > $currentOption) {
                     // om den optionen man är på är mindre än den option som är rätt så plussar den på correct svaret
                     $correcModifier++;
                 }
                 $currentOption++;
                 //och plussar på den man är på så man kan kolla nästa
                 continue;
             }
             if (strip_tags($o) != $o) {
                 throw new Exception("No tags in option in my quiz");
             }
             $currentOption++;
             array_push($options, $o);
             //lägger in allt i arrayen
         }
         if (count($options) == 0) {
             continue;
         }
         $correct = min($q["correct"] - 1 - $correcModifier, count($options) - 1);
         //denna modifiererar den tar det lägsta i options och sätter om det rätta till den nya anpassade listan (Fick hjälp med denna!)
         $questioncount++;
         $quiz->addQuestion(new QuizQuestion($q["title"], $options, $correct));
     }
     if ($questioncount == 0) {
         throw new Exception("No questions in quiz");
     }
     $count = "";
     while (file_exists("Model/quizes/" . $quiz->getTitle() . $count . ".bin")) {
         if ($count == "") {
             $count = 1;
         } else {
             $count++;
         }
     }
     $this->quizDAL->writeToBin("Model/quizes/" . $quiz->getTitle() . $count . ".bin", $quiz);
 }