#!/usr/bin/env python3
"""Genereer SCORM 1.2 package voor Storytelling eLearning"""

import os
import zipfile

output_path = "/root/projects/jg/2026-pbm-lions-storytelling/deliverables"
scorm_dir = os.path.join(output_path, "scorm")
os.makedirs(scorm_dir, exist_ok=True)

# imsmanifest.xml
manifest = """<?xml version="1.0" encoding="UTF-8"?>
<manifest identifier="LIONS_STORYTELLING_2026" version="1.0"
  xmlns="http://www.imsglobal.org/xsd/imscp_v1p1"
  xmlns:adlcp="http://www.adlnet.org/xsd/adlcp_v1p2"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <metadata>
    <schema>ADL SCORM</schema>
    <schemaversion>1.2</schemaversion>
  </metadata>
  <organizations default="LIONS_ORG">
    <organization identifier="LIONS_ORG">
      <title>Storytelling voor Lions 2026-2027</title>
      <item identifier="ITEM_1" identifierref="RES_1">
        <title>Storytelling eLearning Module</title>
      </item>
      <item identifier="ITEM_2" identifierref="RES_2">
        <title>Storytelling Quiz</title>
      </item>
    </organization>
  </organizations>
  <resources>
    <resource identifier="RES_1" type="webcontent" adlcp:scormtype="sco" href="index.html">
      <file href="index.html"/>
    </resource>
    <resource identifier="RES_2" type="webcontent" adlcp:scormtype="sco" href="quiz.html">
      <file href="quiz.html"/>
    </resource>
  </resources>
</manifest>"""

with open(os.path.join(scorm_dir, "imsmanifest.xml"), "w", encoding="utf-8") as f:
    f.write(manifest)

# Kopieer de HTML bestanden
import shutil

# eLearning als index.html
shutil.copy2(
    os.path.join(output_path, "html", "2026-LST-Storytelling-eLearning_v1.0.html"),
    os.path.join(scorm_dir, "index.html")
)

# Quiz als quiz.html
shutil.copy2(
    os.path.join(output_path, "html", "2026-LST-Storytelling-Quiz_v1.0.html"),
    os.path.join(scorm_dir, "quiz.html")
)

# Maak ZIP
scorm_zip = os.path.join(output_path, "2026-LST-Storytelling-SCORM_v1.0.zip")
with zipfile.ZipFile(scorm_zip, "w", zipfile.ZIP_DEFLATED) as zf:
    for fname in ["imsmanifest.xml", "index.html", "quiz.html"]:
        fpath = os.path.join(scorm_dir, fname)
        zf.write(fpath, fname)

print(f"✅ SCORM package: {scorm_zip}")
print(f"   Bestanden: imsmanifest.xml, index.html, quiz.html")
