From 9c147582ee4e4ec7880e259613e4058271c09cdc Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Mon, 27 Nov 2023 21:07:28 +0200 Subject: Add qbank-create-question - Add function to create question as TYPE. - Remove duplicate functions & add footer. --- qbank.el | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'qbank.el') diff --git a/qbank.el b/qbank.el index a61b9c7..0778503 100644 --- a/qbank.el +++ b/qbank.el @@ -83,15 +83,6 @@ (pop mcqs)) (reverse mcqs))) - -(defun qbank-create-mcq-question () - "Create question as MCQ type." - (interactive) - (let ((question (read-string "Question: ")) - (choices (unless (equal choices "q") - (read-string "Choices: "))))) - (qbank--insert-into ')) - (cl-defun qbank-create-mcq-question (&key question choices correct-answer) "Create a QUESTION with a list of multiple CHOICES and one CORRECT-ANSWER. @@ -107,6 +98,15 @@ use it like this: :correct-answer (string-to-number (read-string "Which is the correct answer?")))) (qbank--insert-into 'qbank1 `([nil ,question ,choices ,correct-answer]))) +(defun qbank-create-question (type) + "Create question as TYPE." + (interactive (list (completing-read "Type: " '(MCQ Cloze Basic)))) + (pcase type + ("MCQ" (call-interactively 'qbank-create-mcq-question)) + ("Cloze" (message "Not ready yet.")) + ("Basic" (message "Not ready yet.")) + (_ (message "No such type.")))) + ;; Fix: review for seperate question types. (defun qbank-review (id) "Start review for question ID." @@ -124,3 +124,5 @@ use it like this: (switch-to-buffer (get-buffer-create "*qbank*")) (qbank--display-question 13) (qbank-review 13))) + +;;; qbank.el ends here -- cgit v1.2.3