Commit graph

134 commits

Author SHA1 Message Date
Damien Elmes
12a80ef9c2 handle cloze note types in changeModel() 2012-04-25 13:25:19 +09:00
Damien Elmes
62b44df78e when renaming a field, support cloze: as well 2012-04-22 08:01:17 +09:00
Damien Elmes
9fab2834da cloze generation needs to use provided fields, not field 0 2012-04-21 07:25:35 +09:00
Damien Elmes
7c51a7bb16 update sort field when field moved 2012-04-21 06:40:20 +09:00
Damien Elmes
c2df347909 catch attempt to delete last template 2012-04-20 22:37:31 +09:00
Damien Elmes
a3407020cb split empty card removal into separate report 2012-04-19 11:14:57 +09:00
Damien Elmes
5cbe93b63d more cloze work
- upgrade old decks
- specify the field in the cloze, so the user can have an id in the first
  field
2012-04-19 08:32:19 +09:00
Damien Elmes
41fa9a9896 cloze refactor wip 2012-04-19 07:14:03 +09:00
Damien Elmes
71645aacb5 fix field deletion issues thanks to illforyou 2012-04-08 20:18:46 +09:00
Damien Elmes
51b70a5787 genCards() on model change 2012-03-20 02:46:45 +09:00
Damien Elmes
9e35e4acf2 template and cloze changes
While writing the documentation I realized that the default templates were
somewhat overwhelming. So I've moved the default settings into the card css,
and moved the css into a separate attribute which gets combined with the
question and answer templates.

Also:
- Detect cloze references directly rather than the conditional wrapper
- Add the cloze css to the template
2011-12-17 19:42:30 +09:00
Damien Elmes
619a58216a don't require fields in cloze del model; remove extra brackets in cloze hints 2011-12-17 15:02:15 +09:00
Damien Elmes
3957f07afb add media[] for future use 2011-12-16 10:04:19 +09:00
Damien Elmes
0b96e8a1a9 per-fact empty card deletion, and delete hook 2011-12-11 23:48:24 +09:00
Damien Elmes
8be0e6cccd make sure we add + delete cards after template changes 2011-12-11 23:35:59 +09:00
Damien Elmes
0a279f6a26 remove clozectx, add styling to stdmodels 2011-12-11 02:33:27 +09:00
Damien Elmes
4428c04774 new order is now a deck property 2011-12-10 22:45:44 +09:00
Damien Elmes
451962d4a8 drop the special config for top level decks
New/rev card mixing, collapse time and the timeboxing limit are now a
collection property. I appreciate how it could be useful to have those
settings per top-level deck in some cases, but having some settings inherited
from the top level deck makes for a confusing UI.
2011-12-09 07:55:40 +09:00
Damien Elmes
c0edcae238 fix some sync bugs
- don't send server graves graves back on the next sync
- make sure we update usns of models/tags/decks as well on upload
- don't die when updating decks after current deck deleted
- report counts when sanity check fails
2011-12-06 01:35:54 +09:00
Damien Elmes
9d5357f7a6 after a save, revert to unmodified state; sync tweaks 2011-12-04 14:56:12 +09:00
Damien Elmes
a1693a3691 field operations should mod the schema immediately 2011-11-30 10:57:42 +09:00
Damien Elmes
9dbb0b90d5 fix updateFieldCache() call 2011-11-28 21:30:47 +09:00
Damien Elmes
1235f8362a type answer is now a template replacement 2011-11-28 15:15:38 +09:00
Damien Elmes
ddd890ee75 more fixes for schema being accidentally modified on model add 2011-11-27 13:50:49 +09:00
Damien Elmes
b5c0b1f2c7 drop required/unique field properties
Instead of having required and unique flags for every field, enforce both
requirements on the first field, and neither on the rest. This mirrors the
subject/body format people are used to in note-taking apps. The subject
defines the object being learnt, and the remaining fields represent properties
of that object.

In the past, duplicate checking served two purposes: it quickly notified the
user that they're entering the same fact twice, and it notified the user if
they'd accidentally mistyped a secondary field. The former behaviour is
important for avoiding wasted effort, and so it should be done in real time.
The latter behaviour is not essential however - a typo is not wasted effort,
and it could be fixed in a periodic 'find duplicates' function. Given that
some users ended up with sluggish decks due to the overhead a large number of
facts * a large number of unique fields caused, this seems like a change for
the better.

This also means Anki will let you add notes as long as as the first field has
been filled out. Again, this is not a big deal: Anki is still checking to make
sure one or more cards will be generated, and the user can easily add any
missing fields later.

As a bonus, this change simplifies field configuration somewhat. As the card
layout and field dialogs are a popular point of confusion, the more they can
be simplified, the better.
2011-11-24 22:16:03 +09:00
Damien Elmes
fae153c2af don't mod schema when adding new models 2011-11-24 16:33:40 +09:00
Damien Elmes
f7790275ce groups -> decks 2011-11-23 19:28:09 +09:00
Damien Elmes
279a942642 deck -> collection 2011-11-23 17:47:44 +09:00
Damien Elmes
6e4e8249fb facts -> notes 2011-11-23 12:37:21 +09:00
Damien Elmes
7a5cee1d20 remove remaining CSS; more template properties into div 2011-11-18 08:25:56 +09:00
Damien Elmes
15e4b64162 new approach to hideQ
Instead of a separate option to hide question, embed the question into the
answer format by default. Users who don't want to see the question can remove
the question fields, and users who want a separator between the question and
answer (or not) can control it in HTML now.

Also, remove obsolete field CSS, and don't accidentally chomp a character on
upgrade.
2011-11-18 05:15:15 +09:00
Damien Elmes
770f402905 don't allow template removal to orphan facts 2011-11-17 23:09:18 +09:00
Damien Elmes
a51307701d del -> rem for consistency 2011-11-17 22:55:03 +09:00
Damien Elmes
01b297babc fix model gencards 2011-11-08 22:32:02 +09:00
Damien Elmes
795cdd7d3f remove the concept of non-active templates
The old template handling was too complicated, and generated frequent
questions on the forums. By dropping non-active templates we can do away with
the generate cards function, and advanced users can simulate the old behaviour
by using conditional field templates.
2011-11-08 18:06:19 +09:00
Damien Elmes
f8eefe5ee1 model deleting should use the string id 2011-11-07 18:38:48 +09:00
Damien Elmes
aef7626557 add fieldNames(); fix scmhash() 2011-11-07 14:27:15 +09:00
Damien Elmes
cbdb283b20 refactor model copying 2011-10-31 11:34:03 +09:00
Damien Elmes
ed7367d67f fix reporting of latex errors; catch some bad commands 2011-10-29 15:12:57 +09:00
Damien Elmes
3068e79b42 Merge branch 'new' 2011-10-22 18:39:08 +09:00
Damien Elmes
b31bd5c091 vacuum after import; make sure models.current() always returns 2011-10-22 07:39:13 +09:00
Damien Elmes
852189808f catch attempts to save a fact that deletes a cloze card 2011-10-22 03:10:34 +09:00
Damien Elmes
a4e8eb8b74 cache required fields, drop emptyAns
For importing and the deck creation wizard, we need to be able to generate
thousands of cards efficiently. So instead of requiring the creation of a fact
and rendering it, we cache the required fields and cloze references in the
model.

Also, emptyAns is dropped, as people can achieve the same behaviour by adding
the required answer fields as conditional to the question.

Todo: refactor genCards() to work in bulk, handle cloze edits intelligently
(prompt to delete invalid references, create new cards as necessary)
2011-10-22 02:28:57 +09:00
Damien Elmes
83f8ef45ff anki2 importing and reorganize import code 2011-10-21 07:36:44 +09:00
Damien Elmes
2b34d8a948 more group/sched refactoring
- keep track of rep/time counts per group, instead of just at the top level
- sort by due after retrieving learn cards
- ensure activeGroups is sorted alphabetically
- ensure new cards come in alphabetical group order
- ensure queues are refilled when empty
2011-09-23 08:19:22 +09:00
Damien Elmes
ee767ff132 refactor to allow group deletions without schema mod
because group deletions are likely to be a semi-common operation (esp. for new users trying out shared material), deleting groups will no longer cause a full sync. in order to avoid syncing issues, we now allow cards/facts/etc to point to an invalid group, and in that case, we just treat them like they're in the default group
2011-09-15 01:37:30 +09:00
Damien Elmes
bc9f6e6a24 add USNs
Decks now have an "update sequence number". All objects also have a USN, which
is set to the deck USN each time they are modified. When syncing, each side
sends any objects with a USN >= clientUSN. When objects are copied via sync,
they have their USNs bumped to the current serverUSN. After a sync, the USN on
both sides is set to serverUSN + 1.

This solves the failing three way test, ensures we receive all changes
regardless of clock drift, and as the revlog also has a USN now, ensures that
old revlog entries are imported properly too.

Objects retain a separate modification time, which is used for conflict
resolution, deck subscriptions/importing, and info for the user.

Note that if the clock is too far off, it will still cause confusion for
users, as the due counts may be different depending on the time. For this
reason it's probably a good idea to keep a limit on how far the clock can
deviate.

We still keep track of the last sync time, but only so we can determine if the
schema has changed since the last sync.

The media code needs to be updated to use USNs too.
2011-09-13 21:10:21 +09:00
Damien Elmes
362ae3eee2 initial work on sync refactor
Ported the sync code to the latest libanki structure. Key points:

No summary:

The old style got each side to fetch ids+mod times and required the client to
diff them and then request or bundle up the appropriate objects. Instead, we now
get each side to send all changed objects, and it's the responsibility of the
other side to decide what needs to be merged and what needs to be discarded.
This allows us to skip a separate summary step, which saves scanning tables
twice, and allows us to reduce server requests from 4 to 3.

Schema changes:

Certain operations that are difficult to merge (such as changing the number of
fields in a model, or deleting models or groups) result in a full sync. The
user is warned about it in the GUI before such schema-changing operations
execute.

Sync size:

For now, we don't try to deal with large incremental syncs. Because the cards,
facts and revlog can be large in memory (hundreds of megabytes in some cases),
they would have to be chunked for the benefit of devices with a low amount of
memory.

Currently findChanges() uses the full fact/card objects which we're planning to
send to the server. It could be rewritten to fetch a summary (just the id, mod
& rep columns) which would save some memory, and then compare against blocks
of a few hundred remote objects at a time. However, it's a bit more
complicated than that:

- If the local summary is huge it could exceed memory limits. Without a local
  summary we'd have to query the db for each record, which could be a lot
  slower.

- We currently accumulate a list of remote records we need to add locally.
  This list also has the potential to get too big. We would need to
  periodically commit the changes as we accumulate them.

- Merging a large amount of changes is also potentially slow on mobile
  devices.

Given the fact that certain schema-changing operations require a full sync
anyway, I think it's probably best to concentrate on a chunked full sync for
now instead, as provided the user syncs periodically it should not be easy to
hit the full sync limits except after bulk editing operations.

Chunked partial syncing should be possible to add in the future without any
changes to the deck format.

Still to do:
- deck conf merging
- full syncing
- new http proxy
2011-09-08 12:50:42 +09:00
Damien Elmes
de8a5b69ed top level groups
As discussed on the forums, moving to a single collection requires moving some
deck-level configuration into groups so users can have different settings like
new cards/day for each top level item.

Also:
- store id in groups
- add mod time to gconf updates
- move the limiting code that's not specific to scheduling into groups.py
- store the current model id per top level group
2011-09-07 01:31:46 +09:00
Damien Elmes
cca48a0ced thinko 2011-08-28 14:40:52 +09:00