<?php
$_SESSION['upload_dir'] = '/source/' . $person_info->url . '/';
$_SESSION['current_path'] = '../source/' . $person_info->url . '/';
?>
<div class="col-sm-10">
    <div class="row gray_ttc">
        <div role="tabpanel">
            <?php
            $question_type = $this->session->userdata('question_type');
            $this->session->unset_userdata('question_type');
            ?>
            <!-- Nav tabs -->
            <ul class="nav nav-tabs" role="tablist">
                <li role="presentation" class="<?php
                if (set_value('question_type') == 1) {
                    echo 'active';
                } else if ($question_type == 1) {
                    echo 'active';
                } else if (!$question_type) {
                    echo 'active';
                }
                ?>">
                    <a href="#home" aria-controls="home" role="tab" data-toggle="tab">Multiple Choice</a>
                </li>

                <li role="presentation" class="<?php
                if (set_value('question_type') == 2) {
                    echo 'active';
                } else if ($question_type == 2) {
                    echo 'active';
                }
                ?>">
                    <a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">True False</a>

                </li>

                <li role="presentation" class="<?php
                if (set_value('question_type') == 3) {
                    echo 'active';
                } else if ($question_type == 3) {
                    echo 'active';
                }
                ?>">
                    <a href="#desc" aria-controls="desc" role="tab" data-toggle="tab">Descriptive Question</a>

                </li>

                <li role="presentation" class="<?php
                if (set_value('question_type') == 4) {
                    echo 'active';
                } else if ($question_type == 4) {
                    echo 'active';
                }
                ?>">
                    <a href="#fill" aria-controls="fill" role="tab" data-toggle="tab">Fill in the blank</a>

                </li>

            </ul>

            <!-- Tab panes -->
            <div class="tab-content">

                <div role="tabpanel" class="tab-pane col-sm-12 <?php
                if (set_value('question_type') == 1) {
                    echo 'active';
                } else if ($question_type == 1) {
                    echo 'active';
                } else if (!$question_type) {
                    echo 'active';
                }
                ?>" id="home">

                    <div class="form-group col-sm-10">
                        <?php
//                        echo validation_errors(); //formID2
                        $url = 'super-admin/add-question';
                        echo form_open($url, 'class="" id="formID2" name="mcqForm" onsubmit="return check_form();"');
                        ?>
                        <div class="col-sm-12">
                            <div >
                                <br/>
                                <br/>
                                <br/>
                                <label>Please Type Your question</label>                                
                                <textarea
                                       data-errormessage-value-missing="Question  is required!" 
                                       class="form-control validate[required] resoulation1280"  
                                       id="mc_details" 
                                       name="question_details" 
                                       value="<?php echo set_value('question_details'); ?>"  
                                       placeholder="Please Type Your question" ></textarea>
                                <input type="hidden" class="form-control" id="question_type" name="question_type" value="1"  >
                                <?php echo form_error('question_details'); ?>
                                <div class="form-group  required" ></div>
                            </div> 
                            <br/>

                            <div>
                                <select data-errormessage-value-missing="Please select a quiz!" 
                                        class="form-control validate[required]" 
                                        id="quiz_id"  name="quiz_id" 
                                        onchange="checkQuizType(this.value, 'quiz_required_information_mcq');">
                                    <option value="">--Select Quiz--</option>
                                    <?php foreach ($all_quiz as $v_quiz) { ?>
                                        <option value="<?php echo $v_quiz->url; ?>"><?php echo $v_quiz->quiz_name; ?></option>
                                    <?php } ?>
                                </select>
                            </div>

                            <div class="form-group  required" ></div>
                            <div id="quiz_required_information_mcq">

                            </div>

                        </div>
                        <div class="col-sm-10 col-sm-offset-1">
                            <div class="radio radio-success">
                                <br>
                                <h4>Answers:</h4>

                                <div class="form-group col-sm-12">
                                    <!--<label for="option"><h3>(A)</h3></label>-->
                                    <input data-errormessage-value-missing="Please Select Currect Answer!" 
                                           class="form-control validate[required] showCorrect mc_forminput" 
                                           type="radio" name="status" value="0" id="a1">
                                    <label for="a1" class=""><Strong>(A)</strong>This answer option is correct</label>
                                    <textarea name="option[]" 
                                              data-errormessage-value-missing="Please provide an option!" 
                                              class="form-control validate[required] resoulation1280"><?php echo set_value('option'); ?></textarea>
                                </div>

                                <div class="form-group col-sm-12">
                                    <!--<label for="option"><h3>(B)</h3></label>-->
                                    <input data-errormessage-value-missing="Please Select Currect Answer!" 
                                           class="form-control validate[required] showCorrect mc_forminput"
                                           type="radio" name="status" value="1" id="b1">
                                    <label for="b1" class=""><Strong>(B)</strong>This answer option is correct</label>
                                    <textarea name="option[]" 
                                              data-errormessage-value-missing="Please provide an option!" 
                                              class="form-control validate[required] resoulation1280"><?php echo set_value('option'); ?></textarea>
                                </div>

                                <div class="form-group col-sm-12">
                                    <!--<label for="option"><h3>(C)</h3></label>-->
                                    <input data-errormessage-value-missing="Please Select Currect Answer!" 
                                           class="form-control validate[required] showCorrect mc_forminput"
                                           type="radio" name="status" value="2" id="c1" >
                                    <label for="c1" class=""><Strong>(C)</strong>This answer option is correct</label>
                                    <textarea name="option[]" 
                                              data-errormessage-value-missing="Please provide an option!" 
                                              class="form-control validate[required] resoulation1280" ><?php echo set_value('option'); ?></textarea>
                                </div>

                                <div class="form-group col-sm-12">
                                    <!--<label for="d1"><h3>(D)</h3></label>-->
                                    <input data-errormessage-value-missing="Please Select Currect Answer!" 
                                           class="form-control validate[required] showCorrect mc_forminput"
                                           type="radio" name="status" value="3" id="d1" >
                                    <label for="d1" class=""><Strong>(D)</strong>This answer option is correct</label>
                                    <textarea name="option[]" 
                                              data-errormessage-value-missing="Please provide an option!" 
                                              class="form-control validate[required] resoulation1280"><?php echo set_value('option'); ?></textarea>
                                </div>
                                <br/>
                            </div>
                        </div>

                        <div class=" col-sm-12" >
                            <br/>
                            <br/>
                            <div class="col-sm-4"></div>
                            <div class="col-sm-4">
                                <button class="btn btn-success">Add Question</button>
                            </div>
                            <div class="col-sm-4">
                                <a class="btn btn-success" href="javascript:void(0)" id="finish_button"> Finish </a>
                            </div>

                            <script>
                                $('#finish_button').click(function () {
                                    window.location.href = '<?php echo base_url() . 'quizes/' . $this->session->userdata('active_menu'); ?>';
                                });
                            </script>

                            <div class="col-sm-4"></div>
                        </div>
                        <?php echo form_close(); ?>
                    </div>
                </div>


                <div role="tabpanel" class="tab-pane col-sm-12 <?php
                if (set_value('question_type') == 2) {
                    echo 'active';
                } else if ($question_type == 2) {
                    echo 'active';
                }
                ?>" id="profile">

                    <div class="form-group col-sm-10"> 
                        <?php
                        echo validation_errors(); //formID2
                        $url = 'super-admin/add-question';
                        echo form_open($url, 'class="" id="formID3" name="trueFalseForm" onsubmit="return check_form();"');
                        ?>
                        <div class="col-sm-12">
                            <div>
                                <br/>
                                <br/>
                                <br/>
                                <label>Please Type Your Question</label>
                                <textarea
                                       data-errormessage-value-missing="Question  is required!" 
                                       class="form-control validate[required] resoulation1280"  
                                       id="tf_details" 
                                       name="question_details" 
                                       value="<?php echo set_value('question_details'); ?>"  
                                       placeholder="Please Type Your question" ></textarea>
                                <input type="hidden" class="form-control" id="question_type" name="question_type" value="2"  >
                                <?php echo form_error('question_details'); ?>
                                <div class="form-group  required" ></div>
                            </div>
                            <br/>

                            <div>
                                <select data-errormessage-value-missing="Please select a quiz!" 
                                        class="form-control validate[required]" 
                                        id="quiz_id"  name="quiz_id" 
                                        onchange="checkQuizType(this.value, 'quiz_required_information_true_false');">
                                    <option value="">--Select Quiz--</option>
                                    <?php foreach ($all_quiz as $v_quiz) { ?>
                                        <option value="<?php echo $v_quiz->url; ?>"><?php echo $v_quiz->quiz_name; ?></option>
                                    <?php } ?>
                                </select>
                            </div>

                            <div class="form-group  required" ></div>
                            <div id="quiz_required_information_true_false">

                            </div>
                        </div>

                        <div class="col-sm-10 col-sm-offset-1">
                            <div class="radio radio-success">
                                <h4>Answers:</h4>
                                <div class="form-group col-sm-6">
                                    <!--<label for="option"><h3>(A)</h3></label>-->
                                    <input class="showCorrect mc_forminput" type="hidden" name="option[]" value="True" id="true">
                                    <input data-errormessage-value-missing="Please Select True or False!" 
                                           class="form-control validate[required] showCorrect mc_forminput"  
                                           type="radio" name="status" value="0" id="a1">
                                    <label for="a1" class=""><Strong>(A)</strong>&nbsp;True</label>
                                </div>

                                <div class="form-group col-sm-6">
                                    <!--<label for="option"><h3>(B)</h3></label>-->
                                    <input class="showCorrect mc_forminput" type="hidden" name="option[]" value="False" id="false">
                                    <input data-errormessage-value-missing="Please Select True or False!" 
                                           class="form-control validate[required] showCorrect mc_forminput"  
                                           type="radio" name="status" value="1" id="b1">
                                    <label for="b1" class=""><Strong>(B)</strong>&nbsp;False</label>
                                </div>
                                <br/>
                            </div>
                        </div>

                        <div class=" col-sm-12" >
                            <br/>
                            <br/>
                            <div class="col-sm-4"></div>
                            <div class="col-sm-4">
                                <button class="btn btn-success">Add Question</button>
                            </div>
                            <div class="col-sm-4"></div>
                        </div>
                        <?php echo form_close(); ?>
                    </div>
                </div>

                <div role="tabpanel" class="tab-pane  col-sm-12 <?php
                if (set_value('question_type') == 3) {
                    echo 'active';
                } else if ($question_type == 3) {
                    echo 'active';
                }
                ?>" id="desc">

                    <div class="form-group col-sm-10"> 
                        <?php
//                        echo validation_errors(); //formID2
                        $url = 'super-admin/add-question';
                        echo form_open($url, 'class="" id="formID4" name="descForm" onsubmit="return check_form();"');
                        ?>
                        <div class="col-sm-8 col-sm-offset-1">
                            <div >
                                <br/>
                                <br/>
                                <br/>
                                <label>Please Type Your question</label>
                                <textarea
                                       data-errormessage-value-missing="Question  is required!" 
                                       class="form-control validate[required] resoulation1280"  
                                       id="dq_details" 
                                       name="question_details" 
                                       value="<?php echo set_value('question_details'); ?>"  
                                       placeholder="Please Type Your question" ></textarea>
                                <input type="hidden" class="form-control" id="question_type" name="question_type" value="3"  >
                                <?php echo form_error('question_details'); ?>
                                <div class="form-group  required" ></div>
                            </div> 
                            <br/>

                            <div>
                                <select data-errormessage-value-missing="Please select a quiz!" 
                                        class="form-control validate[required]" 
                                        id="quiz_id"  name="quiz_id" 
                                        onchange="checkQuizType(this.value, 'quiz_required_information_descriptive');">
                                    <option value="">--Select Quiz--</option>
                                    <?php foreach ($all_quiz as $v_quiz) { ?>
                                        <option value="<?php echo $v_quiz->url; ?>"><?php echo $v_quiz->quiz_name; ?></option>
                                    <?php } ?>
                                </select>
                            </div>

                            <div class="form-group  required" ></div>
                            <div id="quiz_required_information_descriptive">

                            </div>

                        </div>

                        <div class="col-sm-10 col-sm-offset-1">
                            <div class="">
                                <div class="form-group col-sm-12">
                                    <label for="desc_answer"><h3>Answer of the Question:</h3></label>
                                    <input class="showCorrect mc_forminput" type="hidden" name="option[]" value="Descriptive" id="dsc">
                                    <textarea name="desc_answer" data-errormessage-value-missing="Answer is required!" class="form-control validate[required] resoulation1280"></textarea>
                                </div>
                                <br/>
                            </div>
                        </div>

                        <div class=" col-sm-12" >
                            <br/>
                            <br/>
                            <div class="col-sm-4"></div>
                            <div class="col-sm-4">
                                <button class="btn btn-success">Add Question</button>
                            </div>
                            <div class="col-sm-4"></div>
                        </div>
                        <?php echo form_close(); ?>
                    </div>
                </div>

                <div role="tabpanel" class="tab-pane  col-sm-12 <?php
                if (set_value('question_type') == 4) {
                    echo 'active';
                } else if ($question_type == 4) {
                    echo 'active';
                }
                ?>" id="fill">
                    <div class="form-group col-sm-12"> 
                        <?php
//                        echo validation_errors(); //formID2
                       $url = 'super-admin/add-question';
//                        $url = 'super-admin/quiz/' . $quiz_info->url . '/add-quiz-question';
                        echo form_open($url, 'class="" id="formID5" name="fillBlankForm" onsubmit="return check_form();"');
                        ?>
                        <div class="col-sm-12">
                            <div >
                                <br/>
                                <br/>
                                <br/>
                                <label>Please Type Your question</label>
                                <textarea class="form-control validate[required] resoulation1280"  
                                       id="fb_details" 
                                       name="question_details" 
                                       value="<?php echo set_value('question_details'); ?>"  
                                       placeholder="Please Type Your question" ></textarea>
                                
                                
                                <input type="hidden" class="form-control" id="question_type" name="question_type" value="4"  >
                                <?php echo form_error('question_details'); ?>
                                <div class="form-group  required" ></div>
                            </div> 
                            <br/>

                            <div>
                                <select data-errormessage-value-missing="Please select a quiz!" 
                                        class="form-control validate[required]" 
                                        id="quiz_id"  name="quiz_id" 
                                        onchange="checkQuizType(this.value, 'quiz_required_information_fill_blank');">
                                    <option value="">--Select Quiz--</option>
                                    <?php foreach ($all_quiz as $v_quiz) { ?>
                                        <option value="<?php echo $v_quiz->url; ?>"><?php echo $v_quiz->quiz_name; ?></option>
                                    <?php } ?>
                                </select>
                            </div>

                            <div class="form-group  required" ></div>
                            <div id="quiz_required_information_fill_blank">

                            </div>

                        </div>
                        <div class="col-sm-12"><br></div>
                        <div class="col-sm-12">
                            <div>
                                <!--<input class="showCorrect mc_forminput" type="hidden" name="option[]" value="Fill Blank" id="fill_blank">-->
                                <label>Type Answer of the Question</label>
                                <textarea
                                       data-errormessage-value-missing="" 
                                       class="form-control validate[required] resoulation12"
                                       name="option" id="fill_blank"
                                       placeholder="Type Answer of the Question" ></textarea>
                            </div>
                        </div>

                        <div class=" col-sm-12" >
                            <br/>
                            <br/>
                            <div class="col-sm-4"></div>
                            <div class="col-sm-4">
                                <button class="btn btn-success">Add Question</button>
                            </div>
                            <div class="col-sm-4"></div>
                        </div>
                        <?php echo form_close(); ?>
                    </div>
                </div>
            </div>
        </div>
    </div><!-- /.row gray_ttc -->
</div>

<script>
</script>
<script>

    function checkQuizType(quizURL, objID) {
        if (quizURL) {
            var xmlhttp = create_xmlhttp();
            var serverPage = base_url + 'super-admin/get-quiz-required-information/' + quizURL;
            xmlhttp.open("GET", serverPage);
            xmlhttp.onreadystatechange = function ()
            {
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                {
                    _(objID).innerHTML = xmlhttp.responseText;
                }
            };
            xmlhttp.send(null);
        } else {
            _(objID).innerHTML = '';
        }
    }

</script>


<script type="text/javascript">

<?php if (set_value('question_type') == 1) { ?>
        document.forms['mcqForm'].elements['quiz_id'].value = '<?php echo set_value('quiz_id'); ?>';
        document.forms['mcqForm'].elements['status'].value = '<?php echo set_value('status'); ?>';
<?php } ?>

<?php if (set_value('question_type') == 2) { ?>
        document.forms['trueFalseForm'].elements['quiz_id'].value = '<?php echo set_value('quiz_id'); ?>';
        document.forms['trueFalseForm'].elements['status'].value = '<?php echo set_value('status'); ?>';
<?php } ?>

<?php if (set_value('question_type') == 3) { ?>
        document.forms['descForm'].elements['quiz_id'].value = '<?php echo set_value('quiz_id'); ?>';
        document.forms['descForm'].elements['status'].value = '<?php echo set_value('status'); ?>';
<?php } ?>

<?php if (set_value('question_type') == 4) { ?>
        document.forms['fillBlankForm'].elements['quiz_id'].value = '<?php echo set_value('quiz_id'); ?>';
        document.forms['fillBlankForm'].elements['status'].value = '<?php echo set_value('status'); ?>';
<?php } ?>

</script>