<?php
if ($quiz_info) {
    $quiz_total_time = 0;
    if ($quiz_info->quiz_random_static == 1) {
        $quiz_total_time = ($quiz_questions[0]->time_limit * 60) * $quiz_info->total_number_of_question;
    } else {
        foreach ($quiz_questions as $value) {
            $quiz_total_time += $value->time_limit;
        }
        $quiz_total_time = $quiz_total_time * 60;
    }

    $quiz_id = $quiz_info->quiz_id;
    $quiz_status = $quiz_info->quiz_status;
    $url = $quiz_info->url;
    $quiz_pulication_status = $quiz_info->quiz_pulication_status;
    $creator_role = $creator->person_role;
    $viewer_role = $this->session->userdata('person_role');
    ?>

    <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 $quiz_info->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 == 3) {
                ?>
                <a href="<?php echo base_url() . $creator->url . '/profile'; ?>" target="_blank">
                    <?php echo $creator->person_first_name . ' ' . $creator->person_last_name; ?>
                </a>
            <?php } else if ($creator_role == 4) {
                ?>
                <a href="<?php echo base_url() . $creator->url . '/profile'; ?>" target="_blank">
                    <?php echo $creator->organization_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); ?></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/' . $quiz_info->url . '/grade-details' ?>"><i class="fa  fa-sun-o" title="View Grade"></i></a>
            <span>&nbsp;&nbsp;</span>

            <?php if ($quiz_info->certificate_id == NULL || $quiz_info->certificate_id == 0 || $quiz_info->certificate_id == '') { ?>
                <a href="javascript:void(0)" onclick="set_quiz_url(<?php // echo $quiz_info->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>

            <?php
            switch ($viewer_role) {
                case 1:
                    switch ($quiz_status) {
                        case 0:
                            ?>
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-quiz-status/' . $url . '/1'; ?>', 'Publish', '<?php echo $quiz_id; ?>')">
                                <i class="fa  fa-user-plus" title="Publish"></i>
                            </a>&nbsp;&nbsp;

                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-quiz-status/' . $url . '/3'; ?>', 'Pending', '<?php echo $quiz_id; ?>')">
                                <i class="fa fa-refresh fa-spin" title="Pending topic"></i>
                            </a>&nbsp;&nbsp;

                            <?php
                            break;
                        case 1:
                            if (!$quiz_attendies) {
                                ?>
                                <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-quiz-status/' . $url . '/0'; ?>', 'Unpublish', '<?php echo $quiz_id; ?>')">
                                    <i class="fa  fa-user-times" title="Unpublish"></i>
                                </a>&nbsp;&nbsp;

                                <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-quiz-status/' . $url . '/3'; ?>', 'Pending', '<?php echo $quiz_id; ?>')">
                                    <i class="fa fa-refresh fa-spin" title="Pending topic"></i>
                                </a>&nbsp;&nbsp;
                            <?php } ?>
                            <?php
                            break;
                        case 2:
                            ?>
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-quiz-status/' . $url . '/1'; ?>', 'Publish', '<?php echo $quiz_id; ?>')">
                                <i class="fa  fa-user-plus" title="Publish"></i>
                            </a>&nbsp;&nbsp;
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-quiz-status/' . $url . '/0'; ?>', 'Unpublish', '<?php echo $quiz_id; ?>')">
                                <i class="fa  fa-user-times" title="Unpublish"></i>
                            </a>&nbsp;&nbsp;
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-quiz-status/' . $url . '/4'; ?>', 'Approve', '<?php echo $quiz_id; ?>')">
                                <i class="glyphicon glyphicon-ok" title="Approve topic"></i>
                            </a>&nbsp;&nbsp;
                            <?php
                            break;
                        case 3:
                            ?>
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-quiz-status/' . $url . '/4'; ?>', 'Approve', '<?php echo $quiz_id; ?>')">
                                <i class="glyphicon glyphicon-ok" title="Approve topic"></i>
                            </a>&nbsp;&nbsp;
                            <?php
                            break;
                        case 4:
                            ?>
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-quiz-status/' . $url . '/1'; ?>', 'Publish', '<?php echo $quiz_id; ?>')">
                                <i class="fa  fa-user-plus" title="Publish"></i>
                            </a>&nbsp;&nbsp;
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-quiz-status/' . $url . '/3'; ?>', 'Pending', '<?php echo $quiz_id; ?>')">
                                <i class="fa fa-refresh fa-spin" title="Pending topic"></i>
                            </a>&nbsp;&nbsp;
                            <?php
                            break;
                        default:
                            break;
                    }
                    ?>
                    <?php if (!$quiz_attendies) { ?>
                        <a  href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/delete-quiz/' . $url; ?>', 'Delete', '<?php echo $quiz_id; ?>')">
                            <i class="fa fa-trash-o" title="Delete"></i>
                        </a>&nbsp;&nbsp;
                    <?php } ?>
                    <?php
                    break;
                case 6:
                    ?>
                    <?php
                    switch ($quiz_status) {
                        case 0:
                            ?>
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-quiz-status/' . $url . '/1'; ?>', 'Publish', '<?php echo $quiz_id; ?>')">
                                <i class="fa  fa-user-plus" title="Publish"></i>
                            </a>&nbsp;&nbsp;

                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-quiz-status/' . $url . '/3'; ?>', 'Pending', '<?php echo $quiz_id; ?>')">
                                <i class="fa fa-refresh fa-spin" title="Pending topic"></i>
                            </a>&nbsp;&nbsp;

                            <?php
                            break;
                        case 1:
                            ?>
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-quiz-status/' . $url . '/0'; ?>', 'Unpublish', '<?php echo $quiz_id; ?>')">
                                <i class="fa  fa-user-times" title="Unpublish"></i>
                            </a>&nbsp;&nbsp;

                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-quiz-status/' . $url . '/3'; ?>', 'Pending', '<?php echo $quiz_id; ?>')">
                                <i class="fa fa-refresh fa-spin" title="Pending topic"></i>
                            </a>&nbsp;&nbsp;
                            <?php
                            break;
                        case 2:
                            ?>
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-quiz-status/' . $url . '/1'; ?>', 'Publish', '<?php echo $quiz_id; ?>')">
                                <i class="fa  fa-user-plus" title="Publish"></i>
                            </a>&nbsp;&nbsp;
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-quiz-status/' . $url . '/0'; ?>', 'Unpublish', '<?php echo $quiz_id; ?>')">
                                <i class="fa  fa-user-times" title="Unpublish"></i>
                            </a>&nbsp;&nbsp;
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-quiz-status/' . $url . '/4'; ?>', 'Approve', '<?php echo $quiz_id; ?>')">
                                <i class="glyphicon glyphicon-ok" title="Approve topic"></i>
                            </a>&nbsp;&nbsp;
                            <?php
                            break;
                        case 3:
                            ?>
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-quiz-status/' . $url . '/4'; ?>', 'Approve', '<?php echo $quiz_id; ?>')">
                                <i class="glyphicon glyphicon-ok" title="Approve topic"></i>
                            </a>&nbsp;&nbsp;
                            <?php
                            break;
                        case 4:
                            ?>
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-quiz-status/' . $url . '/1'; ?>', 'Publish', '<?php echo $quiz_id; ?>')">
                                <i class="fa  fa-user-plus" title="Publish"></i>
                            </a>&nbsp;&nbsp;
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-quiz-status/' . $url . '/3'; ?>', 'Pending', '<?php echo $quiz_id; ?>')">
                                <i class="fa fa-refresh fa-spin" title="Pending topic"></i>
                            </a>&nbsp;&nbsp;
                            <?php
                            break;
                            ?>
                        <?php
                        default:
                            break;
                    }
                    ?>
                    <a  href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/delete-quiz/' . $url; ?>', 'Delete', '<?php echo $quiz_id; ?>')">
                        <i class="fa fa-trash-o" title="Delete"></i>
                    </a>&nbsp;&nbsp;
                    <?php
                    break;
            }
            ?>
        </div>
    </div>
    <div class="col-sm-12"><br></div> 
<?php } ?>
