Add built-in answer tones and automatic multiple-choice progression

This commit is contained in:
Brian Holman committed 2026-11-09 20:30:45 -07:00
1 parent 9f7d6f4786
commit 0bfee790a8
18 files changed
+1658 -21

No files matched your search

+17 -5
View File
@@ -22,13 +22,25 @@ for q,state in enumerate(order):
assert gold>=len(points)*.8,(q,rows[state][0],gold,len(points))
right=q%7!=0;selection=correctpos if right else (correctpos+1)%4
if right:score+=1
# Hold the first answer through feedback: it must not advance to question 2.
c['key'](run,str(selection+1),600 if q==0 else 8,450)
feedback=c['capture'](run,name+'-feedback');fs=Screen(str(EVIDENCE)+'/'+name+'-feedback.png')
# Read the feedback as soon as it appears, before its automatic timeout.
held=[str(selection+1)] if q==0 else []
c['inp'](run,[dict(keys=[str(selection+1)],fields=8),dict(keys=held,fields=80)])
for attempt in range(35):
feedback=c['capture'](run,name+'-feedback');fs=Screen(str(EVIDENCE)+'/'+name+'-feedback.png')
if fs.text(8,158,24) in ('CORRECT!','NOT THIS TIME.'):break
c['inp'](run,[dict(keys=held,fields=20)])
assert fs.text(8,158,24)==('CORRECT!' if right else 'NOT THIS TIME.'),(q,fs.text(8,158,24))
assert fs.text(8,170,50)==f'The capital is {rows[state][2]}.',(q,fs.text(8,170,50))
assert fs.text(8,183,48)=='Next question follows automatically.'
evidence.append(dict(question=q+1,code=rows[state][0],state=rows[state][1],options=opts,answer=opts[selection],correct=right,score=score,gold_pixels=gold,expected_state_pixels=len(points),field=meta['field_clock']))
c['key'](run,'space',8,500)
# No Space/Enter/answer input advances feedback: elapsed guest fields do it.
c['inp'](run,[dict(keys=held,fields=600)])
if q==0:
c['inp'](run,[dict(keys=held,fields=600)])
c['capture'](run,'held-key-next-question');hs=Screen(str(EVIDENCE)+'/held-key-next-question.png')
assert hs.text(8,19,45)==f'Question 2 of 50 Score {score}'
assert hs.text(8,183,48)=='Press 1, 2, 3 or 4'
c['inp'](run,[dict(keys=[],fields=8)])
print(q+1,rows[state][0],score,flush=True)
result=c['capture'](run,'mc-results');s=Screen(str(EVIDENCE)+'/mc-results.png')
assert s.text(8,48,45)==f'{score} / 50 correct {score*2}%',s.text(8,48,45)
@@ -49,5 +61,5 @@ for page in range(3):
c['key'](run,'b',8,500);c['key'](run,'p',8,500);c['capture'](run,'replay-title');c['key'](run,'q',8,200);final=c['capture'](run,'mc-exit')
assert 'screen_text' in final or final.get('screen_text_unavailable') is None,final
json.dump(dict(score=score,positions=pos,questions=evidence,run_id=run,artifact=result['artifact_id'],exit=final),open(str(EVIDENCE)+'/mc-report.json','w'),indent=2)
print('PASS complete multiple-choice quiz, all 50 masks, 42/50, review, held-key feedback, replay, exit.',flush=True)
print('PASS complete multiple-choice quiz, all 50 masks, automatic feedback advance without Space, held-key protection, 42/50, review, replay, exit.',flush=True)
c['v'].close()