Commits

Anonymous committed 855ed66

- At the end of a drill session, when re-presenting items that were failed
during the course of that session, we now avoid showing the same item
straight after itself (unless it is the only item left).

  • Participants
  • Parent commits d83d8da

Comments (0)

Files changed (1)

File org-drill.el

 ;;; org-drill.el - Self-testing using spaced repetition
 ;;;
 ;;; Author: Paul Sexton <eeeickythump@gmail.com>
-;;; Version: 2.1
+;;; Version: 2.1.1
 ;;; Repository at http://bitbucket.org/eeeickythump/org-drill/
 ;;;
 ;;;
                                 (subseq ,place (1+ ,idx)))))))))
 
 
+(defmacro push-end (val place)
+  "Add VAL to the end of the sequence stored in PLACE. Return the new
+value."
+  `(setq ,place (append ,place (list ,val))))
+
+
 (defun shuffle-list (list)
   "Randomly permute the elements of LIST (all permutations equally likely)."
   ;; Adapted from 'shuffle-vector' in cookie1.el
   (let ((n (expt 10 fix)))
     (/ (float (round (* floatnum n))) n)))
 
-
 (defun time-to-inactive-org-timestamp (time)
   (format-time-string
    (concat "[" (substring (cdr org-time-stamp-formats) 1 -1) "]")
                        (t -1))))
       (/ (+ 100 (* (* (/ -1 b) (log (- 1 (* (/ b a ) (abs p)))))
                    (sign p)))
-         100))))
+         100.0))))
 
 
 (defun org-drill-early-interval-factor (optimal-factor
           ;; After all the above are done, last priority is items
           ;; that were failed earlier THIS SESSION.
           (*org-drill-again-entries*
-           (pop-random *org-drill-again-entries*))
+           (pop *org-drill-again-entries*))
           (t                            ; nothing left -- return nil
            (return-from org-drill-pop-next-pending-entry nil)))))
       m)))
            (t
             (cond
              ((<= result org-drill-failure-quality)
-              (push m *org-drill-again-entries*))
+              (if *org-drill-again-entries*
+                  (setq *org-drill-again-entries*
+                        (shuffle-list *org-drill-again-entries*)))
+              (push-end m *org-drill-again-entries*))
              (t
               (push m *org-drill-done-entries*))))))))))