ign="justify"> lt; div id= container gt;
lt;/div gt;
lt; script gt;
quests=JSON.parse ( lt;?=$ questions;? gt; ); result={}; q;
. log (quests);
cl (s)
{. log (s);
}
get_random (q)
{l=Object.keys (q) .length;
(l == 0) return false;
=Math.floor (Math.random () * l) + 1ret, i=1;
$. each (q, function (n, val) {
(i === l)
{= val; (q [n]);
} ++;
}) (ret);
}
test (q)
{
/* var q=get_random (quests); */s= lt; h2 gt; + q.quest + ! lt; h2 gt; +
lt; ul gt; raquo ;;
$. each (q.answers, function (i, val) {+= lt; li gt; +
lt; input type= radio name= ans value= + i + gt; + val +
lt;/li gt;
}) += lt;/ul gt; lt; input num= + q.id + type= button value= id= ans gt; raquo ;; (s);
$ ( # container ). html (s);
}
$ ( # ans ). live ( click , function () {i=$ (this) tr ( num ); v=$ ( input [name=ans]: checked ). val ();
cl (v); (! v)
{( );
return false;
}
[i]=Number (v);=get_random (quests); (q) test (q);
{(result); name=prompt (: raquo ;, defaultText= 3 );=(name!=0)? name: raquo ;;
$ ( # container ). load (
lt;?=base_url ( main/get_result );? gt; ,
{
r :Result,
n :Name
}
);
}
})
$ (function () {= get_random (quests); (q);
lt;/script gt;