Commit graph

650 commits

Author SHA1 Message Date
Damien Elmes
942bf43b52 fix stats
they're running now, but need to be sanity checked to make sure they're doing the right thing
2011-04-28 09:23:57 +09:00
Damien Elmes
4477e21369 make sure we load css on model init 2011-04-28 09:23:57 +09:00
Damien Elmes
2c545cfb1d drop data from renderQA 2011-04-28 09:23:57 +09:00
Damien Elmes
45d1b788ea optimize card q/a generation and model fetching 2011-04-28 09:23:57 +09:00
Damien Elmes
c63b4085c6 add queueless counts; fix special field references on upgrade 2011-04-28 09:23:57 +09:00
Damien Elmes
4e989d98a9 add switch to disable groups without forgetting the selection 2011-04-28 09:23:57 +09:00
Damien Elmes
31a548ee42 add a dirty flag
when we make changes that need to be cleaned up on exit, we mark the deck
dirty so that if we exit without saving, we can clean up on next open
2011-04-28 09:23:57 +09:00
Damien Elmes
ed75e4bee2 refactor cloze deletions and text:field, add forecast
Previously cloze deletions were handled by copying the contents of one field
into another and applying transforms to it. This had a number of problems:
- after you add a card, you can't undo the cloze deletion
- if you spot a mistake, you have to edit it twice (or more if you have more
  than one cloze for a sentence)
- making multiple clozes requires copying & pasting the sentence multiple
  times
- this also lead to much bigger decks if the sentences being cloze-deleted are
  large
- related clozes can't be spaced apart as siblings

To address these issues, we introduce the idea of cloze tags in the card
template and fields. If the template has the text:

{{cloze:1:field}}

And a field has the following contents:

{{c1::hello}}

Then the template will automatically replace that part of the text with either
occluded text, or a highlighted answer. All other clozes in the field are
displayed normally.

At the same time, we add support for text: into the template library, instead
of manually creating text: fields in the dict for every field.

Finally, add a forecast routine to get the due counts for the next week, which
is used in the GUI.
2011-04-28 09:23:56 +09:00
Damien Elmes
8705085200 update latex support 2011-04-28 09:23:56 +09:00
Damien Elmes
eb18460945 save creation time in deck flush, update cutoff on reset not deck load 2011-04-28 09:23:56 +09:00
Damien Elmes
ccc325f87b remove utcOffset; make it a property of crt instead 2011-04-28 09:23:56 +09:00
Damien Elmes
138d9881d3 add the ability to limit a cram to a given period 2011-04-28 09:23:56 +09:00
Damien Elmes
be045d451c remove the media table
The media table was originally introduced when Anki hashed media filenames,
and needed a way to remember the original filename. It also helped with:
1) getting a quick list of all media used in the deck, or the media added
   since the last sync, for mobile clients
2) merging identical files with different names

But had some drawbacks:
- every operation that modifies templates, models or facts meant generating
  the q/a and checking if any new media had appeared
- each entry is about 70 bytes, and some decks have 100k+ media files

So we remove the media table. We address 1) by being more intelligent about
media downloads on the mobile platform. We ask the user after a full sync if
they want to look for missing media, and they can choose not to if they know
they haven't added any. And on a partial sync, we can scan the contents of the
incoming facts for media references, and download any references we find. This
also avoids all the issues people had with media not downloading because it
was in their media folder but not in the media database.

For 2), when copying media to the media folder, if we have a duplicate
filename, we check if that file has the same md5, and avoid copying if so.
This won't merge identical content that has separate names, but instances
where users need that are rare.
2011-04-28 09:23:56 +09:00
Damien Elmes
bd477de1a9 implement cram
still to do:
- altering intervals at cram exit
- tidying up
2011-04-28 09:23:56 +09:00
Damien Elmes
22a72d82c6 give card types a more logical order
they are now 0=new, 1=learning, 2=due, to reflect the natural progression
2011-04-28 09:23:56 +09:00
Damien Elmes
6f5918e8cd move reset etc code into sched 2011-04-28 09:23:56 +09:00
Damien Elmes
be56912caf strip all the old cram code; add way to start cramming from deck 2011-04-28 09:23:56 +09:00
Damien Elmes
17f3cabc25 more unit tests, and unbury on close 2011-04-28 09:23:56 +09:00
Damien Elmes
908dccc2c0 implement new review code, add unit tests
Instead of the old approach to sibling spacing, we instead try to pick a due
date that doesn't have any siblings.
2011-04-28 09:23:56 +09:00
Damien Elmes
4a6b5c9105 generate the counts separately, so they're not limited by queueLimit
this has a negative performance impact on decks with many new cards or reviews
due, but we can't limit the counts to 200 without annoying people
2011-04-28 09:23:55 +09:00
Damien Elmes
96f36e66f7 parse tags when creating fact, add selective study, fix emptyAns default 2011-04-28 09:23:55 +09:00
Damien Elmes
ba09529e34 speed up the revlog migration, tweak db handling
remove the unnecessary transaction magic; we just needed to make sure to
lock again after undo is initialized
2011-04-28 09:23:55 +09:00
Damien Elmes
17ee7757de add some group utilities 2011-04-28 09:23:55 +09:00
Damien Elmes
f9c3b27e5d give facts a group, so that cards can have their group reset if necessary 2011-04-28 09:23:55 +09:00
Damien Elmes
945e5e9da8 fix upgrade code for the lock hack 2011-04-28 09:23:55 +09:00
Damien Elmes
9226922af8 properly lock the DB 2011-04-28 09:23:55 +09:00
Damien Elmes
7acda0f06d remove some unused hooks 2011-04-28 09:23:55 +09:00
Damien Elmes
511d6e89a1 remove progress handling code; we'll do it in the GUI or provide cb 2011-04-28 09:23:55 +09:00
Damien Elmes
e728d49232 delete -> del for consistency 2011-04-28 09:23:55 +09:00
Damien Elmes
f74d9b68fe trigger the db progress handler after more operations
We originally were triggering on 100 opcodes, because at the time we were
doing write-heavy alterations to the DB for inactive tags, and a higher level
of opcodes would pause the interface for a long time. The query structure is
different now, so we can afford to save the overhead of more frequent calls.

With the change, a .reset() triggers the handler 3 times; fixIntegrity()
triggers it 30 times over a period of 4.5 seconds.
2011-04-28 09:23:55 +09:00
Damien Elmes
1dc3a0ad4a make sure revlog is removed on immediate delete 2011-04-28 09:23:55 +09:00
Damien Elmes
f96a495b53 fact.model -> fact.model() 2011-04-28 09:23:54 +09:00
Damien Elmes
870c80e076 add genCards(), previewCards(), and more unit tests 2011-04-28 09:23:54 +09:00
Damien Elmes
53215230b4 we do the db integrity check on backup so need to in fixIntegrity() 2011-04-28 09:23:54 +09:00
Damien Elmes
98290c485d fix integrity check, move dynamic indices into scheduler
A lot of the old checks in fixIntegrity() are no longer relevant, and some of
the others may no longer be required. They can be added back in as the need
arises.
2011-04-28 09:23:54 +09:00
Damien Elmes
d5cce19b56 store the ordinals in templates/fields
this makes it more convenient to pass around templates/fields without having
to instrument them with their position in the list
2011-04-28 09:23:54 +09:00
Damien Elmes
e6a8f7f619 move time & count code into scheduler 2011-04-28 09:23:54 +09:00
Damien Elmes
66dcd45599 use nextID() when adding facts/cards
We want to ensure that we never recycle ids from deleted cards. We could do
this with an autoincrement column in sqlite, but it's cheaper for us to handle
the ids ourselves, as the deck object is always in memory.
2011-04-28 09:23:54 +09:00
Damien Elmes
7d52805b41 move changeModel() into models.py. It is not yet ported to the new code 2011-04-28 09:23:54 +09:00
Damien Elmes
0db95ded74 add template deletion & unit test 2011-04-28 09:23:54 +09:00
Damien Elmes
4638d3de46 implement field add/delete/rename/move
- now in model.py instead of deck.py
- added unit tests
2011-04-28 09:23:54 +09:00
Damien Elmes
d95cc6c44b implement sort fields; make sure they're updated on upgrade 2011-04-28 09:23:54 +09:00
Damien Elmes
93dcfceffe convert templates to a json object, and replace tid with ord
it's faster for us to parse another json string than pull a record from a
separate db table, and this makes templates and fields consistent
2011-04-28 09:23:54 +09:00
Damien Elmes
911069d371 remove ord from cards, give templates an optional gid, change addFact()
When adding facts, you can now pass in a group id which the GUI should support
editing. Templates will have an optional group id which overrides the provided
id, so users can automatically put certain card types in a different group (or
all of them, if desired). Greying out the group box in the GUI in that case
would be a good idea.
2011-04-28 09:23:54 +09:00
Damien Elmes
4f2ecda980 update new card unit test 2011-04-28 09:23:54 +09:00
Damien Elmes
3f92254e1a use the id to sort instead of requiring ordinal
This means that the default learn queue sort order doesn't need another column
in the index, but it also means that generated cards will have a higher id,
and would appear later even if they have a lower ordinal. This is probably an
infrequent issue, and a plugin which rewrites ids would probably be an
adequate solution.
2011-04-28 09:23:54 +09:00
Damien Elmes
ad68500494 updateCache -> renderQA, move some functions around 2011-04-28 09:23:54 +09:00
Damien Elmes
0e084f8e3d refactor font rewriting
Our goal is to allow decks created on one platform to use similar fonts (even
if named differently) when moving to another platform. The old solution wasn't
useful for the web version or mobile versions. Instead, we store a mapping in
the deck, and when generating the CSS, we list all possible fonts. An option
in the interface for the user to add extra fonts might be nice.
2011-04-28 09:23:54 +09:00
Damien Elmes
81a093a8f4 move css generation into model
The model now has a css column, and when it's flushed, it generates the css
for the fields and templates. This means we don't have to generate the CSS on
deck load anymore.

The hex cache has also been removed. Javascript couldn't handle big ints, but
since ints are small numbers now, we no longer need a cache to efficiently
convert an id to hex.
2011-04-28 09:23:54 +09:00
Damien Elmes
f5b326c753 more checksum work
- convert checksums to int
- add bulk update & update on upgrade
- add indices pending performance testing. The fsum table & indices add about
  2MB to a deck with 50k unique fields
2011-04-28 09:23:54 +09:00