Moodle 4.x Get rid of all previous versions of a question - workaround

Moodle 4.x Get rid of all previous versions of a question - workaround

by Dominique Bauer -
Number of replies: 10
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Warning. The following method should only be attempted by highly experienced users.

It would obviously be better if this option existed in the core. In the meantime, here's a workaround that's not ideal but works. However, use it with caution.

So, if you want to get rid of all versions of a question except, of course, the latest one, here's what you can do:

  1. On the "Questions" page, make sure the question is set to "Always latest". I'm not sure if this is necessary here, but it can't hurt.
  2. In the question bank, duplicate the question. Only the latest version (hopefully) will be duplicated.
  3. On the "Questions" page, remove the original question and add the new copy of the question.
  4. Verify that everything is working correctly and then, in the question bank, delete the original question.

And there you have it! You've just gotten rid of your 187 useless versions of the question. You can now sleep the sleep of the righteous.

On the other hand, if the old versions don't bother you, there's not necessarily a need to delete them. smile

Average of ratings: Useful (1)
In reply to Dominique Bauer

Re: Moodle 4.x Get rid of all previous versions of a question - workaround

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
The other option is:

  1. In the question bank, choose Edit -> History for the question.
  2. Select all the verstions that you don't want. (The checkbox in the header row does select all. The usage column lets you see which versions are not used.)
  3. At the bottom, do With selected -> Delete.

(Note, if you accidentally select a version that is used somewhere. Moodle won't acutally delete it, it will just set it's status to Hidden.)


But yes, someone should code the scheduled task everyone wants. I am busy with other things (that lots of people, or at least the people who pay my wages, want) so would be better not to wait for me to get to it.
Average of ratings: Useful (5)
In reply to Tim Hunt

Re: Moodle 4.x Get rid of all previous versions of a question - workaround

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

What would be good reasons for wanting to delete the previous versions of a question?

  1. If a question contains multiple large, high-resolution images, the question file could be quite large. Having many versions could burden the host's disk space. If it's known that they won't be used, could that be a good reason to want to delete them?

  2. Are there any other reasons why one would want to delete previous versions of a question?

Are there any explanations regarding question versions in MoodleDocs?

In reply to Dominique Bauer

Re: Moodle 4.x Get rid of all previous versions of a question - workaround

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
1. is not a reason. Ever since version 2.0, Moodle only ever stores one version of a file on disc, no matter how many different places it is used.
Average of ratings: Useful (3)
In reply to Dominique Bauer

Re: Moodle 4.x Get rid of all previous versions of a question - workaround

by Andreas Steiger -
Picture of Plugin developers
I am currently preparing a Moodle course backup file for a ready-to-use course on practicing integration tasks. Users on other instances restoring the course really do not need to see all the edits we've done before releasing it. For that reason, I want to delete all old versions, but doing this manually with 100+ questions having 3-30 versions really is a bit tedious...
Average of ratings: Useful (1)
In reply to Andreas Steiger

Re: Moodle 4.x Get rid of all previous versions of a question - workaround

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

If it's not possible to choose to keep only the latest version of the questions when making a backup, the developer could perhaps add such an option, which would be a useful feature for cases like yours.

Average of ratings: Useful (1)
In reply to Dominique Bauer

Re: Moodle 4.x Get rid of all previous versions of a question - workaround

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Somebody must have asked this before me: How about an option (site-wide) to disable the versioning of questions?
Average of ratings: Useful (1)
In reply to Visvanath Ratnaweera

Re: Moodle 4.x Get rid of all previous versions of a question - workaround

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
@Visvanath,
Since I retired I only use Moodle for development and testing purposes (and occasionally helping out on the forums😉). I have absolutely NO USE for question versioning, I find that it hampers my development process and would heartily like to be able to disable it site-wide on my Moodle test sites.👍
In reply to Joseph Rézeau

Re: Moodle 4.x Get rid of all previous versions of a question - workaround

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi Joseph

It is true that I don't need this feature. But I was thinking of the teachers I support. We have a couple of very active groups, one is hugely active, 80% in and around the quiz. I don't want a repetition of the current mess I have with an old Moodle "feature". See How to clean up a site with massively duplicated question categories?
In reply to Visvanath Ratnaweera

Re: Moodle 4.x Get rid of all previous versions of a question - workaround

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
As I have discovered the forthcoming improvements to the Question Bank, especially a better "sharing" (and editing) mechanism, I can see the value of question-versioning becoming more important. If a teacher decides to fix (edit) a question and makes a mistake, it will be great to return to an earlier version.
Average of ratings: Useful (1)