# coding: utf-8

"""
    Moodle Webservice API

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

    The version of the OpenAPI document: 4.5 (Build: 20241007)
    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, StrictFloat, StrictInt
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing import Optional, Set
from typing_extensions import Self

class ModWorkshopGetGradesReportResponseReportGradesInnerReviewedbyInner(BaseModel):
    """
    ModWorkshopGetGradesReportResponseReportGradesInnerReviewedbyInner
    """ # noqa: E501
    assessmentid: Optional[StrictInt] = Field(description="The id of the assessment.")
    grade: Optional[Union[StrictFloat, StrictInt]] = Field(description="The grade for submission.")
    gradinggrade: Optional[Union[StrictFloat, StrictInt]] = Field(description="The grade for assessment.")
    gradinggradeover: Optional[Union[StrictFloat, StrictInt]] = Field(description="The aggregated grade overrided.")
    submissionid: Optional[StrictInt] = Field(description="The id of the submission assessed.")
    userid: Optional[StrictInt] = Field(description="The id of the user (0 when is configured to do not display names).")
    weight: Optional[StrictInt] = Field(description="The weight of the assessment for aggregation.")
    __properties: ClassVar[List[str]] = ["assessmentid", "grade", "gradinggrade", "gradinggradeover", "submissionid", "userid", "weight"]

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

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

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

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

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

        return _dict

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

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "assessmentid": obj.get("assessmentid"),
            "grade": obj.get("grade"),
            "gradinggrade": obj.get("gradinggrade"),
            "gradinggradeover": obj.get("gradinggradeover"),
            "submissionid": obj.get("submissionid"),
            "userid": obj.get("userid"),
            "weight": obj.get("weight")
        })
        return _obj


