unit_grader.commands package

Submodules

unit_grader.commands.conversion_grader module

unit_grader.commands.conversion_grader.check_unit_existence(dictionary: dict[str, list[str]], unit_to_check: str) str | None[source]

Check if a unit exists in a dictionary.

Parameters:
  • dictionary (dict) – The dictionary to check.

  • unit_to_check (str) – The unit to check.

Returns:

The category of the unit (e.g., ‘temperature’ or ‘volume’). None: If the unit does not exist.

Return type:

str

unit_grader.commands.conversion_grader.validate_input(from_unit: str, to_unit: str, input_value: str) str | None[source]

Validate the input values

Parameters:
  • from_unit (str) – The unit to convert from.

  • to_unit (str) – The unit to convert to.

  • input_value (str) – The input value to be converted.

Returns:

The category of the units (e.g., ‘temperature’ or ‘volume’). None: If the input is invalid.

Return type:

str

unit_grader.commands.conversion_grader.grade_response(input_value: str, from_unit: str, to_unit: str, student_response: str) Answer[source]

Grade a student’s response to a conversion question. The student’s response is correct if it matches the correct answer after both values are rounded to the tenths place. The rounding strategy follows round half to even (Banker’s rounding). For example round(4.65, 1) == 4.6 and round(4.75, 1) == 4.8.

Parameters:
  • input_value (str) – The input value provided in the question.

  • from_unit (str) – The unit mentioned in the question.

  • to_unit (str) – The target unit mentioned in the question.

  • student_response (str) – The student’s response.

Returns:

The result of the grading. Possible values are: Answer.CORRECT, Answer.INCORRECT, Answer.INVALID

Return type:

Answer

Module contents

This file is used to make the commands folder a python module.


The commands package contains the following modules:

  • conversion_grader: Contains the functions for converting units of measure and grading student responses to conversion questions.