<?php
$question = $this->session->userdata('question_details');
$answer = $this->session->userdata('answer');
$desc_answer = $this->session->userdata('desc_answer');
$words = array(".", "?", ":", ",", ";", "'", "(", ")", "=", "+", "  ");
$desc_answer = str_replace($words, "", $desc_answer);
$unique_ans = array_unique($desc_answer);

$question_option = (explode(" ", $question_options->question_option));
$question_option = str_replace($words, "", $question_option);
$question_unique_option = array_unique($question_option);
$question_option=array();
foreach ($question_unique_option as $value) {
    $question_option[$value] = '1';
}

?>


<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
    <div class="col-md-9 column">

        <h4 style="color:red;">
            <?php
            $message = $this->session->userdata('message');
            $this->session->unset_userdata('message');
            if ($message) {
                echo $message;
            }
            ?>
        </h4>


        <label><h4>Your Question:</h4></label>  <?php echo $question; ?> <br/>

        <h4><label>Your Answer:</h4></label> <?php echo $answer; ?>   <hr/>

        <h4>Select 80% word's as Keyword of your answer that will use to check students answer:</h4> <br/><br/>


        <form action="<?php echo base_url(); ?>super_admin_quiz/update_question_with_keyword" method="post" name="answer_key" enctype="multipart/form-data">

            <?php
            $total_word = 0;

            foreach ($unique_ans as $v_answer) {
                if ($v_answer != 'a' && $v_answer != 'an' && $v_answer != 'the' && $v_answer != 'of' && $v_answer != 'and' && $v_answer != 'for' && $v_answer != 'to' && $v_answer != 'am' && $v_answer != 'is' && $v_answer != 'are' && $v_answer != 'was' && $v_answer != 'were' && $v_answer != 'so' && $v_answer != 'this' && $v_answer != 'but' && $v_answer != 'his' && $v_answer != 'her' && $v_answer != 'can' && $v_answer != 'could' && $v_answer != 'would' && $v_answer != 'this' && $v_answer != 'that' && $v_answer != 'it' && $v_answer != 'be') {
                    ?>
                    <div class="col-sm-2">
                        <input type='checkbox'  name='key_answer[]' class='checkbox-inline' value='<?php echo $v_answer; ?>' <?php if($question_option[$v_answer]){ echo 'checked'; }else{ echo '';} ?> />
                        <?php echo $v_answer; ?>
                    </div>
                    <?php
                    echo '';
                    $total_word++;
                }
            }

            $sdata = array();
            $sdata['total_word'] = $total_word;
            $this->session->set_userdata($sdata);
            ?> 
            <div class="col-sm-12">
                <br/>  <br/>
                <button type="submit" id="submit" class="btn btn-success" >Submit</button>
                <button type="reset" class="btn btn-info">Reset</button>
            </div>

        </form>
    </div>
</div>





