Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions tested/dodona.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,7 @@
from attrs import define
from cattrs.preconf.json import make_converter


@unique
class Permission(StrEnum):
"""To which level of user this message is visible."""

STAFF = auto()
STUDENT = auto()
ZEUS = auto()

from testsuite import Permission

@define
class ExtendedMessage:
Expand Down
13 changes: 12 additions & 1 deletion tested/dsl/schema-strict.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@
},
"hidden" : {
"type" : "boolean",
"description" : "Defines if the unit/tab is hidden for the student or not"
"description" : "Tab is only shown if it has tests that failed"
},
"permission": {
"$ref" : "#/definitions/permission"
},
"tab" : {
"type" : "string",
Expand Down Expand Up @@ -142,6 +145,14 @@
}
]
},
"permission": {
"type" : "string",
"description" : "One of the permission levels supported by Dodona",
"enum" : [
"student",
"staff"
]
},
"unit" : {
"type" : "object",
"description" : "A unit in the test suite.",
Expand Down
13 changes: 12 additions & 1 deletion tested/dsl/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@
},
"hidden" : {
"type" : "boolean",
"description" : "Defines if the unit/tab is hidden for the student or not"
"description" : "Tab is only shown if it has tests that failed"
},
"permission": {
"$ref" : "#/definitions/permission"
},
"tab" : {
"type" : "string",
Expand Down Expand Up @@ -142,6 +145,14 @@
}
]
},
"permission": {
"type" : "string",
"description" : "One of the permission levels supported by Dodona",
"enum" : [
"student",
"staff"
]
},
"unit" : {
"type" : "object",
"description" : "A unit in the test suite.",
Expand Down
2 changes: 1 addition & 1 deletion tested/judge/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def _process_results(
collector.add(CloseTab(), currently_open_tab)
currently_open_tab = currently_open_tab + 1
tab = bundle.suite.tabs[currently_open_tab]
collector.add(StartTab(title=tab.name, hidden=tab.hidden))
collector.add(StartTab(title=tab.name, hidden=tab.hidden, permission=tab.permission))

# Handle the contexts.
collector.add(StartContext(description=planned.context.description))
Expand Down
2 changes: 1 addition & 1 deletion tested/judge/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def complete_evaluation(bundle: Bundle, collector: OutputManager):

for tab in bundle.suite.tabs[tab_start:]:
if context_start == 0 and testcase_start == 0:
collector.add(StartTab(title=tab.name, hidden=tab.hidden))
collector.add(StartTab(title=tab.name, hidden=tab.hidden, permission=tab.permission))
assert tab.contexts
for context in tab.contexts[context_start:]:
updates: list[Update] = [
Expand Down
8 changes: 8 additions & 0 deletions tested/testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,13 @@ def _runs_to_tab_converter(runs: list | None):
contexts.append(context)
return contexts

@unique
class Permission(StrEnum):
"""To which level of user this message is visible."""

STAFF = auto()
STUDENT = auto()
ZEUS = auto()

@custom_fallback_field(get_converter(), {"runs": ("contexts", _runs_to_tab_converter)})
@define
Expand All @@ -692,6 +699,7 @@ class Tab(WithFeatures, WithFunctions):
name: str
contexts: list[Context] = field()
hidden: bool | None = None
permission: Permission | None = None

def get_used_features(self) -> FeatureSet:
assert self.contexts is not None
Expand Down
21 changes: 21 additions & 0 deletions tests/test_dsl_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
GenericValueOracle,
LanguageLiterals,
LanguageSpecificOracle,
Permission,
SupportedLanguage,
TextOutputChannel,
ValueOutputChannel,
Expand Down Expand Up @@ -1326,6 +1327,26 @@ def test_programming_language_can_be_globally_configured():
assert testcase.input.type == "expression"
assert testcase.input.literals.keys() == {"java"}

def test_tabs_can_be_given_permission():
yaml_str = """
namespace: "solution"
tabs:
- tab: "Ctx"
permission: "staff"
testcases:
- arguments: [ "--arg", "argument" ]
stdin: "Input string"
stdout: "Output string"
stderr: "Error string"
exit_code: 1
"""
json_str = translate_to_test_suite(yaml_str)
suite = parse_test_suite(json_str)
assert len(suite.tabs) == 1
tab = suite.tabs[0]
assert tab.permission == Permission.STAFF
assert isinstance(testcase.input, LanguageLiterals)
assert testcase.input.type == "expression"

def test_strict_json_schema_is_valid():
path_to_schema = Path(__file__).parent / "tested-draft7.json"
Expand Down
Loading