Moodle for mobile

Moodle mobile app questions - offline, storage

 
Picture of sam marshall
Moodle mobile app questions - offline, storage
Core developersParticularly helpful MoodlersPlugin developersTesters

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? smile

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

 
Average of ratings: Useful (1)
Picture of Helen Foster
Re: Moodle mobile app questions - offline, storage
Core developersDocumentation writersMoodle HQParticularly helpful MoodlersPlugin developersTestersTranslators

Hi Sam,

Sorry I can't help with any of your questions, however just to note that I'm moving your post from the general dev forum to the mobile forum as suggested by Juan, since mobile devs usually hang out there!

PS I agree about the mobile team being awesome smile

 
Average of ratings: -
Picture of Dani Palou
Re: Moodle mobile app questions - offline, storage
Core developersMoodle HQParticularly helpful MoodlersPlugin developers

Hi Sam!

1 Mechanism for queuing offline activity

The only way to do it right now is using the "cron" service: CoreCronDelegate. The original app (v1) had something like you're describing (a queue of WS calls), but in v2 we moved it to a cron service because it's way more powerful.

You'll see that most activities have a provider whose file name is "sync" or similar and another one called "sync-cron-handler". These providers implement a task to be used in the CoreCronDelegate, and are the ones responsible to synchronize the data. Please notice that each plugin is responsible to store its offline data. So, as you said, there is no easy way to achieve this.

You might want to look at a simple activity, like choice, to get an idea of how it looks like. You'll see that it has an offline provider, this is the one responsible of storing the data to be sent later. It can be a complex task to support all of this using the plugin system.

2 Completion (progress) tickboxes

Right now events and similar don't work in offline, it's something we've been wanted to improve for a while now but we still haven't had the chance to do it. It's in our roadmap though.

3 Deleting old data

Some activities download everything when they're opened (like Page, Book, some mod_resource, SCORM, offline quizzes), but some others only download the required part to view that page (like lesson, workshop, etc.).

a. No, we don't have any automatic deletion of data.

b. No, the data stored is exactly the same so we don't have any way to distinguish between them. It could be a nice improvement if an automatic deletion is implemented.

c. All downloadable activities implement an option to delete the data for the activity, it's accessible in the first page of the activity, using the top-right menu. The activities that implement it do:

  • Call this.courseHelper.fillContextMenu <- To load the required data, like the size of the files.
  • In the template, add a core-context-menu-item that calls removeFiles().
  • In the removeFiles function, call this.courseHelper.confirmAndRemoveFiles.

I haven't tested if this works in a plugin though. In my TODO list I have an entry about making this easier for plugins, but I'm not sure when I'll be able to take a look at that.


Please let me know if you have any other question smile

Cheers,

Dani


 
Average of ratings: Useful (1)
Picture of sam marshall
Re: Moodle mobile app questions - offline, storage
Core developersParticularly helpful MoodlersPlugin developersTesters

Thanks very much for your answers smile This is really helpful. A lot of the time, I can see what I think it is doing, but I'm not certain because I'm not still that familiar with the app so I may have missed something - getting things confirmed (or corrected) is really useful.

Re the first point about storing the offline data - we will look at choice as an example, thank you for the pointer.

Re the last one about deleting data - we hadn't spotted the delete option in activities! As a starting point we'll try to make our own plugins do the same.

--sam


 
Average of ratings: -