private function showStartQuizBox()
    {
        ?>
		<div class="wpProQuiz_text">
			<p>
				<?php 
        echo do_shortcode(apply_filters('comment_text', $this->quiz->getText()));
        ?>
			</p>
			
			<?php 
        if ($this->quiz->isFormActivated() && $this->quiz->getFormShowPosition() == WpProQuiz_Model_Quiz::QUIZ_FORM_POSITION_START) {
            $this->showFormBox();
        }
        ?>
			
			<div>
				<input class="wpProQuiz_button" type="button" value="<?php 
        echo $this->_buttonNames['start_quiz'];
        ?>
" name="startQuiz">
			</div>
		</div>
	<?php 
    }
    private function formTable()
    {
        if (!$this->quiz->isFormActivated()) {
            return;
        }
        ?>
        <div id="wpProQuiz_form_box">
            <div id="poststuff">
                <div class="postbox">
                    <h3 class="hndle"><?php 
        _e('Custom fields', 'wp-pro-quiz');
        ?>
</h3>

                    <div class="inside">
                        <table>
                            <tbody>
                            <?php 
        foreach ($this->forms as $form) {
            /* @var $form WpProQuiz_Model_Form */
            ?>
                                <tr>
                                    <td style="padding: 5px;"><?php 
            echo esc_html($form->getFieldname());
            ?>
</td>
                                    <td id="form_id_<?php 
            echo $form->getFormId();
            ?>
">asdfffffffffffffffffffffsadfsdfa
                                        sf asd fas
                                    </td>
                                </tr>
                            <?php 
        }
        ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <?php 
    }
 public function save(WpProQuiz_Model_Quiz $data)
 {
     if ($data->isResultGradeEnabled()) {
         $resultText = serialize($data->getResultText());
     } else {
         $resultText = $data->getResultText();
     }
     $set = array('name' => $data->getName(), 'text' => $data->getText(), 'result_text' => $resultText, 'title_hidden' => (int) $data->isTitleHidden(), 'btn_restart_quiz_hidden' => (int) $data->isBtnRestartQuizHidden(), 'btn_view_question_hidden' => (int) $data->isBtnViewQuestionHidden(), 'question_random' => (int) $data->isQuestionRandom(), 'answer_random' => (int) $data->isAnswerRandom(), 'time_limit' => (int) $data->getTimeLimit(), 'statistics_on' => (int) $data->isStatisticsOn(), 'statistics_ip_lock' => (int) $data->getStatisticsIpLock(), 'result_grade_enabled' => (int) $data->isResultGradeEnabled(), 'show_points' => (int) $data->isShowPoints(), 'quiz_run_once' => (int) $data->isQuizRunOnce(), 'quiz_run_once_type' => $data->getQuizRunOnceType(), 'quiz_run_once_cookie' => (int) $data->isQuizRunOnceCookie(), 'quiz_run_once_time' => (int) $data->getQuizRunOnceTime(), 'numbered_answer' => (int) $data->isNumberedAnswer(), 'hide_answer_message_box' => (int) $data->isHideAnswerMessageBox(), 'disabled_answer_mark' => (int) $data->isDisabledAnswerMark(), 'show_max_question' => (int) $data->isShowMaxQuestion(), 'show_max_question_value' => (int) $data->getShowMaxQuestionValue(), 'show_max_question_percent' => (int) $data->isShowMaxQuestionPercent(), 'toplist_activated' => (int) $data->isToplistActivated(), 'toplist_data' => $data->getToplistData(), 'show_average_result' => (int) $data->isShowAverageResult(), 'prerequisite' => (int) $data->isPrerequisite(), 'quiz_modus' => (int) $data->getQuizModus(), 'show_review_question' => (int) $data->isShowReviewQuestion(), 'quiz_summary_hide' => (int) $data->isQuizSummaryHide(), 'skip_question_disabled' => (int) $data->isSkipQuestionDisabled(), 'email_notification' => $data->getEmailNotification(), 'user_email_notification' => (int) $data->isUserEmailNotification(), 'show_category_score' => (int) $data->isShowCategoryScore(), 'hide_result_correct_question' => (int) $data->isHideResultCorrectQuestion(), 'hide_result_quiz_time' => (int) $data->isHideResultQuizTime(), 'hide_result_points' => (int) $data->isHideResultPoints(), 'autostart' => (int) $data->isAutostart(), 'forcing_question_solve' => (int) $data->isForcingQuestionSolve(), 'hide_question_position_overview' => (int) $data->isHideQuestionPositionOverview(), 'hide_question_numbering' => (int) $data->isHideQuestionNumbering(), 'form_activated' => (int) $data->isFormActivated(), 'form_show_position' => $data->getFormShowPosition(), 'start_only_registered_user' => (int) $data->isStartOnlyRegisteredUser(), 'questions_per_page' => $data->getQuestionsPerPage(), 'sort_categories' => (int) $data->isSortCategories(), 'show_category' => (int) $data->isShowCategory(), 'category_id' => (int) $data->getCategoryId(), 'admin_email' => $data->getAdminEmail(true), 'user_email' => $data->getUserEmail(true), 'plugin_container' => $data->getPluginContainer(true));
     if ($data->getId() != 0) {
         $result = $this->_wpdb->update($this->_table, $set, array('id' => $data->getId()), array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%s', '%s'), array('%d'));
     } else {
         $result = $this->_wpdb->insert($this->_table, $set, array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%s', '%s'));
         $data->setId($this->_wpdb->insert_id);
     }
     if ($result === false) {
         return null;
     }
     return $data;
 }
 /**
  * @param DOMDocument $dom
  * @param WpProQuiz_Model_Quiz $quiz
  * @param $forms
  * @return DOMElement
  */
 private function getQuizElement($dom, $quiz, $forms)
 {
     $quizElement = $dom->createElement('quiz');
     $title = $dom->createElement('title');
     $title->appendChild($dom->createCDATASection($quiz->getName()));
     $title->setAttribute('titleHidden', $this->booleanToTrueOrFalse($quiz->isTitleHidden()));
     $quizElement->appendChild($title);
     $quizElement->appendChild($text = $dom->createElement('text'));
     $text->appendChild($dom->createCDATASection($quiz->getText()));
     $quizElement->appendChild($dom->createElement('category', $quiz->getCategoryName()));
     if (is_array($quiz->getResultText())) {
         $resultArray = $quiz->getResultText();
         $result = $dom->createElement('resultText');
         $result->setAttribute('gradeEnabled', $this->booleanToTrueOrFalse($quiz->isResultGradeEnabled()));
         for ($i = 0; $i < count($resultArray); $i++) {
             $r = $dom->createElement('text');
             $r->appendChild($dom->createCDATASection($resultArray['text'][$i]));
             $r->setAttribute('prozent', $resultArray['prozent'][$i]);
             $result->appendChild($r);
         }
         $quizElement->appendChild($result);
     } else {
         $result = $dom->createElement('resultText');
         $result->setAttribute('gradeEnabled', $this->booleanToTrueOrFalse($quiz->isResultGradeEnabled()));
         $result->appendChild($dom->createCDATASection($quiz->getResultText()));
         $quizElement->appendChild($result);
     }
     $quizElement->appendChild($dom->createElement('btnRestartQuizHidden', $this->booleanToTrueOrFalse($quiz->isBtnRestartQuizHidden())));
     $quizElement->appendChild($dom->createElement('btnViewQuestionHidden', $this->booleanToTrueOrFalse($quiz->isBtnViewQuestionHidden())));
     $quizElement->appendChild($dom->createElement('questionRandom', $this->booleanToTrueOrFalse($quiz->isQuestionRandom())));
     $quizElement->appendChild($dom->createElement('answerRandom', $this->booleanToTrueOrFalse($quiz->isAnswerRandom())));
     $quizElement->appendChild($dom->createElement('timeLimit', $quiz->getTimeLimit()));
     $quizElement->appendChild($dom->createElement('showPoints', $this->booleanToTrueOrFalse($quiz->isShowPoints())));
     $statistic = $dom->createElement('statistic');
     $statistic->setAttribute('activated', $this->booleanToTrueOrFalse($quiz->isStatisticsOn()));
     $statistic->setAttribute('ipLock', $quiz->getStatisticsIpLock());
     $quizElement->appendChild($statistic);
     $quizElement->appendChild($quizRunOnce = $dom->createElement('quizRunOnce', $this->booleanToTrueOrFalse($quiz->isQuizRunOnce())));
     $quizRunOnce->setAttribute('type', $quiz->getQuizRunOnceType());
     $quizRunOnce->setAttribute('cookie', $this->booleanToTrueOrFalse($quiz->isQuizRunOnceCookie()));
     $quizRunOnce->setAttribute('time', $quiz->getQuizRunOnceTime());
     $quizElement->appendChild($dom->createElement('numberedAnswer', $this->booleanToTrueOrFalse($quiz->isNumberedAnswer())));
     $quizElement->appendChild($dom->createElement('hideAnswerMessageBox', $this->booleanToTrueOrFalse($quiz->isHideAnswerMessageBox())));
     $quizElement->appendChild($dom->createElement('disabledAnswerMark', $this->booleanToTrueOrFalse($quiz->isDisabledAnswerMark())));
     $quizElement->appendChild($showMaxQuestion = $dom->createElement('showMaxQuestion', $this->booleanToTrueOrFalse($quiz->isShowMaxQuestion())));
     $showMaxQuestion->setAttribute('showMaxQuestionValue', $quiz->getShowMaxQuestionValue());
     $showMaxQuestion->setAttribute('showMaxQuestionPercent', $this->booleanToTrueOrFalse($quiz->isShowMaxQuestionPercent()));
     //Toplist
     $toplist = $dom->createElement('toplist');
     $toplist->setAttribute('activated', $this->booleanToTrueOrFalse($quiz->isToplistActivated()));
     $toplist->appendChild($dom->createElement('toplistDataAddPermissions', $quiz->getToplistDataAddPermissions()));
     $toplist->appendChild($dom->createElement('toplistDataSort', $quiz->getToplistDataSort()));
     $toplist->appendChild($dom->createElement('toplistDataAddMultiple', $this->booleanToTrueOrFalse($quiz->isToplistDataAddMultiple())));
     $toplist->appendChild($dom->createElement('toplistDataAddBlock', $quiz->getToplistDataAddBlock()));
     $toplist->appendChild($dom->createElement('toplistDataShowLimit', $quiz->getToplistDataShowLimit()));
     $toplist->appendChild($dom->createElement('toplistDataShowIn', $quiz->getToplistDataShowIn()));
     $toplist->appendChild($dom->createElement('toplistDataCaptcha', $this->booleanToTrueOrFalse($quiz->isToplistDataCaptcha())));
     $toplist->appendChild($dom->createElement('toplistDataAddAutomatic', $this->booleanToTrueOrFalse($quiz->isToplistDataAddAutomatic())));
     $quizElement->appendChild($toplist);
     $quizElement->appendChild($dom->createElement('showAverageResult', $this->booleanToTrueOrFalse($quiz->isShowAverageResult())));
     $quizElement->appendChild($dom->createElement('prerequisite', $this->booleanToTrueOrFalse($quiz->isPrerequisite())));
     $quizElement->appendChild($dom->createElement('showReviewQuestion', $this->booleanToTrueOrFalse($quiz->isShowReviewQuestion())));
     $quizElement->appendChild($dom->createElement('quizSummaryHide', $this->booleanToTrueOrFalse($quiz->isQuizSummaryHide())));
     $quizElement->appendChild($dom->createElement('skipQuestionDisabled', $this->booleanToTrueOrFalse($quiz->isSkipQuestionDisabled())));
     $quizElement->appendChild($dom->createElement('emailNotification', $quiz->getEmailNotification()));
     $quizElement->appendChild($dom->createElement('userEmailNotification', $this->booleanToTrueOrFalse($quiz->isUserEmailNotification())));
     $quizElement->appendChild($dom->createElement('showCategoryScore', $this->booleanToTrueOrFalse($quiz->isShowCategoryScore())));
     $quizElement->appendChild($dom->createElement('hideResultCorrectQuestion', $this->booleanToTrueOrFalse($quiz->isHideResultCorrectQuestion())));
     $quizElement->appendChild($dom->createElement('hideResultQuizTime', $this->booleanToTrueOrFalse($quiz->isHideResultQuizTime())));
     $quizElement->appendChild($dom->createElement('hideResultPoints', $this->booleanToTrueOrFalse($quiz->isHideResultPoints())));
     $quizElement->appendChild($dom->createElement('autostart', $this->booleanToTrueOrFalse($quiz->isAutostart())));
     $quizElement->appendChild($dom->createElement('forcingQuestionSolve', $this->booleanToTrueOrFalse($quiz->isForcingQuestionSolve())));
     $quizElement->appendChild($dom->createElement('hideQuestionPositionOverview', $this->booleanToTrueOrFalse($quiz->isHideQuestionPositionOverview())));
     $quizElement->appendChild($dom->createElement('hideQuestionNumbering', $this->booleanToTrueOrFalse($quiz->isHideQuestionNumbering())));
     //0.27
     $quizElement->appendChild($dom->createElement('sortCategories', $this->booleanToTrueOrFalse($quiz->isSortCategories())));
     $quizElement->appendChild($dom->createElement('showCategory', $this->booleanToTrueOrFalse($quiz->isShowCategory())));
     $quizModus = $dom->createElement('quizModus', $quiz->getQuizModus());
     $quizModus->setAttribute('questionsPerPage', $quiz->getQuestionsPerPage());
     $quizElement->appendChild($quizModus);
     $quizElement->appendChild($dom->createElement('startOnlyRegisteredUser', $this->booleanToTrueOrFalse($quiz->isStartOnlyRegisteredUser())));
     $formsElement = $dom->createElement('forms');
     $formsElement->setAttribute('activated', $this->booleanToTrueOrFalse($quiz->isFormActivated()));
     $formsElement->setAttribute('position', $quiz->getFormShowPosition());
     //0.29
     if ($quiz->getAdminEmail() !== null) {
         /* @var $adminEmail WpProQuiz_Model_Email */
         $adminEmail = $quiz->getAdminEmail();
         $adminEmailXml = $dom->createElement('adminEmail');
         /*
         * $qElement->appendChild($title = $dom->createElement('title'));
                 $title->appendChild($dom->createCDATASection($question->getTitle()));
         */
         $adminEmailXml->appendChild($dom->createElement('to', $adminEmail->getTo()));
         $adminEmailXml->appendChild($dom->createElement('form', $adminEmail->getFrom()));
         $adminEmailXml->appendChild($dom->createElement('subject', $adminEmail->getSubject()));
         $adminEmailXml->appendChild($dom->createElement('html', $this->booleanToTrueOrFalse($adminEmail->isHtml())));
         $adminEmailXml->appendChild($message = $dom->createElement('message'));
         $message->appendChild($dom->createCDATASection($adminEmail->getMessage()));
         $quizElement->appendChild($adminEmailXml);
     }
     if ($quiz->getUserEmail() !== null) {
         /* @var $adminEmail WpProQuiz_Model_Email */
         $userEmail = $quiz->getUserEmail();
         $userEmaillXml = $dom->createElement('userEmail');
         $userEmaillXml->appendChild($dom->createElement('to', $userEmail->getTo()));
         $userEmaillXml->appendChild($dom->createElement('toUser', $this->booleanToTrueOrFalse($userEmail->isToUser())));
         $userEmaillXml->appendChild($dom->createElement('toForm', $this->booleanToTrueOrFalse($userEmail->isToForm())));
         $userEmaillXml->appendChild($dom->createElement('form', $userEmail->getFrom()));
         $userEmaillXml->appendChild($dom->createElement('subject', $userEmail->getSubject()));
         $userEmaillXml->appendChild($dom->createElement('html', $this->booleanToTrueOrFalse($userEmail->isHtml())));
         $userEmaillXml->appendChild($message = $dom->createElement('message'));
         $message->appendChild($dom->createCDATASection($userEmail->getMessage()));
         $quizElement->appendChild($userEmaillXml);
     }
     foreach ($forms as $form) {
         /** @var WpProQuiz_Model_Form $form * */
         $formElement = $dom->createElement('form');
         $formElement->setAttribute('type', $form->getType());
         $formElement->setAttribute('required', $this->booleanToTrueOrFalse($form->isRequired()));
         $formElement->setAttribute('fieldname', $form->getFieldname());
         if ($form->getData() !== null) {
             $data = $form->getData();
             foreach ($data as $d) {
                 $formDataElement = $dom->createElement('formData', $d);
                 $formElement->appendChild($formDataElement);
             }
         }
         $formsElement->appendChild($formElement);
     }
     $quizElement->appendChild($formsElement);
     return $quizElement;
 }
 /**
  * @param WpProQuiz_Model_Quiz $quiz
  * @param $data
  * @return array|null
  */
 private function makeFormData($quiz, $data)
 {
     if (!$quiz->isFormActivated() || empty($data)) {
         return null;
     }
     $formMapper = new WpProQuiz_Model_FormMapper();
     $forms = $formMapper->fetch($quiz->getId());
     if (empty($forms)) {
         return null;
     }
     $formArray = array();
     foreach ($forms as $form) {
         if ($form->getType() != WpProQuiz_Model_Form::FORM_TYPE_DATE) {
             $str = isset($data[$form->getFormId()]) ? $data[$form->getFormId()] : '';
             if (!WpProQuiz_Helper_Form::valid($form, $str)) {
                 return null;
             }
             $formArray[$form->getFormId()] = trim($str);
         } else {
             $date = isset($data[$form->getFormId()]) ? $data[$form->getFormId()] : array();
             $dateStr = WpProQuiz_Helper_Form::validData($form, $date);
             if ($dateStr === null) {
                 return null;
             }
             $formArray[$form->getFormId()] = $dateStr;
         }
     }
     return $formArray;
 }
    private function form()
    {
        $forms = $this->forms;
        $index = 0;
        if (!count($forms)) {
            $forms = array(new WpProQuiz_Model_Form(), new WpProQuiz_Model_Form());
        } else {
            array_unshift($forms, new WpProQuiz_Model_Form());
        }
        ?>
        <div class="postbox">
				<h3 class="hndle"><?php 
        _e('Custom fields', 'wp-pro-quiz');
        ?>
</h3>
				<div class="inside">
					
					<p class="description">
						<?php 
        _e('You can create custom fields, e.g. to request the name or the e-mail address of the users.', 'wp-pro-quiz');
        ?>
					</p>
					<p class="description">
						<?php 
        _e('The statistic function have to be enabled.', 'wp-pro-quiz');
        ?>
					</p>
					
					<table class="form-table">
						<tbody>
							<tr>
								<th scope="row">
									<?php 
        _e('Custom fields enable', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
										<legend class="screen-reader-text">
											<span><?php 
        _e('Custom fields enable', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										<label>
											<input type="checkbox" id="formActivated" value="1" name="formActivated" <?php 
        $this->checked($this->quiz->isFormActivated());
        ?>
>
											<?php 
        _e('Activate', 'wp-pro-quiz');
        ?>
										</label>
										<p class="description">
											<?php 
        _e('If you enable this option, custom fields are enabled.', 'wp-pro-quiz');
        ?>
										</p>
									</fieldset>
								</td>
							</tr>
							<tr>
								<th scope="row">
									<?php 
        _e('Display position', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
										<legend class="screen-reader-text">
											<span><?php 
        _e('Display position', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										<?php 
        _e('Where should the fileds be displayed:', 'wp-pro-quiz');
        ?>
 
										<label>
											<input type="radio" value="<?php 
        echo WpProQuiz_Model_Quiz::QUIZ_FORM_POSITION_START;
        ?>
" name="formShowPosition" <?php 
        $this->checked($this->quiz->getFormShowPosition(), WpProQuiz_Model_Quiz::QUIZ_FORM_POSITION_START);
        ?>
>
											<?php 
        _e('On the quiz startpage', 'wp-pro-quiz');
        ?>
											
											<div style="display: inline-block;" class="wpProQuiz_demoBox">
												<a href="#"><?php 
        _e('Demo', 'wp-pro-quiz');
        ?>
</a> 
												<div style="z-index: 9999999; position: absolute; background-color: #E9E9E9; padding: 10px; box-shadow: 0px 0px 10px 4px rgb(44, 44, 44); display: none; ">
													<img alt="" src="<?php 
        echo WPPROQUIZ_URL . '/img/customFieldsFront.png';
        ?>
 ">
												</div>
											</div>
											
										</label>
										<label>
											<input type="radio" value="<?php 
        echo WpProQuiz_Model_Quiz::QUIZ_FORM_POSITION_END;
        ?>
" name="formShowPosition" <?php 
        $this->checked($this->quiz->getFormShowPosition(), WpProQuiz_Model_Quiz::QUIZ_FORM_POSITION_END);
        ?>
 >
											<?php 
        _e('At the end of the quiz (before the quiz result)', 'wp-pro-quiz');
        ?>
											
											<div style="display: inline-block;" class="wpProQuiz_demoBox">
												<a href="#"><?php 
        _e('Demo', 'wp-pro-quiz');
        ?>
</a> 
												<div style="z-index: 9999999; position: absolute; background-color: #E9E9E9; padding: 10px; box-shadow: 0px 0px 10px 4px rgb(44, 44, 44); display: none; ">
													<img alt="" src="<?php 
        echo WPPROQUIZ_URL . '/img/customFieldsEnd1.png';
        ?>
 ">
												</div>
											</div>
											
											<div style="display: inline-block;" class="wpProQuiz_demoBox">
												<a href="#"><?php 
        _e('Demo', 'wp-pro-quiz');
        ?>
</a> 
												<div style="z-index: 9999999; position: absolute; background-color: #E9E9E9; padding: 10px; box-shadow: 0px 0px 10px 4px rgb(44, 44, 44); display: none; ">
													<img alt="" src="<?php 
        echo WPPROQUIZ_URL . '/img/customFieldsEnd2.png';
        ?>
 ">
												</div>
											</div>
											
										</label>
									</fieldset>
								</td>
							</tr>
						</tbody>
					</table>
					
					<div style="margin-top: 10px; padding: 10px; border: 1px solid #C2C2C2;">
						<table style=" width: 100%; text-align: left; " id="form_table">
							<thead>
								<tr>
									<th>#ID</th>
									<th><?php 
        _e('Field name', 'wp-pro-quiz');
        ?>
</th>
									<th><?php 
        _e('Type', 'wp-pro-quiz');
        ?>
</th>
									<th><?php 
        _e('Required?', 'wp-pro-quiz');
        ?>
</th>
									<th>
										<?php 
        _e('Show in statistic table?', 'wp-pro-quiz');
        ?>
										<div style="display: inline-block;" class="wpProQuiz_demoBox">
											<a href="#"><?php 
        _e('Demo', 'wp-pro-quiz');
        ?>
</a>
											<div style="z-index: 9999999; position: absolute; background-color: #E9E9E9; padding: 10px; box-shadow: 0px 0px 10px 4px rgb(44, 44, 44); display: none; ">
												<img alt="" src="<?php 
        echo WPPROQUIZ_URL . '/img/formStatisticOverview.png';
        ?>
 ">
											</div>
										</div>
									</th>
									<th></th>
								</tr>
							</thead>
							<tbody>
								<?php 
        foreach ($forms as $form) {
            $checkType = $this->selectedArray($form->getType(), array(WpProQuiz_Model_Form::FORM_TYPE_TEXT, WpProQuiz_Model_Form::FORM_TYPE_TEXTAREA, WpProQuiz_Model_Form::FORM_TYPE_CHECKBOX, WpProQuiz_Model_Form::FORM_TYPE_SELECT, WpProQuiz_Model_Form::FORM_TYPE_RADIO, WpProQuiz_Model_Form::FORM_TYPE_NUMBER, WpProQuiz_Model_Form::FORM_TYPE_EMAIL, WpProQuiz_Model_Form::FORM_TYPE_YES_NO, WpProQuiz_Model_Form::FORM_TYPE_DATE));
            ?>
								<tr <?php 
            echo $index++ == 0 ? 'style="display: none;"' : '';
            ?>
>
									<td>
										<?php 
            echo $index - 2;
            ?>
									</td>
									<td>
										<input type="text" name="form[][fieldname]" value="<?php 
            echo esc_attr($form->getFieldname());
            ?>
" class="regular-text formFieldName" />
									</td>
									<td style="position: relative;">
										<select name="form[][type]">
											<option value="<?php 
            echo WpProQuiz_Model_Form::FORM_TYPE_TEXT;
            ?>
" <?php 
            echo $checkType[0];
            ?>
><?php 
            _e('Text', 'wp-pro-quiz');
            ?>
</option>
											<option value="<?php 
            echo WpProQuiz_Model_Form::FORM_TYPE_TEXTAREA;
            ?>
" <?php 
            echo $checkType[1];
            ?>
><?php 
            _e('Textarea', 'wp-pro-quiz');
            ?>
</option>
											<option value="<?php 
            echo WpProQuiz_Model_Form::FORM_TYPE_CHECKBOX;
            ?>
" <?php 
            echo $checkType[2];
            ?>
><?php 
            _e('Checkbox', 'wp-pro-quiz');
            ?>
</option>
											<option value="<?php 
            echo WpProQuiz_Model_Form::FORM_TYPE_SELECT;
            ?>
" <?php 
            echo $checkType[3];
            ?>
><?php 
            _e('Drop-Down menu', 'wp-pro-quiz');
            ?>
</option>
											<option value="<?php 
            echo WpProQuiz_Model_Form::FORM_TYPE_RADIO;
            ?>
" <?php 
            echo $checkType[4];
            ?>
><?php 
            _e('Radio', 'wp-pro-quiz');
            ?>
</option>
											<option value="<?php 
            echo WpProQuiz_Model_Form::FORM_TYPE_NUMBER;
            ?>
" <?php 
            echo $checkType[5];
            ?>
><?php 
            _e('Number', 'wp-pro-quiz');
            ?>
</option>
											<option value="<?php 
            echo WpProQuiz_Model_Form::FORM_TYPE_EMAIL;
            ?>
" <?php 
            echo $checkType[6];
            ?>
><?php 
            _e('Email', 'wp-pro-quiz');
            ?>
</option>
											<option value="<?php 
            echo WpProQuiz_Model_Form::FORM_TYPE_YES_NO;
            ?>
" <?php 
            echo $checkType[7];
            ?>
><?php 
            _e('Yes/No', 'wp-pro-quiz');
            ?>
</option>
											<option value="<?php 
            echo WpProQuiz_Model_Form::FORM_TYPE_DATE;
            ?>
" <?php 
            echo $checkType[8];
            ?>
><?php 
            _e('Date', 'wp-pro-quiz');
            ?>
</option>
										</select>
										
										<a href="#" class="editDropDown"><?php 
            _e('Edit list', 'wp-pro-quiz');
            ?>
</a>
											
										<div class="dropDownEditBox" style="position: absolute; border: 1px solid #AFAFAF; background: #EBEBEB; padding: 5px; bottom: 0;right: 0;box-shadow: 1px 1px 1px 1px #AFAFAF; display: none;">
											<h4><?php 
            _e('One entry per line', 'wp-pro-quiz');
            ?>
</h4>
											<div>
												<textarea rows="5" cols="50" name="form[][data]"><?php 
            echo $form->getData() === null ? '' : esc_textarea(implode("\n", $form->getData()));
            ?>
</textarea>
											</div>
											
											<input type="button" value="<?php 
            _e('OK', 'wp-pro-quiz');
            ?>
" class="button-primary">
										</div>
									</td>
									<td>
										<input type="checkbox" name="form[][required]" value="1" <?php 
            $this->checked($form->isRequired());
            ?>
>
									</td>
									<td>
										<input type="checkbox" name="form[][show_in_statistic]" value="1" <?php 
            $this->checked($form->isShowInStatistic());
            ?>
>
									</td>
									<td>
										<input type="button" name="form_delete" value="<?php 
            _e('Delete', 'wp-pro-quiz');
            ?>
" class="button-secondary">
										<a class="form_move button-secondary" href="#" style="cursor:move;"><?php 
            _e('Move', 'wp-pro-quiz');
            ?>
</a>
										
										<input type="hidden" name="form[][form_id]" value="<?php 
            echo $form->getFormId();
            ?>
">
										<input type="hidden" name="form[][form_delete]" value="0">
									</td>
								</tr>
								<?php 
        }
        ?>
							</tbody>
						</table>
						
						<div style="margin-top: 10px;">
							<input type="button" name="form_add" id="form_add" value="<?php 
        _e('Add field', 'wp-pro-quiz');
        ?>
" class="button-secondary">
						</div>
					</div>
				</div>
			</div>
		<?php 
    }
 /**
  * @param WpProQuiz_Model_Quiz $quiz
  * @param $result
  * @param WpProQuiz_Model_Category[] $categories
  * @param WpProQuiz_Model_Form[] $forms
  * @param $inputForms
  */
 private function emailNote(WpProQuiz_Model_Quiz $quiz, $result, $categories, $forms, $inputForms)
 {
     $user = wp_get_current_user();
     $r = array('$userId' => $user->ID, '$username' => $user->display_name, '$quizname' => $quiz->getName(), '$result' => $result['result'] . '%', '$points' => $result['points'], '$ip' => filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP), '$categories' => empty($result['cats']) ? '' : $this->setCategoryOverview($result['cats'], $categories));
     if ($quiz->isFormActivated() && $forms !== null) {
         foreach ($forms as $form) {
             $value = '';
             if ($form->getType() == WpProQuiz_Model_Form::FORM_TYPE_DATE) {
                 if (isset($inputForms[$form->getFormId()])) {
                     $value = $inputForms[$form->getFormId()]['day'] . '-' . $inputForms[$form->getFormId()]['month'] . '-' . $inputForms[$form->getFormId()]['year'];
                 }
             } else {
                 $value = isset($inputForms[$form->getFormId()]) ? $inputForms[$form->getFormId()] : '';
             }
             $r['$form{' . $form->getSort() . '}'] = esc_html($value);
         }
     }
     if ($user->ID == 0) {
         $r['$username'] = $r['$ip'];
     }
     if ($quiz->isUserEmailNotification()) {
         $userEmail = $quiz->getUserEmail();
         $userAdress = null;
         if ($userEmail->isToUser() && get_current_user_id() > 0) {
             $userAdress = $user->user_email;
         } else {
             if ($userEmail->isToForm() && $quiz->isFormActivated()) {
                 foreach ($forms as $form) {
                     if ($form->getSort() == $userEmail->getTo()) {
                         if (isset($inputForms[$form->getFormId()])) {
                             $userAdress = $inputForms[$form->getFormId()];
                         }
                         break;
                     }
                 }
             }
         }
         if (!empty($userAdress) && filter_var($userAdress, FILTER_VALIDATE_EMAIL) !== false) {
             $msg = str_replace(array_keys($r), $r, $userEmail->getMessage());
             $headers = '';
             $email = $userEmail->getFrom();
             if (!empty($email)) {
                 $headers = 'From: ' . $userEmail->getFrom();
             }
             if ($userEmail->isHtml()) {
                 add_filter('wp_mail_content_type', array($this, 'htmlEmailContent'));
             }
             wp_mail($userAdress, $userEmail->getSubject(), $msg, $headers);
             if ($userEmail->isHtml()) {
                 remove_filter('wp_mail_content_type', array($this, 'htmlEmailContent'));
             }
         }
     }
     if ($quiz->getEmailNotification() == WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_ALL || get_current_user_id() > 0 && $quiz->getEmailNotification() == WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_REG_USER) {
         $adminEmail = $quiz->getAdminEmail();
         $msg = str_replace(array_keys($r), $r, $adminEmail->getMessage());
         $headers = '';
         $email = $adminEmail->getFrom();
         if (!empty($email)) {
             $headers = 'From: ' . $adminEmail->getFrom();
         }
         if ($adminEmail->isHtml()) {
             add_filter('wp_mail_content_type', array($this, 'htmlEmailContent'));
         }
         wp_mail($adminEmail->getTo(), $adminEmail->getSubject(), $msg, $headers);
         if ($adminEmail->isHtml()) {
             remove_filter('wp_mail_content_type', array($this, 'htmlEmailContent'));
         }
     }
 }