<?
function panel_quiz($quiz_id,$virt_status=0)
{     $virt_status=1 ;   $res_quiz=array() ;
      $url=_MAIN_PROTOCOL._MAIN_DOMAIN.'/?operation=quiz&id='.$quiz_id ;
      echo 'Отправляем запрос на пакет данных по контролю знаний: '.$url.'<br>' ;

      $result=IO()->doPut_v2(_MAIN_PROTOCOL,_MAIN_DOMAIN,'/','operation=quiz&id='.$quiz_id,'',array('no_log_request'=>0)) ;
      if ($result['status']==200) $res_quiz=json_decode($result['content'],true);
      else damp_array($result,1,-1);
      //damp_array($res_quiz,1,-1) ;
      if (_sizeof($res_quiz))
      { ?><h3><?echo $res_quiz['quiz']['title']?></h3>
	      <input type="hidden" name="quiz_id" value="<?echo $quiz_id?>">

	      <?
        ?>min_questions: <strong><?echo $res_quiz['quiz']['min_questions']?></strong> <?
        ?>max_errors: <strong><?echo $res_quiz['quiz']['max_errors']?></strong><br><br><?
        if (_sizeof($res_quiz['quiz']['questions'])) foreach($res_quiz['quiz']['questions'] as $question)
        { ?><h3 style="color:green;"><? echo  $question['text']?></h3><?
          if (_sizeof($question['images'])) foreach($question['images'] as $img_base64_content) {?><img width="600" src="<?echo $img_base64_content?>"><br><?}
          $i=0 ;
          if (_sizeof($question['answers'])) foreach($question['answers'] as $answer) if (is_array($answer) and isset($answer['text']))
           {?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="hidden" name="quiz_answers[<?echo $answer['id']?>]" value="<?echo ($answer['correct']===true)? 'true':'false'?>">
                    <input type="radio" name="quiz_answer_correct[<?echo $question['id']?>]" value="<?echo $answer['id']?>" <?if ($virt_status) echo ((rand(1,10)<5 and $answer['correct']) or !$i)? 'checked':''?>>&nbsp;&nbsp;
                    <span style="<?echo ($answer['correct'])? 'text-decoration:underline':'color:gray'?>"><?echo $answer['text']?></span><br><?
               $i++ ;
           }
          ?><br><?
        }
      }
      else {?><h3>Выполняем запрос на контроль уровня знаний</h3><div class="alert">Некорректный ответ сервера</div><?}
}

?>
