Esempio n. 1
0
 /**
  * Vygeneruje početní otázku pro uživatele, která se bude doplňovat JavaScriptem.
  * @param \Nette\Utils\Html $group
  */
 private function generateJavaScriptQuestion(\Nette\Utils\Html &$group)
 {
     $groupId = $this->getHtmlId() . "-question-group";
     $javaScriptGroup = \Nette\Utils\Html::el("div id='{$groupId}'");
     $javaScriptGroup->class[] = $this->getHtmlName() . "-question-group";
     $this->questionLabelPrototype->setText($this->generateMathQuestion());
     $inputName = $this->getHtmlName() . "-question-result";
     $inputId = $this->getHtmlId() . "-question-result";
     $this->questionInputPrototype->addAttributes(["id" => $inputId, "name" => $inputName]);
     $javaScriptGroup->addHtml($this->questionLabelPrototype);
     $javaScriptGroup->addHtml($this->questionInputPrototype);
     $script = \Nette\Utils\Html::el("script");
     $script->setHtml("\r\n\t\t\tdocument.getElementById('{$inputId}').value = " . $this->result . ";\r\n\t\t\tdocument.getElementById('{$groupId}').style.display = 'none';\r\n\t\t");
     $javaScriptGroup->addHtml($script);
     $group->addHtml($javaScriptGroup);
 }