Example #1
0
        protected function show_slickquiz($id)
        {
            global $quiz, $status, $pageQuizzes;
            $quizModel = new SlickQuizModel();
            $quiz = $quizModel->get_quiz_by_id($id);
            $out = '';
            if ($quiz) {
                $status = $quizModel->get_quiz_status($quiz);
                $pageQuizzes[$id] = array($quiz, $status);
                if ($status == self::NOT_PUBLISHED) {
                    $out .= "<p class='quiz-{$id} notPublished'>" . $this->get_admin_option('disabled_quiz_message') . "</p>";
                } else {
                    $out .= '
                        <div class="slickQuizWrapper" id="slickQuiz' . $quiz->id . '">
                            <h2 class="quizName"></h2>

                            <div class="quizArea">
                                <div class="quizHeader">
                                    <div class="buttonWrapper"><a class="button startQuiz" href="#">' . $this->get_admin_option('start_button_text') . '</a></div>
                                </div>
                            </div>

                            <div class="quizResults">
                                <div class="quizResultsCopy">
                                    <h3 class="quizScore">' . $this->get_admin_option('your_score_text') . ' <span>&nbsp;</span></h3>
                                    <h3 class="quizLevel">' . $this->get_admin_option('your_ranking_text') . ' <span>&nbsp;</span></h3>';
                    if ($this->get_admin_option('share_links') == '1') {
                        $out .= '
                                    <div class="quizShare"></div>';
                    }
                    $out .= '
                                </div>';
                    if (has_action('slickquiz_after_result')) {
                        $out .= apply_filters('slickquiz_after_result', $this);
                    }
                    $out .= '
                            </div>
                        </div>';
                }
            } else {
                $out .= "<p class='quiz-{$id} notFound'>" . $this->get_admin_option('missing_quiz_message') . "</p>";
            }
            return $out;
        }
Example #2
0
        public function form($instance)
        {
            $title = isset($instance['title']) ? $instance['title'] : 'Top Quiz Scores';
            ?>
            <p>
            <label for="<?php 
            echo $this->get_field_name('title');
            ?>
"><?php 
            _e('Title:');
            ?>
</label>
            <input class="widefat" id="<?php 
            echo $this->get_field_id('title');
            ?>
" name="<?php 
            echo $this->get_field_name('title');
            ?>
" type="text" value="<?php 
            echo esc_attr($title);
            ?>
" />
            </p>
            <?php 
            $quiz_id = isset($instance['quiz_id']) ? $instance['quiz_id'] : '';
            $quizModel = new SlickQuizModel();
            $quizzes = $quizModel->get_all_quizzes('id, name');
            if (count($quizzes) > 0) {
                ?>
                <p>
                <label for="<?php 
                echo $this->get_field_name('quiz_id');
                ?>
"><?php 
                _e('Quiz:');
                ?>
</label>
                <select class="widefat" id="<?php 
                echo $this->get_field_id('quiz_id');
                ?>
" name="<?php 
                echo $this->get_field_name('quiz_id');
                ?>
">
                <option value=""></option>
                <?php 
                foreach ($quizzes as $quiz) {
                    ?>
                    <option value="<?php 
                    echo $quiz->id;
                    ?>
" <?php 
                    if ($quiz_id == $quiz->id) {
                        echo 'selected';
                    }
                    ?>
><?php 
                    echo $quiz->name;
                    ?>
</option>
                    <?php 
                }
                ?>
                </select>
                </p>
                <?php 
            } else {
                ?>
                <p>You must create a quiz before you can select one to show scores for.</p>
                <input type="hidden" id="<?php 
                echo $this->get_field_id('quiz_id');
                ?>
" name="<?php 
                echo $this->get_field_name('quiz_id');
                ?>
" value="<?php 
                echo $quiz_id;
                ?>
" />
                <?php 
            }
            $score_count = isset($instance['score_count']) ? $instance['score_count'] : '10';
            ?>
            <p>
            <label for="<?php 
            echo $this->get_field_name('score_count');
            ?>
"><?php 
            _e('Number of Scores to Display:');
            ?>
</label>
            <input class="widefat" id="<?php 
            echo $this->get_field_id('score_count');
            ?>
" name="<?php 
            echo $this->get_field_name('score_count');
            ?>
" type="num" value="<?php 
            echo esc_attr($score_count);
            ?>
" />
            </p>
            <?php 
        }