From 3a29de823206e69ae38b63d44f9fa8b347fb1c50 Mon Sep 17 00:00:00 2001 From: Amit Upreti Date: Mon, 27 Mar 2023 21:50:19 -0400 Subject: [PATCH] update training home page for UX Here we updated the training home page to display the progress of modules, and dates to user. This should be helpful as users will be able to see which modules have been completed and when. --- .../training/templates/training/op_training.html | 14 +++++++++++--- .../training/templates/training/quiz.html | 2 +- physionet-django/training/views.py | 15 +++++++++++++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/physionet-django/training/templates/training/op_training.html b/physionet-django/training/templates/training/op_training.html index 992c192727..c8a49d6e20 100644 --- a/physionet-django/training/templates/training/op_training.html +++ b/physionet-django/training/templates/training/op_training.html @@ -40,10 +40,18 @@

Training Modules

{{ module.name }} - Not Started - Not Started + {{ module.progress_status }} + {{ module.progress_updated_date}} - Start + + {% if module.progress_status == ModuleStatus.COMPLETED.label %} + Review + {% elif module.progress_status == ModuleStatus.IN_PROGRESS.label %} + Continue + {% else %} + Start + {% endif %} + {% endfor %} diff --git a/physionet-django/training/templates/training/quiz.html b/physionet-django/training/templates/training/quiz.html index 00e79fc689..44ae4e20bd 100644 --- a/physionet-django/training/templates/training/quiz.html +++ b/physionet-django/training/templates/training/quiz.html @@ -11,7 +11,7 @@
-

{{ training.training_type.name }}

+

{{ training.training_type.name }}


{{ module.name }}

diff --git a/physionet-django/training/views.py b/physionet-django/training/views.py index b1b1ccf592..b24c1d023a 100644 --- a/physionet-django/training/views.py +++ b/physionet-django/training/views.py @@ -34,10 +34,21 @@ def take_training(request, training_id=None): Prefetch("modules__quizzes", queryset=Quiz.objects.order_by("?")), Prefetch("modules__contents", queryset=ContentBlock.objects.all())).filter( training_type__id=training_id).order_by('version').last() - + modules = sorted(chain(training.modules.all()), key=operator.attrgetter('order')) + # get the progress of the user for the modules, updated_date + training_progress = OnPlatformTrainingProgress.objects.filter(user=request.user, training__id=training.id).last() + for module in modules: + module_progress = training_progress.module_progresses.filter(module_id=module.id).last() + if module_progress: + module.progress_status = module_progress.get_status_display() + module.progress_updated_date = module_progress.updated_datetime + else: + module.progress_status = 'Not Started' + module.progress_updated_date = None return render(request, 'training/op_training.html', { - 'modules': sorted(chain(training.modules.all()), key=operator.attrgetter('order')), + 'modules': modules, 'training': training, + 'ModuleStatus': ModuleProgress.Status, })