# 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, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from poodle_async_full.models.core_blog_get_entries_response_entries_inner_attachmentfiles_inner import CoreBlogGetEntriesResponseEntriesInnerAttachmentfilesInner
from typing import Optional, Set
from typing_extensions import Self

from poodle_async_full.configuration import settings

class ModWorkshopGetWorkshopsByCoursesResponseWorkshopsInner(BaseModel):
    """
    ModWorkshopGetWorkshopsByCoursesResponseWorkshopsInner
    """ # noqa: E501
    assessmentend: Optional[StrictInt] = Field(default=0, description="0 = will be closed manually, greater than 0 the timestamp of the end of the assessment phase.")
    assessmentstart: Optional[StrictInt] = Field(default=0, description="0 = will be started manually, greater than 0 the timestamp of the start of the assessment phase.")
    conclusion: Optional[StrictStr] = Field(default=None, description="A text to be displayed at the end of the workshop.")
    conclusionfiles: Optional[List[CoreBlogGetEntriesResponseEntriesInnerAttachmentfilesInner]] = Field(default=None, description="conclusionfiles")
    conclusionformat: Optional[StrictInt] = Field(default=0, description="conclusion format (1 = HTML, 0 = MOODLE, 2 = PLAIN, or 4 = MARKDOWN)")
    course: StrictInt = Field(description="Course id this workshop is part of.")
    coursemodule: StrictInt = Field(description="coursemodule")
    evaluation: Optional[StrictStr] = Field(default='', description="The recently used grading evaluation method.")
    examplesmode: Optional[StrictInt] = Field(default=0, description="0 = example assessments are voluntary, 1 = examples must be assessed before submission,                     2 = examples are available after own submission and must be assessed before peer/self assessment phase.")
    grade: Optional[Union[StrictFloat, StrictInt]] = Field(default=80, description="The maximum grade for submission.")
    gradedecimals: Optional[StrictInt] = Field(default=0, description="Number of digits that should be shown after the decimal point when displaying grades.")
    gradinggrade: Optional[Union[StrictFloat, StrictInt]] = Field(default=20, description="The maximum grade for assessment.")
    id: StrictInt = Field(description="The primary key of the record.")
    instructauthors: Optional[StrictStr] = Field(default=None, description="Instructions for the submission phase.")
    instructauthorsfiles: Optional[List[CoreBlogGetEntriesResponseEntriesInnerAttachmentfilesInner]] = Field(default=None, description="instructauthorsfiles")
    instructauthorsformat: Optional[StrictInt] = Field(default=0, description="instructauthors format (1 = HTML, 0 = MOODLE, 2 = PLAIN, or 4 = MARKDOWN)")
    instructreviewers: Optional[StrictStr] = Field(default=None, description="Instructions for the assessment phase.")
    instructreviewersfiles: Optional[List[CoreBlogGetEntriesResponseEntriesInnerAttachmentfilesInner]] = Field(default=None, description="instructreviewersfiles")
    instructreviewersformat: Optional[StrictInt] = Field(default=0, description="instructreviewers format (1 = HTML, 0 = MOODLE, 2 = PLAIN, or 4 = MARKDOWN)")
    intro: Optional[StrictStr] = Field(description="Workshop introduction text.")
    introfiles: List[CoreBlogGetEntriesResponseEntriesInnerAttachmentfilesInner] = Field(description="introfiles")
    introformat: Optional[StrictInt] = Field(default=0, description="intro format (1 = HTML, 0 = MOODLE, 2 = PLAIN, or 4 = MARKDOWN)")
    lang: Optional[StrictStr] = Field(description="Forced activity language")
    latesubmissions: Optional[StrictBool] = Field(default=False, description="Allow submitting the work after the deadline.")
    maxbytes: Optional[StrictInt] = Field(default=0, description="Maximum size of the one attached file.")
    name: StrictStr = Field(description="Workshop name.")
    nattachments: Optional[StrictInt] = Field(default=0, description="Maximum number of submission attachments.")
    overallfeedbackfiles: Optional[StrictInt] = Field(default=0, description="Number of allowed attachments to the overall feedback.")
    overallfeedbackfiletypes: Optional[StrictStr] = Field(default=None, description="Comma separated list of file extensions.")
    overallfeedbackmaxbytes: Optional[StrictInt] = Field(default=0, description="Maximum size of one file attached to the overall feedback.")
    overallfeedbackmode: Optional[StrictInt] = Field(default=0, description="Mode of the overall feedback support.")
    phase: Optional[StrictInt] = Field(default=0, description="The current phase of workshop (0 = not available, 1 = submission, 2 = assessment, 3 = closed).")
    phaseswitchassessment: Optional[StrictBool] = Field(default=False, description="Automatically switch to the assessment phase after the submissions deadline.")
    strategy: Optional[StrictStr] = Field(default='', description="The type of the current grading strategy used in this workshop.")
    submissionend: Optional[StrictInt] = Field(default=0, description="0 = will be closed manually, greater than 0 the timestamp of the end of the submission phase.")
    submissionfiletypes: Optional[StrictStr] = Field(default=None, description="Comma separated list of file extensions.")
    submissionstart: Optional[StrictInt] = Field(default=0, description="0 = will be started manually, greater than 0 the timestamp of the start of the submission phase.")
    submissiontypefile: Optional[StrictInt] = Field(default=0, description="Indicates whether a file upload is required as part of each submission. 0 for no, 1 for optional, 2 for required.")
    submissiontypetext: Optional[StrictInt] = Field(default=0, description="Indicates whether text is required as part of each submission. 0 for no, 1 for optional, 2 for required.")
    timemodified: Optional[StrictInt] = Field(default=0, description="The timestamp when the module was modified.")
    useexamples: Optional[StrictBool] = Field(default=False, description="Optional feature: students practise evaluating on example submissions from teacher.")
    usepeerassessment: Optional[StrictBool] = Field(default=False, description="Optional feature: students perform peer assessment of others' work.")
    useselfassessment: Optional[StrictBool] = Field(default=False, description="Optional feature: students perform self assessment of their own work.")
    __properties: ClassVar[List[str]] = ["assessmentend", "assessmentstart", "conclusion", "conclusionfiles", "conclusionformat", "course", "coursemodule", "evaluation", "examplesmode", "grade", "gradedecimals", "gradinggrade", "id", "instructauthors", "instructauthorsfiles", "instructauthorsformat", "instructreviewers", "instructreviewersfiles", "instructreviewersformat", "intro", "introfiles", "introformat", "lang", "latesubmissions", "maxbytes", "name", "nattachments", "overallfeedbackfiles", "overallfeedbackfiletypes", "overallfeedbackmaxbytes", "overallfeedbackmode", "phase", "phaseswitchassessment", "strategy", "submissionend", "submissionfiletypes", "submissionstart", "submissiontypefile", "submissiontypetext", "timemodified", "useexamples", "usepeerassessment", "useselfassessment"]

    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 ModWorkshopGetWorkshopsByCoursesResponseWorkshopsInner 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 conclusionfiles (list)
        _items = []
        if self.conclusionfiles:
            for _item_conclusionfiles in self.conclusionfiles:
                if _item_conclusionfiles:
                    _items.append(_item_conclusionfiles.to_dict())
            _dict['conclusionfiles'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in instructauthorsfiles (list)
        _items = []
        if self.instructauthorsfiles:
            for _item_instructauthorsfiles in self.instructauthorsfiles:
                if _item_instructauthorsfiles:
                    _items.append(_item_instructauthorsfiles.to_dict())
            _dict['instructauthorsfiles'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in instructreviewersfiles (list)
        _items = []
        if self.instructreviewersfiles:
            for _item_instructreviewersfiles in self.instructreviewersfiles:
                if _item_instructreviewersfiles:
                    _items.append(_item_instructreviewersfiles.to_dict())
            _dict['instructreviewersfiles'] = _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 conclusion (nullable) is None
        # and model_fields_set contains the field
        if self.conclusion is None and "conclusion" in self.model_fields_set:
            _dict['conclusion'] = None

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

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

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

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

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

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

        return _dict

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

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

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

        data = {
            "assessmentend": obj.get("assessmentend") if obj.get("assessmentend") is not None else 0,
            "assessmentstart": obj.get("assessmentstart") if obj.get("assessmentstart") is not None else 0,
            "conclusion": obj.get("conclusion"),
            "conclusionfiles": [CoreBlogGetEntriesResponseEntriesInnerAttachmentfilesInner.from_dict(_item) for _item in obj["conclusionfiles"]] if obj.get("conclusionfiles") is not None else None,
            "conclusionformat": obj.get("conclusionformat") if obj.get("conclusionformat") is not None else 0,
            "course": obj.get("course") if obj.get("course") is not None else 0,
            "coursemodule": obj.get("coursemodule") if obj.get("coursemodule") is not None else 0,
            "evaluation": obj.get("evaluation") if obj.get("evaluation") is not None else '',
            "examplesmode": obj.get("examplesmode") if obj.get("examplesmode") is not None else 0,
            "grade": obj.get("grade") if obj.get("grade") is not None else 80,
            "gradedecimals": obj.get("gradedecimals") if obj.get("gradedecimals") is not None else 0,
            "gradinggrade": obj.get("gradinggrade") if obj.get("gradinggrade") is not None else 20,
            "id": obj.get("id") if obj.get("id") is not None else 0,
            "instructauthors": obj.get("instructauthors"),
            "instructauthorsfiles": [CoreBlogGetEntriesResponseEntriesInnerAttachmentfilesInner.from_dict(_item) for _item in obj["instructauthorsfiles"]] if obj.get("instructauthorsfiles") is not None else None,
            "instructauthorsformat": obj.get("instructauthorsformat") if obj.get("instructauthorsformat") is not None else 0,
            "instructreviewers": obj.get("instructreviewers"),
            "instructreviewersfiles": [CoreBlogGetEntriesResponseEntriesInnerAttachmentfilesInner.from_dict(_item) for _item in obj["instructreviewersfiles"]] if obj.get("instructreviewersfiles") is not None else None,
            "instructreviewersformat": obj.get("instructreviewersformat") if obj.get("instructreviewersformat") is not None else 0,
            "intro": obj.get("intro") if obj.get("intro") is not None else '',
            "introfiles": [CoreBlogGetEntriesResponseEntriesInnerAttachmentfilesInner.from_dict(_item) for _item in obj["introfiles"]] if obj.get("introfiles") is not None else None,
            "introformat": obj.get("introformat") if obj.get("introformat") is not None else 0,
            "lang": obj.get("lang"),
            "latesubmissions": obj.get("latesubmissions") if obj.get("latesubmissions") is not None else False,
            "maxbytes": obj.get("maxbytes") if obj.get("maxbytes") is not None else 0,
            "name": obj.get("name") if obj.get("name") is not None else '',
            "nattachments": obj.get("nattachments") if obj.get("nattachments") is not None else 0,
            "overallfeedbackfiles": obj.get("overallfeedbackfiles") if obj.get("overallfeedbackfiles") is not None else 0,
            "overallfeedbackfiletypes": obj.get("overallfeedbackfiletypes"),
            "overallfeedbackmaxbytes": obj.get("overallfeedbackmaxbytes") if obj.get("overallfeedbackmaxbytes") is not None else 0,
            "overallfeedbackmode": obj.get("overallfeedbackmode") if obj.get("overallfeedbackmode") is not None else 0,
            "phase": obj.get("phase") if obj.get("phase") is not None else 0,
            "phaseswitchassessment": obj.get("phaseswitchassessment") if obj.get("phaseswitchassessment") is not None else False,
            "strategy": obj.get("strategy") if obj.get("strategy") is not None else '',
            "submissionend": obj.get("submissionend") if obj.get("submissionend") is not None else 0,
            "submissionfiletypes": obj.get("submissionfiletypes"),
            "submissionstart": obj.get("submissionstart") if obj.get("submissionstart") is not None else 0,
            "submissiontypefile": obj.get("submissiontypefile") if obj.get("submissiontypefile") is not None else 0,
            "submissiontypetext": obj.get("submissiontypetext") if obj.get("submissiontypetext") is not None else 0,
            "timemodified": obj.get("timemodified") if obj.get("timemodified") is not None else 0,
            "useexamples": obj.get("useexamples") if obj.get("useexamples") is not None else False,
            "usepeerassessment": obj.get("usepeerassessment") if obj.get("usepeerassessment") is not None else False,
            "useselfassessment": obj.get("useselfassessment") if obj.get("useselfassessment") is not None else False
        }
        _obj = cls.model_construct(**data) if relaxed else cls.model_validate(data)
        return _obj


