You've already forked HeurAMS-legacy
fix
This commit is contained in:
@@ -15,12 +15,14 @@ from typing import TypedDict
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
class Setting(TypedDict):
|
||||
__origin__: str
|
||||
__hint__: str
|
||||
text: str
|
||||
delimiter: str
|
||||
min_denominator: str
|
||||
min_denominator: str
|
||||
|
||||
|
||||
class ClozePuzzle(BasePuzzleWidget):
|
||||
|
||||
@@ -58,7 +60,7 @@ class ClozePuzzle(BasePuzzleWidget):
|
||||
min_denominator=int(setting["min_denominator"]),
|
||||
)
|
||||
self.puzzle.refresh()
|
||||
self.ans = copy.copy(self.puzzle.answer) # 乱序
|
||||
self.ans = copy.copy(self.puzzle.answer) # 乱序
|
||||
random.shuffle(self.ans)
|
||||
|
||||
def compose(self):
|
||||
@@ -78,7 +80,6 @@ class ClozePuzzle(BasePuzzleWidget):
|
||||
preview = self.query_one("#inputpreview")
|
||||
preview.update(f"当前输入: {self.inputlist}") # type: ignore
|
||||
|
||||
|
||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||
button_id = event.button.id
|
||||
|
||||
@@ -87,16 +88,22 @@ class ClozePuzzle(BasePuzzleWidget):
|
||||
self.inputlist.pop()
|
||||
self.update_display()
|
||||
else:
|
||||
answer_text = self.hashmap[button_id[7:]] # type: ignore
|
||||
answer_text = self.hashmap[button_id[7:]] # type: ignore
|
||||
self.inputlist.append(answer_text)
|
||||
self.update_display()
|
||||
|
||||
if len(self.inputlist) >= len(self.puzzle.answer):
|
||||
is_correct = self.inputlist == self.puzzle.answer
|
||||
rating = 4 if is_correct else 2
|
||||
|
||||
self.screen.rating = rating # type: ignore
|
||||
self.handler(rating)
|
||||
self.screen.rating = rating # type: ignore
|
||||
|
||||
if not is_correct:
|
||||
self.inputlist = []
|
||||
self.update_display()
|
||||
|
||||
def handler(self, rating):
|
||||
if self.atom.lock():
|
||||
pass
|
||||
else:
|
||||
self.atom.minimize(rating)
|
||||
Reference in New Issue
Block a user