Mixins provided by mtrchk.org.momotor.lti.mixins¶
- checklet mixin class mtrchk.org.momotor.lti.mixins.feedback.FeedbackOptionMixin¶
A Checklet mixin that adds feedback options to a step. Different feedback can be prepended to the report when the step passes or fails.
- feedback-pass option¶
Feedback to prepend to the report property when this step passes.
Can contain reference placeholders and task id placeholders.
- Type:
Any
- Required:
False
- Multiple:
False
- Location:
config, step, recipe
- Default:
No default
- feedback-fail option¶
Feedback to prepend to the report property when this step fails.
Can contain reference placeholders and task id placeholders.
- Type:
Any
- Required:
False
- Multiple:
False
- Location:
config, step, recipe
- Default:
No default
- _feedback_option_wrapper(result)¶
Takes a
CheckletResultand adds feedback to the report according to the options.- Parameters:
result (
CheckletResult) – the result to update- Return type:
- classmethod decorator(runner)¶
Decorator for
Checklet.run()that adds the feedback to the report based on the options and the outcome of the step.
- MERGED_PROPS_TYPE: typing.ClassVar[dict[str, tuple[type, str | collections.abc.Callable]]] = {'checklet-warning': (<class 'set'>, 'update'), 'reason': (<class 'str'>, <function CheckletResult.<lambda>>), 'report': (<class 'collections.deque'>, 'extend'), 'reportCss': (<class 'set'>, 'update'), 'reportJs': (<class 'set'>, 'update'), 'secret': (<class 'bool'>, <built-in function or_>)}¶
Properties that need special handling when merging using
merge_results(). Default is usingoperator.add()which will work for strings and numeric values. Mapping from property name to a tuple containing the merged type, and a method for merging. The method for merging can be a function, or a method name for a method on the merged type.
- checklet mixin class mtrchk.org.momotor.lti.mixins.label.LabelOptionMixin¶
A Checklet mixin that adds a label property to the result.
The label can contain reference placeholders and task id placeholders
- label option¶
Label for this step. Momotor LTI uses labels as the header of the step in the result view. If a step does not have a label, Momotor LTI will use the step id as the label.
Can contain reference placeholders and task id placeholders.
- Type:
Any
- Required:
False
- Multiple:
False
- Location:
config, step, recipe
- Default:
No default
- _add_label_property(result)¶
Adds label property as provided by the label option
- Parameters:
result (
CheckletResult) – the result to add the label property to- Return type:
- _get_label()¶
Generate the label option with reference and task placeholders resolved
- classmethod decorator(runner)¶
Decorator for
Checklet.run()that adds the label to the result based on the label option value.
- checklet mixin class mtrchk.org.momotor.lti.mixins.outputfile.OutputFileOptionMixin¶
A Checklet mixin that adds commonly used functionality to capture output from a step into a file node.
- output-file option¶
This option defines the file or property that will contain the contents of an output file generated by the step. The syntax is:
output-file-option ::= [ "$" ][ name ] ":" [ output-class-name | "%" output-property-name ]
The left hand side (before the colon) defines the file name. If only name is provided, a file with that name is expected to exist in the step workdir after running the step. If value starts with
$, a unique file name is generated. If a name follows the$, the generated file name is stored in an environment variable with that name.The right hand side (after the colon) is either an output file class name, or a
%followed by a property name. The contents of the file are provided to the next steps through either a file with the given class, or a property with the given name.Example values:
output.txt:output: expects file output.txt in the step workdir and creates a file node with class output with the contents of the output.txt fileoutput.txt:%output: expects file output.txt in the step workdir and creates a property output with the contents of the output.txt file$OUTPUT_FILE:output: creates an empty file with a unique file name and stores that file name in an environment variableOUTPUT_FILEbefore the step is executed. After the step finishes, a file node with class output is created with the contents of the file.
Can contain reference placeholders and task id placeholders.
- Type:
Any
- Required:
False
- Multiple:
True
- All:
False
- Location:
config, step, recipe
- Default:
No default
- output-file-missing option¶
Action to take and optional message if the output file expected by the
output-fileoption does not exist.Action can be one of:
ignore: Do nothingfail: Fail the stepfail-secret: Fail the step marking the step as secretfail-hidden: Fail the step marking the step as hiddenerror: Raise a CheckletErrorwarn: Log a warning
The action can be followed by a message that will be logged or included in the report.
- Type:
string
- Required:
False
- Multiple:
False
- Location:
config, step, recipe
- Default:
fail Expected output file does not exist
- _collect_output(output_file_path, target_option, result)¶
Collects the output from the output file and adds it to the result.
- Parameters:
output_file_path (
Path) – the path to the output filetarget_option (
str) – the target optionresult (
CheckletResult) – the result to add the output to
- Return type:
- _modify_command(cmd, env, temp_dir)¶
Wrapper that should be used by subclasses to modify the command and environment.
- _prepare_output_file(file_name_option)¶
Prepares the output file and yields the file path.
- classmethod decorator(runner)¶
Decorator for
Checklet.run()that adds an output file or property to the result based on the option value.The decorator handles the creation and collection of the output file, but the
_modify_command()method must be used by subclasses to modify the command and environment before execution.
- checklet mixin class mtrchk.org.momotor.lti.mixins.secret.SecretOptionMixin¶
A Checklet mixin that can add a property with name secret to the result.
Momotor LTI will not show steps containing a property named secret set to
trueto learners. The step will still be visible to reviewers.- secret option¶
Dynamic secret property value for the result. Momotor LTI will not show steps with a secret property set to
trueto learners, but will still show that step to reviewers.The option value can be one of the following:
alwaysortrue: adds a secret property with valuetrueto the result.false: do not add a secret property to the result.on-fail: adds a secret property with valuetrueto the result if the step fails.on-pass: adds a secret property with valuetrueto the result if the step passed.default: inherits the value from the next provider. If the last provider is ‘default’ no property will be added.
Note that this only adds a secret property with value
true, but never one with valuefalse. This ensures that a default defined in a recipe will be used unless the step or config explicitly override it.The value can contain reference placeholders to inherit the value from another step’s options or properties.
- Type:
Any
- Required:
False
- Multiple:
False
- Location:
config, step, recipe
- Default:
default
- _add_secret_property(result)¶
Takes a
CheckletResultand adds the secret property based on the secret option value and the outcome of the step.- Parameters:
result (
CheckletResult) – the result to add the secret property to- Return type:
- _is_secret(result)¶
Returns True if the secret property should be added to the given
CheckletResult.- Parameters:
result (
CheckletResult) – the result to check- Return type:
- classmethod decorator(runner)¶
Decorator for
Checklet.run()that adds the secret property to the result based on the secret option value and the outcome of the step.