From b12e5956b8c600d617ba3b817172c32149aa84ea Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Thu, 22 Feb 2024 13:47:49 +0200 Subject: Add gnosis-prompt-mcq-choices Return a list of mcq choices & the correct answer, make input easier and simpler --- gnosis.el | 10 ++++++++++ 1 file changed, 10 insertions(+) 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) -- cgit v1.2.3