diff options
author | Thanos Apollo <[email protected]> | 2023-12-15 10:06:49 +0200 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2023-12-15 10:18:04 +0200 |
commit | b2d89acc3def18af88b83b7b0805b7916d79100a (patch) | |
tree | 63a66511bf312d2f4b83e7ecb98bd2304a76632f | |
parent | 811e6186555e26d933e5c43bbe017adcade0f95e (diff) |
Update addition of mcq note type
- Add error statements
- Add supsend value for review-log
-rw-r--r-- | gnosis.el | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -150,16 +150,19 @@ TAGS are used to organize questions." (list :deck (gnosis--get-deck-id) :question (read-string "Question: ") :choices (gnosis--ask-input "Choices") + ;; NOTE: string-to-number transforms non-number strings to 0 :correct-answer (string-to-number (read-string "Which is the correct answer (number)? ")) - :tags (when (equal (gnosis--ask-input "Tags") nil) 'untagged))) - (when (equal (numberp correct-answer) nil) - (error "The correct answer must be the number of the correct answer")) + :tags (gnosis--ask-input "Tags"))) + (cond ((or (not (numberp correct-answer)) (equal correct-answer 0)) + (error "Correct answer value must be the index number of the correct answer")) + ((null tags) + (setq tags 'untagged))) (gnosis--insert-into 'notes `([nil "mcq" ,question ,choices ,correct-answer ,tags ,deck])) ;; Get last inserted note-id - (let* ((note-id (caar (last (gnosis--select 'id 'notes)))) - (date (gnosis-current-date))) + (let ((note-id (caar (last (gnosis--select 'id 'notes)))) + (date (gnosis-date-current))) (gnosis--insert-into 'review `([,note-id ,gnosis-ef ,gnosis-ff 0 0])) - (gnosis--insert-into 'review-log `([,note-id 0 ,date 0])))) + (gnosis--insert-into 'review-log `([,note-id 0 ,date 0 0])))) (defun gnosis-add-note (type) "Create note as TYPE." |