Skip to content
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

PhET-iO design for scenes #193

Closed
samreid opened this issue May 10, 2023 · 17 comments
Closed

PhET-iO design for scenes #193

samreid opened this issue May 10, 2023 · 17 comments

Comments

@samreid
Copy link
Member

samreid commented May 10, 2023

From #164, we split up the model into scenes. @kathy-phet said:

Hey Sam, Cathy,
Agree with the above in terms of the what changes when you select a different player (just the data). Everything else stays the same - so you can easily compare data sets.

In thinking about PhET-iO of this aspect, I was thinking that each player should have the following data available under it:

  • Array of data points
  • Probability distribution that drives the data for this person
  • Mean
  • Median
  • IQR
  • MAD
  • Range
  • maybe an isActive read-only flag
    So that with the PhET-iO interface you can always access the data for each player, even if they are not the one that is visible.

Then there could be the a data structure in PhET-iO that is the "currently displayed values" that is read only. So that if you built a "save data" function to pull values into your system, you always get the visible data using the same static PhET-iO Element ID.

  • Active Player (who is visible)
  • Probability Distribution
  • Data array Values
  • Mean
  • Median
  • IQR
  • MAD
  • Range
@matthew-blackman
Copy link
Contributor

@samreid @marlitas and I discussed this and would like to move ahead with the following: In CAVModel, create a new IO type CAVModelIO, which would have a new method called getCurrentSceneData.

@samreid
Copy link
Member Author

samreid commented Jun 23, 2023

I'll work on this.

samreid added a commit that referenced this issue Jun 23, 2023
@samreid
Copy link
Member Author

samreid commented Jun 23, 2023

I implemented this and it can be called like:

await phetioClient.invokeAsync('centerAndVariability.medianScreen.model','getCurrentSceneData');

or

await phetioClient.invokeAsync('centerAndVariability.variabilityScreen.model','getCurrentSceneData');

It contains the state data for everything pertinent to that scene. For instance, the variability screen shows MAD values but the median screen does not.

Let's review this in an upcoming phet-io check-in.

Also tagging for #136

@samreid
Copy link
Member Author

samreid commented Jun 27, 2023

We reviewed this with @catherinecarter and @matthew-blackman and it seems like it is ready to close. But we want to share it with @kathy-phet at an upcoming team meeting so she is aware, and to get any other feedback.

@samreid
Copy link
Member Author

samreid commented Jul 18, 2023

@catherinecarter did we review this with @kathy-phet? Or is that still for an upcoming meeting.

@catherinecarter
Copy link
Contributor

If my memory serves me well, I believe we ran this by @kathy-phet, but I'm not 100% sure. I'll run it by her before saying yes here.

@catherinecarter
Copy link
Contributor

@kathy-phet is hoping to have another look at the second part of the comment from the top of this issue.

Simplified data structure to give the main pedagogical things for the data that's currently be displayed so no one needs to do back-processing to know what scene you're on. One array data structure to capture what's currently on the screen.

  • Always want to access the data for the current screen (only visible data)
    • this is already ready with the command above, but explore minimizing the prefix
    • pair down what data is being given
  • Also want to get the data for the scenes not visible (all data whether visible or not)

Requesting a meeting with MS, MB, KP, SR to discuss.

@samreid
Copy link
Member Author

samreid commented Jul 27, 2023

In the conversation above, we also noted that getCurrentSceneData requires the user to invoke it on the appropriate screen (i.e. it doesn't solve the problem of knowing which screen the user is on.)

Jotting down a note that may inform us when we meet with @matthew-blackman. Here is the code a client could use to get the current screen, current scene, and mean value on that scene. It uses one phet-io API call and processes the state. I'm not saying this is obvious or easy, but it is something we could document in the examples.md document:

// Get the entire state from the sim
const state = await phetioClient.invokeAsync('phetioEngine','getState');

// Identify which screen is currently selected
const screen = state['centerAndVariability.homeScreen.model.selectedScreenProperty'].value.phetioID;

// Identify which scene within that screen is currently selected
const scene = state[screen+'.model.selectedSceneModelProperty'].value.phetioID

// Access whatever data measures are of interest
const mean = state[scene+'.meanValueProperty'].value

@samreid
Copy link
Member Author

samreid commented Jul 31, 2023

I elaborated on the code above to use a better model property for the selected screen, and also a better way of getting the scene for screen 1-2.

// Get the entire state from the sim
const state = await phetioClient.invokeAsync( 'phetioEngine', 'getState' );

// Identify which screen is currently selected
const screen = state[ 'centerAndVariability.general.model.screens.selectedScreenProperty' ].value.phetioID;

if ( screen === 'centerAndVariability.homeScreen' ) {
  console.log( 'home screen is selected' )
}
else {

// Identify which scene within that screen is currently selected
  const scene = screen === 'centerAndVariability.meanAndMedianScreen' ? 'centerAndVariability.meanAndMedianScreen.model.sceneModel' :
                screen === 'centerAndVariability.medianScreen' ? 'centerAndVariability.medianScreen.model.sceneModel' :

                  // Variability screen has different scenes
                state[ screen + '.model.selectedSceneModelProperty' ].value.phetioID

// Access whatever data measures are of interest
  const mean = state[ scene + '.meanValueProperty' ].value
  const median = state[ scene + '.medianValueProperty' ].value

  console.log( 'mean=' + mean );
  console.log( 'median=' + median );
}

@samreid
Copy link
Member Author

samreid commented Jul 31, 2023

In discussion with @kathy-phet @matthew-blackman @marlitas and @samreid, we agreed we want to proceed by documenting this in the examples.md rather than adding a new API for feature (which would require development/maintenance/migration rules) for this. We will start with the code in the preceding comment. @kathy-phet says we will decide on a sim-by-sim basis if other sims have a need for something like this. As clients begin to use this, we will get a better sense of whether this is OK or whether we would need to add more support.

@samreid
Copy link
Member Author

samreid commented Jul 31, 2023

Tagging for #136

@samreid
Copy link
Member Author

samreid commented Jul 31, 2023

Closing since the remaining work will be done in #136

@samreid samreid closed this as completed Jul 31, 2023
@samreid
Copy link
Member Author

samreid commented Aug 22, 2023

Reopened for discussion today

@samreid samreid reopened this Aug 22, 2023
@samreid
Copy link
Member Author

samreid commented Aug 22, 2023

We discussed this may be a more appropriate level for examples.md, in order to find what scene is selected, and to get some data for the selected scene:

const scene = (await phetioClient.invokeAsync('centerAndVariability.variabilityScreen.model.selectedSceneModelProperty','getValue')).phetioID;
await phetioClient.invokeAsync(scene + '.meanValueProperty', 'getValue');

@samreid
Copy link
Member Author

samreid commented Aug 22, 2023

Here's a cleaner version:

const sceneElement = await phetioClient.invokeAsync('centerAndVariability.variabilityScreen.model.selectedSceneModelProperty','getValue');
await phetioClient.invokeAsync(sceneElement.phetioID + '.meanValueProperty', 'getValue');

@samreid
Copy link
Member Author

samreid commented Aug 22, 2023

Leaving @catherinecarter assigned to make sure this is documented in the examples.

@catherinecarter
Copy link
Contributor

Thanks. I've copied your code from above and have it recorded in examples. Closing.

@catherinecarter catherinecarter removed their assignment Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants