Note: You are currently viewing documentation for Moodle 3.8. Up-to-date documentation for the latest stable version of Moodle may be available here: Moodle app synchronization.

Moodle app synchronization: Difference between revisions

From MoodleDocs
(templates)
 
No edit summary
Line 1: Line 1:
{{Mobile}}
{{Mobile}}
{{stub}}
{{stub}}
== Automatic synchronization ==
When an activity that can generate offline data is opened in the app, that activity will always be synchronized if the device is connected. For example, opening a wiki in online will always try to synchronize '''that''' wiki (not all the wikis). If there is nothing to synchronize or the offline data is synchronized, the synchronization is successful.
Furthermore, each type of activity has an automatic synchronization process that runs every certain time (usually 10 minutes). Let's use wiki as example. When the wiki synchronization 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. 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:
# Time = 0. The wiki automatic sync process runs. Nothing to sync.
# Time = 5 minutes and 1 second. The user opens a wiki with no offline data, so the synchronization is successful.
# Time = 5 minutes and a few seconds. The user generates some offline data for that wiki.
# Time = 10 minutes. 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.
# Time = 20 minutes. The wiki automatic sync process runs again. Now the wiki is synchronized.
If an automatic synchronization runs when the device is offline, it will stop running until the device is online again. When the device 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:
# Forum sync process runs. Device is online, so it is executed.
# Device goes offline.
# Wiki sync process runs. Device is offline, so it stops being executed.
# Device goes online.
# 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'' there is a setting "''Allow sync only when on Wi-Fi''". If this is enabled and the device is using a 3G/4G connection, the automatic sync processes won't be run, their execution will be delayed for 10 minutes until the device uses a Wi-Fi connection.
Please notice that the automatic sync processes will only run if the app is alive, so if the app is closed then the data won't be synchronized until it is started again. Also, in iOS the app needs to be in foreground (active) in order to execute them, if it is put in background (minimized) the processes won't be executed until the app is in foreground again.
== Manual synchronization ==
When a user generates some data in offline, the app will display a message inside the activity telling that there is some data to be synchronized. Performing a Pull To Refresh in that view will synchronize the data of that activity, but not the rest of activities. The activity can also be synchronized by opening the context menu in the top right and clicking "''Synchronize''". So if a user performs 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 section) will do nothing.
In ''App Settings > Synchronization'' the app will display a list of the sites 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.

Revision as of 11:09, 21 December 2016


Automatic synchronization

When an activity that can generate offline data is opened in the app, that activity will always be synchronized if the device is connected. For example, opening a wiki in online will always try to synchronize that wiki (not all the wikis). If there is nothing to synchronize or the offline data is synchronized, the synchronization is successful.

Furthermore, each type of activity has an automatic synchronization process that runs every certain time (usually 10 minutes). Let's use wiki as example. When the wiki synchronization 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. 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 = 10 minutes. 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 synchronization runs when the device is offline, it will stop running until the device is online again. When the device 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. Device is online, so it is executed.
  2. Device goes offline.
  3. Wiki sync process runs. Device is offline, so it stops being executed.
  4. Device 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 there is a setting "Allow sync only when on Wi-Fi". If this is enabled and the device is using a 3G/4G connection, the automatic sync processes won't be run, their execution will be delayed for 10 minutes until the device uses a Wi-Fi connection.

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

Manual synchronization

When a user generates some data in offline, the app will display a message inside the activity telling that there is some data to be synchronized. Performing a Pull To Refresh in that view will synchronize the data of that activity, but not the rest of activities. The activity can also be synchronized by opening the context menu in the top right and clicking "Synchronize". So if a user performs 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 section) will do nothing.

In App Settings > Synchronization the app will display a list of the sites 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.