<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-3" style="padding:10px 0">Quiz Name</div>
    <div class="col-sm-2" style="padding:10px 0">BY</div>
    <div class="col-sm-1" style="padding:10px 0">Permission</div>
    <div class="col-sm-1" style="padding:10px 0"> Question</div>
    <div class="col-sm-2" style="padding:10px 0">Time</div>
    <div class="col-sm-3" style="padding:10px 0">Action</div>
</div>

<div class="col-sm-12"><br></div> 
<?php
if ($quizes) {
    foreach ($quizes as $v_quiz) {
        $quiz_total_time = 0;
        if ($v_quiz->quiz_random_static == 1 && $quiz_questions[$v_quiz->quiz_id][0]) {
            $quiz_total_time = ($quiz_questions[$v_quiz->quiz_id][0]->time_limit * 60) * $v_quiz->total_number_of_question;
        } else {
            foreach ($quiz_questions[$v_quiz->quiz_id] as $value) {
                $quiz_total_time += $value->time_limit;
            }
            $quiz_total_time = $quiz_total_time * 60;
        }

        $quiz_id = $v_quiz->quiz_id;
        $quiz_status = $v_quiz->quiz_status;
        $url = $v_quiz->url;
        $quiz_pulication_status = $v_quiz->quiz_pulication_status;
        $creator_role = $creator[$v_quiz->quiz_created_by]->person_role;
        $viewer_role = $this->session->userdata('person_role');
        ?>
        <div id="actions<?php echo $quiz_id; ?>">
            <div class="col-sm-12 gray text-center" >
                <div class="col-sm-3" style="padding:10px 0">
                    <a href="<?php echo base_url() . 'quiz/' . $url; ?>"><?php echo $v_quiz->quiz_name; ?>
                    </a>
                </div>
                <div class="col-sm-2" style="padding:10px 0">
                    <?php
                    if ($creator_role == 6) {
                        echo 'TalhaTraining';
                    } else if ($creator_role == 1) {
                        echo 'TalhaTraining';
                    } else if ($creator_role == 8) {
                        ?>
                        <a href="<?php echo base_url() . $creator[$v_quiz->quiz_created_by]->url . '/profile'; ?>" target="_blank">
                        <?php echo $creator[$v_quiz->quiz_created_by]->person_first_name . ' ' . $creator[$v_quiz->quiz_created_by]->person_last_name; ?>
                        </a>
                    <?php
                    } else if ($creator_role == 3) {
                        ?>
                        <a href="<?php echo base_url() . $creator[$v_quiz->quiz_created_by]->url . '/profile'; ?>" target="_blank">
                        <?php echo $creator[$v_quiz->quiz_created_by]->person_first_name . ' ' . $creator[$v_quiz->quiz_created_by]->person_last_name; ?>
                        </a>
                    <?php } else if ($creator_role == 4) {
                        ?>
                        <a href="<?php echo base_url() . $creator[$v_quiz->quiz_created_by]->url . '/profile'; ?>" target="_blank">
                            <?php //echo $creator[$v_quiz->quiz_created_by]->organization_name; ?>
                        <?php echo $creator[$v_quiz->quiz_created_by]->person_first_name . ' ' . $creator[$v_quiz->quiz_created_by]->person_last_name; ?>
                        </a>
                        <?php
                    }
                    ?>
                </div>
                <div class="col-sm-1" style="padding:10px 0">
                    <?php
                    if ($quiz_pulication_status == 1) {
                        echo 'Public';
                    } else if ($quiz_pulication_status == 2) {
                        echo 'Talhatraining Users';
                    } else if ($quiz_pulication_status == 3) {
                        echo 'My Link';
                    } else if ($quiz_pulication_status == 4) {
                        echo 'Group';
                    } else if ($quiz_pulication_status == 5) {
                        echo 'Course';
                    } else if ($quiz_pulication_status == 6) {
                        echo 'Video Course';
                    }
                    ?>
                </div>
                <div class="col-sm-1" style="padding:10px 0"><?php echo count($quiz_questions[$quiz_id]); ?></div>
                <div class="col-sm-2" style="padding:10px 0"><?php echo $this->cf->sec2view($quiz_total_time); ?></div>

                <div class="col-sm-3" style="padding:10px 0">
                    <a href="<?php echo base_url() . 'super-admin/quiz/' . $url . '/add-grade'; ?>"><i class="fa fa-plus-square-o" title="Add Grade"></i></a>
                    <span>&nbsp;&nbsp;</span>

                    <a href="<?php echo base_url() . 'super-admin/quiz/' . $url . '/question' ?>"><i class="fa  fa-th" title="View Question"></i></a>
                    <span>&nbsp;&nbsp;</span>

                    <a href="<?php echo base_url() . 'super-admin/quiz/' . $v_quiz->url . '/grade-details' ?>"><i class="fa  fa-sun-o" title="View Grade"></i></a>
                    <span>&nbsp;&nbsp;</span>

                    <?php if ($v_quiz->certificate_id == NULL || $v_quiz->certificate_id == 0 || $v_quiz->certificate_id == '') { ?>
                        <a href="javascript:void(0)" onclick="set_quiz_url(<?php echo $v_quiz->url; ?>);">
                            <i class="fa  fa-certificate">&nbsp;&nbsp;</i>
                        </a>
                    <?php } ?>

                    <br>

                    <a href="<?php echo base_url() . 'super-admin/quiz/' . $url . '/edit-quiz'; ?>"><i class="fa fa-edit" title="Edit"></i></a>
                    <span>&nbsp;&nbsp;</span>

                    <a href="<?php echo base_url() . 'super-admin/quiz/' . $url . '/add-quiz-question'; ?>">
                        <i class="fa fa-question-circle" title="Add question"></i>
                    </a>
                    <span>&nbsp;&nbsp;</span>
<!---------------------start  quiz active inactive--------------------->  
                    <?php if ($quiz_status == 0) { ?>
                        <a href="javascript:void(0)" data-toggle="modal" data-target="#activequiz<?php echo $quiz_id; ?>">
                            <i class="fa  fa-user-plus" title="Publish"></i>
                        </a>&nbsp;&nbsp;    
                     <?php } else if ($quiz_status == 1) { ?>
                        <a href="javascript:void(0)" data-toggle="modal" data-target="#inactivequiz<?php echo $quiz_id; ?>">
                            <i class="fa  fa-user-times" title="Unpublish"></i>
                        </a>&nbsp;&nbsp;        
                    <?php } ?>

                    <?php if($person_info->person_role == 6){?>

                        <a href="javascript:void(0)" data-toggle="modal" data-target="#deletequiz<?php echo $quiz_id; ?>">
                            <i class="fa fa-trash-o" title="Delete"></i>
                        </a>&nbsp;&nbsp;  

                    <?php } ?>
                        <div class="modal" style="" id="activequiz<?php echo $quiz_id; ?>" tabindex="-1" role="dialog" aria-labelledby="changeRole" aria-hidden="true">
                            <div class='modal-dialog'>
                                <div class='modal-content' style='top: 180px;border: 5px solid #80c12c;border-top: 20px solid #80c12c !important;margin: 0 auto;max-width: 400px'>           
                                    <div class='modal-body text-center' style='padding-bottom: 0px;'>
                                         <span class='text-center'>Are you sure want to Active this quiz ?</span>
                                    </div>
                                    <div class='modal-footer'>
                                        <div  class='col-sm-12 text-center'>  
                                            <span class='col-sm-3 col-sm-offset-3'>
                                                <button type='button' class='btn btn-danger  col-sm-12' data-dismiss='modal' style='font-size: 14px;'>No</button>
                                            </span> 
                                            <span class='col-sm-3'>
                                                <button onclick="activequiz('<?php echo base_url(); ?>super-admin/active-quiz', '<?php echo $quiz_id; ?>')" class='btn btn-success col-sm-12' data-dismiss='modal'>Yes</button>
                                            </span>
                                        </div>
                                    </div>            
                                </div>
                            </div>
                         </div>
                         <div class="modal" style="" id="inactivequiz<?php echo $quiz_id; ?>" tabindex="-1" role="dialog" aria-labelledby="changeRole" aria-hidden="true">
                            <div class='modal-dialog'>
                                <div class='modal-content' style='top: 180px;border: 5px solid #80c12c;border-top: 20px solid #80c12c !important;margin: 0 auto;max-width: 400px'>           
                                    <div class='modal-body text-center' style='padding-bottom: 0px;'>
                                         <span class='text-center'>Are you sure want to inactive this quiz ?</span>
                                    </div>
                                    <div class='modal-footer'>
                                        <div  class='col-sm-12 text-center'>  
                                            <span class='col-sm-3 col-sm-offset-3'>
                                                <button type='button' class='btn btn-danger  col-sm-12' data-dismiss='modal' style='font-size: 14px;'>No</button>
                                            </span> 
                                            <span class='col-sm-3'>
                                                <button onclick="inactivequiz('<?php echo base_url(); ?>super-admin/inactive-quiz', '<?php echo $quiz_id;?>')" class='btn btn-success col-sm-12' data-dismiss='modal'>Yes</button>
                                            </span>

                                        </div>
                                    </div>            
                                </div>
                            </div>
                         </div>
                        <div class="modal" style="" id="deletequiz<?php echo $quiz_id; ?>" tabindex="-1" role="dialog" aria-labelledby="changeRole" aria-hidden="true">
                            <div class='modal-dialog'>
                                <div class='modal-content' style='top: 180px;border: 5px solid #80c12c;border-top: 20px solid #80c12c !important;margin: 0 auto;max-width: 400px'>           
                                    <div class='modal-body text-center' style='padding-bottom: 0px;'>
                                         <span class='text-center'>Are you sure want to Active this quiz ?</span>
                                    </div>
                                    <div class='modal-footer'>
                                        <div  class='col-sm-12 text-center'>  
                                            <span class='col-sm-3 col-sm-offset-3'>
                                                <button type='button' class='btn btn-danger  col-sm-12' data-dismiss='modal' style='font-size: 14px;'>No</button>
                                            </span> 
                                            <span class='col-sm-3'>
                                                <button onclick="deletequiz('<?php echo base_url(); ?>super-admin/delete-quiz', '<?php echo $quiz_id; ?>')" class='btn btn-success col-sm-12' data-dismiss='modal'>Yes</button>
                                            </span>

                                        </div>
                                    </div>            
                                </div>
                            </div>
                         </div>
<!------------------------ end quiz active inactive------------------>                                    
                </div>
            </div>
            <div class="col-sm-12"><br></div> 
        </div>
        <?php
    }
} else { ?>
    <p>Express your talent by <a href="<?php echo base_url().'create-quiz'?>" target="_blank">Creating Quiz</a>!</p>
<?php }
?>

<!--------------------START Pagination---------------------------->
<div class="col-sm-12">
        <?php $total_page = ceil($total_data / $per_page_view); ?>
    <div class="col-sm-12 form-group">
        <?php
        if ($total_page > 1) {
            ?>
            <nav class="course-pagination">
                <ul class="pagination">
                    <?php
                    if ($page > 2) {
                        ?>
                        <li>
                            <a href="<?php echo base_url() . 'super-admin/manage-quiz/1'; ?>"
                               aria-label="Previous">
                                <span aria-hidden="true" title="First Page">&laquo;&laquo;</span>
                            </a>
                        </li>
                        <li>
                            <a href="<?php echo base_url() . 'super-admin/manage-quiz/' . ($page - 1); ?>"
                               aria-label="Previous">
                                <span aria-hidden="true" title="Previous Page">&laquo;</span>
                            </a>
                        </li>
                <?php } elseif ($page > 1) { ?>
                        <li>
                            <a href="<?php echo base_url() . 'super-admin/manage-quiz/' . ($page - 1); ?>"
                               aria-label="Previous">
                                <span aria-hidden="true" title="Previous Page">&laquo;</span>
                            </a>
                        </li>
                        <?php
                    }

                    for ($i = 0; $total_page > $i; $i++) {
                        echo '<li><a href="' . base_url() . 'super-admin/manage-quiz/'. ($i + 1) . '">' . ($i + 1) . '</a></li>';
                    }
                    if ($total_page != $page) {
                        ?>
                        <li>
                            <a href="<?php echo base_url() . 'super-admin/manage-quiz/' . ($page + 1); ?>"
                               aria-label="Next">
                                <span aria-hidden="true" title="Next Page">&raquo;</span>
                            </a>
                        </li>
                        <li>
                            <a href="<?php echo base_url() . 'super-admin/manage-quiz/' . $total_page; ?>" 
                               aria-label="Next">
                                <span aria-hidden="true" title="Last Page">&raquo;&raquo;</span>
                            </a>
                        </li>
                <?php } ?>
                </ul>
            </nav>
    <?php } ?>
    </div>
</div>
                <!--------------------END Pagination---------------------------->