Back to news list

Robust sync to better handle errors in files

Posted on 2024-07-23 by Matt West

Nathan Walters has re-implemented the course "sync" logic inside PrairieLearn. The sync code translates the course configuration files from the on-disk git repository into the live database, and the old sync code used to stop at the first error in a JSON file. In contrast, the new sync code will keep going and sync all the rest of the course.

This change is especially useful if multiple people are editing course content at the same time in the online web editor. Now, if one person introduces an error in a question or assessment, everyone else can continue editing different questions and assessments without interruption. Before, everyone used to have to wait until the error was fixed.

The sync code is one of the core components of PrairieLearn so rewriting it was a significant challenge. Syncing a course configuration that contains errors is especially difficult because there are many dependencies between objects in PrairieLearn. For example, if a question file contains errors, what should happen to assessments which use that question? Nathan developed an elegant new syncing algorithm that has the correct behavior in all such situations—a very impressive achievement! The new sync code also comes with a test suite that verifies its behavior in many edge cases.