title: Retrieve all questions of a Moodle quiz
body: <p>I've a Moodle Quiz on 2 different pages (2 questions on the first and 1 on the second) and I'd like to retrieve those 3 questions.</p>
  
  <p>I use this code :</p>
  
  <pre><code>function getQuiz(IdQuiz){
    ajaxRequest("mod_quiz_start_attempt",{quizid:IdQuiz,forcenew:1}).success(function(quiz){
      getQuestions(quiz.attempt.id,0);
    });
  }
  
  function getQuestions(idAttempt,currentPage){
    ajaxRequest("mod_quiz_get_attempt_data",{attemptid: idAttempt, page: currentPage}).success(function(response){
      console.log(response);
      if (response.nextpage &gt; -1){
        getQuestions(idAttempt,currentPage+1);
      }else{
        console.log('stopped');
      }
    });
  }
  </code></pre>
  
  <p>It correctly get the 2 first questions of the first page but then for the second page, the response does not give me the question but tells me this on the console :</p>
  
  <pre><code>Object {exception: "dml_missing_record_exception", errorcode: "invalidrecord", message: "Can not find data record in database table quiz_attempts."}
  </code></pre>
  
  <p>It is strange because I works when I modify the first function like that :</p>
  
  <pre><code>function getQuiz(IdQuiz){
    ajaxRequest("mod_quiz_start_attempt",{quizid:IdQuiz,forcenew:1}).success(function(quiz){
      getQuestions(quiz.attempt.id,0);
      getQuestions(quiz.attempt.id,1);
    });
  }
  </code></pre>
  
  <p>(ajaxRequest is simply a function that send an Ajax request to Moodle)</p>