-
Notifications
You must be signed in to change notification settings - Fork 305
Securesync: How Cross Computer Syncing Works
Students use KA Lite to view Khan Academy videos, do practice exercises, and to track their progress. Teachers can log in to view the progress of their students and try to figure out where their students need the most help.
In some larger deployments, an organization might want to install multiple KA Lite servers for students to connect to--for example, at different classrooms in a school with unreliable Internet access. We want students to be able to access their progress at those different locations, even though each location has it's own server and data is stored locally on that server.
Cross-computer syncing is the (automated) process of sharing the student data across KA Lite servers. This allows students to log in to other computers and still have their progress information available, and allows teachers to log into other computers to check the progress of their students.
Below are technical details about how this happens.
Syncing involves data, devices, and zones:
- Data are records of student activity--viewing movies, doing exercises, etc. Each time a student views a movie, a single record is created and stored.
- Devices are KA Lite content servers (local installations). Students use a web browser to connect to this KA Lite device to log in, view videos, and do exercises. Note: this "device" is usually different from the device the student uses to browse to KA Lite; here, "device" is the computer server running KA Lite.
- Zones are a group of devices that share data. They are created on our main website, as part of the post-installation setup of KA Lite.
Syncing happens between devices and our central server:
- The Central Server is our main website: http://kalite.learningequality.org/
In order for secure sync to be set up to run, a number of steps must occur:
- Devices must have KA Lite installed on them.
- Each device must "register" on the central server, joining a "zone" (within an organization controlled from a user's account).
Secure sync happens opportunistically, when a device is online (connect to the Internet). Syncing a device involves uploading data generated on that device, then downloading data from all other devices in the zone (including devices it never knew about before!).
In order to understand how that happens, first read about how we store data:
- When a user views a video or does an exercise, a record is either added or updated to the database of the KA Lite device that the video/exercise was downloaded from
- Added if it's the first time the user viewed that video or tried that exercise
- Updated if it's not the first time.
- Every time any record from any student is updated that device, marks the record with a time-stamp, and remembers that time-stamp.
- So each record knows when it was last updated, and the device knows when the last update anywhere on it was.
- NOTE: since times are unreliable, instead of trying to store the actual time-stamp, the device actually uses an integer ("counter") to represent the time-stamp.
Securesync works by:
- Creating a "Session" with the central server (establishes that the central server recognizes the connecting device)
- kalite/securesync/api_views.py:create_session on the current device's side
- kalite/securesync/api_client.py:start_session (SyncClient object) on the central server side
- Sync the device counts for each device in the zone
- The current device uploads its current record count
- kalite/securesync/api_client.py:sync_models on the current device's side
- kalite/securesync/api_views.py:upload_models on the central server's side
- The current device downloads the list of devices in it's own zone, and their current record counts.
- kalite/securesync/api_client.py:sync_device_records on the current device's side
- kalite/securesync/api_views.py:[device_download, device_upload] on the central server's side
- The current device uploads its current record count
- Sync the data records for each device in the zone
- The current device sees what the record count is for ITSELF on the central server, and uploads any records with a number greater than that.
- The current device sends it's record counts for all OTHER devices to the central server; the central server uses that to determine what records (across all devices in the zone) that are missing, and sends them.