Thanks to visit codestin.com
Credit goes to github.com

Skip to content

After Upgrade to Moodle 5 all Coderunner questions stop working: missing prototype #255

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

Open
tbutsch opened this issue Jun 1, 2025 · 6 comments

Comments

@tbutsch
Copy link

tbutsch commented Jun 1, 2025

We upgraded to Moodle 5. Without any errors. And we upgraded to newest qtype-coderunner. No errors.

Now all the questions do not work anymore. Please see the attached screenshots.

Image Image Image
@trampgeek
Copy link
Owner

Prior to Moodle5.0, all the built-in prototypes were in a question category CR_PROTOTYPES at the system level. In Moodle 5.0 there is no such category. So instead, the prototypes are stored in a System Shared Question Bank belonging to the front page course. This should have been created and populated during the install.

To check what's happened, you need to be a Moodle administrator. Login to the site and click the Home link at the top (in the list Moodle5.0, Home, Dashboard, My courses, ...). That puts you in the Front Page context, and you should see a list of links Home, Settings, Participants, Reports, Question banks, More. Click the Question banks link.

You should see a System shared question bank in that context. Do you?

Image

If so, click the link to it. What questions do you find? You should have a set with names beginning BUILTIN_PROTOTYPE. Do you?

Image

@tbutsch
Copy link
Author

tbutsch commented Jun 2, 2025

I found them. But I have three of them. Please see attached screenshots.

Image
Image
Image
Image

@trampgeek
Copy link
Owner

Certainly there should be only one such question bank containing exactly one copy of those prototypes. Multiple copies will break CodeRunner.

I see the first question bank is dated 29 January, well before the main release of Moodle 5.0 and before the required CodeRunner updates. Is that a wrong date, or were you using pre-release/development versions of the code?

I don't know how the multiple copies of the question bank have happened - the code should check for the existence of that question bank before creating it. Please let me know if you have any recollections of odd things happening or other suggestions.

For now, though, I suggest you delete all the BUILT_IN_PROTOTYPE CodeRunner questions from the first two sets (dated 29 January and 23 May). You can probably also delete the question banks themselves unless there are other questions besides CodeRunner prototypes in them. Let me know if that solves the immediate problem.

@faisalm-pk
Copy link

faisalm-pk commented Jun 10, 2025

I am facing the same issue as the owner of this post.

I can see the BUILT_IN_PROTOTYPE and can create and use the CodeRunner questions in that front page course. But the same error as mentioned above is shown in all of the other courses, and I also can not find any question type in the drop-down. It is working fine on the backup site (Moodle v4.5.3+ and CodeRunner v5.7.1+) but facing the above issues in Upgraded site (Moodle v5.0.1 and CodeRunner v5.7.1+).

I have updated the CodeRunner Plugin to v5.7.1+ before Moodle upgrade from 4.5.3 to 5.0.1, I was not able to reinstall the plugin as it is already the latest version. I did the following.

  1. Deleted the front course question banks.
  2. Renamed the only remaining system question bank to something xyz (I think at-least 1 question bank is mandatory).
  3. Edited the CodeRunner plugin version file and incremented the last digit of version by 1.
  4. Reinstalled (kind of update by incrementing the version by 1) and it installed successfully.
  5. It created the "System shared question bank", I deleted the previous xyz Question Bank.

Still the same issue as mentioned above.... Kindly let me know if I am missing something?

It also creates a new "System shared question bank" whenever I update the plugin by incrementing the version by 1. Also in the previous installation there was a category "SQL Prototype and samples (Experimental)" which was also available in "System shared question bank" when I upgraded the Moodle but I can not see it after the above steps but CR_PROTOTYPES.

For now I am reverting to Moodle 4.5.3 as we have exams this week. Hope you will find time to look into this soon. Thanks for your time and efforts.

@trampgeek
Copy link
Owner

Thanks for reporting. Reverting to Moodle 4.5 for the exam was certainly the right call. Upgrading just before exams was a trifle ... brave?! Did you notice in the release notes for the latest version of CodeRunner I describe Moodle 5.0 support as alpha-level? It runs all the tests on my system and I can't replicate the problems you're having, but there are complexities with shared question banks that haven't been tested in a production environment.

It's difficult to debug your problems since I can't replicate them. Certainly on my Moodle 5.0 system, if I bump the version number I do not get a new system shared question bank.

Can you confirm, please that:

(a) The new system shared question banks you were getting were in the front course, not in "normal" courses?
(b) That the newly created (extra) system shared question banks each had a question category CR_PROTOTYPES and that all the usual CodeRunner BUILT_IN_PROTOTYPE_xxxx questions were present in it?

It's odd that you're getting multiple instances of the system shared question bank in the front course, because that question bank is created by a Moodle core function that I call during updates: "get_default_open_instance_system_type()". It's defined to return the system type qbank instance for a given course (the 'front' course in this case) with an option to create it if it doesn't exist. As a comment in the function itself says "We should only ever have 1 of these". This is not my code!

Certainly the duplication of those questions will break CodeRunner. But I would like someone to confirm, please, that eliminating that duplication by deleting all but one of the sets of prototypes, at least gets CodeRunner going again?

@lucaboesch
Copy link
Contributor

This would be fixed by https://tracker.moodle.org/browse/MDL-84695.
The necessary code is there.
Only thing: on MSSQL, which I cannot test, an automated test seems not running.

In my installation, I hotfixed by taking the code there.

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

4 participants