Previous QuestionNext QuestionSubmit Quiz
//Question1
//Define Variables
var onem, onex, oney, onez
//Assigns Random Integers
onem = (Math.floor(Math.random()*10)+1)*5;
do {
onex = Math.floor(Math.random()*10)+1 - Math.floor(Math.random()*10)+1;
oney = Math.floor(Math.random()*10)+1 - Math.floor(Math.random()*10)+1;
onez = Math.floor(Math.random()*10)+1 - Math.floor(Math.random()*10)+1;
}
while (onex == 0 || oney == 0 || onez == 0);
//find momentum
onepx = onem*onex;
onepy = onem*oney;
onepz = onem*onez;
onepx1 = onem*-onex;
onepy1 = onem*oney;
onepz1 = onem*-onez;
onepx2 = onem*onex;
onepy2 = onem*-oney;
onepz2 = onem*onez;
onepx3 = onem*-onex;
onepy3 = onem*-oney;
onepz3 = onem*-onez;
//Answer Choices
onecorrectanswer = "<" + onepx.toString() + "," + onepy.toString() + "," + onepz.toString() + "> N-s"
oneanswer1 = "<" + onepx1.toString() + "," + onepy1.toString() + "," + onepz1.toString() + "> N-s"
oneanswer2 = "<" + onepx2.toString() + "," + onepy2.toString() + "," + onepz2.toString() + "> N-s"
oneanswer3 = "<" + onepx3.toString() + "," + onepy3.toString() + "," + onepz3.toString() + "> N-s"
//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"
}
//Qeustion 1 Question
question1 = "1. A " + onem.toString() + " kg object has a velocity of v = <" + onex.toString() + "," + oney.toString() + "," + onez.toString() + "> m/s. Find the object's momentum."
//Question2
//Define Variables
var twovi, twovf
//Assigns Random Integers
twovi = (Math.floor(Math.random()*5)+5)*5;
twovf = twovi - 5;
//find e
twoe = twovf/twovi;
twoe1 = twovi/twovf;
twoe2 = 1;
twoe3 = 0;
//Answer Choices
twocorrectanswer = twoe.toFixed(3).replace(/\.?0+$/,"").toString()
twoanswer1 = twoe1.toFixed(3).replace(/\.?0+$/,"").toString()
twoanswer2 = twoe2.toString()
twoanswer3 = twoe3.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
question2 = "2. A pool ball has a mass of 500 grams and is traveling at a rate of " + twovi.toString() + " m/s when it hits a wall. When it bounces off the wall it has a rate of " + twovf.toString() + " m/s. Find the coefficient of restitution."
//Question3
//Define Variables
var threem1, threem2, threev1, threev2
//Assigns Random Integers
threem1 = (Math.floor(Math.random()*5)+5)*5;
threem2 = (Math.floor(Math.random()*5)+5)*5;
threev1 = (Math.floor(Math.random()*3)+1)*5;
threev2 = -((Math.floor(Math.random()*3)+1)*5);
//find threevprime
threevprime = (threem1*threev1+threem2*threev2)/(threem1+threem2);
threevprime1 = (threem1*threev1-threem2*threev2)/(threem1+threem2);
threevprime2 = (-threem1*threev1+threem2*threev2)/(threem1+threem2);
threevprime3 = (-threem1*threev1+-threem2*threev2)/(threem1+threem2);
//Answer Choices
threecorrectanswer = threevprime.toFixed(3).replace(/\.?0+$/,"").toString() + " m/s"
threeanswer1 = threevprime1.toFixed(3).replace(/\.?0+$/,"").toString() + " m/s"
threeanswer2 = threevprime2.toFixed(3).replace(/\.?0+$/,"").toString() + " m/s"
threeanswer3 = threevprime3.toFixed(3).replace(/\.?0+$/,"").toString() + " m/s"
//Place Answer Choices into Array
threeanswerchoices = [threeanswer1, threeanswer2, threeanswer3, threecorrectanswer];
//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);
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
question3 = "3. A " + threem1.toString() + " kg block is traveling at a rate of " + threev1.toString() + " m/s to the right, when it collides with a " + threem2.toString() + " kg block traveling at a rate of " + -threev2.toString() + " m/s to the left. Determine the final velocity if system is perfectly inelastic. (+ Velocity is to the right)"
//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
}
];
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(
``
);
}
// 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);
Advertisements
error: Content is protected !!
Cookie Consent
We use cookies to improve your experience on our site. By using our site, you consent to cookies.
Registers a unique ID on mobile devices to enable tracking based on geographical GPS location.
1 day
VISITOR_INFO1_LIVE
Tries to estimate the users' bandwidth on pages with integrated YouTube videos. Also used for marketing
179 days
PREF
This cookie stores your preferences and other information, in particular preferred language, how many search results you wish to be shown on your page, and whether or not you wish to have Google’s SafeSearch filter turned on.
10 years from set/ update
YSC
Registers a unique ID to keep statistics of what videos from YouTube the user has seen.
Session
DEVICE_INFO
Used to detect if the visitor has accepted the marketing category in the cookie banner. This cookie is necessary for GDPR-compliance of the website.
179 days
LOGIN_INFO
This cookie is used to play YouTube videos embedded on the website.