def _renderPreview(self) -> None: self.cancelPreviewTimer() c = self.card ti = self.maybeTextInput bodyclass = bodyClass(self.mw.col, c) q = ti(mungeQA(self.mw.col, c.q(reload=True))) q = gui_hooks.card_will_show(q, c, "clayoutQuestion") a = ti(mungeQA(self.mw.col, c.a()), type="a") a = gui_hooks.card_will_show(a, c, "clayoutAnswer") # use _showAnswer to avoid the longer delay self.pform.frontWeb.eval("_showAnswer(%s,'%s');" % (json.dumps(q), bodyclass)) self.pform.backWeb.eval("_showAnswer(%s, '%s');" % (json.dumps(a), bodyclass)) clearAudioQueue() if c.id not in self.playedAudio: playFromText(c.q()) playFromText(c.a()) self.playedAudio[c.id] = True self.updateCardNames()
def _showQuestion(self): self._reps += 1 self.state = "question" self.typedAnswer = None c = self.card # grab the question and play audio if c.isEmpty(): q = _( """\ The front of this card is empty. Please run Tools>Empty Cards.""" ) else: q = c.q() if self.autoplay(c): playFromText(q) # render & update bottom q = self._mungeQA(q) q = runFilter("prepareQA", q, c, "reviewQuestion") bodyclass = bodyClass(self.mw.col, c) self.web.eval("_showQuestion(%s,'%s');" % (json.dumps(q), bodyclass)) self._drawFlag() self._drawMark() self._showAnswerButton() # if we have a type answer field, focus main web if self.typeCorrect: self.mw.web.setFocus() # user hook gui_hooks.run_reviewer_showing_question_hook(c)
def replayAudio(self, previewer=None): if previewer: state = previewer._previewState c = previewer.card else: state = self.state c = self.card clearAudioQueue() if state == "question": playFromText(c.q()) elif state == "answer": txt = "" if self._replayq(c, previewer): txt = c.q() txt += c.a() playFromText(txt)
def _showAnswer(self): if self.mw.state != "review": # showing resetRequired screen; ignore space return self.state = "answer" c = self.card a = c.a() # play audio? clearAudioQueue() if self.autoplay(c): playFromText(a) a = self._mungeQA(a) a = runFilter("prepareQA", a, c, "reviewAnswer") # render and update bottom self.web.eval("_showAnswer(%s);" % json.dumps(a)) self._showEaseButtons() # user hook gui_hooks.run_reviewer_showing_answer_hook(c)