-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: javascript calls in QPPE, package deps and data structures
- Loading branch information
1 parent
43a429c
commit 8ca0cc1
Showing
16 changed files
with
272 additions
and
138 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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# QuestionPy is free software released under terms of the MIT license. See LICENSE.md. | ||
# (c) Technische Universität Berlin, innoCampus <[email protected]> | ||
|
||
from enum import Enum | ||
from enum import Enum, StrEnum | ||
from typing import Annotated | ||
|
||
from pydantic import BaseModel, Field | ||
|
@@ -17,7 +17,13 @@ | |
"AttemptUi", | ||
"CacheControl", | ||
"ClassifiedResponse", | ||
"DisplayRole", | ||
"FeedbackType", | ||
"JsModuleCall", | ||
"ScoreModel", | ||
"ScoredInputModel", | ||
"ScoredInputState", | ||
"ScoredSubquestionModel", | ||
"ScoringCode", | ||
] | ||
|
||
|
@@ -28,6 +34,33 @@ class CacheControl(Enum): | |
NO_CACHE = "NO_CACHE" | ||
|
||
|
||
class DisplayRole(StrEnum): | ||
DEVELOPER = "DEVELOPER" | ||
PROCTOR = "PROCTOR" | ||
SCORER = "SCORER" | ||
TEACHER = "TEACHER" | ||
|
||
|
||
class FeedbackType(StrEnum): | ||
GENERAL_FEEDBACK = "GENERAL_FEEDBACK" | ||
SPECIFIC_FEEDBACK = "SPECIFIC_FEEDBACK" | ||
RIGHT_ANSWER = "RIGHT_ANSWER" | ||
HINT = "HINT" | ||
|
||
|
||
class JsModuleCall(BaseModel): | ||
module: Annotated[str, Field(pattern=r"^[a-zA-Z0-9_$/@.]+$")] | ||
"""JS module name like @[package namespace]/[package short name]/[module].js""" | ||
function: Annotated[str, Field(pattern=r"^[a-zA-Z0-9_$]+$")] | ||
"""Name of a callable value within the JS module.""" | ||
data: str | None | ||
"""JSON data given as argument to the function""" | ||
if_role: DisplayRole | None | ||
"""Function is only called if the user has this role.""" | ||
if_feedback_type: FeedbackType | None | ||
"""Function is only called if the user is allowed to view this feedback type.""" | ||
|
||
|
||
class AttemptFile(BaseModel): | ||
name: str | ||
mime_type: str | None = None | ||
|
@@ -47,6 +80,7 @@ class AttemptUi(BaseModel): | |
placeholders: dict[str, str] = {} | ||
"""Names and values of the ``<?p`` placeholders that appear in content.""" | ||
css_files: list[str] = [] | ||
javascript_calls: list[JsModuleCall] = [] | ||
files: dict[str, AttemptFile] = {} | ||
cache_control: CacheControl = CacheControl.PRIVATE_CACHE | ||
|
||
|
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
Oops, something went wrong.