summaryrefslogtreecommitdiff
path: root/gnosis.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-01-03 16:51:57 +0200
committerThanos Apollo <[email protected]>2024-01-04 04:25:53 +0200
commit65ba87e40ebdcb22c8bb605effbe5b790b456f52 (patch)
treefbf124befe09235d13ea6b09957812a7ed6212c1 /gnosis.el
parent0506ce9f993178b688ff2fcf596d1108548ca1b4 (diff)
Add gnosis-edit-update-note
a loop to update values of fields using gnosis-update
Diffstat (limited to 'gnosis.el')
-rw-r--r--gnosis.el32
1 files changed, 32 insertions, 0 deletions
diff --git a/gnosis.el b/gnosis.el
index 15cc768..15b6fb0 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -951,6 +951,38 @@ changes."
(insert ")")
(insert "\n;; After finishing editing, evaluate expression with `C-x C-e'.")
(indent-region (point-min) (point-max)))))
+
+
+(cl-defun gnosis-edit-update-note (&key id main options answer tags (extra-notes nil) (image nil) (second-image nil))
+ "Update note with id value of ID.
+
+ID: Note id
+MAIN: Main part of note, the stem part of MCQ, question for basic, etc.
+OPTIONS: Options for mcq type notes/Hint for basic & cloze type notes
+ANSWER: Answer for MAIN, user is asked for input, if equal user-input
+= answer review is marked as successfull
+TAGS: Tags for note, used to organize & differentiate between notes
+EXTRA-NOTES: Notes to display after user-input
+IMAGE: Image to display before user-input
+SECOND-IMAGE: Image to display after user-input"
+ ;; Construct the update clause for the emacsql update statement.
+ (cl-loop for (field . value) in
+ `((main . ,main)
+ (options . ,options)
+ (answer . ,answer)
+ (tags . ,tags)
+ (extra-notes . ,extra-notes)
+ (image . ,image)
+ (second-image . ,second-image))
+ when value
+ do (cond ((member field '(extra-notes image second-image))
+ (gnosis-update 'extras `(= ,field ,value) `(= id ,id)))
+ ((listp value)
+ (gnosis-update 'notes `(= ,field ',value) `(= id ,id)))
+ (t (gnosis-update 'notes `(= ,field ,value) `(= id ,id)))))
+ (throw 'exit nil))
+
+
;;;###autoload
(defun gnosis-review ()
"Start gnosis review session."