summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2023-12-27 06:46:10 +0200
committerThanos Apollo <[email protected]>2023-12-27 06:48:08 +0200
commit2079d1e1c33918d35645d78c901db7c72b807d78 (patch)
treede28e40548bb36f7c0548a2c48809c61c306d3e6
parent62b467007aa0a424038bea817c6c3adbeb769c69 (diff)
Update MCQ for new functions & schemas
With this commit, as of now, gnosis can be used to review MCQ type notes properly.
-rw-r--r--gnosis.el40
1 files changed, 31 insertions, 9 deletions
diff --git a/gnosis.el b/gnosis.el
index 9d1b6a5..fcd4fb2 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -336,27 +336,49 @@ SUCCESS is a binary value, 1 is for successful review."
(defun gnosis-review-mcq (id)
"Display multiple choice answers for question ID."
(gnosis-display--image id)
- (let ((answer (gnosis-get 'answer 'notes `(= id ,id)))
- (choices (gnosis-get 'options 'notes `(= id ,id)))
- (user-choice (gnosis-mcq-answer id)))
- (if (equal (nth answer choices) user-choice)
- (progn (gnosis-review--success id)
+ (gnosis-display--question id)
+ (let* ((choices (gnosis-get 'options 'notes `(= id ,id)))
+ (answer (nth (- (gnosis-get 'answer 'notes `(= id ,id)) 1) choices))
+ (user-choice (gnosis-mcq-answer id)))
+ (if (string= answer user-choice)
+ (progn (gnosis-review--update id 1)
(message "Correct!"))
+ (gnosis-review--update id 0)
(message "False"))
(sit-for 0.5)
- (gnosis-display--correct-answer-mcq id user-choice)
+ (gnosis-display--correct-answer-mcq answer user-choice)
(gnosis-display--extra id)))
+(defun gnosis-review-cloze--input (id answer)
+ "Prompt for user input during cloze review.
+
+If user-input is equal to ANSWER, update card ID for successful review."
+ (let ((user-input (downcase (read-string "Answer: "))))
+ (if (string= user-input (downcase answer))
+ (progn (gnosis-review--update id 1)
+ (message "Correct!"))
+ (gnosis-review--update id 0)
+ (message "Fail"))))
+
+(defun gnosis-review-cloze (id)
+ "Review cloze type note for ID."
+ (gnosis-display--image id)
+ (let* ((main (gnosis-get 'main 'notes `(= id ,id)))
+ (clozes (gnosis-get 'answer 'notes `(= id ,id))))
+ ())
+ (gnosis-display--question 1)
+ (gnosis-display--extra id))
+
(defun gnosis-review-note (id)
"Start review for note with value of id ID."
- (let ((type (gnosis-get 'type 'notes `(= id id))))
- (gnosis-display--question id)
+ (let ((type (gnosis-get 'type 'notes `(= id ,id))))
(pcase type
("mcq" (gnosis-review-mcq id))
("basic" (message "Not Ready yet."))
- ("cloze" (message "Not Ready yet."))
+ ("cloze" (gnosis-review-cloze id))
(_ (error "Malformed note type")))))
+;;;###autoload
(defun gnosis-review ()
"Start gnosis session."
(interactive)