<?php 

function cp_add_quiz_cb() {
	$term = (isset($_POST['term'])) ? $_POST['term'] : get_option('current_academic_term');
  	$all_terms = get_select_options_from_post_q(['type' => 'academic_term', 'order' => $_GET['term']], 'term_name');
  	$modes = get_option('mode_of_scoring');
  	if(!$modes) {
  		echo "Please set mode of scoring first";
  		return false;
  	}
  	if(!_count($modes)) {
  		echo "Please set mode of scoring first";
  		return false;
  	}
  	foreach ($modes as $k => $v) {
  		$mode = explode(',', $v);
  		$mode = trim_array($mode);
  		$mode_arr[$mode[0]] = $mode[0];
  	}
	?>
	<div class="card" id="add-lesson-container">
        <div class="card-header">
            <span class="badge badge-warning pull"><?php echo get_class_name($_GET['class']) ?></span></br><span class="badge badge-success"><?php echo get_course_name($_GET['course']) ?></span>
        </div>
        <div class="card-body">
        
            <form id="add-lesson-form" method="post" action="contents/plugins/classroom_plus/ajax.php" data-clearform=1>
                <input type="hidden" name="class" id="class" value="<?php echo $_GET['class']; ?>">
                <input type="hidden" name="course" id="course" value="<?php echo $_GET['course']; ?>">
                <div class="row">
                    <div class="col-md-6">
                        <?php 
							select(['label' => 'Term/Session', 'id' => 'term', 'required' => 'required'], $all_terms, $term);
                         ?>
                    </div>
                    <div class="col-md-6">
                        <?php 
							select(['label' => 'Test type', 'id' => 'test', 'required' => 'required'], $mode_arr);
                         ?>
                    </div>
                    <div class="col-sm-6">
                    	<?php 
							checkbox(['label' => 'Solve Online', 'id' => 'solve_online'], true);
                         ?>
                    </div>
                    <div class="col-sm-6">
                    	<?php 
							checkbox(['label' => 'Shuffle Questions', 'id' => 'shuffle_questions'], true);
                         ?>
                    </div>
                    <div class="col-sm-6">
                    	<?php 
							input(['label' => 'Time Allowed<br />(in Minutes)', 'id' => 'time_allowed', 'required' => 'required', 'value' => 30, 'class' => 'form-control numbers-only']);
                         ?>
                    </div>
                    <div class="col-sm-6">
                    	<?php 
							input(['label' => 'Maximum<br />Questions', 'id' => 'max_questions', 'required' => 'required', 'value' => 5, 'class' => 'form-control numbers-only']);
                         ?>
                    </div>
                    <?php 
                    	do_action("search_query_filter_date_range_only", ['from' => time(), 'class' => 'col-md-6']);
                     ?>
                    <div class="col-md-12">
                    	<?php 
			                textarea(['label' => 'Instructions', 'id' => 'instructions']);
			                submit_btn('create_quiz');
			             ?>
                    </div>
            </form>
                
        </div>
    </div>
	<?php
	global $post_meta;
	add_page_javascript('app/assets/js/page-scripts/submit.js');
	add_page_javascript('app/assets/js/page-scripts/koweb.js');
}