Future CodeRunner developments for Moodle 4.x

Future CodeRunner developments for Moodle 4.x

by Richard Lobb -
Number of replies: 3

I thought I'd post a recent email exchange with Tim Hunt here, in case other CodeRunner users/developers have opinions on the topic. I asked Tim ...

==========================

Hi Tim

[.. snip..]

Back in May you wrote:

"Just be aware that there are more changes coming in Moodle 4.1 https://moodle.org/mod/forum/discuss.php?d=434031. In particular, MDL-71378 is probably going to require a re-think of how CodeRunner questions relate to their prototypes (which, I have always felt was a bit of a work-around – but one that has worked well for many years. I have some thoughts about that, but I don’t feel inclined to explain my thinking yet. (Sorry. In my defence, it will be easier to explain once the new code is integrated into Moodle master.)"

I see that the mod_qbank got pulled from Moodle 4.1, which was a relief in that it gave me some breathing space. On the other hand, I'm now at the start of my 2-month holiday period, which is when I do any CodeRunner development, so I'd like to be able to get ahead of the game now, so I don't get stuck with trying to do development during a busy teaching time.

For a while I had a semi-working version of the master_MDL-71378-mod_qbank branch of MDL-72752 (https://tracker.moodle.org/browse/MDL-72752) but the current version is throwing CodingErrors at me. I also cloned the current Moodle master, V4.2Dev, but it doesn't seem to have mod_qbank in it. So ... I'm wondering where this development is at and how I can bring myself up to speed with plans. I'd also be interested to hear your thinking of where we should go with managing prototypes. 

One bug I have discovered - you can't fire up a new Moodle + mod_qbank if the CodeRunner plugin code is present, because the CodeRunner installer tries to add the prototypes to the system context: because mod_qbank hasn't been initialised yet, its database tables aren't there and the question insertion code fails. 

Any help or advice would be appreciated.


In reply to Richard Lobb

Re: Future CodeRunner developments for Moodle 4.x

by Richard Lobb -
Tim replied to the above (hope you don't mind my posting it here, Tim, but you did say you tended to prefer forums):
====

I don’t yet know what is going to happen with getting stuff into Moodle 4.2. We are still working out what to do about the fact that it did not get into 4.1. However, we still believe these are the right changes to make, and want to get them in, it is just a matter of how to achieve that.

To answer how CodeRunner should work in the new word, of mod_qbank, when we get there, there are several parts.

  • How should a question link to its prototype? Currently, this works by search on name, in a certain set of contexts. In future (if fact, parts of this are already in the code/database), Moodle has a common way to track where a particular question is used, called the question_references table. So, I think that the way a CodeRunner question should be linked to its prototype is for the question to reference its prototype.
  • That would have some advantages. For example Moodle would stop the prototype from being deleted if any question is using it. It would also represent the link more clearly.
  • This only form post shows the DB structure: https://moodle.org/mod/forum/discuss.php?d=417599#p1688163.
  • When a teacher is editing a question, how to present the choice of prototypes. Once mod_qbank is in Moodle, then have a look at how adding questions to a quiz works, and see if you can create something like that. (Of course, the quiz UI should be built from a reusable widget, but don’t get your hope too high in that regard.)
  • When CodeRunner is installed, where to put the standard prototypes? As you say, there will no longer be an option to put questions in the system context. Instead, probably what you have to do is:
    1. If it does not already exist, create a course called “CodeRunner prototypes”.
    2. If it does not already exist, in that course, create a mod_qbank called “Standard CodeRunner prototypes”.
    3. Put the prototypes in there.
I think those are the main bits to think about.
In reply to Richard Lobb

Re: Future CodeRunner developments for Moodle 4.x

by Richard Lobb -
Many thanks Tim. That's a fascinating forum thread you linked me to. I have a much clearer idea of what is happening/planned now, though I still have plenty of uncertainties, too. Would you mind checking if my understanding of the following points is correct, please?

  • I'm still unclear on how question banks get shared. Suppose I have a lot of question banks in my course and one of them is for question prototypes. I wish to let another course use those prototypes. Do I have to give all teachers in that other course access to all my question banks? 
  • I assume there would have to be a role like QbankVisitor that would allow guest teachers to "use all questions" in my course, but not to edit them.
  • If there is a specific course called CodeRunner prototypes, all teachers wishing to use CodeRunner questions would need to have the QbankVisitor role in that course, correct? Would there be any way to ensure all teachers on the site automatically had that role in that course? Doing it manually would seem very arduous. It would also be very confusing to a teacher who didn't have the role, if they tried to create a CodeRunner question but didn't see any question types.

I like the idea that there is an explicit linking of a question to its prototype to prevent prototype deletion. It would also presumably mean that the type of a question was determined by the type encoded in the prototype so all questions would change their type name if you edited the prototype's type name. However, there seem to be quite a few worrying complexities. I'll have to think more about this before trying to elaborate.

In reply to Richard Lobb

Re: Future CodeRunner developments for Moodle 4.x

by Richard Lobb -
Thinking more about linking of questions to prototypes ...

Suppose in my course I have the following 3 activities
  1. A question bank my_prototype_bank, containing all my custom prototypes.
  2. A question bank my_cr_question_bank containing my learning-module CodeRunner questions. These questions use prototypes from three different question banks:
    • The standard built-in prototypes (in the CodeRunner prototypes course)
    • my_prototype_bank
    • my_other_course_prototypes, which is a question bank in another course I teach.
  3. A quiz that uses a subset of questions from my_cr_question_bank.
What happens when I export that quiz?

Since the goal is to keep together any linked information, I assume that the export will need to contain not only the quiz questions from my_cr_question_bank but also the prototype questions from the three different prototype banks. At this point my understanding get fuzzy (or even fuzzier). Are all those questions and prototypes (and only those ones) in a new question bank that's included in the quiz, with the questions linked to their prototypes in that question bank? That seems the most probable outcome but there are other possibilities, such as multiple attached (partial or complete) question banks.

Now ... if I import that exported quiz into my other course, I have duplicate copies of all the system prototypes that the quiz uses and also duplicates of the prototypes from my_other_prototypes.

On the plus side, this means integrity has been maintained - the quiz will continue to run exactly as before. This is great and will avoid some of the screw-ups that have occurred in the past. But on the downside I have potential confusion from the fact I have duplicate prototypes: if, say, I tried to update one of my prototypes in the my_other_prototypes bank, I would be surprised to discover that the questions in my imported quiz didn't also update, even though their coderunner question type name is exactly the same as that of the updated prototype.

Similar confusions would seem to occur during course backup and restore. Suppose at the start of a new academic year we set up a new Moodle server with a new version of CodeRunner that has updated some of the built-in question prototypes. I backup my course from last year's server and restore it on the new year's server. The backup copy will presumably have copies of all the built-in question types from last year, so will not use the updated question types.

Some or all of these difficulties could be mitigated by having a special CodeRunner question-bank plugin that allows you to manage the prototypes, and perhaps "re-parent" a set of questions that use, say, a copy of a built-in prototype to instead use the updated built-in prototype. But I an concerned that:
  1. This is sounding like a worryingly large amount of redesign and redevelopment of code, and my development time is very limited. 
  2. I fear it might prove even more confusing to question authors than the current 'find-prototype-by-name' system.