0.1.0 - ci-build

collabreefhirdocumentation - Local Development build (v0.1.0) built by the FHIR (HL7® FHIR® Standard) Build Tools. See the Directory of published versions

Quizzes System

Overview

The quiz system provides daily healthcare-related quizzes on a broad variety of topics to engage patients and reinforce healthcare knowledge. Each quiz is delivered within specific time windows and remains active for the day until completed. All quizzes come from the Collabree Study app and were previously stored in Firebase. All quizzes are now stored as static JSON files in the static/questionnaires directory and are aggregated in a Library resource of type module-definition located in the static/library directory, which references all available questionnaires via URLs to allow the application to discover and retrieve quizzes dynamically.

Each quiz follows a standardized format with a descriptive title and category classification. The quiz contains a single question with multiple choice answers. Each answer option includes feedback messages, and only one answer per quiz is considered correct (marked with an ordinal value of 10), while all incorrect answers have an ordinal value of 0.

Quiz Library

All quizzes are stored as static JSON files in the static/questionnaires directory and are organized through a Library resource of type module-definition located in the static/library directory. The Library serves as a central catalog that aggregates and references all available questionnaires via URLs, enabling the application to discover and retrieve quizzes dynamically at runtime. This Library-based approach follows FHIR best practices for content management, providing version control, extensibility, and standardized access to quiz resources.

Quiz Content

The quiz content is created by the Collabree team based on healthcare best practices and evidence-based information. Questions cover a broad variety of healthcare topics including medication safety, general health knowledge, disease management, etc…

The Library resource contains a list of all available quizzes through its content array, where each entry references a Questionnaire resource via a URL. When the application initializes, it retrieves this Library resource to discover which quizzes are available, then fetches individual Questionnaire resources as users interact with the quiz system. This design allows for easy updates to the quiz catalog without requiring application redeployment, as new quizzes can be added to the static files and the Library updated accordingly.

Migrations and Content Management

The quiz system includes a comprehensive migration tool (quizzes_manager) designed to maintain quiz content across format changes and ensure multilingual support. This tool plays a critical role in the evolution of the quiz system, bridging legacy data structures with modern FHIR standards while enhancing accessibility for diverse patient populations.

The migration tool performs three essential operations: (1) extracting quizzes from the legacy Firebase format and converting them to FHIR-compliant Questionnaire resources, as shown in the following example where a Firebase quiz structure is transformed into a FHIR Questionnaire with proper extensions, translations, and scoring mechanisms; (2) enriching existing quizzes with Arabic translations to support Middle Eastern patient populations using DeepL API integration; and (3) updating feedback extension configurations to ensure personalized feedback messages display correctly across all supported languages by fixing extension structures to comply with FHIR specifications.

Quiz Delivery and Scheduling

Quizzes are delivered daily between 6:00 AM and 6:00 PM (local time) with the exact delivery time randomized for each user. This randomization ensures that different users receive their quiz at different times, distributing system load and preventing simultaneous quiz generation activities. The randomization uses a secure random number generator to select a time within the 12-hour delivery window, creating a personalized quiz experience for each patient.

Each quiz remains available until the following day at 6:00 AM, providing a 24-hour window for completion. Users will see a quiz if they have available quizzes that haven't been completed, no quiz has been answered today (after 6:00 AM), and the current time is within the quiz's active period defined by the quiz's effective period. The system tracks quiz responses by timestamp to ensure only one quiz per day is delivered, maintaining engagement without overwhelming patients.

Pre-Generation

Quizzes are pre-generated for the next 7 days using the available questionnaire pool from the Library resource. During pre-generation, items within each selected quiz are shuffled to provide variety even when the same quiz is presented to different users. Each generated quiz is assigned an effective period with a random start time between 6:00 AM and 6:00 PM on the scheduled date, and an end time of 6:00 AM the following day.

All scheduled quizzes are stored locally in SharedPreferences as JSON resources. This local storage strategy ensures that patients can access their daily quiz even when network connectivity is unavailable. The system automatically removes quizzes from local storage when they are answered or when their effective period expires, preventing stale quiz data from being presented to users. Once all available quizzes from the Library have been answered, users see a message indicating they've finished all available quizzes, prompting them to wait for new quiz content to be added to the system.