diff --git a/anki/cards.py b/anki/cards.py index 820d4b261..3f3140a8a 100644 --- a/anki/cards.py +++ b/anki/cards.py @@ -129,7 +129,7 @@ lapses=?, left=?, odue=?, odid=?, did=? where id = ?""", if not self._qa or reload: f = self.note(reload); m = self.model(); t = self.template() data = [self.id, f.id, m['id'], self.odid or self.did, self.ord, - f.stringTags(), f.joinedFields()] + f.stringTags(), f.joinedFields(), self.flags] if browser: args = (t.get('bqfmt'), t.get('bafmt')) else: diff --git a/anki/collection.py b/anki/collection.py index 5a993c1d3..640e52340 100644 --- a/anki/collection.py +++ b/anki/collection.py @@ -549,7 +549,7 @@ where c.nid = n.id and c.id in %s group by nid""" % ids2str(cids)): def _renderQA(self, data, qfmt=None, afmt=None): "Returns hash of id, question, answer." - # data is [cid, nid, mid, did, ord, tags, flds] + # data is [cid, nid, mid, did, ord, tags, flds, cardFlags] # unpack fields and create dict flist = splitFields(data[6]) fields = {} @@ -560,6 +560,7 @@ where c.nid = n.id and c.id in %s group by nid""" % ids2str(cids)): fields['Type'] = model['name'] fields['Deck'] = self.decks.name(data[3]) fields['Subdeck'] = fields['Deck'].split('::')[-1] + fields['CardFlag'] = self._flagNameFromCardFlags(data[7]) if model['type'] == MODEL_STD: template = model['tmpls'][data[4]] else: @@ -593,13 +594,19 @@ where c.nid = n.id and c.id in %s group by nid""" % ids2str(cids)): return d def _qaData(self, where=""): - "Return [cid, nid, mid, did, ord, tags, flds] db query" + "Return [cid, nid, mid, did, ord, tags, flds, cardFlags] db query" return self.db.execute(""" -select c.id, f.id, f.mid, c.did, c.ord, f.tags, f.flds +select c.id, f.id, f.mid, c.did, c.ord, f.tags, f.flds, c.flags from cards c, notes f where c.nid == f.id %s""" % where) + def _flagNameFromCardFlags(self, flags): + flag = flags & 0b111 + if not flag: + return "" + return "flag%d" % flag + # Finding cards ########################################################################## diff --git a/anki/models.py b/anki/models.py index 478b371c0..b077ad7a8 100644 --- a/anki/models.py +++ b/anki/models.py @@ -503,9 +503,9 @@ select id from notes where mid = ?)""" % " ".join(map), for f in flds: a.append("ankiflag") b.append("") - data = [1, 1, m['id'], 1, t['ord'], "", joinFields(a)] + data = [1, 1, m['id'], 1, t['ord'], "", joinFields(a), 0] full = self.col._renderQA(data)['q'] - data = [1, 1, m['id'], 1, t['ord'], "", joinFields(b)] + data = [1, 1, m['id'], 1, t['ord'], "", joinFields(b), 0] empty = self.col._renderQA(data)['q'] # if full and empty are the same, the template is invalid and there is # no way to satisfy it