From a5399625bbe23860962dfdd99c34d8b139dfd9c5 Mon Sep 17 00:00:00 2001 From: rutvikrj26 Date: Tue, 6 Aug 2024 10:15:32 -0400 Subject: [PATCH] Added docstrings for the views.py --- physionet-django/training/views.py | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/physionet-django/training/views.py b/physionet-django/training/views.py index e8a04f341..84a0650c6 100644 --- a/physionet-django/training/views.py +++ b/physionet-django/training/views.py @@ -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: @@ -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)