Your Moodle version

General plugins (Local): Sandbox

local_sandbox
Maintained by Picture of University of Ulm University of Ulm, Picture of Alexander Bias Alexander Bias
Moodle plugin which programatically restores courses to predefined course states. It can be used to provide playground moodle courses which will be cleaned periodically.
199
149
16

After installing local_sandbox, the plugin doesn't do anything until it is configured. To configure the plugin, please visit Plugins -> Local plugins -> Sandbox.

There, you are able to define when local_sandbox should restore the courses. 

You also define the directory where the course backup files to use for course restoring are. local_sandbox takes every file in this directory with a .mbz filename extension, takes the file's name, searches for a existing course with a shortname equal to the file's name and finally, uses the course backup file to restore / reset this course.

Additionally, there is an option to set the course start date to today instead of setting it to the date saved in the course backup file. Use this option if you need to provide playground courses in Moodle which pretend to be up-to-date.

As local_sandbox acts automatically, it can inform you by mail when failures or problems occur.

See README file for details.

Contributors

Picture of University of Ulm
University of Ulm (Lead maintainer)
Picture of Alexander Bias
Alexander Bias: Developer
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Picture of Alexander Bias
    Thu, Sep 25, 2014, 8:55 PM
    Hi Chris,

    sorry that the plugin does not work for you yet.

    This error message occurs when the plugin takes the course backup package, tries to extract it and fails in this step.

    But I have never seen this error message before.
    Two possible reasons come to my mind:
    - The course backup package is extracted to /temp/backup/. It is unlikely, but not impossible, that the process running the moodle cron job is not allowed to write into this directory. Might this be the case?
    - There's something wrong with the course backup package. Did you create it on the same Moodle version as you are trying to restore it now? Are you using the "new backup format" on /admin/settings.php?section=experimentalsettings (I have to say that I have never tested local_sandbox with this setting)?

    Alex
  • Picture of Ioana Gatzka
    Mon, Oct 13, 2014, 9:45 PM
    Hi Alex

    If I understood it right the sandbox does the job once a day at a certain hour. Do you plan to add an option for every hour ? We are thinking about using a sandbox to showcase something and are concerned about stuff that people are going to upload onto the platform. Resetting the courses every hour would help a lot.

    Best regards
    Ioana
  • Picture of Alexander Bias
    Tue, Oct 14, 2014, 2:35 AM
    Dear Ioana,

    thanks for asking.

    The Moodle 2.7 version of the plugin leverages Moodle scheduled tasks for resetting the sandbox courses. So, you are free to define how often and when exactly courses should be resetted - see https://docs.moodle.org/27/en/Scheduled_tasks for details.

    I have changed the description of the plugin here in the plugin repository (it was still describing the pre-2.7 situation of the plugin).

    Alex
  • Picture of Eduardo Hm
    Fri, Jan 30, 2015, 4:30 PM
    Good Morning,

    I am testing this plugin I find interesting about the backup of courses and content. I have successfully installed the version of the plugin for my platform Moodle in version 2.7.x. The following steps have been performed:

    - Created the path of sandbox where I will store the backups of courses, with their read and write permissions.
    - To test it, I backed up a test course. After completing the backup, I've downloaded and placed in the default path previously sandbox.
    - Scheduled Tasks In Moodle, I activated the scheduled task to sandbox, and I run the cron manually on the server.

    I have seen the log of cron, and this is what comes in part Sandbox plugin:

    Execute scheduled task: Restore sandbox courses
    ... started 12:22:38. Current memory use 19.1MB.

    NOW: Processing course "copia_de_seguridad-moodle2-course-3-iesa_cfgmcyg_blo-20150129-1148"

    WARNING: There is no existing course with shortname "copia_de_seguridad-moodle2-course-3-iesa_cfgmcyg_blo-20150129-1148", skipping file...

    NOTICE: Sandbox has restored 0 courses
    ... used 1 dbqueries
    ... used 0.58944416046143 seconds
    Scheduled task complete: Restore sandbox courses

    Regards
  • Picture of Alexander Bias
    Fri, Jan 30, 2015, 5:32 PM
    Hi Eduardo,

    the way local_sandbox works, your course backup's filename needs to equal the shortname of the course which should be resetted. This is explained in the plugin's readme file.

    Based on your current filename, your course shortname will probably be "iesa_cfgmcyg_blo". So you should rename the backup file to iesa_cfgmcyg_blo.mbz

    Alex
  • Picture of Sebastien Gendry
    Fri, Feb 6, 2015, 7:30 PM
    Hello Alexander,
    Awesome plugin.
    Could you please confirm the following? Thank you.

    1) I must always manually upload the .mbz backup file(s) to /moodledata/sandbox/ yes? If so, is there a way to have moodle's course backup automatically be stored there?

    2) I get new students on a regular basis, but from what I understand (limited) when I export a course it freezes the list of students who are enrolled in it. If so, does it mean that I will need to re-export my course (and upload to /moodledata/sandbox) everytime I get new students, because if I don't the ones who enrolled AFTER the first backup won't have access to it?

    3) Is it OK to run a cron every hour with this plugin or is that going to increase the load on the server significantly (I just have one small demo course to restore.)

    Your input is much appreciated!
  • Picture of Alexander Bias
    Sat, Feb 7, 2015, 3:53 AM
    Hi Sebastien,

    > I must always manually upload the .mbz backup file(s) to /moodledata/sandbox/ yes?

    Yes. We have been thinking about implementing a possibility to upload the course backup directly within the Moodle admin interface with the standard filepicker, but up to now we didn't have the time and need to do it.

    > If so, is there a way to have moodle's course backup automatically be stored there?

    I don't think so. You have to download the course backup and then upload it via FTP / SCP / whatever to your webserver. To do this, you will have to have direct access to moodledata. This is not possible with some Moodle hosts, that's why we thought about the filepicker solution.

    > I get new students on a regular basis, but from what I understand (limited) when I export a course it freezes the list of students who are enrolled in it. If so, does it mean that I will need to re-export my course (and upload to /moodledata/sandbox) everytime I get new students, because if I don't the ones who enrolled AFTER the first backup won't have access to it?

    Well, you can backup a course without including enrolments into your backup file. When sandbox restores the course, all students who are enrolled up to then are removed from the course and course content is restored from the backup. That's what we do here and what the plugin is made for.

    I haven't tested yet what sandbox does when you use a backup file with enrolments. But I don't see a real use case for restoring enrolments with sandbox on a regular basis. Why do you want to reset a course regularly _and_ keep students enrolled?

    > Is it OK to run a cron every hour with this plugin or is that going to increase the load on the server significantly (I just have one small demo course to restore.)

    Sure, restoring a course backup takes some seconds to process and puts some load on the DB. But as long as you don't run the cron every minute so that restore processes overlap, this shouldn't be any problem for a healthy server.

    Alex
  • Picture of Bernhard Hiegl
    Mon, May 25, 2015, 8:17 PM
    Hi Alex, do you have plans to update this tool for Moodle 2.9 soon?
  • Picture of Alexander Bias
    Tue, May 26, 2015, 1:21 AM
    Hi Bernhard,

    up to now, we didn't have the time to check our plugins on 2.9 thoroughly. I assume our testing period will start in June.

    Did you test Sandbox on 2.9 and did encounter any problems? If yes, I might be able to have a look at it earlier and provide some quick fix.

    Thanks,
    Alex
  • Picture of Michael Milette
    Tue, Sep 29, 2015, 10:30 PM
    Hi Sebastien,

    > If so, is there a way to have moodle's course backup automatically be stored there?

    Give Moosh a try. It's a command line tool and one of its functions, course-backup, allows you to specify the location where you want the backup file to be saved as well as the file name.

    For more information, see http://moosh-online.com/commands/#course-backup

    Best regards,

    Michael
  • Picture of Jon Bolton
    Wed, Nov 18, 2015, 8:18 PM
    Thanks for this plugin! Is there a way to force the course ID to be the same as my 'original' sandbox course (happy to change code) - two reasons:
    1. my sandbox is hardcoded into menus, so when the course id changes, the link breaks sad
    2. the sandbox will reset every day, so my course ID number is going to increment very rapidly.

    Obviously, the second is not a huge issue, but the first is quite important.

    The course ID seems to in classes/task/restore_courses.php - I tried...

    $newcourseid = $oldcourseid;

    and

    $newcourseid = '19';

    at the start of the // Create new course section, but neither option works.

    Any advice?
  • Picture of Alexander Bias
    Wed, Nov 18, 2015, 8:33 PM
    Jon,

    I can't do anything about 2., that's just how the plugin works at the moment.

    But for 1., you can change your hardcoded link form https://yourmoodle.com/course/view.php?id=1234 to https://yourmoodle.com/course/view.php?name=courseshortname. As the course's shortname will be kept for the resetted course, this link will continue to work. And you don't have to hack the plugin ;)

    Alex
  • Picture of Jon Bolton
    Wed, Nov 18, 2015, 9:00 PM
    Oh yeh, why didn't I think of that! Doh!
    Thanks smile
  • Picture of james aco
    Mon, Mar 28, 2016, 6:40 PM
    Hello,
    Testing the plugin with:
    moodle 3.03.
    v3.0-r2 (2016021000)
    /var/www/clients/client1/web1/private/moodledata/sandbox - (permission: -R 777)
    getting email sandbox notification :
    1 NOTICE: Sandbox has restored 0 courses
    1 WARNING: There is no existing course with shortname "demo_lms", skipping
    file...
    backupfile name - backup-moodle2-course-6-demo_lms-20160328-1326.mbz
    sandbox backup file "demo_lms.mbz"
    what i'm doing wrong?
    Thank you
  • Picture of Alexander Bias
    Tue, Mar 29, 2016, 3:31 AM
    James,

    based on your posted message, local_sandbox is looking for a course which has a shortname called "demo_lms" which it can reset to the state saved in demo_lms.mbz. If such a course does not exist, you can either change the shortname of the course you want to reset to "demo_lms" or you can rename demo_lms.mbz to the shortname of the course you want to reset.

    Alex
1 2
Please login to post comments