Advice on making a question type work with Moodle Mobile2

Advice on making a question type work with Moodle Mobile2

by Marcus Green -
Number of replies: 2
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

I have been reading through the developer docs on Moodle Mobile2 

https://github.com/moodlehq/moodlemobile2

https://docs.moodle.org/dev/Moodle_Mobile

And I would like to make my Gapfill question type work with it.  The core question types work fine including the  draggy droppy OU questions which are a bit similar to mine, but I am quite sure where to start.  Does anyone have advice/suggestions/links?



Average of ratings: Useful (2)
In reply to Marcus Green

Re: Advice on making a question type work with Moodle Mobile2

by Dani Palou -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Marcus,

first of all you should be familiar with Angular and directives, since question types work as directives.

To start developing you should follow this guide:

https://docs.moodle.org/dev/Setting_up_your_development_environment_for_Moodle_Mobile_2

The easiest way to create your addon is to copy a similar question type from the mm2 repository and adapt it to your needs. For example, if your question type is similar to ddwtos then you should base your addon in it:

https://github.com/moodlehq/moodlemobile2/tree/master/www/addons/qtype/ddwtos

The structure of the addon is the following:

scss -> Custom styles for your addon.

directive.js -> The directive that will render your question. It will receive a question object in the scope. You can add a console log to inspect the properties of this question received.

handlers.js -> This service is the one that exposes your addon to the rest of the app. You can see the list of functions it can implement in this JSDoc.

main.js -> This is where the addon module is declared and initialised. Basically, you tell the app that this addon is a question type and its name.

render.js -> This is an adaptation to Angular of the JS code to make drag and drop work in Moodle: https://github.com/moodle/moodle/blob/master/question/type/ddwtos/yui/build/moodle-qtype_ddwtos-dd/moodle-qtype_ddwtos-dd.js

template.html -> The template of the directive.


I hope this helps you get started smile

Dani

Average of ratings: Useful (3)
In reply to Dani Palou

Re: Advice on making a question type work with Moodle Mobile2

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Many thanks for the detailed information Daniel.  I think I will wait a little longer before starting that development.