Synchronizing activities completed offline in Moodle Mobile

Synchronizing activities completed offline in Moodle Mobile

by Jacob Prichard -
Number of replies: 1
Hello,

While testing how different activities behave in Moodle Mobile I ran into the question of "when do activities that are completed offline sync to Moodle after regaining an internet connection?"

Specifically, this is regarding

-posting to Forums

-choosing an option from the Choice activity

-adding a Wiki entry

After preforming each action above while offline, I backed out to the Topic page. Doing a "Pull to refresh" from the Topic page did not update any activity, but going back to the activity itself and doing a "Pull to refresh" would synchronize the data. 

I remember reading that offline activity data should be synced after regaining the internet connection, so I'm wondering if only certain actions trigger the sync or if simply after say 5-10 minutes it will automatically synchronize.

Any insight is much appreciated. Thanks!

Average of ratings: -
In reply to Jacob Prichard

Re: Synchronizing activities completed offline in Moodle Mobile

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 Jacob,

the sync process is a bit complex since it has several conditions, I'll try to explain it as clear as possible smile

We have 2 ways of synchronization: automatic and manual.

Automatic sync

When you open an activity that can generate offline data it will always be synchronized if you are online. So opening a wiki in online will always try to synchronize that wiki (not all the wikis). If there is nothing to sync or the offline data is synchronized, the synchronization is successful.

Besides, each type of activity has an automatic sync process that runs every certain time (usually 10 minutes). Let's use wiki as example. When the wiki sync process runs, it will synchronize all the wikis that have offline data and haven't been synchronized in the last 5 minutes. This is to decrease the data usage of the app, since the server might be down and we don't want to send the data too often. This means that an activity could take up to 15 minutes to be synchronized in the worst case scenario. Example of the worst case scenario:

  1. Time = 0. The wiki automatic sync process runs. Nothing to sync.
  2. Time = 5 minutes and 1 second. The user opens a wiki with no offline data, so the synchronization is successful.
  3. Time = 5 minutes and a few seconds. The user generates some offline data for that wiki.
  4. Time = 10minutes. The wiki automatic sync process runs again. The wiki has offline data, but it has been synchronized in less than 5 minutes (step 2), so it isn't synchronized again.
  5. Time = 20 minutes. The wiki automatic sync process runs again. Now the wiki is synchronized.

If an automatic sync runs when the app is offline, it will stop running until the app is online again. When the app goes back online, all the automatic sync processes that were stopped will be run immediately, synchronizing the activities with offline data that weren't synchronized in the last 5 minutes. Example:

  1. Forum sync process runs. App is online, so it is executed.
  2. App goes offline.
  3. Wiki sync process runs. App is offline, so it stops being executed.
  4. App goes online.
  5. Wiki sync process is executed since it was stopped. Forum isn't executed yet because it wasn't stopped, it will be executed after 10 minutes from step 1.

Finally, in App Settings > Synchronization you'll see a setting "Allow sync only when on Wi-Fi". If this is enabled and you're using a 3G/4G connection, the automatic sync proccesses won't be run, their execution will be delayed for 10 minutes until you use a Wi-Fi connection.

Please notice that the automatic sync processes will only run if the app is alive, so if you close the app the data won't be synchronized until you start it again. Also, in iOS the app needs to be in foreground (active) in order to execute them, if you put it in background (minimize it) the processes won't be executed until you put the app in foreground again.

Manual sync

When you do some action in offline and it is stored, you should see a message telling you that there is some data to be synchronized inside the activity. Performing a Pull To Refresh in that screen will synchronize the data of that activity, but not the rest of activities. You can also synchronize the data by opening the context menu (in the top right) and clicking "Synchronize". So if you perform a Pull To Refresh in a certain wiki, only that wiki will be synchronized. Performing a Pull To Refresh outside of the activity (e.g. in the Topic section) will do nothing.

If you go to App Settings > Synchronization you'll see a list of the sites you have stored in the app. Clicking the refresh button next to a site is going to execute all the automatic sync processes right now, so all the activities with offline data that haven't been synchronized in the last 5 minutes will be synchronized.


That's it, I hope I explained myself. Please let me know if you have any doubt about this.

Cheers,

Dani

Average of ratings: Useful (1)