# 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, conint
from public_api_server_connector.models.correct_answer_show_type import CorrectAnswerShowType
from public_api_server_connector.models.lock_type import LockType
from public_api_server_connector.models.redo_type import RedoType

class QuizOptions(BaseModel):
    """
    QuizOptions
    """
    completion_limit_ms: Optional[conint(strict=True, ge=0)] = Field(default=0, description="Completion limit in milliseconds, 0 means no limit")
    redo_type: Optional[RedoType] = Field(default=None, description="Redo policy")
    redo_after_hours: Optional[conint(strict=True, ge=0)] = Field(default=0, description="Hours before retake allowed (can_redo_after_hours only)")
    show_correct_answers: Optional[CorrectAnswerShowType] = Field(default=None, description="When to show correct answers")
    grade_after_percents: Optional[conint(strict=True, le=100, ge=0)] = Field(default=80, description="Minimum percent to pass")
    randomize_questions: Optional[StrictBool] = Field(default=True, description="Randomize question order")
    randomize_answers: Optional[StrictBool] = Field(default=True, description="Randomize answer order")
    hide_answers_hint: Optional[StrictBool] = Field(default=False, description="Hide correct answer count hint")
    lock_type: Optional[LockType] = None
    __properties = ["completion_limit_ms", "redo_type", "redo_after_hours", "show_correct_answers", "grade_after_percents", "randomize_questions", "randomize_answers", "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)
        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({
            "completion_limit_ms": obj.get("completion_limit_ms") if obj.get("completion_limit_ms") is not None else 0,
            "redo_type": obj.get("redo_type"),
            "redo_after_hours": obj.get("redo_after_hours") if obj.get("redo_after_hours") is not None else 0,
            "show_correct_answers": obj.get("show_correct_answers"),
            "grade_after_percents": obj.get("grade_after_percents") if obj.get("grade_after_percents") is not None else 80,
            "randomize_questions": obj.get("randomize_questions") if obj.get("randomize_questions") is not None else True,
            "randomize_answers": obj.get("randomize_answers") if obj.get("randomize_answers") is not None else True,
            "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


