Bug in Editing Question Prototype?

Bug in Editing Question Prototype?

by Aleksi Postari -
Number of replies: 7

Hi,


We have Moodle Coderunner version 5.7.2+ 2025081500 (latest) installed. While trying to edit a question prototype, we get this error and cannot edit the question prototype:



The question does have these settings under the "Advanced Customization," and the prototype does work fine.


In reply to Aleksi Postari

Re: Bug in Editing Question Prototype?

by Aleksi Postari -
And Moodle version is also the latest (4.5.6+ (Build: 20250822))
In reply to Aleksi Postari

Re: Bug in Editing Question Prototype?

by Richard Lobb -

Are you trying to create a new prototype? If so, the sequence of actions needs to be:

  1. Create a new Question (selecting CodeRunner)
  2. Choose a question type to act as a starting point.
    • I agree this might seem redundant if you're creating some completely new prototype that doesn't have anything in common with the standard question types, but it's a necessary first step.
  3. Click Customise
  4. Expand the Advanced customisation panel and set Is prototype to Yes
You should then be able to proceed as normal.

If missing step 2 isn't the cause of your problem, please post back explaining what sequence of steps you used to get to the failing situation. Also let us know what version of Moodle you're running.

In reply to Richard Lobb

Re: Bug in Editing Question Prototype?

by Aleksi Postari -
The prototype has already been created and new prototypes can be successfully created. I am trying to edit an existing prototype question and get the error above while trying to save the question prototype.

Steps:
1. Navigate to Question bank
2. Select the question prototype to edit and click "Edit" > "Edit Question"
3. The Question type is set to "Undefined" and it cannot be edited
4. Try to press "Save changes and continue editing" and get the error "You must select the type of question"
In reply to Aleksi Postari

Re: Bug in Editing Question Prototype?

by Aleksi Postari -
EDIT:

I created a new question prototype with "Python3" selected as the "Question type". I only clicked "Customize" for the template. Upon saving the question prototype and clicking "Edit" to edit the prototype, the "Question type" has been reverted back to "Undefined" and it is no longer possible to save the prototype.

The only way i could edit the prototype was by opting it out of being a prototype, changing the question type back to Python3, and putting the customisation options back in, changing it back to prototype and saving it. But that sounds like it should not work like that.
In reply to Aleksi Postari

Re: Bug in Editing Question Prototype?

by Richard Lobb -
Certainly that's not how it should behave. But I can't replicate the problem.

I just did the following with CodeRunner 5.7.2+ on Moodle 4.5.4+:
  1. Created a new question, type Python3. 
  2. Clicked customise. 
  3. Opened Advanced Customisation
  4. Set the question to be a prototype, named python3_blah. 
  5. Set a few other critical fields like name and question text.
  6. Saved
  7. Edited question
  8. The question type field was python3_blah, marked in red as unchangeable prototype.

My 5.7.2+ has a few changes since being pushed to master but I don't think any of them could be causing this problem.

I'll look into it in more detail tomorrow. Please let me know if you can cast any further light on the problem yourself. I'd be interested to know when the problem started happening. What changes had you just made to your Moodle server prior to the problems occurring.

In reply to Richard Lobb

Re: Bug in Editing Question Prototype?

by Aleksi Postari -
I created a recording showing the whole issue (no sound). You can view it from YouTube from here: https://youtu.be/8n6cWbo8CmE (can take a little time for it to be upgraded to HD quality)

Moodle 4.5.6+ (Build: 20250822) and Coderunner extension version 5.7.2+ 2025081500 (these versions were reported to me by system administrators today, I do not have administrative rights to our Moodle environment).

I cannot recall when this last worked. I think I last edited a question prototype a year ago or so, and it worked. It's not something I do that frequently... :) Chrome console is also not showing any errors (just printing to console this message: "Starting Moodle session timeout warning.")

Also tried with another browser (Firefox) with no extensions installed just to eliminate the browser issue out.


EDIT: Weird! The issue just sorted itself out. Now it remembers the template being used. I have no idea what could have been the culprit of this...
In reply to Aleksi Postari

Re: Bug in Editing Question Prototype?

by Richard Lobb -
While it's good in a way to hear that the bug has gone away, it's still a bit worrying that you experienced it in the first place.

It's not something I've ever seen before and we do a lot of prototype editing here. And with several thousand sites running CodeRunner and no-one having reported a problem like this before, I think it has to be a very rare problem. It's rarity suggests some sort of race problem but then on the other hand it was very consistent for you over a period of time, which isn't normal for race problems.

I've pored over the source code and the only potential trouble spot I can see is in the author form's use of jQuery, which is now deprecated in Moodle. But jQuery must have been working for you to be able to customise the form. So ... I'm still baffled.

To eliminate at least that one potential cause if the problem ever recurs, I've changed authorform.js to remove all use of jQuery. I'll push the change to the development branch on github but it will likely be some time before it appears in the master branch.

Please report back if the bug reappears.