-
Notifications
You must be signed in to change notification settings - Fork 23
mc/3806/backend/endpoints #3822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: mc/3801/backend/scoring
Are you sure you want to change the base?
Conversation
20f99f1 to
baca66b
Compare
72c745a to
81424da
Compare
baca66b to
b483002
Compare
81424da to
7c13428
Compare
b483002 to
753b1aa
Compare
7c13428 to
a21d018
Compare
243cd5c to
350c67b
Compare
a21d018 to
792fe88
Compare
350c67b to
a585c45
Compare
792fe88 to
6689806
Compare
a585c45 to
c8fe000
Compare
questions/views.py
Outdated
| 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"]) |
There was a problem hiding this comment.
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
hlbmtc
left a comment
There was a problem hiding this 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
6689806 to
df11e3f
Compare
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
df11e3f to
abc10ab
Compare
add MC Options update serializer with validations
c8fe000 to
108d1f0
Compare
abc10ab to
367ece0
Compare
closes #3803
updates
QuestionUpdateSerializerto validate any changes tooptionsupdates
update_questionto trigger appropriate helper method