fixed bug, where your answer was regarded as wrong when it contained uppercase letter in the .tst file

This commit is contained in:
Zdenek Borovec 2019-10-21 16:27:23 +02:00
parent 2b7a21aee1
commit 764de673e1
2 changed files with 29 additions and 9 deletions

19
tests/PSP.tst Normal file
View file

@ -0,0 +1,19 @@
0.0
H/Vodík
He/Helium
Li/Lithium
Be/Beryllium
B/Bor
C/Uhlík
N/Dusík
O/Kyslík
F/Fluor
Ne/Neon
Na/Sodík
Mg/Hořčík
Al/Hliník
Si/Křemík
P/Fosfor
S/Síra
Cl/Chlor
Ar/Argon

View file

@ -53,15 +53,16 @@ def on_closing(): #zobrazi se pri zavirani programu, pokud se uzivatel rozhodne
def submitAnswer(uselessArgument): # precte pole pro zadani odpovedi, zhodnoti ji, a vhodnym zpusobem zmeni score a highscore def submitAnswer(uselessArgument): # precte pole pro zadani odpovedi, zhodnoti ji, a vhodnym zpusobem zmeni score a highscore
global score global score
if answerEntry.get().lower() in test[1] [questionPlace]: for i in test[1][questionPlace]:
score += timeMultiplier if answerEntry.get().lower() == i.lower():
currentScore.set('Score: %s' % (score)) score += timeMultiplier
else: currentScore.set('Score: %s' % (score))
score = 0 else:
currentScore.set('Score: %s' % (score)) score = 0
if score > test[2]: currentScore.set('Score: %s' % (score))
test[2] = score if score > test[2]:
highScore.set('High score: %s' % (test[2])) test[2] = score
highScore.set('High score: %s' % (test[2]))
answerEntry.delete(0, 'end') answerEntry.delete(0, 'end')
newQuestion() newQuestion()
currentScore.set('Score: %s' % round(score, 2)) currentScore.set('Score: %s' % round(score, 2))