Commits

Anonymous committed ee09da7

- Hide comments (#...) in items during drill sessions.
- Fix bug where if a subheading was more than 1 level deeper than the tested item, and had no parent
heading other than the item's heading, it would not be hidden during testing.

  • Participants
  • Parent commits ff1aebb

Comments (0)

Files changed (6)

.hgtags

File contents unchanged.
 <title>Org-Drill</title>
 <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
 <meta name="generator" content="Org-mode"/>
-<meta name="generated" content="2010-09-17 10:05:27 "/>
+<meta name="generated" content="2011-03-25 11:53:49 "/>
 <meta name="author" content="Paul Sexton"/>
 <meta name="description" content=""/>
 <meta name="keywords" content=""/>
   .target { }
   .timestamp { color: #bebebe; }
   .timestamp-kwd { color: #5f9ea0; }
+  .right  {margin-left:auto; margin-right:0px;  text-align:right;}
+  .left   {margin-left:0px;  margin-right:auto; text-align:left;}
+  .center {margin-left:auto; margin-right:auto; text-align:center;}
   p.verse { margin-left: 3% }
   pre {
 	border: 1pt solid #AEBDCC;
         overflow:auto;
   }
   table { border-collapse: collapse; }
-  td, th { vertical-align: top; }
+  td, th { vertical-align: top;  }
+  th.right  { text-align:center;  }
+  th.left   { text-align:center;   }
+  th.center { text-align:center; }
+  td.right  { text-align:right;  }
+  td.left   { text-align:left;   }
+  td.center { text-align:center; }
   dt { font-weight: bold; }
   div.figure { padding: 0.5em; }
   div.figure p { text-align: center; }
 <li><a href="#sec-4_4">Multi-sided cards </a></li>
 <li><a href="#sec-4_5">Multi-cloze cards </a></li>
 <li><a href="#sec-4_6">User-defined topic types </a></li>
+<li><a href="#sec-4_7">Comments </a></li>
 </ul>
 </li>
 <li><a href="#sec-5">Running the drill session </a></li>
 <li>
 <a href="http://mnemosyne-proj.org/index.php">Mnemosyne</a>
 
-
 </li>
 </ul>
+
+
 </div>
 
 </div>
 When the user presses a key, the text "Tallinn" will become visible.
 </p>
 <p>
-Clozed text can also contain a "hint" about the answer. If the text 
+Clozed text can also contain a "hint" about the answer. If the text
 surrounded by single square brackets contains a `|' character (vertical bar),
 all text after that character is treated as a hint, and will be visible when
 the rest of the text is hidden.
 
 <blockquote>
 
-<p>Type 1 hypersensitivity reactions are mediated by 
+<p>Type 1 hypersensitivity reactions are mediated by
 <font style="background-color: blue;" color="cyan">
 <tt>[&hellip;molecule]</tt></font>
 and <font style="background-color: blue;" color="cyan">
 the woman
 
 ** Example sentence
-¿Quién fue esa mujer? 
+¿Quién fue esa mujer?
 Who was that woman?
 </pre>
 
 <p>
 The <code>multisided</code> card type is similar to <code>twosided</code>, except that any
 subheading has a chance of being presented during the topic review. One
-subheading is always shown and all others are always hidden. 
+subheading is always shown and all others are always hidden.
 </p>
 
 
 </p>
 <blockquote>
 
-<p>The capital city of [New Zealand] is [Wellington], which is located in 
+<p>The capital city of [New Zealand] is [Wellington], which is located in
 [the South Island] and has a population of about [400,000].
 </p>
 </blockquote>
 the South Island.
 
 * Fact
-The capital city of New Zealand is [Wellington], which is located in 
+The capital city of New Zealand is [Wellington], which is located in
 the South Island.
 
 * Fact
-The capital city of New Zealand is Wellington, which is located in 
+The capital city of New Zealand is Wellington, which is located in
 [the South Island].
 </pre>
 
   :DRILL_CARD_TYPE: multicloze
   :END:
 
-The capital city of [New Zealand] is [Wellington], which is located in 
+The capital city of [New Zealand] is [Wellington], which is located in
 [the South Island] and has a population of about [400,000].
 </pre>
 
 <p>
 See the file <a href="spanish.html">spanish.org</a> for a full set of example material.
 </p>
+</div>
+
+</div>
+
+<div id="outline-container-4_7" class="outline-3">
+<h3 id="sec-4_7">Comments </h3>
+<div class="outline-text-3" id="text-4_7">
+
+
+<p>
+In org mode, comment lines start with '#'. The rest of the line is ignored by
+Org (apart from some special cases). You may sometimes want to put material in
+comments which you do not want to see when you are being tested on the
+item. For this reason, all comments are rendered invisible while items are
+being tested.
+</p>
 
 </div>
 </div>
 <dt>(file1 file2 &hellip;)</dt><dd>
 A list of filenames. All files in the list will be
 scanned.
-
 </dd>
 </dl>
 
-<p>During a drill session, you will be presented with each item, then asked to
+
+<p>
+During a 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. The meaning of these
 numbers is (taken from <code>org-learn</code>):
 </p>
 <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
 <caption></caption>
-<colgroup><col align="right" /><col align="left" /><col align="left" />
+<colgroup><col class="right" /><col class="left" /><col class="left" />
 </colgroup>
 <thead>
-<tr><th scope="col">Quality</th><th scope="col">SuperMemo label</th><th scope="col">Meaning</th></tr>
+<tr><th scope="col" class="right">Quality</th><th scope="col" class="left">SuperMemo label</th><th scope="col" class="left">Meaning</th></tr>
 </thead>
 <tbody>
-<tr><td>0</td><td>NULL</td><td>You have forgotten this card completely.</td></tr>
-<tr><td>1</td><td>BAD</td><td>Wrong answer.</td></tr>
-<tr><td>2</td><td>FAIL</td><td>Barely correct, the interval was too long.</td></tr>
-<tr><td>3</td><td>PASS</td><td>Correct answer, but with much effort.</td></tr>
-<tr><td>4</td><td>GOOD</td><td>Correct answer, with a little thought.</td></tr>
-<tr><td>5</td><td>BRIGHT</td><td>Correct answer, effortless.</td></tr>
+<tr><td class="right">0</td><td class="left">NULL</td><td class="left">You have forgotten this card completely.</td></tr>
+<tr><td class="right">1</td><td class="left">BAD</td><td class="left">Wrong answer.</td></tr>
+<tr><td class="right">2</td><td class="left">FAIL</td><td class="left">Barely correct, the interval was too long.</td></tr>
+<tr><td class="right">3</td><td class="left">PASS</td><td class="left">Correct answer, but with much effort.</td></tr>
+<tr><td class="right">4</td><td class="left">GOOD</td><td class="left">Correct answer, with a little thought.</td></tr>
+<tr><td class="right">5</td><td class="left">BRIGHT</td><td class="left">Correct answer, effortless.</td></tr>
 </tbody>
 </table>
 
 <dt>warn</dt><dd>
 Leech items are still included in drill sessions, but a warning
 message is printed when each leech item is presented.
-
 </dd>
 </dl>
 
-<p>The best way to deal with a leech is either to delete it, or reformulate it so
+
+<p>
+The best way to deal with a leech is either to delete it, or reformulate it so
 that it is easier to remember, for example by splitting it into more than one
-card. 
+card.
 </p>
 <p>
 See <a href="http://www.supermemo.com/help/leech.htm">the SuperMemo website</a> for more on leeches.
 <p>
 An example of using Org-Drill for incremental reading is given below. First,
 and most importantly, we need to define a couple of <code>org-capture</code> templates for
-captured facts. 
+captured facts.
 </p>
 
 
 to whichever file and heading you nominate in the template. The fact will
 contain a timestamp, and a hyperlink back to the webpage where you created
 it.
-
 </li>
 </ul>
 
-<p>For example, suppose you are reading the Wikipedia entry on tuberculosis <a href="http://en.wikipedia.org/wiki/Tuberculosis">here</a>.
+
+<p>
+For example, suppose you are reading the Wikipedia entry on tuberculosis <a href="http://en.wikipedia.org/wiki/Tuberculosis">here</a>.
 </p>
 <p>
 You read the following:
 sputum, fever, night sweats, and weight loss. Infection of other organs causes
 a wide range of symptoms. Treatment is difficult and requires long courses of
 multiple antibiotics. Antibiotic resistance is a growing problem in
-(extensively) multi-drug-resistant tuberculosis. 
+(extensively) multi-drug-resistant tuberculosis.
 <font style="background-color: yellow;">Prevention relies
 on screening programs and vaccination, usually with Bacillus Calmette-Guérin
 vaccine.</font>
 <p>
 You can of course define browser buttons that use several different "fact"
 templates, each of which might send its fact to a different file or subheading,
-or give it different tags or properties, for example. 
+or give it different tags or properties, for example.
 </p>
 
 </div>
 <li>
 perhaps take account of item priorities, showing high priority items first
 </li>
+<li>
+get tooltips to work for old/new/etc counts during review?
+</li>
 </ul>
+
 </div>
 </div>
 <div id="postamble">
 <p class="author"> Author: Paul Sexton
 </p>
-<p class="date"> Date: 2010-09-17 10:05:27 </p>
-<p class="creator">HTML generated by org-mode 7.01trans in emacs 23</p>
+<p class="date"> Date: 2011-03-25 11:53:49 </p>
+<p class="creator">HTML generated by org-mode 7.4 in emacs 23</p>
 </div>
 </div>
 </body>
 
 When the user presses a key, the text "Tallinn" will become visible.
 
-Clozed text can also contain a "hint" about the answer. If the text 
+Clozed text can also contain a "hint" about the answer. If the text
 surrounded by single square brackets contains a `|' character (vertical bar),
 all text after that character is treated as a hint, and will be visible when
 the rest of the text is hidden.
 #+END_EXAMPLE
 
 #+BEGIN_QUOTE
-Type 1 hypersensitivity reactions are mediated by 
+Type 1 hypersensitivity reactions are mediated by
 @<font style="background-color: blue;" color="cyan">
 @<tt>[...molecule]@</tt>@</font>
 and @<font style="background-color: blue;" color="cyan">
 the woman
 
 ** Example sentence
-¿Quién fue esa mujer? 
+¿Quién fue esa mujer?
 Who was that woman?
 #+END_EXAMPLE
 
 
 The =multisided= card type is similar to =twosided=, except that any
 subheading has a chance of being presented during the topic review. One
-subheading is always shown and all others are always hidden. 
+subheading is always shown and all others are always hidden.
 
 #+BEGIN_EXAMPLE
 * Noun                                               :drill:
 'simple' card with all the facts marked as cloze text, like so:
 
 #+BEGIN_QUOTE
-The capital city of [New Zealand] is [Wellington], which is located in 
+The capital city of [New Zealand] is [Wellington], which is located in
 [the South Island] and has a population of about [400,000].
 #+END_QUOTE
 
 the South Island.
 
 * Fact
-The capital city of New Zealand is [Wellington], which is located in 
+The capital city of New Zealand is [Wellington], which is located in
 the South Island.
 
 * Fact
-The capital city of New Zealand is Wellington, which is located in 
+The capital city of New Zealand is Wellington, which is located in
 [the South Island].
 #+END_EXAMPLE
 
   :DRILL_CARD_TYPE: multicloze
   :END:
 
-The capital city of [New Zealand] is [Wellington], which is located in 
+The capital city of [New Zealand] is [Wellington], which is located in
 [the South Island] and has a population of about [400,000].
 #+END_EXAMPLE
 
 
 See the file [[file:spanish.org][spanish.org]] for a full set of example material.
 
+** Comments
+
+In org mode, comment lines start with '#'. The rest of the line is ignored by
+Org (apart from some special cases). You may sometimes want to put material in
+comments which you do not want to see when you are being tested on the
+item. For this reason, all comments are rendered invisible while items are
+being tested.
+
 
 * Running the drill session
 
 
 The best way to deal with a leech is either to delete it, or reformulate it so
 that it is easier to remember, for example by splitting it into more than one
-card. 
+card.
 
 See [[http://www.supermemo.com/help/leech.htm][the SuperMemo website]] for more on leeches.
 
 
 An example of using Org-Drill for incremental reading is given below. First,
 and most importantly, we need to define a couple of =org-capture= templates for
-captured facts. 
+captured facts.
 
 #+BEGIN_EXAMPLE
 (setq org-capture-templates
 sputum, fever, night sweats, and weight loss. Infection of other organs causes
 a wide range of symptoms. Treatment is difficult and requires long courses of
 multiple antibiotics. Antibiotic resistance is a growing problem in
-(extensively) multi-drug-resistant tuberculosis. 
+(extensively) multi-drug-resistant tuberculosis.
 @<font style="background-color: yellow;">Prevention relies
 on screening programs and vaccination, usually with Bacillus Calmette-Guérin
 vaccine.@</font>
 
 You can of course define browser buttons that use several different "fact"
 templates, each of which might send its fact to a different file or subheading,
-or give it different tags or properties, for example. 
+or give it different tags or properties, for example.
 
 
 * Still to do

apple.jpg

Old
Old image
New
New image
 ;;; org-drill.el - Self-testing with org-learn
 ;;;
 ;;; Author: Paul Sexton <eeeickythump@gmail.com>
-;;; Version: 1.6
+;;; Version: 1.7
 ;;; Repository at http://bitbucket.org/eeeickythump/org-drill/
 ;;;
 ;;;
                     face org-drill-hidden-cloze-face
                     window t))
 
+(setplist 'org-drill-hidden-comment-overlay
+          '(invisible t))
+
 
 (defvar org-drill-cloze-regexp
   ;; ver 1   "[^][]\\(\\[[^][][^]]*\\]\\)"
        (org-drill-unhide-clozed-text))))
 
 
+(defmacro with-hidden-comments (&rest body)
+  `(progn
+     (org-drill-hide-comments)
+     (unwind-protect
+         (progn
+           ,@body)
+       (org-drill-unhide-comments))))
+
+
 (defun org-drill-days-since-last-review ()
   "Nil means a last review date has not yet been stored for
 the item.
     (save-excursion
       (org-map-entries
        (lambda ()
-         (when (= (org-current-level) (1+ drill-entry-level))
+         (when (and (not (outline-invisible-p))
+                    (> (org-current-level) drill-entry-level))
            (setq drill-heading (org-get-heading t))
-           (unless (member drill-heading heading-list)
+           (unless (and (= (org-current-level) (1+ drill-entry-level))
+                        (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* ((item-start-time (current-time))
          (input nil)
     (org-in-regexp regexp nlines)))
 
 
+(defun org-drill-hide-comments ()
+  (save-excursion
+    (while (re-search-forward "^#.*$" nil t)
+      (org-drill-hide-comment))))
+
+
+(defun org-drill-hide-comment ()
+  "Hide the current match with a 'cloze' visual overlay."
+  (let ((ovl (make-overlay (match-beginning 0) (match-end 0))))
+    (overlay-put ovl 'category
+                 'org-drill-hidden-comment-overlay)))
+
+
+(defun org-drill-unhide-comments ()
+  (save-excursion
+    (dolist (ovl (overlays-in (point-min) (point-max)))
+      (when (eql 'org-drill-hidden-comment-overlay (overlay-get ovl 'category))
+        (delete-overlay ovl)))))
+
+
 (defun org-drill-hide-clozed-text ()
   (save-excursion
     (while (re-search-forward org-drill-cloze-regexp nil t)
 ;; recall, nil if they chose to quit.
 
 (defun org-drill-present-simple-card ()
-  (with-hidden-cloze-text
-   (org-drill-hide-all-subheadings-except nil)
-   (org-display-inline-images t)
-   (org-cycle-hide-drawers 'all)
-   (prog1 (org-drill-presentation-prompt)
-     (org-show-subtree))))
-
-
-(defun org-drill-present-two-sided-card ()
-  (with-hidden-cloze-text
-   (let ((drill-sections (org-drill-hide-all-subheadings-except nil)))
-     (when drill-sections
-       (save-excursion
-         (goto-char (nth (random (min 2 (length drill-sections)))
-                         drill-sections))
-         (org-show-subtree)))
-     (org-display-inline-images t)
-     (org-cycle-hide-drawers 'all)
-     (prog1
-         (org-drill-presentation-prompt)
-       (org-show-subtree)))))
-
-
-
-(defun org-drill-present-multi-sided-card ()
-  (with-hidden-cloze-text
-   (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)))
-     (org-display-inline-images t)
-     (org-cycle-hide-drawers 'all)
-     (prog1
-         (org-drill-presentation-prompt)
-       (org-show-subtree)))))
-
-
-(defun org-drill-present-multicloze ()
-  (let ((item-end nil)
-        (match-count 0)
-        (body-start (or (cdr (org-get-property-block))
-                        (point))))
+  (with-hidden-comments
+   (with-hidden-cloze-text
     (org-drill-hide-all-subheadings-except nil)
-    (save-excursion
-      (outline-next-heading)
-      (setq item-end (point)))
-    (save-excursion
-      (goto-char body-start)
-      (while (re-search-forward org-drill-cloze-regexp item-end t)
-        (incf match-count)))
-    (when (plusp match-count)
-      (save-excursion
-        (goto-char body-start)
-        (re-search-forward org-drill-cloze-regexp
-                           item-end t (1+ (random match-count)))
-        (org-drill-hide-matched-cloze-text)))
     (org-display-inline-images t)
     (org-cycle-hide-drawers 'all)
     (prog1 (org-drill-presentation-prompt)
-      (org-show-subtree)
-      (org-drill-unhide-clozed-text))))
+      (org-show-subtree)))))
+
+
+(defun org-drill-present-two-sided-card ()
+  (with-hidden-comments
+   (with-hidden-cloze-text
+    (let ((drill-sections (org-drill-hide-all-subheadings-except nil)))
+      (when drill-sections
+        (save-excursion
+          (goto-char (nth (random (min 2 (length drill-sections)))
+                          drill-sections))
+          (org-show-subtree)))
+      (org-display-inline-images t)
+      (org-cycle-hide-drawers 'all)
+      (prog1
+          (org-drill-presentation-prompt)
+        (org-show-subtree))))))
+
+
+
+(defun org-drill-present-multi-sided-card ()
+  (with-hidden-comments
+   (with-hidden-cloze-text
+    (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)))
+      (org-display-inline-images t)
+      (org-cycle-hide-drawers 'all)
+      (prog1
+          (org-drill-presentation-prompt)
+        (org-show-subtree))))))
+
+
+(defun org-drill-present-multicloze ()
+  (with-hidden-comments
+   (let ((item-end nil)
+         (match-count 0)
+         (body-start (or (cdr (org-get-property-block))
+                         (point))))
+     (org-drill-hide-all-subheadings-except nil)
+     (save-excursion
+       (outline-next-heading)
+       (setq item-end (point)))
+     (save-excursion
+       (goto-char body-start)
+       (while (re-search-forward org-drill-cloze-regexp item-end t)
+         (incf match-count)))
+     (when (plusp match-count)
+       (save-excursion
+         (goto-char body-start)
+         (re-search-forward org-drill-cloze-regexp
+                            item-end t (1+ (random match-count)))
+         (org-drill-hide-matched-cloze-text)))
+     (org-display-inline-images t)
+     (org-cycle-hide-drawers 'all)
+     (prog1 (org-drill-presentation-prompt)
+       (org-show-subtree)
+       (org-drill-unhide-clozed-text)))))
 
 
 (defun org-drill-present-spanish-verb ()
   (let ((prompt nil)
         (reveal-headings nil))
-    (with-hidden-cloze-text
-     (case (random 6)
-       (0
-        (org-drill-hide-all-subheadings-except '("Infinitive"))
-        (setq prompt
-              (concat "Translate this Spanish verb, and conjugate it "
-                      "for the *present* tense.")
-              reveal-headings '("English" "Present Tense" "Notes")))
-       (1
-        (org-drill-hide-all-subheadings-except '("English"))
-        (setq prompt (concat "For the *present* tense, conjugate the "
-                             "Spanish translation of this English verb.")
-              reveal-headings '("Infinitive" "Present Tense" "Notes")))
-       (2
-        (org-drill-hide-all-subheadings-except '("Infinitive"))
-        (setq prompt (concat "Translate this Spanish verb, and "
-                             "conjugate it for the *past* tense.")
-              reveal-headings '("English" "Past Tense" "Notes")))
-       (3
-        (org-drill-hide-all-subheadings-except '("English"))
-        (setq prompt (concat "For the *past* tense, conjugate the "
-                             "Spanish translation of this English verb.")
-              reveal-headings '("Infinitive" "Past Tense" "Notes")))
-       (4
-        (org-drill-hide-all-subheadings-except '("Infinitive"))
-        (setq prompt (concat "Translate this Spanish verb, and "
-                             "conjugate it for the *future perfect* tense.")
-              reveal-headings '("English" "Future Perfect Tense" "Notes")))
-       (5
-        (org-drill-hide-all-subheadings-except '("English"))
-        (setq prompt (concat "For the *future perfect* tense, conjugate the "
-                             "Spanish translation of this English verb.")
-              reveal-headings '("Infinitive" "Future Perfect Tense" "Notes"))))
-     (org-cycle-hide-drawers 'all)
-     (prog1
-         (org-drill-presentation-prompt prompt)
-       (org-drill-hide-all-subheadings-except reveal-headings)))))
+    (with-hidden-comments
+     (with-hidden-cloze-text
+      (case (random 6)
+        (0
+         (org-drill-hide-all-subheadings-except '("Infinitive"))
+         (setq prompt
+               (concat "Translate this Spanish verb, and conjugate it "
+                       "for the *present* tense.")
+               reveal-headings '("English" "Present Tense" "Notes")))
+        (1
+         (org-drill-hide-all-subheadings-except '("English"))
+         (setq prompt (concat "For the *present* tense, conjugate the "
+                              "Spanish translation of this English verb.")
+               reveal-headings '("Infinitive" "Present Tense" "Notes")))
+        (2
+         (org-drill-hide-all-subheadings-except '("Infinitive"))
+         (setq prompt (concat "Translate this Spanish verb, and "
+                              "conjugate it for the *past* tense.")
+               reveal-headings '("English" "Past Tense" "Notes")))
+        (3
+         (org-drill-hide-all-subheadings-except '("English"))
+         (setq prompt (concat "For the *past* tense, conjugate the "
+                              "Spanish translation of this English verb.")
+               reveal-headings '("Infinitive" "Past Tense" "Notes")))
+        (4
+         (org-drill-hide-all-subheadings-except '("Infinitive"))
+         (setq prompt (concat "Translate this Spanish verb, and "
+                              "conjugate it for the *future perfect* tense.")
+               reveal-headings '("English" "Future Perfect Tense" "Notes")))
+        (5
+         (org-drill-hide-all-subheadings-except '("English"))
+         (setq prompt (concat "For the *future perfect* tense, conjugate the "
+                              "Spanish translation of this English verb.")
+               reveal-headings '("Infinitive" "Future Perfect Tense" "Notes"))))
+      (org-cycle-hide-drawers 'all)
+      (prog1
+          (org-drill-presentation-prompt prompt)
+        (org-drill-hide-all-subheadings-except reveal-headings))))))
 
 
 

spanish.org

File contents unchanged.