summaryrefslogtreecommitdiff
path: root/gnosis-dev.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2023-12-31 06:15:45 +0200
committerThanos Apollo <[email protected]>2023-12-31 06:32:13 +0200
commit3e4248c7b6f1b2d045dde9024f9fcba9df00b5a0 (patch)
treee47cc3d393f77c6958d6a17f42bcc05524d2f306 /gnosis-dev.el
parent2023b37b1ea8ceba532c60cf280542b0e2e17e46 (diff)
Redo gnosis-dev.el
Diffstat (limited to 'gnosis-dev.el')
-rw-r--r--gnosis-dev.el99
1 files changed, 58 insertions, 41 deletions
diff --git a/gnosis-dev.el b/gnosis-dev.el
index 793c4ee..a8346e6 100644
--- a/gnosis-dev.el
+++ b/gnosis-dev.el
@@ -21,62 +21,79 @@
(setq shuffled-list (append (butlast shuffled-list index) (nthcdr (1+ index) shuffled-list)))))
selected-items))
-(defun gnosis-dev-add-fields ()
+(defun gnosis-dev-add-fields (&optional num deck)
"Add random inputs to test."
- (when (y-or-n-p "Add MCQ type?")
- (dotimes (_ 3)
- (gnosis-add-note--mcq :deck "Anatomy"
- :question "A 37-year-old man is admitted to the
+ (let ((num (or num (string-to-number (read-string "Number of random inputs: "))))
+ (testing-deck (or deck "testing")))
+ (gnosis-add-deck testing-deck)
+ (when (y-or-n-p "Add MCQ type?")
+ (dotimes (_ num)
+ (gnosis-add-note--mcq :deck testing-deck
+ :question "A 37-year-old man is admitted to the
emergency department after a severe car crash. After examining the
patient the emergency medicine physician concludes that the serratus
anterior muscle is damaged. Which of the following nerves innervates
the serratus anterior muscle?"
- :choices '("Long thoracic" "Axillary" "Spinal accessory" "Dorsal scapular" "Thoracodorsal")
- :correct-answer 1
- :extra "The long thoracic is the only nerve that
+ :choices '("Long thoracic" "Axillary" "Spinal accessory" "Dorsal scapular" "Thoracodorsal")
+ :correct-answer 1
+ :extra "The long thoracic is the only nerve that
innervates the serratus anterior. The axillary nerve innervates the
deltoid, the spinal accessory nerve innervates the sternocleidomastoid
and trapezius, the dorsal scapular nerve supplies the rhomboid muscles
and levator scapulae, and the latissimus dorsi is the muscle supplied
by the thoracodorsal nerve."
- :tags (gnosis-dev-random-items gnosis-dev-tags 2))))
- (when (y-or-n-p "Add Basic type questions?")
- (dotimes (_ 3)
- (gnosis-add-note--basic :deck "Anatomy"
- :question "A question"
- :hint "hint"
- :answer "answer"
- :extra "extra"
:tags (gnosis-dev-random-items gnosis-dev-tags 2))))
- (when (y-or-n-p "Add single cloze type?")
- (dotimes (_ 3)
- (gnosis-add-note--cloze :deck "Anatomy"
- :note "this is a {c1:note}"
- :hint "note"
- :tags (gnosis-dev-random-items gnosis-dev-tags 2)
- :extra "extra")))
- (when (y-or-n-p "Add mulit cloze type?")
- (dotimes (_ 3)
- (gnosis-add-note--cloze :deck "Anatomy"
- :note "this is a {c1:note} with multiple {c1:clozes}"
- :hint "note"
- :tags (gnosis-dev-random-items gnosis-dev-tags 2)
- :extra "extra"))))
+ (when (y-or-n-p "Add Basic type questions?")
+ (dotimes (_ num)
+ (gnosis-add-note--basic :deck testing-deck
+ :question "A question"
+ :hint "hint"
+ :answer "answer"
+ :extra "extra"
+ :tags (gnosis-dev-random-items gnosis-dev-tags 2))))
+ (when (y-or-n-p "Add single cloze type?")
+ (dotimes (_ num)
+ (gnosis-add-note--cloze :deck testing-deck
+ :note "this is a {c1:note}"
+ :hint "note"
+ :tags (gnosis-dev-random-items gnosis-dev-tags 2)
+ :extra "extra")))
+ (when (y-or-n-p "Add mulit cloze type?")
+ (dotimes (_ num)
+ (gnosis-add-note--cloze :deck testing-deck
+ :note "this is a {c1:note} with multiple {c1:clozes}"
+ :hint "note"
+ :tags (gnosis-dev-random-items gnosis-dev-tags 2)
+ :extra "extra")))))
(defun gnosis-dev-test ()
- "Start testing env."
+ "Begin/End testing env.
+
+If ask nil, leave development env"
(interactive)
- (let ((ask (y-or-n-p "Start development env?")))
+ (let ((ask (y-or-n-p "Start development env?"))
+ (testing-dir (concat gnosis-dir "/testing")))
(if ask
- (progn (setf gnosis-testing-dir (concat gnosis-dir "/testing"))
- (unless (file-exists-p gnosis-testing-dir)
- (make-directory gnosis-testing-dir))
- (setf gnosis-db (emacsql-sqlite-open (concat gnosis-testing-dir "/testing.db")))
- (gnosis-init))
- (setf gnosis-db (emacsql-sqlite-open (concat gnosis-dir "/" "gnosis.db"))))
- (message "Adding testing values...")
- (gnosis-dev-add-fields)
- (message "Done.")))
+ (progn (unless (file-exists-p testing-dir)
+ (make-directory testing-dir))
+ (setf gnosis-db (emacsql-sqlite (concat testing-dir "/testing.db")))
+ (setf gnosis-testing t)
+ (gnosis-db-init)
+ (gnosis-dev-add-fields)
+ (message "Adding testing values...")
+ (message "Development env is ready for testing."))
+ (setf gnosis-db (emacsql-sqlite-open (concat gnosis-dir "/" "gnosis.db")))
+ (setf gnosis-testing nil)
+ (message "Exited development env."))))
+
+(defun gnosis-dev-reinit ()
+ "Redo database."
+ (interactive)
+ (dolist (table '(notes decks review review-log extras))
+ (condition-case nil
+ (gnosis--drop-table table)
+ (error (message "No %s table to drop." table))))
+ (gnosis-db-init))
(provide 'gnosis-dev)
;;; gnosis-dev.el ends here