Skip to content

Commit

Permalink
update training home page for UX
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
superryeti committed Mar 28, 2023
1 parent b71b467 commit 3a29de8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
14 changes: 11 additions & 3 deletions physionet-django/training/templates/training/op_training.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,18 @@ <h3>Training Modules</h3>
<td>
<strong>{{ module.name }}</strong>
</td>
<td>Not Started</td>
<td>Not Started</td>
<td>{{ module.progress_status }}</td>
<td>{{ module.progress_updated_date}}</td>
<td>
<a href="{% url 'platform_training_module' training.training_type.pk module.pk %}">Start</a>
<a href="{% url 'platform_training_module' training.training_type.pk module.pk %}">
{% if module.progress_status == ModuleStatus.COMPLETED.label %}
Review
{% elif module.progress_status == ModuleStatus.IN_PROGRESS.label %}
Continue
{% else %}
Start
{% endif %}
</a>
</td>
</tr>
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion physionet-django/training/templates/training/quiz.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="container my-3">
<div class="quizContainer">
<div class="quizHeader">
<h1>{{ training.training_type.name }}</h1>
<h1><a href="{% url 'platform_training' training.training_type.id %}">{{ training.training_type.name }}</a></h1>
</div>
<hr>
<h2>{{ module.name }}</h2>
Expand Down
15 changes: 13 additions & 2 deletions physionet-django/training/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})


Expand Down

0 comments on commit 3a29de8

Please sign in to comment.