Skip to content

Conversation

@lsabor
Copy link
Contributor

@lsabor lsabor commented Nov 21, 2025

closes #3803

updates QuestionUpdateSerializer to validate any changes to options
updates update_question to trigger appropriate helper method

@lsabor lsabor force-pushed the mc/3803/backend/endpoints branch 2 times, most recently from 20f99f1 to baca66b Compare November 23, 2025 18:29
@lsabor lsabor changed the base branch from mc/3800/backend/option_history to mc/3801/backend/scoring November 23, 2025 18:34
@lsabor lsabor force-pushed the mc/3801/backend/scoring branch from 72c745a to 81424da Compare November 23, 2025 20:15
@lsabor lsabor force-pushed the mc/3803/backend/endpoints branch from baca66b to b483002 Compare November 23, 2025 20:15
@lsabor lsabor force-pushed the mc/3801/backend/scoring branch from 81424da to 7c13428 Compare November 23, 2025 20:40
@lsabor lsabor force-pushed the mc/3803/backend/endpoints branch from b483002 to 753b1aa Compare November 23, 2025 20:40
@lsabor lsabor changed the title add options update validation and functionality mc/3806/backend/endpoints Nov 23, 2025
@lsabor lsabor force-pushed the mc/3801/backend/scoring branch from 7c13428 to a21d018 Compare November 23, 2025 21:38
@lsabor lsabor force-pushed the mc/3803/backend/endpoints branch from 243cd5c to 350c67b Compare November 23, 2025 21:39
@lsabor lsabor force-pushed the mc/3801/backend/scoring branch from a21d018 to 792fe88 Compare November 23, 2025 23:14
@lsabor lsabor force-pushed the mc/3803/backend/endpoints branch from 350c67b to a585c45 Compare November 23, 2025 23:14
@lsabor lsabor force-pushed the mc/3801/backend/scoring branch from 792fe88 to 6689806 Compare November 23, 2025 23:28
@lsabor lsabor force-pushed the mc/3803/backend/endpoints branch from a585c45 to c8fe000 Compare November 23, 2025 23:28
Comment on lines 281 to 308
new_options = options or []
current_options = question.options or []
if len(current_options) < len(new_options):
# deletion
options_to_delete = [l for l in new_options if l not in current_options]
multiple_choice_delete_options(
question,
options_to_delete,
timestep=now,
)
question.save(update_fields=["options", "options_history"])
elif len(current_options) > len(new_options):
# addition
if not grace_period_end:
raise ValueError("grace_period_end required when adding options")
options_to_add = [l for l in current_options if l not in new_options]
multiple_choice_add_options(
question,
options_to_add,
grace_period_end=grace_period_end,
timestep=now,
)
question.save(update_fields=["options", "options_history"])
elif current_options != new_options:
# renaming
for old, new in zip(current_options, new_options):
multiple_choice_rename_option(question, old, new)
question.save(update_fields=["options", "options_history"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this business logic to the separate service

Copy link
Contributor

@hlbmtc hlbmtc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A quick conceptual question: I see here we have a separate endpoint for updating question options. Shouldn't we handle it in the existing Post update flow/services?

add options_history to question serialization

add options_history initialization to question creation

add helper functions to question/utils.py and add 'automatic' to forecast.source selection

fix build_question_forecasts import and remove options & options_history from admin panel edit

tests for question creation, multiple_choice_rename_option, multiple_choice_delete_options, multiple_choice_add_options

add options_history to openapi docs

add csv reporting support for options_history

rebase to None

openapi.py spelling

update logic to play well with back/forward filling 0s

update csv_utils

update csv_utils 2

minor logic fix

fix

add all_options_ever to serializer and api docs

add current options to csv return

add support for datetime isoformat instead of timestamps in options_history
move mc operations to mc handlers file
move tests to appropriate locations

minor cleanup

fix forecast creation in test
fix file restructure
fix datetime iso format in history conflicts
other fixes

mc/forecasts tweaks 2

mc forecasts tweaks 3

mc forecasts tweaks 4

mc forecasts tweaks 5

add support for None values in MC predictions

fix tests and source logic
parent 3c40ee2
author lsabor <[email protected]> 1763674087 -0800
committer lsabor <[email protected]> 1764534427 -0800

adjust aggregations to play nicely with placeholders

improve test for comput_weighted_semi_standard_deviations

add support for 0.0s in prediction difference for sorting plus tests

update prediction difference for display to handle placeholders
@lsabor lsabor force-pushed the mc/3801/backend/scoring branch from 6689806 to df11e3f Compare November 30, 2025 23:26
parent 76bcb47
author lsabor <[email protected]> 1763312248 -0800
committer lsabor <[email protected]> 1764541784 -0800

add OptionsHistoryType, multiple_choice_interpret_forecast, and test

update test for change to function

update string_location_to_scaled_location to accept all historical option values, and related test

multiple choice forecasts require interpretation before scoring

remove double written definition

support the new MC format scoring

tests for mc with placeholder values

add support for None values
@lsabor lsabor force-pushed the mc/3801/backend/scoring branch from df11e3f to abc10ab Compare November 30, 2025 23:30
add MC Options update serializer with validations
@lsabor lsabor force-pushed the mc/3803/backend/endpoints branch from c8fe000 to 108d1f0 Compare November 30, 2025 23:43
@lsabor lsabor force-pushed the mc/3801/backend/scoring branch from abc10ab to 367ece0 Compare December 4, 2025 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants