<div id="primary" class="content-area gdlr-lms-primary-wrapper">
<div id="content" class="site-content" role="main">
<?php 
if (function_exists('gdlr_lms_get_header') && !empty($gdlr_lms_option['show-header']) && $gdlr_lms_option['show-header'] == 'enable') {
    gdlr_lms_get_header();
}
?>
	<div class="gdlr-lms-content">
		<div class="gdlr-lms-container gdlr-lms-container">
		<?php 
while (have_posts()) {
    the_post();
    global $gdlr_course_settings, $gdlr_course_options, $gdlr_time_left, $lms_page, $payment_row;
    // assign certificate at last page when there're no quiz
    if ($lms_page == sizeof($gdlr_course_settings) && $gdlr_course_options['quiz'] == 'none' && (!empty($gdlr_course_options['enable-certificate']) && $gdlr_course_options['enable-certificate'] == 'enable') && (empty($gdlr_course_settings['allow-non-member']) || $gdlr_course_settings['allow-non-member'] == 'disable')) {
        gdlr_lms_add_certificate(get_the_ID(), $gdlr_course_options['certificate-template']);
    }
    echo '<div class="gdlr-lms-course-single gdlr-lms-content-type">';
    echo '<div class="gdlr-lms-course-info-wrapper">';
    echo '<div class="gdlr-lms-course-info-title">' . __('Course Process', 'gdlr-lms') . '</div>';
    echo '<div class="gdlr-lms-course-info">';
    for ($i = 1; $i <= sizeof($gdlr_course_settings); $i++) {
        $part_class = $i == sizeof($gdlr_course_settings) ? 'gdlr-last ' : '';
        if ($i < $lms_page) {
            $part_class .= 'gdlr-pass ';
        } else {
            if ($i == $lms_page) {
                $part_class .= 'gdlr-current ';
            } else {
                $part_class .= 'gdlr-next ';
            }
                            $quiz_answer[$question_set][$i] = $_POST['question' . $i];
                        } else {
                            $quiz_answer[$question_set][$i] = stripslashes($_POST['question' . $i]);
                        }
                    }
                }
                $quiz_score = array();
                $quiz_status = 'pending';
                if ($_GET['course_page'] == 'finish') {
                    $quiz_score = gdlr_lms_calculating_score($quiz_options, $quiz_answer, $quiz_score);
                    $quiz_status = sizeof($quiz_score) == sizeof($quiz_options) ? 'complete' : 'submitted';
                    if ($quiz_status == 'complete' && (!empty($course_options['enable-badge']) && $course_options['enable-badge'] == 'enable')) {
                        gdlr_lms_add_badge(get_the_ID(), gdlr_lms_score_summary($quiz_score), $course_options['badge-percent'], $course_options['badge-title'], $course_options['badge-file']);
                    }
                    if ($quiz_status == 'complete' && (!empty($course_options['enable-certificate']) && $course_options['enable-certificate'] == 'enable')) {
                        gdlr_lms_add_certificate(get_the_ID(), $course_options['certificate-template'], gdlr_lms_score_summary($quiz_score), $course_options['certificate-percent']);
                    }
                }
                if ($current_row) {
                    $wpdb->update($wpdb->prefix . 'gdlrquiz', array('quiz_answer' => serialize($quiz_answer), 'quiz_score' => serialize($quiz_score), 'quiz_status' => $quiz_status), array('quiz_id' => $course_options['quiz'], 'student_id' => $current_user->ID, 'course_id' => get_the_ID()), array('%s', '%s', '%s'), array('%d', '%d'));
                } else {
                    $wpdb->insert($wpdb->prefix . 'gdlrquiz', array('quiz_id' => $course_options['quiz'], 'student_id' => $current_user->ID, 'course_id' => get_the_ID(), 'quiz_answer' => serialize($quiz_answer), 'quiz_score' => serialize($quiz_score), 'quiz_status' => $quiz_status), array('%d', '%d', '%s', '%s', '%s', '%s'));
                }
            }
        }
    }
}
if (isset($_GET['course_page']) && $_GET['course_page'] == 'finish') {
    exit;
}
get_header();
예제 #3
0
                if ($_POST['action'] == 'scoring-status-part') {
                    $quiz_val = gdlr_lms_decode_preventslashes(get_post_meta($_GET['quiz_id'], 'gdlr-lms-content-settings', true));
                    $quiz_options = empty($quiz_val) ? array() : json_decode($quiz_val, true);
                    if (!empty($_POST)) {
                        $sql = 'SELECT id, quiz_score FROM ' . $wpdb->prefix . 'gdlrquiz ';
                        $sql .= 'WHERE quiz_id=' . $_GET['quiz_id'] . ' AND student_id=' . $_GET['student_id'] . ' AND course_id=' . $_GET['course_id'];
                        $current_row = $wpdb->get_row($sql);
                        $quiz_score = unserialize($current_row->quiz_score);
                        $quiz_score = empty($quiz_score) ? array() : $quiz_score;
                        $quiz_score[$_POST['pnum']] = array();
                        foreach ($_POST['score'] as $key => $value) {
                            $quiz_score[$_POST['pnum']][$key] = array('score' => $value, 'from' => $_POST['from'][$key]);
                        }
                        $quiz_status = sizeof($quiz_score) == sizeof($quiz_options) ? 'complete' : 'pending';
                        if ($quiz_status == 'complete') {
                            $course_val = gdlr_lms_decode_preventslashes(get_post_meta($_GET['course_id'], 'gdlr-lms-course-settings', true));
                            $course_settings = empty($course_val) ? array() : json_decode($course_val, true);
                            if (!empty($course_settings['enable-badge']) && $course_settings['enable-badge'] == 'enable') {
                                gdlr_lms_add_badge($_GET['course_id'], gdlr_lms_score_summary($quiz_score), $course_settings['badge-percent'], $course_settings['badge-title'], $course_settings['badge-file'], $_GET['student_id']);
                            }
                            if (!empty($course_settings['enable-certificate']) && $course_settings['enable-certificate'] == 'enable') {
                                gdlr_lms_add_certificate($_GET['course_id'], $course_settings['certificate-template'], gdlr_lms_score_summary($quiz_score), $course_settings['certificate-percent'], $_GET['student_id']);
                            }
                        }
                        $wpdb->update($wpdb->prefix . 'gdlrquiz', array('quiz_score' => serialize($quiz_score), 'quiz_status' => $quiz_status), array('id' => $current_row->id), array('%s', '%s'), array('%d'));
                    }
                }
            }
        }
    }
}