summaryrefslogtreecommitdiff
path: root/gnosis.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-03-08 08:04:03 +0200
committerThanos Apollo <[email protected]>2024-03-08 08:33:03 +0200
commite5f5f6db38cc51c798bd9cb9a70da6df34bcfa4d (patch)
treea5f55ca4215c54fa4ede3a80a5e69cf35b581bc4 /gnosis.el
parent5e071a813391267b7ebcfdae15862b7c75e51e14 (diff)
gnosis-edit: Adjust for deck initial interval
Diffstat (limited to 'gnosis.el')
-rw-r--r--gnosis.el19
1 files changed, 14 insertions, 5 deletions
diff --git a/gnosis.el b/gnosis.el
index a719803..d054a28 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -1262,9 +1262,11 @@ Insert deck values:
(ef-increase (gnosis-get 'ef-increase 'decks `(= id ,id)))
(ef-decrease (gnosis-get 'ef-decrease 'decks `(= id ,id)))
(ef-threshold (gnosis-get 'ef-threshold 'decks `(= id ,id)))
- (failure-factor (gnosis-get 'failure-factor 'decks `(= id ,id))))
- (insert (format "\n:id %s\n:name \"%s\"\n:ef-increase %s\n:ef-decrease %s\n:ef-threshold %s\n:failure-factor %s"
- id name ef-increase ef-decrease ef-threshold failure-factor))))
+ (failure-factor (gnosis-get 'failure-factor 'decks `(= id ,id)))
+ (initial-interval (gnosis-get 'initial-interval 'decks `(= id ,id))))
+ (insert
+ (format "\n:id %s\n:name \"%s\"\n:ef-increase %s\n:ef-decrease %s\n:ef-threshold %s\n:failure-factor %s\n :initial-interval '%s"
+ id name ef-increase ef-decrease ef-threshold failure-factor initial-interval))))
(defun gnosis-assert-int-or-nil (value description)
"Assert that VALUE is an integer or nil.
@@ -1291,22 +1293,29 @@ DESCRIPTION is a string that describes the value."
(unless (or (null value) (numberp value))
(error "Invalid value: %s, %s" value description)))
-(cl-defun gnosis-edit-update-deck (&key id name ef-increase ef-decrease ef-threshold failure-factor)
+(cl-defun gnosis-edit-update-deck (&key id name ef-increase ef-decrease ef-threshold failure-factor initial-interval)
"Update deck with id value of ID.
NAME: Name of deck
EF-INCREASE: Easiness factor increase value
EF-DECREASE: Easiness factor decrease value
EF-THRESHOLD: Easiness factor threshold value
-FAILURE-FACTOR: Failure factor value"
+FAILURE-FACTOR: Failure factor value
+INITIAL-INTERVAL: Initial interval for notes of deck"
(gnosis-assert-float-or-nil failure-factor "failure-factor must be a float less than 1" t)
(gnosis-assert-int-or-nil ef-threshold "ef-threshold must be an integer")
(gnosis-assert-number-or-nil ef-increase "ef-increase must be a number")
+ (cl-assert (or (and (listp initial-interval)
+ (and (cl-every #'integerp initial-interval)
+ (length= initial-interval 2)))
+ (null initial-interval))
+ nil "Initial-interval must be a list of 2 integers")
(cl-loop for (field . value) in
`((ef-increase . ,ef-increase)
(ef-decrease . ,ef-decrease)
(ef-threshold . ,ef-threshold)
(failure-factor . ,failure-factor)
+ (initial-interval . ',initial-interval)
(name . ,name))
when value
do (gnosis-update 'decks `(= ,field ,value) `(= id ,id))))