A comprehensive validation script for MoFaCTS zip packages that validates structure, JSON syntax, keys, values, and cross-references based on the package uploader validation logic.
Windows:
- Download Python from python.org
- Run the installer and ensure "Add Python to PATH" is checked
- Verify installation:
python --version
macOS:
- Install using Homebrew:
brew install python - Or download from python.org
- Verify installation:
python3 --version
Linux:
- Ubuntu/Debian:
sudo apt update && sudo apt install python3 python3-pip - CentOS/RHEL:
sudo yum install python3 python3-piporsudo dnf install python3 python3-pip - Verify installation:
python3 --version
python3 package_validator.py <zip_file_path> [-v|--verbose]zip_file_path: Path to the zip package to validate-v, --verbose: Enable verbose output during validation
# Basic validation
python3 package_validator.py my_package.zip
# Verbose validation with detailed output
python3 package_validator.py my_package.zip -v- Package Structure: Ensures the zip contains at least one TDF-stimulus pair
- JSON Syntax: Validates all JSON files can be parsed correctly
- Stimulus Files: Comprehensive validation including:
- Required
setspec.clustersstructure - Each cluster has
stimsarray and optionalresponseType - Each stimulus has required fields and proper types
- Parameter validation (format like "0,.7")
- Optimal probability validation
- Response validation with unicode character warnings
- Display field validation
- Media reference validation
- Required
- TDF Files: Comprehensive validation including:
- Required
tutor.setspecstructure - Unit and unitTemplate validation
- Cluster index and assessmentsession validation
- Lesson name and stimulus file references
- Required
- Cross-references: Ensures TDF-referenced stimulus files exist and cluster indices are valid
- Media References: Checks that media files referenced in stimuli exist in the package or are valid URLs
- Must have
setspecobject withclustersarray (at least one cluster) - Each cluster must have
stimsarray (at least one stimulus) and optionalresponseType(string) - Each stimulus must have
response.correctResponse(string) response.incorrectResponses(if present) must be a string or array of strings- Warning: Stimuli with question-like display text but missing
incorrectResponses - Warning: Responses containing invisible unicode characters (\u0080-\u00FF) that will be removed
parameter(if present) should be in format "number,number" (e.g., "0,.7")optimalProb(if present) must be a number- Display fields (
text,audioSrc,imgSrc,videoSrc, etc.) must be strings if present - Optional fields like
speechHintExclusionList(string),alternateDisplays(array),tags(array)
- Must have
tutor.setspecobject - Must have valid
lessonname(non-empty string) - Must have
stimulusfile(string) - May have
experimentTarget(string, gets lowercased during processing) tutor.unitandtutor.unitTemplate(if present) must be arrays- Units can have
clusterIndex(number/string) andassessmentsessionobjects assessmentsession.clusterlist(if present) must be a valid cluster list format (e.g., "1,2,3-5")- Should have proper structure to prevent runtime errors during processing
- Referenced stimulus files must exist in the package
- Cluster indices referenced in TDF units must exist in the stimulus file
- Media file references must either be HTTP URLs or exist in the package
0: Validation successful1: Validation failed (errors found)
The script provides clear error and warning messages. In verbose mode, it shows progress during validation.