<?php 
    $choiceData = $this->db->get_where('activity', array('activity_id' => base64_decode($param2)))->row();
    $pollId = $choiceData->activity_id;
    $uploaderID = $choiceData->uploader_id;
    $uploaderType = $choiceData->uploader_role;
    $options = $choiceData->description;
?>
    <?php echo form_open(base_url() . 'student/polls/subject_response/' , array('enctype' => 'multipart/form-data'));?>
        <?php 
            $id = $this->session->userdata('login_user_id');
            $query = $this->db->get_where('subject_poll_response', array('activity_id' => $pollId, 'student_id' => $id));
            if($query->num_rows() <= 0):
        ?>
        <div class="ui-block paddingtel rmmb">
            <input type="hidden" name="poll_code" id="poll_code" value="<?php echo $pollId;?>">
            <article class="hentry post">
                <div class="post__author author vcard inline-items">
                    <img src="<?php echo $this->crud->get_image_url($uploaderType, $uploaderID);?>">
                    <div class="author-date">
                        <a class="h6 post__author-name fn" href="javascript:void(0);"><?php echo $this->crud->get_name($uploaderType, $uploaderID);?></a>
                        <div class="post__date">
                            <time class="published btcolor"><?php echo $choiceData->date;?></time>
                        </div>
                    </div>
                </div>
                <div class="wall-content">
                    <div>
                        <ul class="widget w-pool">
                            <li>
                                <h4><?php echo $choiceData->title;?></h4>
                            </li><br>
                            <?php 
                                $array = (explode(',',$options));
                                for($i = 0; $i < count($array)-1; $i++):
                            ?>
                            <li>
                                <div class="skills-item">
                                    <div class="skills-item-info">
                                        <span class="skills-item-title">
                                            <span class="radio">
                                                <h6>
                                                    <label>
                                                        <input type="radio" id="answer" name="answer<?php echo $pollId;?>" value="<?php echo $array[$i];?>"><span class="circle circlebrd"></span><span class="check"></span>
                                                        <?php echo $array[$i];?>
                                                    </label>
                                                </h6>
                                            </span>
                                        </span>
                                    </div>
                                </div>  
                            </li>
                            <?php endfor;?>
                        </ul>
                    </div>
                    <button class="btn btn-md-2 btn-border-think custom-color c-grey btn-vote text-white" type="submit"><?php echo getEduAppGTLang('vote');?><div class="ripple-container"></div></button>
                </div>
                <br><br><br>
            </article>
        </div>
        <?php endif;?>
        <?php if($query->num_rows() > 0):?>
        <div class="ui-block paddingtel rmmb">
            <article class="hentry post">
                <div class="post__author author vcard inline-items">
                    <img src="<?php echo $this->crud->get_image_url($uploaderType, $uploaderID);?>">
                    <div class="author-date">
                        <a class="h6 post__author-name fn" href="javascript:void(0);"><?php echo $this->crud->get_name($uploaderType, $uploaderID);?></a>
                        <div class="post__date">
                            <time class="published btcolor"><?php echo $choiceData->date;?></time>
                        </div>
                    </div>      
                </div>
                <div class="wall-content">
                    <div>
                        <ul class="widget w-pool">
                            <li>
                                <h4><?php echo $choiceData->title;?></h4>
                            </li><br>
                            <?php 
                                $this->db->where('activity_id', $pollId);
                                $polls = $this->db->count_all_results('subject_poll_response');
                                $array = ( explode(',' , $options));
                                $questions = count($array)-1;
                                $op = 0;
                                for($i = 0 ; $i<count($array)-1; $i++):
                                $this->db->group_by('activity_id');
                                $po = $this->db->get_where('subject_poll_response', array('activity_id' => $pollId))->result_array();
                                foreach($po as $p):
                            ?>
                            <li>
                                <div class="skills-item">
                                    <div class="skills-item-info">
                                        <span class="skills-item-title">
                                        <?php 
                                            $this->db->where('answer', $array[$i]);
                                            $this->db->where('activity_id', $pollId);
                                            $res = $this->db->count_all_results('subject_poll_response');
                                        ?>
                                            <h6><label><?php echo $array[$i];?></label></h6>
                                        </span>
                                        <?php 
                                            $response = $res/$polls;
                                            $response2 = $response*100;
                                        ?>
                                        <span class="skills-item-count">
                                            <span class="count-animate" data-speed="1000" data-refresh-interval="50" data-to="62" data-from="0"></span>
                                            <span class="units"><?php echo round($response2);?>/100%</span>
                                        </span>
                                    </div>
                                    <div class="skills-item-meter">
                                        <span class="skills-item-meter-active bg-primary skills-animate" style="width: <?php echo $response2;?>%; opacity: 1;"></span>
                                    </div>
                                </div>
                            </li>
                            <?php endforeach;?>
                            <?php endfor;?>
                        </ul>
                    </div>
                </div>
                <br><br><br>
            </article>
        </div>
    <?php endif;?>
    <?php echo form_close();?>