Quiz devel: multiple-choice questions in "needsgrading" state

Quiz devel: multiple-choice questions in "needsgrading" state

Ray Morris -
回帖数:1

If question attempts have answers recorded, but they are the "needsgrading" state, which function(s) need to be called to get them graded?  Or should they be graded at the time that answers are saved?


Background:

I am updating the papercopy module to work with Using Moodle 2.8, and making some improvements.  The module follows roughly this series of steps:


$usage = question_engine::make_questions_usage_by_activity

foreach($quiz_questions

    $usage->add_question($question);

}

...


//enter the student's answers for each of the questions

foreach($slotsas$slot){

$usage->process_action($slot, array('answer' =>$set['Question'.$slot]-1));

}

...


question_engine::save_questions_usage_by_activity($usage);

$attempt=newstdClass();

$attempt->quiz =$this->quiz->id; ...

$attempt_object=new quiz_attempt($attempt, $this->quiz, $this->cm, $this->course, true);

$attempt_object->process_finish(time(), true);


The full code is here:

https://github.com/MorrisR2/moodle-quiz_papercopy/blob/create_user_if_not_exist/report.php


What we end up with is a quiz attempt shows in the reports, and clicking on "Review attempt" shows which answers were selected for the questions, but the questions are as-yet ungraded.  The "state" of the question attempts == $needsgrading. What needs to be done to have the questions / quiz graded?




回复Ray Morris

Re: Quiz devel: multiple-choice questions in "needsgrading" state

Tim Hunt -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像

I can't see anything obviously wrong on a quick skim of your code, but you must be missing something because the question engine works for everyone else.

Try comparing the output of this query https://docs.moodle.org/dev/Overview_of_the_Moodle_question_engine#Detailed_data_about_an_attempt for two quiz attempts (usages), one created by your code, and one created using Moodle's quiz module. That might give you the necessary clues.