Skip to content

Instantly share code, notes, and snippets.

@Kimeiga
Created April 29, 2020 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kimeiga/02125ea272da35be2c60021495ec6e78 to your computer and use it in GitHub Desktop.
Save Kimeiga/02125ea272da35be2c60021495ec6e78 to your computer and use it in GitHub Desktop.
hi brandon
<script Language="JavaScript">
count = 0;
numberCorrect = 0;
questin = 'What is the capital of Massachusetts?-Boston,What is the capital of California?-Sacramento,What is the capital of Oregon-Salem,What is the capital of Texas-Austin,What is the capital of Idaho?-Boise';
quests = questin.split(",");
questionShuffle(quests);
answer = questin.split("-");
wrongins = "Springfield,Salem,Jacksonville,Boise,Montgomery,Helena,Juneau,Lincoln,Carson City,Concord,Hartford,Dover,Columbus,Columbia,Pierre,Richmond,Lansing,Olympia,Charleston,Madison";
wrongs = wrongins.split(",");
questionShuffle(wrongs);
function showquestion() {
document.getElementById('showAnswer').style.display = 'none';
document.getElementById('rtanswer').style.display = 'none';
if (count < 5) {
document.getElementById('showquestions').innerHTML = quests[count];
count = count + 1;
setTimeout(showquestion, 1000);
}
else {
}
}
function showAnswer() {
if (count < 5) {
document.getElementById('showAnswer').innerHTML = answer[count];
count = count + 1;
setTimeout(showquestion, 1000);
}
else {
percentCorrect = (correctCount / 5) * 100;
document.getElementById('finalDisplay').innerHTML = "You got " + percentCorrect + "% correct."
document.getElementById('finalDisplay'.style.display = 'block');
if (percentCorrect == 100) {
document.getElementById('hundredPercent').innerHTML = "You are awesome."
document.getElementById('hundredPercent').style.display = 'block';
}
}
}
function shuffleDistracters(distracterArray) {
x = Math.random();
i = Math.floor(x * 4);
}
function questionShuffle(array) {
for (var i = array.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = array[i];
array[i] = array[j];
array[j] = temp;
}
document.getElementById('showquestions').innerHTML = quests;
}
function answerShuffle(array) {
for (var i = array.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = array[i];
array[i] = array[j];
array[j] = temp;
}
document.getElementById('showanswers').innerHTML = answer;
}
function runScript(e) {
valresp = 0;
if (e.keyCode == 32 || e.keyCode == 70 || e.keyCode == 75 || e.keyCode == 76) {
valresp = 1;
}
if (valresp == 1) {
endtime = new Date().getTime();
resptime = endtime - starttime;
resptime = resptime / 1000;
if (e.keyCode == correctAnswer) {
document.getElementById('showAnswer').innerHTML = 'CORRECT!';
document.getElementById('showAnswer').style.color = '#00FF00';
document.getElementById('showAnswer').style.display = 'block';
numberCorrect = numberCorrect + 1;
// response time
document.getElementById('showResponseTime').innerHTML = 'Response Time: ' + resptime;
document.getElementById('showResponseTime').style.color = '#00FF00';
}
else {
document.getElementById('showAnswer').innerHTML = 'INCORRECT.';
document.getElementById('showAnswer').style.color = '#FF0000';
document.getElementById('showAnswer').style.display = 'block';
// response time
document.getElementById('showResponseTime').innerHTML = 'Response Time: ' + resptime;
document.getElementById('showResponseTime').style.color = '#FF0000';
}
}
trialnum = 0;
}
</script>
<body onkeyup="return runScript(event)">
<div id='instruct'> Click the button to start the quiz. There will be 5 multiple choice questions regarding state
capitals. Press the key corresponding to the answer you believe is correct. Move onto the next question by
pressing the spacebar. </div><br>
<button type='button' style='font-size:24pt;background:#ddffdd' onclick="this.blur();showquestion()">Click Here to
Start</button><br>
</body>
<div id='questions' style='font-size:16pt;display:none'></div><br>
<div id='showquestions' style=''>Words will appear here</div><br>
<table id='answerChoice' style='display:none'>
<tr>
<td>
<div id='choice1'></div>
</td>
<td>
<div id='choice2'></div>
</td>
<td>
<div id='choice3'></div>
</td>
<td>
<div id='choice4'></div>
</td>
</tr>
</table><br><br>
<div id='showAnswer' style='display:none'></div><br>
<div id='showResponseTime' style='display:none'></div><br><br>
<div id='finalDisplay' style='display:none'></div><br>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment