tmuras / moosh Goto Github PK
View Code? Open in Web Editor NEWMoosh
License: GNU General Public License v3.0
Moosh
License: GNU General Public License v3.0
I had a call today from a colleague who had backed up one section of a course, and was restoring it to another course, presumably so that the resources from the first course were available in the second. It all worked as expected, however the restore took in the order of 20 mins and during this time it was not clear that anything was happening, or if the process had failed. So, I am thinking of a function along the lines of:
course-copy-section [from-course-id] [from-section-id] [to-course-id]
So you specify the 'from' course by id and the section/topic/week by it's id, and then specify the 'to' course by id.
Additional (optional) parameters could be [to-section-id]
, so that the incoming section didn't simply appear at the bottom of the course, but instead could be slotted in at a higher point and the existing sections all shifted down by one.
(course-move-section
would work similarly, but move sections instead of copying.)
It seems the library being used for commanline processing has problems dealing with booleans.
When trying to create a course that is not visible, -v 0 and -v '0' both generate the same exception:
PHP Fatal error: Uncaught exception 'GetOptionKit\Exception\RequireValueException' with message 'Option 'v' requires a value.' in /usr/local/moosh/vendor/c9s/GetOptionKit/src/GetOptionKit/ContinuousOptionParser.php:174
Stack trace:
#0 /usr/local/moosh/vendor/c9s/GetOptionKit/src/GetOptionKit/ContinuousOptionParser.php(124): GetOptionKit\ContinuousOptionParser->parse(Array)
#1 /usr/local/moosh/moosh.php(122): GetOptionKit\ContinuousOptionParser->continueParse()
#2 {main}
thrown in /usr/local/moosh/vendor/c9s/GetOptionKit/src/GetOptionKit/ContinuousOptionParser.php on line 174
I also tried -v 'false' and -v N but they also don't work, giving Dabatbase errors instead:
Default exception handler: Error writing to database Debug: Incorrect integer value: 'N' for column 'visible' at row 1
INSERT INTO mdl_course (fullname,shortname,format,idnumber,visible,category,timecreated,timemodified,sortorder,visibleold) VALUES(?,?,?,?,?,?,?,?,?,?)
[array (
0 => 'TEST - All Students [2014-2015]',
1 => 'TEST',
2 => 'weeks',
3 => 'test_2015_allstudents',
4 => 'N',
5 => '361',
6 => 1403023635,
7 => 1403023635,
8 => 0,
9 => 'N',
)]
Error code: dmlwriteexception
!!! Error writing to database !!!
I had a look at the docs for php-GetOptionKit, and tried with v|visible:=i in the hope that that would make it see sense, but alas not, it still doesn't think 0 is an integer!
I have two suggestions for possible fixes, and would be happy to submit either as a patch:
Obviously the real problem is that GetOptionKit is being dumb, but since that's not part of this codebase, I suggest we need to hack around it, so that probably means one of the above two approaches.
It would be nice if moosh had a "moosh make" command similar to "drush make":
plugin-install assumes a plugin should be put in a folder named after whatever comes before the first underscore in the name.
So, auth_saml goes in "auth/" and enrol_autoenrol goes in "enrol/", which is correct. But Moodle does not strictly follow that convention.
plugin-install incorrectly puts block_rss_plus in "block/" but it should go in "blocks/". It also puts format_grid in "format/" but it should go in "**course/**format/"
Many of the Moosh commands I've tried seem to work in Windows however the one related to generating a new plugin don't. For example,
moosh generate-block hello
...produces the following error that \moodle\blocks\hello isn't a directory:
cp: copying multiple files, but last argument ('c:\moodle/blocks/hello') is not a directory
Try `cp --help' for more information.
Copying from module template failed
If I try to create the directory first, it then complains that the directory already exists.
Already exists: 'c:\moodle/blocks/hello'
Not creating new block hello
The same thing happens with the generate-module command. I would assume that it is likely a problem across the board for all of the generate-xxxx commands and anywhere in Moosh where it is assumed that a directory will be automatically created if it doesn't already exist.
I had better results running Moosh under Cygwin.
The current moodle process for this is extremely laboring (particularly if there are a lot of courses in the system) It would be awesome to be able to do it with moosh.
Right now the -v option allows you to select the major version of moodle to download, ie 2.8, 2.6, but not the minor version, ie 2.8.5, 2.6.2.
It would me nice to have that level of control so I could be sure of the version I was getting.
Moodle coding style states
Use an indent of 4 spaces with no tab characters.
However, I just used moosh generate-form
and moosh form-add
to generate some code, and found that the code used 2 spaces to indent instead of 4. For consistency with written code, it would be good to follow the Moodle coding guidelines.
Hello,
I have made available a template for Moodle Grade Export plugin based on txt export from core.
Hope you like and add it to Moosh =)
Kind regards,
Daniel
Running data-stats
on Moodle 2.9.1 gives the following error:
www-data@moodle:$ moosh.php data-stats
Default exception handler: Error reading from database Debug: ERROR: column "mdl_files.contenthash" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: SELECT DISTINCT contenthash, SUM(filesize) AS total FROM mdl...
^
SELECT DISTINCT contenthash, SUM(filesize) AS total FROM mdl_files
[array (
)]
Error code: dmlreadexception
* line 443 of /lib/dml/moodle_database.php: dml_read_exception thrown
* line 244 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
* line 764 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
* line 1478 of /lib/dml/moodle_database.php: call to pgsql_native_moodle_database->get_records_sql()
* line 38 of /usr/local/bin/moosh/Moosh/Command/Moodle23/Data/DataStats.php: call to moodle_database->get_record_sql()
* line 265 of /usr/local/bin/moosh/moosh.php: call to Moosh\Command\Moodle23\Data\DataStats->execute()
!!! Error reading from database !!!
This happens with any command when given -v global option.
PHP 5.5.9, current moodle dev 3.0
~/projects/moodle/master master
❯ moosh -n -v course-create
Top Moodle dir: /home/daniel/projects/moodle/master
Current working dir: /home/daniel/projects/moodle/master
Relative Moodle dir:
PHP Warning: session_regenerate_id(): Cannot regenerate session id - headers already sent in /home/daniel/projects/moodle/master/lib/classes/session/manager.php on line 462
Warning: session_regenerate_id(): Cannot regenerate session id - headers already sent in /home/daniel/projects/moodle/master/lib/classes/session/manager.php on line 462
Not enough arguments provided. Please specify:
shortname
Using moosh 0.18 installed via apt on Ubuntu Trusty, when I run the plugin-list example command, I get the following warnings, and no other output (same with other plugin names I've tried).
Maybe the warnings are just because I have PHP's debugging settings set too high, but they look like they could be related to why there are no results. I do have a ~/.moosh
directory, but it's empty.
$ moosh plugin-list quickmail
PHP Warning: file_get_contents(/u0/brsmith/.moosh/plugins.json): failed to open stream: No such file or directory in /usr/share/moosh/Moosh/Command/Generic/Plugin/PluginList.php on line 40
Warning: file_get_contents(/u0/brsmith/.moosh/plugins.json): failed to open stream: No such file or directory in /usr/share/moosh/Moosh/Command/Generic/Plugin/PluginList.php on line 40
Can't read json file
Hi,
In the documentation you specified to use the course id to import the questionaries but internally is asking for the quiz activity id. Then when you specified the xml file you need to give the full path to catch it.
I'm making a new version of the quiz importer with more parameters as I need, I'll post it here when I finish.
I've been working on a couple of command additions and I'd like to provide unit tests for them before putting in a pull request but can't see any documentation on running the existing tests. I've tried a few things but no joy.
Apologies in advance if I'm missing something obvious.
The following example from the readme doesn't work in moodle 2.4 without adding a shortname like course1 at the end
moosh course-create --category 1 --fullname "full course name" --description "course description"
Even simple Moosh commands do not seem to be working on Moodle 2.8.
As a test, I'm using the command: moosh config-get moodle forgottenpasswordurl
However, every single test fails, I look in the DB, see that a config value is definitely set, run the command, and get back nothing - no error, no answer, just straight back to the command prompt.
I added a debug print statement to the constructor in Moodle23/ConfigGet.php, and that prints, but, when I add a print statement as the second line (after the globals) in execute(), that print never happens, so the command is not even being executed.
Since I am not getting an error message, I have absolutely no idea how I can even start to debug this?
How can I get to the bottom of why the command is not even being executed?
Sorry, this isn't an issue in the sense of a problem, more a comment. I have just installed Moosh under Win32 and it seems to work OK. I have cleared cache, added a user and generated a form. It will fall over on unixy things like your example of
moosh user-create user_{1..5}
but
moosh user-create_user_1
Works fine. You could put something like this information in the FAQ
At the institution where I am employed we make extensive use of metacourses. A single Moodle shell will contain all the content, and two or more child courses will track enrollment and grading separately. I can use the moosh command to create all the shells, but I can't figure out if it's possible to link those courses or not. To do this via the standard interface, I would typically use:
Course Administration -> Users -> Enrollment Methods -> "Add method: Course meta link."
I would then need to find the shells listed. When we have a thousand or so course shells, however, this becomes quite tedious.
It's not immediately apparent to me how Moodle actually handles this on the database side, so I was wondering if this is a feature you would consider adding to the moosh tool?
Thanks for an awesome tool!
Could you add a new command?
moosh generate-local
Which would generate a local type plugin.
the course-reset command does not reset students by default.
workaround:
add the following line after the line that defines the $default variable in file moosh/Moosh/Command/Moodle23/Course/CourseReset.php
$defaults['unenrol_users'] = array(6);
Hi,
As I read on the wiki we could import quiz .xml files into moodle but is not possible yet to export it.
I think that would be usefull.
I am testing Moosh to bulk-reset courses, and on Moodle 2.8 I received the following error (I had to run with -v or I received no output):
paulvaughan@webdev:~/moosh$ php moosh.php -v -p /srv/moodle2_dev/current/ course-reset 8
Top Moodle dir: /srv/moodle2_dev/current/
Current working dir: /home/paulvaughan/moosh
Relative Moodle dir:
PHP Warning: session_regenerate_id(): Cannot regenerate session id - headers already sent in /srv/moodle2_dev/releases/20150211093320/lib/classes/session/manager.php on line 462
Warning: session_regenerate_id(): Cannot regenerate session id - headers already sent in /srv/moodle2_dev/releases/20150211093320/lib/classes/session/manager.php on line 462
Processing command option 'help''
Command: reset (course)
Options:
help (): ''
Arguments:
8
PHP Notice: Undefined property: stdClass::$cacherev in /srv/moodle2_dev/releases/20150211093320/lib/modinfolib.php on line 450
Notice: Undefined property: stdClass::$cacherev in /srv/moodle2_dev/releases/20150211093320/lib/modinfolib.php on line 450
++ Incorrect scale id: 31 ++
* line 837 of /lib/grade/grade_item.php: call to debugging()
* line 273 of /lib/grade/grade_item.php: call to grade_item->load_scale()
* line 158 of /lib/gradelib.php: call to grade_item->update()
* line 985 of /mod/assign/lib.php: call to grade_update()
* line 106 of /mod/assign/lib.php: call to assign_grade_item_update()
* line 780 of /mod/assign/locallib.php: call to assign_reset_gradebook()
* line 84 of /mod/assign/lib.php: call to assign->reset_userdata()
* line 5521 of /lib/moodlelib.php: call to assign_reset_userdata()
* line 30 of /home/paulvaughan/moosh/Moosh/Command/Moodle23/Course/CourseReset.php: call to reset_course_userdata()
* line 253 of /home/paulvaughan/moosh/moosh.php: call to Moosh\Command\Moodle23\Course\CourseReset->execute()
I don't know anything about Moosh so I can't supply a solution, but I thought it was odd that (on the last line) Moodle23 is referenced, when I'm running Moodle 2.8.
Also wondering if #80 is relevant.
Vaughany.
Hi, I ran:
./composer.phar update
to update to the latest version of moosh (from 0.13).
I get
and then when running moosh:
PHP Fatal error: Class 'GetOptionKit\OptionSpecCollection' not found in /root/moosh/moosh.php on line 38
Run of moosh plugin-fetchinfo
command (08a73cd) gives such notices
Fetching: https://moodle.org/plugins/view.php?id=522&moodle_version=3
Notice: Undefined index: plugin in ~/.moosh/Moosh/Command/Generic/Plugin/PluginFetchInfo.php on line 59
PHP 5.5.13 (cli) (built: Jun 13 2014 11:04:11)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
Before I go and do it myself, have you considered a web-service based version of this?
Without thinking about it too hard - it would probably involve a local plugin for Moodle that exposed the required set of web services (or simply accepted a 'mooch' command and wrapped the rest of the mooch functionality into a proper plugin). The command line bit could then be remote.
It looks like 2.9 no longer has a lib/pluginlib.php
, which seems to have been moved to lib/classes/plugin_manager.php
Obviously this breaks the plugin-install
command, and probably others. :(
It seems that this function that category-export uses is deprecated since 2.5 - here's the output I get:
[root@host html] moosh -n category-export 4
++ Function get_course_category_tree() is deprecated, please use course renderer or coursecat class, see function phpdocs for more info ++
* line 3061 of /lib/deprecatedlib.php: call to debugging()
* line 35 of /opt/moosh/Moosh/Command/Moodle23/Category/CategoryExport.php: call to get_course_category_tree()
* line 265 of /opt/moosh/moosh.php: call to Moosh\Command\Moodle23\Category\CategoryExport->execute()
++ context_instance_preload_sql() is deprecated, please use context_helper::get_preload_record_columns_sql() instead. ++
* line 4140 of /lib/deprecatedlib.php: call to debugging()
* line 3098 of /lib/deprecatedlib.php: call to context_instance_preload_sql()
* line 35 of /opt/moosh/Moosh/Command/Moodle23/Category/CategoryExport.php: call to get_course_category_tree()
* line 265 of /opt/moosh/moosh.php: call to Moosh\Command\Moodle23\Category\CategoryExport->execute()
<categories>
...XML content...
</categories>
Is it possible to enable a plugin with moosh?
Thanks
This is a bad practice to depend on master branch https://github.com/tmuras/moosh/blob/master/composer.json#L100, because nobody sure that next commit won't brake something.
The GetOptionKit and twig have tags. Repositories without tags could be defined using particular commit like "jamiepratt/moodle-qtype_TEMPLATE":"dev-master#bf2b7bc641c1db5c4889e4cc78ee3c2225398871".
Without such approach this tool can't be treated as reliable.
Steps to replicate:
Vanilla Moodle 2.6.4
On a totally fresh install of moosh, if you run something like moosh course-backup -h
you get:
PHP Fatal error: Call to undefined method GetOptionKit\OptionCollection::printOptions() in /Users/merrill/moosh/Moosh/MooshCommand.php on line 328
This is because GetOptionKit has removed/changed the printOptions kit. c9s/GetOptionKit#20
https://github.com/moodlehq/moodle-local_amos.git is no longer available on github.
It would be great to be able to specify which role to assign when using cohort-enrol.
Please update the documentation or change the command name. I added the "clear-cache" command in my fork to get the command which is described in the documentation.
There is now a new web service API that moosh might use to get the list of available plugins (instead of the current hackery :-)) The URL of the new service is https://download.moodle.org/api/1.3/pluglist.php and it does not accept any parameters. It's not documented yet but it should be pretty intuitive.
I have moosh installed through the Ubuntu PPA.
When I use moosh category-export on a Moodle 2.8 instance, I get the following message (above the exported XML):
++ Function get_course_category_tree() is deprecated, please use course renderer or coursecat class, see function phpdocs for more info ++
* line 3108 of /lib/deprecatedlib.php: call to debugging()
* line 35 of /usr/share/moosh/Moosh/Command/Moodle23/Category/CategoryExport.php: call to get_course_category_tree()
* line 274 of /usr/bin/moosh: call to Moosh\Command\Moodle23\Category\CategoryExport->execute()
++ context_instance_preload_sql() is deprecated, please use context_helper::get_preload_record_columns_sql() instead. ++
* line 4187 of /lib/deprecatedlib.php: call to debugging()
* line 3145 of /lib/deprecatedlib.php: call to context_instance_preload_sql()
* line 35 of /usr/share/moosh/Moosh/Command/Moodle23/Category/CategoryExport.php: call to get_course_category_tree()
* line 274 of /usr/bin/moosh: call to Moosh\Command\Moodle23\Category\CategoryExport->execute()
Right now I can't use moosh for deployment or automation because I cannot specify the exact version of a plugin to install with plugin-install.
If, on my staging environment, I install block_rss_plus with:
$ moosh plugin-install block_rss_plus 28
I will get version 2015060101 because that is the latest version released for Moodle 2.8. But if there is a release between the time I deployed to staging and the time I deployed to production then the same command may give me version 2015101400 on production, which is obviously not the version I tested.
So, what I am asking for is to option of specifying a version like this
$ moosh plugin-install block_rss_plus 28 2015060101
In a previous version of moosh, course-unenrol was able to unenroll multiple users from a course by running the following command:
course-unenrol 1005 508 509 510
(where 1005 = courseid and 508-510 = userids)
This is no longer possible. No unenrollments are being performed.
A great addition to moosh would be a session monitor to see a list of currently logged in users, since when they are logged in and if they are active or idle (time since last action). That list should update every 30 seconds.
Hi,
could you add a full moodle backup feature?
This could work like the drush ard command in moodle
Thanks!
if you could have an option for Nginx equivalent to "apache-parse-missing-files" that would rock!
I think it would be great if the Course-Unenrol function didn't remove all users with a certain role, but allowed you to specify a user id number so it would be like:
mouse course-unenrol --role rolegoeshere --user userid courseid
moosh course-unenrol --role editingteacher --user 1 144
I could take a crack at it, but wondered if it would be easier for you to look at if you thought it was a useful change.
Not sure if this is a bug or an enhancement request:
If a user has two roles in a course (student, teacher) and I only want to take one role away (student), I assumed that I can run the following command:
moosh course-unenrol -r student 1554 12314
But instead of taking only the student role away, it unenrolls the user completely (and takes the teacher role away as well).
It would be great if Moosh would only take the specified role away, if the user has more than one role in the course and the -role option was supplied.
Is MOOSH admin-only, or would it be useful for a user (to upload files or edit content from the command line)?
If not, are you aware of any other tool that would?
Thanks a lot anyway..
Matteo
Twig dev-master requires PHP >= 5.5 - installing Moosh on Ubuntu Precise 12.04 (php 5.3.10) fails. I've installed on Precise a number of times previously using the same provisioning playbook without issue so would appear that something has changed recently at the Twig end.
Even though the dependency in composer.json
is on a very specific old commit: dev-master#4cf7464348e7f9893a93f7096a90b73722be99cf , the fact that it's called "dev-master", brings PHP >= 5.5 dependency. Error output (via Ansible provisioning script):
stderr: Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for twig/twig dev-master#4cf7464348e7f9893a93f7096a90b73722be99cf -> satisfiable by twig/twig[dev-master].
- twig/twig dev-master requires php >=5.5.0 -> your PHP version does not satisfy that requirement.
FATAL: all hosts have already failed -- aborting
The "Installation from Ubuntu package" section of homepage don't provide the repository's public key (if this is supposed to be automatically added by apt-add-repository, it wasn't for me), resulting in warnings if you manually install and potentially causing bigger problems for automated installs (I'd love to integrate this into a Moodle role for Ansible).
Could you please include downloading and adding the repo's public key to the instructions?
I can create roles using moosh role-create -d "Desc" -a teacher -n "Moosh role" mooshrole
, expecting the new role to inherit the archetype's capabilities. Instead, all the new role's capabilities are "Not set".
It would be much more useful if the capabilities were included, so I'm attempting to do that by modifying RoleCreate.php to use core_role_define_role_table_advanced, instead of create_role().
Any suggestions or other thoughts?
Hi,
if I use the "-i" option for file-list, i.e:
"moosh file-list -i course=26 | moosh file-path -s -r | tar -C $(moosh config-get core dataroot) -T - -czf /home/admin/dateiablage.tgz"
I get this PHP error:
"Default exception handler: Fehler beim Schreiben der Datenbank Debug: Duplicate entry '' for key 'mdl_sess_sid_uix'
INSERT INTO mdl_sessions (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip) VALUES(?,?,?,?,?,?,?,?)
[array (
0 => 0,
1 => '',
2 => NULL,
3 => '2',
4 => 1427271809,
5 => 1427271809,
6 => '0.0.0.0',
7 => '0.0.0.0',
)]
Error code: dmlwriteexception
tar: File '!!! Fehler beim Schreiben der Datenbank !!!' not found: Kann stat nicht ausführen: Datei oder Verzeichnis nicht gefunden
tar: Beende mit Fehlerstatus aufgrund vorheriger Fehler
"
Without the "-i" option the tar file is created but not with the real files in it. Instead the relative path in moodledata are compressed, i.e "filedir/00/..."
What goes wrong here?
Thanks
Andreas
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.