branch: elpa/gnosis
commit 42852c75adeccc4cd6dda05133b965ce28722794
Author: Thanos Apollo <pub...@thanosapollo.org>
Commit: Thanos Apollo <pub...@thanosapollo.org>

    mc-cloze: Update review function.
    
    + Adjust review func for new db note types
---
 gnosis.el | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/gnosis.el b/gnosis.el
index cb8edf9af8..9f8c7ba546 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -120,7 +120,8 @@ framework's minibuffer."
   '(("Basic" . gnosis-add-note--basic)
     ("MCQ" .  gnosis-add-note--mcq)
     ("Double" .  gnosis-add-note--double)
-    ("Cloze" . gnosis-add-note--cloze))
+    ("Cloze" . gnosis-add-note--cloze)
+    ("MC-cloze" . gnosis-add-note--mc-cloze))
   "Mapping of Notes & their respective functions.")
 
 (defvar gnosis-previous-note-tags '()
@@ -1494,22 +1495,23 @@ If user-input is equal to CLOZE, return t."
     success))
 
 (defun gnosis-review-mc-cloze (id)
-  "Review MC-CLOZE note of ID."
-  (let ((main (gnosis-get 'keimenon 'notes `(= id ,id)))
-       ;; Cloze needs to be a list, we take car as the answer
-       (cloze (list (gnosis-get 'hypothesis 'notes `(= id ,id))))
-       (user-choice nil)
-       (success nil))
-    (gnosis-display-cloze-string main cloze nil nil nil)
-    (setf user-choice (gnosis-mcq-answer id)
-         success (string= user-choice (car cloze)))
-    (if success
-       (gnosis-display-cloze-string main nil nil cloze nil)
-      (gnosis-display-cloze-string main nil nil nil cloze))
-    ;; Display user answer only upon failure
-    (unless success
-      (gnosis-display-cloze-user-answer user-choice))
-    (gnosis-display-extra id)
+  "Review mc-cloze type note for ID."
+  (let* ((keimenon (gnosis-get 'keimenon 'notes `(= id ,id)))
+        (cloze (gnosis-get 'answer 'notes `(= id ,id)))
+        (options (gnosis-get 'hypothesis 'notes `(= id ,id)))
+        (parathema (gnosis-get 'parathema 'extras `(= id ,id)))
+        (user-input)
+        (success))
+    (gnosis-display-cloze-string keimenon cloze nil nil nil)
+    (setq user-input (funcall gnosis-completing-read-function
+                             "Select answer: "
+                             options))
+    (if (string= user-input (car cloze))
+       (progn
+         (gnosis-display-cloze-string keimenon nil nil cloze nil)
+         (setq success t))
+      (gnosis-display-cloze-string keimenon nil nil nil cloze))
+    (gnosis-display-parathema parathema)
     (gnosis-display-next-review id success)
     success))
 

Reply via email to