I have reported this issue to the bug tracker.
Well, I'm new to the quiz code, but I was looking at the source code, I think I found where the problem is, but I would like to know if any Moodle soul can help me with this.
I have a quiz (name="Quiz 1", id=5 in mdl_quiz) consisting of only one question: an essay question (name="Question 1" id=9 in mdl_question).
Two students (student1 and student2) are part of the class and both of them have finished the quiz "Quiz 1".
Then as a course teacher I graded the answer from student1, and I realized that in the table mdl_question_states a new entry (id = 60) has been added for this question with event "9". I found that questionlib.php defines
define('QUESTION_EVENTMANUALGRADE', '9'); // Grade was entered by teacher
.. and that is correct.
The question for student2 is present in mdl_question_states with event "8" and Id ="63"
define('QUESTION_EVENTCLOSE', '8'); // The response has been submitted and the session has been closed, either because the student requested it or because Moodle did it (e.g. because of a timelimit). The responses have not been graded.
So, if I go now to the "Manual Grading" tab, it says "2" Ungraded questions.
If I add some "echo" to the function is_graded($question, $attempt) found at report/grading/report.php I found out that an SQL statement is being executed with the following output:
checking question 9 for user 5
state id is 59 and event es 7
checking question 9 for user 6
state id is 63 and event is 8
user 6 is student2 and user 5 is student1.
But wait, why user 5 returns event 7 and id 59 when it should be returning 9 and id 60?. The SQL statement is not returning the newest event!
the SQL statement executed in function is_graded includes the column "mdl_question_session.newest" in its WHERE clause. However, the newest column doesn't contain the last state id with the newest event of the question. Column "newgrade" actually contains the last state id.
I think something is wrong with this.