test data import fix for scoring
Some checks failed
PHPUnit / test (push) Has been cancelled

This commit is contained in:
2026-06-08 19:44:58 +02:00
parent 3211d35b43
commit d16bd1b3c4
5 changed files with 85 additions and 22 deletions

View File

@ -14,7 +14,7 @@ SCALE = 5
RNG = random.Random(42)
ANCHOR = datetime(2026, 5, 27, 15, 30, 0)
BUNDLE_PATH = Path(__file__).resolve().parents[2] / "questionnaires_bundle_2026-05-28.json"
REPO_ROOT = Path(__file__).resolve().parents[2]
FALLBACK_QUESTIONNAIRE_IDS = [
"questionnaire_1_demographic_information",
@ -35,10 +35,20 @@ CLIENTS_WITHOUT_COMPLETIONS = 15 * SCALE
COMPLETION_PARTICIPATION = 0.82
def load_questionnaire_ids() -> list[str]:
if not BUNDLE_PATH.is_file():
def resolve_bundle_path() -> Path | None:
"""Use the newest questionnaires_bundle_*.json in the repo root."""
candidates = sorted(
REPO_ROOT.glob("questionnaires_bundle_*.json"),
key=lambda p: p.stat().st_mtime,
reverse=True,
)
return candidates[0] if candidates else None
def load_questionnaire_ids(bundle_path: Path | None) -> list[str]:
if bundle_path is None or not bundle_path.is_file():
return FALLBACK_QUESTIONNAIRE_IDS
bundle = json.loads(BUNDLE_PATH.read_text(encoding="utf-8"))
bundle = json.loads(bundle_path.read_text(encoding="utf-8"))
ids = [
item["questionnaire"]["questionnaireID"]
for item in bundle.get("questionnaires", [])
@ -153,7 +163,8 @@ def build_completions(
def main():
questionnaire_ids = load_questionnaire_ids()
bundle_path = resolve_bundle_path()
questionnaire_ids = load_questionnaire_ids(bundle_path)
admins = [
{"username": f"{PREFIX}admin_{i}", "location": f"Dev Admin Standort {i}"}
@ -185,7 +196,7 @@ def main():
total_uploads = sum(c["versions"] for c in completions)
multi_version_pairs = sum(1 for c in completions if c["versions"] > 1)
bundle_note = BUNDLE_PATH.name if BUNDLE_PATH.is_file() else "fallback questionnaire list"
bundle_note = bundle_path.name if bundle_path and bundle_path.is_file() else "fallback questionnaire list"
fixture = {
"fixtureVersion": 2,
@ -216,7 +227,7 @@ def main():
},
}
out = Path(__file__).resolve().parents[2] / "dev-test-fixture.json"
out = REPO_ROOT / "dev-test-fixture.json"
out.write_text(json.dumps(fixture, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
print(f"Wrote {out}")
print(json.dumps(fixture["stats"], indent=2))