Hi, I have three developer questions about the Moodle mobile app. (We are in the process of developing support for some of our plugins so that we can eventually release it for our students.)
Overall the app and plugin support is really good now and we are making good progress - also the mobile team are awesome, thank you for all the help in developer chat. But we have a few slightly complicated questions that I thought would be worth asking in the forum since it's a bit more public and maybe other people will know, or else be interested in, the answers...
Also if we do get answers I am happy to add them to the existing wiki documentation if I can find somewhere appropriate.
So here goes:
1 Mechanism for queuing offline activity
When writing code for a plugin, there doesn’t seem to be an easy-to-use/generic way to queue actions offline in order to send them to the server when next offline. I did spot some code called ‘cron’ which seems to have a way to schedule tasks when online but that looks complicated…
I was sort of hoping for an API like:
that.CoreSitesProvider.getCurrentSite().writeNowOrWhenOnline(
'mod_oucontent_record_page_view',
{ cmid: myValue, data2: otherValue });
Maybe with some extra parameters for some cases, like which bits of cache to purge after it succeeds (for example where the value might potentially have been changed elsewhere too).
Is there something like this and I missed it? Or if not, if this is already feasible but more complicated – can anyone suggest where in the app code is the best example to rip off?
2 Completion (progress) tickboxes
These don’t seem to work when offline. Shouldn’t it queue
the progress tick? Same kind of thing as question 1 really. Just wondering if we're missing something and the app actually does do it, or there's a tracker issue already that I didn't find.
The main use case here is, supposing there are progress tickboxes against some documents (e.g. Page activities). The user downloads the course in advance, then takes a plane trip and reads through the Page activities while offline. After reading each one, they try to tick the progress box to indicate they finished it, but it doesn’t work.
3 Deleting old data
Unless we have misunderstood the way it works, whenever you view something it is cached on your device in the same way as if you manually chose to download it. For example if you view a Page with a picture in it, it will cache both the web service result (the page contents) and the file (the picture). This is the same thing that would happen if you hit Download before viewing it. As a result, space is occupied on your device whether you manually Download or not.
You can manually delete all the files from the entire site using the option to delete storage from the main menu. But:
a. Is there any automatic deletion of old data so that if you keep viewing things over a few weeks, the older ones get deleted?
b. Is there any distinction between viewed and downloaded files? (E.g. if you only viewed it will get deleted automatically, but if you manually downloaded then it won’t.)
c.
I don’t think there is any way for a user to
manually delete data more specifically then for the entire site; for example,
for a single activity, section, or course. [I already filed a tracker issue about this.]
Unless there’s features we missed, it seems hard to understand how the app would work well for a content-heavy site (most OU sites are in the 10GB range, of which maybe half would be included if you did a full download to the app). I guess most people don’t host their own videos, but if you do, just viewing an activity could use up say 200MB and then you view the next one and the next… Even pictures or audio can add up...
--sam