hello,
I had the same problem, and I saw a similar error in this post but in the file_storage not in quiz: https://tracker.moodle.org/browse/MDL-34079
There was fixed by Pavel's fix: (http://odam.upol.cz/moodle_cron_mssql_patch.zip)
so I made quite the same change in cronlib.php, assigning the recordset to an array and everything start working properly, this way:
$attemptarray=array();
foreach ($attemptstoprocess as $attempt) {
$attemptarray[] = $attempt;
}
$attemptstoprocess->close();
foreach ($attemptarray as $attempt) {
// If we have moved on to a different quiz, fetch the new data.
if (!$quiz || $attempt->quiz != $quiz->id) {
$quiz = $DB->get_record('quiz', array('id' => $attempt->quiz), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('quiz', $attempt->quiz);
$quizcount += 1;
}
// If we have moved on to a different course, fetch the new data.
if (!$course || $course->id != $quiz->course) {
$course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST);
}
// Make a specialised version of the quiz settings, with the relevant overrides.
$quizforuser = clone($quiz);
$quizforuser->timeclose = $attempt->usertimeclose;
$quizforuser->timelimit = $attempt->usertimelimit;
// Trigger any transitions that are required.
$attemptobj = new quiz_attempt($attempt, $quizforuser, $cm, $course);
$attemptobj->handle_if_time_expired($timenow, false);
$count += 1;
}
unset($attemptarray);
return array($count, $quizcount);
I hope I've done it right...