Skip to content

Commit

Permalink
disable worksheets
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Dec 3, 2024
1 parent 3eb9fd2 commit 9b48ea9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
44 changes: 24 additions & 20 deletions game/templates/game/python_den_level_selection.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,18 @@ <h4>Introduction to Python</h4>
{% for level in episode.levels %}
{% for worksheet in episode.worksheets %}
{% if worksheet.before_level == level.id %}
{% if user|is_logged_in %}
{% if not user|is_logged_in or user.new_student.class_field in worksheet.locked_classes.all %}
{% if not user|is_logged_in %}
<p class="text--warning">In order to access the full content for this course, please log in.</p>
{% endif %}
<div class="col-sm-10 python-den-level">
<a class="disabled">{{episode.name}}</a>
</div>
<div class="col-sm-2 python-den-level">
<a class="button button--level button--icon disabled">
Worksheet<span class="iconify" data-icon="mdi:open-in-new"></span></a>
</div>
{% else %}
<div class="col-sm-7 python-den-level">
<a href="https://editor.raspberrypi.org/en/projects/blank-python-starter" target="_blank">{{episode.name}}</a>
</div>
Expand Down Expand Up @@ -178,15 +189,6 @@ <h4>Introduction to Python</h4>
Worksheet<span class="iconify" data-icon="mdi:open-in-new"></span></a>
</div>
{% endif %}
{% else %}
<p class="text--warning">In order to access the full content for this course, please log in.</p>
<div class="col-sm-10 python-den-level">
<a class="disabled">{{episode.name}}</a>
</div>
<div class="col-sm-2 python-den-level">
<a class="button button--level button--icon disabled">
Worksheet<span class="iconify" data-icon="mdi:open-in-new"></span></a>
</div>
{% endif %}
{% endif %}
{% endfor %}
Expand Down Expand Up @@ -220,7 +222,18 @@ <h4>Introduction to Python</h4>
{% endfor %}
{% for worksheet in episode.worksheets %}
{% if not worksheet.before_level %}
{% if user|is_logged_in %}
{% if not user|is_logged_in or user.new_student.class_field in worksheet.locked_classes.all %}
{% if not user|is_logged_in %}
<p class="text--warning">In order to access the full content for this course, please log in.</p>
{% endif %}
<div class="col-sm-10 python-den-level">
<a class="disabled">{{episode.name}}{% if episode.worksheets|length > 1 %} pt. {{ forloop.counter }}{% endif %}</a>
</div>
<div class="col-sm-2 python-den-level">
<a class="button button--level button--icon disabled">
Worksheet<span class="iconify" data-icon="mdi:open-in-new"></span></a>
</div>
{% else %}
<div class="col-sm-7 python-den-level">
<a href="https://editor.raspberrypi.org/en/projects/blank-python-starter" target="_blank">{{episode.name}}{% if episode.worksheets|length > 1 %} pt. {{ forloop.counter }}{% endif %}</a>
</div>
Expand Down Expand Up @@ -249,15 +262,6 @@ <h4>Introduction to Python</h4>
Worksheet<span class="iconify" data-icon="mdi:open-in-new"></span></a>
</div>
{% endif %}
{% else %}
<p class="text--warning">In order to access the full content for this course, please log in.</p>
<div class="col-sm-10 python-den-level">
<a class="disabled">{{episode.name}}{% if episode.worksheets|length > 1 %} pt. {{ forloop.counter }}{% endif %}</a>
</div>
<div class="col-sm-2 python-den-level">
<a class="button button--level button--icon disabled">
Worksheet<span class="iconify" data-icon="mdi:open-in-new"></span></a>
</div>
{% endif %}
{% endif %}
{% endfor %}
Expand Down
5 changes: 5 additions & 0 deletions game/views/level_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ def levels(request, language):
id=level["id"]
).locked_for_class

for worksheet in episode["worksheets"]:
worksheet["locked_classes"] = Worksheet.objects.get(
id=worksheet["id"]
).locked_classes

context["pythonEpisodes"] = python_episodes

return context
Expand Down

0 comments on commit 9b48ea9

Please sign in to comment.