Utilities: moosh

Maintained by Picture of Tomasz MurasTomasz 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.
635 downloads
39 fans
Current versions available: 2

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

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

Comments RSS

Show comments
  • Picture of wz z
    Wed, May 25, 2016, 9:30 PM
    I hope it can run on PHP 7.
  • Picture of Tomasz Muras
    Fri, Aug 5, 2016, 3:14 AM
    Yes, it does run with PHP7:

    vagrant@vagrant:~/moosh$ php --version
    PHP 7.0.8-0ubuntu0.16.04.2 (cli) ( NTS )
    Copyright (c) 1997-2016 The PHP Group
    Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.8-0ubuntu0.16.04.2, Copyright (c) 1999-2016, by Zend Technologies

    vagrant@vagrant:~/moosh$ ./moosh.php
    moosh version 0.21
    No command provided, possible commands:
    category-export
    ...
  • Picture of Henry Chung
    Mon, Aug 22, 2016, 8:00 PM
    Hi,
    I'm getting an error when I'm using user-delete:

    PHP Fatal error: Call to undefined function get_sorted_course_formats() in /moodleapp/course/format/lib.php on line 103

    it eventually works after a couple of tries and the user is deleted.
    I've tried upgrading to the latest moosh version but still getting the same error, tried on Moodle 2.8/2.9 and both give same error
  • Picture of sreenu eabyas
    Fri, May 26, 2017, 7:22 PM
    Hi,
    Is it possible backup and restore an activity using moosh?
    Thanks
  • Picture of Tomasz Muras
    Sat, May 27, 2017, 4:38 AM
    At the moment the only backup implemented is backup::TYPE_1COURSE (whole course) in course-backup command.
  • Picture of Bernat Martinez
    Mon, Jul 31, 2017, 7:20 PM
    Hi,
    Is it possible delete multiple users filtering by role? (moosh user-delete)
    Thank's in advance
  • Picture of Jock Coats
    Thu, Nov 30, 2017, 10:40 PM
    Hi Tomasz, this looks amazing. I haven't tried it yet, but looked through the documentation and wondered, can I give it a file for its input. I wish to delete lots and lots of users, and was trying to use "User Upload" with a csv of usernames with the delete flag on but it's running so slowly and wondered if I could use a command line version like this.

    Cheers,

    Jock Coats
  • Picture of Tomasz Muras
    Tue, Dec 5, 2017, 1:01 AM
    Hi Jock,

    moosh user-delete does not accept a file as an input (see https://moosh-online.com/commands/#user-delete) but you can use a power of Linux command line and simply do something like:
    cat file_with_user_names.txt | xargs moosh user-delete
  • Picture of Jock Coats
    Tue, Dec 5, 2017, 1:07 AM
    Thanks Tomasz. A colleague also pointed this out to me smile
  • Picture of Cyril Z.
    Mon, Apr 9, 2018, 7:29 PM
    Hello,

    Unfortunately, I was not able to run Moosh. Some information is missing on the offical Moodle's web page and on the official website. You may miss potential users and you seem to have worked hard to realise this great tool. Too bad.

    A video explaning how to install it and how to link it to moodle in local (and in production) would be great. Is it uesable with a Moodle which is not hosted in local ? I mean a test website or even a production website ? If there was some more information I would be interested in making a video tutorial.

    I really hope to get information from you and to be able to use it soon.

    Thank you in advance.
  • Picture of Henry Chung
    Thu, Aug 2, 2018, 6:25 PM
    Hi,
    I'm getting the following error when using block-add (moosh v0.26) on Moodle3.5+, mysql 5.7.19 and 5.7.23

    Default exception handler: Error writing to database Debug: Field 'timecreated' doesn't have a default value
    INSERT INTO mdl_block_instances (blockname,parentcontextid,showinsubcontexts,pagetypepattern,subpagepattern,defaultregion,defaultweight,configdata) VALUES(?,?,?,?,?,?,?,?)
    [array (
    0 => 'gsb',
    1 => 343147,
    2 => 1,
    3 => 'course-view-*',
    4 => NULL,
    5 => 'Right',
    6 => '10',
    7 => '',
    )]
    Error code: dmlwriteexception
    * line 489 of /lib/dml/moodle_database.php: dml_write_exception thrown
    * line 1329 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
    * line 1375 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
    * line 98 of /usr/share/moosh/Moosh/Command/Moodle23/Block/BlockAdd.php: call to mysqli_native_moodle_database->insert_record()
    * line 59 of /usr/share/moosh/Moosh/Command/Moodle23/Block/BlockAdd.php: call to Moosh\Command\Moodle23\Block\BlockAdd->blockAdd()
    * line 291 of /usr/bin/moosh: call to Moosh\Command\Moodle23\Block\BlockAdd->execute()

    !!! Error writing to database !!
  • Wazza
    Fri, Aug 17, 2018, 4:52 PM
    This seems a very good plugin to use, however... I'm running in some problems. Is it possible to make this a 'real' Moodle-plugin, and with that I mean a plugin that can be installed and accessed from within Moodle?

    As an example I would like to refer to adminer, a tool to get direct access to the database. The plugin installs and runs within Moodle, accessible from the web.

    The problem is that many don't have shell access (or even FTP access) to the server Moodle is running on. That way, you can't use this plugin at all...
  • Picture of Carlos Sanchez
    Tue, Feb 12, 2019, 6:33 PM
    Thank you so much. Very useful.
    I am going to use it to integrate a woocommerce store with the moodel courses.
    One question, is it possible to specify the end date of enrollment in a course?
  • Picture of Serge Fleussu
    Wed, May 22, 2019, 4:56 PM
    Hi,
    Thank you so much for this very useful tool (reducing time consuming reading API).

    I'm using moosh for a while with great satisfaction (backup automation is done with it and works very well).

    I encounter a problem since "surely upgrade version 3.6.3" with user creation.
    Here is the message I got every time a user is created with moosh (in fact user is created with username good, firstname and lastname the same but message stop the script : I could catch the error but I would like to avoid the error, better isn't-it ?).

    I use moosh 0.29 and Moodle 3.6.3+ (Build: 20190418)

    Here is the error (and the command sent) :

    /home/www/moosh/moosh.php -p=/home/www/moodle/htdocs -n user-create --city "Bruxelles" --country "BE" 19ag0022
    Default exception handler: Exception : Call to undefined method cachestore_dummy::find_by_prefix() Debug:
    Error code: generalexceptionmessage
    * line 1796 of /cache/classes/loaders.php: Error thrown
    * line 131 of /user/lib.php: call to cache_session->purge_current_user()
    * line 80 of /home/www/moosh/Moosh/Command/Moodle23/User/UserCreate.php: call to user_create_user()
    * line 297 of /home/www/moosh/moosh.php: call to Moosh\Command\Moodle23\User\UserCreate->execute()

    Thanks for help (I'm gonna catch the error waiting for soluce).
  • Picture of Kashyap Kr
    Wed, Jun 19, 2019, 7:23 PM
    Is there any command to set the "letters(percentage)" grader report settings in a single go. Like we set it by visiting single course at a time.
1 2 3
Please login to post comments