summaryrefslogtreecommitdiff
path: root/gnosis.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-02-22 13:47:49 +0200
committerThanos Apollo <[email protected]>2024-02-22 13:47:49 +0200
commitb12e5956b8c600d617ba3b817172c32149aa84ea (patch)
tree6a6333b64c2bfca7f2b507ad49397823699ceb5b /gnosis.el
parent67afa56d09de10a7e3593088c28a97215d03b651 (diff)
Add gnosis-prompt-mcq-choices
Return a list of mcq choices & the correct answer, make input easier and simpler
Diffstat (limited to 'gnosis.el')
-rw-r--r--gnosis.el10
1 files changed, 10 insertions, 0 deletions
diff --git a/gnosis.el b/gnosis.el
index f0ce2dc..e8ea3cc 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -852,6 +852,16 @@ Returns a list of unique tags."
(setf gnosis-previous-note-hint hint)
hint))
+(defun gnosis-prompt-mcq-choices ()
+ "Prompt user for mcq choices."
+ (let* ((input (split-string
+ (read-string-from-buffer "Options\nEach '-' corresponds to an option\n-Example Option 1\n-Example Option 2\nYou can add as many options as you want\nCorrect Option must be inside {}" "-\n-")
+ "-" t "[\s\n]"))
+ (correct-choice-index (or (cl-position-if (lambda (string) (string-match "{.*}" string)) input)
+ (error "Correct choice not found. Use {} to indicate the correct opiton")))
+ (choices (mapcar (lambda (string) (replace-regexp-in-string "{\\|}" "" string)) input)))
+ (list choices (+ correct-choice-index 1))))
+
;; Review
;;;;;;;;;;
(defun gnosis-review-is-due-p (note-id)