/**
  * @param ISurvey $parent
  * @param IEntitySurveyTemplate $template
  * @param $owner
  * @return EntitySurvey
  */
 public function buildEntitySurvey(ISurvey $parent, IEntitySurveyTemplate $template, $owner)
 {
     $survey = new EntitySurvey();
     $survey->TemplateID = $template->getIdentifier();
     $survey->CreatedByID = $owner->getIdentifier();
     $survey->ParentID = $parent->getIdentifier();
     $i = 0;
     foreach ($template->getSteps() as $step_template) {
         ++$i;
         $new_step = $this->buildStep($step_template);
         $survey->addStep($new_step);
         if ($i == 1) {
             $survey->registerCurrentStep($new_step);
             $survey->registerAllowedMaxStep($new_step);
         }
     }
     return $survey;
 }