Skip to content

Embedded Component API

Geoffrey Kwan edited this page Jul 20, 2018 · 8 revisions

How an embedded model sends a message to WISE

The embedded Javascript model will use the iframe window.postMessage() to send data to WISE. Here is an example of how the model would send a message to WISE.

  let message = {
    messageType: "studentWork",
    studentData: {
      yourModelData1: "abc",
      yourModelData2: 123
    }
  }
  window.postMessage(message, "*");

Message types that the embedded model can send to WISE

Message Type Description
studentDataChanged The student data in the model has changed and the model is sending the student data to WISE so that it can be saved. This student data will be saved when WISE auto saves. Use this way of saving student data if you don't need complete control of how often student data is saved.
studentWork The model is sending student work to WISE so that it can be saved. This student data will be saved immediately. This can be used to overwrite existing saved data. Use this way of saving student data if you want complete control of how often student data is saved.
event An event has occurred in the model and the model is sending the event to WISE so that it can be saved. This event will be saved immediately.
applicationInitialized The model is telling WISE that the model is done initializing.
getParameters The model is requesting the parameters that have been authored into this WISE embedded component.
componentDirty The model is notifying WISE that it has unsaved student work.
componentSubmitDirty The model is notifying WISE that it has unsubmitted student work.
getStudentWork The model is requesting student work from WISE. This student work can be from any step and any component.
getLatestStudentWork The model is requesting the latest student work from this model.

Message types that WISE can send to the embedded model

Message Type Description
studentWork WISE is sending student work to the model. This is the response to the "getStudentWork" message that the model has sent to WISE. This student work can be from any step and any component.
latestStudentWork WISE is sending the latest student work to the model. This is the response to the "getLatestStudentWork" message that the model has sent to WISE.
parameters WISE is sending the parameters to the model. This is a response to the "getParameters" message that the model has sent to WISE.
componentStateSaved WISE is sending a confirmation that the model student work has been saved.
componentState WISE is sending the latest student work to the model. This is automatically sent when the component is loaded.
handleConnectedComponentStudentDataChanged The embedded component has a connected component. The student work in a connected component has changed in WISE so WISE is sending the connected component student work to the model.
siblingComponentStudentDataChanged The student work in the same step but a different component has changed in WISE so WISE is sending the sibling student work to the model.
Clone this wiki locally