prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  AMP Doesn't Return STUDENT_TYPE
  I am an idiot.
  
  https://github.com/uclapi/uclapi/blob/69f0d3240d8ec6cf2a3b018897dc247aa58cb1bf/backend/uclapi/timetable/amp.py#L31
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `backend/uclapi/timetable/amp.py`
  Content:
  ```
  1 """
  2 UCL Academic Modelling Project
  3 Fast Code Processing
  4 """
  5 
  6 STUDENT_TYPES = {
  7     'A': "Campus-based, numeric mark scheme",
  8     'B': "Campus-based, non-numeric mark scheme",
  9     'C': "Distance learner, numeric mark scheme",
  10     'D': "Distance learner, non-numeric mark scheme",
  11     'E': "MBBS Resit"
  12 }
  13 
  14 
  15 class InvalidAMPCodeException(Exception):
  16     pass
  17 
  18 
  19 class ModuleDelivery:
  20     def __init__(self, delivery_code):
  21         # Sanity check the code we have
  22         if len(delivery_code) != 3:
  23             raise InvalidAMPCodeException("Delivery code is too long")
  24         if delivery_code[0] in STUDENT_TYPES:
  25             self.student_type = STUDENT_TYPES[delivery_code[0]]
  26         else:
  27             raise InvalidAMPCodeException("Student type is not valid")
  28         self.fheq_level = int(delivery_code[1])
  29         self.undergraduate = delivery_code[2] == 'U'
  30 
  31     def get_delivery(self):
  32         return {
  33             "fheq_level": self.fheq_level,
  34             "is_undergraduate": self.undergraduate
  35         }
  36 
  37 
  38 class ModulePeriods:
  39     # Default Attributes
  40     term_1 = False
  41     term_2 = False
  42     term_3 = False
  43     term_4 = False  # Term 1 of the next academic year
  44     summer = False  # Summer Teaching Period
  45     summer_school = False  # UCL Summer School
  46     summer_school_1 = False  # UCL Summer School Session 1
  47     summer_school_2 = False  # UCL Summer School Session 2
  48     lsr = False  # Late Summer Resit period
  49     year = False  # Whole year module
  50 
  51     def __init__(self, periods_code):
  52         if periods_code == 'YEAR':
  53             self.term_1 = True
  54             self.term_2 = True
  55             self.term_3 = True
  56             self.year = True
  57         elif periods_code == 'SUMMER':
  58             self.summer = True
  59         elif periods_code == 'LSR':
  60             self.lsr = True
  61         elif periods_code[0] == 'S':
  62             # Summer School periods start with an S.
  63             # S1, S2, S1+2
  64             self.summer_school = True
  65             if periods_code == 'S1':
  66                 self.summer_school_1 = True
  67             elif periods_code == 'S2':
  68                 self.summer_school_2 = True
  69             elif periods_code == 'S1+2':
  70                 self.summer_school_1 = True
  71                 self.summer_school_2 = True
  72             else:
  73                 raise InvalidAMPCodeException(
  74                     "An invalid AMP code was found: " + periods_code
  75                 )
  76         elif periods_code[0] == 'T':
  77             # Normal classes start with a T for Term
  78             if periods_code == 'T1':
  79                 self.term_1 = True
  80             elif periods_code == 'T1/2':
  81                 self.term_1 = True
  82                 self.term_2 = True
  83             elif periods_code == 'T1/2/3':
  84                 self.term_1 = True
  85                 self.term_2 = True
  86                 self.term_3 = True
  87             elif periods_code == 'T1/3':
  88                 self.term_1 = True
  89                 self.term_3 = True
  90             elif periods_code == 'T2':
  91                 self.term_2 = True
  92             elif periods_code == 'T2/3':
  93                 self.term_2 = True
  94                 self.term_3 = True
  95             elif periods_code == 'T2/3/S' or periods_code == 'T2/3/4':
  96                 self.term_2 = True
  97                 self.term_3 = True
  98                 self.summer = True
  99             elif periods_code == 'T3':
  100                 self.term_3 = True
  101             elif periods_code == 'T3/1':
  102                 self.term_3 = True
  103                 self.term_4 = True
  104             elif periods_code == 'T3/S' or periods_code == 'T3/4':
  105                 self.term_3 = True
  106                 self.summer = True
  107             elif periods_code == 'T4':
  108                 self.term_4 = True
  109             else:
  110                 raise InvalidAMPCodeException(
  111                     "AMP Periods Code contained an invalid term element"
  112                 )
  113         else:
  114             raise InvalidAMPCodeException(
  115                 "An invalid AMP code was found: " + periods_code
  116             )
  117 
  118     def get_periods(self):
  119         return {
  120             "teaching_periods": {
  121                 "term_1": self.term_1,
  122                 "term_2": self.term_2,
  123                 "term_3": self.term_3,
  124                 "term_1_next_year": self.term_4,
  125                 "summer": self.summer
  126             },
  127             "year_long": self.year,
  128             "lsr": self.lsr,
  129             "summer_school": {
  130                 "is_summer_school": self.summer_school,
  131                 "sessions": {
  132                     "session_1": self.summer_school_1,
  133                     "session_2": self.summer_school_2
  134                 }
  135             }
  136         }
  137 
  138 
  139 class ModuleInstance:
  140     def __init__(self, amp_code):
  141         """
  142         An AMP Code is stored as the INSTID in CMIS.
  143         It looks something like this: A6U-T1/2
  144         """
  145         parts = amp_code.split('-')
  146         module_delivery_code = parts[0]  # A6U
  147         periods_code = parts[1]  # T1/2
  148 
  149         self.delivery = ModuleDelivery(module_delivery_code)
  150         self.periods = ModulePeriods(periods_code)
  151
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/backend/uclapi/timetable/amp.py b/backend/uclapi/timetable/amp.py
  --- a/backend/uclapi/timetable/amp.py
  +++ b/backend/uclapi/timetable/amp.py
  @@ -31,7 +31,8 @@
       def get_delivery(self):
           return {
               "fheq_level": self.fheq_level,
  -            "is_undergraduate": self.undergraduate
  +            "is_undergraduate": self.undergraduate,
  +            "student_type": self.student_type
           }
  
verification_info: {"golden_diff": "diff --git a/backend/uclapi/timetable/amp.py b/backend/uclapi/timetable/amp.py\n--- a/backend/uclapi/timetable/amp.py\n+++ b/backend/uclapi/timetable/amp.py\n@@ -31,7 +31,8 @@\n     def get_delivery(self):\r\n         return {\r\n             \"fheq_level\": self.fheq_level,\r\n-            \"is_undergraduate\": self.undergraduate\r\n+            \"is_undergraduate\": self.undergraduate,\r\n+            \"student_type\": self.student_type\r\n         }\n", "issue": "AMP Doesn't Return STUDENT_TYPE\nI am an idiot.\r\n\r\nhttps://github.com/uclapi/uclapi/blob/69f0d3240d8ec6cf2a3b018897dc247aa58cb1bf/backend/uclapi/timetable/amp.py#L31\n", "before_files": [{"content": "\"\"\"\r\nUCL Academic Modelling Project\r\nFast Code Processing\r\n\"\"\"\r\n\r\nSTUDENT_TYPES = {\r\n    'A': \"Campus-based, numeric mark scheme\",\r\n    'B': \"Campus-based, non-numeric mark scheme\",\r\n    'C': \"Distance learner, numeric mark scheme\",\r\n    'D': \"Distance learner, non-numeric mark scheme\",\r\n    'E': \"MBBS Resit\"\r\n}\r\n\r\n\r\nclass InvalidAMPCodeException(Exception):\r\n    pass\r\n\r\n\r\nclass ModuleDelivery:\r\n    def __init__(self, delivery_code):\r\n        # Sanity check the code we have\r\n        if len(delivery_code) != 3:\r\n            raise InvalidAMPCodeException(\"Delivery code is too long\")\r\n        if delivery_code[0] in STUDENT_TYPES:\r\n            self.student_type = STUDENT_TYPES[delivery_code[0]]\r\n        else:\r\n            raise InvalidAMPCodeException(\"Student type is not valid\")\r\n        self.fheq_level = int(delivery_code[1])\r\n        self.undergraduate = delivery_code[2] == 'U'\r\n\r\n    def get_delivery(self):\r\n        return {\r\n            \"fheq_level\": self.fheq_level,\r\n            \"is_undergraduate\": self.undergraduate\r\n        }\r\n\r\n\r\nclass ModulePeriods:\r\n    # Default Attributes\r\n    term_1 = False\r\n    term_2 = False\r\n    term_3 = False\r\n    term_4 = False  # Term 1 of the next academic year\r\n    summer = False  # Summer Teaching Period\r\n    summer_school = False  # UCL Summer School\r\n    summer_school_1 = False  # UCL Summer School Session 1\r\n    summer_school_2 = False  # UCL Summer School Session 2\r\n    lsr = False  # Late Summer Resit period\r\n    year = False  # Whole year module\r\n\r\n    def __init__(self, periods_code):\r\n        if periods_code == 'YEAR':\r\n            self.term_1 = True\r\n            self.term_2 = True\r\n            self.term_3 = True\r\n            self.year = True\r\n        elif periods_code == 'SUMMER':\r\n            self.summer = True\r\n        elif periods_code == 'LSR':\r\n            self.lsr = True\r\n        elif periods_code[0] == 'S':\r\n            # Summer School periods start with an S.\r\n            # S1, S2, S1+2\r\n            self.summer_school = True\r\n            if periods_code == 'S1':\r\n                self.summer_school_1 = True\r\n            elif periods_code == 'S2':\r\n                self.summer_school_2 = True\r\n            elif periods_code == 'S1+2':\r\n                self.summer_school_1 = True\r\n                self.summer_school_2 = True\r\n            else:\r\n                raise InvalidAMPCodeException(\r\n                    \"An invalid AMP code was found: \" + periods_code\r\n                )\r\n        elif periods_code[0] == 'T':\r\n            # Normal classes start with a T for Term\r\n            if periods_code == 'T1':\r\n                self.term_1 = True\r\n            elif periods_code == 'T1/2':\r\n                self.term_1 = True\r\n                self.term_2 = True\r\n            elif periods_code == 'T1/2/3':\r\n                self.term_1 = True\r\n                self.term_2 = True\r\n                self.term_3 = True\r\n            elif periods_code == 'T1/3':\r\n                self.term_1 = True\r\n                self.term_3 = True\r\n            elif periods_code == 'T2':\r\n                self.term_2 = True\r\n            elif periods_code == 'T2/3':\r\n                self.term_2 = True\r\n                self.term_3 = True\r\n            elif periods_code == 'T2/3/S' or periods_code == 'T2/3/4':\r\n                self.term_2 = True\r\n                self.term_3 = True\r\n                self.summer = True\r\n            elif periods_code == 'T3':\r\n                self.term_3 = True\r\n            elif periods_code == 'T3/1':\r\n                self.term_3 = True\r\n                self.term_4 = True\r\n            elif periods_code == 'T3/S' or periods_code == 'T3/4':\r\n                self.term_3 = True\r\n                self.summer = True\r\n            elif periods_code == 'T4':\r\n                self.term_4 = True\r\n            else:\r\n                raise InvalidAMPCodeException(\r\n                    \"AMP Periods Code contained an invalid term element\"\r\n                )\r\n        else:\r\n            raise InvalidAMPCodeException(\r\n                \"An invalid AMP code was found: \" + periods_code\r\n            )\r\n\r\n    def get_periods(self):\r\n        return {\r\n            \"teaching_periods\": {\r\n                \"term_1\": self.term_1,\r\n                \"term_2\": self.term_2,\r\n                \"term_3\": self.term_3,\r\n                \"term_1_next_year\": self.term_4,\r\n                \"summer\": self.summer\r\n            },\r\n            \"year_long\": self.year,\r\n            \"lsr\": self.lsr,\r\n            \"summer_school\": {\r\n                \"is_summer_school\": self.summer_school,\r\n                \"sessions\": {\r\n                    \"session_1\": self.summer_school_1,\r\n                    \"session_2\": self.summer_school_2\r\n                }\r\n            }\r\n        }\r\n\r\n\r\nclass ModuleInstance:\r\n    def __init__(self, amp_code):\r\n        \"\"\"\r\n        An AMP Code is stored as the INSTID in CMIS.\r\n        It looks something like this: A6U-T1/2\r\n        \"\"\"\r\n        parts = amp_code.split('-')\r\n        module_delivery_code = parts[0]  # A6U\r\n        periods_code = parts[1]  # T1/2\r\n\r\n        self.delivery = ModuleDelivery(module_delivery_code)\r\n        self.periods = ModulePeriods(periods_code)\r\n", "path": "backend/uclapi/timetable/amp.py"}], "after_files": [{"content": "\"\"\"\r\nUCL Academic Modelling Project\r\nFast Code Processing\r\n\"\"\"\r\n\r\nSTUDENT_TYPES = {\r\n    'A': \"Campus-based, numeric mark scheme\",\r\n    'B': \"Campus-based, non-numeric mark scheme\",\r\n    'C': \"Distance learner, numeric mark scheme\",\r\n    'D': \"Distance learner, non-numeric mark scheme\",\r\n    'E': \"MBBS Resit\"\r\n}\r\n\r\n\r\nclass InvalidAMPCodeException(Exception):\r\n    pass\r\n\r\n\r\nclass ModuleDelivery:\r\n    def __init__(self, delivery_code):\r\n        # Sanity check the code we have\r\n        if len(delivery_code) != 3:\r\n            raise InvalidAMPCodeException(\"Delivery code is too long\")\r\n        if delivery_code[0] in STUDENT_TYPES:\r\n            self.student_type = STUDENT_TYPES[delivery_code[0]]\r\n        else:\r\n            raise InvalidAMPCodeException(\"Student type is not valid\")\r\n        self.fheq_level = int(delivery_code[1])\r\n        self.undergraduate = delivery_code[2] == 'U'\r\n\r\n    def get_delivery(self):\r\n        return {\r\n            \"fheq_level\": self.fheq_level,\r\n            \"is_undergraduate\": self.undergraduate,\r\n            \"student_type\": self.student_type\r\n        }\r\n\r\n\r\nclass ModulePeriods:\r\n    # Default Attributes\r\n    term_1 = False\r\n    term_2 = False\r\n    term_3 = False\r\n    term_4 = False  # Term 1 of the next academic year\r\n    summer = False  # Summer Teaching Period\r\n    summer_school = False  # UCL Summer School\r\n    summer_school_1 = False  # UCL Summer School Session 1\r\n    summer_school_2 = False  # UCL Summer School Session 2\r\n    lsr = False  # Late Summer Resit period\r\n    year = False  # Whole year module\r\n\r\n    def __init__(self, periods_code):\r\n        if periods_code == 'YEAR':\r\n            self.term_1 = True\r\n            self.term_2 = True\r\n            self.term_3 = True\r\n            self.year = True\r\n        elif periods_code == 'SUMMER':\r\n            self.summer = True\r\n        elif periods_code == 'LSR':\r\n            self.lsr = True\r\n        elif periods_code[0] == 'S':\r\n            # Summer School periods start with an S.\r\n            # S1, S2, S1+2\r\n            self.summer_school = True\r\n            if periods_code == 'S1':\r\n                self.summer_school_1 = True\r\n            elif periods_code == 'S2':\r\n                self.summer_school_2 = True\r\n            elif periods_code == 'S1+2':\r\n                self.summer_school_1 = True\r\n                self.summer_school_2 = True\r\n            else:\r\n                raise InvalidAMPCodeException(\r\n                    \"An invalid AMP code was found: \" + periods_code\r\n                )\r\n        elif periods_code[0] == 'T':\r\n            # Normal classes start with a T for Term\r\n            if periods_code == 'T1':\r\n                self.term_1 = True\r\n            elif periods_code == 'T1/2':\r\n                self.term_1 = True\r\n                self.term_2 = True\r\n            elif periods_code == 'T1/2/3':\r\n                self.term_1 = True\r\n                self.term_2 = True\r\n                self.term_3 = True\r\n            elif periods_code == 'T1/3':\r\n                self.term_1 = True\r\n                self.term_3 = True\r\n            elif periods_code == 'T2':\r\n                self.term_2 = True\r\n            elif periods_code == 'T2/3':\r\n                self.term_2 = True\r\n                self.term_3 = True\r\n            elif periods_code == 'T2/3/S' or periods_code == 'T2/3/4':\r\n                self.term_2 = True\r\n                self.term_3 = True\r\n                self.summer = True\r\n            elif periods_code == 'T3':\r\n                self.term_3 = True\r\n            elif periods_code == 'T3/1':\r\n                self.term_3 = True\r\n                self.term_4 = True\r\n            elif periods_code == 'T3/S' or periods_code == 'T3/4':\r\n                self.term_3 = True\r\n                self.summer = True\r\n            elif periods_code == 'T4':\r\n                self.term_4 = True\r\n            else:\r\n                raise InvalidAMPCodeException(\r\n                    \"AMP Periods Code contained an invalid term element\"\r\n                )\r\n        else:\r\n            raise InvalidAMPCodeException(\r\n                \"An invalid AMP code was found: \" + periods_code\r\n            )\r\n\r\n    def get_periods(self):\r\n        return {\r\n            \"teaching_periods\": {\r\n                \"term_1\": self.term_1,\r\n                \"term_2\": self.term_2,\r\n                \"term_3\": self.term_3,\r\n                \"term_1_next_year\": self.term_4,\r\n                \"summer\": self.summer\r\n            },\r\n            \"year_long\": self.year,\r\n            \"lsr\": self.lsr,\r\n            \"summer_school\": {\r\n                \"is_summer_school\": self.summer_school,\r\n                \"sessions\": {\r\n                    \"session_1\": self.summer_school_1,\r\n                    \"session_2\": self.summer_school_2\r\n                }\r\n            }\r\n        }\r\n\r\n\r\nclass ModuleInstance:\r\n    def __init__(self, amp_code):\r\n        \"\"\"\r\n        An AMP Code is stored as the INSTID in CMIS.\r\n        It looks something like this: A6U-T1/2\r\n        \"\"\"\r\n        parts = amp_code.split('-')\r\n        module_delivery_code = parts[0]  # A6U\r\n        periods_code = parts[1]  # T1/2\r\n\r\n        self.delivery = ModuleDelivery(module_delivery_code)\r\n        self.periods = ModulePeriods(periods_code)\r\n", "path": "backend/uclapi/timetable/amp.py"}]}