Source code for codegrade.models.restriction_exam_environment_redirect_preparation

"""The module that defines the ``RestrictionExamEnvironmentRedirectPreparation`` 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 .redirect_preparation import RedirectPreparation


[docs] @dataclass(kw_only=True) class RestrictionExamEnvironmentRedirectPreparation(RedirectPreparation): """The student must be sent to the provider to onboard into a kiosk.""" #: The moment from which the requesting user may set up the exam #: environment, derived from their effective entry window. `None` when no #: window resolves and preparing is therefore not time-bounded. Preparing #: before this moment is refused, so a UI offering the set-up action should #: disable it until then. 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: RedirectPreparation.data_parser.parser.combine( rqa.FixedMapping( rqa.RequiredArgument( "opens_at", rqa.Nullable(rqa.RichValue.DateTime), doc="The moment from which the requesting user may set up the exam environment, derived from their effective entry window. `None` when no window resolves and preparing is therefore not time-bounded. Preparing before this moment is refused, so a UI offering the set-up action should disable it until then.", ), ) ) ) 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[RestrictionExamEnvironmentRedirectPreparation], d: t.Dict[str, t.Any], ) -> RestrictionExamEnvironmentRedirectPreparation: 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