From e9ee5cd8c6a2958d5b5f867eb016b335110b8ccd Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 12 Dec 2023 16:14:14 +0200 Subject: mcq: Add error catch when correct-answer is not a number --- gnosis.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gnosis.el b/gnosis.el index bb74bb8..f60bf09 100644 --- a/gnosis.el +++ b/gnosis.el @@ -102,7 +102,9 @@ use it like this: :choices (gnosis--ask-input "Choices") :correct-answer (string-to-number (read-string "Which is the correct answer (number)? ")) :tags (gnosis--ask-input "Tags"))) - (gnosis--insert-into 'notes `([nil "mcq" ,question ,choices ,correct-answer 0 0 ,tags]))) + (when (equal (numberp correct-answer)) + (error "The correct answer must be the number of the correct answer")) + (gnosis--insert-into 'notes `([nil "mcq" ,question ,choices ,correct-answer ,tags, nil, nil nil]))) (defun gnosis-create-question (type) "Create question as TYPE." -- cgit v1.2.3