# coding: utf-8

"""
    Moodle Webservice API

    Auto-generated OpenAPI spec for Moodle's Webservice API.

    The version of the OpenAPI document: 5.0.3 (Build: 20251006)
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from poodle_async_full.models.core_block_get_course_blocks_response_blocks_inner_contents_files_inner import CoreBlockGetCourseBlocksResponseBlocksInnerContentsFilesInner
from typing import Optional, Set
from typing_extensions import Self

from poodle_async_full.configuration import settings

class ModScormGetScormsByCoursesResponseScormsInner(BaseModel):
    """
    SCORM
    """ # noqa: E501
    auto: Optional[StrictBool] = Field(default=None, description="Auto continue?")
    autocommit: Optional[StrictBool] = Field(default=None, description="Save track data automatically?")
    completionscorerequired: Optional[StrictInt] = Field(default=None, description="Minimum score required")
    completionstatusallscos: Optional[StrictInt] = Field(default=None, description="Require all scos to return completion status")
    completionstatusrequired: Optional[StrictInt] = Field(default=None, description="Status passed/completed required?")
    course: Optional[StrictInt] = Field(description="Course id")
    coursemodule: Optional[StrictInt] = Field(description="Course module id")
    displayattemptstatus: Optional[StrictInt] = Field(default=None, description="How to display attempt status")
    displaycoursestructure: Optional[StrictBool] = Field(default=None, description="Display contents structure")
    forcecompleted: Optional[StrictBool] = Field(default=None, description="Status current attempt is forced to \"completed\"")
    forcenewattempt: Optional[StrictInt] = Field(default=None, description="Controls re-entry behaviour")
    grademethod: Optional[StrictInt] = Field(default=None, description="Grade method")
    groupingid: Optional[StrictInt] = Field(default=None, description="Group id")
    groupmode: Optional[StrictInt] = Field(default=None, description="Group mode")
    height: Optional[StrictInt] = Field(default=None, description="Frame height")
    hidebrowse: Optional[StrictBool] = Field(default=None, description="Disable preview mode?")
    hidetoc: Optional[StrictInt] = Field(default=None, description="How to display the SCORM structure in player")
    id: Optional[StrictInt] = Field(description="Activity instance id")
    intro: Optional[StrictStr] = Field(description="Activity introduction")
    introfiles: Optional[List[CoreBlockGetCourseBlocksResponseBlocksInnerContentsFilesInner]] = Field(default=None, description="Files in the introduction")
    introformat: Optional[StrictInt] = Field(description="intro format (1 = HTML, 0 = MOODLE, 2 = PLAIN, or 4 = MARKDOWN)")
    lang: Optional[StrictStr] = Field(default=None, description="Forced activity language")
    lastattemptlock: Optional[StrictBool] = Field(default=None, description="Prevents to launch new attempts once finished")
    launch: Optional[StrictInt] = Field(default=None, description="First content to launch")
    maxattempt: Optional[StrictInt] = Field(default=None, description="Maximum number of attemtps")
    maxgrade: Optional[StrictInt] = Field(default=None, description="Max grade")
    md5hash: Optional[StrictStr] = Field(default=None, description="MD5 Hash of package file")
    name: Optional[StrictStr] = Field(description="Activity name")
    nav: Optional[StrictInt] = Field(default=None, description="Show navigation buttons")
    navpositionleft: Optional[StrictInt] = Field(default=None, description="Navigation position left")
    navpositiontop: Optional[StrictInt] = Field(default=None, description="Navigation position top")
    options: Optional[StrictStr] = Field(default=None, description="Additional options")
    packagesize: Optional[StrictInt] = Field(default=None, description="SCORM zip package size")
    packageurl: Optional[StrictStr] = Field(default=None, description="SCORM zip package URL")
    popup: Optional[StrictInt] = Field(default=None, description="Display in current or new window")
    protectpackagedownloads: Optional[StrictBool] = Field(default=None, description="Protect package downloads?")
    reference: Optional[StrictStr] = Field(default=None, description="Reference to the package")
    revision: Optional[StrictInt] = Field(default=None, description="Revison number")
    scormtype: Optional[StrictStr] = Field(default=None, description="SCORM type")
    section: Optional[StrictInt] = Field(default=None, description="Course section id")
    sha1hash: Optional[StrictStr] = Field(default=None, description="Package content or ext path hash")
    skipview: Optional[StrictInt] = Field(default=None, description="How to skip the content structure page")
    timeclose: Optional[StrictInt] = Field(default=None, description="Available to")
    timemodified: Optional[StrictInt] = Field(default=None, description="Time of last modification")
    timeopen: Optional[StrictInt] = Field(default=None, description="Available from")
    updatefreq: Optional[StrictInt] = Field(default=None, description="Auto-update frequency for remote packages")
    version: Optional[StrictStr] = Field(default=None, description="SCORM version (SCORM_12, SCORM_13, SCORM_AICC)")
    visible: Optional[StrictBool] = Field(default=None, description="Visible")
    whatgrade: Optional[StrictInt] = Field(default=None, description="What grade")
    width: Optional[StrictInt] = Field(default=None, description="Frame width")
    __properties: ClassVar[List[str]] = ["auto", "autocommit", "completionscorerequired", "completionstatusallscos", "completionstatusrequired", "course", "coursemodule", "displayattemptstatus", "displaycoursestructure", "forcecompleted", "forcenewattempt", "grademethod", "groupingid", "groupmode", "height", "hidebrowse", "hidetoc", "id", "intro", "introfiles", "introformat", "lang", "lastattemptlock", "launch", "maxattempt", "maxgrade", "md5hash", "name", "nav", "navpositionleft", "navpositiontop", "options", "packagesize", "packageurl", "popup", "protectpackagedownloads", "reference", "revision", "scormtype", "section", "sha1hash", "skipview", "timeclose", "timemodified", "timeopen", "updatefreq", "version", "visible", "whatgrade", "width"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of ModScormGetScormsByCoursesResponseScormsInner from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of each item in introfiles (list)
        _items = []
        if self.introfiles:
            for _item_introfiles in self.introfiles:
                if _item_introfiles:
                    _items.append(_item_introfiles.to_dict())
            _dict['introfiles'] = _items
        # set to None if auto (nullable) is None
        # and model_fields_set contains the field
        if self.auto is None and "auto" in self.model_fields_set:
            _dict['auto'] = None

        # set to None if autocommit (nullable) is None
        # and model_fields_set contains the field
        if self.autocommit is None and "autocommit" in self.model_fields_set:
            _dict['autocommit'] = None

        # set to None if completionscorerequired (nullable) is None
        # and model_fields_set contains the field
        if self.completionscorerequired is None and "completionscorerequired" in self.model_fields_set:
            _dict['completionscorerequired'] = None

        # set to None if completionstatusallscos (nullable) is None
        # and model_fields_set contains the field
        if self.completionstatusallscos is None and "completionstatusallscos" in self.model_fields_set:
            _dict['completionstatusallscos'] = None

        # set to None if completionstatusrequired (nullable) is None
        # and model_fields_set contains the field
        if self.completionstatusrequired is None and "completionstatusrequired" in self.model_fields_set:
            _dict['completionstatusrequired'] = None

        # set to None if course (nullable) is None
        # and model_fields_set contains the field
        if self.course is None and "course" in self.model_fields_set:
            _dict['course'] = None

        # set to None if coursemodule (nullable) is None
        # and model_fields_set contains the field
        if self.coursemodule is None and "coursemodule" in self.model_fields_set:
            _dict['coursemodule'] = None

        # set to None if displayattemptstatus (nullable) is None
        # and model_fields_set contains the field
        if self.displayattemptstatus is None and "displayattemptstatus" in self.model_fields_set:
            _dict['displayattemptstatus'] = None

        # set to None if displaycoursestructure (nullable) is None
        # and model_fields_set contains the field
        if self.displaycoursestructure is None and "displaycoursestructure" in self.model_fields_set:
            _dict['displaycoursestructure'] = None

        # set to None if forcecompleted (nullable) is None
        # and model_fields_set contains the field
        if self.forcecompleted is None and "forcecompleted" in self.model_fields_set:
            _dict['forcecompleted'] = None

        # set to None if forcenewattempt (nullable) is None
        # and model_fields_set contains the field
        if self.forcenewattempt is None and "forcenewattempt" in self.model_fields_set:
            _dict['forcenewattempt'] = None

        # set to None if grademethod (nullable) is None
        # and model_fields_set contains the field
        if self.grademethod is None and "grademethod" in self.model_fields_set:
            _dict['grademethod'] = None

        # set to None if groupingid (nullable) is None
        # and model_fields_set contains the field
        if self.groupingid is None and "groupingid" in self.model_fields_set:
            _dict['groupingid'] = None

        # set to None if groupmode (nullable) is None
        # and model_fields_set contains the field
        if self.groupmode is None and "groupmode" in self.model_fields_set:
            _dict['groupmode'] = None

        # set to None if height (nullable) is None
        # and model_fields_set contains the field
        if self.height is None and "height" in self.model_fields_set:
            _dict['height'] = None

        # set to None if hidebrowse (nullable) is None
        # and model_fields_set contains the field
        if self.hidebrowse is None and "hidebrowse" in self.model_fields_set:
            _dict['hidebrowse'] = None

        # set to None if hidetoc (nullable) is None
        # and model_fields_set contains the field
        if self.hidetoc is None and "hidetoc" in self.model_fields_set:
            _dict['hidetoc'] = None

        # set to None if id (nullable) is None
        # and model_fields_set contains the field
        if self.id is None and "id" in self.model_fields_set:
            _dict['id'] = None

        # set to None if intro (nullable) is None
        # and model_fields_set contains the field
        if self.intro is None and "intro" in self.model_fields_set:
            _dict['intro'] = None

        # set to None if introformat (nullable) is None
        # and model_fields_set contains the field
        if self.introformat is None and "introformat" in self.model_fields_set:
            _dict['introformat'] = None

        # set to None if lang (nullable) is None
        # and model_fields_set contains the field
        if self.lang is None and "lang" in self.model_fields_set:
            _dict['lang'] = None

        # set to None if lastattemptlock (nullable) is None
        # and model_fields_set contains the field
        if self.lastattemptlock is None and "lastattemptlock" in self.model_fields_set:
            _dict['lastattemptlock'] = None

        # set to None if launch (nullable) is None
        # and model_fields_set contains the field
        if self.launch is None and "launch" in self.model_fields_set:
            _dict['launch'] = None

        # set to None if maxattempt (nullable) is None
        # and model_fields_set contains the field
        if self.maxattempt is None and "maxattempt" in self.model_fields_set:
            _dict['maxattempt'] = None

        # set to None if maxgrade (nullable) is None
        # and model_fields_set contains the field
        if self.maxgrade is None and "maxgrade" in self.model_fields_set:
            _dict['maxgrade'] = None

        # set to None if md5hash (nullable) is None
        # and model_fields_set contains the field
        if self.md5hash is None and "md5hash" in self.model_fields_set:
            _dict['md5hash'] = None

        # set to None if name (nullable) is None
        # and model_fields_set contains the field
        if self.name is None and "name" in self.model_fields_set:
            _dict['name'] = None

        # set to None if nav (nullable) is None
        # and model_fields_set contains the field
        if self.nav is None and "nav" in self.model_fields_set:
            _dict['nav'] = None

        # set to None if navpositionleft (nullable) is None
        # and model_fields_set contains the field
        if self.navpositionleft is None and "navpositionleft" in self.model_fields_set:
            _dict['navpositionleft'] = None

        # set to None if navpositiontop (nullable) is None
        # and model_fields_set contains the field
        if self.navpositiontop is None and "navpositiontop" in self.model_fields_set:
            _dict['navpositiontop'] = None

        # set to None if options (nullable) is None
        # and model_fields_set contains the field
        if self.options is None and "options" in self.model_fields_set:
            _dict['options'] = None

        # set to None if packagesize (nullable) is None
        # and model_fields_set contains the field
        if self.packagesize is None and "packagesize" in self.model_fields_set:
            _dict['packagesize'] = None

        # set to None if packageurl (nullable) is None
        # and model_fields_set contains the field
        if self.packageurl is None and "packageurl" in self.model_fields_set:
            _dict['packageurl'] = None

        # set to None if popup (nullable) is None
        # and model_fields_set contains the field
        if self.popup is None and "popup" in self.model_fields_set:
            _dict['popup'] = None

        # set to None if protectpackagedownloads (nullable) is None
        # and model_fields_set contains the field
        if self.protectpackagedownloads is None and "protectpackagedownloads" in self.model_fields_set:
            _dict['protectpackagedownloads'] = None

        # set to None if reference (nullable) is None
        # and model_fields_set contains the field
        if self.reference is None and "reference" in self.model_fields_set:
            _dict['reference'] = None

        # set to None if revision (nullable) is None
        # and model_fields_set contains the field
        if self.revision is None and "revision" in self.model_fields_set:
            _dict['revision'] = None

        # set to None if scormtype (nullable) is None
        # and model_fields_set contains the field
        if self.scormtype is None and "scormtype" in self.model_fields_set:
            _dict['scormtype'] = None

        # set to None if section (nullable) is None
        # and model_fields_set contains the field
        if self.section is None and "section" in self.model_fields_set:
            _dict['section'] = None

        # set to None if sha1hash (nullable) is None
        # and model_fields_set contains the field
        if self.sha1hash is None and "sha1hash" in self.model_fields_set:
            _dict['sha1hash'] = None

        # set to None if skipview (nullable) is None
        # and model_fields_set contains the field
        if self.skipview is None and "skipview" in self.model_fields_set:
            _dict['skipview'] = None

        # set to None if timeclose (nullable) is None
        # and model_fields_set contains the field
        if self.timeclose is None and "timeclose" in self.model_fields_set:
            _dict['timeclose'] = None

        # set to None if timemodified (nullable) is None
        # and model_fields_set contains the field
        if self.timemodified is None and "timemodified" in self.model_fields_set:
            _dict['timemodified'] = None

        # set to None if timeopen (nullable) is None
        # and model_fields_set contains the field
        if self.timeopen is None and "timeopen" in self.model_fields_set:
            _dict['timeopen'] = None

        # set to None if updatefreq (nullable) is None
        # and model_fields_set contains the field
        if self.updatefreq is None and "updatefreq" in self.model_fields_set:
            _dict['updatefreq'] = None

        # set to None if version (nullable) is None
        # and model_fields_set contains the field
        if self.version is None and "version" in self.model_fields_set:
            _dict['version'] = None

        # set to None if visible (nullable) is None
        # and model_fields_set contains the field
        if self.visible is None and "visible" in self.model_fields_set:
            _dict['visible'] = None

        # set to None if whatgrade (nullable) is None
        # and model_fields_set contains the field
        if self.whatgrade is None and "whatgrade" in self.model_fields_set:
            _dict['whatgrade'] = None

        # set to None if width (nullable) is None
        # and model_fields_set contains the field
        if self.width is None and "width" in self.model_fields_set:
            _dict['width'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of ModScormGetScormsByCoursesResponseScormsInner from a dict"""
        if obj is None:
            return None

        relaxed = settings.relaxe_all_models or "ModScormGetScormsByCoursesResponseScormsInner" in settings.relaxed_models

        if not isinstance(obj, dict):
            return cls.model_construct(**obj) if relaxed else cls.model_validate(obj)

        data = {
            "auto": obj.get("auto"),
            "autocommit": obj.get("autocommit"),
            "completionscorerequired": obj.get("completionscorerequired"),
            "completionstatusallscos": obj.get("completionstatusallscos"),
            "completionstatusrequired": obj.get("completionstatusrequired"),
            "course": obj.get("course"),
            "coursemodule": obj.get("coursemodule"),
            "displayattemptstatus": obj.get("displayattemptstatus"),
            "displaycoursestructure": obj.get("displaycoursestructure"),
            "forcecompleted": obj.get("forcecompleted"),
            "forcenewattempt": obj.get("forcenewattempt"),
            "grademethod": obj.get("grademethod"),
            "groupingid": obj.get("groupingid"),
            "groupmode": obj.get("groupmode"),
            "height": obj.get("height"),
            "hidebrowse": obj.get("hidebrowse"),
            "hidetoc": obj.get("hidetoc"),
            "id": obj.get("id"),
            "intro": obj.get("intro"),
            "introfiles": [CoreBlockGetCourseBlocksResponseBlocksInnerContentsFilesInner.from_dict(_item) for _item in obj["introfiles"]] if obj.get("introfiles") is not None else None,
            "introformat": obj.get("introformat"),
            "lang": obj.get("lang"),
            "lastattemptlock": obj.get("lastattemptlock"),
            "launch": obj.get("launch"),
            "maxattempt": obj.get("maxattempt"),
            "maxgrade": obj.get("maxgrade"),
            "md5hash": obj.get("md5hash"),
            "name": obj.get("name"),
            "nav": obj.get("nav"),
            "navpositionleft": obj.get("navpositionleft"),
            "navpositiontop": obj.get("navpositiontop"),
            "options": obj.get("options"),
            "packagesize": obj.get("packagesize"),
            "packageurl": obj.get("packageurl"),
            "popup": obj.get("popup"),
            "protectpackagedownloads": obj.get("protectpackagedownloads"),
            "reference": obj.get("reference"),
            "revision": obj.get("revision"),
            "scormtype": obj.get("scormtype"),
            "section": obj.get("section"),
            "sha1hash": obj.get("sha1hash"),
            "skipview": obj.get("skipview"),
            "timeclose": obj.get("timeclose"),
            "timemodified": obj.get("timemodified"),
            "timeopen": obj.get("timeopen"),
            "updatefreq": obj.get("updatefreq"),
            "version": obj.get("version"),
            "visible": obj.get("visible"),
            "whatgrade": obj.get("whatgrade"),
            "width": obj.get("width")
        }
        _obj = cls.model_construct(**data) if relaxed else cls.model_validate(data)
        return _obj


