                                        lessonLabel])]
     (if (and moduleName lessons)
         (let [lessonInfoSeq (doall
-                              (map (fn [lesson]
+                              (map (fn [[lessonIdx lesson]]
                                      (add-module-lesson moduleCode
                                                         moduleName
                                                         lessonType
                                                         lessonLabel
                                                         lesson
+                                                        lessonIdx
                                                         bgColorCssClass))
-                                   lessons))]
+                                   (map vector
+                                        (range 0 (count lessons)) lessons)))]
           ; Update ModulesSelected with the lesson group
           (set! ModulesSelected
                 (assoc-in ModulesSelected [moduleCode lessonType]

            (zero? (:nrLessonGroups row))
            (assoc result :foundFreeRow true)

            (not (some true?
                       (map (fn [timeIdx] (nth (:occupied row) timeIdx))
                            (range startTime endTime))))
            (assoc result :foundFreeRow true)

(defn- add-module-lesson
  "Adds a single lesson of a module (obtained from the `ModulesMap` global) to
   the timetable, and returns its jQuery div element."
  [moduleCode moduleName lessonType lessonLabel lesson lessonIdx
   bgColorCssClass]
  (let [rowNum      (find-free-row-for-lesson lesson)
        day         (:day lesson)
        startTime   (:startTime lesson)
