~emihalac/mnemosyne-proj/mnemosyne-proj

« back to all changes in this revision

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

  • Committer: Peter Bienstman
  • Date: 2017-03-01 18:28:52 UTC
  • Revision ID: peter.bienstman@ugent.be-20170301182852-uzlgodwicl505ft1
Option to have single window Q and A.

Show diffs side-by-side

added added

removed removed

Lines of Context:
134
134
    def render_question(self, card, **render_args):
135
135
        fact_keys = card.fact_view.q_fact_keys
136
136
        decorators = card.fact_view.q_fact_key_decorators
 
137
        if self.config()["QA_split"] == "single_window":
 
138
            render_args["align_top"] = True        
137
139
        return self._render(card, fact_keys, decorators, **render_args)
138
140
 
139
141
    def render_answer(self, card, **render_args):
140
 
        fact_keys = card.fact_view.a_fact_keys
141
 
        decorators = card.fact_view.a_fact_key_decorators
 
142
        fact_keys, decorators = [], {}
 
143
        if self.config()["QA_split"] == "single_window":
 
144
            render_args["align_top"] = True
 
145
            fact_keys += card.fact_view.q_fact_keys
 
146
            fact_keys.append("__line__")
 
147
            decorators.update(card.fact_view.q_fact_key_decorators)       
 
148
        fact_keys += card.fact_view.a_fact_keys
 
149
        decorators.update(card.fact_view.a_fact_key_decorators)
142
150
        return self._render(card, fact_keys, decorators, **render_args)
143
151
 
144
152
    def _render(self, card, fact_keys, decorators, **render_args):
146
154
        # generated by the renderer, which would be much slower.
147
155
        fact_data = copy.copy(card.card_type.fact_data(card))
148
156
        for fact_key in fact_keys:
 
157
            if fact_key == "__line__":
 
158
                fact_data[fact_key] = "<hr id=answer>"            
149
159
            if fact_key not in fact_data:  # Optional key.
150
160
                continue
151
161
            for filter in self._filters: