Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new python den episodes and fix links #1750

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions game/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -3339,6 +3339,8 @@ def get_episode_title(episode_id):
20: "String Manipulation",
21: "Lists",
22: "Procedures",
23: "2D Lists",
24: "Procedures and Functions"
}

return episode_titles[episode_id]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.16 on 2024-11-27 15:43

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("game", "0106_fields_to_snake_case"),
]

operations = [
migrations.RenameField(
model_name="episode",
old_name="worksheet_link",
new_name="student_worksheet_link",
),
]
18 changes: 18 additions & 0 deletions game/migrations/0108_episode_indy_worksheet_link.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.16 on 2024-11-27 15:44

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("game", "0107_rename_worksheet_link_episode_student_worksheet_link"),
]

operations = [
migrations.AddField(
model_name="episode",
name="indy_worksheet_link",
field=models.CharField(blank=True, default=None, max_length=500, null=True),
),
]
99 changes: 99 additions & 0 deletions game/migrations/0109_create_episodes_23_and_24.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
from django.apps.registry import Apps
from django.db import migrations


def create_episodes_23_and_24(apps: Apps, *args):
Episode = apps.get_model("game", "Episode")

episode_23 = Episode.objects.create(
pk=23,
name="2D Lists",
student_worksheet_link="https://code-for-life.gitbook.io/student-resources/python-den-student-resources/worksheet-12-2d-lists",
indy_worksheet_link="https://code-for-life.gitbook.io/independent-student-resources/python-den-resources-beta/session-12-2d-lists",
video_link="https://www.youtube.com/watch?v=MBU49ivZk6w",
lesson_plan_link="https://code-for-life.gitbook.io/python-lessons-with-raspberry-pi-ide/EMEzsyyl4uRclyA9LDGN/python-12-2d-lists",
slides_link="https://4077022412-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwAuC4Q5WQz4ea2O2b2JP%2Fuploads%2F3Q4X7ZDk1TNej5c2e7LW%2FPython%2012%202D%20Lists.pptx?alt=media&token=847d9d69-4610-4c67-a649-0c6e0f88d372",
)

episode_24 = Episode.objects.create(
pk=24,
name="Procedures and Functions",
student_worksheet_link="https://code-for-life.gitbook.io/student-resources/python-den-student-resources/worksheet-13-procedures-and-functions",
indy_worksheet_link="https://code-for-life.gitbook.io/independent-student-resources/python-den-resources-beta/session-13-procedures-and-functions",
video_link="https://www.youtube.com/watch?v=LJMfI7P3Dzk",
lesson_plan_link="https://code-for-life.gitbook.io/python-lessons-with-raspberry-pi-ide/EMEzsyyl4uRclyA9LDGN/python-13-procedures-and-functions",
slides_link="https://4077022412-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwAuC4Q5WQz4ea2O2b2JP%2Fuploads%2Fmr6FvFzY3LVuaGT1zd6d%2FPython%2013%20Procedures%20and%20Functions.pptx?alt=media&token=c5835e00-8d42-4567-8cf4-868b0f23dc0a",
)

episode_23.next_episode = episode_24
episode_23.save()

episode_16 = Episode.objects.get(pk=16)
episode_16.indy_worksheet_link = "https://code-for-life.gitbook.io/independent-student-resources/python-den-resources-beta/session-1-output-operators-and-data"
episode_16.save()

episode_17 = Episode.objects.get(pk=17)
episode_17.indy_worksheet_link = "https://code-for-life.gitbook.io/independent-student-resources/python-den-resources-beta/session-2-variables-input-and-casting"
episode_17.save()

episode_18 = Episode.objects.get(pk=18)
episode_18.indy_worksheet_link = "https://code-for-life.gitbook.io/independent-student-resources/python-den-resources-beta/session-3-selection"
episode_18.save()

episode_19 = Episode.objects.get(pk=19)
episode_19.indy_worksheet_link = "https://code-for-life.gitbook.io/independent-student-resources/python-den-resources-beta/session-4-complex-selection"
episode_19.save()

episode_12 = Episode.objects.get(pk=12)
episode_12.indy_worksheet_link = "https://code-for-life.gitbook.io/independent-student-resources/python-den-resources-beta/session-5-iteration-part-1"
episode_12.save()

episode_13 = Episode.objects.get(pk=13)
episode_13.indy_worksheet_link = "https://code-for-life.gitbook.io/independent-student-resources/python-den-resources-beta/session-7-selection-in-a-loop"
episode_13.save()

episode_14 = Episode.objects.get(pk=14)
episode_14.indy_worksheet_link = "https://code-for-life.gitbook.io/independent-student-resources/python-den-resources-beta/session-8-indeterminate-loops"
episode_14.save()

episode_20 = Episode.objects.get(pk=20)
episode_20.indy_worksheet_link = "https://code-for-life.gitbook.io/independent-student-resources/python-den-resources-beta/session-9-string-manipulation"
episode_20.save()

episode_21 = Episode.objects.get(pk=21)
episode_21.indy_worksheet_link = "https://code-for-life.gitbook.io/independent-student-resources/python-den-resources-beta/session-10-1d-lists"
episode_21.save()

episode_15 = Episode.objects.get(pk=15)
episode_15.next_episode = episode_23
episode_15.indy_worksheet_link = "https://code-for-life.gitbook.io/independent-student-resources/python-den-resources-beta/session-11-using-for-loops"
episode_15.save()


def delete_episodes_23_and_24(apps: Apps, *args):
Episode = apps.get_model("game", "Episode")

episode_15 = Episode.objects.get(pk=15)
episode_15.next_episode = None
episode_15.indy_worksheet_link = None
episode_15.save()

Episode.objects.filter(pk__in=[
16, 17, 18, 19, 12, 13, 14, 20, 21
]).update(indy_worksheet_link=None)

Episode.objects.filter(pk__in=[23, 24]).delete()


class Migration(migrations.Migration):

dependencies = [
("game", "0108_episode_indy_worksheet_link"),
]

operations = [
migrations.RunPython(
code=create_episodes_23_and_24,
reverse_code=delete_episodes_23_and_24,
)
]
5 changes: 4 additions & 1 deletion game/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ class Episode(models.Model):
slides_link = models.CharField(
max_length=500, null=True, blank=True, default=None
)
worksheet_link = models.CharField(
student_worksheet_link = models.CharField(
max_length=500, null=True, blank=True, default=None
)
indy_worksheet_link = models.CharField(
max_length=500, null=True, blank=True, default=None
)
video_link = models.CharField(
Expand Down
10 changes: 5 additions & 5 deletions game/templates/game/python_den_level_selection.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ <h4>Introduction to Python</h4>
</div>
{% elif user|is_independent_student %}
<div class="col-sm-3 python-den-level">
<a href="{{episode.worksheet_link}}" class="button button--level button--icon" target="_blank">
<a href="{{episode.indy_worksheet_link}}" class="button button--level button--icon" target="_blank">
Worksheet<span class="iconify" data-icon="mdi:open-in-new"></span></a>
</div>
<div class="col-sm-2 python-den-level">
Expand All @@ -95,7 +95,7 @@ <h4>Introduction to Python</h4>
{% else %}
<div class="col-sm-3"></div>
<div class="col-sm-2 python-den-level">
<a href="{{episode.worksheet_link}}" class="button button--level button--icon" target="_blank">
<a href="{{episode.student_worksheet_link}}" class="button button--level button--icon" target="_blank">
Worksheet<span class="iconify" data-icon="mdi:open-in-new"></span></a>
</div>
{% endif %}
Expand Down Expand Up @@ -161,7 +161,7 @@ <h4>Introduction to Python</h4>
</div>
{% elif user|is_independent_student %}
<div class="col-sm-3 python-den-level">
<a href="{{episode.worksheet_link}}" class="button button--level button--icon" target="_blank">
<a href="{{episode.indy_worksheet_link}}" class="button button--level button--icon" target="_blank">
Worksheet<span class="iconify" data-icon="mdi:open-in-new"></span></a>
</div>
<div class="col-sm-2 python-den-level">
Expand All @@ -171,7 +171,7 @@ <h4>Introduction to Python</h4>
{% else %}
<div class="col-sm-3"></div>
<div class="col-sm-2 python-den-level">
<a href="{{episode.worksheet_link}}" class="button button--level button--icon" target="_blank">
<a href="{{episode.student_worksheet_link}}" class="button button--level button--icon" target="_blank">
Worksheet<span class="iconify" data-icon="mdi:open-in-new"></span></a>
</div>
{% endif %}
Expand Down Expand Up @@ -230,7 +230,7 @@ <h4>Introduction to Python</h4>
</div>
{% elif user|is_independent_student %}
<div class="col-sm-3 python-den-level">
<a href="https://code-for-life.gitbook.io/student-resources/python-den-student-resources/worksheet-6-iteration-part-2" class="button button--level button--icon" target="_blank">
<a href="https://code-for-life.gitbook.io/independent-student-resources/python-den-resources-beta/session-6-iteration-part-2" class="button button--level button--icon" target="_blank">
Worksheet<span class="iconify" data-icon="mdi:open-in-new"></span></a>
</div>
<div class="col-sm-2 python-den-level">
Expand Down
3 changes: 2 additions & 1 deletion game/views/level_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def fetch_episode_data_from_database(early_access, start, end):
"difficulty": episode.difficulty,
"lesson_plan_link": episode.lesson_plan_link,
"slides_link": episode.slides_link,
"worksheet_link": episode.worksheet_link,
"student_worksheet_link": episode.student_worksheet_link,
"indy_worksheet_link": episode.indy_worksheet_link,
"video_link": episode.video_link,
}

Expand Down