Skip to content

Commit

Permalink
Merge pull request #2 from virtual-labs/testing
Browse files Browse the repository at this point in the history
Testing
  • Loading branch information
vaibhavkurhe27 authored Feb 10, 2021
2 parents 85d4c27 + c059b40 commit f16309e
Show file tree
Hide file tree
Showing 214 changed files with 174,996 additions and 198 deletions.
2 changes: 1 addition & 1 deletion experiment/aim.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
### Aim of the experiment
Design High/Low selector for interlocking in process industry
2 changes: 1 addition & 1 deletion experiment/experiment-name.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
## Experiment name
Design High/Low selector for interlocking in process industry
Binary file added experiment/images/img1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added experiment/images/img2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added experiment/images/img3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added experiment/images/img4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added experiment/images/img5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
242 changes: 152 additions & 90 deletions experiment/posttest.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,131 +5,193 @@
/////////////////////////////////////////////////////////////////////////////

(function() {
function buildQuiz() {
// we'll need a place to store the HTML output
const output = [];
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(
`<label>
<input type="radio" name="question${questionNumber}" value="${letter}">
${letter} :
${currentQuestion.answers[letter]}
</label>`
);
}

// add this question and its answers to the output
output.push(
`<div class="question"> ${currentQuestion.question} </div>
<div class="answers"> ${answers.join("")} </div>`
);
});

// 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 = "lightgreen";
} 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}`;
}

const quizContainer = document.getElementById("quiz");
const resultsContainer = document.getElementById("results");
const submitButton = document.getElementById("submit");


// 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(
`<label>
<input type="radio" name="question${questionNumber}" value="${letter}">
${letter} :
${currentQuestion.answers[letter]}
</label>`
);
}

// add this question and its answers to the output
output.push(
`<div class="question"> ${currentQuestion.question} </div>
<div class="answers"> ${answers.join("")} </div>`
);
});

// 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;
/////////////////////// Do not modify the above code ////////////////////////

// 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 = "lightgreen";
} 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}`;
}

const quizContainer = document.getElementById("quiz");
const resultsContainer = document.getElementById("results");
const submitButton = document.getElementById("submit");


/////////////////////////////////////////////////////////////////////////////
/////////////// Write the MCQ below in the exactly same described format ///////////////

/////////////////////// Do not modify the above code ////////////////////////

/////////////////////////////////////////////////////////////////////////////
const myQuestions = [
{
question: "A component which will compare the process parameter based on multiple sensors installed and pass Highest amongst all, to the regulatory device", ///// Write the question inside double quotes
answers: {
a: "High Selector", ///// Write the option 1 inside double quotes
b: "Low Selector", ///// Write the option 2 inside double quotes
c: "Rate Limiter", ///// Write the option 3 inside double quotes
d: "None of these" ///// Write the option 4 inside double quotes
},
correctAnswer: "a" ///// Write the correct option inside double quotes
},

{
question: "A component which will compare the process parameter based on multiple sensors installed and pass Lowest amongst all, to the regulatory device", ///// Write the question inside double quotes
answers: {
a: "Low Selector", ///// Write the option 1 inside double quotes
b: "High Selector", ///// Write the option 2 inside double quotes
c: "Rate Limiter", ///// Write the option 3 inside double quotes
d: "None of these" ///// Write the option 4 inside double quotes
},
correctAnswer: "a" ///// Write the correct option inside double quotes
}, ///// To add more questions, copy the section below
///// this line
{
question: "Number of inputs to high selector are",
answers: {
a: "Two or many",
b: "One",
c: "Either a or b",
d: "Both a and b"
},
correctAnswer: "a"
},

{
question: "Power supply used is",
answers: {
a: "5 VDC",
b: "10 VDC",
c: "24 VDC",
d: "12 VDC"
},
correctAnswer: "c"
},

{
question: "Limiter will have the inputs",
answers: {
a: "One",
b: "Two",
c: "Three",
d: "Four"
},
correctAnswer: "b"
},

/* To add more MCQ's, copy the below section, starting from open curly braces ( { )
till closing curly braces comma ( }, )
and paste it below the curly braces comma ( below correct answer }, ) of above
question
Copy below section
{
question: "This is question n?",
answers: {
a: "Option 1",
b: "Option 2",
c: "Option 3",
d: "Option 4"
},
correctAnswer: "c"
},
/////////////// Write the MCQ below in the exactly same described format ///////////////
Copy above section
*/

const myQuestions = [{
question: "1.This is a sample question:", ///// Write the question inside double quotes
answers: {
a: "This is a sample answer A", ///// Write the option 1 inside double quotes
b: "This is a sample answer B", ///// Write the option 2 inside double quotes
},
correctAnswer: "a" ///// Write the correct option inside double quotes
},

{
question: "<img src='images/8.PNG'><br>Identify the location of Secondary electron detector", ///// Write the question inside double quotes
answers: {
a: "<img src='images/1b.png'>", ///// Write the option 1 inside double quotes
b: "<img src='images/1a.png'>", ///// Write the option 2 inside double quotes
c: "<img src='images/1c.PNG'>", },
correctAnswer: "c" ///// Write the correct option inside double quotes
},



];
];




/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////

/////////////////////// Do not modify the below code ////////////////////////
/////////////////////// Do not modify the below code ////////////////////////

/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////


// display quiz right away
buildQuiz();
// display quiz right away
buildQuiz();

// on submit, show results
submitButton.addEventListener("click", showResults);
// on submit, show results
submitButton.addEventListener("click", showResults);
})();


/////////////////////////////////////////////////////////////////////////////

/////////////////////// Do not modify the above code ////////////////////////

/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
Loading

0 comments on commit f16309e

Please sign in to comment.