# coding: utf-8

"""
    Mentortools Public API

    Mentortools public API service

    The version of the OpenAPI document: 0.1.0
    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 typing import Optional
from pydantic import BaseModel, Field, StrictBool
from public_api_server_connector.models.correct_answer_options import CorrectAnswerOptions
from public_api_server_connector.models.grade_options import GradeOptions
from public_api_server_connector.models.lock_type import LockType
from public_api_server_connector.models.randomize_options import RandomizeOptions
from public_api_server_connector.models.redo_options import RedoOptions
from public_api_server_connector.models.timing_options import TimingOptions

class QuizOptions(BaseModel):
    """
    QuizOptions
    """
    timing: Optional[TimingOptions] = None
    redo: Optional[RedoOptions] = None
    correct_answer: Optional[CorrectAnswerOptions] = None
    grade: Optional[GradeOptions] = None
    randomize: Optional[RandomizeOptions] = None
    hide_answers_hint: Optional[StrictBool] = Field(default=False, description="Hide correct answer count hint")
    lock_type: Optional[LockType] = None
    __properties = ["timing", "redo", "correct_answer", "grade", "randomize", "hide_answers_hint", "lock_type"]

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_name = True
        validate_assignment = True

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

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

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

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of timing
        if self.timing:
            _dict['timing'] = self.timing.to_dict()
        # override the default output from pydantic by calling `to_dict()` of redo
        if self.redo:
            _dict['redo'] = self.redo.to_dict()
        # override the default output from pydantic by calling `to_dict()` of correct_answer
        if self.correct_answer:
            _dict['correct_answer'] = self.correct_answer.to_dict()
        # override the default output from pydantic by calling `to_dict()` of grade
        if self.grade:
            _dict['grade'] = self.grade.to_dict()
        # override the default output from pydantic by calling `to_dict()` of randomize
        if self.randomize:
            _dict['randomize'] = self.randomize.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> QuizOptions:
        """Create an instance of QuizOptions from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return QuizOptions.parse_obj(obj)

        _obj = QuizOptions.parse_obj({
            "timing": TimingOptions.from_dict(obj.get("timing")) if obj.get("timing") is not None else None,
            "redo": RedoOptions.from_dict(obj.get("redo")) if obj.get("redo") is not None else None,
            "correct_answer": CorrectAnswerOptions.from_dict(obj.get("correct_answer")) if obj.get("correct_answer") is not None else None,
            "grade": GradeOptions.from_dict(obj.get("grade")) if obj.get("grade") is not None else None,
            "randomize": RandomizeOptions.from_dict(obj.get("randomize")) if obj.get("randomize") is not None else None,
            "hide_answers_hint": obj.get("hide_answers_hint") if obj.get("hide_answers_hint") is not None else False,
            "lock_type": obj.get("lock_type")
        })
        return _obj


