Open timhunt opened 1 year ago
Thanks for checking Tim. Indeed there must be an underlying problem for this to be happening. It implies that either the student's answer or the sample answer is being displayed in an unknown language, which at very least will mean no syntax colouring.
Much of the complexity, and the reason for the two somewhat different bits of code, stems from the multilanguage question type. This was initially a temporary hack but - as they so often do - it stuck around. I'm inclined to suspect the multilanguage question is the cause of the problem you're seeing but I can't immediately see how. Do you have a repeatable scenario that leads to this problem? If not, are you able to confirm please whether anyone in your institution is using multilanguage questions? We never use them ourselves, except for the in-house programming contest question type.
And certainly there is room for some refactoring here. But I'd first like to know what's causing the problem you're seeing.
We are seeing this notice for some questions, running with PHP 8.1
It seems that the code which determines
$currentlanguage
is getting null, and then ucwords does not like that. Obviously, changing toucwords($currentlanguage ?? '');
make the notice go away, but that might hide a real issue. @trampgeek, I though I would check with you before changing anything.(Also, while looking at this, I noticed there were two similar but different chunks of code at https://github.com/trampgeek/moodle-qtype_coderunner/blob/7ba87a110d33ce4ef5002a2365b2e3d594e5febe/renderer.php#L97 and https://github.com/trampgeek/moodle-qtype_coderunner/blob/7ba87a110d33ce4ef5002a2365b2e3d594e5febe/renderer.php#L508. I wonder if it would be worth moving that into a helper function?