-
Notifications
You must be signed in to change notification settings - Fork 24
Add / Remove Multiple Choice Options #3951
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: main
Are you sure you want to change the base?
Conversation
support null values on frontend fix flake8 complaints
add options_history field to question model and migration add options_history to question serialization add options_history initialization to question creation add helper functions to question/services/multiple_choice_handlers.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_options_reorder, multiple_choice_delete_options, multiple_choice_add_options add options_history to openapi docs add csv reporting support for options_history update logic to play well with back/forward filling 0s add all_options_ever to serializer and api docs add current options to csv return add support for datetime isoformat in options_history
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
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
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
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
add notification logic add mjml and update tasks to setup for notifications add withdrawal notifications and bulletin deactivation spelling of arg causes failure fix grace period end bug and skip emails
add admin form for changing options add comment author and text to admin panel action and mc change methods
add admin form for changing options add comment author and text to admin panel action and mc change methods
forecast only current option values aggregation explorer disclaimer to forecast during grace period add option reordering (should be in mc/3804)
| ? previousForecast.forecast_values.map((v) => { | ||
| if (v === null) { | ||
| throw new Error("Forecast values contain null values"); | ||
| } | ||
| return v; | ||
| }) |
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.
You do the mapping with the same behavior multiple times, better to extract it and reuse
| const [mounted, setMounted] = React.useState(false); | ||
|
|
||
| React.useEffect(() => { | ||
| setMounted(true); | ||
| }, []); |
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.
| const [mounted, setMounted] = React.useState(false); | |
| React.useEffect(() => { | |
| setMounted(true); | |
| }, []); | |
| const [mounted, setMounted] = useState(false); | |
| useEffect(() => { | |
| setMounted(true); | |
| }, []); |
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.
maybe let's create a reusable hook, sth like useIsMounted, as I see a lot of places where similar behavior is used
| const showOverlay = | ||
| showUserMustForecast && !dismissedOverlay && newOptions.length > 0; | ||
|
|
||
| const firstNewOptionRef = React.useRef<HTMLTableRowElement | null>(null); |
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.
| const firstNewOptionRef = React.useRef<HTMLTableRowElement | null>(null); | |
| const firstNewOptionRef = useRef<HTMLTableRowElement | null>(null); |
| const NewOptionCallout: FC = () => { | ||
| const isPlural = newOptions.length > 1; | ||
| return ( | ||
| <div className="mb-3 w-full rounded-lg bg-blue-900 p-4 shadow-lg dark:bg-blue-900-dark"> | ||
| <p className="mb-2 mt-0 text-sm text-gray-0 dark:text-gray-0-dark"> | ||
| {isPlural | ||
| ? "These options were recently added, please adjust your forecast(s) accordingly." | ||
| : "A new option was recently added, please adjust your forecasts accordingly."} | ||
| </p> | ||
| {isPlural && newOptions.length > 0 && mounted && ( | ||
| <div className="mb-3 flex flex-wrap gap-4"> | ||
| {newOptions.map((option) => ( | ||
| <div key={option.name} className="flex items-center gap-1.5"> | ||
| <div | ||
| className="h-3 w-3 shrink-0 rounded-sm" | ||
| style={{ backgroundColor: getThemeColor(option.color) }} | ||
| /> | ||
| <span className="text-xs text-gray-0 dark:text-gray-0-dark"> | ||
| {option.name} | ||
| </span> | ||
| </div> | ||
| ))} | ||
| </div> | ||
| )} | ||
| <div className="flex gap-2"> | ||
| <Button variant="secondary" size="sm" onClick={scrollToNewOptions}> | ||
| {isPlural ? "Show New Options" : "Show New Option"} | ||
| </Button> | ||
| <Button | ||
| variant="text" | ||
| size="sm" | ||
| className="text-gray-0 hover:text-gray-100 dark:text-gray-0-dark dark:hover:text-gray-100-dark" | ||
| onClick={() => setDismissedOverlay(true)} | ||
| > | ||
| Dismiss | ||
| </Button> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
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.
Let's not nest it inside another component and add translations
No description provided.