From b2d89acc3def18af88b83b7b0805b7916d79100a Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 15 Dec 2023 10:06:49 +0200 Subject: Update addition of mcq note type - Add error statements - Add supsend value for review-log --- gnosis.el | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gnosis.el b/gnosis.el index bb95ff0..f27c66f 100644 --- a/gnosis.el +++ b/gnosis.el @@ -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." -- cgit v1.2.3