moosh

Utilities
Maintained by Tomasz Muras
Moosh stands for MOOdle SHell. It is a commandline tool that will allow you to perform most common Moodle tasks. It's inspired by Drush - a similar tool for Drupal.
Latest release:
2k downloads
109 fans
Moodle 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8

Moosh is a tool that exposes some common Moodle functionality to the commandline.

You install moosh outside of the Moodle directory, it can be anywhere really. Then simply make moosh.php (or symlink named like moosh) available somewhere in $PATH.

To run moosh, change the directory into your installed Moodle's instance and run one of the commands. To get the list of all available commands only run moosh.php (or just moosh if you've symlinked it like this) or read the documentation and examples.

Moosh is meant to work nicely with Linux features like bash/zsh expansion. For example, to create 10 users, you just type:

% moosh user-create username{1..10}

 

Screenshots

Screenshot #0

Contributors

Tomasz Muras (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments

Show comments
  • Alexandre Scherbyna
    Wed, 3 Aug 2022, 10:27 PM
    Hi, Tomasz.
    Moosh has a command for enroll cohort "my cohort18" to course id 4:
    moosh cohort-enrol -c 4 "my cohort18"
    But Moosh does not have a similar command for enroll students via the course meta link.

    Can you add a command
    moosh meta-enrol -c 4 18
    for enroll in course id 4 students enrolled in course id 18?
    Thank you!
  • Oscar Nogueiras
    Wed, 24 Aug 2022, 7:41 PM
    Hi Tomasz!
    I've recently upgraded to Moodle 4.0 and tried to use moosh to reset some courses. I did it one year ago and worked fine (Moodle 3.X).
    But now, it is not working.

    Running command "moosh" is returning this error message:
    "PHP Deprecated: Return type of GetOptionKit\OptionCollection::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /root/moosh/vendor/corneltek/getoptionkit/src/OptionCollection.php on line 196"

    And running more complex comands results in a large list of similar errors.

    Any idea on what is hapening?
  • Dario Roig Garcia
    Tue, 4 Oct 2022, 3:00 PM
    Hi, Tomasz.

    Thanks for sharing your work, it is very useful this plugin to do less annonyng the daly admin routines.
    Would be gladful a command to add course meta link, like Alexandre Scherbyna wrote:

    >Moosh has a command for enroll cohort "my cohort18" to course id 4:
    >moosh cohort-enrol -c 4 "my cohort18"
    >But, Moosh does not have a similar command for enroll students via the course meta link.

    >Can you add a command
    >moosh meta-enrol -c 4 18
    >for enroll in course id 4 students enrolled in course id 18?
    >Thank you!

    Thank you so much!
  • Fra Parlant
    Fri, 4 Nov 2022, 2:03 AM
    RANDOM LABELS NOT WORKING
    Thanks a lot Tomasz for this great plugin.
    I tried to add some labels (lot of videos to include), but I couldn't get them to work neither on 3.10 or 4.0.4...
    I created an issue in github if you go there sometimes.
    Maybe someone else knows what to modify in the code to make them work.
    https://github.com/tmuras/moosh/issues/419
    Cheers
    François
  • Ricardo Caiado
    Fri, 9 Dec 2022, 7:08 AM
    Hi,

    After running "moosh file-dbcheck" I got this message:

    "List of files on disk but not in DB:
    /www/moodledata/filedir/07/6e/076e13e06b13acb5c699372d23ed80f0a2549f2f
    /www/moodledata/filedir/10/a8/10a8438cb752380396d8906caf615c8663c8a667
    /www/moodledata/filedir/17/33/17334433c8ad5f34312005a9660f4831fe535d8f
    /www/moodledata/filedir/25/4f/254fd46abbe9386ab25cd37f1b21011dcb81ac19
    /www/moodledata/filedir/2a/66/2a6676e2f000e31c3948a9501ea67784b55d4846
    /www/moodledata/filedir/4c/39/4c3942f1abfe8f7c6fb4923b772cf013082bcc33
    /www/moodledata/filedir/79/d8/79d8291afbe116f1f346339152cadec7b56d0282
    /www/moodledata/filedir/81/61/816131c0dbf2d0200314c9e77554dfc667b4a35c
    /www/moodledata/filedir/91/a3/91a3ca800eff23d5b1aa1a02289483c42bc79fba
    /www/moodledata/filedir/9b/4d/9b4d85ddefe9d5bd9f250fc3e0a1dbac2abfe19b
    /www/moodledata/filedir/b1/f9/b1f99ef9ebd4231347bbf87a26b6ea17d498cee9
    /www/moodledata/filedir/bc/cc/bccc8c81c01a9c0bdb6ffa9dce4657d406e5542f
    /www/moodledata/filedir/be/da/beda8aba8c987d8c8cf1b7c438fcb11f97c00ea2
    /www/moodledata/filedir/c8/d2/c8d2a54c355b1b54c463248a0f4a78541270cda4
    /www/moodledata/filedir/cf/65/cf65e0d932cc06a5e6d2270d1975ab536a4f9910
    /www/moodledata/filedir/d1/0b/d10be20ed4c53355966ba93746067f5d5c5afba7"

    Is it safe to delete these files from disk?

    Ricardo
  • Andres Ramos
    Sat, 6 May 2023, 5:24 AM
    Does this plugin allow to delete a course?
  • DTA 28/03/2015
    Sun, 10 Sept 2023, 2:30 AM
    Great plug-in Congrats!

    My challenge is to modify existing courses section by adding new activity and Modify /Add Access restrictions (sets) on existing and/or new activity
    moosh activity-add / activity-move will add and locate new activity
    But I' m looking after any syntax allowing to import or set any activity 'Access Restrictions" set
    Is that possible with Moosh ?

    Thanks in advance
  • Cristina Martín
    Wed, 8 Nov 2023, 9:09 PM
    Thanks a lot for this plugin, it is being very useful for me.
    I have a question: I am working with version 3.11.7 of Moodle and version 1.3 of moosh and when trying to export the categories of my moodle it throws an error. Could it be because it is an old version of moosh? What version of moosh do you recommend for moodle 3.11.7? I want to export the current categories to take them to a new Moodle in version 4.1.7 and there I already have moosh 1.14

    Thanks again
  • Petros Kara
    Thu, 25 Jan 2024, 8:36 PM
    My moodle version is Moodle 4.3.2.

    When i am trying to run moosh i get an error like 'Fatal error: Uncaught Error: Call to undefined function get_local_referer() in E:\laragon\www\myproject\lib\setuplib.php on line 575'

    I have the latest version of moosh.

    Do you have any solution?

  • John D
    Thu, 1 Aug 2024, 11:06 PM
    Please take a look at https://moodle.org/mod/forum/discuss.php?d=460726 -- Deprecated warnings from moosh (with moodle 4.1) under PHP 8.1. thanks
  • Jose Perez Paris
    Sun, 8 Sept 2024, 5:54 PM
    Moodle 4.4.1, unable to install Moosh using Moodle's install plugin from ZIP. It complains about version.php not found...
  • Cristina Martín
    Fri, 12 Sept 2025, 10:57 PM
    Good morning, for updating and managing plugins, when working with multiple Moodle instances, we use scripts that perform these tasks using Moosh commands. The issue is that we are now receiving the following error message indicating a connection refusal:

    root@e9ec53cda824:/var/www/html# moosh plugin-list

    Warning: fopen(https://download.moodle.org/api/1.3/pluglist.php): Failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
    in /usr/src/moosh/Moosh/Command/Generic/Plugin/PluginList.php on line 37

    Is there any way to request this connection be enabled? It's very helpful since we centralize the Moodles for more than 300 public educational centers.

    We're working with Moodle 4.1.6 and Moosh 1.8.

    Thank you.
  • Rana Hamza Khalid
    Thu, 30 Oct 2025, 1:21 AM
    I am currently working on a project which aims to integrate with moodle by being able to export its couses to moodle programatically. We have observed one approach which is to manually download a mbz file on our software as per moodle format and the restore it on moodle. This approach can work but I want to do this programatically. Does anyone know about any such possibility. I have scrolled around Moodle documentation but didn't find any such thing. Any help will be greatly appreciated.
1 2 3 4
Please login to post comments