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?
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.
sorry for the delay in answering, it's been some crazy months lately.
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: