# Change: Show Synthetic Historical Demand on Round 1 for Everyone ## Summary Modified the historical demand display so that **everyone** (regardless of tool access level) sees the 25 pre-generated synthetic historical demand values on Round 1. From Round 2 onwards, they see their own actual demand history from completed rounds. ## Changes Made ### 1. Backend Logic (`newsvendor/__init__.py`) #### In `Order.vars_for_template` (Lines 173-203): **Before:** ```python # Past demand: show only after the first round using player's own actual history actual_hist = pv.get('actual_demand_history', []) if player.round_number > 1 and actual_hist: # Format as discrete integers (no decimals) formatted_history = [f"{int(v)}" for v in actual_hist] # ... calculate stats ... has_history = True else: formatted_history = [] hist_mean = hist_std = hist_min = hist_max = None has_history = False ``` **After:** ```python # Past demand: On Round 1, show synthetic history for everyone. # From Round 2 onwards, show player's own actual demand history. actual_hist = pv.get('actual_demand_history', []) if player.round_number == 1: # Round 1: Show synthetic historical demand for everyone synthetic_hist = pv.get('fixed_scenario', {}).get('history', []) if synthetic_hist: formatted_history = [f"{int(v)}" for v in synthetic_hist] hist_mean = float(np.mean(synthetic_hist)) if synthetic_hist else None hist_std = float(np.std(synthetic_hist, ddof=1)) if len(synthetic_hist) > 1 else None hist_min = int(np.min(synthetic_hist)) if synthetic_hist else None hist_max = int(np.max(synthetic_hist)) if synthetic_hist else None has_history = True else: formatted_history = [] hist_mean = hist_std = hist_min = hist_max = None has_history = False elif player.round_number > 1 and actual_hist: # Round 2+: Show player's actual demand history from completed rounds formatted_history = [f"{int(v)}" for v in actual_hist] hist_mean = float(np.mean(actual_hist)) if actual_hist else None hist_std = float(np.std(actual_hist, ddof=1)) if len(actual_hist) > 1 else None hist_min = int(np.min(actual_hist)) if actual_hist else None hist_max = int(np.max(actual_hist)) if actual_hist else None has_history = True else: formatted_history = [] hist_mean = hist_std = hist_min = hist_max = None has_history = False ``` ### 2. Template Changes (`newsvendor/Order.html`) #### Historical Demand Section (Lines 17-38): **Changes:** 1. Added conditional text based on round number 2. Changed fallback message from "will appear after first round" to "No historical demand data available" **Key additions:** ```html {% if round_number == 1 %}

Historical demand data from similar past scenarios:

{% else %}

Past actual demand from your completed rounds:

{% endif %} ``` ## Behavior by Round | Round | What Users See | Source | |-------|---------------|--------| | 1 | 25 synthetic historical demand values | `participant.vars['fixed_scenario']['history']` | | 2 | 1 actual demand value (from Round 1) | `participant.vars['actual_demand_history']` | | 3 | 2 actual demand values (from Rounds 1-2) | `participant.vars['actual_demand_history']` | | 4 | 3 actual demand values (from Rounds 1-3) | `participant.vars['actual_demand_history']` | | 5 | 4 actual demand values (from Rounds 1-4) | `participant.vars['actual_demand_history']` | ## Access Control Still Applied The tiered access control for **summary statistics** remains: - **Everyone** sees the demand values (synthetic on R1, actual on R2+) - **Only forecasting tool users (tool_count ≥ 2)** see the summary statistics (mean, std, min, max, n) ## Testing Recommendations 1. **Round 1 - All tool levels**: - Start a new session - Check participants with `tool_count=1` (no tools) - Verify they see 25 synthetic demand values - Verify they do NOT see summary statistics 2. **Round 1 - Forecasting tool users**: - Check participants with `tool_count=2+` - Verify they see 25 synthetic demand values - Verify they DO see summary statistics 3. **Round 2+ progression**: - Complete Round 1 - On Round 2, verify the display switches from synthetic to actual history - Verify only 1 value shown (the demand from Round 1) - Continue through rounds to verify history grows 4. **Verify synthetic history quality**: - The 25 values should match the scenario's distribution - All values should be discrete integers (no decimals) - Mean/std should be close to the assigned scenario parameters