function bp_course_get_course_quiz_submissions($course_id)
    {
        $quizes = bp_course_get_curriculum_quizes($course_id);
        if (!empty($quizes)) {
            ?>
			<div class="submissions_form">
				<select id="fetch_quiz">
				<?php 
            foreach ($quizes as $quiz_id) {
                ?>
					<option value="<?php 
                echo $quiz_id;
                ?>
"><?php 
                echo get_the_title($quiz_id);
                ?>
</option>
					<?php 
            }
            ?>
				</select>
				<select id="fetch_status">
					<option value="0"><?php 
            echo _x('Pending evaluation', 'Quiz status', 'vibe');
            ?>
</option>
					<option value="1"><?php 
            echo _x('Evaluation complete', 'Quiz status', 'vibe');
            ?>
</option>
				</select>
				<?php 
            wp_nonce_field('quiz_submissions', 'quiz_submissions');
            ?>
				<a id="fetch_quiz_submissions" class="button"><?php 
            echo _x('Get', 'get quiz submissions button', 'vibe');
            ?>
</a>
			</div>
			<script>
				jQuery(document).ready(function($){
					$('#fetch_quiz_submissions').on('click',function(){
						var parent = $(this).parent();
						$('.quiz_students').remove();
						$('.message').remove();
						$.ajax({
	                      	type: "POST",
	                      	url: ajaxurl,
	                      	data: { action: 'fetch_quiz_submissions', 
	                              	security: $('#quiz_submissions').val(),
	                              	quiz_id:$('#fetch_quiz').val(),
	                              	status:$('#fetch_status').val(),
	                            	},
	                      	cache: false,
	                      	success: function (html) {
	                      		parent.after(html);
	                      		$('#quiz').trigger('loaded');
	                      	}
	                    });
					});
				});
			</script>
			<?php 
        } else {
            ?>
			<div class="message">
				<p><?php 
            echo _x('No Quiz found !', 'No quizzes in course, error on course submissions', 'vibe');
            ?>
</p>
			</div>
			<?php 
        }
    }
function bp_course_get_quiz_submission_count($course_id)
{
    global $wpdb;
    $quizes = bp_course_get_curriculum_quizes($course_id);
    $quiz_ids = implode(',', $quizes);
    $count = $wpdb->get_var("SELECT count(*) FROM {$wpdb->postmeta} as p LEFT JOIN {$wpdb->usermeta} as u ON p.meta_key = u.user_id WHERE p.meta_value LIKE '0' AND u.meta_key = p.post_id AND p.post_id IN ({$quiz_ids})");
    return empty($count) ? 0 : $count;
}