<?php header("Access-Control-Allow-Origin: *");
  header("Access-Control-Allow-Headers: *");  

  header('Content-Type: application/json');

  include '../db/connectMe.php';   
  include '../function/function.php';  

  //quiz questions

  if (@$_GET['q'] != "" ) {

      @$quizId = mysql_prep($_GET['q']);

      $questions = find_all_quiz_questions($quizId, 1);
      $i = 0; 

      $quests = [];

      foreach ($questions as $question[] ) {

        
        $options = find_all_quiz_question_options($question[$i]->id, 1);

        $question[$i]->options = $options;
        $quests = json_encode($question);

        $i++;

      }

      exit($quests);


  }else {
    exit(json_encode([]));
  }  
