   "Appends a module to `ModulesSelectedOrder`"
   [moduleCode]
   (set! ModulesSelectedOrder (conj ModulesSelectedOrder moduleCode)))
+
+(defn- select2-box-update-modules
+  "Update the select2 box with the currently selected modules"
+  []
+  (select2/select2-box-set-val select2/$Select2-Box
+                               (get-selected-module-codes-as-js-array)))
 
 (def ^{:doc     "Converts a short form lesson type string to its long form"
        :private true}

                    ; Update select2 box.
                    ; NOTE: This does a quadratic amount of work but I do not
                    ;       have a workaround.
                    (select2/select2-box-set-val
                      select2/$Select2-Box
                      (get-selected-module-codes-as-js-array))))

              ; Only lesson types with more than 1 option of lesson group
              ; will be draggable

  (timetable-create!)
  (set! ModulesSelected {})
  (set! ModulesSelectedOrder [])
  (select2-box-update-modules)
  (set-document-location-hash! ""))
