Update app.py
Browse files
app.py
CHANGED
|
@@ -115,7 +115,7 @@ def fetch_personalized_data(externalID):
|
|
| 115 |
e5390g37899_decisions.tripledAmount1,
|
| 116 |
e5390g37899_decisions.keptForSelf1,
|
| 117 |
e5390g37899_decisions.returned1,
|
| 118 |
-
e5390g37899_decisions.
|
| 119 |
e5390g37899_decisions.transfer2,
|
| 120 |
e5390g37899_decisions.tripledAmount2,
|
| 121 |
e5390g37899_decisions.keptForSelf2,
|
|
@@ -158,7 +158,7 @@ def fetch_personalized_data(externalID):
|
|
| 158 |
e5390g37899_decisions.tripledAmount1,
|
| 159 |
e5390g37899_decisions.keptForSelf1,
|
| 160 |
e5390g37899_decisions.returned1,
|
| 161 |
-
e5390g37899_decisions.
|
| 162 |
e5390g37899_decisions.transfer2,
|
| 163 |
e5390g37899_decisions.tripledAmount2,
|
| 164 |
e5390g37899_decisions.keptForSelf2,
|
|
@@ -210,7 +210,7 @@ def fetch_personalized_data(externalID):
|
|
| 210 |
'tripledAmount1': row[9],
|
| 211 |
'keptForSelf1': row[10],
|
| 212 |
'returned1': row[11],
|
| 213 |
-
'
|
| 214 |
'transfer2': row[13],
|
| 215 |
'tripledAmount2': row[14],
|
| 216 |
'keptForSelf2': row[15],
|
|
@@ -245,9 +245,9 @@ def extract_variables(all_personalized_data, part):
|
|
| 245 |
extracted_data = {}
|
| 246 |
|
| 247 |
if part == "1":
|
| 248 |
-
rounds = range(1, 4) # Rounds 1-3
|
| 249 |
elif part == "2":
|
| 250 |
-
rounds = range(
|
| 251 |
else:
|
| 252 |
print("No data for the particular part found")
|
| 253 |
return None
|
|
@@ -256,10 +256,14 @@ def extract_variables(all_personalized_data, part):
|
|
| 256 |
role = map_role(str(data.get('role', 'unknown'))) # Get the role description
|
| 257 |
player_data = {} # Store data for the current player
|
| 258 |
for round_num in rounds:
|
| 259 |
-
round_key = f'round{round_num}'
|
| 260 |
player_data[round_key] = {}
|
| 261 |
for var in ['transfer', 'tripledAmount', 'keptForSelf', 'returned', 'totalRound']:
|
| 262 |
var_name = f'{var}{round_num}'
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
if data.get(var_name) is not None:
|
| 264 |
player_data[round_key][var] = data[var_name]
|
| 265 |
|
|
@@ -396,7 +400,7 @@ def generate(
|
|
| 396 |
groupNrStart = entry.get('groupNrStart', "no_groupNrStart") # Retrieve groupNrStart value
|
| 397 |
onPage = entry.get('onPage', "no_onPage") # Retrieve onPage value
|
| 398 |
role = entry.get('role', "no_role") # Retrieve role value
|
| 399 |
-
part =
|
| 400 |
break # Break the loop since we found the desired entry
|
| 401 |
|
| 402 |
# Print the values of onPage, playerNr, and groupNrStart and oart
|
|
@@ -412,7 +416,7 @@ def generate(
|
|
| 412 |
print("onPage_prompt:", onPage_prompt)
|
| 413 |
|
| 414 |
# Print the role value
|
| 415 |
-
role_prompt = map_role(role)
|
| 416 |
print("role_prompt:", role_prompt)
|
| 417 |
|
| 418 |
extracted_data = extract_variables(all_personalized_data, part)
|
|
|
|
| 115 |
e5390g37899_decisions.tripledAmount1,
|
| 116 |
e5390g37899_decisions.keptForSelf1,
|
| 117 |
e5390g37899_decisions.returned1,
|
| 118 |
+
e5390g37899_decisions.totalRound1,
|
| 119 |
e5390g37899_decisions.transfer2,
|
| 120 |
e5390g37899_decisions.tripledAmount2,
|
| 121 |
e5390g37899_decisions.keptForSelf2,
|
|
|
|
| 158 |
e5390g37899_decisions.tripledAmount1,
|
| 159 |
e5390g37899_decisions.keptForSelf1,
|
| 160 |
e5390g37899_decisions.returned1,
|
| 161 |
+
e5390g37899_decisions.totalRound1,
|
| 162 |
e5390g37899_decisions.transfer2,
|
| 163 |
e5390g37899_decisions.tripledAmount2,
|
| 164 |
e5390g37899_decisions.keptForSelf2,
|
|
|
|
| 210 |
'tripledAmount1': row[9],
|
| 211 |
'keptForSelf1': row[10],
|
| 212 |
'returned1': row[11],
|
| 213 |
+
'totalRound1': row[12],
|
| 214 |
'transfer2': row[13],
|
| 215 |
'tripledAmount2': row[14],
|
| 216 |
'keptForSelf2': row[15],
|
|
|
|
| 245 |
extracted_data = {}
|
| 246 |
|
| 247 |
if part == "1":
|
| 248 |
+
rounds = range(1, 4) # Rounds 1-3 for part 1
|
| 249 |
elif part == "2":
|
| 250 |
+
rounds = range(4, 7) # Rounds 4-6 for part 2
|
| 251 |
else:
|
| 252 |
print("No data for the particular part found")
|
| 253 |
return None
|
|
|
|
| 256 |
role = map_role(str(data.get('role', 'unknown'))) # Get the role description
|
| 257 |
player_data = {} # Store data for the current player
|
| 258 |
for round_num in rounds:
|
| 259 |
+
round_key = f'round{round_num - 3 if part == "2" else round_num}' # Adjusting round numbers if part is 2
|
| 260 |
player_data[round_key] = {}
|
| 261 |
for var in ['transfer', 'tripledAmount', 'keptForSelf', 'returned', 'totalRound']:
|
| 262 |
var_name = f'{var}{round_num}'
|
| 263 |
+
if role == 'The Dealer' and var == 'tripledAmount':
|
| 264 |
+
continue # Skip adding 'tripledAmount' for the Dealer
|
| 265 |
+
if role == 'The Investor' and var == 'keptForSelf':
|
| 266 |
+
continue # Skip adding 'keptForSelf' for the Investor
|
| 267 |
if data.get(var_name) is not None:
|
| 268 |
player_data[round_key][var] = data[var_name]
|
| 269 |
|
|
|
|
| 400 |
groupNrStart = entry.get('groupNrStart', "no_groupNrStart") # Retrieve groupNrStart value
|
| 401 |
onPage = entry.get('onPage', "no_onPage") # Retrieve onPage value
|
| 402 |
role = entry.get('role', "no_role") # Retrieve role value
|
| 403 |
+
part = entry.get('part', "no_part") # Retrieve part value
|
| 404 |
break # Break the loop since we found the desired entry
|
| 405 |
|
| 406 |
# Print the values of onPage, playerNr, and groupNrStart and oart
|
|
|
|
| 416 |
print("onPage_prompt:", onPage_prompt)
|
| 417 |
|
| 418 |
# Print the role value
|
| 419 |
+
role_prompt = map_role(str(role))
|
| 420 |
print("role_prompt:", role_prompt)
|
| 421 |
|
| 422 |
extracted_data = extract_variables(all_personalized_data, part)
|