<div class="col-sm-8">
    <div class="row ">
        <div class="col-sm-12 " style="padding: 0">
            <div class="col-sm-12" >
                <h3>
                    Selected Grade Information
                        <!--<a href=""> <span class="pull-right" style="font-size: 18px">Create Quiz</span></a>-->
                </h3>
                <hr>
            </div>

            <div class="col-sm-12" >
                <div class="col-sm-12 gray_ttc text-center" style="border-bottom: 2px solid #8CC73F;padding-top: 10px;padding-bottom: 10px;font-weight: bold">
                    <div class="col-sm-4" style="padding:10px 0">Grade</div>
                    <div class="col-sm-4" style="padding:10px 0">Grade Number </div>
                    <div class="col-sm-4" style="padding:10px 0">Action</div>
                </div>

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

                <?php
                if ($quiz_grades) {
                    $top_number = 0;
                    foreach ($quiz_grades as $v_grade) {
                        $id = $v_grade->grade_id;
                        $status = $v_grade->grade_status;
                        ?>
                        <div class="col-sm-12 gray text-center" >
                            <div class="col-sm-4" style="padding:10px 0"><?php echo $v_grade->grade_name; ?></div>
                            <div class="col-sm-4" style="padding:10px 0">
                                <?php
                                if ($top_number > $v_grade->grade_number) {
                                    echo $v_grade->grade_number;
                                    echo '-';
                                    echo $top_number - 1;
                                    $top_number = $v_grade->grade_number;
                                } else {
                                    echo $v_grade->grade_number . '-' . $v_grade->grade_total_number;
                                    $top_number = $v_grade->grade_number;
                                }
                                ?>
                            </div>

                            <div class="col-sm-4" style="padding:10px 0" id="actions<?php echo $id; ?>">
                                <a href="<?php echo base_url() ?>edit-selected-grade"><i class="fa fa-edit" title="Edit"></i></a>
                                <span>&nbsp;&nbsp;</span>
                                <?php
                                if ($status == 0) {
                                    ?>
                                    <a href="#" onclick="return checkForAction('<?php echo base_url() . 'activate-grade/' . $id; ?>', 'Active', '<?php echo $id; ?>')">
                                        <i class="fa  fa-user-plus" title="Active"></i>
                                    </a>&nbsp;&nbsp;
                                <?php } else if ($status == 1) { ?>
                                    <a href="#" onclick="return checkForAction('<?php echo base_url() . 'inactivate-grade/' . $id; ?>', 'Inactive', '<?php echo $id; ?>')">
                                        <i class="fa  fa-user-times" title="Inactive"></i>
                                    </a>&nbsp;&nbsp;
                                <?php } else if ($status == 2) { ?>
                                    <a href="#" onclick="return checkForAction('<?php echo base_url() . 'activate-grade/' . $id; ?>', 'Active', '<?php echo $id; ?>')">
                                        <i class="fa  fa-user-plus" title="Active"></i>
                                    </a>&nbsp;&nbsp;
                                <?php } ?>

                                <?php if ($status != 2) { ?>
                                    <a  href="#" onclick="return checkForAction('<?php echo base_url() . 'archive-grade/' . $id; ?>', 'Delete', '<?php echo $id; ?>')">
                                        <i class="fa fa-trash-o" title="Delete"></i>
                                    </a>&nbsp;&nbsp;
                                <?php } ?>
                            </div>
                        </div>

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

                        <?php
                    }
                } else {
                    echo 'You do not have any grade for this quiz.';
                }
                ?>



                <!--                <nav class="course-pagination">
                                    <ul class="pagination">
                                        <li>
                                            <a href="#" aria-label="Previous">
                                                <span aria-hidden="true" title="First Page">&laquo;&laquo;</span>
                                            </a>
                                        </li>
                                        <li>
                                            <a href="#" aria-label="Previous">
                                                <span aria-hidden="true" title="Previous Page">&laquo;</span>
                                            </a>
                                        </li>
                                        <li><a href="#">1</a></li>
                                        <li><a href="#">2</a></li>
                                        <li><a href="#">3</a></li>
                                        <li><a href="#">4</a></li>
                                        <li><a href="#">5</a></li>
                                        <li>
                                            <a href="#" aria-label="Next">
                                                <span aria-hidden="true" title="Next Page">&raquo;</span>
                                            </a>
                                        </li>
                                        <li>
                                            <a href="#" aria-label="Next">
                                                <span aria-hidden="true" title="Last Page">&raquo;&raquo;</span>
                                            </a>
                                        </li>
                                    </ul>
                                </nav>-->

            </div>


        </div><!-- /.row gray -->


    </div>

</div>

<script>

    function checkForAction(url, action, quizID) { // check for Active Inactives
//        alert(url);
        swal({
            title: "",
            text: "Are you sure you want to " + action + " this Group?",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: '#DD6B55',
            confirmButtonText: 'Yes',
            cancelButtonText: "No",
            closeOnConfirm: true,
            closeOnCancel: true
        },
        function (isConfirm) {
            if (isConfirm) {
//                document.location.href = url;
//                ac_inac_del_action
                serverPage = url;
                xmlhttp.open("GET", serverPage);
//                alert(serverPage);
                xmlhttp.onreadystatechange = function ()
                {
//                    alert(xmlhttp.readyState);
//                    alert(xmlhttp.status);
                    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                    {
//                        alert(xmlhttp.responseText);
                        document.getElementById("actions" + quizID).innerHTML = xmlhttp.responseText;
                        document.getElementById("message" + quizID).innerHTML = "<div class='col-sm-12 alert alert-info' ><a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a>Quiz Successfully " + action + "</div>";

                    }
                }
                xmlhttp.send(null);
            } else {
                return;
            }

        });
    }

</script>