Skip to content

Commit

Permalink
Add no-op spacing algorithm for use in org-fc-demo
Browse files Browse the repository at this point in the history
  • Loading branch information
l3kn committed Mar 11, 2024
1 parent dd71e87 commit 0163a79
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 51 deletions.
66 changes: 36 additions & 30 deletions demo.org
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#+TITLE: Org-Flashcards Demo File
#+FILETAGS: fc-demo

* Normal Card :fc:
:PROPERTIES:
:ID: 9f80ab65-dbff-41b3-902f-0e8e177debbe
:FC_CREATED: 2000-01-01T00:00:00Z
:FC_TYPE: normal
:FC_ALGO: noop
:END:
:REVIEW_DATA:
| position | ease | box | interval | due |
|----------+------+-----+----------+----------------------|
| front | 2.5 | 0 | 0 | 2000-01-01T00:00:00Z |
| position | due |
|----------+----------------------|
| front | 2000-01-01T00:00:00Z |
:END:

Welcome to the org-fc demo!
Expand Down Expand Up @@ -46,12 +46,13 @@ Give it one of these ratings to continue to the next card.
:PROPERTIES:
:FC_CREATED: 2000-01-01T00:00:00Z
:FC_TYPE: normal
:FC_ALGO: noop
:ID: af18545c-e87c-48a2-9df3-9483cfcec7f6
:END:
:REVIEW_DATA:
| position | ease | box | interval | due |
|----------+------+-----+----------+----------------------|
| front | 2.5 | 0 | 0 | 2000-01-01T00:00:00Z |
| position | due |
|----------+----------------------|
| front | 2000-01-01T00:00:00Z |
:END:

Cards in this format are great for simple question-answer pairs.
Expand All @@ -77,12 +78,13 @@ Rate this card to continue see an example for such a compact card.
:PROPERTIES:
:FC_CREATED: 2000-01-01T00:00:00Z
:FC_TYPE: normal
:FC_ALGO: noop
:ID: 9ecfadf9-2823-49d6-a65c-cca19d0c4a4c
:END:
:REVIEW_DATA:
| position | ease | box | interval | due |
|----------+------+-----+----------+----------------------|
| front | 2.5 | 0 | 0 | 2000-01-01T00:00:00Z |
| position | due |
|----------+----------------------|
| front | 2000-01-01T00:00:00Z |
:END:

This card uses the *compact* style.
Expand All @@ -95,13 +97,14 @@ contains a definition.
:PROPERTIES:
:FC_CREATED: 2000-01-01T00:00:00Z
:FC_TYPE: double
:FC_ALGO: noop
:ID: 855253c7-ed09-4b7c-a878-b7b890d140c2
:END:
:REVIEW_DATA:
| position | ease | box | interval | due |
|----------+------+-----+----------+----------------------|
| front | 2.5 | 0 | 0 | 2000-01-01T00:00:00Z |
| back | 2.5 | 0 | 0 | 2000-01-01T00:00:00Z |
| position | due |
|----------+----------------------|
| front | 2000-01-01T00:00:00Z |
| back | 2000-01-01T00:00:00Z |
:END:

For other kinds of knowledge, we'd like to learn not just one
Expand Down Expand Up @@ -135,33 +138,35 @@ exclude reviews of the same card from the current review session.
:ID: 2ffc8b34-b2b5-4472-9295-714b5422679d
:FC_CREATED: 2021-11-30T01:46:02Z
:FC_TYPE: cloze
:FC_ALGO: noop
:FC_CLOZE_MAX: 1
:FC_CLOZE_TYPE: deletion
:END:
:REVIEW_DATA:
| position | ease | box | interval | due |
|----------+------+-----+----------+----------------------|
| 0 | 2.5 | 0 | 0 | 2021-11-30T01:46:02Z |
| 1 | 2.5 | 0 | 0 | 2021-11-30T01:46:02Z |
| 2 | 2.5 | 0 | 0 | 2021-11-30T01:46:02Z |
| position | due |
|----------+----------------------|
| 0 | 2000-01-01T00:00:00Z |
| 1 | 2000-01-01T00:00:00Z |
| 2 | 2000-01-01T00:00:00Z |
:END:
A {{cloze deletion}@0} can have multiple {{holes}@1}. And each hole can
have {{hints}{Synonym for suggestion}@2} too.
* Cloze Enumeration :fc:
:PROPERTIES:
:FC_CREATED: 2000-01-01T00:00:00Z
:FC_TYPE: cloze
:FC_ALGO: noop
:ID: 5eac5801-0ef5-4957-a818-e3f9f08a7d59
:FC_CLOZE_MAX: 3
:FC_CLOZE_TYPE: enumeration
:END:
:REVIEW_DATA:
| position | ease | box | interval | due |
|----------+------+-----+----------+----------------------|
| 0 | 2.50 | 6 | 80.76 | 2000-01-01T00:00:00Z |
| 1 | 2.50 | 6 | 72.76 | 2000-01-01T00:00:00Z |
| 2 | 2.50 | 6 | 91.28 | 2000-01-01T00:00:00Z |
| 3 | 2.50 | 6 | 95.75 | 2000-01-01T00:00:00Z |
| position | due |
|----------+----------------------|
| 0 | 2000-01-01T00:00:00Z |
| 1 | 2000-01-01T00:00:00Z |
| 2 | 2000-01-01T00:00:00Z |
| 3 | 2000-01-01T00:00:00Z |
:END:

Enumerations are useful for
Expand All @@ -174,16 +179,17 @@ Enumerations are useful for
:PROPERTIES:
:FC_CREATED: 2000-01-01T00:00:00Z
:FC_TYPE: cloze
:FC_ALGO: noop
:FC_CLOZE_MAX: 2
:FC_CLOZE_TYPE: single
:ID: ae675e11-e003-4057-b6b1-1f4702837502
:END:
:REVIEW_DATA:
| position | ease | box | interval | due |
|----------+------+-----+----------+----------------------|
| 0 | 2.50 | 3 | 6.00 | 2000-01-01T00:00:00Z |
| 1 | 2.50 | 2 | 1.00 | 2000-01-01T00:00:00Z |
| 2 | 2.50 | 3 | 6.00 | 2000-01-01T00:00:00Z |
| position | due |
|----------+----------------------|
| 0 | 2000-01-01T00:00:00Z |
| 1 | 2000-01-01T00:00:00Z |
| 2 | 2000-01-01T00:00:00Z |
:END:
#+begin_src awk
# Set up variables for new file
Expand Down
44 changes: 44 additions & 0 deletions org-fc-algo-noop.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
;;; org-fc-algo-noop.el --- No-op spacing algorithm -*- lexical-binding: t; -*-

;; Copyright (C) 2024-2024 Leon Rische

;; Author: Leon Rische <[email protected]>

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:
;;
;; A no-op scheduling algorithm that logs no history entries
;; and doesn't update the review data or due date of a card.
;;
;; Ideally positions using this algorithm would not even have a
;; due-date but for now, org-fc assumes that every position has a
;; due-date it can use for scheduling cards to review.
;;
;;; Code:

(defclass org-fc-algo-noop (eieio-singleton org-fc-algo) ())

(cl-defmethod org-fc-algo-headers ((_algo org-fc-algo-noop))
'())

(cl-defmethod org-fc-algo-update-review-data
((algo org-fc-algo-noop)
(_position org-fc-position)
_rating _delta)
"Don't do anything, the card will remain due.")

(org-fc-register-algo 'noop org-fc-algo-noop)

;;; org-fc-algo-noop.el ends here
8 changes: 0 additions & 8 deletions org-fc-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,6 @@ Used to generate absolute paths to the awk scripts.")
:type 'string
:group 'org-fc)

(defcustom org-fc-demo-tag "fc-demo"
"Tag for marking headlines as demo flashcards.
When demo flashcards are reviewed, their review data is not
updated. This is used for the `org-fc-demo' and for testing card
types."
:type 'string
:group 'org-fc)

(defcustom org-fc-drawer-whitelist '()
"Drawers that are not hidden during review."
:type 'list
Expand Down
7 changes: 2 additions & 5 deletions org-fc-review.el
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,8 @@ POSITION.
RATING is a review rating and DELTA the time in seconds between
showing and rating the card."
(org-fc-with-point-at-entry
;; If the card is marked as a demo card, don't log its reviews and
;; don't update its review data
(unless (member org-fc-demo-tag (org-get-tags))
(let ((algo (oref (oref position card) algo)))
(org-fc-algo-update-review-data algo position rating delta)))))
(let ((algo (oref (oref position card) algo)))
(org-fc-algo-update-review-data algo position rating delta))))

(defun org-fc-review-reset ()
"Reset the buffer to its state before the review."
Expand Down
1 change: 1 addition & 0 deletions org-fc.el
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
(require 'org-fc-compat)

(require 'org-fc-awk)
(require 'org-fc-algo-none)
(require 'org-fc-algo-sm2)

(require 'org-fc-review-data)
Expand Down
8 changes: 4 additions & 4 deletions tests/index/test.org
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ body
:PROPERTIES:
:FC_CREATED: 2020-07-08T12:18:45Z
:FC_TYPE: normal
:FC_ALGO: sm2
:FC_ALGO: noop
:ID: a7ed2686-73e6-4780-825d-78cf4b2e5374
:END:
:REVIEW_DATA:
| position | ease | box | interval | due |
|----------+------+-----+----------+----------------------|
| front | 2.5 | 0 | 0 | 2020-07-08T12:18:46Z |
| position | due |
|----------+----------------------|
| front | 2020-07-08T12:18:46Z |
:END:
body
9 changes: 5 additions & 4 deletions tests/org-fc-indexer-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,20 @@
(org-fc-test-fixture "index/lowercase.org")))))

(ert-deftest org-fc-test-index ()
(let ((algo (org-fc-algo-sm2)))
(let ((algo-sm2 (org-fc-algo-sm2))
(algo-noop (org-fc-algo-noop)))
(org-fc-test-check-structure
`((:cards
((:id "edee8940-5c9a-4c70-b1c4-f45c194c0c97"
:tags ("fc" "tag1")
:title "Headline"
:algo ,algo)
:algo ,algo-sm2)
(:id "59b3b102-aebd-44ba-a1fd-6dc912c34fcf"
:tags ("fc" "tag2")
:title "Headline 2"
:algo ,algo)
:algo ,algo-sm2)
(:id "a7ed2686-73e6-4780-825d-78cf4b2e5374"
:tags ("fc" "tag3")
:title "Headline 3:not_a_tag:"
:algo ,algo))))
:algo ,algo-noop))))
(org-fc-awk-index (list (org-fc-test-fixture "index/test.org"))))))

0 comments on commit 0163a79

Please sign in to comment.