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

« back to all changes in this revision

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

  • Committer: pbienst
  • Date: 2008-08-03 16:08:48 UTC
  • Revision ID: svn-v3-trunk0:e5e6b78b-db40-0410-9517-b98c64f8d2c1:trunk:494
Update fact.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
import datetime, md5
8
8
 
 
9
from mnemosyne.libmnemosyne.plugin_manager import get_database,
 
10
 
9
11
 
10
12
 
11
13
##############################################################################
15
17
#   Basic unit of information from which several cards can be derived.
16
18
#   The fields are stored in a dictionary.
17
19
#
 
20
#   categories and card_type_id are stored here, because when resetting the
 
21
#   learning data on export, we only export facts. Of course cards can have
 
22
#   categories of their own as well.
 
23
#
18
24
# TODO: make list of common keys for standardisation.
19
25
#
20
26
##############################################################################
27
33
    #
28
34
    ##########################################################################
29
35
 
30
 
    def __init__(self, data, id=None):
31
 
        
32
 
        self.data  = data 
 
36
    def __init__(self, data, cat_names, card_type_id, id=None):
 
37
 
33
38
        self.added = datetime.datetime.now()
 
39
        
 
40
        self.data         = data 
 
41
        self.categories   = categories
 
42
        self.card_type_id = card_type_id
 
43
 
 
44
        self.cat = []
 
45
        for cat_name in cat_names:
 
46
            self.cat.append(db.get_or_create_category_with_name(cat_name))
34
47
 
35
48
        if id is not None:
36
49
 
68
81
        
69
82
        self.data[key] = value
70
83
 
 
84
 
 
85
    ##########################################################################
 
86
    #
 
87
    # is_active
 
88
    #
 
89
    ##########################################################################
 
90
 
 
91
    def is_active(self):
 
92
        
 
93
        for c in self.cat:
 
94
            if c.active == False:
 
95
                return False
 
96
            
 
97
        return True
 
98
 
71
99