Sandbox

General plugins (Local) ::: local_sandbox
Maintained by Logo "Moodle an Hochschulen e.V."Moodle an Hochschulen e.V., 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.
Latest release:
303 sites
636 downloads
53 fans
Current versions available: 23

Providing sandbox courses to your users makes sense for simplifying live training courses or for letting new Moodle users explore the features of Moodle. However, manually resetting sandbox courses after a live training session or after a certain amount of time is a daunting task.

If you want to get rid of this senseless job of resetting courses periodically manually, this plugin is for you.

Please see README file for details about the usage and features of this plugin.

No support in the comments section on this page

Please note that we don't provide any support for this plugin in the comments section on this page.

We appreciate your commendation and reviews for this plugin in the comments. For bug reports and support requests, please read the extensive information in the plugin's README file first and create, if needed, a ticket in the bug tracker which is linked below.

Thanks for your cooperation.

Screenshots

Screenshot #0

Contributors

Logo "Moodle an Hochschulen e.V."
Moodle an Hochschulen e.V. (Lead maintainer): Maintainer
Alexander Bias: Maintainer
Ulm University: Initial Maintainer
Kathrin Osswald: Former Developer
Please login to view contributors details and/or to contact them

Comments RSS

Comments

  • Alexander Bias
    Thu, 13 Feb 2014, 7:19 PM
    Dear Carol,

    the message you are citing appears if
    a) the current day is not one of the days you have configured sandbox to run.
    b) the current time is before the time you have configured sandbox to run or if sandbox has already run today.

    So, assuming that you have configured sandbox with correct day and time when it should run, I can think of these problems:
    - You are looking at a manually started cron run output, but there was already a automatic cron run today before your manual start. Please check if the cron run you are looking at is the only cron run on your server.
    - There is something wrong with timezones. Actually, the sandbox settings as well as the sandbox run functions should use the timezone of the admin user. But I can't tell if my code is timezone-bulletproof. Please check if the sandbox works if you are scheduling the cron run some hourse before or after your current local time. If yes, I will try to fix the problem.

    After that, I have no more simple ideas at the moment...

    Alex
  • Work Photo 2014
    Wed, 26 Feb 2014, 4:40 PM
    HI Alexander
    Again sorry for the delay in my reply and thank you for your assistance. I think the answer may be much simpler - I got an email from my server:
    WARNING: There is no existing course with shortname
    "backup-moodle2-course-90-features_demo-20140210-1315", skipping file...

    I had put the course backup into the sandbox directory without renaming but I think I should have just named it 'shortname.mbz'?
    I will do this now and hopefully not bother you again!
    thanks
    Carol
  • Alexander Bias
    Wed, 26 Feb 2014, 4:54 PM
    Carol,
    I think you are on the right track. That's a reason for the problem which I didn't think of.

    Alex
  • Zach Bratcher
    Wed, 16 July 2014, 2:58 AM
    Guys,
    I'm needing some help. I am using this to restore a lot of our backups from a different moodle instance. So my issue is I would like to move the files to a different folder once the course has been successfully restored. I have tried the command shell_exec("cp $file /srv/moodledata/moodledata_production2/repository/restored"); and it says that it can't find the file or directory
  • Alexander Bias
    Thu, 17 July 2014, 4:10 PM
    Zach,
    what you are doing is not what the plugin was built for - although it can be abused to do what you want to do ;)

    So I'm trying to give you some basic feedback.

    $file contains only the filename of the course backup. If you make a shell call with only this filename and the current working directory of the shell is not the directory where the backups are, the file won't be found. You have to provide the whole path of the file to the shell command.

    Please use
    $config->coursebackupsdirectory.'/'.$file
    instead of
    $file
    and your shell command should work.

    Alex
  • Chris Chapman
    Thu, 25 Sept 2014, 7:34 PM
    Hi Alex, this plugin looks awesome, save me restroing our Sandpit course every monday. However I cant seem to get it working, I've read the readme, I have made the dir in moodledata, placed a .mbz backup named the same as the shortname of my sandpit course 'MOODPIT' . but I get an email saying.. WARNING: Unzipping of backup file "MOODPIT" failed, skipping file... any ideas?
  • Alexander Bias
    Thu, 25 Sept 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
  • Ioana Gatzka
    Mon, 13 Oct 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
  • Alexander Bias
    Tue, 14 Oct 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
  • Eduardo Hm
    Fri, 30 Jan 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
  • Alexander Bias
    Fri, 30 Jan 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
  • Sebastian Gendry
    Fri, 6 Feb 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!
  • Alexander Bias
    Sat, 7 Feb 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
  • Bernhard Hiegl
    Mon, 25 May 2015, 8:17 PM
    Hi Alex, do you have plans to update this tool for Moodle 2.9 soon?
  • Alexander Bias
    Tue, 26 May 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
Please login to post comments