Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added submit button with checking of answers #152

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions src/lab/exp8/Quizzes.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<!DOCTYPE html>
<html lang="en">
<head>
Expand Down Expand Up @@ -102,16 +103,21 @@ <h1 class="text-h2-lightblue">Compression Test on Spring</h1><div class="content
<p>
<b>Q1.</b>
Coiled spring is also known as helical spring. <br>
<input id="q1" name="q1" type="radio" value="1">
<input id="q1t" name="q1" type="radio" value="1">
<font color="green"> True </font> <br>
<input id="q1" name="q1" type="radio" value="0">
<input id="q1f" name="q1" type="radio" value="0">
<font color="red"> False </font> <br/><br/>
<b>Q2.</b>
Compression spring is a special type of torsion spring. <br>
<input id="q2" name="q2" type="radio" value="1">
<input id="q2t" name="q2" type="radio" value="1">
<font color="green"> True </font> <br>
<input id="q2" name="q2" type="radio" value="0">
<input id="q2f" name="q2" type="radio" value="0">
<font color="red"> False </font> <br/><br/>

<br><br>
<button onclick="checkerfn()">Submit (Q1 and Q2 only)</button>
<br><br>

<b>Q3.</b>
What do you mean by deflection? <br/><br/>
<b>Q4.</b>
Expand Down Expand Up @@ -247,6 +253,32 @@ <h2 class="text-h2-lightblue-small" style="font-weight: bold;margin-top: 0px;">
});

});

function checkerfn() {
q1ans = 0;
q2ans = 0;

if(document.getElementById('q1t').checked)
q1ans = 1;
if(document.getElementById('q2t').checked)
q2ans = 1;

strans = '';
strans += 'Answer to Q1 is '
if(q1ans == 1)
strans += 'Correct!\n'
else
strans += 'Incorrect!\n'

strans += 'Answer to Q2 is '
if(q2ans == 0)
strans += 'Correct!\n'
else
strans += 'Incorrect!\n'

window.alert(strans);

}
</script>

</html>