gbateson / moodle-qtype_essayautograde

Essay (auto-grade) question type for Moodle >= 3.0
13 stars 12 forks source link

Generater renderer error #32

Open vrooyen opened 4 years ago

vrooyen commented 4 years ago

We've started implementing the auto-graded question and it works very well overall. However, we had two instances where it generated the following error:

Exception - Argument 2 passed to has_capability() must be an instance of context, null given, called in [dirroot]/question/type/essayautograde/renderer.php on line 205

It impacted the whole review of the quiz attempt. You can review each question separately, but the moment you want to review the whole quiz attempt, it generates this error and obviously also when you review the specific question. 9 students completed this quiz; 7 out of the 9 had no problems with it. In two cases (and it was not the same question), it generated this error.

For one question they had to write pseudocode. The other question was on Boolean Algebra. They had to simplify an equation.

gbateson commented 4 years ago

The code for the "renderer.php" script is here: https://github.com/gbateson/moodle-qtype_essayautograde/blob/master/renderer.php

If I look at that code, I notice two things: (1) line 205 does not refer to "has_capability(...)", but lines 244 and 247 do. (2) before lines 244 and 247, there is a "if (...)" that explicitly tests whether or not the "context" attribute is null.

Therefore, it looks to me to be impossible for the "has_capability(...)" to be executed if the context is missing. How puzzling.

vrooyen commented 4 years ago

I found out what is causing the error. If a student submitted an empty answer, the system generates a null value (represented on screen by the -), I assume. If the lecturer overrides this mark with a 0, it causes the error.

gbateson commented 4 years ago

I see. I'll try to replicate the error on my development server.