We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add sorting networks lessons
- [ ] Lesson 2 (8-10) - needs generated resources
- [ ] Lesson 1 (11-14)
- [ ] Lesson 2 (11-14)

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `csunplugged/resources/views/sorting_network_cards.py`
Content:
```
1 """Module for generating Sorting Network Cards resource."""
2 
3 from random import sample
4 from PIL import Image, ImageDraw, ImageFont
5 from utils.retrieve_query_parameter import retrieve_query_parameter
6 
7 
8 def resource_image(request, resource):
9     """Create a image for Sorting Network Cards resource.
10 
11     Args:
12         request: HTTP request object.
13         resource: Object of resource data.
14 
15     Returns:
16         A list of Pillow image objects.
17     """
18     IMAGE_SIZE_X = 2000
19     IMAGE_SIZE_Y = 3000
20     LINE_COLOUR = "#000000"
21     LINE_WIDTH = 3
22     font_path = "static/fonts/PatrickHand-Regular.ttf"
23 
24     # Retrieve parameters
25     parameter_options = valid_options()
26     card_type = retrieve_query_parameter(request, "type", parameter_options["type"])
27 
28     # Create card outlines
29     card_outlines = Image.new("RGB", (IMAGE_SIZE_X, IMAGE_SIZE_Y), "#fff")
30     draw = ImageDraw.Draw(card_outlines)
31     for x_coord in range(0, IMAGE_SIZE_X, IMAGE_SIZE_X - LINE_WIDTH):
32         draw.line([(x_coord, 0), (x_coord, IMAGE_SIZE_Y)], fill=LINE_COLOUR, width=LINE_WIDTH)
33     for y_coord in range(0, IMAGE_SIZE_Y, int(IMAGE_SIZE_Y / 2 - LINE_WIDTH)):
34         draw.line([(0, y_coord), (IMAGE_SIZE_X, y_coord)], fill=LINE_COLOUR, width=LINE_WIDTH)
35 
36     # Prepare text data
37     if card_type == "small_numbers":
38         font_size = 800
39         text = ["1", "2", "3", "4", "5", "6"]
40     elif card_type == "large_numbers":
41         font_size = 500
42         text = []
43         numbers = sample(range(1700000, 2100000), 6)
44         for number in numbers:
45             text.append("{:,}".format(number))
46     elif card_type == "fractions":
47         font_size = 900
48         font_path = "static/fonts/NotoSans-Regular.ttf"
49         text = [u"\u00bd", u"\u2153", u"\u2154", u"\u215c", u"\u00be", u"\u215d"]
50     else:
51         font_size = 300
52         text = [
53             "tahi",
54             "rua",
55             "toru",
56             "whā",
57             "rima",
58             "ono",
59             "whitu",
60             "waru",
61             "iwa",
62             "tekau",
63             "tekau mā tahi",
64             "tekau mā waru",
65             "tekau mā toru",
66             "tekau mā whā",
67             "rua tekau",
68             "rua tekau mā ono",
69         ]
70 
71     font = ImageFont.truetype(font_path, font_size)
72     card_centers = [
73         (IMAGE_SIZE_X / 2, IMAGE_SIZE_Y / 4),
74         (IMAGE_SIZE_X / 2, (IMAGE_SIZE_Y / 4) * 3),
75     ]
76 
77     # Add text to cards
78     images = []
79     for (text_number, text_string) in enumerate(text):
80         if text_number % 2 == 0:
81             page = card_outlines.copy()
82             draw = ImageDraw.Draw(page)
83             (x, y) = card_centers[0]
84         else:
85             (x, y) = card_centers[1]
86 
87         text_width, text_height = draw.textsize(text_string, font=font)
88         coord_x = x - (text_width / 2)
89         coord_y = y - (text_height / 1.5)
90         draw.text(
91             (coord_x, coord_y),
92             text_string,
93             font=font,
94             fill="#000"
95         )
96         # If text on second card but not last page
97         if text_number % 2 == 1 and text_number != len(text) - 1:
98             images.append(page)
99     images.append(page)
100 
101     return images
102 
103 
104 def subtitle(request, resource):
105     """Return the subtitle string of the resource.
106 
107     Used after the resource name in the filename, and
108     also on the resource image.
109 
110     Args:
111         request: HTTP request object
112         resource: Object of resource data.
113 
114     Returns:
115         text for subtitle (string)
116     """
117     return "{} - {}".format(
118         retrieve_query_parameter(request, "type").replace("_", " "),
119         retrieve_query_parameter(request, "paper_size")
120     )
121 
122 
123 def valid_options():
124     """Provide dictionary of all valid parameters.
125 
126     This excludes the header text parameter.
127 
128     Returns:
129         All valid options (dict).
130     """
131     return {
132         "type": ["small_numbers", "large_numbers", "fractions", "maori_numbers"],
133         "paper_size": ["a4", "letter"],
134     }
135
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/csunplugged/resources/views/sorting_network_cards.py b/csunplugged/resources/views/sorting_network_cards.py
--- a/csunplugged/resources/views/sorting_network_cards.py
+++ b/csunplugged/resources/views/sorting_network_cards.py
@@ -47,25 +47,24 @@
         font_size = 900
         font_path = "static/fonts/NotoSans-Regular.ttf"
         text = [u"\u00bd", u"\u2153", u"\u2154", u"\u215c", u"\u00be", u"\u215d"]
-    else:
+    elif card_type == "maori_numbers":
         font_size = 300
         text = [
-            "tahi",
-            "rua",
-            "toru",
-            "whā",
-            "rima",
-            "ono",
-            "whitu",
-            "waru",
-            "iwa",
-            "tekau",
-            "tekau mā tahi",
-            "tekau mā waru",
-            "tekau mā toru",
-            "tekau mā whā",
-            "rua tekau",
-            "rua tekau mā ono",
+            "tahi", "rua", "toru", "whā", "rima", "ono", "whitu", "waru",
+            "iwa", "tekau", "tekau mā tahi", "tekau mā waru", "tekau mā toru",
+            "tekau mā whā", "rua tekau", "rua tekau mā ono"
+        ]
+    elif card_type == "words":
+        font_size = 500
+        text = ["crocodile", "crochet", "kiwi", "weka", "kiwi", "kiwano"]
+    elif card_type == "letters":
+        font_size = 800
+        text = ["L", "O", "N", "K", "E", "D", "S", "P", "G", "B", "I", "Y"]
+    else:
+        font_size = 500
+        text = [
+            "whero", "kākāriki", "kiwikiwi", "karaka",
+            "kōwhai", "pango", "māwhero", "mā"
         ]
 
     font = ImageFont.truetype(font_path, font_size)
@@ -129,6 +128,9 @@
         All valid options (dict).
     """
     return {
-        "type": ["small_numbers", "large_numbers", "fractions", "maori_numbers"],
+        "type": [
+            "small_numbers", "large_numbers", "fractions", "maori_numbers",
+            "words", "letters", "maori_colours"
+        ],
         "paper_size": ["a4", "letter"],
     }

{"golden_diff": "diff --git a/csunplugged/resources/views/sorting_network_cards.py b/csunplugged/resources/views/sorting_network_cards.py\n--- a/csunplugged/resources/views/sorting_network_cards.py\n+++ b/csunplugged/resources/views/sorting_network_cards.py\n@@ -47,25 +47,24 @@\n         font_size = 900\n         font_path = \"static/fonts/NotoSans-Regular.ttf\"\n         text = [u\"\\u00bd\", u\"\\u2153\", u\"\\u2154\", u\"\\u215c\", u\"\\u00be\", u\"\\u215d\"]\n-    else:\n+    elif card_type == \"maori_numbers\":\n         font_size = 300\n         text = [\n-            \"tahi\",\n-            \"rua\",\n-            \"toru\",\n-            \"wh\u0101\",\n-            \"rima\",\n-            \"ono\",\n-            \"whitu\",\n-            \"waru\",\n-            \"iwa\",\n-            \"tekau\",\n-            \"tekau m\u0101 tahi\",\n-            \"tekau m\u0101 waru\",\n-            \"tekau m\u0101 toru\",\n-            \"tekau m\u0101 wh\u0101\",\n-            \"rua tekau\",\n-            \"rua tekau m\u0101 ono\",\n+            \"tahi\", \"rua\", \"toru\", \"wh\u0101\", \"rima\", \"ono\", \"whitu\", \"waru\",\n+            \"iwa\", \"tekau\", \"tekau m\u0101 tahi\", \"tekau m\u0101 waru\", \"tekau m\u0101 toru\",\n+            \"tekau m\u0101 wh\u0101\", \"rua tekau\", \"rua tekau m\u0101 ono\"\n+        ]\n+    elif card_type == \"words\":\n+        font_size = 500\n+        text = [\"crocodile\", \"crochet\", \"kiwi\", \"weka\", \"kiwi\", \"kiwano\"]\n+    elif card_type == \"letters\":\n+        font_size = 800\n+        text = [\"L\", \"O\", \"N\", \"K\", \"E\", \"D\", \"S\", \"P\", \"G\", \"B\", \"I\", \"Y\"]\n+    else:\n+        font_size = 500\n+        text = [\n+            \"whero\", \"k\u0101k\u0101riki\", \"kiwikiwi\", \"karaka\",\n+            \"k\u014dwhai\", \"pango\", \"m\u0101whero\", \"m\u0101\"\n         ]\n \n     font = ImageFont.truetype(font_path, font_size)\n@@ -129,6 +128,9 @@\n         All valid options (dict).\n     \"\"\"\n     return {\n-        \"type\": [\"small_numbers\", \"large_numbers\", \"fractions\", \"maori_numbers\"],\n+        \"type\": [\n+            \"small_numbers\", \"large_numbers\", \"fractions\", \"maori_numbers\",\n+            \"words\", \"letters\", \"maori_colours\"\n+        ],\n         \"paper_size\": [\"a4\", \"letter\"],\n     }\n", "issue": "Add sorting networks lessons\n- [ ] Lesson 2 (8-10) - needs generated resources\r\n- [ ] Lesson 1 (11-14)\r\n- [ ] Lesson 2 (11-14)\n", "before_files": [{"content": "\"\"\"Module for generating Sorting Network Cards resource.\"\"\"\n\nfrom random import sample\nfrom PIL import Image, ImageDraw, ImageFont\nfrom utils.retrieve_query_parameter import retrieve_query_parameter\n\n\ndef resource_image(request, resource):\n    \"\"\"Create a image for Sorting Network Cards resource.\n\n    Args:\n        request: HTTP request object.\n        resource: Object of resource data.\n\n    Returns:\n        A list of Pillow image objects.\n    \"\"\"\n    IMAGE_SIZE_X = 2000\n    IMAGE_SIZE_Y = 3000\n    LINE_COLOUR = \"#000000\"\n    LINE_WIDTH = 3\n    font_path = \"static/fonts/PatrickHand-Regular.ttf\"\n\n    # Retrieve parameters\n    parameter_options = valid_options()\n    card_type = retrieve_query_parameter(request, \"type\", parameter_options[\"type\"])\n\n    # Create card outlines\n    card_outlines = Image.new(\"RGB\", (IMAGE_SIZE_X, IMAGE_SIZE_Y), \"#fff\")\n    draw = ImageDraw.Draw(card_outlines)\n    for x_coord in range(0, IMAGE_SIZE_X, IMAGE_SIZE_X - LINE_WIDTH):\n        draw.line([(x_coord, 0), (x_coord, IMAGE_SIZE_Y)], fill=LINE_COLOUR, width=LINE_WIDTH)\n    for y_coord in range(0, IMAGE_SIZE_Y, int(IMAGE_SIZE_Y / 2 - LINE_WIDTH)):\n        draw.line([(0, y_coord), (IMAGE_SIZE_X, y_coord)], fill=LINE_COLOUR, width=LINE_WIDTH)\n\n    # Prepare text data\n    if card_type == \"small_numbers\":\n        font_size = 800\n        text = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\"]\n    elif card_type == \"large_numbers\":\n        font_size = 500\n        text = []\n        numbers = sample(range(1700000, 2100000), 6)\n        for number in numbers:\n            text.append(\"{:,}\".format(number))\n    elif card_type == \"fractions\":\n        font_size = 900\n        font_path = \"static/fonts/NotoSans-Regular.ttf\"\n        text = [u\"\\u00bd\", u\"\\u2153\", u\"\\u2154\", u\"\\u215c\", u\"\\u00be\", u\"\\u215d\"]\n    else:\n        font_size = 300\n        text = [\n            \"tahi\",\n            \"rua\",\n            \"toru\",\n            \"wh\u0101\",\n            \"rima\",\n            \"ono\",\n            \"whitu\",\n            \"waru\",\n            \"iwa\",\n            \"tekau\",\n            \"tekau m\u0101 tahi\",\n            \"tekau m\u0101 waru\",\n            \"tekau m\u0101 toru\",\n            \"tekau m\u0101 wh\u0101\",\n            \"rua tekau\",\n            \"rua tekau m\u0101 ono\",\n        ]\n\n    font = ImageFont.truetype(font_path, font_size)\n    card_centers = [\n        (IMAGE_SIZE_X / 2, IMAGE_SIZE_Y / 4),\n        (IMAGE_SIZE_X / 2, (IMAGE_SIZE_Y / 4) * 3),\n    ]\n\n    # Add text to cards\n    images = []\n    for (text_number, text_string) in enumerate(text):\n        if text_number % 2 == 0:\n            page = card_outlines.copy()\n            draw = ImageDraw.Draw(page)\n            (x, y) = card_centers[0]\n        else:\n            (x, y) = card_centers[1]\n\n        text_width, text_height = draw.textsize(text_string, font=font)\n        coord_x = x - (text_width / 2)\n        coord_y = y - (text_height / 1.5)\n        draw.text(\n            (coord_x, coord_y),\n            text_string,\n            font=font,\n            fill=\"#000\"\n        )\n        # If text on second card but not last page\n        if text_number % 2 == 1 and text_number != len(text) - 1:\n            images.append(page)\n    images.append(page)\n\n    return images\n\n\ndef subtitle(request, resource):\n    \"\"\"Return the subtitle string of the resource.\n\n    Used after the resource name in the filename, and\n    also on the resource image.\n\n    Args:\n        request: HTTP request object\n        resource: Object of resource data.\n\n    Returns:\n        text for subtitle (string)\n    \"\"\"\n    return \"{} - {}\".format(\n        retrieve_query_parameter(request, \"type\").replace(\"_\", \" \"),\n        retrieve_query_parameter(request, \"paper_size\")\n    )\n\n\ndef valid_options():\n    \"\"\"Provide dictionary of all valid parameters.\n\n    This excludes the header text parameter.\n\n    Returns:\n        All valid options (dict).\n    \"\"\"\n    return {\n        \"type\": [\"small_numbers\", \"large_numbers\", \"fractions\", \"maori_numbers\"],\n        \"paper_size\": [\"a4\", \"letter\"],\n    }\n", "path": "csunplugged/resources/views/sorting_network_cards.py"}], "after_files": [{"content": "\"\"\"Module for generating Sorting Network Cards resource.\"\"\"\n\nfrom random import sample\nfrom PIL import Image, ImageDraw, ImageFont\nfrom utils.retrieve_query_parameter import retrieve_query_parameter\n\n\ndef resource_image(request, resource):\n    \"\"\"Create a image for Sorting Network Cards resource.\n\n    Args:\n        request: HTTP request object.\n        resource: Object of resource data.\n\n    Returns:\n        A list of Pillow image objects.\n    \"\"\"\n    IMAGE_SIZE_X = 2000\n    IMAGE_SIZE_Y = 3000\n    LINE_COLOUR = \"#000000\"\n    LINE_WIDTH = 3\n    font_path = \"static/fonts/PatrickHand-Regular.ttf\"\n\n    # Retrieve parameters\n    parameter_options = valid_options()\n    card_type = retrieve_query_parameter(request, \"type\", parameter_options[\"type\"])\n\n    # Create card outlines\n    card_outlines = Image.new(\"RGB\", (IMAGE_SIZE_X, IMAGE_SIZE_Y), \"#fff\")\n    draw = ImageDraw.Draw(card_outlines)\n    for x_coord in range(0, IMAGE_SIZE_X, IMAGE_SIZE_X - LINE_WIDTH):\n        draw.line([(x_coord, 0), (x_coord, IMAGE_SIZE_Y)], fill=LINE_COLOUR, width=LINE_WIDTH)\n    for y_coord in range(0, IMAGE_SIZE_Y, int(IMAGE_SIZE_Y / 2 - LINE_WIDTH)):\n        draw.line([(0, y_coord), (IMAGE_SIZE_X, y_coord)], fill=LINE_COLOUR, width=LINE_WIDTH)\n\n    # Prepare text data\n    if card_type == \"small_numbers\":\n        font_size = 800\n        text = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\"]\n    elif card_type == \"large_numbers\":\n        font_size = 500\n        text = []\n        numbers = sample(range(1700000, 2100000), 6)\n        for number in numbers:\n            text.append(\"{:,}\".format(number))\n    elif card_type == \"fractions\":\n        font_size = 900\n        font_path = \"static/fonts/NotoSans-Regular.ttf\"\n        text = [u\"\\u00bd\", u\"\\u2153\", u\"\\u2154\", u\"\\u215c\", u\"\\u00be\", u\"\\u215d\"]\n    elif card_type == \"maori_numbers\":\n        font_size = 300\n        text = [\n            \"tahi\", \"rua\", \"toru\", \"wh\u0101\", \"rima\", \"ono\", \"whitu\", \"waru\",\n            \"iwa\", \"tekau\", \"tekau m\u0101 tahi\", \"tekau m\u0101 waru\", \"tekau m\u0101 toru\",\n            \"tekau m\u0101 wh\u0101\", \"rua tekau\", \"rua tekau m\u0101 ono\"\n        ]\n    elif card_type == \"words\":\n        font_size = 500\n        text = [\"crocodile\", \"crochet\", \"kiwi\", \"weka\", \"kiwi\", \"kiwano\"]\n    elif card_type == \"letters\":\n        font_size = 800\n        text = [\"L\", \"O\", \"N\", \"K\", \"E\", \"D\", \"S\", \"P\", \"G\", \"B\", \"I\", \"Y\"]\n    else:\n        font_size = 500\n        text = [\n            \"whero\", \"k\u0101k\u0101riki\", \"kiwikiwi\", \"karaka\",\n            \"k\u014dwhai\", \"pango\", \"m\u0101whero\", \"m\u0101\"\n        ]\n\n    font = ImageFont.truetype(font_path, font_size)\n    card_centers = [\n        (IMAGE_SIZE_X / 2, IMAGE_SIZE_Y / 4),\n        (IMAGE_SIZE_X / 2, (IMAGE_SIZE_Y / 4) * 3),\n    ]\n\n    # Add text to cards\n    images = []\n    for (text_number, text_string) in enumerate(text):\n        if text_number % 2 == 0:\n            page = card_outlines.copy()\n            draw = ImageDraw.Draw(page)\n            (x, y) = card_centers[0]\n        else:\n            (x, y) = card_centers[1]\n\n        text_width, text_height = draw.textsize(text_string, font=font)\n        coord_x = x - (text_width / 2)\n        coord_y = y - (text_height / 1.5)\n        draw.text(\n            (coord_x, coord_y),\n            text_string,\n            font=font,\n            fill=\"#000\"\n        )\n        # If text on second card but not last page\n        if text_number % 2 == 1 and text_number != len(text) - 1:\n            images.append(page)\n    images.append(page)\n\n    return images\n\n\ndef subtitle(request, resource):\n    \"\"\"Return the subtitle string of the resource.\n\n    Used after the resource name in the filename, and\n    also on the resource image.\n\n    Args:\n        request: HTTP request object\n        resource: Object of resource data.\n\n    Returns:\n        text for subtitle (string)\n    \"\"\"\n    return \"{} - {}\".format(\n        retrieve_query_parameter(request, \"type\").replace(\"_\", \" \"),\n        retrieve_query_parameter(request, \"paper_size\")\n    )\n\n\ndef valid_options():\n    \"\"\"Provide dictionary of all valid parameters.\n\n    This excludes the header text parameter.\n\n    Returns:\n        All valid options (dict).\n    \"\"\"\n    return {\n        \"type\": [\n            \"small_numbers\", \"large_numbers\", \"fractions\", \"maori_numbers\",\n            \"words\", \"letters\", \"maori_colours\"\n        ],\n        \"paper_size\": [\"a4\", \"letter\"],\n    }\n", "path": "csunplugged/resources/views/sorting_network_cards.py"}]}