phetsims / greenhouse-effect

"Greenhouse Effect" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
4 stars 4 forks source link

Launched Sim doesn't reset to default temperature units #352

Closed Nancy-Salpepi closed 10 months ago

Nancy-Salpepi commented 10 months ago

Test device MacBook Air M1 chip

Operating System 13.5

Browser Safari 16.6

Problem description For https://github.com/phetsims/qa/issues/970, the state of the default temperature units isn't working as it should. If a user changes the default units in the standard wrapper, pressing Reset All will restore the units to what the sim was launched in.

Steps to reproduce

  1. In Studio, press the Test button --> the standard wrapper will open with Celsius as the default temperature.
  2. In the preferences menu of the standard wrapper, change the default units to K.
  3. Go to any screen--> the temperature units will be in K
  4. Press Reset All --> temperature units go back to Celsius even though default is Kelvin.

Visuals

https://github.com/phetsims/greenhouse-effect/assets/87318828/58889154-e6f9-43dd-b943-9e810a0ad63b

jbphet commented 10 months ago

This might actually be the correct behavior. When a sim is launched from Studio like this, a reset is supposed to restore the state as it was when the sim was launched and not the completely unmodified state.

@arouinfar - My guess is that we've never thought about how reset should work for a global setting like this. I'd like to pass this off to you for consideration. It does strike me as a little weird that a global value is being reset in this way, but I think it's probably how the phet-io post-studio-launch reset works under the hood.

arouinfar commented 10 months ago

When a sim is launched from Studio like this, a reset is supposed to restore the state as it was when the sim was launched and not the completely unmodified state.

This is true. However, controls in the Preferences menu are not supposed to be overridden by the ResetAllButton, either. If a client doesn't want students to make changes to the Preferences, they can hide the tabs or individual controls on the SImulation tab.

I would expect that changes to Preferences after the sim is launched (e.g. enabling Interactive Highlights) should remain when the sim is reset. I think the same applies to the controls under the Simulation tab. This is how things are handled in Geometric Optics and Calculus Grapher.

jbphet commented 10 months ago

@samreid looked at this with me, and we realized that the situation here is a bit unique versus that of Geometric Optics and Calculus Grapher. In those sims, the value set in the Preferences dialog is used in the various screens and there is no way to deviate from the preferences in the screens. In Greenhouse the value for temperature units is a default that can be changed on each of the screens. Each of the screens therefore has its own state variable for the temperature units, and that is what is being restored on a reset in a standard wrapper. The solution that we came up with is to set the temperature units to the default value after phet-io state has finished updating.

jbphet commented 10 months ago

QA - Feel free to close once verified.

Nancy-Salpepi commented 10 months ago

This looks good in rc.1!