prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Include button to go back to previous level
  Thanks for the great project! While trying the website I wished I could go back one level, but there is only a button to go to the next level.
  
  </issue>
  <code>
  [start of hedyweb.py]
  1 import collections
  2 import attr
  3 import glob
  4 from os import path
  5 
  6 from flask import jsonify, render_template, abort, redirect
  7 import courses
  8 from auth import current_user
  9 
  10 class Translations:
  11   def __init__(self):
  12     self.data = {}
  13     translations = glob.glob('coursedata/texts/*.yaml')
  14     for trans_file in translations:
  15       lang = path.splitext(path.basename(trans_file))[0]
  16       self.data[lang] = courses.load_yaml(trans_file)
  17 
  18   def get_translations(self, language, section):
  19     # Merge with English when lacking translations
  20     # Start from a defaultdict
  21     d = collections.defaultdict(lambda: '???')
  22     d.update(**self.data.get('en', {}).get(section, {}))
  23     d.update(**self.data.get(language, {}).get(section, {}))
  24     return d
  25 
  26 
  27 def render_assignment_editor(request, course, level_number, assignment_number, menu, translations, version, loaded_program):
  28   assignment = course.get_assignment(level_number, assignment_number)
  29   if not assignment:
  30     abort(404)
  31 
  32   arguments_dict = {}
  33 
  34   # Meta stuff
  35   arguments_dict['course'] = course
  36   arguments_dict['level_nr'] = str(level_number)
  37   arguments_dict['assignment_nr'] = assignment.step  # Give this a chance to be 'None'
  38   arguments_dict['lang'] = course.language
  39   arguments_dict['level'] = assignment.level
  40   arguments_dict['next_level'] = int(level_number) + 1 if int(level_number) < course.max_level() else None
  41   arguments_dict['next_assignment'] = int(assignment_number) + 1 if int(assignment_number) < course.max_step(level_number) else None
  42   arguments_dict['menu'] = menu
  43   arguments_dict['latest'] = version
  44   arguments_dict['selected_page'] = 'code'
  45   arguments_dict['page_title'] = f'Level {level_number} – Hedy'
  46   arguments_dict['docs'] = [attr.asdict(d) for d in assignment.docs]
  47   arguments_dict['auth'] = translations.data [course.language] ['Auth']
  48   arguments_dict['username'] = current_user(request) ['username']
  49   arguments_dict['loaded_program'] = loaded_program or ''
  50 
  51   # Translations
  52   arguments_dict.update(**translations.get_translations(course.language, 'ui'))
  53 
  54   # Actual assignment
  55   arguments_dict.update(**attr.asdict(assignment))
  56 
  57   return render_template("code-page.html", **arguments_dict)
  58 
  59 
  60 def render_assignment_docs(doc_type, course, level_number, assignment_number, menu, translations):
  61   assignment = course.get_assignment(level_number, assignment_number)
  62   if not assignment:
  63     abort(404)
  64 
  65   arguments_dict = {}
  66 
  67   # Meta stuff
  68   arguments_dict['course'] = course
  69   arguments_dict['level_nr'] = str(level_number)
  70   arguments_dict['assignment_nr'] = assignment.step  # Give this a chance to be 'None'
  71   arguments_dict['pagetitle'] = f'Level {level_number} - Hedy'
  72   arguments_dict['lang'] = course.language
  73   arguments_dict['selected_page'] = doc_type
  74   arguments_dict['docs'] = [attr.asdict(d) for d in assignment.docs]
  75   arguments_dict['auth'] = translations.data [course.language] ['Auth']
  76 
  77   # Translations
  78   arguments_dict.update(**translations.get_translations(course.language, 'ui'))
  79 
  80   doc = course.docs.get(int(level_number), doc_type)
  81   if not doc:
  82     # Redirect to code page. Nasty 'import' here to work around
  83     # cyclic imports.
  84     import app
  85     return redirect(app.hedy_link(level_number, assignment_number))
  86 
  87   arguments_dict['mkd'] = doc.markdown
  88   arguments_dict['menu'] = menu
  89   arguments_dict['page_title'] = f'Level {level_number}.{assignment_number} – ' + doc.front_matter.get('title', '') + ' – Hedy'
  90 
  91   return render_template("per-level-text.html", **arguments_dict)
  92
  [end of hedyweb.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/hedyweb.py b/hedyweb.py
  --- a/hedyweb.py
  +++ b/hedyweb.py
  @@ -37,6 +37,7 @@
     arguments_dict['assignment_nr'] = assignment.step  # Give this a chance to be 'None'
     arguments_dict['lang'] = course.language
     arguments_dict['level'] = assignment.level
  +  arguments_dict['prev_level'] = int(level_number) - 1 if int(level_number) > 1 else None
     arguments_dict['next_level'] = int(level_number) + 1 if int(level_number) < course.max_level() else None
     arguments_dict['next_assignment'] = int(assignment_number) + 1 if int(assignment_number) < course.max_step(level_number) else None
     arguments_dict['menu'] = menu
  
verification_info: {"golden_diff": "diff --git a/hedyweb.py b/hedyweb.py\n--- a/hedyweb.py\n+++ b/hedyweb.py\n@@ -37,6 +37,7 @@\n   arguments_dict['assignment_nr'] = assignment.step  # Give this a chance to be 'None'\n   arguments_dict['lang'] = course.language\n   arguments_dict['level'] = assignment.level\n+  arguments_dict['prev_level'] = int(level_number) - 1 if int(level_number) > 1 else None\n   arguments_dict['next_level'] = int(level_number) + 1 if int(level_number) < course.max_level() else None\n   arguments_dict['next_assignment'] = int(assignment_number) + 1 if int(assignment_number) < course.max_step(level_number) else None\n   arguments_dict['menu'] = menu\n", "issue": "Include button to go back to previous level\nThanks for the great project! While trying the website I wished I could go back one level, but there is only a button to go to the next level.\n", "before_files": [{"content": "import collections\nimport attr\nimport glob\nfrom os import path\n\nfrom flask import jsonify, render_template, abort, redirect\nimport courses\nfrom auth import current_user\n\nclass Translations:\n  def __init__(self):\n    self.data = {}\n    translations = glob.glob('coursedata/texts/*.yaml')\n    for trans_file in translations:\n      lang = path.splitext(path.basename(trans_file))[0]\n      self.data[lang] = courses.load_yaml(trans_file)\n\n  def get_translations(self, language, section):\n    # Merge with English when lacking translations\n    # Start from a defaultdict\n    d = collections.defaultdict(lambda: '???')\n    d.update(**self.data.get('en', {}).get(section, {}))\n    d.update(**self.data.get(language, {}).get(section, {}))\n    return d\n\n\ndef render_assignment_editor(request, course, level_number, assignment_number, menu, translations, version, loaded_program):\n  assignment = course.get_assignment(level_number, assignment_number)\n  if not assignment:\n    abort(404)\n\n  arguments_dict = {}\n\n  # Meta stuff\n  arguments_dict['course'] = course\n  arguments_dict['level_nr'] = str(level_number)\n  arguments_dict['assignment_nr'] = assignment.step  # Give this a chance to be 'None'\n  arguments_dict['lang'] = course.language\n  arguments_dict['level'] = assignment.level\n  arguments_dict['next_level'] = int(level_number) + 1 if int(level_number) < course.max_level() else None\n  arguments_dict['next_assignment'] = int(assignment_number) + 1 if int(assignment_number) < course.max_step(level_number) else None\n  arguments_dict['menu'] = menu\n  arguments_dict['latest'] = version\n  arguments_dict['selected_page'] = 'code'\n  arguments_dict['page_title'] = f'Level {level_number} \u2013 Hedy'\n  arguments_dict['docs'] = [attr.asdict(d) for d in assignment.docs]\n  arguments_dict['auth'] = translations.data [course.language] ['Auth']\n  arguments_dict['username'] = current_user(request) ['username']\n  arguments_dict['loaded_program'] = loaded_program or ''\n\n  # Translations\n  arguments_dict.update(**translations.get_translations(course.language, 'ui'))\n\n  # Actual assignment\n  arguments_dict.update(**attr.asdict(assignment))\n\n  return render_template(\"code-page.html\", **arguments_dict)\n\n\ndef render_assignment_docs(doc_type, course, level_number, assignment_number, menu, translations):\n  assignment = course.get_assignment(level_number, assignment_number)\n  if not assignment:\n    abort(404)\n\n  arguments_dict = {}\n\n  # Meta stuff\n  arguments_dict['course'] = course\n  arguments_dict['level_nr'] = str(level_number)\n  arguments_dict['assignment_nr'] = assignment.step  # Give this a chance to be 'None'\n  arguments_dict['pagetitle'] = f'Level {level_number} - Hedy'\n  arguments_dict['lang'] = course.language\n  arguments_dict['selected_page'] = doc_type\n  arguments_dict['docs'] = [attr.asdict(d) for d in assignment.docs]\n  arguments_dict['auth'] = translations.data [course.language] ['Auth']\n\n  # Translations\n  arguments_dict.update(**translations.get_translations(course.language, 'ui'))\n\n  doc = course.docs.get(int(level_number), doc_type)\n  if not doc:\n    # Redirect to code page. Nasty 'import' here to work around\n    # cyclic imports.\n    import app\n    return redirect(app.hedy_link(level_number, assignment_number))\n\n  arguments_dict['mkd'] = doc.markdown\n  arguments_dict['menu'] = menu\n  arguments_dict['page_title'] = f'Level {level_number}.{assignment_number} \u2013 ' + doc.front_matter.get('title', '') + ' \u2013 Hedy'\n\n  return render_template(\"per-level-text.html\", **arguments_dict)\n", "path": "hedyweb.py"}]}