<?php
include_once('c_quiz_known_card.php');

class c_page_cab_quiz_known_card_questions extends c_page_cab_quiz_known_card
{
    public $h1='Контроль знаний - карточка знаний - вопросы';

    function block_main()
    {   $this->page_title() ;
        $this->panel_quiz_rasdel_tickets() ;
    }

    function panel_quiz_rasdel_tickets()
     {
       $this->panel_known_manual();

       $recs=execSQL('select * from quiz_questions where parent='.$this->rec_known['pkey']) ;
       if (_sizeof($recs)) $recs_answers=execSQL('select * from quiz_answers where question_id in ('.implode(',',array_keys($recs)).')') ;
       if (_sizeof($recs)) $recs_contents=execSQL('select * from quiz_content where question_id in ('.implode(',',array_keys($recs)).')') ;
       $recs_answers_by_question=group_by_field('question_id',$recs_answers) ;
       $recs_contents_by_question=group_by_field('question_id',$recs_contents) ;
       ?><div id="panel_filter" class="full"><form id="sky-form" class="sky-form">
           <div id="panel_buttons">
                <button class="button v1" href="/frame/quiz/known/card/<? echo $this->rec_known['pkey'] ?>/new_question/">Добавить билет</button>
                <?if (_sizeof($recs)){?>
                <button class="button v2" cmd="quiz/get_panel_tiket_move" parent="<?echo $this->rec_known['pkey']?>">Переместить билет</button>
                <button class="button v2" cmd="quiz/get_panel_tiket_delete" parent="<?echo $this->rec_known['pkey']?>">Удалить билет</button>
                <?}?>
           </div>
         <input type="hidden" name="theme_id" value="<?echo $this->rec_known['parent2']?>">
         <input type="hidden" name="section_id" value="<?echo $this->rec_known['pkey']?>">
       <table class="basic fz_small full auto">
         <tr>
             <th style="width:70px;">Выбор</th>
             <th style="width:70px;">№ билета</th>
             <th style="width:30%;">Вопрос</th>
             <th style="width:auto;">Ответы</th>
             <th style="width:200px;">Фото/Видео</th>
         </tr><?
           $i=1 ;
       foreach($recs as $rec)
       {   ?><tr>
               <td><input type="checkbox" name="_check[]" value="<?echo $rec['pkey']?>"></td>
               <td><?echo $i ; $i++?></td>
               <td class="left"><i class="far fa-question-circle"></i><a class="v1" href="/frame/quiz/question/card/<?echo $rec['pkey']?>/"><?echo $rec['obj_name']?></a></td>
               <td class="left"><ul><? if (_sizeof($recs_answers_by_question[$rec['pkey']])) foreach($recs_answers_by_question[$rec['pkey']] as $rec_answer) {?><li class="<?echo ($rec_answer['status']==1)? 'green':''?>"><?echo $rec_answer['obj_name']?></li><?}?></ul></td>
               <td><? if (_sizeof($recs_contents_by_question[$rec['pkey']])) foreach($recs_contents_by_question[$rec['pkey']] as $rec_content)
               { switch($rec_content['type'])
                 { case 'image/jpeg': ?><img src="<?echo $rec_content['dir'].$rec_content['file_name']?>" width="150px"><? break ;

                 }
                 //print_r($rec_content) ; echo '<br>' ;
                }
                ?></td>
           </tr><?
       }
           ?></table></form></div><?
     }


}

?>
