summaryrefslogtreecommitdiff
path: root/gnosis.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2023-12-12 16:14:14 +0200
committerThanos Apollo <[email protected]>2023-12-12 16:14:14 +0200
commite9ee5cd8c6a2958d5b5f867eb016b335110b8ccd (patch)
tree190febb5ac99d4e56241e433016e81d6e13babf5 /gnosis.el
parent4da784814ee2a1767aeb67cda2d8dfd8141a4260 (diff)
mcq: Add error catch when correct-answer is not a number
Diffstat (limited to 'gnosis.el')
-rw-r--r--gnosis.el4
1 files changed, 3 insertions, 1 deletions
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."