[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-drill 9fa9b6eabf 148/251: Robot test all card types
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/org-drill 9fa9b6eabf 148/251: Robot test all card types |
Date: |
Mon, 17 Jan 2022 18:59:10 -0500 (EST) |
branch: elpa/org-drill
commit 9fa9b6eabf0372538a88819c1f9ff26c30102aaa
Author: Phillip Lord <phillip.lord@russet.org.uk>
Commit: Phillip Lord <phillip.lord@russet.org.uk>
Robot test all card types
Fix multiple missing session parameters.
---
.gitignore | 1 +
Makefile | 4 ++
org-drill.el | 76 ++++++++++++-----------------
robot/all-card-run.el | 11 +++++
robot/all-card-run.sh | 44 +++++++++++++++++
robot/all-card.org | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 223 insertions(+), 46 deletions(-)
diff --git a/.gitignore b/.gitignore
index 516ac3fac2..325f62e158 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/Makefile b/Makefile
index b5da6388fb..4d4e86e00d 100644
--- a/Makefile
+++ b/Makefile
@@ -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 3c550624b4..83adc9fa15 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 0000000000..cfc27a826f
--- /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 0000000000..8ca247c40a
--- /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 0000000000..c056287119
--- /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
+
- [nongnu] elpa/org-drill d9ffa4b91f 104/251: Add support for typing in buffer input, (continued)
- [nongnu] elpa/org-drill d9ffa4b91f 104/251: Add support for typing in buffer input, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 45e92eca74 109/251: Add org-drill-cram-tree function, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill ef79a22735 111/251: Add explain support, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill ef9bad812c 112/251: Explain tags now inherit, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 6959903b99 113/251: Explain status of fork, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 507daae5a2 128/251: Remove org-drill-session-qualities, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 0e89d9a638 134/251: Remove more variables, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill a803289de9 137/251: Remove last of earmuff variables, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill df13d89a4c 119/251: Add interactive test functions, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill d37519f54c 147/251: Clean up robot testing, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 9fa9b6eabf 148/251: Robot test all card types,
ELPA Syncer <=
- [nongnu] elpa/org-drill 500d1475c3 120/251: Add count entries test, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill c1c57adea9 133/251: Remove dormant-entry-count, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill a923ba2c90 145/251: Move exit-kind to slot, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 9555e487d4 143/251: Fix presentation-in-buffer, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 0286de5402 139/251: Remove unneed form, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill ba0a346583 125/251: Removed generated file, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill ffc04493f8 136/251: Remove more variables, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill d47080e3bc 121/251: Remove generated file, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill fd3efa233e 127/251: Port to cl-lib, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill c49af4a9b3 155/251: Replace more non-namespaced commands, ELPA Syncer, 2022/01/17