    if (box_state == 1.0 && link_state == 1.0 && button_state == 1.0){
      console.log(['click-dialog', 1.0, box_state, button_state, link_state]);
      core.endEpisode(1.0, true);
    } else {
      console.log(['click-dialog', -1.0, box_state, button_state, link_state]);
      core.endEpisode(-1.0);
    }
  })

  // generate query text in the UI
  d3.select('#query').html('Click on the link "' + correctText + '", click on the "' + correct_text + '" button, select ' + qstr + ' and click Submit, and then