     (.draggable $divElem
                 (js-obj "zIndex" 100
                         "helper" "clone"
-                        ; TODO: Replace this `revert` function with one
-                        ;       which detects whether a revert should
-                        ;       occur
-                        "revert" (fn [] true)
+                        "revert" "invalid"
                         "start"  (lesson-draggable-start-evt-handler-maker
                                    moduleCode lessonType lessonLabel
                                    bgColorCssClass)
-                        "stop"   (lesson-draggable-stop-evt-handler-maker)))))
+                        "stop"   (lesson-draggable-stop-evt-handler-maker
+                                   moduleCode lessonType lessonLabel
+                                   bgColorCssClass)))))
 
 (defn- make-fake-lessons-droppable
   "For 'fake' lessons created due to a lesson <div> being dragged, we make
    them droppable in order for the user to switch lesson groups."
-  [$divElemSeq]
-  (doseq [$divElem $divElemSeq]
-    (.droppable $divElem
-                (js-obj "tolerance" "intersect"
-
-                        "over"
-                        (fn [evt ui]
-                          (.removeClass $divElem "lesson-droppable-not-hover")
-                          (.addClass $divElem "lesson-droppable-hover"))
-
-                        "out"
-                        (fn [evt ui]
-                          (.removeClass $divElem "lesson-droppable-hover")
-                          (.addClass $divElem "lesson-droppable-not-hover"))))))
+  [augModuleSelectedLessonInfoSeq]
+  (doseq [augModuleSelectedLessonInfo augModuleSelectedLessonInfoSeq]
+    (let [$divElem (:divElem augModuleSelectedLessonInfo)]
+      (.droppable
+        $divElem
+        (js-obj "tolerance" "intersect"
+
+                "over"
+                (fn [evt ui]
+                  (.removeClass $divElem "lesson-droppable-not-hover")
+                  (.addClass $divElem "lesson-droppable-hover"))
+
+                "out"
+                (fn [evt ui]
+                  (.removeClass $divElem "lesson-droppable-hover")
+                  (.addClass $divElem "lesson-droppable-not-hover"))
+
+                "drop"
+                (fn [evt ui]
+                  (let [$helper (aget ui "helper")]
+                    ; Set a data attribute on the draggable helper to signal
+                    ; that the user has dropped the <div> on a droppable to
+                    ; change the lesson group
+                    (data $helper
+                          LESSON-GROUP-CHANGE-KEY
+                          (:lessonGroup augModuleSelectedLessonInfo)))))))))
 
 (defn- add-module-lesson-group
   "Adds a lesson group of a module to the timetable.

(ns ^{:doc "Code for Timetable Builder page"}
  cljs-nusmods.timetable
  (:use [jayq.core :only [$ attr before children hide insert-after is parent
                          prepend prevent remove-attr show text width]])
  (:require [clojure.set]
            [clojure.string]
            [cljs-nusmods.select2 :as select2]

    (aset (aget js/document "location") "hash"
          (clojure.string/replace urlHashWithoutModule #"&$" ""))))

(defn- update-document-location-hash-with-changed-lesson-group
  "Updates a module's lesson type in `document.location.hash` with a changed
   changed lesson group."
  [moduleCode lessonTypeLongForm newLessonGroup]
  (let [orgUrlHash (aget (aget js/document "location") "hash")
        lessonType (Lesson-Type-Long-To-Short-Form lessonTypeLongForm)
        newUrlHash (clojure.string/replace
                     orgUrlHash
                     (re-pattern (str moduleCode "_" lessonType "=[^&]+"))
                     (str moduleCode "_" lessonType "=" newLessonGroup))]
    (aset (aget js/document "location") "hash"
          newUrlHash)))

(def ^{:doc "Vector of <tBody> objects representing the days of the timetable
             in the Timetable Builder page"
       :private true
