Thursday 15 January 2015

html - How to grade a quiz in javascript -



html - How to grade a quiz in javascript -

i have made quiz in javascript html , trying figure out how grade it.

here html quiz:

<div id="takequiz" class="quiz" style="display:none"> <p name="questions" class="question" id="q">random question</p> <ul class="answers"> <input type="radio" name="choices" value="a" id="q1a"><label for="q1a">answer 1</label><br/> <input type="radio" name="choices" value="b" id="q1b"><label for="q1b">answer 2</label><br/> <input type="radio" name="choices" value="c" id="q1c"><label for="q1c">answer 3</label><br/> <input type="radio" name="choices" value="d" id="q1d"><label for="q1d">answer 4</label><br/> </ul> </div>

i have created next() function creates new question each time next question button clicked.

var next = function () { "use strict"; console.log("next question "); var choices; choices = document.getelementbyname("choices"); questionindex = questionindex + 1; createquestions(); //allquestions += 1; if (choices == correct) { correct++; } if (questionindex >= 12) { console.log("the quiz has ended"); document.getelementbyid("takequiz").style.display = 'none'; document.getelementbyid("thequizresults").style.display = 'block'; } };

i want know how if selection selected right 1 increment right count 1. can create gradequiz function grade quiz 1 time complete. dont know if im making sense, help appreciated

this link code ive written http://jsfiddle.net/xxsw5u7g/

this text file loading questions array

maunga,mountain,ika,fish,awa,river,roto,lake,moana,sea,ngahere,forest,puke,hill,manu,bird,kererū,wood pigeon,kiore,rat,kiwi,kiwi,pīwakawaka,fantail

in html give same id 4 radio buttons. maintain hidden variable storing count

you can have submit button , on click phone call function name thing.

function grader() { var value=document.getelementbyid('radiobuttonid') if(value=={original answer}) count++; }

javascript html

No comments:

Post a Comment