Issue with CodeRunner Prototypes in Moodle 4.6/5.0

Re: Issue with CodeRunner Prototypes in Moodle 4.6/5.0

by Richard Lobb -
Number of replies: 6
Many thanks for the extra test info, Luca. Very helpful.

I've pushed an update that I think should solve the problem. Because the moodle5 qbank module isn't available during installs, I was deferring question prototype updates when running Moodle 5.0 installs do a post-install task. It seems I have to do the same for Moodle 5.0 updates.

I have done pretty minimal testing (just run the version upgrade on Moodle 4.5 and Moodle 4.6) as (a) it's Sunday and (b) I'm teaching a course with over 1000 students at present, so software development time is minimal. But the changes are pretty simple so I don't think it's likely I've broken anything and I *should* have at least fixed the bug you're reporting. Please confirm.

Thanks again for the help with testing.
In reply to Richard Lobb

Re: Issue with CodeRunner Prototypes in Moodle 4.6/5.0

by Luca Bösch -
Thanks to you, Richard!

The update passed and I can see the PROTOTYPE questions in the right spot I think but two things tell me something is not yet as expected: the 'create question' dialogue finding no prototype and a "Broken question (missing or duplicate prototype 'java_method'). Cannot be run." notification.


In reply to Luca Bösch

Re: Issue with CodeRunner Prototypes in Moodle 4.6/5.0

by Richard Lobb -
Hi Luca

I've moved this discussion to the developers forum while we get things sorted out.

I don't know why it's not working for you. We've just run a test, upgrading a Moodle 4.5 server with serveral courses to Moodle 5.0 and the existing questions work fine. However, we did do the upgrade with the development branch of coderunner in place, which you didn't do, so that might be a factor. All the same, if the prototypes are present in the Front Page question bank, you shouldn't be seeing the errors you're seeing since the new version of the code includes that context in all searches for prototypes.

So, can you clarify what you mean when you say "I can see the PROTOTYPE questions in the right spot I think", please?

On my Moodle 5.0 system, if I click the Home link (taking me to the Front Page course), and then choose the Question banks link, I get told that the "Question banks in this course" are the System shared question bank (a link). When I click that link I see all the CodeRunner built-in prototypes.

Is that working for you?

Richard
In reply to Richard Lobb

Re: Issue with CodeRunner Prototypes in Moodle 4.6/5.0

by Luca Bösch -
Hi Richard.
Yes I can see this System shared question bank with the CodeRunner built-in prototypes.
However it seems to me that in a course, I can only create/run CodeRunner questions when a prototypes exists within that course. If there is no prototype in the course question bank neither the question runs properly nor the chooser for the type in a CodeRunner question shows any option.
The impression is that somehow the prototypes in that System shared question bank in the front page course can't be 'seen' from anywhere.
In reply to Luca Bösch

Re: Issue with CodeRunner Prototypes in Moodle 4.6/5.0

by Luca Bösch -
Dear Richard.

I have been able to track back my issues to https://tracker.moodle.org/browse/MDL-84695.

Best,
Luca
In reply to Luca Bösch

Re: Issue with CodeRunner Prototypes in Moodle 4.6/5.0

by Richard Lobb -
Great catch! Many thanks Luca. A colleague and I had pored over the CodeRunner code looking for plausible explanations for your problem but had drawn a blank. We would certainly never have thought of that!

However, I'd like to better understand the bug, so I know when it will be relevant to me. The $defaultactivityname variable should normally be 'qbank', in which case the code would join only with the qbank table and all would be well, wouldn't it? The only fail case I can see is if the variable $CFG->corequestion_defaultqbankmod has been set to some value other than 'qbank'. Was that the situation on your site?

Thanks again for the debugging effort, saving me from lots more totally fruitless imaginings.

To clarify:
In reply to Luca Bösch

Re: Issue with CodeRunner Prototypes in Moodle 4.6/5.0

by Luca Bösch -
I'm happy to tell you this issue is resolved in Moodle upstream as of now. https://moodle.atlassian.net/browse/MDL-84695 is in the code base as of yesterday.
Either grab a weekly Moodle 5.0 release or, alternatively, wait for Moodle 5.0.2 due to be published August 11th, 2025.

Best,
Luca