<?php wp_enqueue_script( 'ulp_public_instructor_actions', ULP_URL . 'assets/js/instructor_actions.js', [], false, false );?>
<h3><?php _e('Questions', 'ulp');?></h3>

<div class="ulp-instructor-dashboard-bttn">
    <a href="<?php echo $addNewLink;?>" class="btn btn-primary pointer"><?php _e('Add New Question', 'ulp');?></a>
</div>

<?php if ($items):?>
    <div class="ulp-instructor-dashboard-question-list ulp-instructor-dashboard-list">
    <div class="ulp-instructor-item-list-head">
     <div class="ulp-instructor-item-list-row">
        <div class="ulp-instructor-item-list-col ulp-instructor-item-list-title"><?php _e('Title', 'ulp');?></div>
        <div class="ulp-instructor-item-list-col ulp-instructor-item-list-quiz"><?php _e('Quiz', 'ulp');?></div>
        <div class="ulp-instructor-item-list-col ulp-instructor-item-list-type"><?php _e('Type', 'ulp');?></div>
        <div class="ulp-instructor-item-list-col ulp-instructor-item-list-points"><?php _e('Points', 'ulp');?></div>
        <div class="ulp-instructor-item-list-col ulp-instructor-item-list-date"><?php _e('Date', 'ulp');?></div>
     </div>
    </div>
     <div class="ulp-instructor-item-list-content">
        <?php foreach ($items as $key=>$post):?>
		<?php
				$row_class ='';
				if($key%2 == 0) $row_class = 'even';
				else   $row_class = 'odd';
			?>
         <div class="ulp-instructor-item-list-row <?php echo $row_class;?>">
            <div class="ulp-instructor-item-list-col ulp-instructor-item-list-title">
                  <i class="fa-ulp fa-ulp_question-ulp"></i><span class="ulp-instructor-item-list-name"><a href="<?php echo \Ulp_Permalinks::getForQuestion($post->ID);?>" target="_blank">
                  <?php
                    $limited_content = mb_substr( strip_tags(stripslashes($post->post_content)), 0 , 120);
                    echo $limited_content;?></a></span>
                     —
                    <span class="ulp-instructor-item-list-status-<?php echo $post->post_status;?>"><?php echo ucfirst($post->post_status);?></span>
                    <div  class="ulp-instructor-item-list-options">
                      <span><a href="<?php echo add_query_arg(['tab' => 'add-edit', 'type' => 'ulp_question', 'postId' => $post->ID], $baseUri);?>"><?php _e('Edit', 'ulp');?></a></span> |
                      <span><a href="<?php echo add_query_arg(['tab' => 'special-settings', 'type' => 'ulp_question', 'postId' => $post->ID], $baseUri);?>"><?php _e('Special settings', 'ulp');?></a></span> |
                      <span class="js-ulp-do-delete-post ulp-delete-link" data-post="<?php echo $post->ID;?>"><?php _e('Delete', 'ulp');?></span> |
                      <span><a href="<?php echo \Ulp_Permalinks::getForQuestion($post->ID);?>" target="_blank"><?php _e('View', 'ulp');?></a></span>
                  </div>
              </div>
                <div class="ulp-instructor-item-list-col ulp-instructor-item-list-quiz">
                  <?php
                  $items = DbUlp::getQuizesForQuestionId($post->ID);
      						$str = '';
      						if ($items){
      							foreach ($items as $item){
      								echo '<div class="ulp-instructor-item-list-quiz-name">' . DbUlp::getPostTitleByPostId($item['quiz_id']) . '</div>';
      							}
      						}
                  ?>
              </div>
                <div class="ulp-instructor-item-list-col ulp-instructor-item-list-type">
                  <?php
                      $opt = array(
          									1 => __('Free choice', 'ulp'),
          									7 => __('Fill In', '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'),
          						);
          						$type = get_post_meta($post->ID, 'answer_type', true);
          						if ($type){
          							echo $opt[$type];
          						}
                  ?>
              </div>
                <div class="ulp-instructor-item-list-col ulp-instructor-item-list-points">
                <?php
                  $points = get_post_meta($post->ID, 'ulp_question_points', true);
      						if ($points){
      							echo $points;
      						}
                ?>
              </div>
                <div class="ulp-instructor-item-list-col ulp-instructor-item-list-date">
                  <?php echo ulp_print_date_like_wp($post->post_date, false);?>
             </div>
		 </div>
        <?php endforeach;?>
     </div>
 </div>
<?php endif;?>

<?php if ($pagination):?>
    <?php echo $pagination;?>
<?php endif;?>
