Example #1
0
// now select and display questions
$answer_display = $exam->show_answers == "" ? get_option('watupro_show_answers') : $exam->show_answers;
// loading serialized questions or questions coming by POST
if (!empty($_POST['action']) or !empty($in_progress->serialized_questions)) {
    $serialized_questions = empty($_REQUEST['watupro_questions']) ? @$in_progress->serialized_questions : $_REQUEST['watupro_questions'];
    $all_question = watupro_unserialize_questions($serialized_questions);
}
// this happens either at the beginning or if for some reason $all_question is empty on submitting
if (empty($all_question)) {
    $all_question = WTPQuestion::select_all($exam);
    // regroup by cats?
    if (empty($passed_question_ids)) {
        $all_question = $_watu->group_by_cat($all_question, $exam);
    }
    // now match answers to non-textarea questions
    $_watu->match_answers($all_question, $exam);
}
$cnt_questions = sizeof($all_question);
// get required question ids as string
$rids = array(0);
foreach ($all_question as $q) {
    if ($q->is_required) {
        $rids[] = $q->ID;
    }
}
$required_ids_str = implode(",", $rids);
// requires captcha?
if ($exam->require_captcha) {
    $recaptcha_public = get_option("watupro_recaptcha_public");
    $recaptcha_private = get_option("watupro_recaptcha_private");
    if (!function_exists('recaptcha_get_html')) {