Foreign app ORM queries

Translate word exercise lookup parameters

Database query module for Foreign word translation exercises.

class WordLookupParams(lookup_conditions: dict)

Bases: LookupParams

Lookup parameters class.

Parameters:

lookup_conditions (dict) – The user exercise conditions.

Examples

lookup_params = LookupParams(lookup_conditions)
params: tuple[Q, ...] = lookup_params.params
query = Model.objects.filter(*params)
property params: tuple[Q, ...]

Lookup parameters (tuple[Q, …], read-only).

property word_favorites: Q

Lookup parameter by favorite status (Q, read-only).

property word_progress: Q

Lookup parameter by user assessment (Q, read-only).

property word_count: Q

Lookup parameter by word count (Q, read-only).

property word_date_start: Q

Lookup parameter by word added date (Q, read-only).

property word_date_end: Q

Lookup parameter by word added date (Q, read-only).

get_date_value(period_date: str, format_time: str) str

Get lookup date value.

Favorite word

The module of favorite words orm_queries using Django ORM.

is_word_in_favorites(user_id: int | str, word_id: int | str) bool

Find out if the word is the favorites.

Parameters:
  • user_id (int | str) – The current user id.

  • word_id (int | str) – The word id for status retrieve.

Return is_favorites:

Return the True if the word is the favorites, otherwise return the False.

Return type:

bool

update_word_favorites_status(word_id: int | str, user_id: int | str) bool

Update the favorite status of the word.

Parameters:
  • word_id (int | str) – The word id for status update.

  • user_id (int | str) – The current user id.

Return favorites_status:

Return the True if the word is the favorites, otherwise return the False. return the False.

Return type:

bool

Word study progress

A module for user word assessment knowledge accounting.

Accounting of the level of knowledge of words in the application.

The module contains functions for querying the database for adding, updating and retrieving the level of knowledge of words assessed by the user. The knowledge assessment has a limited range containing intervals. Each interval is used by the selection of words for display on the page of the user of the application. Each user has his own assessments of words, given by him and available only to him. The application contains the following intervals: study, repetition, verification, know.

get_progress(word_id: int, user_id: int) int

Get or create a user rating of word knowledge.

Get or create a user rating of word knowledge in the database. When creating a rating, the rating is set to “0”.

update_progress(word_pk: int, user_pk: int, new_assessment: int) None

Update the user’s word knowledge score.

Update the user’s word knowledge score in the database, within the acceptable range.

get_numeric_value(progress: str) list[int]

Convert a string representation of a knowledge level.

Convert a string representation of a knowledge level into a range of numbers for that level.