Mathematics exercise

The mathematical calculate exercise module.

POINTS_FOR_THE_TASK = 0

The number of points awarded for a correctly completed task, by default (int).

MAX_POINTS_BALANCE = 0

The maximum allowed accumulation of points on the user’s balance. (int)

class CalculationExercise(*, user_id: int | None = None, calculation_type: str, min_value: int, max_value: int, timeout: int | None = None)

Bases: object

Calculation exercise class with two operands.

Stores in cache the date and time of task creation for a specific user.

Parameters

user_idint

User performing the exercise.

calculation_typestr

Alias representation of mathematical operator of task.

min_valueint

Minimum value of operands.

max_valueint

Maximum value of operands.

timeoutint | None

Time value to display a math task before displaying the result, sec (None | int).

question_text = None

Еhe text representation of a mathematical expression to render to the user(None | str).

answer_text = None

The text representation of the result of calculating a mathematical expression (None | str).

class CalculationExerciseCheck(*, request: HttpRequest, form: Form)

Bases: object

Calculation exercise check class.

user_id: int | None = None

Current user id (int | None).

property solution_time: int

Time for user to solve the task (reade-only).

check_user_to_reward() bool

Check if points should be awarded to the user.

save_task_to_db() None

Save task conditions and user solution to database.

property award: int

The number of points as a reward for success task solution (int, read-only).

accrue_reward() None

Award points to the user for solving the task correctly.

check_and_save_user_solution() bool

Check and save the user task with its solution.