Exemplo n.º 1
0
 function display($ques, $qct, $question_count, $in_progress, $exam = null)
 {
     global $wpdb, $question_catids;
     // should we display category header? (when quiz is paginated 1 category per page this is handled by watupro_cat_header())
     if (!empty($exam) and $exam->group_by_cat and !in_array($ques->cat_id, $question_catids) and $exam->single_page != WATUPRO_PAGINATE_PAGE_PER_CATEGORY) {
         echo "<h3>" . $ques->cat . "</h3>";
         if (!empty($ques->cat_description)) {
             echo "<div>" . apply_filters('watupro_content', stripslashes(wpautop($ques->cat_description))) . "</div>";
         }
         $question_catids[] = $ques->cat_id;
     }
     // fill in_progress once to avoid running multiple qiueries
     if (!empty($in_progress)) {
         // check if we already fetched the answers. if not, fetch
         // this is to avoid queries on every question
         WTPQuestion::$in_progress = $in_progress;
         if (empty($this->inprogress_details)) {
             $answers = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . WATUPRO_STUDENT_ANSWERS . " \n\t  \t\t\t\tWHERE taking_id=%d AND exam_id=%d", $in_progress->ID, $in_progress->exam_id));
             $this->inprogress_details = $this->inprogress_hints = $this->inprogress_snapshots = array();
             $this->num_hints_total = 0;
             foreach ($answers as $answer) {
                 $this->inprogress_details[$answer->question_id] = unserialize($answer->answer);
                 $this->inprogress_hints[$answer->question_id] = stripslashes($answer->hints_used);
                 $this->inprogress_snapshots[$answer->question_id] = stripslashes($answer->snapshot);
                 if (!empty($answer->feedback)) {
                     $this->inprogress_feedbacks[$answer->question_id] = $answer->feedback;
                 }
                 $this->num_hints_total += $answer->num_hints_used;
             }
         }
     }
     // if there is snapshot, means we have called 'see answer'. In this case we should make the div below invisible
     $nodisplay = '';
     if (!empty($this->inprogress_snapshots[$ques->ID]) and $exam->live_result) {
         $nodisplay = 'style="display:none;"';
     }
     $compact_class = $ques->compact_format ? "watupro-compact" : "";
     $question_number = empty(self::$advanced_settings['dont_display_question_numbers']) ? "<span class='watupro_num'>Question {$qct} </span>" : '';
     echo "<div id='questionWrap-{$question_count}' {$nodisplay} class='{$compact_class}'>\n\t\t\t<div class='question-content' " . @$display_style . ">";
     // replace {{{ID}}} if any
     $ques->question = str_replace('{{{ID}}}', $ques->ID, $ques->question);
     if (watupro_intel() and ($ques->answer_type == 'gaps' or $ques->answer_type == 'sort' or $ques->answer_type == 'matrix')) {
         require_once WATUPRO_PATH . "/i/models/question.php";
         WatuPROIQuestion::display($ques, $qct, $question_count, @$this->inprogress_details);
     } else {
         echo wpautop(self::flag_review($ques, $qct) . $question_number . stripslashes($ques->question));
     }
     echo "<input type='hidden' name='question_id[]' id='qID_{$question_count}' value='{$ques->ID}' />";
     echo "<input type='hidden' id='answerType{$ques->ID}' value='{$ques->answer_type}'>";
     if ($ques->is_required) {
         echo "<input type='hidden' id='watupro-required-question-" . $ques->ID . "'>";
     }
     if (!empty($exam->question_hints)) {
         $this->display_hints($ques, $in_progress);
     }
     if ($ques->answer_type != 'sort') {
         echo "<!-- end question-content--></div>";
     }
     // end question-content
     $this->display_choices($ques, $in_progress);
     // accept feedback?
     if ($ques->accept_feedback) {
         $feedback = empty($this->inprogress_feedbacks[$ques->ID]) ? '' : stripslashes($this->inprogress_feedbacks[$ques->ID]);
         echo "<p>" . stripslashes($ques->feedback_label) . "<br>\n \t\t\t<textarea name='feedback-{$ques->ID}' rows='3' cols='30' class='watupro-user-feedback' id='watuproUserFeedback{$ques->ID}'>{$feedback}</textarea></p>";
     }
     echo '<!-- end questionWrap--></div>';
     // end questionWrap
 }