From 0677731a081c4e41404eabd447ad2c230519c0f4 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Wed, 27 Dec 2023 10:04:07 +0200 Subject: Redo cloze input to return result & user-input Return (cons result user-input), user-input will be displayed when result is nil, meaning failed review --- gnosis.el | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/gnosis.el b/gnosis.el index 3ea14da..3a41e58 100644 --- a/gnosis.el +++ b/gnosis.el @@ -371,17 +371,27 @@ SUCCESS is a binary value, 1 is for successful review." If user-input is equal to CLOZE, return t." (let ((user-input (read-string "Cloze: "))) - (if (string= user-input cloze) - t - nil))) + (cons (string= (downcase user-input) (downcase cloze)) user-input))) + +(defun gnosis-review-cloze--reveal (clozes) + "Reveal CLOZES." + (cl-loop for cloze in clozes do (gnosis-display--cloze-correct gnosis-cloze-char cloze))) (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--image id) + (gnosis-display--cloze-sentence main clozes) + (cl-loop for cloze in clozes + do (let ((input (gnosis-review-cloze--input cloze))) + (when (equal (car input) nil) + (gnosis-review-cloze--reveal clozes) + (gnosis-display--cloze-user-answer (cdr input) t) + (gnosis-review--update id 0) + (cl-return))) + finally (progn (gnosis-review-cloze--reveal clozes) + (gnosis-review--update id 1)))) (gnosis-display--extra id)) (defun gnosis-review-note (id) -- cgit v1.2.3