from graphene.types.generic import GenericScalar
from graphene_django import DjangoObjectType

from vbv_lernwelt.assignment.models import Assignment, AssignmentCompletion
from vbv_lernwelt.core.graphql.types import JSONStreamField
from vbv_lernwelt.course.schema import CoursePageInterface


class AssignmentType(DjangoObjectType):
    tasks = JSONStreamField()
    evaluation_tasks = JSONStreamField()
    performance_objectives = JSONStreamField()

    class Meta:
        model = Assignment
        interfaces = (CoursePageInterface,)
        fields = (
            "assignment_type",
            "intro_text",
            "effort_required",
            "evaluation_description",
            "evaluation_document_url",
        )


class AssignmentCompletionType(DjangoObjectType):
    completion_data = GenericScalar()

    class Meta:
        model = AssignmentCompletion
        fields = (
            "id",
            "created_at",
            "updated_at",
            "submitted_at",
            "evaluation_submitted_at",
            "assignment_user",
            "assignment",
            "course_session",
            "completion_status",
            "completion_data",
            "evaluation_user",
            "additional_json_data",
            "evaluation_grade",
            "evaluation_points",
        )
