Combined Stress, Principal Stress, and Mohr’s Circle Quiz
Advertisements
Previous QuestionNext QuestionSubmit Quiz
//Question1
//Define Variables
var onesigmax, onesigmay, onetau
//Assigns Random Integers
onesigmax = (Math.floor(Math.random()*8)+1)*10
onesigmay = (Math.floor(Math.random()*8)+1)*10
onetau = (Math.floor(Math.random()*8)+1)*10
//find principal stresses
onecenter = (onesigmax + onesigmay)/2;
oner = Math.sqrt(Math.pow((onesigmax-onesigmay)/2,2)+Math.pow(onetau,2));
onesigmaone = onecenter + oner;
onesigmatwo = onecenter - oner;
oner1 = Math.sqrt(Math.pow((onesigmax-onesigmay)/2,1)+Math.pow(onetau,1));
onesigmaone1 = onecenter + oner1;
onesigmatwo1 = onecenter - oner1;
oner2 = Math.sqrt(Math.pow((onesigmax+onesigmay)/2,2)+Math.pow(onetau,2));
onesigmaone2 = onecenter + oner2;
onesigmatwo2 = onecenter - oner2;
onecenter3 = (onesigmax - onesigmay)/2;
onesigmaone3 = onecenter3 + oner;
onesigmatwo3 = onecenter3 - oner;
//Answer Choices
onecorrectanswer = "\u03c3\u2081 = " + onesigmaone.toFixed(1).replace(/\.?0+$/,"").toString() + " ksi, \u03c3\u2082 = " + onesigmatwo.toFixed(1).replace(/\.?0+$/,"").toString() + " ksi"
oneanswer1 = "\u03c3\u2081 = " + onesigmaone1.toFixed(1).replace(/\.?0+$/,"").toString() + " ksi, \u03c3\u2082 = " + onesigmatwo1.toFixed(1).replace(/\.?0+$/,"").toString() + " ksi"
oneanswer2 = "\u03c3\u2081 = " + onesigmaone2.toFixed(1).replace(/\.?0+$/,"").toString() + " ksi, \u03c3\u2082 = " + onesigmatwo2.toFixed(1).replace(/\.?0+$/,"").toString() + " ksi"
oneanswer3 = "\u03c3\u2081 = " + onesigmaone3.toFixed(1).replace(/\.?0+$/,"").toString() + " ksi, \u03c3\u2082 = " + onesigmatwo3.toFixed(1).replace(/\.?0+$/,"").toString() + " ksi"
//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. Find the principal stresses for an element with \u03C3(x) = " + onesigmax.toString() + " ksi, \u03C3(y) = " + onesigmay.toString() + " ksi, and \u03C4(xy) = " + onetau.toString() + " ksi."
//Question2
//Define Variables
var twosigmax, twosigmay, twotau
//Assigns Random Integers
twosigmax = (Math.floor(Math.random()*8)+1)*10
twosigmay = (Math.floor(Math.random()*8)+1)*10
twotau = (Math.floor(Math.random()*8)+1)*10
//find max shear stress, and angle
twotaumax = Math.sqrt(Math.pow((twosigmax-twosigmay)/2,2)+Math.pow(twotau,2));
twotheta = 0.5*Math.atan((2*twotau)/(twosigmax-twosigmay))*180/Math.PI;
twotaumax1 = Math.sqrt(Math.pow((twosigmax-twosigmay)/2,2)+Math.pow(twotau,2));
twotheta1 = 0.5*Math.atan((2*twotau)/(twosigmax+twosigmay))*180/Math.PI;
twotaumax2 = Math.sqrt(Math.pow((twosigmax+twosigmay)/2,2)+Math.pow(twotau,2));
twotheta2 = 0.5*Math.atan((2*twotau)/(twosigmax-twosigmay))*180/Math.PI;
twotaumax3 = Math.sqrt(Math.pow((twosigmax+twosigmay)/2,2)+Math.pow(twotau,2));
twotheta3 = 0.5*Math.atan((2*twotau)/(twosigmax+twosigmay))*180/Math.PI;
//Answer Choices
//correct answer
twocorrectanswer = "\u03c4max = " + twotaumax.toFixed(3).replace(/\.?0+$/,"").toString() + " ksi, \u0398 = " + twotheta.toFixed(3).replace(/\.?0+$/,"").toString() + " degrees."
twoanswer1 = "\u03c4max = " + twotaumax1.toFixed(3).replace(/\.?0+$/,"").toString() + " ksi, \u0398 = " + twotheta1.toFixed(3).replace(/\.?0+$/,"").toString() + " degrees."
twoanswer2 = "\u03c4max = " + twotaumax2.toFixed(3).replace(/\.?0+$/,"").toString() + " ksi, \u0398 = " + twotheta2.toFixed(3).replace(/\.?0+$/,"").toString() + " degrees."
twoanswer3 = "\u03c4max = " + twotaumax3.toFixed(3).replace(/\.?0+$/,"").toString() + " ksi, \u0398 = " + twotheta3.toFixed(3).replace(/\.?0+$/,"").toString() + " degrees."
//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. Find the the maximum shear stress, and angle of the plane on which the principal acts for an element with \u03C3(x) = " + twosigmax.toString() + " ksi, \u03C3(y) = " + twosigmay.toString() + " ksi, and \u03C4(xy) = " + twotau.toString() + " ksi."
//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
}
];
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.