Skip to content

Latest commit

 

History

History
14 lines (8 loc) · 3.34 KB

change-statements.md

File metadata and controls

14 lines (8 loc) · 3.34 KB

Guide to Changing Statements

So you've found a statement that you'd like to change. If you're not comfortable with PHP or can't get to grips with Moodle's logstore, then you should probably ask for the change in a new issue via our Github issue tracker and hopefully someone will have some time to make the changes you require.

If PHP and the logstore aren't scaring you away 🤘, then the first thing you need to do is install the plugin using Git. Once you've installed the plugin using Git, all of the code in this Git repository will be in the "admin/tool/log/store/xapi" directory path from the root directory of your Moodle installation.

Now hold your horses 🏇, before you dive in and edit some code, we need to do a bit of house keeping so that your changes are easy to review and more likely to get merged. Open up your terminal, change to the directory of the plugin ("admin/tool/log/store/xapi"), and then create a new Git branch for your modifications using git checkout master && git pull && git checkout -b A_BRANCH_NAME_FOR_YOUR_CHANGES.

With the house keeping taken care of you now need to track down the transformer for the statement. We've tried to make tracking this down a piece of cake 🍰, if you look at the statement you'd like to change, you should see that inside the statement.context.extensions there is a property with the URL of http://lrs.learninglocker.net/define/extensions/info. Inside that property is a property called event_function and the value of that will be something like \\src\\transformer\\events\\mod_quiz\\attempt_submitted. This value is the file path to the function that transforms the logstore event into an array of xAPI statements. If you look inside the src directory of the plugin you should be able to follow this file path to the function that you'll need to change. For the value above that takes you to the attempt_submitted transformer.

Once you've tracked down the transformer, make the changes you require and then test those changes by running ./vendor/bin/phpunit in your terminal from inside the plugin directory. You'll probably need to change the tests a little in order for them to pass since the tests check the properties and values of the statement. To change the tests, take a look in the tests directory of the plugin, you'll find that it's structured very similarly to the src/transformer directory. You should also notice that each test is made up of 4 files, this is explained in our testing guide.

When you've got those pesky tests passing again ✅, it's time to commit your changes and make a pull request. To commit all of your changes you can run git add -A && git commit -am "A_DESCRIPTION_OF_YOUR_CHANGES && git push". To make a pull request you can follow Github's guide for creating a pull request from a fork. Once your pull request is made, your changes will be reviewed and merged by a maintainer.

If you're having some issues with this guide, we're really sorry 😞 and we'd like to improve it for you, so please create a new issue on our Github issue tracker.