What's new

Closed Quiz project

Status
Not open for further replies.

nash_08

Addict
Joined
Nov 10, 2016
Posts
215
Reaction
50
Points
112
Badly needed all my masters/bossing/experts in Phcorner

Requirement sa EDUCATIONAL TECHNOLOGY

*MULTIPLE CHOICE with TIMER and randomize questions

O.K na sya dahil nakhanap na ako ng code but the problem are;
>dapat my starter/begin button (ung code na nahanap ko directly, pagopen mo sa file nya deretso sa question agad dpat my BEGIN BUTTON @ my box na susulatan ng pangalan)
>dapat ma store ung results @ printable sya

BIG THANKS sa mga pinagpalang mga MASTER ^_^
 
May code ka na pala. Exploit mo na, h a c k mo na para masunod ang gusto mo.
 
May code ka na pala. Exploit mo na, h a c k mo na para masunod ang gusto mo.
ito ung code

<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<title>QUIZ</title>
<!-- Set the viewport width to device width for mobile -->
<meta name= "viewport" content = "width=device-width" />
<style>
#table_1 {
background:img src= "NARUTO.jpg";
}
</style>
<div id="table_1"></div>
<script> /* You do not have permission to view the full content of this post. Log in or register now. */
var questions = [ [ /* here we will move asked (whether answered or not) questions */ ],
[["Ano ang ibig sabihin ng BTC?" , "Bachelor of Training Center", "Banipa Training Center", "Black Troop Camp"],"false",2],
[["What is 20 - 9?", "7", "13", "11", "C" ],"false",3],
[["What is 7 x 3?", "21", "24", "25", "A" ],"false",1],
[["What is 8 / 2?", "10", "2", "4", "C" ],"false",3],
[["Who is 1 + 1?", "1", "2", "4", "3," ],"false",2],
[["What is 2 + 3", "5", "4", "2", "1" ],"false",1],
[["What is the smallest particle of matter?",],"false",1]
],
to='',
sec=15,
A; /* useful funcs */
function _(x){return document.getElementById(x);}
function getRandomInt(min,max){return Math.floor(Math.random() * (max - min)) + min;}
function in_array(what,where){for(var i=0; i < where.length; i++)if(what == where)return true;return false;}
function ask(){
var len=questions.length;
if(len==1){
var answers=questions[0],
a_len=answers.length,
cor=0,
incor=0,
msg='';
for(var z=0; z < a_len; z++){
if(in_array('true',answers[z])){cor++;}
else{incor++;}
}
msg='You have given '+cor+' correct and '+incor+' incorrect answers for '+a_len+' questions Quiz.<br />';
_('test').innerHTML=msg;
if(_('nw').checked){
var win=window.open('','resultWin','width=500,height=500,top=0,left=0,statusbar=no,searchbar=no,titlebar=no,toolbar=no,location=no,scrollbars=no');
win.document.write('<center><div style="padding:150px 20px;">'+msg+'</div><a href="#null" onclick="window.close();">Close</a></center>');
win.focus(); win.moveBy((screen.width-500)/2,(screen.height-500)/3);
}
return;
}
else{
var answered=questions[0].length,/* how many questions already answered */
temp=questions.slice(1),/* get a copy of questions w/o first element */
total=answered + temp.length,/* how many questions in the Quiz */
index=getRandomInt(0,temp.length),
Q=A=temp[index],/* pick a random element from temp */
Q_answer_index=Q[2], /* index of the correct answer */
q_text=Q[0][0],/* question text */
q_answers=Q[0].slice(1),/* possible answers */
test=_('test'),
i=0,/* counter */
user_input='false';/* user answer */
test.innerHTML='<div>You have answered '+answered+' questions from '+total+'</div><h3>'+q_text+'</h3><div id="tt"></div>';
for(; i<q_answers.length; i++){
var val=(i+1==Q_answer_index) ? 'true' : 'false';
test.innerHTML+='<b>'+(i+1)+'.</b>&nbsp;<input type="radio" name="choices" value="'+val+'" title="'+val+'" />&nbsp;<i>'+q_answers+'</i><br />'; }
test.innerHTML+='<br /><button>Submit Answer</button>';
var opts=test.querySelectorAll('[type="radio"]'),
btn=test.querySelector('button');
for(var k=0; k<opts.length; k++){
opts[k].onchange=function(){user_input=this.value;
}
}
btn.onclick=function(){
A[1]=user_input;
clearTimeout(to);
answer(index+1);
}
timer(sec,index+1);
}
}
function timer(val,ind){
var ending=(val > 1) ? 's' : '';
var txt='<b class="r">'+( val>9 ? val : ('0'+val) )+'</b> second'+ending+' left';
if(val > 0){ _('tt').innerHTML=txt;
val--;
to=setTimeout('timer('+val+','+ind+')',1000);
}
else{
_('tt').innerHTML='Time is up';
clearTimeout(to); answer(ind);
return;
}
}
function answer(ind){
questions[0].push(A);
questions.splice(ind,1);
setTimeout('ask()',200);
}
onload=ask;
</script>
</head>
<body>
<div id="test"></div>
<label for="nw"><input type="checkbox" checked="checked" id="nw" />&nbsp;Show results in a new window</label>
<div id="footer" class="row">
<div id="table_1"></div>
good luck!!!
</div>

</body>

</html>


beginner here master, not too familiar in exploiting but I understand some basic code
 
Status
Not open for further replies.

Similar threads

Back
Top