【问题标题】:Retrieve all questions of a Moodle quiz检索 Moodle 测验的所有问题
【发布时间】:2017-04-13 18:04:56
【问题描述】:

我在 2 个不同的页面上有一个 Moodle 测验(第一页有 2 个问题,第二个有 1 个问题),我想检索这 3 个问题。

我使用这个代码:

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 > -1){
      getQuestions(idAttempt,currentPage+1);
    }else{
      console.log('stopped');
    }
  });
}

它正确地得到了第一页的 2 个第一个问题,但是对于第二页,响应没有给我问题,而是在控制台上告诉我:

Object {exception: "dml_missing_record_exception", errorcode: "invalidrecord", message: "Can not find data record in database table quiz_attempts."}

这很奇怪,因为我在修改第一个函数时工作:

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);
  });
}

(ajaxRequest 只是一个向 Moodle 发送 Ajax 请求的函数)

【问题讨论】:

    标签: javascript moodle moodle-api


    【解决方案1】:

    我自己解决了!实际上是因为我试图访问一个已经完成的测验(代码在我不知情的情况下执行了多次)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-11
      • 1970-01-01
      相关资源
      最近更新 更多