diff options
author | Thanos Apollo <[email protected]> | 2024-03-08 08:04:03 +0200 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2024-03-08 08:33:03 +0200 |
commit | e5f5f6db38cc51c798bd9cb9a70da6df34bcfa4d (patch) | |
tree | a5f55ca4215c54fa4ede3a80a5e69cf35b581bc4 /gnosis.el | |
parent | 5e071a813391267b7ebcfdae15862b7c75e51e14 (diff) |
gnosis-edit: Adjust for deck initial interval
Diffstat (limited to 'gnosis.el')
-rw-r--r-- | gnosis.el | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -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)))) |