<?php wp_enqueue_script( 'ulp_admin_questions_answers', ULP_URL . 'assets/js/admin_questions_answers.js', [], false, false );?>
<?php do_action('ulp_admin_before_meta_box_question_answer');?>

<style>

	#free_choice_type_of_answer{<?php if ($data['answer_type']==1) echo 'display: block;'; else echo 'display:none;';?>}

	#fill_in_type_of_answer{<?php if ($data['answer_type']==7) echo 'display: block;'; else echo 'display:none;';?>}
	#single_choice_type_of_answer{<?php if ($data['answer_type']==2) echo 'display: block;'; else echo 'display:none;';?>}

	#multi_choice_type_of_answer{<?php if ($data['answer_type']==3) echo 'display: block;'; else echo 'display:none;';?>}

	#true_or_false_type_of_answer{<?php if ($data['answer_type']==4) echo 'display: block;'; else echo 'display:none;';?>}

	#essay_type_of_answer{<?php if ($data['answer_type']==5) echo 'display: block;'; else echo 'display:none;';?>}

	#sorting_type_of_answer{<?php if ($data['answer_type']==6) echo 'display: block;'; else echo 'display:none;';?>}

	#image_single_type_of_answer{<?php if ($data['answer_type']==8) echo 'display: block;'; else echo 'display:none;';?>}
	#image_multiple_type_of_answer{<?php if ($data['answer_type']==9) echo 'display: block;'; else echo 'display:none;';?>}
	#matching_type_of_answer{<?php if ($data['answer_type']==10) echo 'display: block;'; else echo 'display:none;';?>}
</style>

<div class="ulp-inside-item">

  <div class="row">

   <div class="col-xs-6">

	<h4><?php _e('Type of Question', 'ulp');?></h4>

    <div style="  max-width: 400px;">

				<select name='answer_type' id="ulp_answer_type"  class="form-control m-bot15">

					<?php

						$opt = array(

									1 => __('Free choice', 'ulp'),

									7 => __('Fill in blank', 'ulp'),
									2 => __('One Choice', 'ulp'),

									3 => __('Multi Choice', 'ulp'),

									4 => __('True or False', 'ulp'),

									5 => __('Essay', 'ulp'),

									6 => __('Sorting answers', 'ulp'),

									8 => __('Choose image - single choice', 'ulp'),
									9 => __('Choose image - multiple choice', 'ulp'),
									10 => __('Matching', 'ulp'),
						);

					?>

					<?php foreach ($opt as $k=>$v):?>

						<?php $selected = ($k==$data['answer_type']) ? 'selected' : '';?>

						<option value="<?php echo $k;?>" <?php echo $selected;?> ><?php echo $v;?></option>

					<?php endforeach;?>

				</select>

    </div>

  </div>

 </div>

</div>

<div class="ulp-line-break"></div>





<div id="free_choice_type_of_answer" class="ulp_div_to_show_hide">

  <div class="ulp-inside-item">

  <div class="row">

   <div class="col-xs-6">

    <h4><?php _e('Correct Answer', 'ulp');?></h4>

    <div class="input-group" style="  max-width: 400px;">

    <span class="input-group-addon" id="basic-addon1"><?php _e('answer:', 'ulp');?></span>

	<input type='text'  class="form-control" name='answer_value' value="<?php echo stripslashes($data['answer_value']);?>" id='' />

    </div>

  </div>

 </div>

 </div>

</div>


<div id="fill_in_type_of_answer" class="ulp_div_to_show_hide">
  <div class="ulp-inside-item">
  <div class="row">
   <div class="col-xs-6">
    <h4><?php _e('Required Answer', 'ulp');?></h4>
    <div class="" style="  max-width: 600px;">
		<textarea name='answer_value_required' rows="3" cols="85"><?php echo stripslashes($data['answer_value_required']);?></textarea>
     <div style="margin-top:15px;">
	 <p><i><?php _e('You can provide more required answers. Set the right answer between {}. If more possible rights exist split them by |', 'ulp');?></i></p>
     <p><strong><?php _e('Examples:', 'ulp');?></strong></p>
     <p><?php _e('In WordPress are you able to install additional <strong>{themes|plugins}</strong>', 'ulp');?></p>
     <p><?php _e('The <strong>{bear|wolf}</strong> is bigger than a <strong>{rabbit}</strong>', 'ulp');?></p>
    </div>
    </div>
  </div>
 </div>
 </div>
</div>



<div id="multi_choice_type_of_answer" class="ulp_div_to_show_hide">

  <div class="ulp-inside-item">

  <div class="row">

   <div class="col-xs-6">

	<h4><?php _e('Multiple Choices', 'ulp');?></h4>

	<?php

		$checkbox_correct_values = array();

		$checkbox_correct_values = $data['answers_multiple_answers_correct_answers'];



		if (empty($data['answers_multiple_answers_possible_values'])){

			$data['answers_multiple_answers_possible_values'] = array('exemple');

		}

	?>

	<div id="ulpmultipleanswers_wrapp">

		<?php foreach ($data['answers_multiple_answers_possible_values'] as $k => $v ):?>

			<div class="input-group" style="  max-width: 400px;">

				<input type="text" class="form-control" value="<?php echo $v;?>" name="answers_multiple_answers_possible_values[]" />

				<span class="ulp-delete-parent input-group-addon"><i class="fa-ulp fa-remove-ulp ulp-pointer"></i></span>

			</div>

		<?php endforeach;?>

	</div>





	<div id="ulp_add_values_for_multiple_answers" class="ulp_add_value"><?php _e('Add new Option', 'ulp');?></div>



	<h4><?php _e('Correct Answers', 'ulp');?></h4>

    <div class="input-group" style="  max-width: 400px;">

    <span class="input-group-addon" id="basic-addon1"><?php _e('answers:', 'ulp');?></span>

    <input type="text" name="answers_multiple_answers_correct_answers" class="form-control" id="answers_multiple_answers_correct_answers" value="<?php echo $data['answers_multiple_answers_correct_answers'];?>" />

    </div>

	<div style="font-size: 13px; color: green;"><?php _e("write correct values between comma ',' .", 'ulp');?></div>

  </div>

 </div>

 </div>

</div>



<div id="single_choice_type_of_answer" class="ulp_div_to_show_hide">

  <div class="ulp-inside-item">

  <div class="row">

   <div class="col-xs-6">

    <h4><?php _e('Single Choices', 'ulp');?></h4>

	<?php

		if (empty($data['answers_single_answer_possible_values'])){

			$data['answers_single_answer_possible_values'] = array('exemple');

		}

	?>

	<div id="ulpsingleanswers_wrapp" >

		<?php foreach ($data['answers_single_answer_possible_values'] as $value):?>

			 <div class="input-group" style="  max-width: 400px;">

				<input type="text" onkeyup=""  class="form-control" value="<?php echo $value;?>" name="answers_single_answer_possible_values[]" />

				<span class="ulp-delete-parent input-group-addon"><i class="fa-ulp fa-remove-ulp ulp-pointer"></i></span>

			</div>

		<?php endforeach;?>

	</div>



	<div id="ulp_add_values_for_single_answers" class="ulp_add_value"><?php _e('Add new Option', 'ulp');?></div>



	<h4><?php _e('Correct Answer', 'ulp');?></h4>

    <div class="input-group" style="  max-width: 400px;">

    <span class="input-group-addon" id="basic-addon1"><?php _e('answer:', 'ulp');?></span>

    <input type="text" name="answers_single_answer_correct_value" class="form-control" id="answers_single_answer_correct_value" value="<?php echo $data['answers_single_answer_correct_value'];?>" />

    </div>

   </div>

 </div>

 </div>

</div>



<div id="true_or_false_type_of_answer" class="ulp_div_to_show_hide">

 <div class="ulp-inside-item">

  <div class="row">

   <div class="col-xs-6">

	<h4><?php _e('Correct Answer', 'ulp');?></h4>

	<div>

		<input type="radio" name="answer_value_for_bool" value="0" <?php if ($data['answer_value_for_bool']==0) echo 'checked';?> /> <?php _e('False', 'ulp');?>

	</div>

	<div>

		<input type="radio" name="answer_value_for_bool" value="1" <?php if ($data['answer_value_for_bool']==1) echo 'checked';?> /> <?php _e('True', 'ulp');?>

	</div>

  </div>

  </div>

 </div>

</div>



<div id="essay_type_of_answer" class="ulp_div_to_show_hide">

		<div class="ulp-inside-item">

          <div class="row">

              <div class="col-xs-6">

				<h4><?php _e("Keywords", 'ulp');?></h4>

                <div class="form-group">

				<textarea name="answer_value_for_essay" class="form-control text-area"><?php echo stripslashes($data['answer_value_for_essay']);?></textarea>

              	</div>

              </div>

          </div>

      </div>

</div>





<div id="sorting_type_of_answer" class="ulp_div_to_show_hide">

		<div class="ulp-inside-item">

			  <div class="row">

					   <div class="col-xs-6">

						    <h4><?php _e('Sorting answes', 'ulp');?></h4>

								<?php

									if (empty($data['answers_sorting_type'])){

										$data['answers_sorting_type'] = array('exemple', 'exemple 2');

									}

								?>

								<div id="ulpsrotingtype_wrapp" >

									<?php foreach ($data['answers_sorting_type'] as $value):?>

										 <div class="input-group ulp-the-sorting-answers" style="max-width: 400px;">

											 <span class="input-group-addon"><i class="fa-ulp fa-sort-ulp"></i></span>

											<input type="text" onkeyup=""  class="form-control" value="<?php echo $value;?>" name="answers_sorting_type[]" />

											<span class="ulp-delete-parent input-group-addon"><i class="fa-ulp fa-remove-ulp ulp-pointer"></i></span>

										</div>

									<?php endforeach;?>

								</div>



								<div id="ulp_add_values_for_sorting_type" class="ulp_add_value"><?php _e('Add new Value', 'ulp');?></div>



				   </div>

			 </div>

	 </div>

</div>


<div id="image_single_type_of_answer" class="ulp_div_to_show_hide">
  <div class="ulp-inside-item">
		  <div class="row">
		   <div class="col-xs-6">
			    <h4><?php _e('Choose Image - single choice', 'ulp');?></h4>
				<?php
					if (empty($data['image_answers_single_answer_possible_values'])){
						$data['image_answers_single_answer_possible_values'] = ['...upload an image from Media Library'];
					}
				?>
				<div id="ulp_image_single_answers_wrapp" >
					<?php $i = 1;?>
					<?php foreach ($data['image_answers_single_answer_possible_values'] as $value):?>
						<div class="input-group" style="  max-width: 400px; margin-bottom:10px;">
							<span class="input-group-addon" id="basic-addon1"><?php _e('ID:', 'ulp');?><span class="ulp_answer_num"><?php echo $i;$i++;?></span></span>
							<input type="text" onkeyup=""  class="form-control" value="<?php echo $value;?>" name="image_answers_single_answer_possible_values[]" onClick="openMediaUp(this);" placeholder="...upload an image from Media Library" />
							<span class="ulp-delete-parent input-group-addon"><i class="fa-ulp fa-remove-ulp ulp-pointer"></i></span>
						</div>
					<?php endforeach;?>
				</div>

				<div id="ulp_add_values_for_image_single_answers" class="ulp_add_value"><?php _e('Add new Option', 'ulp');?></div>
				<h4><?php _e('Correct Answer', 'ulp');?></h4>
			    <div class="input-group" style="  max-width: 400px;">
			    		<span class="input-group-addon" id="basic-addon1"><?php _e('Right Answer:', 'ulp');?></span>
			    		<input type="text" name="image_answers_single_answer_correct_value" class="form-control" id="image_answers_single_answer_correct_value" value="<?php echo $data['image_answers_single_answer_correct_value'];?>" />
			    </div>
                <div style="margin-top:15px;"><strong><i><?php _e('Write the ID of the right image', 'ulp');?></i></strong></div>
		   </div>
		 </div>
 </div>
</div>

<div id="image_multiple_type_of_answer" class="ulp_div_to_show_hide">
	  <div class="ulp-inside-item">
				<div class="row">
					   <div class="col-xs-6">
								<h4><?php _e('Choose Image - multiple choice', 'ulp');?></h4>
								<?php
									$checkbox_correct_values = [];
									$checkbox_correct_values = $data['image_answers_multiple_answers_possible_values'];

									if (empty($data['image_answers_multiple_answers_possible_values'])){
										$data['image_answers_multiple_answers_possible_values'] = ['...upload an image from Media Library'];
									}
								?>
								<div id="ulp_image_multiple_answers_wrapp">
									<?php $i = 1;?>
									<?php foreach ($data['image_answers_multiple_answers_possible_values'] as $k => $v ):?>
										<div class="input-group" style="  max-width: 400px; margin-bottom:10px;">
											<span class="input-group-addon" id="basic-addon1"><?php _e('ID:', 'ulp');?><span class="ulp_answer_num"><?php echo $i;$i++;?></span></span>
											<input type="text" class="form-control" value="<?php echo $v;?>" name="image_answers_multiple_answers_possible_values[]" onClick="openMediaUp(this);" placeholder="...upload an image from Media Library"/>
											<span class="ulp-delete-parent input-group-addon"><i class="fa-ulp fa-remove-ulp ulp-pointer"></i></span>
										</div>
									<?php endforeach;?>
								</div>
								<div id="ulp_add_values_for_image_multiple_answers" class="ulp_add_value"><?php _e('Add new Option', 'ulp');?></div>
								<h4><?php _e('Correct Answers', 'ulp');?></h4>
							    <div class="input-group" style="  max-width: 400px;">
							    <span class="input-group-addon" id="basic-addon1"><?php _e('Right Answers:', 'ulp');?></span>
							    <input type="text" name="image_answers_multiple_answers_correct_answers" class="form-control" id="image_answers_multiple_answers_correct_answers" value="<?php echo $data['image_answers_multiple_answers_correct_answers'];?>" />
								</div>
								<div style="font-size: 13px; color: green; margin-top:15px;"><strong><i><?php _e("Write the IDs of the right images separated by comma ',' .", 'ulp');?></i></strong></div>
					  </div>
			 	</div>
 	  </div>
</div>

<div id="matching_type_of_answer" class="ulp_div_to_show_hide">
	<div class="ulp-inside-item">
			<div class="row">
					 <div class="col-xs-6">
							<h4><?php _e('Add Matched data', 'ulp');?></h4>
							<?php
								if (empty($data['matching_micro_questions'])){
									$data['matching_micro_questions'] = ['examples'];
								}
							?>
							<div id="ulp_matching_qanda_wrapp">
								<?php foreach ($data['matching_micro_questions'] as $k => $v ):?>
									<div class="input-group" style="max-width: 600px; margin-bottom: 15px;">
										<input type="text" class="form-control" value="<?php echo $v;?>" name="matching_micro_questions[]" placeholder="<?php _e('Question', 'ulp');?>" />
										<input type="text" class="form-control" style="margin-top:3px;" value="<?php if (isset($data['matching_micro_questions_answers'][$k])) echo $data['matching_micro_questions_answers'][$k];?>"
										 name="matching_micro_questions_answers[]" placeholder="<?php _e('Answer', 'ulp');?>" />
										<span class="ulp-delete-parent input-group-addon"><i class="fa-ulp fa-remove-ulp ulp-pointer"></i></span>
									</div>
								<?php endforeach;?>
							</div>
							<div id="ulp_add_values_for_matching" class="ulp_add_value"><?php _e('Add new Option', 'ulp');?></div>

					</div>
			</div>
	</div>
</div>

<script>

jQuery(document).ready(function(){

	jQuery('#ulpsrotingtype_wrapp').sortable({

		 update: function(e, ui) {

			jQuery('#ulpsrotingtype_wrapp div').each(function (i, row) {

				//var id = jQuery(this).attr('id');

				//jQuery('#'+id+' .ulp_account_page_menu_order').val(i);

			});

		 }

	});

});

</script>



<?php do_action('ulp_admin_after_meta_box_question_answer');?>
