Example #1
0
				</div>
		   </div>			
	</div>
	
	<?php 
if (watupro_intel()) {
    if (@file_exists(get_stylesheet_directory() . '/watupro/i/exam_form_intelligence.php')) {
        require get_stylesheet_directory() . '/watupro/i/exam_form_intelligence.php';
    } else {
        require WATUPRO_PATH . "/i/views/exam_form_intelligence.php";
    }
    ?>
			<div class="postbox watupro-tab-div" id="advanced" style="display:none;">
				<?php 
    $_GET['exam_id'] = @$dquiz->ID;
    watupro_advanced_exam_settings();
    ?>
			</div>
			<?php 
}
?>
	
	<style type="text/css"> #gradecontent p{border-bottom:1px dotted #ccc;padding-bottom:3px;} #gradecontent label{padding: 5px 10px;} #gradecontent textarea{width:96%;margin-left:10px;} #gradecontent p img.gradeclose{ border:0 none; float:right; } </style>
	
	<div id="finalscreen" class="watupro-tab-div postbox" style="display:none;">				
		<div class="inside">
			<h3><?php 
_e('Final Screen', 'watupro');
?>
</h3>
			
Example #2
0
function watupro_exam()
{
    global $wpdb, $user_ID;
    $multiuser_access = 'all';
    if (watupro_intel()) {
        $multiuser_access = WatuPROIMultiUser::check_access('exams_access');
    }
    if (isset($_REQUEST['submit'])) {
        // prepare advanced settings - email grades and contact info fields
        $advanced_settings = $wpdb->get_var($wpdb->prepare("SELECT advanced_settings FROM " . WATUPRO_EXAMS . "\n\t\t\tWHERE id=%d", @$_REQUEST['quiz']));
        if (!empty($advanced_settings)) {
            $advanced_settings = unserialize(stripslashes($advanced_settings));
        } else {
            $advanced_settings = array();
        }
        // email grades
        $advanced_settings['email_grades'] = @$_POST['email_grades'];
        // flag for review
        $advanced_settings['flag_for_review'] = @$_POST['flag_for_review'];
        // dont display question numbers
        $advanced_settings['dont_display_question_numbers'] = @$_POST['dont_display_question_numbers'];
        // contact fields
        $advanced_settings['contact_fields'] = array();
        $advanced_settings['contact_fields']['email'] = $_POST['ask_for_email'];
        $advanced_settings['contact_fields']['email_label'] = $_POST['ask_for_email_label'];
        $advanced_settings['contact_fields']['name'] = $_POST['ask_for_name'];
        $advanced_settings['contact_fields']['name_label'] = $_POST['ask_for_name_label'];
        $advanced_settings['contact_fields']['phone'] = $_POST['ask_for_phone'];
        $advanced_settings['contact_fields']['phone_label'] = $_POST['ask_for_phone_label'];
        $advanced_settings['contact_fields']['company'] = $_POST['ask_for_company'];
        $advanced_settings['contact_fields']['company_label'] = $_POST['ask_for_company_label'];
        $advanced_settings['ask_for_contact_details'] = $_POST['ask_for_contact_details'];
        $_POST['advanced_settings'] = serialize($advanced_settings);
        if ($_REQUEST['action'] == 'edit') {
            //Update goes here
            $exam_id = $_REQUEST['quiz'];
            if ($multiuser_access == 'own') {
                $editor_id = $wpdb->get_var($wpdb->prepare("SELECT editor_id FROM " . WATUPRO_EXAMS . " WHERE ID=%d", $exam_id));
                if ($editor_id != $user_ID) {
                    wp_die('You can edit only your own exams', 'watupro');
                }
            }
            if (empty($_POST['use_different_email_output'])) {
                $_POST['email_output'] = '';
            }
            WTPExam::edit($_POST, $exam_id);
            if (!empty($_POST['auto_publish'])) {
                watupro_auto_publish($exam_id);
            }
            $wp_redirect = admin_url('admin.php?page=watupro_exams&message=updated');
            // save advanced settings
            if ($exam_id and watupro_intel()) {
                $_GET['exam_id'] = $exam_id;
                $_POST['ok'] = true;
                watupro_advanced_exam_settings();
            }
        } else {
            // add new exam
            $exam_id = WTPExam::add($_POST);
            if ($exam_id == 0) {
                $wp_redirect = admin_url('admin.php?page=watupro_exams&message=fail');
            }
            if ($exam_id and !empty($_POST['auto_publish'])) {
                watupro_auto_publish($exam_id);
            }
            $wp_redirect = admin_url('admin.php?page=watupro_questions&message=new_quiz&quiz=' . $exam_id);
        }
        echo "<meta http-equiv='refresh' content='0;url={$wp_redirect}' />";
        exit;
    }
    $action = 'new';
    if ($_REQUEST['action'] == 'edit') {
        $action = 'edit';
    }
    // global answer_display
    $answer_display = get_option('watupro_show_answers');
    // global single page display
    $single_page = get_option('watupro_single_page');
    $dquiz = array();
    $grades = array();
    if ($action == 'edit') {
        $dquiz = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . WATUPRO_EXAMS . " WHERE ID=%d", $_GET['quiz']));
        $single_page = $dquiz->single_page;
        if ($multiuser_access == 'own' and $dquiz->editor_id != $user_ID) {
            wp_die('You can edit only your own exams', 'watupro');
        }
        $grades = WTPGrade::get_grades($dquiz);
        $final_screen = stripslashes($dquiz->final_screen);
        $schedule_from = $dquiz->schedule_from;
        list($schedule_from) = explode(" ", $schedule_from);
        $schedule_to = $dquiz->schedule_to;
        list($schedule_to) = explode(" ", $schedule_to);
        $advanced_settings = unserialize(stripslashes($dquiz->advanced_settings));
    } else {
        $final_screen = __("<p>You have completed %%QUIZ_NAME%%.</p>\n\n<p>You scored %%SCORE%% correct out of %%TOTAL%% questions.</p>\n\n<p>You have collected %%POINTS%% points.</p>\n\n<p>Your obtained grade is <b>%%GRADE%%</b></p>\n\n<p>Your answers are shown below:</p>\n\n%%ANSWERS%%", 'watupro');
        $schedule_from = date("Y-m-d");
        $schedule_to = date("Y-m-d");
    }
    // select certificates if any
    $certificates = $wpdb->get_results("SELECT * FROM " . WATUPRO_CERTIFICATES . " ORDER BY title");
    $cnt_certificates = sizeof($certificates);
    // categories if any
    $cats = $wpdb->get_results("SELECT * FROM " . WATUPRO_CATS . " ORDER BY name");
    // select other exams
    $other_exams = $wpdb->get_results("SELECT * FROM " . WATUPRO_EXAMS . " WHERE ID!='" . @$dquiz->ID . "' ORDER BY name");
    if (watupro_intel()) {
        require_once WATUPRO_PATH . "/i/models/dependency.php";
        $dependencies = WatuPRODependency::select(@$dquiz->ID);
    }
    // check if recaptcha keys are in place
    $recaptcha_public = get_option('watupro_recaptcha_public');
    $recaptcha_private = get_option('watupro_recaptcha_private');
    // is this quiz currently published?
    if (!empty($_GET['quiz'])) {
        $quiz_id = intval($_GET['quiz']);
        $is_published = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%[watupro " . $quiz_id . "]%' \n\t\t\t\tAND post_status='publish' AND post_title!=''");
    } else {
        $is_published = false;
    }
    wp_enqueue_script('jquery-ui-datepicker');
    wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
    if (@file_exists(get_stylesheet_directory() . '/watupro/exam_form.php')) {
        require get_stylesheet_directory() . '/watupro/exam_form.php';
    } else {
        require WATUPRO_PATH . "/views/exam_form.php";
    }
}