Represents one study direction generated from an AnkiNote. More...
Public Member Functions | |
| AnkiCard (long id, long noteId, long deckId, int templateOrdinal, AnkiScheduling scheduling) | |
| Initializes an unattached card for an importer or format adapter. | |
Properties | |
| long | Id [get] |
| Gets the persisted identity Anki uses to distinguish this card from every other card. | |
| long | NoteId [get] |
| Gets the ID of the note whose fields and template render this card. | |
| long | DeckId [get, set] |
| Gets or sets the deck in which Anki should place this individual card. | |
| int | TemplateOrdinal [get] |
| Gets which template or Cloze deletion generated this card. | |
| AnkiScheduling | Scheduling [get, set] |
| Gets or replaces the complete persisted scheduler state for this card. | |
| int | Flag [get, set] |
| Gets or sets the single user-visible color flag attached to this card. | |
| IList< AnkiReviewLog > | ReviewHistory = new List<AnkiReviewLog>() [get] |
| Gets answer events associated with this card. | |
Represents one study direction generated from an AnkiNote.
A note stores facts; a card is the question/answer view Anki schedules. A Basic note normally owns one card, a Basic-and-reversed note owns two, and a Cloze note owns one card per distinct positive cloze index. Most callers should obtain cards from AnkiNote.Cards after adding a note to a deck instead of constructing cards directly.
DeckId, Scheduling, Flag, and ReviewHistory are mutable advanced state. AnkiIO does not run Anki's scheduler; it only models and validates persisted values. Call AnkiValidator.Validate(AnkiDeck) before export. Instances and their history lists are not thread-safe.
Definition at line 23 of file AnkiCard.cs.
|
inline |
Initializes an unattached card for an importer or format adapter.
| id | The persisted card ID. It must be unique across the exported graph. |
| noteId | The ID of the note that generated this card. |
| deckId | The ID of the deck in which Anki should place this card. |
| templateOrdinal | For a standard note type, the zero-based index in AnkiNoteType.Templates. For Cloze, cloze marker c1 maps to ordinal 0, c2 to ordinal 1, and so on. |
| scheduling | Non-null persisted scheduler state. Use AnkiScheduling.New unless importing verified existing state. The object is retained by reference rather than copied. |
This constructor does not attach the card to a note or deck. Ordinary creation through AnkiDeck.AddNote establishes those relationships and assigns safe new-card scheduling automatically.
| ArgumentOutOfRangeException | templateOrdinal is negative. |
| ArgumentNullException | scheduling is null. |
Definition at line 45 of file AnkiCard.cs.
|
getset |
Gets or sets the deck in which Anki should place this individual card.
A deck ID, normally the ID of the deck that owns the note.
Anki permits sibling cards from one note to live in different decks. Changing this value models that placement; it does not move the note between AnkiDeck.Notes collections or create a missing deck. Validate the complete graph before export so the referenced deck can be checked.
Definition at line 75 of file AnkiCard.cs.
|
getset |
Gets or sets the single user-visible color flag attached to this card.
Anki's numeric flag code; valid persisted values are 0 through 7 and a new card starts at 0.
Flags are card-level reminders shown during review and in the browser; unlike note tags, flagging one sibling does not flag the others. Anki lets users rename flag labels, but the persisted numeric/color mapping remains:
| Value | Default flag |
|---|---|
| 0 | No flag |
| 1 | Red |
| 2 | Orange |
| 3 | Green |
| 4 | Blue |
| 5 | Pink |
| 6 | Turquoise |
| 7 | Purple |
The legacy card column stores the flag in its low three bits. The setter deliberately accepts an int so importers can represent malformed source data and obtain a complete diagnostic report; it does not silently mask high bits. AnkiValidator.Validate(AnkiDeck) reports ANKI032 for values outside 0-7, and validated writers refuse to export that graph. Validate after assigning imported state.
Use tags when an annotation should apply to every card generated by a note or when multiple labels are needed; a card can have only one flag.
Definition at line 127 of file AnkiCard.cs.
|
get |
Gets the persisted identity Anki uses to distinguish this card from every other card.
The fixed ID supplied by an importer or generated by AnkiIO.
Preserve this value during updates so Anki can recognize the same card. Supplying explicit IDs makes collision avoidance the caller's responsibility; AnkiValidator reports duplicate card IDs in a deck graph.
Definition at line 62 of file AnkiCard.cs.
|
get |
Gets the ID of the note whose fields and template render this card.
A fixed note ID that should match an AnkiNote.Id in the same object graph.
Definition at line 66 of file AnkiCard.cs.
|
get |
Gets answer events associated with this card.
A live mutable list owned by the card; append records in chronological or persisted ID order.
Native AnkiIO JSON preserves this list and the legacy package writer emits it. The current legacy APKG reader does not reconstruct existing review-log rows, so APKG read-modify-write is not a lossless history migration. Adding a log does not update Scheduling automatically, and changing scheduling does not synthesize a log. Treat both as advanced imported state and keep them consistent yourself.
Definition at line 137 of file AnkiCard.cs.
|
getset |
Gets or replaces the complete persisted scheduler state for this card.
A non-null immutable value object; generated cards start with AnkiScheduling.New.
Replace this only when importing or deliberately preserving known scheduling data. Queue/type combinations and the units of AnkiScheduling.Due vary by state. AnkiIO validates combinations but does not calculate the next interval, apply deck options, or run FSRS.
| ArgumentNullException | The assigned value is null. |
Definition at line 95 of file AnkiCard.cs.
|
get |
Gets which template or Cloze deletion generated this card.
A fixed zero-based template index for standard notes, or one less than the positive Cloze index for Cloze notes.
For example, the second template and {{c2::answer}} both use ordinal 1. An ordinal outside the note type's available templates or current cloze indexes represents stale/corrupt state and is rejected by validation.
Definition at line 85 of file AnkiCard.cs.