[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-drill 9487fd21f8 002/251: Added special card type for
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/org-drill 9487fd21f8 002/251: Added special card type for spanish verbs, to demonstrate custom card types. |
Date: |
Mon, 17 Jan 2022 18:58:55 -0500 (EST) |
branch: elpa/org-drill
commit 9487fd21f8fa1338027fbef67109430fce052288
Author: eeeickythump <devnull@localhost>
Commit: eeeickythump <devnull@localhost>
Added special card type for spanish verbs, to demonstrate custom card types.
---
org-drill.el | 172 ++++++++++++++++++++++++++++++++++++++++++++--------------
questions.org | 80 ---------------------------
spanish.org | 128 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 258 insertions(+), 122 deletions(-)
diff --git a/org-drill.el b/org-drill.el
index 76a54e99b8..116a6f18fd 100644
--- a/org-drill.el
+++ b/org-drill.el
@@ -9,12 +9,14 @@
;;; ========
;;;
;;; Uses the spaced repetition algorithm in `org-learn' to conduct interactive
-;;; "drill sessions" where material to be remembered is presented to the
-;;; student. The student rates his or her recall of each item, and this
information
-;;; is fed back to 'org-learn' to schedule later revision of the item.
+;;; "drill sessions", where the material to be remembered is presented to the
+;;; student in random order. The student rates his or her recall of each item,
+;;; and this information is fed back to `org-learn' to schedule the item for
+;;; later revision.
;;;
-;;; Drills can include topics in one buffer, one or several files,
-;;; all agenda files, or a subtree. A single topic can also be drilled.
+;;; Each drill session can be restricted to topics in the current buffer
+;;; (default), one or several files, all agenda files, or a subtree. A single
+;;; topic can also be drilled.
;;;
;;; Different "card types" can be defined, which present their information to
;;; the student in different ways.
@@ -29,19 +31,24 @@
;;; (require 'org-drill)
;;;
;;;
-;;; Usage
-;;; =====
+;;; Writing the questions
+;;; =====================
+;;;
+;;; See the file "spanish.org" for an example set of material.
;;;
;;; Tag all items you want to be asked about with a tag that matches
;;; `org-drill-question-tag'. This is :drill: by default.
;;;
-;;; You don't need to schedule the topics initially. Within each question, the
-;;; answer can be included in the following ways:
+;;; You don't need to schedule the topics initially. However org-drill *will*
+;;; recognise items that have been scheduled previously with `org-learn'.
+;;;
+;;; Within each question, the answer can be included in the following ways:
;;;
;;; - Question in the main body text, answer in subtopics. This is the
-;;; default. All subtopics will be shown collapsed.
+;;; default. All subtopics will be shown collapsed, while the text under
+;;; the main heading will stay visible.
;;;
-;;; - Each subtopic contains a piece of information related to the topic. One
+;;; - Each subtopic contains a piece of information related to the topic. ONE
;;; of these will revealed at random, and the others hidden. To define a
;;; topic of this type, give the topic a property `DRILL_CARD_TYPE' with
;;; value `multisided'.
@@ -54,16 +61,24 @@
;;; - No explicit answer -- the user judges whether they recalled the
;;; fact adequately.
;;;
-;;; See "questions.org" for examples.
+;;; - Other methods of your own devising, provided you write a function to
+;;; handle selective display of the topic. See the function
+;;; `org-drill-present-spanish-verb', which handles topics of type
"spanish_verb",
+;;; for an example.
+;;;
+;;;
+;;; Running the drill session
+;;; =========================
;;;
-;;; Run a drill session with `M-x org-drill'. This will include all eligible
+;;; Start a drill session with `M-x org-drill'. This will include all eligible
;;; topics in the current buffer. `org-drill' can also be targeted at a
particular
-;;; subtree or particular files or sets of files; see the documentation of that
-;;; function for details.
+;;; subtree or particular files or sets of files; see the documentation of
+;;; the function `org-drill' for details.
;;;
;;; During the drill session, you will be presented with each item, then asked
;;; to rate your recall of it by pressing a key between 0 and 5. At any time
you
-;;; can press 'q' to finish the drill early (your progress will be saved).
+;;; can press 'q' to finish the drill early (your progress will be saved), or
+;;; 'e' to finish the drill and jump to the current topic for editing.
;;;
;;;
;;; TODO
@@ -131,7 +146,8 @@ Nil means unlimited."
(defcustom org-drill-card-type-alist
'((nil . org-drill-present-simple-card)
("simple" . org-drill-present-simple-card)
- ("multisided" . org-drill-present-multi-sided-card))
+ ("multisided" . org-drill-present-multi-sided-card)
+ ("spanish_verb" . org-drill-present-spanish-verb))
"Alist associating card types with presentation functions. Each entry in the
alist takes the form (CARDTYPE . FUNCTION), where CARDTYPE is a string
or nil, and FUNCTION is a function which takes no arguments and returns a
@@ -196,6 +212,36 @@ How well did you do? (0-5, ?=help, q=quit)"
nil))))
+(defun org-drill-hide-all-subheadings-except (heading-list)
+ "Returns a list containing the position of each immediate subheading of
+the current topic."
+ (let ((drill-entry-level (org-current-level))
+ (drill-sections nil)
+ (drill-heading nil))
+ (org-show-subtree)
+ (save-excursion
+ (org-map-entries
+ (lambda ()
+ (when (= (org-current-level) (1+ drill-entry-level))
+ (setq drill-heading (org-get-heading t))
+ (unless (member drill-heading heading-list)
+ (hide-subtree))
+ (push (point) drill-sections)))
+ "" 'tree))
+ (reverse drill-sections)))
+
+
+(defun org-drill-presentation-prompt (&rest fmt-and-args)
+ (let ((ch (read-char (if fmt-and-args
+ (apply 'format
+ (first fmt-and-args)
+ (rest fmt-and-args))
+ "Press any key to see the answer, 'e' to edit, 'q' to
quit."))))
+ (case ch
+ (?q nil)
+ (?e 'edit)
+ (otherwise t))))
+
;;; Presentation functions ====================================================
@@ -207,36 +253,68 @@ How well did you do? (0-5, ?=help, q=quit)"
;; recall, nil if they chose to quit.
(defun org-drill-present-simple-card ()
- (save-excursion
- (let ((drill-entry-level (org-current-level)))
- (org-map-entries
- (lambda ()
- (if (> (org-current-level) drill-entry-level)
- (hide-subtree)))
- "" 'tree)))
- (setq ch (read-char "Press a key to see the answer..."))
- (org-show-subtree)
- (not (eq ch ?q)))
-
+ (org-drill-hide-all-subheadings-except nil)
+ (prog1 (org-drill-presentation-prompt)
+ (org-show-subtree)))
(defun org-drill-present-multi-sided-card ()
- (let ((drill-entry-level (org-current-level))
- (drill-sections nil))
- (save-excursion
- (org-map-entries
- (lambda ()
- (when (> (org-current-level) drill-entry-level)
- (hide-subtree)
- (push (point) drill-sections)))
- "" 'tree))
+ (let ((drill-sections (org-drill-hide-all-subheadings-except nil)))
(when drill-sections
(save-excursion
(goto-char (nth (random (length drill-sections)) drill-sections))
(org-show-subtree)))
- (setq ch (read-char "Press a key to see the answer..."))
- (org-show-subtree)
- (not (eq ch ?q))))
+ (prog1
+ (org-drill-presentation-prompt)
+ (org-show-subtree))))
+
+
+
+(defun org-drill-present-spanish-verb ()
+ (case (random 6)
+ (0
+ (org-drill-hide-all-subheadings-except '("Infinitive"))
+ (prog1
+ (org-drill-presentation-prompt
+ "Translate this Spanish verb, and conjugate it for the *present*
tense.")
+ (org-drill-hide-all-subheadings-except '("English" "Present Tense"
+ "Notes"))))
+ (1
+ (org-drill-hide-all-subheadings-except '("English"))
+ (prog1
+ (org-drill-presentation-prompt
+ "For the *present* tense, conjugate the Spanish translation of this
English verb.")
+ (org-drill-hide-all-subheadings-except '("Infinitive" "Present Tense"
+ "Notes"))))
+ (2
+ (org-drill-hide-all-subheadings-except '("Infinitive"))
+ (prog1
+ (org-drill-presentation-prompt
+ "Translate this Spanish verb, and conjugate it for the *past*
tense.")
+ (org-drill-hide-all-subheadings-except '("English" "Past Tense"
+ "Notes"))))
+ (3
+ (org-drill-hide-all-subheadings-except '("English"))
+ (prog1
+ (org-drill-presentation-prompt
+ "For the *past* tense, conjugate the Spanish translation of this
English verb.")
+ (org-drill-hide-all-subheadings-except '("Infinitive" "Past Tense"
+ "Notes"))))
+ (4
+ (org-drill-hide-all-subheadings-except '("Infinitive"))
+ (prog1
+ (org-drill-presentation-prompt
+ "Translate this Spanish verb, and conjugate it for the *future
perfect* tense.")
+ (org-drill-hide-all-subheadings-except '("English" "Future Perfect
Tense"
+ "Notes"))))
+ (5
+ (org-drill-hide-all-subheadings-except '("English"))
+ (prog1
+ (org-drill-presentation-prompt
+ "For the *future perfect* tense, conjugate the Spanish translation
of this English verb.")
+ (org-drill-hide-all-subheadings-except '("Infinitive" "Future Perfect
Tense"
+ "Notes"))))))
+
@@ -270,6 +348,8 @@ See `org-drill' for more details."
((not cont)
(message "Quit")
nil)
+ ((eql cont 'edit)
+ 'edit)
(t
(save-excursion
(org-drill-reschedule)))))))
@@ -319,7 +399,8 @@ agenda-with-archives
(interactive)
(let ((entries nil)
(result nil)
- (results nil))
+ (results nil)
+ (end-pos nil))
(block org-drill
(save-excursion
(org-map-entries
@@ -345,13 +426,20 @@ agenda-with-archives
((null result)
(message "Quit")
(return-from org-drill nil))
+ ((eql result 'edit)
+ (setq end-pos (point-marker))
+ (return-from org-drill nil))
((and org-drill-maximum-duration
(> (- (float-time (current-time)) start-time)
(* org-drill-maximum-duration 60)))
(message "This drill session has reached its maximum
duration.")
(return-from org-drill nil)))))
(message "Drill session finished!")
- )))))))
+ )))))
+ (when end-pos
+ (switch-to-buffer (marker-buffer end-pos))
+ (goto-char (marker-position end-pos))
+ (message "Edit topic."))))
diff --git a/questions.org b/questions.org
deleted file mode 100644
index 2855345815..0000000000
--- a/questions.org
+++ /dev/null
@@ -1,80 +0,0 @@
-# -*- mode: org; coding: utf-8 -*-
-# example of card definitions for use with org-drill.
-
-* Spanish questions
-
-** Greetings
-
-# Simple cards. When each card is presented, all subheadings are collapsed.
-
-*** Greeting 1 :drill:
-
-Translate into Spanish:
-What is your name? (formal)
-
-**** Answer
-
-¿Cómo se llama usted?
-
-*** Greeting 2 :drill:
-
-Translate into Spanish:
-What is your name? (informal)
-
-**** Answer
-
-¿Cómo te llamas?
-
-** Nouns
-
-# Examples of 'multisided' cards. The user will randomly be presented either
-# with the Spanish word, or the English word, and asked to recall the
-# appropriate translation.
-
-*** Noun :drill:
- :PROPERTIES:
- :DRILL_CARD_TYPE: multisided
- :END:
-
-Translate this word.
-
-**** Front
-
-el gato
-
-**** Back
-
-the cat
-
-
-*** Noun :drill:
- :PROPERTIES:
- :DRILL_CARD_TYPE: multisided
- :END:
-
-Translate this word.
-
-**** Front
-
-el perro
-
-**** Back
-
-the dog
-
-
-** Grammar rules
-
-# Simple cards -- the question and answer are produced purely using cloze
-# deletion, without the need to hide any subtopics.
-
-*** Rule :drill:
-
-To make the plural of an adjective ending in [a stressed vowel or a consonant
-other than -z], add /-es/.
-
-*** Rule :drill:
-
-To form an adverb from an adjective, add [-mente] to the [feminine] (gender)
-form of the adjective.
-
diff --git a/spanish.org b/spanish.org
new file mode 100644
index 0000000000..82dc981e36
--- /dev/null
+++ b/spanish.org
@@ -0,0 +1,128 @@
+# -*- mode: org; coding: utf-8 -*-
+#+STARTUP: showall
+
+# examples of card definitions for use with org-drill.
+
+* Spanish questions
+
+** Greetings
+
+# Simple cards. When each card is presented, any subheadings are collapsed, but
+# the text under the topic's main heading remains visible.
+
+*** Greeting 1 :drill:
+
+Translate into Spanish:
+What is your name? (formal)
+
+**** Answer
+
+¿Cómo se llama usted?
+
+*** Greeting 2 :drill:
+
+Translate into Spanish:
+What is your name? (informal)
+
+**** Answer
+
+¿Cómo te llamas?
+
+** Nouns
+
+# Examples of 'multisided' cards. The user will randomly be presented with ONE
+# of the subheadings -- in this case either the Spanish word, or the English
+# word.
+
+# (we could include a third subheading which just contains an inline picture.)
+
+*** Noun :drill:
+ :PROPERTIES:
+ :DRILL_CARD_TYPE: multisided
+ :END:
+
+Translate this word.
+
+**** Spanish
+
+el gato
+
+**** English
+
+the cat
+
+
+*** Noun :drill:
+ :PROPERTIES:
+ :DRILL_CARD_TYPE: multisided
+ :END:
+
+Translate this word.
+
+**** Spanish
+
+el perro
+
+**** English
+
+the dog
+
+
+** Grammar rules
+
+# More simple cards -- here the question and answer are produced purely using
+# cloze deletion of test in [square brackets], without the need to hide any
+# subtopics.
+
+*** Grammar Rule :drill:
+
+To make the plural of an adjective ending in [a stressed vowel or a consonant
+other than -z], add /-es/.
+
+*** Grammar Rule :drill:
+
+To form an adverb from an adjective, add [-mente] to the [feminine] (gender)
+form of the adjective.
+
+** Verbs
+
+# An example of a special card type. The information in "spanish_verb" topics
+# can be presented in any of several different ways -- see the function
+# `org-drill-present-spanish-verb'.
+
+*** Verb :drill:
+ :PROPERTIES:
+ :DRILL_CARD_TYPE: spanish_verb
+ :END:
+
+**** Infinitive
+
+cantar
+
+**** English
+
+to sing
+
+**** Present Tense
+
+| yo canto | nosotros cantamos |
+| tú cantas | vosotros cantáis |
+| él canta | ellos cantan |
+
+**** Past Tense
+
+| yo canté | nosotros cantamos |
+| tú cantaste | vosotros cantasteis |
+| él cantó | ellos cantaron |
+
+**** Future Perfect Tense
+
+| yo cantaré | nosotros cantaremos |
+| tú cantarás | vosotros cantaréis |
+| él cantarán | ellos cantarán |
+
+
+**** Notes
+
+Regular verb.
+
- [nongnu] elpa/org-drill 97aad88728 029/251: - 'multicloze' card type renamed to 'hide1cloze' (though 'multicloze' is, (continued)
- [nongnu] elpa/org-drill 97aad88728 029/251: - 'multicloze' card type renamed to 'hide1cloze' (though 'multicloze' is, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 02e454f8d0 033/251: Added tag 2.3 for changeset b5d5b9f5c203, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill b69d212068 053/251: Go back to using org-save-outline-visibility instead of org-drill-save-visibility -, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 6dc1b90f21 050/251: Added tag 2.3.5 for changeset 872dde6580f6, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 9cb409a1ba 012/251: * New command: 'M-x org-drill-cram'. "Cram Mode" is the same as an ordinary drill session, except, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 5749d5bb7a 057/251: Contents of entry drawers are now hidden while displaying answers., ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 79a0ac93ae 058/251: Hide entry drawers when showing answers for verb conjugation and noun, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 93545edb91 063/251: Added tag 2.3.8 for changeset a8cade42f59c, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 8b6e230886 065/251: Added ability to define arbitrary left and right cloze delimiters (strings),, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill b17bf579bd 039/251: - New card types: show2cloze, hide1_firstmore, show1_firstless, show1_lastmore. See docs for details., ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 9487fd21f8 002/251: Added special card type for spanish verbs, to demonstrate custom card types.,
ELPA Syncer <=
- [nongnu] elpa/org-drill 5040d0e6d2 014/251: Added tag 1.4 for changeset 2e4735840112, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill e698616493 026/251: - More robust handling of the situation where we resume a drill session but, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill e7ffd8e6eb 040/251: Renamed documentation file and fixed a few typos., ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 063e8035a8 071/251: - Ignore cloze markings if they occur inside Org source blocks, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 663a1ee3f3 079/251: Clarified that org-drill is licensed under GPL v3., ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 8a9192cc2f 080/251: Persistence of the optimal factor matrix across application sessions is now, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill cfe271d824 062/251: Fixed: org-drill-strip-all-data now works again (was using obsolete arguments, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 09f7bc5c9b 083/251: Backout changeset 5d9b61ea5a181eb282e4069c17cbdf00e4325726, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill f9a217faa1 052/251: Wrapped all calls to 'org-display-inline-images' in 'ignore-errors', to prevent, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill d0405e9311 060/251: Fixed bug with scheduling failed cards, caused by changes to 'org-schedule' in, ELPA Syncer, 2022/01/17