组件可用性更新
This commit is contained in:
@@ -108,6 +108,7 @@ class Recognition(Composition):
|
|||||||
return -1
|
return -1
|
||||||
|
|
||||||
class BasicEvaluation(Composition):
|
class BasicEvaluation(Composition):
|
||||||
|
# 不再使用, 仅作为测试
|
||||||
def __init__(self, screen: Screen, reactor, atom: Tuple[pt.Electron, pt.Nucleon, Dict]):
|
def __init__(self, screen: Screen, reactor, atom: Tuple[pt.Electron, pt.Nucleon, Dict]):
|
||||||
super().__init__(screen, reactor, atom)
|
super().__init__(screen, reactor, atom)
|
||||||
def compose(self):
|
def compose(self):
|
||||||
@@ -133,50 +134,68 @@ class BasicEvaluation(Composition):
|
|||||||
class FillBlank(Composition):
|
class FillBlank(Composition):
|
||||||
def __init__(self, screen: Screen, reactor, atom: Tuple[pt.Electron, pt.Nucleon, Dict]):
|
def __init__(self, screen: Screen, reactor, atom: Tuple[pt.Electron, pt.Nucleon, Dict]):
|
||||||
super().__init__(screen, reactor, atom)
|
super().__init__(screen, reactor, atom)
|
||||||
|
self.inputlist = []
|
||||||
|
self.hashtable = {}
|
||||||
|
self._work()
|
||||||
def _work(self):
|
def _work(self):
|
||||||
self.puzzle = pz.BlankPuzzle(self.atom[1]["content"], 4)
|
self.puzzle = pz.BlankPuzzle(self.atom[1]["content"], 4)
|
||||||
self.puzzle.refresh()
|
self.puzzle.refresh()
|
||||||
|
self.ans = copy.copy(self.puzzle.answer)
|
||||||
|
random.shuffle(self.ans)
|
||||||
def compose(self):
|
def compose(self):
|
||||||
self._work()
|
|
||||||
yield Label(self.puzzle.wording, id=self.regid("sentence"))
|
yield Label(self.puzzle.wording, id=self.regid("sentence"))
|
||||||
ans = copy.copy(self.puzzle.answer)
|
yield Label(f"当前输入: {self.inputlist}", id=self.regid("inputpreview"))
|
||||||
random.shuffle(ans)
|
#yield Label(renderable=f"答案: {self.puzzle.answer}", id=self.regid("ans"))
|
||||||
for i in ans:
|
for i in self.ans:
|
||||||
yield
|
self.hashtable[str(hash(i))] = i
|
||||||
yield Button("我已知晓", id="ok")
|
yield Button(i, id=self.regid(f"select{hash(i)}"))
|
||||||
|
yield Button("退格", id=self.regid(f"delete"))
|
||||||
def handler(self, event, type_):
|
def handler(self, event, type_):
|
||||||
if event.button.id == "ok":
|
if type_ == "button":
|
||||||
return 1
|
if self.recid(event.button.id) == "delete" and len(self.inputlist) > 0:
|
||||||
|
self.inputlist.pop()
|
||||||
|
else:
|
||||||
|
self.inputlist.append(self.hashtable[self.recid(event.button.id)[6:]])
|
||||||
|
if len(self.inputlist) < len(self.puzzle.answer):
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
if self.inputlist == self.puzzle.answer:
|
||||||
|
print("ok")
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
self.inputlist = []
|
||||||
|
return 1
|
||||||
|
|
||||||
class DrawCard(Composition):
|
class DrawCard(Composition):
|
||||||
def __init__(self, screen: Screen, reactor, atom: Tuple[pt.Electron, pt.Nucleon, Dict]):
|
def __init__(self, screen: Screen, reactor, atom: Tuple[pt.Electron, pt.Nucleon, Dict]):
|
||||||
super().__init__(screen, reactor, atom)
|
super().__init__(screen, reactor, atom)
|
||||||
self.inputlist = []
|
self.inputlist = []
|
||||||
self.hashtable = {}
|
self.hashtable = {}
|
||||||
|
self._work()
|
||||||
def _work(self):
|
def _work(self):
|
||||||
self.puzzle = pz.SelectionPuzzle(self.atom[1]["keyword_note"], [], 2, "选择正确词义: ")
|
self.puzzle = pz.SelectionPuzzle(self.atom[1]["keyword_note"], [], 2, "选择正确词义: ")
|
||||||
self.puzzle.refresh()
|
self.puzzle.refresh()
|
||||||
def compose(self):
|
def compose(self):
|
||||||
self._work()
|
|
||||||
print(len(self.inputlist))
|
print(len(self.inputlist))
|
||||||
yield Label(self.puzzle.wording[len(self.inputlist)], id=self.regid("sentence"))
|
yield Label(self.atom[1].content, id=self.regid("sentence"))
|
||||||
yield Label(f"当前输入: {self.inputlist}", id=self.regid("sentence"))
|
yield Label(self.puzzle.wording[len(self.inputlist)], id=self.regid("puzzle"))
|
||||||
|
yield Label(f"当前输入: {self.inputlist}", id=self.regid("inputpreview"))
|
||||||
|
yield Label(renderable=f"答案: {self.puzzle.answer}", id=self.regid("ans"))
|
||||||
for i in self.puzzle.options[len(self.inputlist)]:
|
for i in self.puzzle.options[len(self.inputlist)]:
|
||||||
self.hashtable[str(hash(i))] = i
|
self.hashtable[str(hash(i))] = i
|
||||||
yield Button(i, id=self.regid(f"select{hash(i)}"))
|
yield Button(i, id=self.regid(f"select{hash(i)}"))
|
||||||
yield Button("退格", id=self.regid(f"delete"))
|
yield Button("退格", id=self.regid(f"delete"))
|
||||||
def handler(self, event, type_):
|
def handler(self, event, type_):
|
||||||
if type_ == "button":
|
if type_ == "button":
|
||||||
|
if self.recid(event.button.id) == "delete" and len(self.inputlist) > 0:
|
||||||
|
self.inputlist.pop()
|
||||||
|
else:
|
||||||
|
self.inputlist.append(self.hashtable[self.recid(event.button.id)[6:]])
|
||||||
if len(self.inputlist) < len(self.puzzle.answer):
|
if len(self.inputlist) < len(self.puzzle.answer):
|
||||||
if self.recid(event.button.id) == "delete" and len(self.inputlist) > 0:
|
return 1
|
||||||
self.inputlist.pop()
|
|
||||||
return 1
|
|
||||||
else:
|
|
||||||
self.inputlist.append(self.hashtable[self.recid(event.button.id)[6:]])
|
|
||||||
return 1
|
|
||||||
else:
|
else:
|
||||||
if self.inputlist == self.puzzle.answer:
|
if self.inputlist == self.puzzle.answer:
|
||||||
self.inputlist = []
|
print("ok")
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
self.inputlist = []
|
self.inputlist = []
|
||||||
@@ -185,7 +204,7 @@ class DrawCard(Composition):
|
|||||||
registry = {
|
registry = {
|
||||||
"sample": Composition,
|
"sample": Composition,
|
||||||
"recognition": Recognition,
|
"recognition": Recognition,
|
||||||
"fill_blank_test": BasicEvaluation,
|
"fill_blank_test": FillBlank,
|
||||||
"draw_card_test": DrawCard,
|
"draw_card_test": DrawCard,
|
||||||
"basic_evaluation": BasicEvaluation,
|
"basic_evaluation": BasicEvaluation,
|
||||||
}
|
}
|
||||||
|
@@ -50,6 +50,7 @@ class SelectionPuzzle(Puzzle):
|
|||||||
prefix: 问题前缀
|
prefix: 问题前缀
|
||||||
"""
|
"""
|
||||||
def __init__(self, mapping, jammer: list, max_riddles_num: int = 2, prefix: str = ""):
|
def __init__(self, mapping, jammer: list, max_riddles_num: int = 2, prefix: str = ""):
|
||||||
|
jammer += ["1","2","3","4"]
|
||||||
self.prefix = prefix
|
self.prefix = prefix
|
||||||
self.mapping = mapping
|
self.mapping = mapping
|
||||||
self.jammer = list(set(jammer + list(mapping.values()))) # 合并干扰项和正确答案并去重
|
self.jammer = list(set(jammer + list(mapping.values()))) # 合并干扰项和正确答案并去重
|
||||||
|
Reference in New Issue
Block a user