<?php
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

foreach ($this->cart->contents() as $items) {
    if ($items['id'] == $question_id) {
        echo $items['id'];
        echo $items['name'];
        foreach ($this->cart->product_options($items['rowid']) as $option_name => $option_value) {
            echo $option_name . ': ' . $option_value;
            $q = $option_value;
        }
    }
}

$pre_q = $this->session->userdata('pre_q');
?>

<div id="tutorial_question" class="col-sm-11 col-sm-offset-1">     
    <h1>Quiz</h1>
    <!--<form method="post" role="form">-->

    <div class="col-sm-12 ">
        <div class="row ">
            <form name="quizQuestion">

                <input type="hidden" name="quiz_question_time"  id="quiz_question_time" value="<?php echo $question->time_limit * 60; ?>" >
                <input type="hidden" name="points_per_answer" id="points_per_answer" value="<?php echo $question->points_per_answer ?>" >
                <input type="hidden" name="question_type" id="question_type" value="<?php echo $question->question_type ?>" >
                <input type="hidden" name="question_id" id="question_id" value="<?php echo $question->question_id ?>" >

                <input type="hidden" name="quiz_running" id="quiz_running" value="<?php echo $this->session->userdata('running_quiz_status'); ?>" >
                <input type="hidden" name="question_number" id="question_number" value="<?php echo $q; ?>" >

                <input type="hidden" name="quiz_question_time" id="quiz_question_time" value="30" >

                <div class="col-sm-12 padding-zero"><br></div>

                <div class="col-sm-12">

                    <div class="col-sm-8  padding-zero text-left">

                        <div class="col-sm-12 text-left" style="padding: 0 0 5px 20px;">
                            <h4> <?php echo ($i + 1) . '.'; ?>
                                <?php
                                if ($question->question_type == 4) {

                                    $ques = $question->question_details;
                                    $ques_mod = str_replace("_", "  ______  ", $ques);
                                    echo $ques_mod;
                                } else {
                                    echo $question->question_details;
                                }
                                echo '<br>' . $pre_q . ' |' . $q . '<br>';
                                echo $this->session->set_userdata('previous_question');
                                echo '<br>';
                                $question_id = $this->session->userdata('question_id');
                                print_r($question_id);
//                                exit();
                                ?>
                            </h4>
                        </div>

                        <div class="col-sm-12">  <hr><br>  </div>

                        <div class="col-sm-12 text-left" style="padding: 0 0 5px 20px;">
                            <div class="form-group col-sm-12">
                                <?php if ($question->question_type == 3) { ?>
                                    <!--<br/>-->
                                    <h4>Write Your Answer:</h4>
                                    <textarea name='desc_answer' id='desc_answer' class='col-sm-8'></textarea>
                                <?php } elseif ($question->question_type == 4) { ?>
                                    <br/><h4>Write Your Answer:</h4>
                                    <textarea name='fill_answer' id='fill_answer' class='col-sm-7' rows='1'></textarea>
                                <?php } else {
                                    ?>

                                    <div  class="radio radio-success" style="margin: 0">
                                        <?php
                                        foreach ($options[$question->question_id] as $v_option) {
                                            echo '<h4>';
                                            $v = $v_option->question_option_id;
                                            ?>

                                            <?php
                                            $c_answer = $v_option->question_option;
                                            $c_answer = str_replace('<', '&lt', $c_answer);
                                            $c_answer = str_replace('>', '&gt', $c_answer);
//                                        echo $c_answer;
                                            ?>

                                            <input  type="radio" name='status[]' id='status'   value='<?php echo $v; ?>'>
                                            <label for="free">
                                                <?php
                                                echo ' ' . $c_answer;
                                                echo '</h4>';
                                                ?>
                                            </label>
                                            <input type='hidden' name='option_id[]' id="option_id" value='<?php echo $v_option->question_option_id; ?>'>
                                        <?php } ?>
                                    </div>
                                    <?php
                                }

                                $time = $question->time_limit * 60;

                                $min = $question->time_limit;
                                ?> 
                            </div>

                            <input type='hidden' name='taken_time' id="taken_time" value=''>

                        </div>

                        <div class="form-group col-sm-12  text-center"> 

                            <span><br><br></span>
                            <span>

                                <?php
                                if ($pre_q) {
                                    $questions = explode('.', $pre_q);
                                    array_pop($questions);
                                    $first_question = $questions[0];
                                    $previous_question = $questions[count($questions) - 1];
                                    ?>

                                    <a href="javascript:void()" onclick="firstQuestion('<?php echo $questions[0]; ?>')" ><i class="fa fa-backward" title="first"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

                                    <a href="javascript:void()" onclick="previousQuestion('<?php echo $previous_question; ?>')"><i class="fa  fa-arrow-left" title="Previous"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

                                <?php } ?>
                                <a href="javascript:void()" onclick="getElapsedTime();"><i class="fa  fa-arrow-right" title="Next"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

                                <a href="javascript:void()" onclick="load_quiz_question()"><i class="fa  fa-toggle-down" title="Skip"></i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

                                    <a href="javascript:void()" onclick="showResult()"> <i class="fa   fa-forward" title="Finish"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

                            </span>
                            <span><br></span>

                        </div>

                        <div class="form-group col-sm-3 "> </div>
                        <div class="col-sm-12"><br></div>
                    </div>

                    <div class="col-sm-4 padding-zero">
                        <div class="row">
                            <div class="col-sm-12"><br><br><br></div>
                            <div id="countdown">
                                <canvas id="countdown360_countdown" width="150" height="150">
                                    <span id="countdown-text" role="status" aria-live="assertive"></span>
                                </canvas>
                            </div>

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

                <div class="col-sm-12"><br></div>

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

</div>

