Skip to content

Commit 01b34ec

Browse files
committed
Fix error when switching tools in IntroDrawing, Level Viewer more options, Statistics3 JSON Export
1 parent 5664a63 commit 01b34ec

File tree

13 files changed

+177
-97
lines changed

13 files changed

+177
-97
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ conf/
2121
log_merging_config.json
2222
dockerComposeMPI.yml
2323
*.csv
24+
statistics_*.json
2425
reversim-conf
2526

2627
# Debugpy logs, WinMerge Backups etc.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ instance/statistics/**
1212

1313
# Don't track generated statistics
1414
*.csv
15+
statistics_*.json
1516
log_merging_config.json
1617
investigateLogs.py
1718

.vscode/launch.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,13 @@
9696
"type": "debugpy",
9797
"request": "launch",
9898
"module": "app.statistics3.statistics3",
99-
"args": [
100-
],
10199
"env": {
102100
"REVERSIM_INSTANCE": "${input:instancePath}"
103101
},
102+
"args": [
103+
"--beginning",
104+
"${input:date}"
105+
],
104106
"justMyCode": true,
105107
"console": "integratedTerminal",
106108
},
@@ -145,5 +147,11 @@
145147
"type": "promptString",
146148
"default": "instance"
147149
},
150+
{
151+
"id": "date",
152+
"description": "A date in ISO 8601 format at which the logs shall start",
153+
"type": "promptString",
154+
"default": ""
155+
},
148156
]
149157
}

app/model/Participant.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,11 +730,13 @@ def selectDrawingTool(self, timeStamp: int, tool: Any):
730730

731731
self.logger.writeToLog(EventType.Click, e, timeStamp)
732732

733+
LEVEL_INTRO_DRAWING = (LevelType.LEVEL, 'elementIntroduction/simple_circuit.txt')
734+
733735
event = SelectDrawToolEvent(
734736
clientTime=timeStamp, serverTime=now(),
735737
pseudonym=self.pseudonym,
736738
phase=self.getPhaseName(),
737-
level=self.getLevelContext(),
739+
level=self.getLevelContext() if self.getPhase().hasLevels() else LEVEL_INTRO_DRAWING,
738740
object=tool
739741
)
740742
event.commit()

app/screenshotGenerator.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,16 @@ def screenshotLevel(page: Page, levelName: str):
249249
# print(f'Skipping: "{outputPath}"')
250250
# return
251251

252-
quotedLevelName = urllib.parse.quote_plus(currentLevel)
253-
page.goto(f'{base_url}/game?group=viewer&lang=en&ui={pseudonym}&level={quotedLevelName}')
252+
query_string = urllib.parse.urlencode({
253+
'group': 'viewer',
254+
'lang': 'en',
255+
'showSwitchID': '',
256+
'showClues': '',
257+
'ui': pseudonym,
258+
'level': currentLevel,
259+
})
260+
261+
page.goto(f'{base_url}/game?' + query_string)
254262
page.wait_for_timeout(1000)
255263

256264
downloadCanvasImage(page, outputName=outputPath)

app/statistics3/StatsCircuit.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1+
from dataclasses import dataclass
12
from typing import override
23
from app.statistics3.StatsSlide import StatsSlide
34
from app.statistics3.statisticsUtils import TIME_TOLERANCE, TIMESTAMP_MS, CurrentLevelState, LogValidationError
4-
from app.utilsGame import LevelType
55

66

7+
@dataclass
78
class StatsCircuit(StatsSlide):
89

9-
def __init__(self, type_slide: LevelType, log_name: str, time_load: TIMESTAMP_MS) -> None:
10-
super().__init__(type_slide, log_name, time_load)
11-
12-
self.switchClicks: int = 0
13-
self.minSwitchClicks: int|None = None
14-
self.confirmClicks: int = 0
10+
switchClicks: int = 0
11+
minSwitchClicks: int|None = None
12+
confirmClicks: int = 0
1513

1614

1715
def click_switch(self):

app/statistics3/StatsParticipant.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
1+
from dataclasses import dataclass, field
12
from datetime import timedelta
23
from app.gameConfig import PHASES_WITH_LEVELS
34
from app.statistics3.StatsPhase import StatsPhase
45
from app.statistics3.StatsPhaseLevels import StatsPhaseLevels
56
from app.statistics3.statisticsUtils import TIMESTAMP_MS, LogValidationError
67
from app.utilsGame import PhaseType
78

8-
9+
@dataclass
910
class StatsParticipant:
1011

11-
@property
12-
def activePhase(self) -> StatsPhase:
13-
assert self.phaseIdx >= 0 and self.phaseIdx < len(self.phases)
14-
return self.phases[self.phaseIdx]
15-
12+
pseudonym: str
13+
is_debug: bool
1614

17-
def __init__(self, pseudonym: str, is_debug: bool) -> None:
18-
self.pseudonym = pseudonym
19-
self.is_debug = is_debug
15+
groups: list[str] = field(default_factory=list[str])
2016

21-
self.is_debug: bool
22-
self.groups: list[str] = []
17+
phases: list[StatsPhase] = field(default_factory=list[StatsPhase])
18+
phaseIdx: int = -1
2319

24-
self.phases: list[StatsPhase] = []
25-
self.phaseIdx: int = -1
20+
quali_fails: int = 0
2621

27-
self.quali_fails: int = 0
22+
game_started: bool = False
23+
reloads: list[str] = field(default_factory=list[str])
2824

29-
self.game_started = False
30-
self.reloads: list[str] = []
25+
time_limit: timedelta|None = None
3126

32-
self.time_limit: timedelta|None = None
27+
@property
28+
def activePhase(self) -> StatsPhase:
29+
assert self.phaseIdx >= 0 and self.phaseIdx < len(self.phases)
30+
return self.phases[self.phaseIdx]
3331

3432

3533
def load_phase(self, type_phase: str, time_loaded: TIMESTAMP_MS):

app/statistics3/StatsPhase.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
from dataclasses import dataclass
23
import logging
34
from datetime import timedelta
45

@@ -10,21 +11,19 @@
1011
)
1112
from app.utilsGame import PhaseType
1213

13-
14+
@dataclass
1415
class StatsPhase:
16+
phaseType: PhaseType
17+
time_load: TIMESTAMP_MS
1518

16-
def __init__(self, type_phase: PhaseType, time_load: TIMESTAMP_MS) -> None:
17-
self.phaseType = type_phase
18-
19-
self.time_load: TIMESTAMP_MS = time_load
20-
self.time_start: TIMESTAMP_MS|None = None
21-
self.time_start_levels: TIMESTAMP_MS|None = None
22-
self.time_finish: TIMESTAMP_MS|None = None
19+
time_start: TIMESTAMP_MS|None = None
20+
time_start_levels: TIMESTAMP_MS|None = None
21+
time_finish: TIMESTAMP_MS|None = None
2322

24-
self.time_limit: timedelta|None = None
23+
time_limit: timedelta|None = None
2524

26-
self.status: CurrentState = CurrentState.LOADED
27-
self.reloaded = False
25+
status: CurrentState = CurrentState.LOADED
26+
reloaded = False
2827

2928

3029
def start(self, time_start: TIMESTAMP_MS, time_limit: float|None):

app/statistics3/StatsPhaseLevels.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from dataclasses import dataclass, field
12
from typing import override
23

34
from app.gameConfig import LEVEL_FILETYPES_WITH_TASK, PHASES_WITH_LEVELS
@@ -8,8 +9,12 @@
89
from app.utilsGame import LevelType, PhaseType
910

1011

12+
@dataclass
1113
class StatsPhaseLevels(StatsPhase):
1214

15+
levels: list[StatsSlide] = field(default_factory=list[StatsSlide])
16+
levelIdx: int = -1
17+
1318
@property
1419
def activeLevel(self) -> StatsSlide:
1520
assert self.levelIdx >= 0 and self.levelIdx < len(self.levels)
@@ -20,8 +25,8 @@ def __init__(self, type_phase: PhaseType, time_load: TIMESTAMP_MS) -> None:
2025
super().__init__(type_phase, time_load)
2126
assert type_phase in PHASES_WITH_LEVELS
2227

23-
self.levels: list[StatsSlide] = []
24-
self.levelIdx: int = -1
28+
self.levels = []
29+
self.levelIdx = -1
2530

2631

2732
def load_level(self, type_level: str, log_name: str, time_load: TIMESTAMP_MS):

app/statistics3/StatsSlide.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from dataclasses import dataclass
12
import logging
23
from datetime import timedelta
34

@@ -10,24 +11,20 @@
1011
from app.utilsGame import LevelType
1112

1213

14+
@dataclass
1315
class StatsSlide:
1416

15-
def __init__(self,
16-
type_slide: LevelType,
17-
log_name: str,
18-
time_load: TIMESTAMP_MS
19-
) -> None:
20-
self.slide_type = type_slide
21-
self.log_name = log_name
17+
slide_type: LevelType
18+
log_name: str
2219

23-
self.time_load: TIMESTAMP_MS = time_load
24-
self.time_start: TIMESTAMP_MS|None = None
25-
self.time_finish: TIMESTAMP_MS|None = None
20+
time_load: TIMESTAMP_MS
21+
time_start: TIMESTAMP_MS|None = None
22+
time_finish: TIMESTAMP_MS|None = None
2623

27-
self.time_limit: timedelta|None = None
24+
time_limit: timedelta|None = None
2825

29-
self.status: CurrentLevelState = CurrentLevelState.LOADED
30-
self.reloaded = False
26+
status: CurrentLevelState = CurrentLevelState.LOADED
27+
reloaded = False
3128

3229

3330
def start(self, time_start: TIMESTAMP_MS, time_limit: float|None):

0 commit comments

Comments
 (0)