A command-line tool inspired from git to sync content between a Moodle/Cyberlearn course page and a local folder.
It is currently tested on https://cyberlearn.hes-so.ch, which is a Moodle 2 platform (the only one I have access to). For Moodle 1, have a look at CybeJava-old. If you want support for your platform, contact me, I would be happy to help.
This project is split between two maven projects:
- cybe-lib is a library handling moodle/cyberlearn specifics. Classes allows you to easily connect, authenticate, list courses and resources, download files;
- cybe-cmdline is the actual terminal application. It is inspired by git for commands and behavior.
- Clone the repo
- Run
mvn packagein the root directory - Launch the cmdline jar, using
ava -jar cybe-cmdline/target/cybe-cmdline-<version>-full.jar
The command-line app includes a basic interpreter and also supports commands passed as program argument.
configuration
First of all, you need to enter your moodle/cyberlearn credentials and select your platform:
cybe init-global
This will create a file .cybeconf in your home directory with the following structure:
{
"username": "lucy.linder",
"password": "<encrypted pass>",
"target platform": "cyberlearn.hes-so"
}initialise a directory and pull resources
The system is ready to use.
Navigate to the directory you want to sync to and use the init command to tell cybe which course you want this folder to be bound to. This will create a .cybe inside the directory with some metadata. If you won't use cybe anymore, just delete the file.
Once a directory is initialised (i.e. contains a valid .cybe file), you can use pull to download all the resources (skipping the ones you already have) from the course page.
Here is an example:
java -jar cybe.jar
> init
Select a course
[0] C-PrivLaw-A - Privacy and Law
[1] GPU - Programmation parallèle sur GPU
[2] T-Alg - Algorithmique
[3] T-MachLe - Machine Learning
[4] VI - Visualisation de l'Information
Your choice [0-4] 4
Saving LocalConfig...
> pull
--> SAVING InfoVis09-2c.pdf (thread: 13)
...
--> SAVING InfoVisMSE_01.pdf (thread: 12)
--> SAVING UV_Intervention_He-Arc_v20161120.pdf (thread: 17)
> exit
Saving LocalConfig...
Cleaning up.
Done.
whenever you want, rerun pull to check for new resources.
renaming files: you can rename files downloaded by cybe. Out-of-the box, cybe will detect the change and won't re-download the renamed resources again. If you want to move a resource in another directory, just tell cybe with add-dir [path], so it can detect the resource is already present on the local machine (use rm-dir to undo).
changing password: simply rerun init-global and enter your new credentials.
downloading other types of resources: by default, cybe downloads resources of type "pdf", "text/plain", "zip" and "doc". If a course has different resources you want to automatically pull, run cybe add-ctype [type]. Note that this must be done on a folder basis.
> add-ctype tar html
tar : added.
html : added.
manually downloaded resources: if you already have some files in the directory (that cybe should not re-download/override), you can use the command resync: cybe will memorize the unique ids of the files present and ignore them in future pull. Note that it won't work if you renamed the files before the sync.
viewing the current config: the dump command will display the content of the .cybe file in the interpreter/terminal. It is the same result if you type cat .cybe in a unix-terminal.
- init: bind the current directory to one of your Cyberlearn course
- pinit: same as cybe init && cybe pull
- init-global: store your credentials once and for all
- add-origin url [urls]: add an url to the parsing process
- rm-origin url [urls]: remove an url from the parsing process
- add-ctype ctype [ctypes]: add a content-type to the list of valid resources
- rm-ctype ctype [ctypes]: remove a user-defined content-type. Note that this command
- add-dir path [paths]: mark the directory(-ies) as containing downloaded resources
- rm-dir path [paths]: remove the directory(-ies)
- pull: download the latest resources for the course bound
- resync: force a resync of the existing resources list. May be useful when the app bugged. Note that the whole list fileid <--> filename will be reset, so if some files were renamed, you need to manually edit the new .cybe file...
- oneshot url: parse the given url and download resources in the
- help: print a brief help message
- man: display the full documentation
- dump: display the content of the current local configuration
- open: open the course page in the default browser