# Generated by Django 6.0.2 on 2026-02-20 08:40

import django.db.models.deletion
import wagtail.blocks
import wagtail.fields
import wagtail.snippets.blocks
from django.conf import settings
from django.db import migrations, models

import wagtail_lms.models


class Migration(migrations.Migration):
    dependencies = [
        ("wagtail_lms", "0001_initial"),
        ("wagtailcore", "0091_remove_revision_submitted_for_moderation"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="H5PActivity",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("title", models.CharField(max_length=255)),
                ("description", models.TextField(blank=True)),
                (
                    "package_file",
                    models.FileField(
                        upload_to=wagtail_lms.models._h5p_package_upload_path
                    ),
                ),
                ("extracted_path", models.CharField(blank=True, max_length=500)),
                ("main_library", models.CharField(blank=True, max_length=255)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("h5p_json", models.JSONField(blank=True, default=dict)),
            ],
            options={
                "verbose_name": "H5P Activity",
                "verbose_name_plural": "H5P Activities",
            },
        ),
        migrations.CreateModel(
            name="LessonPage",
            fields=[
                (
                    "page_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        parent_link=True,
                        primary_key=True,
                        serialize=False,
                        to="wagtailcore.page",
                    ),
                ),
                ("intro", wagtail.fields.RichTextField(blank=True)),
                (
                    "body",
                    wagtail.fields.StreamField(
                        [
                            ("paragraph", wagtail.blocks.RichTextBlock()),
                            (
                                "h5p_activity",
                                wagtail.blocks.StructBlock(
                                    [
                                        (
                                            "activity",
                                            wagtail.snippets.blocks.SnippetChooserBlock(
                                                "wagtail_lms.H5PActivity"
                                            ),
                                        )
                                    ]
                                ),
                            ),
                        ],
                        blank=True,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
            bases=("wagtailcore.page",),
        ),
        migrations.CreateModel(
            name="H5PAttempt",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("started_at", models.DateTimeField(auto_now_add=True)),
                ("last_accessed", models.DateTimeField(auto_now=True)),
                (
                    "completion_status",
                    models.CharField(
                        choices=[
                            ("not_attempted", "Not Attempted"),
                            ("incomplete", "Incomplete"),
                            ("completed", "Completed"),
                            ("unknown", "Unknown"),
                        ],
                        default="not_attempted",
                        max_length=20,
                    ),
                ),
                (
                    "success_status",
                    models.CharField(
                        choices=[
                            ("passed", "Passed"),
                            ("failed", "Failed"),
                            ("unknown", "Unknown"),
                        ],
                        default="unknown",
                        max_length=20,
                    ),
                ),
                ("score_raw", models.FloatField(blank=True, null=True)),
                ("score_min", models.FloatField(blank=True, null=True)),
                ("score_max", models.FloatField(blank=True, null=True)),
                ("score_scaled", models.FloatField(blank=True, null=True)),
                (
                    "activity",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="wagtail_lms.h5pactivity",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "H5P Attempt",
                "verbose_name_plural": "H5P Attempts",
                "unique_together": {("user", "activity")},
            },
        ),
        migrations.CreateModel(
            name="H5PXAPIStatement",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("verb", models.CharField(max_length=255)),
                ("verb_display", models.CharField(blank=True, max_length=255)),
                ("statement", models.JSONField()),
                ("timestamp", models.DateTimeField(auto_now_add=True)),
                (
                    "attempt",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="xapi_statements",
                        to="wagtail_lms.h5pattempt",
                    ),
                ),
            ],
            options={
                "verbose_name": "H5P xAPI Statement",
                "verbose_name_plural": "H5P xAPI Statements",
            },
        ),
        migrations.CreateModel(
            name="H5PContentUserData",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("data_type", models.CharField(max_length=255)),
                ("sub_content_id", models.PositiveIntegerField(default=0)),
                ("value", models.TextField(blank=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "attempt",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="content_user_data",
                        to="wagtail_lms.h5pattempt",
                    ),
                ),
            ],
            options={
                "verbose_name": "H5P Content User Data",
                "verbose_name_plural": "H5P Content User Data",
                "unique_together": {("attempt", "data_type", "sub_content_id")},
            },
        ),
        migrations.CreateModel(
            name="LessonCompletion",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("completed_at", models.DateTimeField(auto_now_add=True)),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "lesson",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="wagtail_lms.lessonpage",
                    ),
                ),
            ],
            options={
                "verbose_name": "Lesson Completion",
                "verbose_name_plural": "Lesson Completions",
                "unique_together": {("user", "lesson")},
            },
        ),
    ]
