<?php
include_once('c_quiz_theme_card.php');
class c_page_cab_quiz_theme_card_knows extends c_page_cab_quiz_theme_card
{
    public $h1='Контроль знаний - карточка раздела - знания';
    public $title=' - знания';

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

    function panel_quiz_theme_sections()
    {
        $recs_questions=[];
        $recs=execSQL('select t1.*,t2.obj_name as manual
                       from quiz_themes t1
                       left join quiz_themes_text t2 on t2.parent=t1.pkey
                       where t1.parent='.$this->rec_section['pkey'].' and t1.clss=481');
        if (_sizeof($recs)) $recs_questions=execSQL('select pkey,obj_name,parent from quiz_questions where parent in ('.implode(',',array_keys($recs)).')') ;
        $recs_questions_by_sections=group_by_field('parent',$recs_questions) ;


        ?>
        <div id="panel_filter" class="full">
        <form id="sky-form" class="sky-form">
            <div id="panel_buttons">
                <button class="button v2" cmd="quiz/get_panel_section_create" theme_id="<? echo $this->rec_section['pkey'] ?>">Добавить знание</button>
                <?if (_sizeof($recs)){?>
                <button class="button v2" cmd="quiz/get_panel_section_move" theme_id="<? echo $this->rec_section['pkey'] ?>">Переместить знание</button>
                <button class="button v2" cmd="quiz/get_panel_section_delete" theme_id="<? echo $this->rec_section['pkey'] ?>">Удалить знание</button>
                <?}?>
            </div>

        <table class="basic fz_small full auto">
            <tr>
                <th style="width:100px;">Выбор</th>
                <th>Наименование, контент знания / текст вопросов</th>
            </tr><?
            foreach($recs as $rec)
            { ?>
                <tr>
                <td><input type="checkbox" name="_check[]" value="<? echo $rec['pkey'] ?>"></td>
                <td class="left"><i class="far fa-bookmark"></i><strong><a class="v1" href="/frame/quiz/known/card/<?echo $rec['pkey']?>/"><? echo $rec['obj_name'] ?></a></strong><br><?echo $rec['manual']?></td>

                </tr><?
                if (_sizeof($recs_questions_by_sections[$rec['pkey']])) foreach($recs_questions_by_sections[$rec['pkey']] as $rec_question)
                {
                    ?>
                        <tr>
                        <td></td>
                        <td class="left"><i class="far fa-question-circle"></i><a style="color:gray;" class="v1" href="/frame/quiz/question/card/<?echo $rec_question['pkey']?>/"><? echo $rec_question['obj_name'] ?></a></td>
                        </tr>
                    <?
                }
            }
            ?></table>
        </form></div>
        <?
    }

}

?>
