Moodle for mobile

Question type plugins for the 3.5 App

 
Picture of Marcus Green
Question type plugins for the 3.5 App
Core developersParticularly helpful MoodlersPlugin developersTesters

I was having an online chap with the excellent Dani Palou recently and he was giving me advice on creating support for question type plugins for the new Moodle 3.5 app. I thought it would be best for everyone if I ask my questions in public so others might benefit. I have the app installed locally with access via chromium and I have faked duplicating my question type by copying stuff from core question types. Dani then said

'the idea is that in your PHP method you need to return a generic template, similar to the ones we use in the app (or that you used in your remote addon). This template will use JS data that the app will provide'

As the core question types do not have any php I was wondering where this code would go. Is it in the mobile.php file as described here?

https://docs.moodle.org/dev/Mobile_support_for_plugins#Step_1._Update_the_db.2Fmobile.php_file





 
Average of ratings: -
Picture of Elton LaClare
Re: Question type plugins for the 3.5 App
 

Thank you Marcus. I think it's very useful to initiate your questions on the forum in this way. This should help to create a knowledge base that others designing remote add-ons can refer to.

 
Average of ratings: Useful (1)
Picture of Dani Palou
Re: Question type plugins for the 3.5 App
Core developersMoodle HQParticularly helpful MoodlersPlugin developers

Hi Marcus,

sorry for the delay in answering, it's been some crazy months lately.

The process is the same as in the certificate example: create the mobile.php file, create a PHP function that returns a template/javascript/etc. and then create the template. The difference is that the certificate activity builds the template using PHP data because that template is downloaded when the user opens the activity (hence it has the cmid and courseid).

In question types your function is called as soon as the app is started, so there's no context, that's why you need to return a generic template. Instead of getting the data using PHP and use it to render the data, you need to return a "generic" template that will be built using JS data provided by the app. Your template will receive these inputs and outputs:

https://github.com/moodlehq/moodlemobile2/blob/v3.5.0/src/core/question/classes/base-question-component.ts#L25

Cheers,

Dani

 
Average of ratings: -