~kevang/mnemosyne-proj/grade-shortcuts-improvements

« back to all changes in this revision

Viewing changes to mnemosyne/mnemosyne/libmnemosyne/card_type.py

  • Committer: pbienst
  • Date: 2008-08-04 16:13:00 UTC
  • Revision ID: svn-v3-trunk0:e5e6b78b-db40-0410-9517-b98c64f8d2c1:trunk:497
Progress dump.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#   give different names to the same key. (E.g. 'pronunciation' could be
20
20
#   called 'reading' in a Kanji card type).
21
21
#
 
22
#   We could use the component manager to track fact views, but this is
 
23
#   probably overkill.
 
24
#
22
25
##############################################################################
23
26
 
24
27
class CardType(Component):
32
35
    def __init__(self, id, name, description=""):
33
36
 
34
37
        self.fact_key_names = {}
 
38
        self.unique_fact_keys = "" # For duplicate checking.
35
39
 
36
40
        self.fact_views = []
37
41
        
47
51
 
48
52
    ##########################################################################
49
53
    #
50
 
    # Functions to be implemented by the specific card types.
 
54
    # new_cards
51
55
    #
52
56
    ########################################################################## 
53
57
 
54
 
    def new_cards(self):
55
 
        raise NotImplementedError
56
 
 
 
58
    def new_cards(self, fact_data, grade, cat_names):
 
59
 
 
60
        db = get_database()
 
61
 
 
62
        # Create fact.
 
63
 
 
64
        fact = Fact(fact_data)
 
65
        db.save_fact(fact)
 
66
 
 
67
        # Create cards.
 
68
 
 
69
        for fact_view in self.fact_views:
 
70
 
 
71
            card = Card(grade=grade, card_type=self, fact=fact,
 
72
                        fact_view=fact_view, cat_names=cat_names)
 
73
        
 
74
            db.save_card(card)
 
75
 
 
76
 
 
77
            
 
78
    ##########################################################################
 
79
    #
 
80
    # update_cards
 
81
    #
 
82
    ##########################################################################
 
83
    
57
84
    def update_cards(self):
58
85
        raise NotImplementedError