Skip to content

Commit

Permalink
Added docstrings for the views.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Rutvikrj26 committed Aug 6, 2024
1 parent 90784a9 commit a539962
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions physionet-django/training/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,23 @@ def download_course(request, training_slug, version):

@login_required
def take_training(request, training_slug):
"""
Handles the display of a user's training course and their progress.
This view performs the following tasks:
- Retrieves the active course based on the provided training slug.
- Retrieves the modules associated with the course.
- Retrieves or creates the user's course progress.
- Retrieves or creates the user's module progress for each module.
- Updates the module's progress status and last completed order.
- Renders the training course page with the course and module details.
Input Required:
- training_slug: The slug of the training course.
Returns:
- A rendered template displaying the training course and module progress.
"""

course = Course.objects.filter(training_type__slug=training_slug, is_active=True).order_by('version').last()
if course is None:
Expand Down Expand Up @@ -286,6 +303,25 @@ def take_training(request, training_slug):

@login_required
def current_module_block(request, training_slug, module_order, order):
"""
Handles the display and progression of a user's current module block in a training course.
This view performs the following tasks:
- Retrieves the course, module, course progress, and module progress based on the provided training slug and module order.
- Ensures the requested order is within the valid range of the module's content and quizzes.
- Handles POST requests to update the user's progress when they complete a quiz or content block.
- Redirects the user to the appropriate next block or module upon completion.
- Renders the current module block (quiz or content) for GET requests.
Input Required:
- training_slug: The slug of the training course.
- module_order: The order of the module within the course.
- order: The order of the content block or quiz within the module.
Returns:
- A redirect to the appropriate module block or training page upon completion.
- A rendered template displaying the current module block for GET requests.
"""

# get the course, module, course_progress, module_progress
course, module = get_course_and_module(training_slug, module_order)
Expand Down

0 comments on commit a539962

Please sign in to comment.