# 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, 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 poodle_async_full.models.mod_assign_get_assignments_response_courses_inner_assignments_inner_configs_inner import ModAssignGetAssignmentsResponseCoursesInnerAssignmentsInnerConfigsInner
from typing import Optional, Set
from typing_extensions import Self

from poodle_async_full.configuration import settings

class ModAssignGetAssignmentsResponseCoursesInnerAssignmentsInner(BaseModel):
    """
    assignment information object
    """ # noqa: E501
    activity: Optional[StrictStr] = Field(default=None, description="Description of activity")
    activityattachments: Optional[List[CoreBlockGetCourseBlocksResponseBlocksInnerContentsFilesInner]] = Field(default=None, description="Files from activity field")
    activityformat: Optional[StrictInt] = Field(default=None, description="activity format (1 = HTML, 0 = MOODLE, 2 = PLAIN, or 4 = MARKDOWN)")
    allowsubmissionsfromdate: Optional[StrictInt] = Field(description="allow submissions from date")
    attemptreopenmethod: Optional[StrictStr] = Field(description="method used to control opening new attempts")
    blindmarking: Optional[StrictInt] = Field(description="if enabled, hide identities until reveal identities actioned")
    cmid: Optional[StrictInt] = Field(description="course module id")
    completionsubmit: Optional[StrictInt] = Field(description="if enabled, set activity as complete following submission")
    configs: List[ModAssignGetAssignmentsResponseCoursesInnerAssignmentsInnerConfigsInner] = Field(description="configuration settings")
    course: Optional[StrictInt] = Field(description="course id")
    cutoffdate: Optional[StrictInt] = Field(description="date after which submission is not accepted without an extension")
    duedate: Optional[StrictInt] = Field(description="assignment due date")
    grade: Optional[StrictInt] = Field(description="grade type")
    gradepenalty: Optional[StrictInt] = Field(description="if enabled, penalty will be applied to late submissions")
    gradingduedate: Optional[StrictInt] = Field(description="the expected date for marking the submissions")
    hidegrader: Optional[StrictInt] = Field(description="If enabled, hide grader to student")
    id: Optional[StrictInt] = Field(description="assignment id")
    intro: Optional[StrictStr] = Field(default=None, description="assignment intro, not allways returned because it deppends on the activity configuration")
    introattachments: Optional[List[CoreBlockGetCourseBlocksResponseBlocksInnerContentsFilesInner]] = Field(default=None, description="intro attachments files")
    introfiles: Optional[List[CoreBlockGetCourseBlocksResponseBlocksInnerContentsFilesInner]] = Field(default=None, description="Files in the introduction text")
    introformat: Optional[StrictInt] = Field(default=None, description="intro format (1 = HTML, 0 = MOODLE, 2 = PLAIN, or 4 = MARKDOWN)")
    markingallocation: Optional[StrictInt] = Field(description="enable marking allocation")
    markinganonymous: Optional[StrictInt] = Field(description="enable marking anonymous")
    markingworkflow: Optional[StrictInt] = Field(description="enable marking workflow")
    maxattempts: Optional[StrictInt] = Field(description="maximum number of attempts allowed")
    name: Optional[StrictStr] = Field(description="assignment name")
    nosubmissions: Optional[StrictInt] = Field(description="no submissions")
    preventsubmissionnotingroup: Optional[StrictInt] = Field(default=None, description="Prevent submission not in group")
    requireallteammemberssubmit: Optional[StrictInt] = Field(description="if enabled, all team members must submit")
    requiresubmissionstatement: Optional[StrictInt] = Field(description="student must accept submission statement")
    revealidentities: Optional[StrictInt] = Field(description="show identities for a blind marking assignment")
    sendlatenotifications: Optional[StrictInt] = Field(description="send notifications")
    sendnotifications: Optional[StrictInt] = Field(description="send notifications")
    sendstudentnotifications: Optional[StrictInt] = Field(description="send student notifications (default)")
    submissionattachments: Optional[StrictInt] = Field(default=None, description="Flag to only show files during submission")
    submissiondrafts: Optional[StrictInt] = Field(description="submissions drafts")
    submissionstatement: Optional[StrictStr] = Field(default=None, description="Submission statement formatted.")
    submissionstatementformat: Optional[StrictInt] = Field(default=None, description="submissionstatement format (1 = HTML, 0 = MOODLE, 2 = PLAIN, or 4 = MARKDOWN)")
    teamsubmission: Optional[StrictInt] = Field(description="if enabled, students submit as a team")
    teamsubmissiongroupingid: Optional[StrictInt] = Field(description="the grouping id for the team submission groups")
    timelimit: Optional[StrictInt] = Field(default=None, description="Time limit to complete assigment")
    timemodified: Optional[StrictInt] = Field(description="last time assignment was modified")
    __properties: ClassVar[List[str]] = ["activity", "activityattachments", "activityformat", "allowsubmissionsfromdate", "attemptreopenmethod", "blindmarking", "cmid", "completionsubmit", "configs", "course", "cutoffdate", "duedate", "grade", "gradepenalty", "gradingduedate", "hidegrader", "id", "intro", "introattachments", "introfiles", "introformat", "markingallocation", "markinganonymous", "markingworkflow", "maxattempts", "name", "nosubmissions", "preventsubmissionnotingroup", "requireallteammemberssubmit", "requiresubmissionstatement", "revealidentities", "sendlatenotifications", "sendnotifications", "sendstudentnotifications", "submissionattachments", "submissiondrafts", "submissionstatement", "submissionstatementformat", "teamsubmission", "teamsubmissiongroupingid", "timelimit", "timemodified"]

    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 ModAssignGetAssignmentsResponseCoursesInnerAssignmentsInner 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 activityattachments (list)
        _items = []
        if self.activityattachments:
            for _item_activityattachments in self.activityattachments:
                if _item_activityattachments:
                    _items.append(_item_activityattachments.to_dict())
            _dict['activityattachments'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in configs (list)
        _items = []
        if self.configs:
            for _item_configs in self.configs:
                if _item_configs:
                    _items.append(_item_configs.to_dict())
            _dict['configs'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in introattachments (list)
        _items = []
        if self.introattachments:
            for _item_introattachments in self.introattachments:
                if _item_introattachments:
                    _items.append(_item_introattachments.to_dict())
            _dict['introattachments'] = _items
        # 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 activity (nullable) is None
        # and model_fields_set contains the field
        if self.activity is None and "activity" in self.model_fields_set:
            _dict['activity'] = None

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

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

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

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

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

        # set to None if completionsubmit (nullable) is None
        # and model_fields_set contains the field
        if self.completionsubmit is None and "completionsubmit" in self.model_fields_set:
            _dict['completionsubmit'] = 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 cutoffdate (nullable) is None
        # and model_fields_set contains the field
        if self.cutoffdate is None and "cutoffdate" in self.model_fields_set:
            _dict['cutoffdate'] = None

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

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

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

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

        # set to None if hidegrader (nullable) is None
        # and model_fields_set contains the field
        if self.hidegrader is None and "hidegrader" in self.model_fields_set:
            _dict['hidegrader'] = 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 markingallocation (nullable) is None
        # and model_fields_set contains the field
        if self.markingallocation is None and "markingallocation" in self.model_fields_set:
            _dict['markingallocation'] = None

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

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

        # set to None if maxattempts (nullable) is None
        # and model_fields_set contains the field
        if self.maxattempts is None and "maxattempts" in self.model_fields_set:
            _dict['maxattempts'] = 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 nosubmissions (nullable) is None
        # and model_fields_set contains the field
        if self.nosubmissions is None and "nosubmissions" in self.model_fields_set:
            _dict['nosubmissions'] = None

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

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

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

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

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

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

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

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

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

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

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

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

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

        # set to None if timelimit (nullable) is None
        # and model_fields_set contains the field
        if self.timelimit is None and "timelimit" in self.model_fields_set:
            _dict['timelimit'] = 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

        return _dict

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

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

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

        data = {
            "activity": obj.get("activity"),
            "activityattachments": [CoreBlockGetCourseBlocksResponseBlocksInnerContentsFilesInner.from_dict(_item) for _item in obj["activityattachments"]] if obj.get("activityattachments") is not None else None,
            "activityformat": obj.get("activityformat"),
            "allowsubmissionsfromdate": obj.get("allowsubmissionsfromdate"),
            "attemptreopenmethod": obj.get("attemptreopenmethod"),
            "blindmarking": obj.get("blindmarking"),
            "cmid": obj.get("cmid"),
            "completionsubmit": obj.get("completionsubmit"),
            "configs": [ModAssignGetAssignmentsResponseCoursesInnerAssignmentsInnerConfigsInner.from_dict(_item) for _item in obj["configs"]] if obj.get("configs") is not None else None,
            "course": obj.get("course"),
            "cutoffdate": obj.get("cutoffdate"),
            "duedate": obj.get("duedate"),
            "grade": obj.get("grade"),
            "gradepenalty": obj.get("gradepenalty"),
            "gradingduedate": obj.get("gradingduedate"),
            "hidegrader": obj.get("hidegrader"),
            "id": obj.get("id"),
            "intro": obj.get("intro"),
            "introattachments": [CoreBlockGetCourseBlocksResponseBlocksInnerContentsFilesInner.from_dict(_item) for _item in obj["introattachments"]] if obj.get("introattachments") is not None else None,
            "introfiles": [CoreBlockGetCourseBlocksResponseBlocksInnerContentsFilesInner.from_dict(_item) for _item in obj["introfiles"]] if obj.get("introfiles") is not None else None,
            "introformat": obj.get("introformat"),
            "markingallocation": obj.get("markingallocation"),
            "markinganonymous": obj.get("markinganonymous"),
            "markingworkflow": obj.get("markingworkflow"),
            "maxattempts": obj.get("maxattempts"),
            "name": obj.get("name"),
            "nosubmissions": obj.get("nosubmissions"),
            "preventsubmissionnotingroup": obj.get("preventsubmissionnotingroup"),
            "requireallteammemberssubmit": obj.get("requireallteammemberssubmit"),
            "requiresubmissionstatement": obj.get("requiresubmissionstatement"),
            "revealidentities": obj.get("revealidentities"),
            "sendlatenotifications": obj.get("sendlatenotifications"),
            "sendnotifications": obj.get("sendnotifications"),
            "sendstudentnotifications": obj.get("sendstudentnotifications"),
            "submissionattachments": obj.get("submissionattachments"),
            "submissiondrafts": obj.get("submissiondrafts"),
            "submissionstatement": obj.get("submissionstatement"),
            "submissionstatementformat": obj.get("submissionstatementformat"),
            "teamsubmission": obj.get("teamsubmission"),
            "teamsubmissiongroupingid": obj.get("teamsubmissiongroupingid"),
            "timelimit": obj.get("timelimit"),
            "timemodified": obj.get("timemodified")
        }
        _obj = cls.model_construct(**data) if relaxed else cls.model_validate(data)
        return _obj


