<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


function template_soal()
{
	$ci =& get_instance();
	$kategori = $ci->db->get('t_kategori')->result();
	$soal = $ci->db->get('t_soal')->result_array();
	
	foreach($soal as $a => $b)
	{
		$combine[$b['f_kategori_id']][] = $b;
	}
	
	//echo "<pre>";echo print_r($combine)."</pre><br/>";
	$html = "";
	
	foreach($kategori as $a)
	{
		$html .= "<div class=\"step\">
				<h3>".$a->f_kategori_name."</h3>
				<p class=\"lead\">Bacalah baik-baik Setiap Soal, dan Pilih Jawaban yang Paling Menggambarkan Diri Anda.</p>
				<div class=\"row\" style=\"font-size: 15pt;\">
					<div class=\"col-md-6\">
		";
		$i=1;
		foreach($combine[$a->f_kategori_id] as $b)
		{
			if($i > 5)	$html .= "</div><div class=\"col-md-6\">";
				
			$html .= "
					<div class=\"form-group\">
						<p class=\"col-md-12\">$i. ".$b['f_soal_name']." </p>
						<div class=\"col-md-offset-1 col-md-9\">	
			";
			$jwb = unserialize($b['f_soal_array']);
			//echo "<pre>";echo print_r($jwb)."</pre><br/>";
			if($b['f_soal_type'] == 'text')
			{
				$html .= "<input type=\"text\" name=\"no".$b['f_soal_id']."\" id=\"no".$b['f_soal_id']."\" class=\"form-control\" placeholder=\"Jawab ... \" required>";
			}
			else if($b['f_soal_type'] == 'textarea')
			{
				$html .= "<textarea name=\"no".$b['f_soal_id']."\" id=\"no".$b['f_soal_id']."\"></textarea>";
			}
			else if($b['f_soal_type'] == 'checkbox')
			{
				$j=1;
				foreach($jwb as $c)
				{
					$html .= "<input type=\"checkbox\" name=\"no".$b['f_soal_id']."\" id=\"no".$b['f_soal_id']."\" value=\"".$j."_".$c['value']."\" required>  ".$c['keterangan']."<br/>";
					$j++;
				}
			}
			else if($b['f_soal_type'] == 'radio')
			{
				$j=1;
				foreach($jwb as $c)
				{
					$html .= "<input type=\"radio\" name=\"no".$b['f_soal_id']."\" id=\"no".$b['f_soal_id']."\" value=\"".$j."_".$c['value']."\" required>  ".$c['keterangan']."<br/>";
					$j++;
				}
			}
				$html .= "
							</div>
						</div>
						<div class=\"pesan_no".$b['f_soal_id']."\"></div>
					";

			$i++;
		}
		$html .= "
					</div>
				</div>
			";
		$html .= "</div>"; // end .step		
	}
	
	return $html;
}
