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 CheckletResult and adds feedback to the report according to the options.

Parameters:

result (CheckletResult) – the result to update

Return type:

CheckletResult

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 using operator.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:

CheckletResult

_get_label()

Generate the label option with reference and task placeholders resolved

Return type:

str | None

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 file

  • output.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 variable OUTPUT_FILE before 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-file option does not exist.

Action can be one of:

  • ignore: Do nothing

  • fail: Fail the step

  • fail-secret: Fail the step marking the step as secret

  • fail-hidden: Fail the step marking the step as hidden

  • error: Raise a CheckletError

  • warn: 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 file

  • target_option (str) – the target option

  • result (CheckletResult) – the result to add the output to

Return type:

CheckletResult

_modify_command(cmd, env, temp_dir)

Wrapper that should be used by subclasses to modify the command and environment.

Return type:

tuple[Sequence[str], dict[str, str]]

_prepare_output_file(file_name_option)

Prepares the output file and yields the file path.

Return type:

Generator[Path, None, None]

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 true to 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 true to learners, but will still show that step to reviewers.

The option value can be one of the following:

  • always or true: adds a secret property with value true to the result.

  • false: do not add a secret property to the result.

  • on-fail: adds a secret property with value true to the result if the step fails.

  • on-pass: adds a secret property with value true to 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 value false. 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 CheckletResult and 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:

CheckletResult

_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:

bool

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.