_buttonNames)) {
return;
}
$names = array(
'start_quiz' => __('Start quiz', 'wp-adv-quiz'),
'restart_quiz' => __('Restart quiz', 'wp-adv-quiz'),
'quiz_summary' => __('Quiz-summary', 'wp-adv-quiz'),
'finish_quiz' => __('Finish quiz', 'wp-adv-quiz'),
'quiz_is_loading' => __('Quiz is loading...', 'wp-adv-quiz'),
'lock_box_msg' => __('You have already completed the quiz before. Hence you can not start it again.',
'wp-adv-quiz'),
'only_registered_user_msg' => __('You must sign in or sign up to start the quiz.', 'wp-adv-quiz'),
'prerequisite_msg' => __('You have to finish following quiz, to start this quiz:', 'wp-adv-quiz')
);
$this->_buttonNames = ((array)apply_filters('wpAdvQuiz_filter_frontButtonNames', $names, $this)) + $names;
}
/**
* @param $data WpAdvQuiz_Model_AnswerTypes
*
* @return array
*/
private function getFreeCorrect($data)
{
$t = str_replace("\r\n", "\n", strtolower($data->getAnswer()));
$t = str_replace("\r", "\n", $t);
$t = explode("\n", $t);
return array_values(array_filter(array_map('trim', $t), array($this, 'removeEmptyElements')));
}
private function removeEmptyElements($v)
{
return !empty($v) || $v === '0';
}
public function show($preview = false)
{
$this->loadButtonNames();
$question_count = count($this->question);
$result = $this->quiz->getResultText();
//$result = preg_replace('##is', '', $result);
if (!$this->quiz->isResultGradeEnabled()) {
$result = array(
'text' => array($result),
'prozent' => array(0)
);
}
$resultsProzent = json_encode($result['prozent']);
$resultReplace = array();
foreach ($this->forms as $form) {
/* @var $form WpAdvQuiz_Model_Form */
$resultReplace['$form{' . $form->getSort() . '}'] = ' ';
}
$allowed_html = wp_kses_allowed_html( 'post' );
foreach ($result['text'] as &$text) {
$text = wp_kses($text, $allowed_html);
$text = str_replace(array_keys($resultReplace), $resultReplace, $text);
}
?>
quiz->isTitleHidden()) {
echo '
' . esc_html($this->quiz->getName()) . ' ';
}
$this->showTimeLimitBox();
$this->showCheckPageBox($question_count);
$this->showInfoPageBox();
$this->showStartQuizBox();
$this->showLockBox();
$this->showLoadQuizBox();
$this->showStartOnlyRegisteredUserBox();
$this->showPrerequisiteBox();
$this->showResultBox($result, $question_count);
if ($this->quiz->getToplistDataShowIn() == WpAdvQuiz_Model_Quiz::QUIZ_TOPLIST_SHOW_IN_BUTTON) {
$this->showToplistInButtonBox();
}
$this->showReviewBox($question_count);
$this->showQuizAnker();
$quizData = $this->showQuizBox($question_count);
?>
createOption($preview);
?>
quiz->isAnswerRandom()) << 0;
$bo |= ((int)$this->quiz->isQuestionRandom()) << 1;
$bo |= ((int)$this->quiz->isDisabledAnswerMark()) << 2;
$bo |= ((int)($this->quiz->isQuizRunOnce() || $this->quiz->isPrerequisite() || $this->quiz->isStartOnlyRegisteredUser())) << 3;
$bo |= ((int)$preview) << 4;
$bo |= ((int)get_option('wpAdvQuiz_corsActivated')) << 5;
$bo |= ((int)$this->quiz->isToplistDataAddAutomatic()) << 6;
$bo |= ((int)$this->quiz->isShowReviewQuestion()) << 7;
$bo |= ((int)$this->quiz->isQuizSummaryHide()) << 8;
$bo |= ((int)(!$this->quiz->isSkipQuestionDisabled() && $this->quiz->isShowReviewQuestion())) << 9;
$bo |= ((int)$this->quiz->isAutostart()) << 10;
$bo |= ((int)$this->quiz->isForcingQuestionSolve()) << 11;
$bo |= ((int)$this->quiz->isHideQuestionPositionOverview()) << 12;
$bo |= ((int)$this->quiz->isFormActivated()) << 13;
$bo |= ((int)$this->quiz->isShowMaxQuestion()) << 14;
$bo |= ((int)$this->quiz->isSortCategories()) << 15;
return $bo;
}
public function showMaxQuestion()
{
$this->loadButtonNames();
$question_count = count($this->question);
$result = $this->quiz->getResultText();
//$result = preg_replace('##is', '', $result);
$allowed_html = wp_kses_allowed_html( 'post' );
$result = wp_kses($result, $allowed_html);
if (!$this->quiz->isResultGradeEnabled()) {
$result = array(
'text' => array($result),
'prozent' => array(0)
);
}
$resultsProzent = json_encode($result['prozent']);
?>
quiz->isTitleHidden()) {
echo '
' . esc_html($this->quiz->getName()) . ' ';
}
$this->showTimeLimitBox();
$this->showCheckPageBox($question_count);
$this->showInfoPageBox();
$this->showStartQuizBox();
$this->showLockBox();
$this->showLoadQuizBox();
$this->showStartOnlyRegisteredUserBox();
$this->showPrerequisiteBox();
$this->showResultBox($result, $question_count);
if ($this->quiz->getToplistDataShowIn() == WpAdvQuiz_Model_Quiz::QUIZ_TOPLIST_SHOW_IN_BUTTON) {
$this->showToplistInButtonBox();
}
$this->showReviewBox($question_count);
$this->showQuizAnker();
?>
createOption(false);
?>
loadButtonNames();
$quizData = $this->showQuizBox(count($this->question));
$quizData['content'] = ob_get_contents();
ob_end_clean();
return $quizData;
}
private function showQuizAnker()
{
?>
$v) {
$text = $v[1];
$points = !empty($v[2]) ? (int)$v[2] : 1;
$rowText = $multiTextData = array();
$len = array();
if (preg_match_all('#\[(.*?)\]#im', $text, $multiTextMatches)) {
foreach ($multiTextMatches[1] as $multiText) {
$x = mb_strtolower(trim(html_entity_decode($multiText, ENT_QUOTES)));
$len[] = strlen($x);
$multiTextData[] = $x;
$rowText[] = $multiText;
}
} else {
$x = mb_strtolower(trim(html_entity_decode($text, ENT_QUOTES)));
$len[] = strlen($x);
$multiTextData[] = $x;
$rowText[] = $text;
}
$a = ' ';
$a .= '(' . implode(', ',
$rowText) . ') ';
$data['correct'][] = $multiTextData;
$data['points'][] = $points;
$data['data'][] = $a;
}
//$answerText = preg_replace('##is', '', $answerText);
$allowed_html = wp_kses_allowed_html( 'post' );
$answerText = wp_kses($answerText, $allowed_html);
$data['replace'] = preg_replace('#\{(.*?)(?:\|(\d+))?(?:[\s]+)?\}#im', '@@wpAdvQuizCloze@@', $answer_text);
return $data;
}
private function clozeCallback($t)
{
$a = array_shift($this->_clozeTemp);
return $a === null ? '' : $a;
}
private function fetchAssessment($answerText, $quizId, $questionId)
{
preg_match_all('#\{(.*?)\}#im', $answerText, $matches);
$this->_assessmetTemp = array();
$data = array();
for ($i = 0, $ci = count($matches[1]); $i < $ci; $i++) {
$match = $matches[1][$i];
preg_match_all('#\[([^\|\]]+)(?:\|(\d+))?\]#im', $match, $ms);
$a = '';
for ($j = 0, $cj = count($ms[1]); $j < $cj; $j++) {
$v = $ms[1][$j];
$a .= '
' . $v . '
';
}
$this->_assessmetTemp[] = $a;
}
//$answerText = preg_replace('##is', '', $answerText);
$allowed_html = wp_kses_allowed_html( 'post' );
$answerText = wp_kses($answerText, $allowed_html);
$data['replace'] = preg_replace('#\{(.*?)\}#im', '@@wpAdvQuizAssessment@@', $answerText);
return $data;
}
private function assessmentCallback($t)
{
$a = array_shift($this->_assessmetTemp);
return $a === null ? '' : $a;
}
private function showFormBox()
{
$info = '' . __('You must fill out this field.', 'wp-adv-quiz') . '
';
$validateText = array(
WpAdvQuiz_Model_Form::FORM_TYPE_NUMBER => __('You must specify a number.', 'wp-adv-quiz'),
WpAdvQuiz_Model_Form::FORM_TYPE_TEXT => __('You must specify a text.', 'wp-adv-quiz'),
WpAdvQuiz_Model_Form::FORM_TYPE_EMAIL => __('You must specify an email address.', 'wp-adv-quiz'),
WpAdvQuiz_Model_Form::FORM_TYPE_DATE => __('You must specify a date.', 'wp-adv-quiz')
);
?>
_buttonNames['lock_box_msg']); ?>
_buttonNames['only_registered_user_msg']); ?>
_buttonNames['prerequisite_msg']); ?>
0', $questionCount); ?>
:
quiz->isFormActivated() && $this->quiz->getFormShowPosition() == WpAdvQuiz_Model_Quiz::QUIZ_FORM_POSITION_END
&& ($this->quiz->isShowReviewQuestion() && !$this->quiz->isQuizSummaryHide())
) {
?>
showFormBox();
}
?>
quiz->isFormActivated() && $this->quiz->getFormShowPosition() == WpAdvQuiz_Model_Quiz::QUIZ_FORM_POSITION_END
&& (!$this->quiz->isShowReviewQuestion() || $this->quiz->isQuizSummaryHide())
) {
$this->showFormBox();
}
?>
quiz->getText();
//$postBoxQuizDescription = sanitize_text_field($postBoxQuizDescription);
echo do_shortcode(apply_filters('comment_text', $postBoxQuizDescription)); ?>
quiz->isFormActivated() && $this->quiz->getFormShowPosition() == WpAdvQuiz_Model_Quiz::QUIZ_FORM_POSITION_START) {
$this->showFormBox();
}
?>
quiz->isHideResultCorrectQuestion()) { ?>
0', '' . $questionCount . ' '); ?>
quiz->isHideResultQuizTime()) { ?>
', 'wp-adv-quiz'); ?>
quiz->isHideResultPoints()) { ?>
0',
'0 ', '0 '); ?>
quiz->isShowAverageResult()) { ?>
isDisplayNone($this->quiz->isShowCategoryScore()); ?>>
category as $cat) {
if (!$cat->getCategoryId()) {
$cat->setCategoryName(__('Not categorized', 'wp-adv-quiz'));
}
?>
getCategoryName()); ?>
0%
(.*?)#is', '', $resultText);
$allowed_html = wp_kses_allowed_html( 'post' );
$resultText = wp_kses($resultText, $allowed_html);
echo do_shortcode(apply_filters('comment_text', $resultText)); ?>
quiz->isToplistActivated()) {
if ($this->quiz->getToplistDataShowIn() == WpAdvQuiz_Model_Quiz::QUIZ_TOPLIST_SHOW_IN_NORMAL) {
echo do_shortcode('[WpAdvQuiz_toplist ' . $this->quiz->getId() . ' q="true"]');
}
$this->showAddToplist();
}
?>
quiz->isBtnRestartQuizHidden()) { ?>
quiz->isBtnViewQuestionHidden()) { ?>
quiz->isToplistActivated() && $this->quiz->getToplistDataShowIn() == WpAdvQuiz_Model_Quiz::QUIZ_TOPLIST_SHOW_IN_BUTTON) { ?>
quiz->getId() . ' q="true"]'); ?>
question as $question) {
$index++;
/* @var $answerArray WpAdvQuiz_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;
}
?>
isDisplayNone($this->quiz->getQuizModus() != WpAdvQuiz_Model_Quiz::QUIZ_MODUS_SINGLE && !$this->quiz->isHideQuestionPositionOverview()); ?> >
' . $index . '',
'' . $questionCount . ' '); ?>
quiz->isShowPoints()) { ?>
getPoints()); ?>
getCategoryId() && $this->quiz->isShowCategory()) { ?>
getCategoryName())); ?>
getQuestion(),$allowed_html) )); ?>
getAnswerType() === 'matrix_sort_answer') { ?>
$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) {
?>
isSortStringHtml()) ? $v->getSortString() : esc_html($v->getSortString()); ?>
isHtml() ? $v->getAnswer() : esc_html($v->getAnswer());
//$answer_text = preg_replace('##is', '', $answer_text);
$allowed_html = wp_kses_allowed_html( 'post' );
$answer_text = wp_kses($answer_text, $allowed_html);
if ($answer_text == '') {
continue;
}
if ($question->isAnswerPointsActivated()) {
$json[$question->getId()]['points'][] = $v->getPoints();
// if(!$question->isAnswerPointsDiffModusActivated())
// $catPoints[$question->getCategoryId()] += $question->getPoints();
}
?>
getAnswerType() === 'single' || $question->getAnswerType() === 'multiple') { ?>
getId()]['correct'][] = (int)$v->isCorrect(); ?>
quiz->isNumberedAnswer()) ? '' : 'style="display:none;"' ?>>
getAnswerType() === 'sort_answer') { ?>
getId()]['correct'][] = (int)$answer_index; ?>
getAnswerType() === 'free_answer') { ?>
getId()]['correct'] = $this->getFreeCorrect($v); ?>
getAnswerType() === 'matrix_sort_answer') { ?>
getId()]['correct'][] = (int)$answer_index;
$msacwValue = $question->getMatrixSortAnswerCriteriaWidth() > 0 ? $question->getMatrixSortAnswerCriteriaWidth() : 20;
?>
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('#@@wpAdvQuizCloze@@#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('#@@wpAdvQuizAssessment@@#im',
array($this, 'assessmentCallback'), $assessment);
}
}
}
}
}
} ?>
quiz->isHideAnswerMessageBox()) { ?>
isShowPointsInBox() && $question->isAnswerPointsActivated()) { ?>
getPoints()) . ' / ' . $question->getPoints(); ?>
getCorrectMsg())));
//$_correctMsg = preg_replace('##is', '', $_correctMsg);
$allowed_html = wp_kses_allowed_html( 'post' );
$_correctMsg = wp_kses($_correctMsg, $allowed_html);
if (stripos(ltrim($_correctMsg), '
]*>/i', $_correctMsg)) {
echo $_correctMsg;
} else {
echo '
', htmlspecialchars($_correctMsg, ENT_QUOTES, 'UTF-8'), '
';
}
?>
isShowPointsInBox() && $question->isAnswerPointsActivated()) { ?>
isCorrectSameText()) {
$_incorrectMsg = do_shortcode(apply_filters('comment_text',
$question->getCorrectMsg()));
} else {
$_incorrectMsg = do_shortcode(apply_filters('comment_text',
$question->getIncorrectMsg()));
}
//$_incorrectMsg = preg_replace('##is', '', $_incorrectMsg);
$allowed_html = wp_kses_allowed_html( 'post' );
$_incorrectMsg = wp_kses($_incorrectMsg, $allowed_html);
if (stripos(ltrim($_incorrectMsg), '
]*>/i', $_incorrectMsg)) {
echo $_incorrectMsg;
} else {
echo '
', htmlspecialchars($_incorrectMsg, ENT_QUOTES, 'UTF-8'), '
';
}
?>
isTipEnabled()) { ?>
getTipMsg();
//$tipMsg = preg_replace('##is', '', $tipMsg);
$allowed_html = wp_kses_allowed_html( 'post' );
$tipMsg = wp_kses($tipMsg, $allowed_html);
do_shortcode(apply_filters('comment_text', $tipMsg)); ?>
quiz->getQuizModus() == WpAdvQuiz_Model_Quiz::QUIZ_MODUS_CHECK && !$this->quiz->isSkipQuestionDisabled() && $this->quiz->isShowReviewQuestion()) { ?>
isTipEnabled()) { ?>
quiz->isBtnClearQuizHidden()) { ?>
quiz->isBtnViewPracticeShow()) { ?>
quiz->getQuizModus() == WpAdvQuiz_Model_Quiz::QUIZ_MODUS_SINGLE) { ?>
quiz->getQuizModus() == WpAdvQuiz_Model_Quiz::QUIZ_MODUS_SINGLE) { ?>
$globalPoints, 'json' => $json, 'catPoints' => $catPoints);
}
private function showLoadQuizBox()
{
?>
_buttonNames['quiz_is_loading']); ?>