Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Having a couple smalll issues with this one, on html this quiz I created -It is

ID: 3814049 • Letter: H

Question

Having a couple smalll issues with this one, on html this quiz I created
-It is only randomizing between the first 8 Questions in the code instead of randomizing from all 12
-I have 5 pictures in a folder called "Homework 11 Pictures", if the user gets at least 6/10 correctly, I need to have one of those pictures at random pop up on the screen available for save
Thank You and here is the code

<!DOCTYPE html>
<head>
<title>The UGLT Challenge</title>
<style>
div#test{ border:#000 1px solid; padding:10px 40px 40px 40px; }
</style>
</head>
<body>
<div>
<h2 id="test_status">Do Yo Best G</h2>
<h3 id="timeleft">Time left</h3>
</h4> I Finish Fast, So Can You</h4>
</div>
<div id="test"></div>
  
<script>
var totalQuetions = 08;
var myVar;
function startTimer() {
myVar = setInterval(function(){myTimer()},1000);
timelimit = maxtimelimit;
}
function myTimer() {
if (timelimit > 0) {
curmin=Math.floor(timelimit/60);
cursec=timelimit%60;
if (curmin!=0) { curtime=curmin+" minutes and "+cursec+" seconds left"; }
else { curtime=cursec+" seconds left"; }
$_('timeleft').innerHTML = curtime;
} else {
$_('timeleft').innerHTML = timelimit+' - Out of Time - You Took The L Homie';
clearInterval(myVar);
}
timelimit--; //How Much Time
}
  
  
var pos = 0, posn, choice, correct = 0, rscore = 0;
var maxtimelimit = 08, timelimit = maxtimelimit; // 08 seconds per question
var questions = [
[ "Who is the first offical President of the U.S.A?", "Ben Franklin", "George Washington", "Barack Obama", "Abe Lincoln", "Jay-Z", "B" ],
[ "Which Movie won best picture at the 71st Academy Awards", "Titanic", "American Beauty", "Shakespeare in Love", "Gladiator", "Pootie Tang", "C" ],
[ "More people die of dehydration than drown in a desert?", "LIE", "Troof", "L", "Taco", "Lice", "A" ],
[ "Which was the northern most battle of the civil war?", "Cedar Hill", "Bull Run", "Gettysburg", "Antietam", "Schrute Farms", "E" ],
[ "What is 99 x 99?", "9907", "9571", "9801", "8901", "9081", "C"],
[ "The month of July is named after Julius Ceaser, what was it known as before ? ?", "Dromas", "Quintilis", "Andromeda", "Gemmae", "Junius", "B" ],
[ "The Anglo-Zanzibar war of 1896 lasted how long?", "Thirty-Eight Minutes", "Two Hours and 12 Minutes", "ninety-three minutes", "49 minutes", "2700 Seconds", "A" ],
[ "The term Dog Days of Summer comes from a star in what Constellation ?", "Coma Berenices", "Ursa Major", "Andromeda", "Corvus", "Canis Major", "E" ],
[ "Eminem was the highest selling artist of the 2000s, who was second?", "NSYNC", "The Beatles", "Beyonce", "Elvis Pressley", "Britney Spears", "B" ],
[ "The decimal value of 01000011 is", "23", "67", "48", "73", "55", "B" ],
[ "At over 2000 km long, The BLANK reef is the largest living structure on Earth", "Belize Barrier Reef", "Apo Reef", "New Caledonian", "Tubbataha", "Great Barrier Reef", "E" ],
[ "What is 842 / 2?", "407", "477", "421", "441", "389", "C" ],
["Which former WWE Suprtstar had the longest WWE Championship reign of all time?", "Gorgeous George", "Bruno Sammartino", "Andre tthe Giant", "Hulk Hogan", "Roddy Piper", "B" ],
["What was the first song to hit Number 1 on the Billboard Hot 100?", "Hit the Road Jack", "It's Only Make Believe", "The Chipmunk Song", "Little Star", "Poor Little Fool", "E" ],
  
];
var questionOrder = [];
function setQuestionOrder() {
questionOrder.length = 0;
for (var i=0; i<totalQuetions; i++) { questionOrder.push(i); }
questionOrder.sort(randOrd); // alert(questionOrder); // shuffle display order
pos = 0; posn = questionOrder[pos];
}
function $_(IDS) { return document.getElementById(IDS); }
function randOrd() { return (Math.round(Math.random())-0.5); }
function renderResults(){
var test = $_("test");
test.innerHTML = "<h2>You got "+correct+" of "+totalQuetions+" questions correct</h2>";
$_("test_status").innerHTML = "Test Completed";
$_('timeleft').innerHTML = '';
test.innerHTML += '<button>Re-test</a> ';
setQuestionOrder();
correct = 0;
clearInterval(myVar);
return false;
}
function renderQuestion() {
var test = $_("test");
$_("test_status").innerHTML = "Question "+(pos+1)+" of "+totalQuetions;
if (rscore != 0) { $_("test_status").innerHTML += '<br>Currently: '+(correct/rscore*100).toFixed(0)+'% correct'; }
var question = questions[posn][0];
var chA = questions[posn][1];
var chB = questions[posn][2];
var chC = questions[posn][3];
var chD = questions[posn][4];
var chE = questions[posn][5];
test.innerHTML = "<h3>"+question+"</h3>";
test.innerHTML += "<label><input type='radio' name='choices' value='A'> "+chA+"</label><br>";
test.innerHTML += "<label><input type='radio' name='choices' value='B'> "+chB+"</label><br>";
test.innerHTML += "<label><input type='radio' name='choices' value='C'> "+chC+"</label><br>";
test.innerHTML += "<label><input type='radio' name='choices' value='D'> "+chD+"</label><br>";
test.innerHTML += "<label><input type='radio' name='choices' value='E'> "+chE+"</label><br>";
test.innerHTML += "<button>Submit Answer</button>";
timelimit = maxtimelimit;
clearInterval(myVar);
startTimer();
}
function checkAnswer(){
var choices = document.getElementsByName("choices");
for (var i=0; i<choices.length; i++) {
if (choices[i].checked) { choice = choices[i].value; }
}
rscore++;
if (choice == questions[posn][6] && timelimit > 0) { correct++; }
pos++; posn = questionOrder[pos];
if (pos < totalQuetions) { renderQuestion(); } else { renderResults(); }
}
window.onload = function() {
setQuestionOrder();
renderQuestion();
}
</script>
</body>
</html>

Explanation / Answer

Below is the corrected code

<!DOCTYPE html>
<head>
<title>The UGLT Challenge</title>
<style>
div#test{ border:#000 1px solid; padding:10px 40px 40px 40px; }
</style>
</head>
<body>
<div>
<h2 id="test_status">Do Yo Best G</h2>
<h3 id="timeleft">Time left</h3>
</h4> I Finish Fast, So Can You</h4>
</div>
<div id="test"></div>
  
<script>
var totalQuetions = 12;
var myVar;
function startTimer() {
myVar = setInterval(function(){myTimer()},1000);
timelimit = maxtimelimit;
}
function myTimer() {
if (timelimit > 0) {
curmin=Math.floor(timelimit/60);
cursec=timelimit%60;
if (curmin!=0) { curtime=curmin+" minutes and "+cursec+" seconds left"; }
else { curtime=cursec+" seconds left"; }
$_('timeleft').innerHTML = curtime;
} else {
$_('timeleft').innerHTML = timelimit+' - Out of Time - You Took The L Homie';
clearInterval(myVar);
}
timelimit--; //How Much Time
}
  
  
var pos = 0, posn, choice, correct = 0, rscore = 0;
var maxtimelimit = 08, timelimit = maxtimelimit; // 08 seconds per question
var questions = [
[ "Who is the first offical President of the U.S.A?", "Ben Franklin", "George Washington", "Barack Obama", "Abe Lincoln", "Jay-Z", "B" ],
[ "Which Movie won best picture at the 71st Academy Awards", "Titanic", "American Beauty", "Shakespeare in Love", "Gladiator", "Pootie Tang", "C" ],
[ "More people die of dehydration than drown in a desert?", "LIE", "Troof", "L", "Taco", "Lice", "A" ],
[ "Which was the northern most battle of the civil war?", "Cedar Hill", "Bull Run", "Gettysburg", "Antietam", "Schrute Farms", "E" ],
[ "What is 99 x 99?", "9907", "9571", "9801", "8901", "9081", "C"],
[ "The month of July is named after Julius Ceaser, what was it known as before ? ?", "Dromas", "Quintilis", "Andromeda", "Gemmae", "Junius", "B" ],
[ "The Anglo-Zanzibar war of 1896 lasted how long?", "Thirty-Eight Minutes", "Two Hours and 12 Minutes", "ninety-three minutes", "49 minutes", "2700 Seconds", "A" ],
[ "The term Dog Days of Summer comes from a star in what Constellation ?", "Coma Berenices", "Ursa Major", "Andromeda", "Corvus", "Canis Major", "E" ],
[ "Eminem was the highest selling artist of the 2000s, who was second?", "NSYNC", "The Beatles", "Beyonce", "Elvis Pressley", "Britney Spears", "B" ],
[ "The decimal value of 01000011 is", "23", "67", "48", "73", "55", "B" ],
[ "At over 2000 km long, The BLANK reef is the largest living structure on Earth", "Belize Barrier Reef", "Apo Reef", "New Caledonian", "Tubbataha", "Great Barrier Reef", "E" ],
[ "What is 842 / 2?", "407", "477", "421", "441", "389", "C" ],
["Which former WWE Suprtstar had the longest WWE Championship reign of all time?", "Gorgeous George", "Bruno Sammartino", "Andre tthe Giant", "Hulk Hogan", "Roddy Piper", "B" ],
["What was the first song to hit Number 1 on the Billboard Hot 100?", "Hit the Road Jack", "It's Only Make Believe", "The Chipmunk Song", "Little Star", "Poor Little Fool", "E" ],
  
];
var questionOrder = [];
function setQuestionOrder() {
questionOrder.length = 0;
for (var i=0; i<totalQuetions; i++) { questionOrder.push(i); }
questionOrder.sort(randOrd); // alert(questionOrder); // shuffle display order
pos = 0; posn = questionOrder[pos];
}
function $_(IDS) { return document.getElementById(IDS); }
function randOrd() { return (Math.round(Math.random())-0.5); }
function renderResults(){
var test = $_("test");
test.innerHTML = "<h2>You got "+correct+" of "+totalQuetions+" questions correct</h2>";
$_("test_status").innerHTML = "Test Completed";
$_('timeleft').innerHTML = '';
test.innerHTML += '<button>Re-test</a> ';
setQuestionOrder();
correct = 0;
clearInterval(myVar);
return false;
}
function renderQuestion() {
var test = $_("test");
$_("test_status").innerHTML = "Question "+(pos+1)+" of "+totalQuetions;
if (rscore != 0) { $_("test_status").innerHTML += '<br>Currently: '+(correct/rscore*100).toFixed(0)+'% correct'; }
var question = questions[posn][0];
var chA = questions[posn][1];
var chB = questions[posn][2];
var chC = questions[posn][3];
var chD = questions[posn][4];
var chE = questions[posn][5];

test.innerHTML = "<h3>"+question+"</h3>";
test.innerHTML += "<label><input type='radio' name='choices' value='A'> "+chA+"</label><br>";
test.innerHTML += "<label><input type='radio' name='choices' value='B'> "+chB+"</label><br>";
test.innerHTML += "<label><input type='radio' name='choices' value='C'> "+chC+"</label><br>";
test.innerHTML += "<label><input type='radio' name='choices' value='D'> "+chD+"</label><br>";
test.innerHTML += "<label><input type='radio' name='choices' value='E'> "+chE+"</label><br>";
test.innerHTML += "<button>Submit Answer</button>";
timelimit = maxtimelimit;
clearInterval(myVar);
startTimer();
}
function checkAnswer(){
var choices = document.getElementsByName("choices");
for (var i=0; i<choices.length; i++) {
if (choices[i].checked) { choice = choices[i].value; }
}
rscore++;
if (choice == questions[posn][6] && timelimit > 0) { correct++; }
pos++; posn = questionOrder[pos];
if (pos < totalQuetions) { renderQuestion(); } else { renderResults(); }
}
window.onload = function() {
setQuestionOrder();
renderQuestion();
}
</script>
</body>
</html>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote