Source code for codegrade.models.restriction_exam_environment_no_preparation

"""The module that defines the ``RestrictionExamEnvironmentNoPreparation`` model.

SPDX-License-Identifier: AGPL-3.0-only OR BSD-3-Clause-Clear
"""

from __future__ import annotations

import datetime
import typing as t
from dataclasses import dataclass, field

import cg_request_args as rqa

from ..utils import to_dict
from .no_preparation import NoPreparation


[docs] @dataclass(kw_only=True) class RestrictionExamEnvironmentNoPreparation(NoPreparation): """The provider needs nothing from the student before the exam.""" #: Always `None`: there is nothing to set up. opens_at: t.Optional[datetime.datetime] raw_data: t.Optional[t.Dict[str, t.Any]] = field(init=False, repr=False) data_parser: t.ClassVar[t.Any] = rqa.Lazy( lambda: NoPreparation.data_parser.parser.combine( rqa.FixedMapping( rqa.RequiredArgument( "opens_at", rqa.Nullable(rqa.RichValue.DateTime), doc="Always `None`: there is nothing to set up.", ), ) ) ) def to_dict(self) -> t.Dict[str, t.Any]: res: t.Dict[str, t.Any] = { "opens_at": to_dict(self.opens_at), "tag": to_dict(self.tag), } return res @classmethod def from_dict( cls: t.Type[RestrictionExamEnvironmentNoPreparation], d: t.Dict[str, t.Any], ) -> RestrictionExamEnvironmentNoPreparation: parsed = cls.data_parser.try_parse(d) res = cls( opens_at=parsed.opens_at, tag=parsed.tag, ) res.raw_data = d return res
import os if os.getenv("CG_GENERATING_DOCS", "False").lower() in ("", "true"): pass