private function setResultCookie(WpProQuiz_Model_Quiz $quiz)
 {
     $prerequisite = new WpProQuiz_Model_PrerequisiteMapper();
     if (get_current_user_id() == 0 && $prerequisite->isQuizId($quiz->getId())) {
         $cookieData = array();
         if (isset($this->_cookie['wpProQuiz_result'])) {
             $d = json_decode($this->_cookie['wpProQuiz_result'], true);
             if ($d !== null && is_array($d)) {
                 $cookieData = $d;
             }
         }
         $cookieData[$quiz->getId()] = 1;
         $url = parse_url(get_bloginfo('url'));
         setcookie('wpProQuiz_result', json_encode($cookieData), time() + 60 * 60 * 24 * 300, empty($url['path']) ? '/' : $url['path']);
     }
 }
    public function show()
    {
        ?>
	
<style>
.wpProQuiz_blueBox {
	padding: 20px; 
	background-color: rgb(223, 238, 255); 
	border: 1px dotted;
	margin-top: 10px;
}
.categoryTr th {
	background-color: #F1F1F1;
}
.wpProQuiz_modal_backdrop {
	background: #000;
	opacity: 0.7;
	top: 0;
	bottom: 0;
	right: 0;
	left: 0;
	position: fixed;
	z-index: 159900;
}
.wpProQuiz_modal_window {
	position: fixed;
	background: #FFF;
	top: 40px;
	bottom: 40px;
	left: 40px;
	right: 40px;
	z-index: 160000;
}
.wpProQuiz_actions {
	display: none;
	padding: 2px 0 0;
}

.mobile .wpProQuiz_actions {
	display: block;
}

tr:hover .wpProQuiz_actions {
	display: block;
}
</style>

	<div class="wrap wpProQuiz_statisticsNew">
		<input type="hidden" id="quizId" value="<?php 
        echo $this->quiz->getId();
        ?>
" name="quizId">
		<h2><?php 
        printf(__('Quiz: %s - Statistics', 'wp-pro-quiz'), $this->quiz->getName());
        ?>
</h2>
		<p><a class="button-secondary" href="admin.php?page=wpProQuiz"><?php 
        _e('back to overview', 'wp-pro-quiz');
        ?>
</a></p>
		
		<?php 
        if (!$this->quiz->isStatisticsOn()) {
            ?>
		<p style="padding: 30px; background: #F7E4E4; border: 1px dotted; width: 300px;">
			<span style="font-weight: bold; padding-right: 10px;"><?php 
            _e('Stats not enabled', 'wp-pro-quiz');
            ?>
</span>
			<a class="button-secondary" href="admin.php?page=wpProQuiz&action=addEdit&quizId=<?php 
            echo $this->quiz->getId();
            ?>
"><?php 
            _e('Activate statistics', 'wp-pro-quiz');
            ?>
</a>
		</p>
		<?php 
            return;
        }
        ?>
		
		<div style="padding: 10px 0px;" class="wpProQuiz_tab_wrapper">
			<a class="button-primary" href="#" data-tab="#wpProQuiz_tabHistory"><?php 
        _e('History', 'wp-pro-quiz');
        ?>
</a>
			<a class="button-secondary" href="#" data-tab="#wpProQuiz_tabOverview"><?php 
        _e('Overview', 'wp-pro-quiz');
        ?>
</a>
		</div>
		
		<div id="wpProQuiz_loadData" class="wpProQuiz_blueBox" style="background-color: #F8F5A8; display: none;">
			<img alt="load" src="data:image/gif;base64,R0lGODlhEAAQAPYAAP///wAAANTU1JSUlGBgYEBAQERERG5ubqKiotzc3KSkpCQkJCgoKDAwMDY2Nj4+Pmpqarq6uhwcHHJycuzs7O7u7sLCwoqKilBQUF5eXr6+vtDQ0Do6OhYWFoyMjKqqqlxcXHx8fOLi4oaGhg4ODmhoaJycnGZmZra2tkZGRgoKCrCwsJaWlhgYGAYGBujo6PT09Hh4eISEhPb29oKCgqioqPr6+vz8/MDAwMrKyvj4+NbW1q6urvDw8NLS0uTk5N7e3s7OzsbGxry8vODg4NjY2PLy8tra2np6erS0tLKyskxMTFJSUlpaWmJiYkJCQjw8PMTExHZ2djIyMurq6ioqKo6OjlhYWCwsLB4eHqCgoE5OThISEoiIiGRkZDQ0NMjIyMzMzObm5ri4uH5+fpKSkp6enlZWVpCQkEpKSkhISCIiIqamphAQEAwMDKysrAQEBJqamiYmJhQUFDg4OHR0dC4uLggICHBwcCAgIFRUVGxsbICAgAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAAHjYAAgoOEhYUbIykthoUIHCQqLoI2OjeFCgsdJSsvgjcwPTaDAgYSHoY2FBSWAAMLE4wAPT89ggQMEbEzQD+CBQ0UsQA7RYIGDhWxN0E+ggcPFrEUQjuCCAYXsT5DRIIJEBgfhjsrFkaDERkgJhswMwk4CDzdhBohJwcxNB4sPAmMIlCwkOGhRo5gwhIGAgAh+QQJCgAAACwAAAAAEAAQAAAHjIAAgoOEhYU7A1dYDFtdG4YAPBhVC1ktXCRfJoVKT1NIERRUSl4qXIRHBFCbhTKFCgYjkII3g0hLUbMAOjaCBEw9ukZGgidNxLMUFYIXTkGzOmLLAEkQCLNUQMEAPxdSGoYvAkS9gjkyNEkJOjovRWAb04NBJlYsWh9KQ2FUkFQ5SWqsEJIAhq6DAAIBACH5BAkKAAAALAAAAAAQABAAAAeJgACCg4SFhQkKE2kGXiwChgBDB0sGDw4NDGpshTheZ2hRFRVDUmsMCIMiZE48hmgtUBuCYxBmkAAQbV2CLBM+t0puaoIySDC3VC4tgh40M7eFNRdH0IRgZUO3NjqDFB9mv4U6Pc+DRzUfQVQ3NzAULxU2hUBDKENCQTtAL9yGRgkbcvggEq9atUAAIfkECQoAAAAsAAAAABAAEAAAB4+AAIKDhIWFPygeEE4hbEeGADkXBycZZ1tqTkqFQSNIbBtGPUJdD088g1QmMjiGZl9MO4I5ViiQAEgMA4JKLAm3EWtXgmxmOrcUElWCb2zHkFQdcoIWPGK3Sm1LgkcoPrdOKiOCRmA4IpBwDUGDL2A5IjCCN/QAcYUURQIJIlQ9MzZu6aAgRgwFGAFvKRwUCAAh+QQJCgAAACwAAAAAEAAQAAAHjIAAgoOEhYUUYW9lHiYRP4YACStxZRc0SBMyFoVEPAoWQDMzAgolEBqDRjg8O4ZKIBNAgkBjG5AAZVtsgj44VLdCanWCYUI3txUPS7xBx5AVDgazAjC3Q3ZeghUJv5B1cgOCNmI/1YUeWSkCgzNUFDODKydzCwqFNkYwOoIubnQIt244MzDC1q2DggIBACH5BAkKAAAALAAAAAAQABAAAAeJgACCg4SFhTBAOSgrEUEUhgBUQThjSh8IcQo+hRUbYEdUNjoiGlZWQYM2QD4vhkI0ZWKCPQmtkG9SEYJURDOQAD4HaLuyv0ZeB4IVj8ZNJ4IwRje/QkxkgjYz05BdamyDN9uFJg9OR4YEK1RUYzFTT0qGdnduXC1Zchg8kEEjaQsMzpTZ8avgoEAAIfkECQoAAAAsAAAAABAAEAAAB4iAAIKDhIWFNz0/Oz47IjCGADpURAkCQUI4USKFNhUvFTMANxU7KElAhDA9OoZHH0oVgjczrJBRZkGyNpCCRCw8vIUzHmXBhDM0HoIGLsCQAjEmgjIqXrxaBxGCGw5cF4Y8TnybglprLXhjFBUWVnpeOIUIT3lydg4PantDz2UZDwYOIEhgzFggACH5BAkKAAAALAAAAAAQABAAAAeLgACCg4SFhjc6RhUVRjaGgzYzRhRiREQ9hSaGOhRFOxSDQQ0uj1RBPjOCIypOjwAJFkSCSyQrrhRDOYILXFSuNkpjggwtvo86H7YAZ1korkRaEYJlC3WuESxBggJLWHGGFhcIxgBvUHQyUT1GQWwhFxuFKyBPakxNXgceYY9HCDEZTlxA8cOVwUGBAAA7AAAAAAAAAAAA">
			<?php 
        _e('Loading', 'wp-pro-quiz');
        ?>
		</div>
		
		<div id="wpProQuiz_content" style="display: block;">
			<?php 
        $this->showHistory();
        ?>
			<?php 
        $this->showTabOverview();
        ?>
		</div>
		
		<?php 
        $this->showModalWindow();
        ?>
		
	</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;
 }
    private function showQuizBox($questionCount)
    {
        $globalPoints = 0;
        $json = array();
        $catPoints = array();
        ?>
		<div style="display: none;" class="wpProQuiz_quiz">
			<ol class="wpProQuiz_list">
			<?php 
        $index = 0;
        foreach ($this->question as $question) {
            $index++;
            /* @var $answerArray WpProQuiz_Model_AnswerTypes[] */
            $answerArray = $question->getAnswerData();
            $globalPoints += $question->getPoints();
            $json[$question->getId()]['type'] = $question->getAnswerType();
            $json[$question->getId()]['id'] = (int) $question->getId();
            $json[$question->getId()]['catId'] = (int) $question->getCategoryId();
            if ($question->isAnswerPointsActivated() && $question->isAnswerPointsDiffModusActivated() && $question->isDisableCorrect()) {
                $json[$question->getId()]['disCorrect'] = (int) $question->isDisableCorrect();
            }
            if (!isset($catPoints[$question->getCategoryId()])) {
                $catPoints[$question->getCategoryId()] = 0;
            }
            $catPoints[$question->getCategoryId()] += $question->getPoints();
            if (!$question->isAnswerPointsActivated()) {
                $json[$question->getId()]['points'] = $question->getPoints();
                // 					$catPoints[$question->getCategoryId()] += $question->getPoints();
            }
            if ($question->isAnswerPointsActivated() && $question->isAnswerPointsDiffModusActivated()) {
                // 					$catPoints[$question->getCategoryId()] += $question->getPoints();
                $json[$question->getId()]['diffMode'] = 1;
            }
            ?>
				<li class="wpProQuiz_listItem" style="display: none;">
					<div class="wpProQuiz_question_page" <?php 
            $this->isDisplayNone($this->quiz->getQuizModus() != WpProQuiz_Model_Quiz::QUIZ_MODUS_SINGLE && !$this->quiz->isHideQuestionPositionOverview());
            ?>
 >
						<?php 
            printf(__('Question %s of %s', 'wp-pro-quiz'), '<span>' . $index . '</span>', '<span>' . $questionCount . '</span>');
            ?>
					</div>
					<h5 style="<?php 
            echo $this->quiz->isHideQuestionNumbering() ? 'display: none;' : 'display: inline-block;';
            ?>
" class="wpProQuiz_header">
						<span><?php 
            echo $index;
            ?>
</span>. <?php 
            _e('Question', 'wp-pro-quiz');
            ?>
					</h5>
					
					<?php 
            if ($this->quiz->isShowPoints()) {
                ?>
						<span style="font-weight: bold; float: right;"><?php 
                printf(__('%d points', 'wp-pro-quiz'), $question->getPoints());
                ?>
</span>
						<div style="clear: both;"></div>
					<?php 
            }
            ?>
					
					<?php 
            if ($question->getCategoryId() && $this->quiz->isShowCategory()) {
                ?>
					<div style="font-weight: bold; padding-top: 5px;">
						<?php 
                printf(__('Category: %s', 'wp-pro-quiz'), esc_html($question->getCategoryName()));
                ?>
					</div>
					<?php 
            }
            ?>
					<div class="wpProQuiz_question" style="margin: 10px 0 0 0;">
						<div class="wpProQuiz_question_text">
							<?php 
            echo do_shortcode(apply_filters('comment_text', $question->getQuestion()));
            ?>
						</div>
						<?php 
            if ($question->getAnswerType() === 'matrix_sort_answer') {
                ?>
						<div class="wpProQuiz_matrixSortString">
							<h5 class="wpProQuiz_header"><?php 
                _e('Sort elements', 'wp-pro-quiz');
                ?>
</h5>
							<ul class="wpProQuiz_sortStringList">
							<?php 
                $matrix = array();
                foreach ($answerArray as $k => $v) {
                    $matrix[$k][] = $k;
                    foreach ($answerArray as $k2 => $v2) {
                        if ($k != $k2) {
                            if ($v->getAnswer() == $v2->getAnswer()) {
                                $matrix[$k][] = $k2;
                            } else {
                                if ($v->getSortString() == $v2->getSortString()) {
                                    $matrix[$k][] = $k2;
                                }
                            }
                        }
                    }
                }
                foreach ($answerArray as $k => $v) {
                    ?>
							 <li class="wpProQuiz_sortStringItem" data-pos="<?php 
                    echo $k;
                    ?>
" data-correct="<?php 
                    echo implode(',', $matrix[$k]);
                    ?>
">
							 	<?php 
                    echo $v->isSortStringHtml() ? $v->getSortString() : esc_html($v->getSortString());
                    ?>
							 </li>
							<?php 
                }
                ?>
							</ul>
							<div style="clear: both;"></div>
						</div>
						<?php 
            }
            ?>
						<ul class="wpProQuiz_questionList" data-question_id="<?php 
            echo $question->getId();
            ?>
" data-type="<?php 
            echo $question->getAnswerType();
            ?>
">
						<?php 
            $answer_index = 0;
            foreach ($answerArray as $v) {
                $answer_text = $v->isHtml() ? $v->getAnswer() : esc_html($v->getAnswer());
                if ($answer_text == '') {
                    continue;
                }
                if ($question->isAnswerPointsActivated()) {
                    $json[$question->getId()]['points'][] = $v->getPoints();
                    // 								if(!$question->isAnswerPointsDiffModusActivated())
                    // 									$catPoints[$question->getCategoryId()] += $question->getPoints();
                }
                ?>
								
								<li class="wpProQuiz_questionListItem" data-pos="<?php 
                echo $answer_index;
                ?>
">
								
							<?php 
                if ($question->getAnswerType() === 'single' || $question->getAnswerType() === 'multiple') {
                    ?>
								<?php 
                    $json[$question->getId()]['correct'][] = (int) $v->isCorrect();
                    ?>
									<span <?php 
                    echo $this->quiz->isNumberedAnswer() ? '' : 'style="display:none;"';
                    ?>
></span>
									<label>
										<input class="wpProQuiz_questionInput" type="<?php 
                    echo $question->getAnswerType() === 'single' ? 'radio' : 'checkbox';
                    ?>
" name="question_<?php 
                    echo $this->quiz->getId();
                    ?>
_<?php 
                    echo $question->getId();
                    ?>
" value="<?php 
                    echo $answer_index + 1;
                    ?>
"> <?php 
                    echo $answer_text;
                    ?>
									</label>
							
							<?php 
                } else {
                    if ($question->getAnswerType() === 'sort_answer') {
                        ?>
								<?php 
                        $json[$question->getId()]['correct'][] = (int) $answer_index;
                        ?>
									<div class="wpProQuiz_sortable">
										<?php 
                        echo $answer_text;
                        ?>
									</div>
						 	<?php 
                    } else {
                        if ($question->getAnswerType() === 'free_answer') {
                            ?>
						 		<?php 
                            $json[$question->getId()]['correct'] = $this->getFreeCorrect($v);
                            ?>
									<label>
										<input class="wpProQuiz_questionInput" type="text" name="question_<?php 
                            echo $this->quiz->getId();
                            ?>
_<?php 
                            echo $question->getId();
                            ?>
" style="width: 300px;">
									</label>
						 	<?php 
                        } else {
                            if ($question->getAnswerType() === 'matrix_sort_answer') {
                                ?>
						 		<?php 
                                $json[$question->getId()]['correct'][] = (int) $answer_index;
                                $msacwValue = $question->getMatrixSortAnswerCriteriaWidth() > 0 ? $question->getMatrixSortAnswerCriteriaWidth() : 20;
                                ?>
									<table>
										<tbody>
											<tr class="wpProQuiz_mextrixTr">
												<td width="<?php 
                                echo $msacwValue;
                                ?>
%"><div class="wpProQuiz_maxtrixSortText" ><?php 
                                echo $answer_text;
                                ?>
</div></td>
												<td width="<?php 
                                echo 100 - $msacwValue;
                                ?>
%" >
													<ul class="wpProQuiz_maxtrixSortCriterion"></ul>
												</td>
											</tr>
										</tbody>
									</table>
									
							 <?php 
                            } else {
                                if ($question->getAnswerType() === 'cloze_answer') {
                                    $clozeData = $this->fetchCloze($v->getAnswer());
                                    $this->_clozeTemp = $clozeData['data'];
                                    $json[$question->getId()]['correct'] = $clozeData['correct'];
                                    if ($question->isAnswerPointsActivated()) {
                                        $json[$question->getId()]['points'] = $clozeData['points'];
                                    }
                                    $cloze = do_shortcode(apply_filters('comment_text', $clozeData['replace']));
                                    $cloze = $clozeData['replace'];
                                    echo preg_replace_callback('#@@wpProQuizCloze@@#im', array($this, 'clozeCallback'), $cloze);
                                } else {
                                    if ($question->getAnswerType() === 'assessment_answer') {
                                        $assessmentData = $this->fetchAssessment($v->getAnswer(), $this->quiz->getId(), $question->getId());
                                        $assessment = do_shortcode(apply_filters('comment_text', $assessmentData['replace']));
                                        echo preg_replace_callback('#@@wpProQuizAssessment@@#im', array($this, 'assessmentCallback'), $assessment);
                                    }
                                }
                            }
                        }
                    }
                }
                ?>
						 		</li> 
						 <?php 
                $answer_index++;
            }
            ?>
						</ul>
					</div>
					<?php 
            if (!$this->quiz->isHideAnswerMessageBox()) {
                ?>
						<div class="wpProQuiz_response" style="display: none;">
							<div style="display: none;" class="wpProQuiz_correct">
								<?php 
                if ($question->isShowPointsInBox() && $question->isAnswerPointsActivated()) {
                    ?>
								<div>
									<span style="float: left;" class="wpProQuiz_respone_span">
										<?php 
                    _e('Correct', 'wp-pro-quiz');
                    ?>
									</span>
									<span style="float: right;"><?php 
                    echo $question->getPoints() . ' / ' . $question->getPoints();
                    ?>
 <?php 
                    _e('Points', 'wp-pro-quiz');
                    ?>
</span>
									<div style="clear: both;"></div>
								</div>		
							<?php 
                } else {
                    ?>
								<span class="wpProQuiz_respone_span">
									<?php 
                    _e('Correct', 'wp-pro-quiz');
                    ?>
								</span><br>
							<?php 
                }
                $_correctMsg = trim(do_shortcode(apply_filters('comment_text', $question->getCorrectMsg())));
                if (strpos($_correctMsg, '<p') === 0) {
                    echo $_correctMsg;
                } else {
                    echo '<p>', $_correctMsg, '</p>';
                }
                ?>
							</div>
							<div style="display: none;" class="wpProQuiz_incorrect">
							<?php 
                if ($question->isShowPointsInBox() && $question->isAnswerPointsActivated()) {
                    ?>
								<div>
									<span style="float: left;" class="wpProQuiz_respone_span">
										<?php 
                    _e('Incorrect', 'wp-pro-quiz');
                    ?>
									</span>
									<span style="float: right;"><span class="wpProQuiz_responsePoints"></span> / <?php 
                    echo $question->getPoints();
                    ?>
 <?php 
                    _e('Points', 'wp-pro-quiz');
                    ?>
</span>
									<div style="clear: both;"></div>
								</div>		
							<?php 
                } else {
                    ?>
								<span class="wpProQuiz_respone_span">
									<?php 
                    _e('Incorrect', 'wp-pro-quiz');
                    ?>
								</span><br>
							<?php 
                }
                if ($question->isCorrectSameText()) {
                    $_incorrectMsg = do_shortcode(apply_filters('comment_text', $question->getCorrectMsg()));
                } else {
                    $_incorrectMsg = do_shortcode(apply_filters('comment_text', $question->getIncorrectMsg()));
                }
                if (strpos($_incorrectMsg, '<p') === 0) {
                    echo $_incorrectMsg;
                } else {
                    echo '<p>', $_incorrectMsg, '</p>';
                }
                ?>
							</div>
						</div>
					<?php 
            }
            ?>
					
					<?php 
            if ($question->isTipEnabled()) {
                ?>
					<div class="wpProQuiz_tipp" style="display: none; position: relative;">
						<div>
							<h5 style="margin: 0 0 10px;" class="wpProQuiz_header"><?php 
                _e('Hint', 'wp-pro-quiz');
                ?>
</h5>
							<?php 
                echo do_shortcode(apply_filters('comment_text', $question->getTipMsg()));
                ?>
						</div>
					</div>
					<?php 
            }
            ?>
					
						<?php 
            if ($this->quiz->getQuizModus() == WpProQuiz_Model_Quiz::QUIZ_MODUS_CHECK && !$this->quiz->isSkipQuestionDisabled() && $this->quiz->isShowReviewQuestion()) {
                ?>
							<input type="button" name="skip" value="<?php 
                _e('Skip question', 'wp-pro-quiz');
                ?>
" class="wpProQuiz_button wpProQuiz_QuestionButton" style="float: left; margin-right: 10px !important;" >
						<?php 
            }
            ?>
						<input type="button" name="back" value="<?php 
            _e('Back', 'wp-pro-quiz');
            ?>
" class="wpProQuiz_button wpProQuiz_QuestionButton" style="float: left !important; margin-right: 10px !important; display: none;">
						<?php 
            if ($question->isTipEnabled()) {
                ?>
							<input type="button" name="tip" value="<?php 
                _e('Hint', 'wp-pro-quiz');
                ?>
" class="wpProQuiz_button wpProQuiz_QuestionButton wpProQuiz_TipButton" style="float: left !important; display: inline-block; margin-right: 10px !important;">
						<?php 
            }
            ?>
						<input type="button" name="check" value="<?php 
            _e('Check', 'wp-pro-quiz');
            ?>
" class="wpProQuiz_button wpProQuiz_QuestionButton" style="float: right !important; margin-right: 10px !important; display: none;">
						<input type="button" name="next" value="<?php 
            _e('Next', 'wp-pro-quiz');
            ?>
" class="wpProQuiz_button wpProQuiz_QuestionButton" style="float: right; display: none;" >
						<div style="clear: both;"></div>
						
					<?php 
            if ($this->quiz->getQuizModus() == WpProQuiz_Model_Quiz::QUIZ_MODUS_SINGLE) {
                ?>
						<div style="margin-bottom: 20px;"></div>
					<?php 
            }
            ?>
					
				</li>
			
			<?php 
        }
        ?>
			</ol>
			<?php 
        if ($this->quiz->getQuizModus() == WpProQuiz_Model_Quiz::QUIZ_MODUS_SINGLE) {
            ?>
				<div>
					<input type="button" name="wpProQuiz_pageLeft" data-text="<?php 
            echo esc_attr(__('Page %d', 'wp-pro-quiz'));
            ?>
" style="float: left; display: none;" class="wpProQuiz_button wpProQuiz_QuestionButton">
					<input type="button" name="wpProQuiz_pageRight" data-text="<?php 
            echo esc_attr(__('Page %d', 'wp-pro-quiz'));
            ?>
" style="float: right; display: none;" class="wpProQuiz_button wpProQuiz_QuestionButton">
					
					<?php 
            if ($this->quiz->isShowReviewQuestion() && !$this->quiz->isQuizSummaryHide()) {
                ?>
						<input type="button" name="checkSingle" value="<?php 
                echo $this->_buttonNames['quiz_summary'];
                ?>
" class="wpProQuiz_button wpProQuiz_QuestionButton" style="float: right;" >
					<?php 
            } else {
                ?>
						<input type="button" name="checkSingle" value="<?php 
                echo $this->_buttonNames['finish_quiz'];
                ?>
" class="wpProQuiz_button wpProQuiz_QuestionButton" style="float: right;">
					<?php 
            }
            ?>
					
					<div style="clear: both;"></div>
				</div>
			<?php 
        }
        ?>
		</div>
	<?php 
        return array('globalPoints' => $globalPoints, 'json' => $json, 'catPoints' => $catPoints);
    }
 private function handleAddInToplist(WpProQuiz_Model_Quiz $quiz)
 {
     if (!wp_verify_nonce($this->_post['token'], 'wpProQuiz_toplist')) {
         return array('text' => __('An error has occurred.', 'wp-pro-quiz'), 'clear' => true);
     }
     if (!isset($this->_post['points']) || !isset($this->_post['totalPoints'])) {
         return array('text' => __('An error has occurred.', 'wp-pro-quiz'), 'clear' => true);
     }
     $quizId = $quiz->getId();
     $userId = get_current_user_id();
     $points = (int) $this->_post['points'];
     $totalPoints = (int) $this->_post['totalPoints'];
     $name = !empty($this->_post['name']) ? trim($this->_post['name']) : '';
     $email = !empty($this->_post['email']) ? trim($this->_post['email']) : '';
     $ip = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP);
     $captchaAnswer = !empty($this->_post['captcha']) ? trim($this->_post['captcha']) : '';
     $prefix = !empty($this->_post['prefix']) ? trim($this->_post['prefix']) : '';
     $quizMapper = new WpProQuiz_Model_QuizMapper();
     $toplistMapper = new WpProQuiz_Model_ToplistMapper();
     if ($quiz == null || $quiz->getId() == 0 || !$quiz->isToplistActivated()) {
         return array('text' => __('An error has occurred.', 'wp-pro-quiz'), 'clear' => true);
     }
     if (!$this->preCheck($quiz->getToplistDataAddPermissions(), $userId)) {
         return array('text' => __('An error has occurred.', 'wp-pro-quiz'), 'clear' => true);
     }
     $numPoints = $quizMapper->sumQuestionPoints($quizId);
     if ($totalPoints > $numPoints || $points > $numPoints) {
         return array('text' => __('An error has occurred.', 'wp-pro-quiz'), 'clear' => true);
     }
     $clearTime = null;
     if ($quiz->isToplistDataAddMultiple()) {
         $clearTime = $quiz->getToplistDataAddBlock() * 60;
     }
     if ($userId > 0) {
         if ($toplistMapper->countUser($quizId, $userId, $clearTime)) {
             return array('text' => __('You can not enter again.', 'wp-pro-quiz'), 'clear' => true);
         }
         $user = wp_get_current_user();
         $email = $user->user_email;
         $name = $user->display_name;
     } else {
         if ($toplistMapper->countFree($quizId, $name, $email, $ip, $clearTime)) {
             return array('text' => __('You can not enter again.', 'wp-pro-quiz'), 'clear' => true);
         }
         if (empty($name) || empty($email) || filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
             return array('text' => __('No name or e-mail entered.', 'wp-pro-quiz'), 'clear' => false);
         }
         if (strlen($name) > 15) {
             return array('text' => __('Your name can not exceed 15 characters.', 'wp-pro-quiz'), 'clear' => false);
         }
         if ($quiz->isToplistDataCaptcha()) {
             $captcha = WpProQuiz_Helper_Captcha::getInstance();
             if ($captcha->isSupported()) {
                 if (!$captcha->check($prefix, $captchaAnswer)) {
                     return array('text' => __('You entered wrong captcha code.', 'wp-pro-quiz'), 'clear' => false);
                 }
             }
         }
     }
     $toplist = new WpProQuiz_Model_Toplist();
     $toplist->setQuizId($quizId)->setUserId($userId)->setDate(time())->setName($name)->setEmail($email)->setPoints($points)->setResult(round($points / $totalPoints * 100, 2))->setIp($ip);
     $toplistMapper->save($toplist);
     return true;
 }
 /**
  * @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;
 }
    public function show()
    {
        ?>
<style>
.wpProQuiz_quizModus th, .wpProQuiz_quizModus td {
	border-right: 1px solid #A0A0A0;
	padding: 5px;
}
.wpProQuiz_demoBox {
	position:  relative;
}
</style>
<div class="wrap wpProQuiz_quizEdit">
	<h2 style="margin-bottom: 10px;"><?php 
        echo $this->header;
        ?>
</h2>
	<form method="post" action="admin.php?page=wpProQuiz&action=addEdit&quizId=<?php 
        echo $this->quiz->getId();
        ?>
">
		<a style="float: left;" class="button-secondary" href="admin.php?page=wpProQuiz"><?php 
        _e('back to overview', 'wp-pro-quiz');
        ?>
</a>
		<div style="float: right;">
			<select name="templateLoadId">
				<?php 
        foreach ($this->templates as $template) {
            echo '<option value="', $template->getTemplateId(), '">', esc_html($template->getName()), '</option>';
        }
        ?>
			</select>
			<input type="submit" name="templateLoad" value="<?php 
        _e('load template', 'wp-pro-quiz');
        ?>
" class="button-primary">
		</div>
		<div style="clear: both;"></div>
		<div id="poststuff">
			<div class="postbox">
				<h3 class="hndle"><?php 
        _e('Quiz title', 'wp-pro-quiz');
        ?>
 <?php 
        _e('(required)', 'wp-pro-quiz');
        ?>
</h3>
				<div class="inside">
					<input name="name" id="wpProQuiz_title" type="text" class="regular-text" value="<?php 
        echo htmlspecialchars($this->quiz->getName(), ENT_QUOTES);
        ?>
">
				</div>
			</div>
			<div class="postbox">
				<h3 class="hndle"><?php 
        _e('Category', 'wp-pro-quiz');
        ?>
 <?php 
        _e('(optional)', 'wp-pro-quiz');
        ?>
</h3>
				<div class="inside">
					<p class="description">
						<?php 
        _e('You can assign classify category for a quiz.', 'wp-pro-quiz');
        ?>
					</p>
					<p class="description">
						<?php 
        _e('You can manage categories in global settings.', 'wp-pro-quiz');
        ?>
					</p>
					<div>
						<select name="category">
							<option value="-1">--- <?php 
        _e('Create new category', 'wp-pro-quiz');
        ?>
 ----</option>
							<option value="0" <?php 
        echo $this->quiz->getCategoryId() == 0 ? 'selected="selected"' : '';
        ?>
>--- <?php 
        _e('No category', 'wp-pro-quiz');
        ?>
 ---</option>
							<?php 
        foreach ($this->categories as $cat) {
            echo '<option ' . ($this->quiz->getCategoryId() == $cat->getCategoryId() ? 'selected="selected"' : '') . ' value="' . $cat->getCategoryId() . '">' . $cat->getCategoryName() . '</option>';
        }
        ?>
						</select>
					</div>
					<div style="display: none;" id="categoryAddBox">
						<h4><?php 
        _e('Create new category', 'wp-pro-quiz');
        ?>
</h4>
						<input type="text" name="categoryAdd" value=""> 
						<input type="button" class="button-secondary" name="" id="categoryAddBtn" value="<?php 
        _e('Create', 'wp-pro-quiz');
        ?>
"> 	
					</div>
					<div id="categoryMsgBox" style="display:none; padding: 5px; border: 1px solid rgb(160, 160, 160); background-color: rgb(255, 255, 168); font-weight: bold; margin: 5px; ">
						Kategorie gespeichert
					</div>
				</div>
			</div>

			<?php 
        do_action('wpProQuiz_action_plugin_quizEdit', $this);
        ?>

			<div class="postbox">
				<h3 class="hndle"><?php 
        _e('Options', 'wp-pro-quiz');
        ?>
</h3>
				<div class="inside">
					<table class="form-table">
						<tbody>
							<tr>
								<th scope="row">
									<?php 
        _e('Hide quiz title', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
										<legend class="screen-reader-text">
											<span><?php 
        _e('Hide title', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										<label for="title_hidden">
											<input type="checkbox" id="title_hidden" value="1" name="titleHidden" <?php 
        echo $this->quiz->isTitleHidden() ? 'checked="checked"' : '';
        ?>
 >
											<?php 
        _e('Activate', 'wp-pro-quiz');
        ?>
										</label>
										<p class="description">
											<?php 
        _e('The title serves as quiz heading.', 'wp-pro-quiz');
        ?>
										</p>
									</fieldset>
								</td>
							</tr>
							<tr>
								<th scope="row">
									<?php 
        _e('Hide "Restart quiz" button', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
										<legend class="screen-reader-text">
											<span><?php 
        _e('Hide "Restart quiz" button', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										<label for="btn_restart_quiz_hidden">
											<input type="checkbox" id="btn_restart_quiz_hidden" value="1" name="btnRestartQuizHidden" <?php 
        echo $this->quiz->isBtnRestartQuizHidden() ? 'checked="checked"' : '';
        ?>
 >
											<?php 
        _e('Activate', 'wp-pro-quiz');
        ?>
										</label>
										<p class="description">
											<?php 
        _e('Hide the "Restart quiz" button in the Frontend.', 'wp-pro-quiz');
        ?>
										</p>
									</fieldset>
								</td>
							</tr>
							<tr>
								<th scope="row">
									<?php 
        _e('Hide "View question" button', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
										<legend class="screen-reader-text">
											<span><?php 
        _e('Hide "View question" button', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										<label for="btn_view_question_hidden">
											<input type="checkbox" id="btn_view_question_hidden" value="1" name="btnViewQuestionHidden" <?php 
        echo $this->quiz->isBtnViewQuestionHidden() ? 'checked="checked"' : '';
        ?>
 >
											<?php 
        _e('Activate', 'wp-pro-quiz');
        ?>
										</label>
										<p class="description">
											<?php 
        _e('Hide the "View question" button in the Frontend.', 'wp-pro-quiz');
        ?>
										</p>
									</fieldset>
								</td>
							</tr>
							<tr>
								<th scope="row">
									<?php 
        _e('Display question randomly', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
										<legend class="screen-reader-text">
											<span><?php 
        _e('Display question randomly', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										<label for="question_random">
											<input type="checkbox" id="question_random" value="1" name="questionRandom" <?php 
        echo $this->quiz->isQuestionRandom() ? 'checked="checked"' : '';
        ?>
 >
											<?php 
        _e('Activate', 'wp-pro-quiz');
        ?>
										</label>
									</fieldset>
								</td>
							</tr>
							<tr>
								<th scope="row">
									<?php 
        _e('Display answers randomly', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
										<legend class="screen-reader-text">
											<span><?php 
        _e('Display answers randomly', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										<label for="answer_random">
											<input type="checkbox" id="answer_random" value="1" name="answerRandom" <?php 
        echo $this->quiz->isAnswerRandom() ? 'checked="checked"' : '';
        ?>
 >
											<?php 
        _e('Activate', 'wp-pro-quiz');
        ?>
										</label>
									</fieldset>
								</td>
							</tr>
							<tr>
								<th scope="row">
									<?php 
        _e('Sort questions by category', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
										<legend class="screen-reader-text">
											<span><?php 
        _e('Sort questions by category', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										<label>
											<input type="checkbox" value="1" name="sortCategories" <?php 
        $this->checked($this->quiz->isSortCategories());
        ?>
 >
											<?php 
        _e('Activate', 'wp-pro-quiz');
        ?>
										</label>
										<p class="description">
											<?php 
        _e('Also works in conjunction with the "display randomly question" option.', 'wp-pro-quiz');
        ?>
										</p>
									</fieldset>
								</td>
							</tr>
							<tr>
								<th scope="row">
									<?php 
        _e('Time limit', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
										<legend class="screen-reader-text">
											<span><?php 
        _e('Time limit', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										<label for="time_limit">
											<input type="number" min="0" class="small-text" id="time_limit" value="<?php 
        echo $this->quiz->getTimeLimit();
        ?>
" name="timeLimit"> <?php 
        _e('Seconds', 'wp-pro-quiz');
        ?>
										</label>
										<p class="description">
											<?php 
        _e('0 = no limit', 'wp-pro-quiz');
        ?>
										</p>
									</fieldset>
								</td>
							</tr>
							<tr>
								<th scope="row">
									<?php 
        _e('Statistics', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
										<legend class="screen-reader-text">
											<span><?php 
        _e('Statistics', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										<label for="statistics_on">
											<input type="checkbox" id="statistics_on" value="1" name="statisticsOn" <?php 
        echo $this->quiz->isStatisticsOn() ? 'checked="checked"' : '';
        ?>
>
											<?php 
        _e('Activate', 'wp-pro-quiz');
        ?>
										</label>
										<p class="description">
											<?php 
        _e('Statistics about right or wrong answers. Statistics will be saved by completed quiz, not after every question. The statistics is only visible over administration menu. (internal statistics)', 'wp-pro-quiz');
        ?>
										</p>
									</fieldset>
								</td>
							</tr>
							<tr id="statistics_ip_lock_tr" style="display: none;">
								<th scope="row">
									<?php 
        _e('Statistics IP-lock', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
										<legend class="screen-reader-text">
											<span><?php 
        _e('Statistics IP-lock', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										<label for="statistics_ip_lock">
											<input type="number" min="0" class="small-text" id="statistics_ip_lock" value="<?php 
        echo $this->quiz->getStatisticsIpLock() === null ? 1440 : $this->quiz->getStatisticsIpLock();
        ?>
" name="statisticsIpLock">
											<?php 
        _e('in minutes (recommended 1440 minutes = 1 day)', 'wp-pro-quiz');
        ?>
										</label>
										<p class="description">
											<?php 
        _e('Protect the statistics from spam. Result will only be saved every X minutes from same IP. (0 = deactivated)', 'wp-pro-quiz');
        ?>
										</p>
									</fieldset>
								</td>
							</tr>
							<tr>
								<th scope="row">
									<?php 
        _e('Execute quiz only once', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
									
										<legend class="screen-reader-text">
											<span><?php 
        _e('Execute quiz only once', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										
										<label>
											<input type="checkbox" value="1" name="quizRunOnce" <?php 
        echo $this->quiz->isQuizRunOnce() ? 'checked="checked"' : '';
        ?>
>
											<?php 
        _e('Activate', 'wp-pro-quiz');
        ?>
										</label>
										<p class="description">
											<?php 
        _e('If you activate this option, the user can complete the quiz only once. Afterwards the quiz is blocked for this user.', 'wp-pro-quiz');
        ?>
										</p>
										
										<div id="wpProQuiz_quiz_run_once_type" style="margin-bottom: 5px; display: none;">
											<?php 
        _e('This option applies to:', 'wp-pro-quiz');
        $quizRunOnceType = $this->quiz->getQuizRunOnceType();
        $quizRunOnceType = $quizRunOnceType == 0 ? 1 : $quizRunOnceType;
        ?>
		
											<label>
												<input name="quizRunOnceType" type="radio" value="1" <?php 
        echo $quizRunOnceType == 1 ? 'checked="checked"' : '';
        ?>
>
												<?php 
        _e('all users', 'wp-pro-quiz');
        ?>
											</label>
											<label>
												<input name="quizRunOnceType" type="radio" value="2" <?php 
        echo $quizRunOnceType == 2 ? 'checked="checked"' : '';
        ?>
>
												<?php 
        _e('registered useres only', 'wp-pro-quiz');
        ?>
											</label>
											<label>
												<input name="quizRunOnceType" type="radio" value="3" <?php 
        echo $quizRunOnceType == 3 ? 'checked="checked"' : '';
        ?>
>
												<?php 
        _e('anonymous users only', 'wp-pro-quiz');
        ?>
											</label>
											
											<div id="wpProQuiz_quiz_run_once_cookie" style="margin-top: 10px;">
												<label>
													<input type="checkbox" value="1" name="quizRunOnceCookie" <?php 
        echo $this->quiz->isQuizRunOnceCookie() ? 'checked="checked"' : '';
        ?>
>
													<?php 
        _e('user identification by cookie', 'wp-pro-quiz');
        ?>
												</label>
												<p class="description">
													<?php 
        _e('If you activate this option, a cookie is set additionally for unregistrated (anonymous) users. This ensures a longer assignment of the user than the simple assignment by the IP address.', 'wp-pro-quiz');
        ?>
												</p>
											</div>
											
											<div style="margin-top: 15px;">
												<input class="button-secondary" type="button" name="resetQuizLock" value="<?php 
        _e('Reset the user identification', 'wp-pro-quiz');
        ?>
">
												<span id="resetLockMsg" style="display:none; background-color: rgb(255, 255, 173); border: 1px solid rgb(143, 143, 143); padding: 4px; margin-left: 5px; "><?php 
        _e('User identification has been reset.');
        ?>
</span>
												<p class="description">
													<?php 
        _e('Resets user identification for all users.', 'wp-pro-quiz');
        ?>
												</p>
											</div>
										</div>
									</fieldset>
								</td>
							</tr>
							<tr>
								<th scope="row">
									<?php 
        _e('Show only specific number of questions', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
										<legend class="screen-reader-text">
											<span><?php 
        _e('Show only specific number of questions', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										<label>
											<input type="checkbox" value="1" name="showMaxQuestion" <?php 
        echo $this->quiz->isShowMaxQuestion() ? 'checked="checked"' : '';
        ?>
>
											<?php 
        _e('Activate', 'wp-pro-quiz');
        ?>
										</label>
										<p class="description">
											<?php 
        _e('If you enable this option, maximum number of displayed questions will be X from X questions. (The output of questions is random)', 'wp-pro-quiz');
        ?>
										</p>
										<div id="wpProQuiz_showMaxBox" style="display: none;">
											<label>
												<?php 
        _e('How many questions should be displayed simultaneously:', 'wp-pro-quiz');
        ?>
 
												<input class="small-text" type="text" name="showMaxQuestionValue" value="<?php 
        echo $this->quiz->getShowMaxQuestionValue();
        ?>
">
											</label>
											<label>
												<input type="checkbox" value="1" name="showMaxQuestionPercent" <?php 
        echo $this->quiz->isShowMaxQuestionPercent() ? 'checked="checked"' : '';
        ?>
>
												<?php 
        _e('in percent', 'wp-pro-quiz');
        ?>
 
											</label>
										</div>
									</fieldset>
								</td>
							</tr>
						<tr>
								<th scope="row">
									<?php 
        _e('End quiz after first incorrect answer', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
										<legend class="screen-reader-text">
											<span><?php 
        _e('End quiz after first incorrect answer', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										<label>
											<input type="checkbox" value="1" name="endOnFirstIncorrect" <?php 
        echo $this->quiz->isEndOnFirstIncorrect() ? 'checked="checked"' : '';
        ?>
>
											<?php 
        _e('Activate', 'wp-pro-quiz');
        ?>
										</label>
										<p class="description">
											<?php 
        _e('If you enable this option, first incorrect answer will end the test', 'wp-pro-quiz');
        ?>
										</p>
									</fieldset>
								</td>
						</tr>
						<tr>
								<th scope="row">
									<?php 
        _e('Prerequisites', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
										<legend class="screen-reader-text">
											<span><?php 
        _e('Prerequisites', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										<label>
											<input type="checkbox" value="1" name="prerequisite" <?php 
        $this->checked($this->quiz->isPrerequisite());
        ?>
>
											<?php 
        _e('Activate', 'wp-pro-quiz');
        ?>
										</label>
										<p class="description">
											<?php 
        _e('If you enable this option, you can choose quiz, which user have to finish before he can start this quiz.', 'wp-pro-quiz');
        ?>
										</p>
										<p class="description">
											<?php 
        _e('In all selected quizzes statistic function have to be active. If it is not it will be activated automatically.', 'wp-pro-quiz');
        ?>
										</p>
										<div id="prerequisiteBox" style="display: none;">
											<table>
												<tr>
													<th style="width: 120px; padding: 0;"><?php 
        _e('Quiz', 'wp-pro-quiz');
        ?>
</th>
													<th style="padding: 0; width: 50px;"></th>
													<th style="padding: 0; width: 400px;"><?php 
        _e('Prerequisites (This quiz have to be finished)', 'wp-pro-quiz');
        ?>
</th>
												</tr>
												<tr>
													<td style="padding: 0;">
														<select multiple="multiple" size="8" style="width: 200px;" name="quizList">
															<?php 
        foreach ($this->quizList as $list) {
            if (in_array($list['id'], $this->prerequisiteQuizList)) {
                continue;
            }
            echo '<option value="' . $list['id'] . '">' . $list['name'] . '</option>';
        }
        ?>
														</select>
													</td>
													<td style="padding: 0; text-align: center;">
														<div>
															<input type="button" id="btnPrerequisiteAdd" value="&gt;&gt;">
														</div>
														<div>
															<input type="button" id="btnPrerequisiteDelete" value="&lt;&lt;">
														</div>
													</td>
													<td style="padding: 0;">
														<select multiple="multiple" size="8" style="width: 200px" name="prerequisiteList[]">
															<?php 
        foreach ($this->quizList as $list) {
            if (!in_array($list['id'], $this->prerequisiteQuizList)) {
                continue;
            }
            echo '<option value="' . $list['id'] . '">' . $list['name'] . '</option>';
        }
        ?>
														</select>
													</td>
												</tr>
											</table>
										</div>
									</fieldset>
								</td>
							</tr>
							<tr>
								<th scope="row">
									<?php 
        _e('Question overview', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
										<legend class="screen-reader-text">
											<span><?php 
        _e('Question overview', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										<label>
											<input type="checkbox" value="1" name="showReviewQuestion" <?php 
        $this->checked($this->quiz->isShowReviewQuestion());
        ?>
>
											<?php 
        _e('Activate', 'wp-pro-quiz');
        ?>
										</label>
										<p class="description">
											<?php 
        _e('Add at the top of the quiz a question overview, which allows easy navigation. Additional questions can be marked "to review".', 'wp-pro-quiz');
        ?>
										</p>
										<p class="description">
											<?php 
        _e('Additional quiz overview will be displayed, before quiz is finished.', 'wp-pro-quiz');
        ?>
										</p>
										<div class="wpProQuiz_demoBox">
											<?php 
        _e('Question overview', 'wp-pro-quiz');
        ?>
: <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/questionOverview.png';
        ?>
 ">
											</div>
										</div>
										<div class="wpProQuiz_demoBox">
											<?php 
        _e('Quiz-summary', 'wp-pro-quiz');
        ?>
: <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/quizSummary.png';
        ?>
 ">
											</div>
										</div>
									</fieldset>
								</td>
							</tr>
							<tr class="wpProQuiz_reviewQuestionOptions" style="display: none;">
								<th scope="row">
									<?php 
        _e('Quiz-summary', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
										<legend class="screen-reader-text">
											<span><?php 
        _e('Quiz-summary', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										<label>
											<input type="checkbox" value="1" name="quizSummaryHide" <?php 
        $this->checked($this->quiz->isQuizSummaryHide());
        ?>
>
											<?php 
        _e('Deactivate', 'wp-pro-quiz');
        ?>
										</label>
										<p class="description">
											<?php 
        _e('If you enalbe this option, no quiz overview will be displayed, before finishing quiz.', 'wp-pro-quiz');
        ?>
										</p>
									</fieldset>
								</td>
							</tr>
							<tr class="wpProQuiz_reviewQuestionOptions" style="display: none;">
								<th scope="row">
									<?php 
        _e('Skip question', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
										<legend class="screen-reader-text">
											<span><?php 
        _e('Skip question', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										<label>
											<input type="checkbox" value="1" name="skipQuestionDisabled" <?php 
        $this->checked($this->quiz->isSkipQuestionDisabled());
        ?>
>
											<?php 
        _e('Deactivate', 'wp-pro-quiz');
        ?>
										</label>
										<p class="description">
											<?php 
        _e('If you enable this option, user won\'t be able to skip question. (only in "Overview -> next" mode). User still will be able to navigate over "Question-Overview"', 'wp-pro-quiz');
        ?>
										</p>
									</fieldset>
								</td>
							</tr>
							<!-- 
							<tr>
								<th scope="row">
									<?php 
        _e('Admin e-mail notification', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
										<legend class="screen-reader-text">
											<span><?php 
        _e('Admin e-mail notification', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										<label>
											<input type="radio" name="emailNotification" value="<?php 
        echo WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_NONE;
        ?>
" <?php 
        $this->checked($this->quiz->getEmailNotification(), WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_NONE);
        ?>
>
											<?php 
        _e('Deactivate', 'wp-pro-quiz');
        ?>
										</label>
										<label>
											<input type="radio" name="emailNotification" value="<?php 
        echo WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_REG_USER;
        ?>
" <?php 
        $this->checked($this->quiz->getEmailNotification(), WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_REG_USER);
        ?>
>
											<?php 
        _e('for registered users only', 'wp-pro-quiz');
        ?>
										</label>
										<label>
											<input type="radio" name="emailNotification" value="<?php 
        echo WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_ALL;
        ?>
" <?php 
        $this->checked($this->quiz->getEmailNotification(), WpProQuiz_Model_Quiz::QUIZ_EMAIL_NOTE_ALL);
        ?>
>
											<?php 
        _e('for all users', 'wp-pro-quiz');
        ?>
										</label>
										<p class="description">
											<?php 
        _e('If you enable this option, you will be informed if a user completes this quiz.', 'wp-pro-quiz');
        ?>
										</p>
										<p class="description">
											<?php 
        _e('E-Mail settings can be edited in global settings.', 'wp-pro-quiz');
        ?>
										</p>
									</fieldset>
								</td>
							</tr>
							
							<tr>
								<th scope="row">
									<?php 
        _e('User e-mail notification', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
										<legend class="screen-reader-text">
											<span><?php 
        _e('User e-mail notification', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										<label>
											<input type="checkbox" name="userEmailNotification" value="1" <?php 
        $this->checked($this->quiz->isUserEmailNotification());
        ?>
>
											<?php 
        _e('Activate', 'wp-pro-quiz');
        ?>
										</label>
										<p class="description">
											<?php 
        _e('If you enable this option, an email is sent with his quiz result to the user. (only registered users)', 'wp-pro-quiz');
        ?>
										</p>
										<p class="description">
											<?php 
        _e('E-Mail settings can be edited in global settings.', 'wp-pro-quiz');
        ?>
										</p>
									</fieldset>
								</td>
							</tr>
							 -->
							<tr>
								<th scope="row">
									<?php 
        _e('Autostart', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
										<legend class="screen-reader-text">
											<span><?php 
        _e('Autostart', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										<label>
											<input type="checkbox" name="autostart" value="1" <?php 
        $this->checked($this->quiz->isAutostart());
        ?>
>
											<?php 
        _e('Activate', 'wp-pro-quiz');
        ?>
										</label>
										<p class="description">
											<?php 
        _e('If you enable this option, the quiz will start automatically after the page is loaded.', 'wp-pro-quiz');
        ?>
										</p>
									</fieldset>
								</td>
							</tr>
							<tr>
								<th scope="row">
									<?php 
        _e('Only registered users are allowed to start the quiz', 'wp-pro-quiz');
        ?>
								</th>
								<td>
									<fieldset>
										<legend class="screen-reader-text">
											<span><?php 
        _e('Only registered users are allowed to start the quiz', 'wp-pro-quiz');
        ?>
</span>
										</legend>
										<label>
											<input type="checkbox" name="startOnlyRegisteredUser" value="1" <?php 
        $this->checked($this->quiz->isStartOnlyRegisteredUser());
        ?>
>
											<?php 
        _e('Activate', 'wp-pro-quiz');
        ?>
										</label>
										<p class="description">
											<?php 
        _e('If you enable this option, only registered users allowed start the quiz.', 'wp-pro-quiz');
        ?>
										</p>
									</fieldset>
								</td>
							</tr>
						</tbody>
					</table>
				</div>
			</div>
			<?php 
        $this->questionOptions();
        ?>
			<?php 
        $this->resultOptions();
        ?>
			<?php 
        $this->quizMode();
        ?>
			<?php 
        $this->leaderboardOptions();
        ?>
			<?php 
        $this->form();
        ?>
			<?php 
        $this->adminEmailOption();
        ?>
			<?php 
        $this->userEmailOption();
        ?>
			<div class="postbox">
				<h3 class="hndle"><?php 
        _e('Quiz description', 'wp-pro-quiz');
        ?>
 <?php 
        _e('(required)', 'wp-pro-quiz');
        ?>
</h3>
				<div class="inside">
					<p class="description">
						<?php 
        _e('This text will be displayed before start of the quiz.', 'wp-pro-quiz');
        ?>
					</p>
					<?php 
        wp_editor($this->quiz->getText(), "text");
        ?>
				</div>
			</div>
			<div class="postbox">
				<h3 class="hndle"><?php 
        _e('Results text', 'wp-pro-quiz');
        ?>
 <?php 
        _e('(optional)', 'wp-pro-quiz');
        ?>
</h3>
				<div class="inside">
					<p class="description">
						<?php 
        _e('This text will be displayed at the end of the quiz (in results). (this text is optional)', 'wp-pro-quiz');
        ?>
					</p>
					<div style="padding-top: 10px; padding-bottom: 10px;">
						<label for="wpProQuiz_resultGradeEnabled">
							<?php 
        _e('Activate graduation', 'wp-pro-quiz');
        ?>
  
							<input type="checkbox" name="resultGradeEnabled" id="wpProQuiz_resultGradeEnabled" value="1" <?php 
        echo $this->quiz->isResultGradeEnabled() ? 'checked="checked"' : '';
        ?>
>
						</label>
					</div>
					<div style="display: none;" id="resultGrade">
						<div>
							<strong><?php 
        _e('Hint:', 'wp-pro-quiz');
        ?>
</strong>
							<ul style="list-style-type: square; padding: 5px; margin-left: 20px; margin-top: 0;">
								<li><?php 
        _e('Maximal 15 levels', 'wp-pro-quiz');
        ?>
</li>
								<li>
									<?php 
        printf(__('Percentages refer to the total score of the quiz. (Current total %d points in %d questions.', 'wp-pro-quiz'), $this->quiz->fetchSumQuestionPoints(), $this->quiz->fetchCountQuestions());
        ?>
									</li>
								<li><?php 
        _e('Values can also be mixed up', 'wp-pro-quiz');
        ?>
</li>
								<li><?php 
        _e('10,15% or 10.15% allowed (max. two digits after the decimal point)', 'wp-pro-quiz');
        ?>
</li>
							</ul>
								
						</div>
						<div>
							<ul id="resultList">
							<?php 
        $resultText = $this->quiz->getResultText();
        for ($i = 0; $i < 15; $i++) {
            if ($this->quiz->isResultGradeEnabled() && isset($resultText['text'][$i])) {
                ?>
								<li style="padding: 5px; border: 1; border: 1px dotted;">
									<div style="margin-bottom: 5px;"><?php 
                wp_editor($resultText['text'][$i], 'resultText_' . $i, array('textarea_rows' => 3, 'textarea_name' => 'resultTextGrade[text][]'));
                ?>
</div>
									<div style="margin-bottom: 5px;background-color: rgb(207, 207, 207);padding: 10px;">
										<?php 
                _e('from:', 'wp-pro-quiz');
                ?>
 <input type="text" name="resultTextGrade[prozent][]" class="small-text" value="<?php 
                echo $resultText['prozent'][$i];
                ?>
"> <?php 
                _e('percent', 'wp-pro-quiz');
                ?>
 <?php 
                printf(__('(Will be displayed, when result-percent is >= <span class="resultProzent">%s</span>%%)', 'wp-pro-quiz'), $resultText['prozent'][$i]);
                ?>
										<input type="button" style="float: right;" class="button-primary deleteResult" value="<?php 
                _e('Delete graduation', 'wp-pro-quiz');
                ?>
">
										<div style="clear: right;"></div>
										<input type="hidden" value="1" name="resultTextGrade[activ][]">
									</div>
								</li>
							
							<?php 
            } else {
                ?>
								<li style="padding: 5px; border: 1; border: 1px dotted; <?php 
                echo $i ? 'display:none;' : '';
                ?>
">
									<div style="margin-bottom: 5px;"><?php 
                wp_editor('', 'resultText_' . $i, array('textarea_rows' => 3, 'textarea_name' => 'resultTextGrade[text][]'));
                ?>
</div>
									<div style="margin-bottom: 5px;background-color: rgb(207, 207, 207);padding: 10px;">
										<?php 
                _e('from:', 'wp-pro-quiz');
                ?>
 <input type="text" name="resultTextGrade[prozent][]" class="small-text" value="0"> <?php 
                _e('percent', 'wp-pro-quiz');
                ?>
 <?php 
                printf(__('(Will be displayed, when result-percent is >= <span class="resultProzent">%s</span>%%)', 'wp-pro-quiz'), '0');
                ?>
										<input type="button" style="float: right;" class="button-primary deleteResult" value="<?php 
                _e('Delete graduation', 'wp-pro-quiz');
                ?>
">
										<div style="clear: right;"></div>
										<input type="hidden" value="<?php 
                echo $i ? '0' : '1';
                ?>
" name="resultTextGrade[activ][]">
									</div>
								</li>
							<?php 
            }
        }
        ?>
							</ul>
							<input type="button" class="button-primary addResult" value="<?php 
        _e('Add graduation', 'wp-pro-quiz');
        ?>
">
						</div>
					</div>
					<div id="resultNormal">
						<?php 
        $resultText = is_array($resultText) ? '' : $resultText;
        wp_editor($resultText, 'resultText', array('textarea_rows' => 10));
        ?>
					</div>
					
					<h4><?php 
        _e('Custom fields - Variables', 'wp-pro-quiz');
        ?>
</h4>
					<ul class="formVariables"></ul>
					
				</div>
			</div>
		<div style="float: left;">
			<input type="submit" name="submit" class="button-primary" id="wpProQuiz_save" value="<?php 
        _e('Save', 'wp-pro-quiz');
        ?>
">
		</div>
		<div style="float: right;">
			<input type="text" placeholder="<?php 
        _e('template name', 'wp-pro-quiz');
        ?>
" class="regular-text" name="templateName" style="border: 1px solid rgb(255, 134, 134);">
			<select name="templateSaveList">
				<option value="0">=== <?php 
        _e('Create new template', 'wp-pro-quiz');
        ?>
 === </option>
				<?php 
        foreach ($this->templates as $template) {
            echo '<option value="', $template->getTemplateId(), '">', esc_html($template->getName()), '</option>';
        }
        ?>
			</select>
			
			<input type="submit" name="template" class="button-primary" id="wpProQuiz_saveTemplate" value="<?php 
        _e('Save as template', 'wp-pro-quiz');
        ?>
">
		</div>
		<div style="clear: both;"></div>
		</div>
	</form>
</div>
<?php 
    }