/**
  * @param stdClass $o
  * @returns \ScenarioModel
  */
 public static function fromObject($o)
 {
     $scenario = new ScenarioModel();
     $scenario->setId($o->id);
     $scenario->setStudyId($o->studyId);
     $scenario->setTitle($o->title);
     $scenario->setNamespace($o->namespace);
     $scenario->setText($o->text);
     $scenario->setCompiled($o->compiled);
     return $scenario;
 }
 function add_scenario()
 {
     $caseId = $this->session->get('caseId');
     $models = ModelModel::loadAll($caseId);
     $scenarios = ScenarioModel::loadAll($caseId);
     $case = CaseModel::load($caseId);
     $this->assign('models', $models);
     $this->assign('scenarios', $scenarios);
     $this->assign('case', $case);
     $this->load->view('scenario_add');
 }
 function add_report($studyId)
 {
     $this->assign('study', StudyModel::loadById($studyId));
     $this->assign('models', ModelModel::loadByStudy($studyId));
     $this->assign('scenarios', ScenarioModel::loadByStudy($studyId));
     $this->assign('queries', QueryModel::loadByStudy($studyId));
     $this->load->view('header');
     $this->load->view('add_report');
     $this->load->view('footer');
 }
 function delete_scenario($studyId, $scenarioId)
 {
     $this->load->model('ScenarioModel');
     ScenarioModel::delete($scenarioId);
     $this->location('/study/' . $studyId);
 }
 /**
  * @AjaxCallable=TRUE
  * @AjaxMethod=POST
  * @AjaxAsync=TRUE
  */
 function update_scenario_text()
 {
     $caseId = $this->session->get('caseId');
     $id = filter_input(INPUT_POST, 'id');
     $text = filter_input(INPUT_POST, 'text');
     ScenarioModel::updateText($id, $caseId, $text);
     $info = ScenarioModel::getInfo($id, $caseId);
     if (!$info['isError']) {
         $newId = $info['body']['id'];
         $name = $info['body']['name'];
         ScenarioModel::updateId($id, $caseId, $newId);
         ScenarioModel::updateName($newId, $caseId, $name);
         return $info;
     }
     return $info;
 }