
<script>
	var editors = [];
</script>
<br>
	<div class="panel-group" id="questions_accordion">
		<?php  
		foreach($questions_answers_data as $key=>$data): 
			$question_standard 	= '';
			$exam_org 			= '';
			$post_level 		= '';
			$question_level		= $ques_levels[ $data['question']->question_level];
			$subject 			= '';
                   

			foreach($exam_standards as $standard ) {
				if($data['question']->exam_standard_ID == $standard->exam_standard_ID) {
					$question_standard = $standard;	
                                        break;
				}
			}

			foreach($exam_orgs as $org ) {
				if($data['question']->exam_org_ID == $org->exam_org_ID) {
					$exam_org = $org;
                                        break;
				}
			}

			foreach($post_levels as $post ) {
				if($data['question']->post_level_ID == $post->post_level_ID) {
					$post_level = $post;
                                        break;
				}
			}

			foreach($subjects as $subject ) {
				if($data['question']->subject_ID == $subject->subject_ID) {
					$subject = $subject;
                                        break;
                                   
                                          
				}
			}
		?>		
		  <div class="panel panel-default">
		    <div class="panel-heading">
		      <h4 class="panel-title">
		        <a data-toggle="collapse" data-parent="#questions_accordion"  href="#collapse<?=$key?>">
		        	#Question No. <?=count($questions_answers_data)-$key?>
		        </a>&nbsp;&nbsp;&nbsp;
		        [<span>
		      		<strong>Question Standard :</strong> <?= $question_standard->standard_name; ?>&nbsp;&nbsp;&nbsp;
		      		<strong>Exam Org :</strong> <?= $exam_org->exam_org_name; ?>&nbsp;&nbsp;&nbsp;
		    		<strong>Post Level :</strong> <?= $post_level->post_level_name; ?>&nbsp;&nbsp;&nbsp;
		    		<strong>Question Level :</strong> <?= $question_level; ?>&nbsp;&nbsp;&nbsp;
		    		<strong>Subject :</strong> <?= $subject->subject_name; ?>
	      		</span>]
		        <span class="pull-right" style="width: 80px;">
		        	<?= form_open(base_url('questions_answers/edit'),array('style'=>'float:left;margin-right: 5px;')) ?>
		        	<?= hidden_input(array('name'=>'edit_id','value'=>$data['question']->question_ID)) ?>
		        	<button type="submit" style="margin-top: -5px;" class="btn btn-warning btn-sm" data-toggle="tooltip" data-placement="bottom"  data-original-title="Edit"> <span class="glyphicon glyphicon-edit"></span> </a></button>
		        	<?= form_close() ?>
		        	<?= form_open(base_url('questions_answers/delete'),array('style'=>'float:left;margin-right: 5px;')) ?>
		        	<?= hidden_input(array('name'=>'delete_id','value'=>$data['question']->question_ID)) ?>
		        	<button type="submit" style="margin-top: -5px;" class="btn btn-danger btn-sm" data-toggle="tooltip" data-placement="bottom" data-original-title="Delete"> <span class="glyphicon glyphicon-trash"></span> </a></button>
		        	<?= form_close() ?>
		        </span>
		      </h4>
		    </div>
		    <div id="collapse<?=$key?>" class="panel-collapse collapse">
		      <div class="panel-body">

		      	<ul class="nav nav-tabs">
		  			<li class="active"><a data-toggle="tab" href="#tab_ques_content_en_<?=$key?>">English</a></li>
		  			<li><a data-toggle="tab" href="#tab_ques_content_hin_<?=$key?>">Hindi</a></li>
				</ul>
				<div class="tab-content">
					<br>
					<div id="tab_ques_content_en_<?=$key?>" class="tab-pane fade in active">
						<div class="row">
							<div class="<?= ($data['paragraph'] == NULL)? 'col-sm-12':'col-sm-5' ?>">
								<p><strong>Question :</strong></p>
								<div id="question_content_en_<?= $data['question']->question_ID ?>">
									<?= $data['question']->question_content_en ?>
								</div>
								<script>
								editors.push('question_content_en_<?= $data['question']->question_ID ?>');
								</script>		
								<p><strong>Answers :</strong></p>
								<ol>
									<?php 
									foreach($data['answers'] as $answer):
									?>
									<li>) &nbsp;&nbsp; <?= $answer->answer_content_en ?></li>
									<?php 
									endforeach; 
									?>
								</ol>
								<p><strong>Correct Answer :</strong> <?=$data['correct_answer']->answer_content_en?></p>
								<p><strong>Explanation :</strong></p>
								<?= $data['question']->explanation_en; ?>
							</div>
							<?php
							if($data['paragraph'] != NULL):
							?>
							<div class="col-sm-7">
								<p><strong>Paragraph :</strong></p>
								<?= $data['paragraph']->resource_content_en ?>
							</div>
							<?php
							endif;
							?>
						</div>
						
					</div>
					<div id="tab_ques_content_hin_<?=$key?>" class="tab-pane fade">
						<div class="row">
							<div class="<?= ($data['paragraph'] == NULL)? 'col-sm-12':'col-sm-5' ?>">
								<p><strong>Question:</strong></p>
								<div id="question_content_hin_<?= $data['question']->question_ID ?>">
									<?= $data['question']->question_content_hin ?>
								</div>
								<script>
								editors.push('question_content_hin_<?= $data['question']->question_ID ?>');
								</script>
								<p><strong>Answers:</strong></p>
								<ol>
									<?php 
									foreach($data['answers'] as $answer):
									?>
									<li>) &nbsp;&nbsp;<?= $answer->answer_content_hin ?></li>
									<?php 
									endforeach; 
									?>
								</ol>
								<p><strong>Correct Answer :</strong> <?=$data['correct_answer']->answer_content_hin?></p>
								<p><strong>Explanation :</strong></p>
								<?= $data['question']->explanation_en; ?>
							</div>
							<?php
							if($data['paragraph'] != NULL):
							?>
							<div class="col-sm-7">
								<p><strong>Paragraph :</strong></p>
								<?= $data['paragraph']->resource_content_en ?>
							</div>
							<?php
							endif;
							?>
						</div>
					</div>
				</div>
			 </div>
		    </div>
		  </div>
		<?php 
		endforeach;
		?>
		</div>

<script>
	//<![CDATA[
	(function($){
		$('document').ready(function(){
			init();
		});

		function init(){

			CKEDITOR.disableAutoInline = true;
			$.each(editors,function(index,editor){
				CKEDITOR.inline(editor,{});
			});

			$.each(CKEDITOR.instances, function(index, instance){
				var editor = instance;
				if (editor) {
					 editor.on('focus', function (event) {
		                return false;
		            });
				}
			});
		}
	})(jQuery);
	////]]>
</script>
<style>
	.cke_editable, .cke_widget_inline, .cke_widget_inline:hover .cke_widget_element, .cke_widget_inline.cke_widget_focused .cke_widget_element{
		outline:none;
	}
	.cke_widget_drag_handler_container {
		display:none !important;
	}	
</style>