Previous Question
Next Question
Submit Quiz
//Question1
//Define Variables
var onex1, onex2, oney1, oney2
do { //Eliminates Slope = 1, -1
//Assigns Random Integers
onex1 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
onex2 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
oney1 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
oney2 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
//Eliminates Vertical and Horizontal Lines
if (onex1 == onex2 || oney1 == oney2) {
do {
onex1 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
onex2 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
oney1 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
oney2 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
}
while (onex1 == onex2 || oney1 == oney2);
}
//Find Slope
onerise = (oney2 - oney1);
onerun = (onex2 - onex1);
onem = onerise/onerun;
}
while (onem == 1 || onem == -1);
//Answer Choices
onecorrectanswer = onem.toFixed(3).replace(/\.?0+$/,"").toString();
oneanswer1 = (1/onem).toFixed(3).replace(/\.?0+$/,"").toString();
oneanswer2 = (-1*onem).toFixed(3).replace(/\.?0+$/,"").toString();
oneanswer3 = (-1/onem).toFixed(3).replace(/\.?0+$/,"").toString();
//Place Answer Choices into Array
oneanswerchoices = [oneanswer1, oneanswer2, oneanswer3, onecorrectanswer];
//Randomize Answer Choices
do {
var indexa = Math.floor(Math.random()*oneanswerchoices.length);
var indexb = Math.floor(Math.random()*oneanswerchoices.length);
}
while (indexb == indexa);
do {
var indexc = Math.floor(Math.random()*oneanswerchoices.length);
}
while (indexc == indexa || indexc == indexb);
do {
var indexd = Math.floor(Math.random()*oneanswerchoices.length);
}
while (indexd == indexa || indexd == indexb ||
indexd == indexc);
onea = oneanswerchoices[indexa];
oneb = oneanswerchoices[indexb];
onec = oneanswerchoices[indexc];
oned = oneanswerchoices[indexd];
if (indexa == 3) {
onecorrectchoice = "a"
}
if (indexb == 3) {
onecorrectchoice = "b"
}
if (indexc == 3) {
onecorrectchoice = "c"
}
if (indexd == 3) {
onecorrectchoice = "d"
}
question1 = "1. Find the slope of a line that passes through the points (" + onex1.toString() + "," + oney1.toString() + ") and (" + onex2.toString() + "," + oney2.toString() + ")."
//Question2
//Define Variables
var twox1, twoy1, twom, twomperp, twobint, twobintperp
//Assigns Random Integers
twox1 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
twoy1 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
twobint = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
do {
twom = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
}
while (twom == 0 || twom == 1 || twom == -1);
twomperp = (-1/twom);
twobintperp = ((-1)*twomperp*twox1)+twoy1;
//Answer Choices
if (twobintperp < 0) {
twocorrectanswer = "y = " + twomperp.toFixed(3).replace(/\.?0+$/,"").toString() + "x" + twobintperp.toFixed(3).replace(/\.?0+$/,"").toString();
}
else if (twobintperp == 0) {
twocorrectanswer = "y = " + twomperp.toFixed(3).replace(/\.?0+$/,"").toString() + "x";
}
else {
twocorrectanswer = "y = " + twomperp.toFixed(3).replace(/\.?0+$/,"").toString() + "x+" + twobintperp.toFixed(3).replace(/\.?0+$/,"").toString();
}
if ((-1/twomperp)*twox1+twoy1 < 0) {
twoanswer1 = "y = " + (1/twomperp).toFixed(3).replace(/\.?0+$/,"").toString() + "x" + ((-1/twomperp)*twox1+twoy1).toFixed(3).replace(/\.?0+$/,"").toString();
}
else if ((-1/twomperp)*twox1+twoy1 == 0) {
twoanswer1 = "y = " + twomperp.toFixed(3).replace(/\.?0+$/,"").toString() + "x";
}
else {
twoanswer1 = "y = " + (1/twomperp).toFixed(3).replace(/\.?0+$/,"").toString() + "x+" + ((-1/twomperp)*twox1+twoy1).toFixed(3).replace(/\.?0+$/,"").toString();
}
if ((1/twomperp)*twox1+twoy1 < 0) {
twoanswer2 = "y = " + (-1/twomperp).toFixed(3).replace(/\.?0+$/,"").toString() + "x" + ((1/twomperp)*twox1+twoy1).toFixed(3).replace(/\.?0+$/,"").toString();
}
else if ((1/twomperp)*twox1+twoy1 == 0) {
twoanswer2 = "y = " + twomperp.toFixed(3).replace(/\.?0+$/,"").toString() + "x";
}
else {
twoanswer2 = "y = " + (-1/twomperp).toFixed(3).replace(/\.?0+$/,"").toString() + "x+" + ((1/twomperp)*twox1+twoy1).toFixed(3).replace(/\.?0+$/,"").toString();
}
if (twomperp*twox1+twoy1 < 0) {
twoanswer3 = "y = " + (-1*twomperp).toFixed(3).replace(/\.?0+$/,"").toString() + "x" + (twomperp*twox1+twoy1).toFixed(3).replace(/\.?0+$/,"").toString();
}
else if (twomperp*twox1+twoy1 == 0) {
twoanswer3 = "y = " + twomperp.toFixed(3).replace(/\.?0+$/,"").toString() + "x";
}
else {
twoanswer3 = "y = " + (-1*twomperp).toFixed(3).replace(/\.?0+$/,"").toString() + "x+" + (twomperp*twox1+twoy1).toFixed(3).replace(/\.?0+$/,"").toString();
}
//Place Answer Choices into Array
twoanswerchoices = [twoanswer1, twoanswer2, twoanswer3, twocorrectanswer];
//Randomize Answer Choices
do {
var indexa = Math.floor(Math.random()*twoanswerchoices.length);
var indexb = Math.floor(Math.random()*twoanswerchoices.length);
}
while (indexb == indexa);
do {
var indexc = Math.floor(Math.random()*twoanswerchoices.length);
}
while (indexc == indexa || indexc == indexb);
do {
var indexd = Math.floor(Math.random()*twoanswerchoices.length);
}
while (indexd == indexa || indexd == indexb ||
indexd == indexc);
twoa = twoanswerchoices[indexa];
twob = twoanswerchoices[indexb];
twoc = twoanswerchoices[indexc];
twod = twoanswerchoices[indexd];
if (indexa == 3) {
twocorrectchoice = "a"
}
if (indexb == 3) {
twocorrectchoice = "b"
}
if (indexc == 3) {
twocorrectchoice = "c"
}
if (indexd == 3) {
twocorrectchoice = "d"
}
//Question 2 Question
if (twobint > 0) {
question2 = "2. What is the equation of the line that passes through the point (" + twox1.toString() + "," + twoy1.toString() + ") and is perpendicular to the line y =" + twom.toString() + "x+" + twobint.toString() + "?"
}
else if (twobint == 0) {
question2 = "2. What is the equation of the line that passes through the point (" + twox1.toString() + "," + twoy1.toString() + ") and is perpendicular to the line y =" + twom.toString() + "x?"
}
else {
question2 = "2. What is the equation of the line that passes through the point (" + twox1.toString() + "," + twoy1.toString() + ") and is perpendicular to the line y =" + twom.toString() + "x" + twobint.toString() + "?"
}
//Question3
//define variables
var threex1, threey1, threec1
//Assign Random Integers
do {
threex1 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
}
while (threex1 == 0);
do {
threey1 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
}
while (threey1 == 0);
threec1 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
//Find Slope and y-intercept
threem = -threex1/threey1;
threebint = threec1/threey1;
//Answer Choices
threecorrectanswer = "m=" + threem.toFixed(3).replace(/\.?0+$/,"").toString() + ", b=" + threebint.toFixed(3).replace(/\.?0+$/,"").toString();
threeanswer1 = "m=" + -threem.toFixed(3).replace(/\.?0+$/,"").toString() + ", b=" + threebint.toFixed(3).replace(/\.?0+$/,"").toString();
threeanswer2 = "m=" + -threem.toFixed(3).replace(/\.?0+$/,"").toString() + ", b=" + -threebint.toFixed(3).replace(/\.?0+$/,"").toString();
threeanswer3 = "m=" + threem.toFixed(3).replace(/\.?0+$/,"").toString() + ", b=" + -threebint.toFixed(3).replace(/\.?0+$/,"").toString();
//Place Answer Choices into Array
threeanswerchoices = [threeanswer1, threeanswer2, threeanswer3, threecorrectanswer];
//Randomize Answer Choices
do {
var indexa = Math.floor(Math.random()*threeanswerchoices.length);
var indexb = Math.floor(Math.random()*threeanswerchoices.length);
}
while (indexb == indexa);
do {
var indexc = Math.floor(Math.random()*threeanswerchoices.length);
}
while (indexc == indexa || indexc == indexb);
do {
var indexd = Math.floor(Math.random()*threeanswerchoices.length);
}
while (indexd == indexa || indexd == indexb ||
indexd == indexc);
threea = threeanswerchoices[indexa];
threeb = threeanswerchoices[indexb];
threec = threeanswerchoices[indexc];
threed = threeanswerchoices[indexd];
if (indexa == 3) {
threecorrectchoice = "a"
}
if (indexb == 3) {
threecorrectchoice = "b"
}
if (indexc == 3) {
threecorrectchoice = "c"
}
if (indexd == 3) {
threecorrectchoice = "d"
}
//Question 3 Question
if (threex1 > 0) {
question3 = "3. Given the Equation " + threey1.toString() + "y+" + threex1.toString() + "x=" + threec1.toString() + ", identify the slope and y-intercept."
}
else{
question3 = "3. Given the Equation " + threey1.toString() + "y" + threex1.toString() + "x=" + threec1.toString() + ", identify the slope and y-intercept."
}
//Qestion4
//define variables
var fourxint, fouryint, fourx1, foury1
//Assign Random Integers
do {
fourxint = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
fouryint = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
fourx1 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
foury1 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
c1a = -fourx1*fourxint;
c1b = -foury1*fouryint;
fourc1 = -fourx1*fourxint;
}
while (fourxint ==0 || fouryint == 0 || fourx1 == 0 || foury1 ==0 || c1a != c1b);
//Answer Choices
//CorrectAnswer
if (fourx1 > 0 && fourc1 > 0) {
fourcorrectanswer = foury1.toString() + "y+" + fourx1.toString() + "x+" + fourc1.toString() + "=0";
}
else if (fourx1 < 0 && fourc1 > 0) {
fourcorrectanswer = foury1.toString() + "y" + fourx1.toString() + "x+" + fourc1.toString() + "=0";
}
else if (fourx1 > 0 && fourc1 < 0) {
fourcorrectanswer = foury1.toString() + "y+" + fourx1.toString() + "x" + fourc1.toString() + "=0";
}
else {
fourcorrectanswer = foury1.toString() + "y" + fourx1.toString() + "x" + fourc1.toString() + "=0";
}
//Answer1
if (-fourx1 > 0 && fourc1 > 0) {
fouranswer1 = (-foury1).toString() + "y+" + (-fourx1).toString() + "x+" + fourc1.toString() + "=0";
}
else if (-fourx1 < 0 && fourc1 > 0) {
fouranswer1 = (-foury1).toString() + "y" + (-fourx1).toString() + "x+" + fourc1.toString() + "=0";
}
else if (-fourx1 > 0 && fourc1 < 0) {
fouranswer1 = f(-foury1).toString() + "y+" + (-fourx1).toString() + "x" + fourc1.toString() + "=0";
}
else {
fouranswer1 = (-foury1).toString() + "y" + (-fourx1).toString() + "x" + fourc1.toString() + "=0";
}
//Answer2
if (foury1 > 0 && -fourc1 > 0) {
fouranswer2 = fourx1.toString() + "y+" + foury1.toString() + "x+" + (-fourc1).toString() + "=0";
}
else if (foury1 < 0 && -fourc1 > 0) {
fouranswer2 = fourx1.toString() + "y" + foury1.toString() + "x+" + (-fourc1).toString() + "=0";
}
else if (foury1 > 0 && -fourc1 < 0) {
fouranswer2 = fourx1.toString() + "y+" + foury1.toString() + "x" + (-fourc1).toString() + "=0";
}
else {
fouranswer2 = fourx1.toString() + "y" + foury1.toString() + "x" + (-fourc1).toString() + "=0";
}
//Answer3
if (-foury1 > 0 && -fourc1 > 0) {
fouranswer3 = (-fourx1).toString() + "y+" + (-foury1).toString() + "x+" + (-fourc1).toString() + "=0";
}
else if (-foury1 < 0 && -fourc1 > 0) {
fouranswer3 = (-fourx1).toString() + "y" + (-foury1).toString() + "x+" + (-fourc1).toString() + "=0";
}
else if (-foury1 > 0 && -fourc1 < 0) {
fouranswer3 = (-fourx1).toString() + "y+" + (-foury1).toString() + "x" + (-fourc1).toString() + "=0";
}
else {
fouranswer3 = (-fourx1).toString() + "y" + (-foury1).toString() + "x" + (-fourc1).toString() + "=0";
}
//Place Answer Choices into Array
fouranswerchoices = [fouranswer1, fouranswer2, fouranswer3, fourcorrectanswer];
//Randomize Answer Choices
do {
var indexa = Math.floor(Math.random()*fouranswerchoices.length);
var indexb = Math.floor(Math.random()*fouranswerchoices.length);
}
while (indexb == indexa);
do {
var indexc = Math.floor(Math.random()*fouranswerchoices.length);
}
while (indexc == indexa || indexc == indexb);
do {
var indexd = Math.floor(Math.random()*fouranswerchoices.length);
}
while (indexd == indexa || indexd == indexb ||
indexd == indexc);
foura = fouranswerchoices[indexa];
fourb = fouranswerchoices[indexb];
fourc = fouranswerchoices[indexc];
fourd = fouranswerchoices[indexd];
if (indexa == 3) {
fourcorrectchoice = "a"
}
if (indexb == 3) {
fourcorrectchoice = "b"
}
if (indexc == 3) {
fourcorrectchoice = "c"
}
if (indexd == 3) {
fourcorrectchoice = "d"
}
//Qeustion 4 Question
question4 = "4. Which of the following equatons has an x-intercept = " + fourxint.toString() + " and a y-intercept = " + fouryint.toString() + "?"
//Question5
//define variables
var fivex1, fivey1, fivex2, fivey2
//Get Random Integers
do {
fivex1 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
fivey1 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
fivex2 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
fivey2 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
//find slope
fivem = (fivey2 - fivey1)/(fivex2 - fivex1);
fivebint = -fivem*fivex1+fivey1;
}
while (fivem == 0 || fivem == 1 || fivem == -1 || fivebint == 0);
//Answer Choices
//CorrectAnswer
if (-fivem*fivex1+fivey1 > 0) {
fivecorrectanswer = "y=" + fivem.toFixed(3).replace(/\.?0+$/,"").toString() + "x+" + (-fivem*fivex1+fivey1).toFixed(3).replace(/\.?0+$/,"").toString();
}
else {
fivecorrectanswer = "y=" + fivem.toFixed(3).replace(/\.?0+$/,"").toString() + "x" + (-fivem*fivex1+fivey1).toFixed(3).replace(/\.?0+$/,"").toString();
}
//Answer1
if (fivem*fivex1+fivey1 > 0) {
fiveanswer1 = "y=" + fivem.toFixed(3).replace(/\.?0+$/,"").toString() + "x+" + (fivem*fivex1+fivey1).toFixed(3).replace(/\.?0+$/,"").toString();
}
else {
fiveanswer1 = "y=" + fivem.toFixed(3).replace(/\.?0+$/,"").toString() + "x" + (fivem*fivex1+fivey1).toFixed(3).replace(/\.?0+$/,"").toString();
}
//answer2
if (fivem*fivex1+fivey1 > 0) {
fiveanswer2 = "y=" + (-fivem).toFixed(3).replace(/\.?0+$/,"").toString() + "x+" + (fivem*fivex1+fivey1).toFixed(3).replace(/\.?0+$/,"").toString();
}
else {
fiveanswer2 = "y=" + (-fivem).toFixed(3).replace(/\.?0+$/,"").toString() + "x" + (fivem*fivex1+fivey1).toFixed(3).replace(/\.?0+$/,"").toString();
}
//answer3
if (-1/fivem*fivex1+fivey1 > 0) {
fiveanswer3 = "y=" + (1/fivem).toFixed(3).replace(/\.?0+$/,"").toString() + "x+" + (-1/fivem*fivex1+fivey1).toFixed(3).replace(/\.?0+$/,"").toString();
}
else {
fiveanswer3 = "y=" + (1/fivem).toFixed(3).replace(/\.?0+$/,"").toString() + "x+" + (-1/fivem*fivex1+fivey1).toFixed(3).replace(/\.?0+$/,"").toString();
}
//Place Answers into Array
fiveanswerchoices = [fiveanswer1, fiveanswer2,fiveanswer3, fivecorrectanswer];
//Randomize Answer Choices
do {
var indexa = Math.floor(Math.random()*fiveanswerchoices.length);
var indexb = Math.floor(Math.random()*fiveanswerchoices.length);
}
while (indexb == indexa);
do {
var indexc = Math.floor(Math.random()*fiveanswerchoices.length);
}
while (indexc == indexa || indexc == indexb);
do {
var indexd = Math.floor(Math.random()*fiveanswerchoices.length);
}
while (indexd == indexa || indexd == indexb ||
indexd == indexc);
fivea = fiveanswerchoices[indexa];
fiveb = fiveanswerchoices[indexb];
fivec = fiveanswerchoices[indexc];
fived = fiveanswerchoices[indexd];
if (indexa == 3) {
fivecorrectchoice = "a"
}
if (indexb == 3) {
fivecorrectchoice = "b"
}
if (indexc == 3) {
fivecorrectchoice = "c"
}
if (indexd == 3) {
fivecorrectchoice = "d"
}
//Question 5 Question
question5 = "5. Write an equation for a line that passes through the points (" + fivex1.toString() + "," + fivey1.toString() + ") and (" + fivex2.toString() + "," + fivey2.toString() + ")."
//Question6
//define variables
var sixx1, sixy1, sixz1, sixx2, sixy2, sixz2
//Assign Random Variables
do {
sixx1 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
sixy1 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
sixz1 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
sixx2 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
sixy2 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
sixz2 = Math.floor(Math.random()*11) - Math.floor(Math.random()*11);
}
while (sixx1 == sixx2 || sixy1 == sixy2 || sixz1 == sixz2);
//Find Distance
sixxdist = (sixx2-sixx1)*(sixx2-sixx1);
sixydist = (sixy2-sixy1)*(sixy2-sixy1);
sixzdist = (sixz2-sixz1)*(sixz2-sixz1);
sixdist = Math.sqrt(sixxdist+sixydist+sixzdist);
sixdist1 = Math.sqrt(Math.abs(sixxdist-sixydist-sixzdist));
sixdist2 = Math.sqrt(sixxdist) + Math.sqrt(sixydist) + Math.sqrt(sixzdist);
sixdist3 = (sixxdist+sixydist+sixzdist)/2;
//Answer Choices
sixcorrectanswer = "distance = " + sixdist.toFixed(3).replace(/\.?0+$/,"").toString();
sixanswer1 = "distance = " + sixdist1.toFixed(3).replace(/\.?0+$/,"").toString();
sixanswer2 = "distance = " + sixdist2.toFixed(3).replace(/\.?0+$/,"").toString();
sixanswer3 = "distance = " + sixdist3.toFixed(3).replace(/\.?0+$/,"").toString();
//Place answers into Array
sixanswerchoices = [sixanswer1, sixanswer2, sixanswer3, sixcorrectanswer];
//Randomize Answer Choices
do {
var indexa = Math.floor(Math.random()*sixanswerchoices.length);
var indexb = Math.floor(Math.random()*sixanswerchoices.length);
}
while (indexb == indexa);
do {
var indexc = Math.floor(Math.random()*sixanswerchoices.length);
}
while (indexc == indexa || indexc == indexb);
do {
var indexd = Math.floor(Math.random()*sixanswerchoices.length);
}
while (indexd == indexa || indexd == indexb ||
indexd == indexc);
sixa = sixanswerchoices[indexa];
sixb = sixanswerchoices[indexb];
sixc = sixanswerchoices[indexc];
sixd = sixanswerchoices[indexd];
if (indexa == 3) {
sixcorrectchoice = "a"
}
if (indexb == 3) {
sixcorrectchoice = "b"
}
if (indexc == 3) {
sixcorrectchoice = "c"
}
if (indexd == 3) {
sixcorrectchoice = "d"
}
//Question 6 Question
question6 = "6. Find the distance between the points (" + sixx1.toString() + "," + sixy1.toString() + "," + sixz1.toString() + ") and (" + sixx2.toString() + "," + sixy2.toString() + "," + sixz2.toString() + ")."
//Question7
//define variables
var sevendeg1, sevenrad1
//Assign Random Values
sevendeg1 = Math.floor(Math.random()*361)+1;
sevenrad1 = Math.floor(Math.random()*7)+1 - Math.random();
//Conversion
sevenrad = sevendeg1*Math.PI/180;
sevendeg = sevenrad1*180/Math.PI;
//AnswerChoices
sevencorrectanswer = sevenrad.toFixed(3).toString() + " radians, " + sevendeg.toFixed(0).toString() + " degrees"
sevenanswer1 = (sevendeg1*Math.PI/360).toFixed(3).toString() + " radians, " + (sevenrad1/Math.PI*360).toFixed(0).toString() + " degrees"
sevenanswer2 = (sevenrad1*Math.PI/360).toFixed(3).toString() + " radians, " + (sevenrad1/Math.PI*270).toFixed(0).toString() + " degrees"
sevenanswer3 = (sevendeg1*Math.PI/90).toFixed(3).toString() + " radians, " + (sevenrad1*90/Math.PI).toFixed(0).toString() + " degrees"
//Place answers into Array
sevenanswerchoices = [sevenanswer1, sevenanswer2, sevenanswer3, sevencorrectanswer];
//Randomize Answer Choices
do {
var indexa = Math.floor(Math.random()*sevenanswerchoices.length);
var indexb = Math.floor(Math.random()*sevenanswerchoices.length);
}
while (indexb == indexa);
do {
var indexc = Math.floor(Math.random()*sevenanswerchoices.length);
}
while (indexc == indexa || indexc == indexb);
do {
var indexd = Math.floor(Math.random()*sevenanswerchoices.length);
}
while (indexd == indexa || indexd == indexb ||
indexd == indexc);
sevena = sevenanswerchoices[indexa];
sevenb = sevenanswerchoices[indexb];
sevenc = sevenanswerchoices[indexc];
sevend = sevenanswerchoices[indexd];
if (indexa == 3) {
sevencorrectchoice = "a"
}
if (indexb == 3) {
sevencorrectchoice = "b"
}
if (indexc == 3) {
sevencorrectchoice = "c"
}
if (indexd == 3) {
sevencorrectchoice = "d"
}
//Question 7 Question
question7 = "7. Convert " + sevendeg1.toString() + " degrees to radians and " + sevenrad1.toFixed(3).toString() + " to degrees."
//Question8
//define variables
var eighta1, eighta2, eightb1
//Assign Random Integers
eighta1 = Math.floor(Math.random()*26)+1;
eighta2 = Math.floor(Math.random()*26)+1;
eightb1 = Math.floor(Math.random()*16)+1;
//find missing side
eightb2 = eighta2*eightb1/eighta1;
//Answer Choices
eightcorrectanswer = "b2 = " + eightb2.toFixed(3).replace(/\.?0+$/,"").toString();
eightanswer1 = "b2 = " + (eighta1*eightb1/eighta2).toFixed(3).replace(/\.?0+$/,"").toString();
eightanswer2 = "b2 = " + (eighta1*eighta2/eightb1).toFixed(3).replace(/\.?0+$/,"").toString();
eightanswer3 = "b2 = " + (eighta1*eightb1/2).toFixed(3).replace(/\.?0+$/,"").toString();
//Place answers into Array
eightanswerchoices = [eightanswer1, eightanswer2, eightanswer3, eightcorrectanswer];
//Randomize Answer Choices
do {
var indexa = Math.floor(Math.random()*eightanswerchoices.length);
var indexb = Math.floor(Math.random()*eightanswerchoices.length);
}
while (indexb == indexa);
do {
var indexc = Math.floor(Math.random()*eightanswerchoices.length);
}
while (indexc == indexa || indexc == indexb);
do {
var indexd = Math.floor(Math.random()*eightanswerchoices.length);
}
while (indexd == indexa || indexd == indexb ||
indexd == indexc);
eighta = eightanswerchoices[indexa];
eightb = eightanswerchoices[indexb];
eightc = eightanswerchoices[indexc];
eightd = eightanswerchoices[indexd];
if (indexa == 3) {
eightcorrectchoice = "a"
}
if (indexb == 3) {
eightcorrectchoice = "b"
}
if (indexc == 3) {
eightcorrectchoice = "c"
}
if (indexd == 3) {
eightcorrectchoice = "d"
}
//Question 8 Question
question8 = "8. Use the two triangles shown below this quiz to solve for b2 where a1 = " + eighta1.toString() + ", b1 = " + eightb1.toString() + ", a2 = " + eighta2.toString() + ".";
//Question9
//define variables
var ninea1, nineb1, ninec2
//Assign Random Integers
ninea1 = Math.floor(Math.random()*26)+7;
nineb1 = Math.floor(Math.random()*16)+1;
ninec2 = Math.floor(Math.random()*121)+20;
//Find c1
ninec1 = Math.sqrt((ninea1*ninea1)+(nineb1*nineb1)-(2*ninea1*nineb1*Math.cos(ninec2*Math.PI/180)));
//Answer Choices
ninecorrectanswer = ninec1.toFixed(3).replace(/\.?0+$/,"").toString();
nineanswer1 = (Math.hypot(ninea1,nineb1)).toFixed(3).replace(/\.?0+$/,"").toString();
nineanswer2 = (ninea1/Math.cos(ninec2*Math.PI/180)).toFixed(3).replace(/\.?0+$/,"").toString();
nineanswer3 = (nineb1/Math.cos(ninec2*Math.PI/180)).toFixed(3).replace(/\.?0+$/,"").toString();
//Place answers into Array
nineanswerchoices = [nineanswer1, nineanswer2, nineanswer3, ninecorrectanswer];
//Randomize Answer Choices
do {
var indexa = Math.floor(Math.random()*nineanswerchoices.length);
var indexb = Math.floor(Math.random()*nineanswerchoices.length);
}
while (indexb == indexa);
do {
var indexc = Math.floor(Math.random()*nineanswerchoices.length);
}
while (indexc == indexa || indexc == indexb);
do {
var indexd = Math.floor(Math.random()*nineanswerchoices.length);
}
while (indexd == indexa || indexd == indexb ||
indexd == indexc);
ninea = nineanswerchoices[indexa];
nineb = nineanswerchoices[indexb];
ninec = nineanswerchoices[indexc];
nined = nineanswerchoices[indexd];
if (indexa == 3) {
ninecorrectchoice = "a"
}
if (indexb == 3) {
ninecorrectchoice = "b"
}
if (indexc == 3) {
ninecorrectchoice = "c"
}
if (indexd == 3) {
ninecorrectchoice = "d"
}
//Question 9 Question
question9 = "9. Find the missing side of the triangle shown belew this quiz where a = " + ninea1.toString() + " and b = " + nineb1.toString() + " and C = " + ninec2.toString() + " degrees.";
//Question10
//define variables
var tenb1, tenb2, tenc2
//Assign Random Variables
tenb1 = Math.floor(Math.random()*26)+1;
tenb2 = Math.floor(Math.random()*101)+15;
tenc2 = Math.floor(Math.random()*51)+10;
//find c1
tenc1 = tenb1*Math.sin(tenc2*Math.PI/180)/Math.sin(tenb2*Math.PI/180);
//Answer Choices
tencorrectanswer = tenc1.toFixed(3).replace(/\.?0+$/,"").toString();
tenanswer1 = (tenb1/Math.tan(tenb2*Math.PI/180)).toFixed(3).replace(/\.?0+$/,"").toString();
tenanswer2 = (tenb1*Math.tan(tenc2*Math.PI/180)).toFixed(3).replace(/\.?0+$/,"").toString();
tenanswer3 = (tenb1/Math.cos(tenb2*Math.PI/180)).toFixed(3).replace(/\.?0+$/,"").toString();
//Place Answers into Array
tenanswerchoices = [tenanswer1, tenanswer2, tenanswer3, tencorrectanswer];
//Randomize Answer Choices
do {
var indexa = Math.floor(Math.random()*tenanswerchoices.length);
var indexb = Math.floor(Math.random()*tenanswerchoices.length);
}
while (indexb == indexa);
do {
var indexc = Math.floor(Math.random()*tenanswerchoices.length);
}
while (indexc == indexa || indexc == indexb);
do {
var indexd = Math.floor(Math.random()*tenanswerchoices.length);
}
while (indexd == indexa || indexd == indexb ||
indexd == indexc);
tena = tenanswerchoices[indexa];
tenb = tenanswerchoices[indexb];
tenc = tenanswerchoices[indexc];
tend = tenanswerchoices[indexd];
if (indexa == 3) {
tencorrectchoice = "a"
}
if (indexb == 3) {
tencorrectchoice = "b"
}
if (indexc == 3) {
tencorrectchoice = "c"
}
if (indexd == 3) {
tencorrectchoice = "d"
}
//Question 10 Question
question10 = "10. Find the missing side of the triangle shown below this quiz where b = " + tenb1.toString() + ", B = " + tenb2.toString() + " degrees and C = " + tenc2.toString() + " degrees.";
//Question11
//define variables
var elevena1, elevenb1
//Assign Random Integers
elevena1 = Math.floor(Math.random()*11)+1;
elevenb1 = Math.floor(Math.random()*11)+1;
//Find c1
elevenc1 = Math.hypot(elevena1,elevenb1);
//Answer Choices
elevencorrectanswer = elevenc1.toFixed(3).replace(/\.?0+$/,"").toString();
elevenanswer1 = (Math.abs((elevena1*elevena1)-(elevenb1*elevenb1))).toFixed(3).replace(/\.?0+$/,"").toString();
elevenanswer2 = (Math.sqrt((elevena1*elevena1))+Math.sqrt((elevenb1*elevenb1))).toFixed(3).replace(/\.?0+$/,"").toString();
elevenanswer3 = (Math.sqrt(Math.abs((elevena1*elevena1)-(elevenb1*elevenb1)))).toFixed(3).replace(/\.?0+$/,"").toString();
//Place Answers into Array
elevenanswerchoices = [elevenanswer1, elevenanswer2, elevenanswer3, elevencorrectanswer];
//Randomize Answer Choices
do {
var indexa = Math.floor(Math.random()*elevenanswerchoices.length);
var indexb = Math.floor(Math.random()*elevenanswerchoices.length);
}
while (indexb == indexa);
do {
var indexc = Math.floor(Math.random()*elevenanswerchoices.length);
}
while (indexc == indexa || indexc == indexb);
do {
var indexd = Math.floor(Math.random()*elevenanswerchoices.length);
}
while (indexd == indexa || indexd == indexb ||
indexd == indexc);
elevena = elevenanswerchoices[indexa];
elevenb = elevenanswerchoices[indexb];
elevenc = elevenanswerchoices[indexc];
elevend = elevenanswerchoices[indexd];
if (indexa == 3) {
elevencorrectchoice = "a"
}
if (indexb == 3) {
elevencorrectchoice = "b"
}
if (indexc == 3) {
elevencorrectchoice = "c"
}
if (indexd == 3) {
elevencorrectchoice = "d"
}
//Question 11 Question
question11 = "11. Find the missing side of the right triangle shown below this quiz where a = " + elevena1.toString() + " and b = " + elevenb1.toString();
//Question12
//define variables
var twelvea1, twelveb2
//Assign Random Integers
twelvea1 = Math.floor(Math.random()*11)+1;
twelveb2 = Math.floor(Math.random()*61)+1;
//find b1
twelveb1 = twelvea1*Math.tan(twelveb2*Math.PI/180);
//Answer Choices
twelvecorrectanswer = twelveb1.toFixed(3).replace(/\.?0+$/,"").toString();
twelveanswer1 = (twelvea1/Math.tan(twelveb2*Math.PI/180)).toFixed(3).replace(/\.?0+$/,"").toString();
twelveanswer2 = (twelvea1*Math.cos(twelveb2*Math.PI/180)).toFixed(3).replace(/\.?0+$/,"").toString();
twelveanswer3 = (twelvea1*Math.sin(twelveb2*Math.PI/180)).toFixed(3).replace(/\.?0+$/,"").toString();
//Place Answers into Array
twelveanswerchoices = [twelveanswer1, twelveanswer2, twelveanswer3, twelvecorrectanswer];
//Randomize Answer Choices
do {
var indexa = Math.floor(Math.random()*twelveanswerchoices.length);
var indexb = Math.floor(Math.random()*twelveanswerchoices.length);
}
while (indexb == indexa);
do {
var indexc = Math.floor(Math.random()*twelveanswerchoices.length);
}
while (indexc == indexa || indexc == indexb);
do {
var indexd = Math.floor(Math.random()*twelveanswerchoices.length);
}
while (indexd == indexa || indexd == indexb ||
indexd == indexc);
twelvea = twelveanswerchoices[indexa];
twelveb = twelveanswerchoices[indexb];
twelvec = twelveanswerchoices[indexc];
twelved = twelveanswerchoices[indexd];
if (indexa == 3) {
twelvecorrectchoice = "a"
}
if (indexb == 3) {
twelvecorrectchoice = "b"
}
if (indexc == 3) {
twelvecorrectchoice = "c"
}
if (indexd == 3) {
twelvecorrectchoice = "d"
}
//Qeustion 12 Question
question12 = "12. Find the missing side of the right triangle shown below this quiz where a = " + twelvea1.toString() + " and B = " + twelveb2.toString() + " degrees.";
//Question Slides
const myQuestions = [
{
question: question1,
answers: {
a: onea,
b: oneb,
c: onec,
d: oned
},
correctAnswer: onecorrectchoice
},
{
question: question2,
answers: {
a: twoa,
b: twob,
c: twoc,
d: twod
},
correctAnswer: twocorrectchoice
},
{
question: question3,
answers: {
a: threea,
b: threeb,
c: threec,
d: threed
},
correctAnswer: threecorrectchoice
},
{
question: question4,
answers: {
a: foura,
b: fourb,
c: fourc,
d: fourd
},
correctAnswer: fourcorrectchoice
},
{
question: question5,
answers: {
a: fivea,
b: fiveb,
c: fivec,
d: fived
},
correctAnswer: fivecorrectchoice
},
{
question: question6,
answers: {
a: sixa,
b: sixb,
c: sixc,
d: sixd
},
correctAnswer: sixcorrectchoice
},
{
question: question7,
answers: {
a: sevena,
b: sevenb,
c: sevenc,
d: sevend
},
correctAnswer: sevencorrectchoice
},
{
question: question8,
answers: {
a: eighta,
b: eightb,
c: eightc,
d: eightd
},
correctAnswer: eightcorrectchoice
},
{
question: question9,
answers: {
a: ninea,
b: nineb,
c: ninec,
d: nined
},
correctAnswer: ninecorrectchoice
},
{
question: question10,
answers: {
a: tena,
b: tenb,
c: tenc,
d: tend
},
correctAnswer: tencorrectchoice
},
{
question: question11,
answers: {
a: elevena,
b: elevenb,
c: elevenc,
d: elevend
},
correctAnswer: elevencorrectchoice
},
{
question: question12,
answers: {
a: twelvea,
b: twelveb,
c: twelvec,
d: twelved
},
correctAnswer: twelvecorrectchoice
}
];
function buildQuiz() {
// we'll need a place to store the HTML output
const output = [];
// for each question...
myQuestions.forEach((currentQuestion, questionNumber) => {
// we'll want to store the list of answer choices
const answers = [];
// and for each available answer...
for (letter in currentQuestion.answers) {
// ...add an HTML radio button
answers.push(
`
${letter} :
${currentQuestion.answers[letter]}
`
);
}
// add this question and its answers to the output
output.push(
`
${currentQuestion.question}
${answers.join("")}
`
);
});
// finally combine our output list into one string of HTML and put it on the page
quizContainer.innerHTML = output.join("");
}
function showResults() {
// gather answer containers from our quiz
const answerContainers = quizContainer.querySelectorAll(".answers");
// keep track of user's answers
let numCorrect = 0;
// for each question...
myQuestions.forEach((currentQuestion, questionNumber) => {
// find selected answer
const answerContainer = answerContainers[questionNumber];
const selector = `input[name=question${questionNumber}]:checked`;
const userAnswer = (answerContainer.querySelector(selector) || {}).value;
// if answer is correct
if (userAnswer === currentQuestion.correctAnswer) {
// add to the number of correct answers
numCorrect++;
// color the answers green
answerContainers[questionNumber].style.color = "green";
} else {
// if answer is wrong or blank
// color the answers red
answerContainers[questionNumber].style.color = "red";
}
});
// show number of correct answers out of total
resultsContainer.innerHTML = `${numCorrect} out of ${myQuestions.length}`;
}
function showSlide(n) {
slides[currentSlide].classList.remove("active-slide");
slides[n].classList.add("active-slide");
currentSlide = n;
if (currentSlide === 0) {
previousButton.style.display = "none";
} else {
previousButton.style.display = "inline-block";
}
if (currentSlide === slides.length - 1) {
nextButton.style.display = "none";
submitButton.style.display = "inline-block";
} else {
nextButton.style.display = "inline-block";
submitButton.style.display = "inline-block";
}
}
function showNextSlide() {
showSlide(currentSlide + 1);
}
function showPreviousSlide() {
showSlide(currentSlide - 1);
}
const quizContainer = document.getElementById("quiz");
const resultsContainer = document.getElementById("results");
const submitButton = document.getElementById("submit");
// display quiz right away
buildQuiz();
const previousButton = document.getElementById("previous");
const nextButton = document.getElementById("next");
const slides = document.querySelectorAll(".slide");
let currentSlide = 0;
showSlide(0);
// on submit, show results
submitButton.addEventListener("click", showResults);
previousButton.addEventListener("click", showPreviousSlide);
nextButton.addEventListener("click", showNextSlide);
Quiz Image
You must be logged in to post a comment.