Premier League Predictor: Django & MySQL — Chapter 6, Exercise 3 ==================================================== TASK Enter an incorrect result for a real fixture with at least two predictions already recorded via enter_result, confirm their points_awarded values, then call enter_result again with the corrected result and confirm every prediction's points_awarded genuinely changed via bulk_update() rather than only being scored the first time. SOLUTION Using fixture_id 42 with two predictions already recorded (a user prediction of 2-1, an expert prediction of 1-1): 1. Enter a deliberately wrong first result: POST /fixtures/42/result/ {"home_score": 1, "away_score": 1} Inside enter_result, this sets fixture.home_score = 1, fixture.away_score = 1, status = "played", saves the fixture, then builds a list of both Prediction rows and computes points_awarded for each before calling bulk_update(). 2. Call GET /fixtures/42/predictions/ and check points_awarded: - user (2-1): _outcome(2, 1) is "home_win"; the entered result (1, 1) is a draw. No exact match, no outcome match -> points_awarded = 0. - expert (1-1): exact match against the entered (1, 1) result -> points_awarded = 40. 3. Now correct the result to the real one: POST /fixtures/42/result/ {"home_score": 2, "away_score": 1} enter_result runs exactly the same way a second time: it re-fetches both Prediction rows fresh from the database, recomputes points_awarded for both against the new (2, 1) result, and calls bulk_update(predictions, ['points_awarded']) again. 4. Call GET /fixtures/42/predictions/ again and check points_awarded: - user (2-1): now an exact match against the corrected (2, 1) result -> points_awarded = 40. - expert (1-1): a draw prediction against a corrected home-win result -> different outcomes -> points_awarded = 0. Both predictions' points_awarded values genuinely flipped between the two calls — the user went from 0 to 40, the expert went from 40 to 0 — confirming that enter_result really does rebuild the full list of predictions and rescore every one of them from scratch on every call, and that bulk_update() writes the corrected values back to the database rather than the first call's values silently persisting. WHY THIS WORKS AS AN ANSWER ---------------------------- It walks through a real before-and-after sequence using two predictions deliberately chosen so the correction flips which one scores well (rather than one where both happen to end up scored the same either way), making the change genuinely visible and verifiable in both directions, and explicitly ties the outcome back to enter_result re-running its full loop and bulk_update() call on every invocation, not just the first.