diff options
| author | Phillip Lord <phillip.lord@russet.org.uk> | 2019-06-17 17:42:16 +0100 |
|---|---|---|
| committer | Phillip Lord <phillip.lord@russet.org.uk> | 2019-06-17 17:42:16 +0100 |
| commit | 9fa9b6eabf0372538a88819c1f9ff26c30102aaa (patch) | |
| tree | 07fdc23949e97cd168db4a7366307d690cce1789 | |
| parent | d37519f54c903bc51377a261c070cb0e0987fbc5 (diff) | |
| download | org-drill-9fa9b6eabf0372538a88819c1f9ff26c30102aaa.tar.gz org-drill-9fa9b6eabf0372538a88819c1f9ff26c30102aaa.zip | |
Robot test all card types
Fix multiple missing session parameters.
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | org-drill.el | 76 | ||||
| -rw-r--r-- | robot/all-card-run.el | 11 | ||||
| -rwxr-xr-x | robot/all-card-run.sh | 44 | ||||
| -rw-r--r-- | robot/all-card.org | 133 |
6 files changed, 223 insertions, 46 deletions
@@ -8,3 +8,4 @@ org-drill.html /robot/messages.txt /robot/main-test-copy.org~ /robot/main-test-interactive-copy.org +/robot/all-card-copy.org @@ -39,4 +39,8 @@ basic-robot-test: $(CASK) clean-elc $(EMACS_ENV) ./robot/basic-run.sh +all-card-robot-test: + $(CASK) clean-elc + $(EMACS_ENV) ./robot/all-card-run.sh + .PHONY: test diff --git a/org-drill.el b/org-drill.el index 3c55062..83adc9f 100644 --- a/org-drill.el +++ b/org-drill.el @@ -727,23 +727,6 @@ regardless of whether the test was successful.") value." `(setq ,place (append ,place (list ,val)))) - -(defun shuffle-list (list) - "Randomly permute the elements of LIST (all permutations equally likely)." - ;; Adapted from 'shuffle-vector' in cookie1.el - (let ((i 0) - j - temp - (len (length list))) - (while (< i len) - (setq j (+ i (cl-random (- len i)))) - (setq temp (nth i list)) - (setf (nth i list) (nth j list)) - (setf (nth j list) temp) - (setq i (1+ i)))) - list) - - (defun round-float (floatnum fix) "Round the floating point number FLOATNUM to FIX decimal places. Example: (round-float 3.56755765 3) -> 3.568" @@ -2204,7 +2187,7 @@ Note: does not actually alter the item." -(defun org-drill-present-multi-sided-card () +(defun org-drill-present-multi-sided-card (session) (with-hidden-comments (with-hidden-cloze-hints (with-hidden-cloze-text @@ -2262,9 +2245,10 @@ items if FORCE-SHOW-FIRST or FORCE-SHOW-LAST is non-nil)." (if (cl-minusp number-to-hide) (setq number-to-hide (+ match-count number-to-hide))) (when (cl-plusp match-count) - (let* ((positions (shuffle-list (loop for i from 1 - to match-count - collect i))) + (let* ((positions (org-drill-shuffle + (cl-loop for i from 1 + to match-count + collect i))) (match-nums nil) (cnt nil)) (if force-hide-first @@ -2305,7 +2289,7 @@ items if FORCE-SHOW-FIRST or FORCE-SHOW-LAST is non-nil)." (org-drill-unhide-clozed-text)))))) -(defun org-drill-present-multicloze-hide-nth (to-hide) +(defun org-drill-present-multicloze-hide-nth (session to-hide) "Hide the TO-HIDE'th piece of clozed text. 1 is the first piece. If TO-HIDE is negative, count backwards, so -1 means the last item, -2 the second to last, etc." @@ -2359,29 +2343,29 @@ the second to last, etc." (org-drill-unhide-clozed-text)))))) -(defun org-drill-present-multicloze-hide1 () +(defun org-drill-present-multicloze-hide1 (session) "Hides one of the pieces of text that are marked for cloze deletion, chosen at random." - (org-drill-present-multicloze-hide-n 1)) + (org-drill-present-multicloze-hide-n session 1)) -(defun org-drill-present-multicloze-hide2 () +(defun org-drill-present-multicloze-hide2 (session) "Hides two of the pieces of text that are marked for cloze deletion, chosen at random." - (org-drill-present-multicloze-hide-n 2)) + (org-drill-present-multicloze-hide-n session 2)) -(defun org-drill-present-multicloze-hide-first () +(defun org-drill-present-multicloze-hide-first (session) "Hides the first piece of text that is marked for cloze deletion." - (org-drill-present-multicloze-hide-nth 1)) + (org-drill-present-multicloze-hide-nth session 1)) -(defun org-drill-present-multicloze-hide-last () +(defun org-drill-present-multicloze-hide-last (session) "Hides the last piece of text that is marked for cloze deletion." - (org-drill-present-multicloze-hide-nth -1)) + (org-drill-present-multicloze-hide-nth session -1)) -(defun org-drill-present-multicloze-hide1-firstmore () +(defun org-drill-present-multicloze-hide1-firstmore (session) "Commonly, hides the FIRST piece of text that is marked for cloze deletion. Uncommonly, hide one of the other pieces of text, chosen at random. @@ -2405,13 +2389,13 @@ the value of `org-drill-cloze-text-weight'." ((zerop (mod (1+ (org-drill-entry-total-repeats 0)) org-drill-cloze-text-weight)) ;; Uncommonly, hide any item except the first - (org-drill-present-multicloze-hide-n 1 t)) + (org-drill-present-multicloze-hide-n session 1 t)) (t ;; Commonly, hide first item - (org-drill-present-multicloze-hide-first)))) + (org-drill-present-multicloze-hide-first session)))) -(defun org-drill-present-multicloze-show1-lastmore () +(defun org-drill-present-multicloze-show1-lastmore (session) "Commonly, hides all pieces except the last. Uncommonly, shows any random piece. The effect is similar to 'show1cloze' except that the last item is much less likely to be the item that is @@ -2430,13 +2414,13 @@ the value of `org-drill-cloze-text-weight'." ((zerop (mod (1+ (org-drill-entry-total-repeats 0)) org-drill-cloze-text-weight)) ;; Uncommonly, show any item except the last - (org-drill-present-multicloze-hide-n -1 nil nil t)) + (org-drill-present-multicloze-hide-n session -1 nil nil t)) (t ;; Commonly, show the LAST item - (org-drill-present-multicloze-hide-n -1 nil t)))) + (org-drill-present-multicloze-hide-n session -1 nil t)))) -(defun org-drill-present-multicloze-show1-firstless () +(defun org-drill-present-multicloze-show1-firstless (session) "Commonly, hides all pieces except one, where the shown piece is guaranteed NOT to be the first piece. Uncommonly, shows any random piece. The effect is similar to 'show1cloze' except that @@ -2456,23 +2440,23 @@ the value of `org-drill-cloze-text-weight'." ((zerop (mod (1+ (org-drill-entry-total-repeats 0)) org-drill-cloze-text-weight)) ;; Uncommonly, show the first item - (org-drill-present-multicloze-hide-n -1 t)) + (org-drill-present-multicloze-hide-n session -1 t)) (t ;; Commonly, show any item, except the first - (org-drill-present-multicloze-hide-n -1 nil nil t)))) + (org-drill-present-multicloze-hide-n session -1 nil nil t)))) -(defun org-drill-present-multicloze-show1 () +(defun org-drill-present-multicloze-show1 (session) "Similar to `org-drill-present-multicloze-hide1', but hides all the pieces of text that are marked for cloze deletion, except for one piece which is chosen at random." - (org-drill-present-multicloze-hide-n -1)) + (org-drill-present-multicloze-hide-n session -1)) -(defun org-drill-present-multicloze-show2 () +(defun org-drill-present-multicloze-show2 (session) "Similar to `org-drill-present-multicloze-show1', but reveals two pieces rather than one." - (org-drill-present-multicloze-hide-n -2)) + (org-drill-present-multicloze-hide-n session -2)) (defun org-drill-present-card-using-text (session question &optional answer) @@ -2731,7 +2715,7 @@ RESUMING-P is true if we are resuming a suspended drill session." ((<= result org-drill-failure-quality) (if (oref session again-entries) (setf (oref session again-entries) - (shuffle-list (oref session again-entries)))) + (org-drill-shuffle (oref session again-entries)))) (push-end m (oref session again-entries))) (t (push m (oref session done-entries)))) @@ -2866,7 +2850,7 @@ all the markers used by Org-Drill will be freed." (setf (oref session overdue-entries) (mapcar 'first (append - (sort (shuffle-list not-lapsed) + (sort (org-drill-shuffle not-lapsed) (lambda (a b) (> (cl-second a) (cl-second b)))) (sort lapsed (lambda (a b) (> (cl-third a) (cl-third b))))))))) @@ -3894,7 +3878,7 @@ Returns a list of strings." (defun org-drill-shuffle (LIST) "Shuffle the elements in LIST. shuffling is done in place." - (loop for i in (reverse (number-sequence 1 (1- (length LIST)))) + (cl-loop for i in (reverse (number-sequence 1 (1- (length LIST)))) do (let ((j (random (+ i 1)))) (org-drill-swap LIST i j))) LIST) diff --git a/robot/all-card-run.el b/robot/all-card-run.el new file mode 100644 index 0000000..cfc27a8 --- /dev/null +++ b/robot/all-card-run.el @@ -0,0 +1,11 @@ +(load-file "robot/robot.el") +(load-file "org-drill.el") + +(copy "all-card.org" "all-card-copy.org") +(find "all-card-copy.org") + +(org-drill) + +(robot-check-cards-seen-and-die + (string-to-number + (car command-line-args-left))) diff --git a/robot/all-card-run.sh b/robot/all-card-run.sh new file mode 100755 index 0000000..8ca247c --- /dev/null +++ b/robot/all-card-run.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +set -e + +this_dir="$(dirname "$0")" +source $this_dir/robot.sh + + +card_no=12 +small_sleep=0.1 + + +function run_drill { + ## Org-drill should be running at this point, so give three answers + ## with a score of file + sleep_big + + for i in `seq 1 $card_no`; + do + echo Answer: $i + send_answer + done + + ## Press any key to continue + echo press any key to continue + retn + sleep_small + + echo Save file + key y +} + +launch_emacs $this_dir/all-card-run.el $card_no + +{ + sleep 2 + find_bot + + ## Run once with default options + run_drill + + + wait_emacs +} || cat robot/failure.txt diff --git a/robot/all-card.org b/robot/all-card.org new file mode 100644 index 0000000..c056287 --- /dev/null +++ b/robot/all-card.org @@ -0,0 +1,133 @@ + +* Simple Topic :drill: + +This is the simple topic body + +** Answer + +This is the simple topic body answer + + +* Simple Clozed :drill: + +This is the [clozed] text + +* Clozed Text Hints :drill: + +This is [clozed||with a text hint] + +* Two Sided :drill: + :PROPERTIES: + :DRILL_CARD_TYPE: twosided + :END: + +This is the two sided body + +** First Side + +This is the first side of the two side + +** Second Second + +This is the other side of the two side + +** Answer + +This shows the answer + + +* Multi-sided Card :drill: + :PROPERTIES: + :DRILL_CARD_TYPE: multisided + :END: + +This is the body of the multisided + +** Side One + +This is the first body of the multisided + +** Side Two + +This is the second body of the multisided + +** Side Three + +This is the third body of the multisided + + +* Multi-cloze + +There are lots of multicloze types + +** hide1cloze :drill: + :PROPERTIES: + :DRILL_CARD_TYPE: hide1cloze + :END: + +This is the body of a multiclozed card: +[one][two][three][four][five][six] + +hide1cloze + + +** show1cloze :drill: + :PROPERTIES: + :DRILL_CARD_TYPE: show1cloze + :END: + +This is the body of a multiclozed card: +[one][two][three][four][five][six] + +show1cloze + +** hide2cloze :drill: + :PROPERTIES: + :DRILL_CARD_TYPE: hide2cloze + :END: + +This is the body of a multiclozed card: +[one][two][three][four][five][six] + +hide2cloze + +** show2cloze :drill: + :PROPERTIES: + :DRILL_CARD_TYPE: show2cloze + :END: + +This is the body of a multiclozed card: +[one][two][three][four][five][six] + +show2cloze + +** hide1_firstmore :drill: + :PROPERTIES: + :DRILL_CARD_TYPE: hide1_firstmore + :END: + +This is the body of a multiclozed card: +[one][two][three][four][five][six] + +hide1_firstmore + +** show1_firstless :drill: + :PROPERTIES: + :DRILL_CARD_TYPE: show1_firstless + :END: + +This is the body of a multiclozed card: +[one][two][three][four][five][six] + +show1_firstless + +** show1_lastmore :drill: + :PROPERTIES: + :DRILL_CARD_TYPE: show1_lastmore + :END: + +This is the body of a multiclozed card: +[one][two][three][four][five][six] + +show1_lastmore + |
