 
 ; Forward declaration
 (declare add-module-lesson-group)
+(declare timetable-prune-empty-rows)
+(declare add-missing-td-elements-replacing-lesson)
 
 (defn- lesson-draggable-start-evt-handler-maker
   "Returns a function that can be used as the `start` event handler for a

  "Returns a function used as the `stop` event handler for a draggable lesson."
  []
  (fn [evt ui]
    (let [$divElemSeq (map #(:divElem %1) Lessons-Created-By-Draggable)

          daysAndRowsAffected
          (reduce (fn [dayVec ttLessonInfo]
                    (update-in dayVec [(:day ttLessonInfo)]
                               (fn [rowSet]
                                 (conj rowSet (:rowNum ttLessonInfo)))))
                  [#{} #{} #{} #{} #{}]
                  Lessons-Created-By-Draggable)

          ; This should not be placed here.
          ; We should only remove such rows after we update the `Timetable`
          ; global
          emptyRowsToRemove
          (map (fn [[day rowSet]]
                 (let [ttDay (get-timetable-day day)]
                   [day,
                    (sort > (filter (fn [rowNum]
                                      (and (> rowNum 1)
                                           (zero? (count (nth ttDay rowNum)))))
                                    rowSet))]))
               (map vector (range (count daysAndRowsAffected))
                    daysAndRowsAffected))]
      (doseq [augTTLessonInfo Lessons-Created-By-Draggable]
        (timetable-remove-lesson (:day augTTLessonInfo)
                                 (:rowNum augTTLessonInfo)
                                 (dissoc augTTLessonInfo :divElem :day
                                         :rowNum)))
      (doseq [$divElem $divElemSeq]
        (.remove $divElem))
      (doseq [[day rowsToRemove]]
        (s)
        )
      )))

; TODO: Make lesson type with only a single lessongroup non-draggable
(defn- make-added-lessons-draggable

          ; Add all the <div> elements
          augmentedTTLessonInfoSeq
          (doall
            (flatten
              (map (fn [[lessonGroup _]]
                     (add-module-lesson-group moduleCode lessonType lessonGroup
                                              bgColorCssClass false))
                   unselectedLessonGroupsMap)))]
      (set! Lessons-Created-By-Draggable augmentedTTLessonInfoSeq))))

; TODO: Account for a user dropping the draggable lesson onto a different lesson
