Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated: ucwords(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/moodle/question/type/coderunner/renderer.php on line 741 #180

Open
timhunt opened this issue Nov 8, 2023 · 1 comment

Comments

@timhunt
Copy link
Collaborator

timhunt commented Nov 8, 2023

We are seeing this notice for some questions, running with PHP 8.1

Deprecated: ucwords(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/moodle/question/type/coderunner/renderer.php on line 741

It seems that the code which determines $currentlanguage is getting null, and then ucwords does not like that. Obviously, changing to ucwords($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

if (empty($question->acelang)) {
and
$currentlanguage = $question->acelang ? $question->acelang : $question->language;
. I wonder if it would be worth moving that into a helper function?

@trampgeek
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants