<div class="col-sm-12"><br>
    <?php
//    echo '<pre>';
//    print_r($quiz_groups);
//    exit();
    ?>
</div>
<div class="form-group col-sm-12">
    <?php if ($access_level == 3) { ?>
        <?php
        $selected_student = array(0);
        $to_address = '';
        ?>

        <input class="col-sm-12" type="hidden" name="previous_access_user" id="previous_access_user" value="" >
        <input class="col-sm-12" type="hidden" name="to_address" id="to_address" value="" >

        <div class="col-sm-11 column">
            <select required  name="name_email" style="width: 280px;padding: 8px;" id="tokenize_placeholder" 
                    class="tokenize-sample" multiple="multiple" style="margin: 0px; padding: 0px; border: 0px; display: none;">
                        <?php
                        foreach ($link_person as $v_person) {
                            ?>
                    <option value="<?php echo $v_person->requested_person_id ?>" <?php
                    if ($selected_student[$v_person->person_id]) {
                        echo 'selected';
                    }
                    ?>>
                                <?php echo $v_person->person_first_name . ' (' . $v_person->person_email . ')'; ?>
                    </option>
                <?php } ?>
            </select>
        </div>

        <?php
    } else if ($access_level == 4) {
        $selected_group = array(0);
        $previous_group_access_user = '';
        if ($quiz_groups) {
            foreach ($quiz_groups as $v_group) {
                $selected_group[$v_group->group_id] = '1';
                $previous_group_access_user .= $v_group->group_id . ',';
            }
        }
//        echo '<pre>';
//        print_r($previous_group_access_user);
//        print_r($selected_group);
//        exit();
        ?>
        <input class="col-sm-12" type="hidden" name="previous_access_user" id="previous_access_user" value="<?php echo $previous_group_access_user; ?>" >
        <input class="col-sm-12" type="hidden" name="to_address" id="to_address" value="" >

        <div class="col-sm-11 column">
            <select required  name="name_email" style="width: 280px;padding: 8px;" id="tokenize_placeholder" 
                    class="tokenize-sample" multiple="multiple" style="margin: 0px; padding: 0px; border: 0px; display: none;">
                        <?php foreach ($group as $v_group) { ?>

                    <option value="<?php echo $v_group->group_id ?>" <?php
                    if ($selected_group[$v_group->group_id]) {
                        echo 'selected';
                    }
                    ?>>
                                <?php echo $v_group->group_name . ' (' . $v_group->group_public_id . ')'; ?>
                    </option>

                <?php } ?>
            </select>
        </div>

        <?php
    } else if ($access_level == 5) {
        $selected_course = array(0);
        $selected_course[$quiz_courses->course_id] = '1';
        ?>
        <input class="col-sm-12" type="hidden" name="course_quiz_permission_id" id="course_quiz_permission_id" value="<?php echo $quiz_courses->course_quiz_permission_id; ?>" >

        <div class="row">
            <div class="col-lg-12 text-left">
                <select data-placeholder="Select Course" class="chosen-select tokenize-sample" tabindex="5" name="quiz_course">
                    <option value=""></option>
                    <?php
                    foreach ($all_course as $v_course) {
                        if (!$course_permission[$v_course->course_id]) {
                            ?>
                            <option value="<?php echo $v_course->course_id ?>" <?php
                            if ($selected_course[$v_course->course_id]) {
                                echo 'selected';
                            }
                            ?>>
                                <?php echo $v_course->course_name; ?></option>
                            <?php
                        }
                    }
                    ?>
                </select>
            </div>
        </div>

        <?php
    } else if ($access_level == 6) {
        $selected_course = array(0);
        $selected_course[$quiz_video_courses->video_management_id] = '1';
//        echo '<pre>';
//        print_r($selected_course);
//        print_r($previous_video_course_access_user);
//        exit();
        ?>
        <input class="col-sm-12" type="hidden" name="course_quiz_permission_id" id="course_quiz_permission_id" value="<?php echo $quiz_video_courses->course_quiz_permission_id; ?>" >

        <div class="row">
            <div class="col-lg-12 text-left">
                <select data-placeholder="Select Course" 
                        data-errormessage-value-missing="Course is Required!"
                        class="form-control validate[required] text-input chosen-select tokenize-sample" tabindex="5" name="quiz_video_course">
                    <option value=""></option>
                    <?php
                    foreach ($all_video_course as $v_video_course) {
                        if (!$video_course_permission[$v_video_course->video_management_id]) {
                            ?>

                            <option value="<?php echo $v_video_course->video_management_id ?>" <?php
                            if ($selected_course[$v_video_course->video_management_id]) {
                                echo 'selected';
                            }
                            ?>>
                                        <?php echo $v_video_course->video_course_title; ?>
                            </option>

                            <?php
                        }
                    }
                    ?>
                </select>
            </div>
        </div>

    <?php } ?>
    <div class="form-group col-sm-5 required" id="course_url_status"><?php echo form_error('course_url'); ?></div>
    <div class="col-sm-4 required" id=""><?php echo form_error('course_name'); ?></div>
</div>