I think I resolved this issue. At least for PostgreSQL, the problem is with the function quiz_get_total_qas_graded_and_ungraded. The query uses the following expression to compute the number of graded attempts:
sum(qs.event in (...)) as gradedattempts
This does not work in PostgreSQL because sum expects an integers, and "... in ..." returns a boolean. This needs to be changed to use the cast operator. My final revision of this function is as follows:
function quiz_get_total_qas_graded_and_ungraded($quiz, $questionids, $userids){
global $CFG;
$sql = "SELECT qs.question, COUNT(1) AS totalattempts, " .
"sum(cast ((qs.event IN (".QUESTION_EVENTS_GRADED.")) as integer)) AS gradedattempts " .
"FROM " .
"{$CFG->prefix}quiz_attempts qa, " .
"{$CFG->prefix}question_sessions qns, " .
"{$CFG->prefix}question_states qs " .
"WHERE " .
"qa.quiz = {$quiz->id} AND " .
"qa.userid IN ({$userids}) AND " .
"qns.attemptid = qa.uniqueid AND " .
"qns.newgraded = qs.id AND " .
"qs.question IN ({$questionids}) " .
"GROUP BY qs.question";
return get_records_sql($sql);
}
I tried this with my local Moodle installation and it fixed the reported problem.
Also, personally I think the yellow-highlighted is not accessible nor good looking, what do people think?