Enhancement Request: set a maximum interval

Issue #56 new
Channing Walton
created an issue

I use org-drill to help me keep musical pieces I've learned on the piano. Having the interval grow without bounds, even if I set org-drill-learn-fraction to a low value, isn't the best option for that and I need to practice regularly. So I would like to set a maximum number of days for the interval.

Comments (1)

  1. David

    Try this.

        (setq org-drill-max-interval 60)
        (defun org-drill-smart-reschedule (quality &optional days-ahead)
          "If DAYS-AHEAD is supplied it must be a positive integer. The
    item will be scheduled exactly this many days into the future."
          (let ((delta-days (- (time-to-days (current-time))
                   (time-to-days (or (org-get-scheduled-time (point))
                             (current-time)))))
            (ofmatrix org-drill-sm5-optimal-factor-matrix)
            ;; Entries can have weights, 1 by default. Intervals are divided by the
            ;; item's weight, so an item with a weight of 2 will have all intervals
            ;; halved, meaning you will end up reviewing it twice as often.
            ;; Useful for entries which randomly present any of several facts.
            (weight (org-entry-get (point) "DRILL_CARD_WEIGHT")))
        (if (stringp weight)
            (setq weight (read weight)))
        (destructuring-bind (last-interval repetitions failures
                           total-repeats meanq ease)
            (org-drill-get-item-data)
          (destructuring-bind (next-interval repetitions ease
                             failures meanq total-repeats
                             &optional new-ofmatrix)
              (case org-drill-spaced-repetition-algorithm
            (sm5 (determine-next-interval-sm5 last-interval repetitions
                              ease quality failures
                              meanq total-repeats ofmatrix))
            (sm2 (determine-next-interval-sm2 last-interval repetitions
                              ease quality failures
                              meanq total-repeats))
            (simple8 (determine-next-interval-simple8 last-interval repetitions
                                  quality failures meanq
                                  total-repeats
                                  delta-days)))
            (if (numberp days-ahead)
            ;; set maximum interval to org-drill-max-interval
            (setq next-interval
                  (min org-drill-max-interval days-ahead)))
    
            (if (and (null days-ahead)
                 (numberp weight) (plusp weight)
                 (not (minusp next-interval)))
    
            (setq next-interval
                  (max 1.0 (+ last-interval
                             (/ (- next-interval last-interval) weight)))))
    
            (org-drill-store-item-data next-interval repetitions failures
                           total-repeats meanq ease)
    
            (if (eql 'sm5 org-drill-spaced-repetition-algorithm)
            (setq org-drill-sm5-optimal-factor-matrix new-ofmatrix))
    
            (cond
             ((= 0 days-ahead)
              (org-schedule '(4)))
             ((minusp days-ahead)
              (org-schedule nil (current-time)))
             (t
              (org-schedule nil (time-add (current-time)
                          (days-to-time
                           (round next-interval))))))))))
    
  2. Log in to comment