-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! ✨(models) add assessment xAPI profile
- Loading branch information
1 parent
8461478
commit 753179b
Showing
10 changed files
with
198 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
"""`Assessment` xAPI events context fields definitions.""" | ||
|
||
from typing import List, Union | ||
|
||
from ..base.contexts import BaseXapiContext, BaseXapiContextContextActivities | ||
from ..base.unnested_objects import BaseXapiActivityType, BaseXapiActivityTypeDefinition | ||
from ..concepts.constants.assessment import ASSESSMENT_CONTEXT_CATEGORY | ||
from ..constants import CONTEXT_CONTEXTACTIVTIES_CATEGORY_DEFINITION_TYPE | ||
|
||
|
||
class AssessmentContextActivitiesCategoryDefinition(BaseXapiActivityTypeDefinition): | ||
# noqa: D205 | ||
"""Pydantic model for assessment `context`.`contextActivities`.`category`. | ||
`definition` property. | ||
Attributes: | ||
type (str): Consists of the value `http://adlnet.gov/expapi/activities/profile`. | ||
""" | ||
|
||
type: CONTEXT_CONTEXTACTIVTIES_CATEGORY_DEFINITION_TYPE = ( | ||
CONTEXT_CONTEXTACTIVTIES_CATEGORY_DEFINITION_TYPE.__args__[0] | ||
) | ||
|
||
|
||
class AssessmentContextActivitiesCategory(BaseXapiActivityType): | ||
# noqa: D205, D415 | ||
"""Pydantic model for assessment `context`.`contextActivities`.`category` | ||
property. | ||
Attributes: | ||
id (str): Consists of the value `https://w3id.org/xapi/virtual-classroom`. | ||
definition (dict): see AssessmentContextActivitiesCategoryDefinition. | ||
""" | ||
|
||
id: ASSESSMENT_CONTEXT_CATEGORY = ASSESSMENT_CONTEXT_CATEGORY.__args__[0] | ||
definition: AssessmentContextActivitiesCategoryDefinition = ( | ||
AssessmentContextActivitiesCategoryDefinition() | ||
) | ||
|
||
|
||
class AssessmentContextActivities(BaseXapiContextContextActivities): | ||
"""Pydantic model for assessment `context`.`contextActivities` property. | ||
Attributes: | ||
category (list): see AssessmentContextActivitiesCategory. | ||
""" | ||
|
||
category: Union[ | ||
AssessmentContextActivitiesCategory, | ||
List[AssessmentContextActivitiesCategory], | ||
] = [AssessmentContextActivitiesCategory()] | ||
|
||
|
||
class AssessmentContext(BaseXapiContext): | ||
"""Pydantic model for assessment base `context` property. | ||
Attributes: | ||
contextActivities: see AssessmentContextActivities. | ||
""" | ||
|
||
contextActivities: AssessmentContextActivities = AssessmentContextActivities() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,110 @@ | ||
"""Video xAPI event definitions.""" | ||
"""`Assessment` xAPI event definitions.""" | ||
|
||
from typing import Optional | ||
from datetime import datetime | ||
|
||
from ...selector import selector | ||
from ..base import BaseXapiModel | ||
from ..fields.results import ResultField | ||
from .fields.contexts import AssessmentContextField | ||
from .fields.objects import QuestionObjectField | ||
from .fields.verbs import AnsweredVerbField | ||
from ..base.statements import BaseXapiStatement | ||
from ..concepts.activity_types.scorm_profile import CMIInteractionActivityType | ||
from ..concepts.verbs.scorm_profile import ( | ||
CompletedVerb, | ||
InitializedVerb, | ||
LaunchedVerb, | ||
TerminatedVerb, | ||
) | ||
from .contexts import AssessmentContext | ||
|
||
# Mandatory statements | ||
|
||
class AssessmentAnsweredQuestion(BaseXapiModel): | ||
"""Pydantic model for video answered question statement. | ||
|
||
Example: John has answered a question in an assessment. | ||
class AssessmentInitialized(BaseXapiStatement): | ||
"""Pydantic model for assessment initialized statement. | ||
Example: | ||
Attributes: | ||
verb (dict): See InitializedVerb. | ||
object (dict): See CMIInteractionActivityType. | ||
context (dict): See AssessmentContext. | ||
timestamp (datetime): Consists of the timestamp of when the event occurred. | ||
""" | ||
|
||
__selector__ = selector( | ||
verb__id="http://adlnet.gov/expapi/verbs/initialized", | ||
object__definition__type=( | ||
"http://adlnet.gov/expapi/activities/cmi.interaction" | ||
), | ||
) | ||
|
||
verb: InitializedVerb = InitializedVerb() | ||
object: CMIInteractionActivityType | ||
context: AssessmentContext | ||
timestamp: datetime | ||
|
||
|
||
class AssessmentLaunched(BaseXapiStatement): | ||
"""Pydantic model for assessment launched statement. | ||
Example: | ||
Attributes: | ||
object (dict): See QuestionObjectField. | ||
verb (dict): See AnsweredVerbField. | ||
context (dict): See AssessmentContextField. | ||
verb (dict): See LaunchedVerb. | ||
object (dict): See CMIInteractionActivityType. | ||
context (dict): See AssessmentContext. | ||
timestamp (datetime): Consists of the timestamp of when the event occurred. | ||
""" | ||
|
||
__selector__ = selector( | ||
verb__id="http://adlnet.gov/expapi/verbs/answered", | ||
context__contextActivities__definition__type=( | ||
"http://adlnet.gov/expapi/activities/assessment" | ||
verb__id="http://adlnet.gov/expapi/verbs/launched", | ||
object__definition__type=( | ||
"http://adlnet.gov/expapi/activities/cmi.interaction" | ||
), | ||
) | ||
|
||
object: QuestionObjectField = QuestionObjectField() | ||
verb: AnsweredVerbField = AnsweredVerbField() | ||
context: AssessmentContextField = AssessmentContextField() | ||
result: Optional[ResultField] | ||
verb: LaunchedVerb = LaunchedVerb() | ||
object: CMIInteractionActivityType | ||
context: AssessmentContext | ||
timestamp: datetime | ||
|
||
|
||
class AssessmentCompleted(BaseXapiStatement): | ||
"""Pydantic model for assessment completed statement. | ||
Example: | ||
Attributes: | ||
verb (dict): See CompletedVerb. | ||
result (dict): See CMIInteractionActivityType. | ||
context (dict): See VideoCompletedContext. | ||
""" | ||
|
||
__selector__ = selector( | ||
object__definition__type="http://adlnet.gov/expapi/activities/cmi.interaction", | ||
verb__id="http://adlnet.gov/expapi/verbs/completed", | ||
) | ||
|
||
verb: CompletedVerb = CompletedVerb() | ||
result: CMIInteractionActivityType | ||
context: AssessmentContext | ||
timestamp: datetime | ||
|
||
|
||
class AssessmentTerminated(BaseXapiStatement): | ||
"""Pydantic model for assessment terminated statement. | ||
Example: | ||
Attributes: | ||
verb (dict): See CompletedVerb. | ||
result (dict): See CMIInteractionActivityType. | ||
context (dict): See VideoCompletedContext. | ||
""" | ||
|
||
__selector__ = selector( | ||
object__definition__type="http://adlnet.gov/expapi/activities/cmi.interaction", | ||
verb__id="http://adlnet.gov/expapi/verbs/terminated", | ||
) | ||
|
||
verb: TerminatedVerb = TerminatedVerb() | ||
result: CMIInteractionActivityType | ||
context: AssessmentContext | ||
timestamp: datetime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"""Constants for `Assessment` xAPI profile.""" | ||
|
||
try: | ||
from typing import Literal | ||
except ImportError: | ||
from typing_extensions import Literal | ||
|
||
|
||
ASSESSMENT_CONTEXT_CATEGORY = Literal[ # pylint:disable=invalid-name | ||
"https://w3id.org/xapi/assessment" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.