updated test file structure, fixed submit bug

This commit is contained in:
Zdenek Borovec 2019-09-02 12:55:41 +02:00
parent 21b72f2fad
commit c3fdcb93b0
4 changed files with 44 additions and 41 deletions

View file

@ -2,6 +2,7 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="51fbe63a-b9a4-4568-8b8d-3351f51944b9" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/programfiles/default.tst" beforeDir="false" afterPath="$PROJECT_DIR$/programfiles/default.tst" afterDir="false" />
<change beforePath="$PROJECT_DIR$/tests/example angtest.tst" beforeDir="false" afterPath="$PROJECT_DIR$/tests/example angtest.tst" afterDir="false" />
<change beforePath="$PROJECT_DIR$/vyzkousejme.pyw" beforeDir="false" afterPath="$PROJECT_DIR$/vyzkousejme.pyw" afterDir="false" />
</list>
@ -12,12 +13,12 @@
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileEditorManager">
<leaf>
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/vyzkousejme.pyw">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="204">
<caret line="72" lean-forward="true" selection-start-line="72" selection-end-line="72" />
<state relative-caret-position="170">
<caret line="10" column="19" selection-start-line="10" selection-start-column="19" selection-end-line="10" selection-end-column="19" />
<folding>
<element signature="e#0#21#0" expanded="true" />
</folding>
@ -27,6 +28,14 @@
</file>
</leaf>
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>test[1]</find>
</findStrings>
<replaceStrings>
<replace>test[0]</replace>
</replaceStrings>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
@ -47,6 +56,7 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
@ -58,7 +68,6 @@
<select />
</subPane>
</pane>
<pane id="Scope" />
</panes>
</component>
<component name="RunDashboard">
@ -117,13 +126,9 @@
<component name="ToolWindowManager">
<frame x="-7" y="0" width="974" height="1047" extended-state="0" />
<layout>
<window_info id="Favorites" side_tool="true" />
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.33653846" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Version Control" />
<window_info anchor="bottom" id="Python Console" />
<window_info anchor="bottom" id="Terminal" />
<window_info anchor="bottom" id="Event Log" side_tool="true" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" weight="0.32932165" />
@ -131,6 +136,10 @@
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Version Control" order="7" />
<window_info anchor="bottom" id="Terminal" order="8" />
<window_info anchor="bottom" id="Event Log" order="9" side_tool="true" />
<window_info anchor="bottom" id="Python Console" order="10" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
@ -139,8 +148,8 @@
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/vyzkousejme.pyw">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="204">
<caret line="72" lean-forward="true" selection-start-line="72" selection-end-line="72" />
<state relative-caret-position="170">
<caret line="10" column="19" selection-start-line="10" selection-start-column="19" selection-end-line="10" selection-end-column="19" />
<folding>
<element signature="e#0#21#0" expanded="true" />
</folding>

View file

@ -1,3 +1,2 @@
EXAMPLE TEST SUBJECT 1/EXAMPLE TEST SUBJECT 2
0
question will appear here/question will appear here

View file

@ -1,5 +1,4 @@
ČEŠTINA/ENGLISH
5
0
apple/jablko
car,automobile/auto,automobil
chopper,helicopter/vrtulník,helikoptéra

View file

@ -7,9 +7,9 @@ import random
def swapSides():
global test
temp = test[2]
test[2] = test[3]
test[3] = temp
temp = test[0]
test[0] = test[1]
test[1] = temp
newQuestion()
@ -17,25 +17,24 @@ def swapSides():
def saveTest():
print(test)
with open(filepath, mode='w', encoding = "UTF-8") as file:
file.write(test[0]+'/'+test[1])
file.write(str(test[4])+'\n')
for i in range(len(test[2])):
for j in range(len(test[2][i])):
file.write(test[2][i][j])
if j < len(test[2][i])-1:
file.write(str(test[2])+'\n')
for i in range(len(test[0])):
for j in range(len(test[0][i])):
file.write(test[0][i][j])
if j < len(test[0][i])-1:
file.write(',')
file.write('/')
for j in range(len(test[3][i])):
file.write(test[3][i][j])
if j < len(test[3][i])-1:
for j in range(len(test[1][i])):
file.write(test[1][i][j])
if j < len(test[1][i])-1:
file.write(',')
file.write('\n')
def newQuestion():
global questionPlace
questionPlace = random.randint(0, len(test[2])-1)
newQuestion = test[2][questionPlace][0]
questionPlace = random.randint(0, len(test[0])-1)
newQuestion = test[0][questionPlace][0]
question.set(newQuestion)
@ -47,15 +46,15 @@ def on_closing():
def submitAnswer(uselessArgument):
global score
if answerEntry.get().lower() in test[3] [questionPlace]:
if answerEntry.get().lower() in test[1] [questionPlace]:
score += 1
currentScore.set('Score: %s' % (score))
else:
score = 0
currentScore.set('Score: %s' % (score))
if score > test[4]:
test[4] = score
highScore.set('High score: %d' % (test[4]))
if score > test[2]:
test[2] = score
highScore.set('High score: %d' % (test[2]))
answerEntry.delete(0, 'end')
newQuestion()
@ -65,22 +64,19 @@ def formatTest(filepath):
with open(filepath, encoding = "UTF-8") as file:
file = file.readlines()
nazev1 = file[0].split('/')[0]
nazev2 = file[0].split('/')[1]
sloupec1 = []
sloupec2 = []
highScore = int(file[1].strip('\n'))
highScore = int(file[0].strip('\n'))
score = 0
for line in file[2:]:
for line in file[1:]:
currentline = line.strip('\n')
currentline = currentline.split('/')
sloupec1.append(currentline[0].split(','))
sloupec2.append(currentline[1].split(','))
return nazev1, nazev2, sloupec1, sloupec2, highScore
return sloupec1, sloupec2, highScore
def getExtension(filename): # returns the last four characters in a filename as a string
@ -102,7 +98,7 @@ def openTest():
test = list(formatTest(filepath))
newQuestion()
currentScore.set('Score: %s' % score)
highScore.set('High score: %d' % test[4])
highScore.set('High score: %d' % test[2])
def makeMenu(root):
@ -141,7 +137,7 @@ highScoreLabel = Label(root, textvariable=highScore, bg='gray')
questionLabel = Label(root, textvariable=question, width=30)
spacingLabel = Label(bg='gray', padx=10)
answerEntry = Entry(root, width=30)
answerButton = Button(root, text='submit', command=submitAnswer)
answerButton = Button(root, text='submit', command=lambda: submitAnswer(0))
timeMultiplierLabel = Label(root, textvariable=timeMultiplier, bg='gray')
anotherSpacingLabel.grid(row=0, column=0)
@ -154,7 +150,7 @@ answerButton.grid(row=1, column=5, sticky=W)
#timeMultiplierLabel.grid(row=2, column=1, columnspan=5)
currentScore.set('Score: %s' %(score))
highScore.set('High score: %d' %(test[4]))
highScore.set('High score: %d' %(test[2]))
question.set('question will appear here')
timeMultiplier.set('Time multiplier is: 0')