Skip to content

Commit

Permalink
Merge pull request #19 from virtual-labs/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
vlabs-iiith-ecc authored Nov 25, 2023
2 parents 1870a3d + 1434eb6 commit 0418d44
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 95 deletions.
79 changes: 41 additions & 38 deletions experiment/simulation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,26 +157,35 @@
<td><br> <b>x<sup>3</sup>+x<sup>2</sup>+x+1</b> </td>
<td><br> <b>0</b> </td>
<td><br> <b>1</b> </td>
<form action="" method="get" id="form1" autocomplete="off" onsubmit="return false">
<td> </td>


</tr>

<tr height="65px">
<form action="" method="get" id="form1" autocomplete="off" onsubmit="return false">
<td> <input id="m-field-1" class="text-inp"
oninput="this.value = this.value.replace(/\s+/g, '')"> </td>
<td> <input id="m-field-2" class="text-inp"
oninput="this.value = this.value.replace(/\s+/g, '')"> </td>
<td> <input id="m-field-3" class="text-inp"
oninput="this.value = this.value.replace(/\s+/g, '')"> </td>
<td>
<input id="m-field-1" class="text-inp"
oninput="this.value = this.value.replace(/\s+/g, '')"> &emsp;<button
class="v-button" role="button" id="submit1" form="form1"
<input id="m-field-4" class="text-inp"
oninput="this.value = this.value.replace(/\s+/g, '')"> &emsp;
<button class="v-button" role="button" id="submit1" form="form1"
onClick="confirm1()"> Submit
</button>
</td>
</form>
</tr>

<tr height="65px">
<tr height="40px">
<td> <b>0</b> </td>
<td> </td>
<td> </td>
<form action="" method="get" id="form2" autocomplete="off" onsubmit="return false">
<td> <input id="m-field-2" class="text-inp"
oninput="this.value = this.value.replace(/\s+/g, '')" disabled> </td>
<td> <input id="m-field-3" class="text-inp"
oninput="this.value = this.value.replace(/\s+/g, '')" disabled> </td>
<td> <input id="m-field-4" class="text-inp"
oninput="this.value = this.value.replace(/\s+/g, '')" disabled> </td>

<td>
<input id="m-field-5" class="text-inp"
oninput="this.value = this.value.replace(/\s+/g, '')" disabled>
Expand All @@ -185,13 +194,7 @@
Submit </button>
</td>
</form>
</tr>

<tr height="40px">
<td> <b>0</b> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>

</table>
Expand Down Expand Up @@ -255,43 +258,37 @@
<td><br> <b>x<sup>3</sup>+1</b> </td>
<td><br> <b>0</b> </td>
<td><br> <b>1</b> </td>
<form action="" method="get" id="form3" autocomplete="off" onsubmit="return false">
<td> <input id="math-field-1" class="text-inp"
oninput="this.value = this.value.replace(/\s+/g, '')"> &emsp; <button
class="v-button" role="button" id="sub1" form="form3" onClick="check1()">
Submit </button>
</td>
</form>
<td> </td>
</tr>

<tr height="65px">
<form action="" method="get" id="form4" autocomplete="off" onsubmit="return false">
<form action="" method="get" id="form3" autocomplete="off" onsubmit="return false">
<td> <input id="math-field-1" class="text-inp"
oninput="this.value = this.value.replace(/\s+/g, '')"> </td>
<td> <input id="math-field-2" class="text-inp"
oninput="this.value = this.value.replace(/\s+/g, '')" disabled> </td>
oninput="this.value = this.value.replace(/\s+/g, '')"> </td>
<td> <input id="math-field-3" class="text-inp"
oninput="this.value = this.value.replace(/\s+/g, '')" disabled> </td>
oninput="this.value = this.value.replace(/\s+/g, '')"> </td>
<td> <input id="math-field-4" class="text-inp"
oninput="this.value = this.value.replace(/\s+/g, '')" disabled> </td>
<td> <input id="math-field-5" class="text-inp"
oninput="this.value = this.value.replace(/\s+/g, '')" disabled> &emsp;
<button class="v-button" role="button" id="sub2" form="form4" onClick="check2()"
disabled> Submit
oninput="this.value = this.value.replace(/\s+/g, '')"> &emsp;
<button class="v-button" role="button" id="sub1" form="form3"
onClick="check1()"> Submit
</button>
</td>
</form>
</tr>

<tr height="65px">
<form action="" method="get" id="form5" autocomplete="off" onsubmit="return false">
<form action="" method="get" id="form4" autocomplete="off" onsubmit="return false">
<td> <input id="math-field-5" class="text-inp"
oninput="this.value = this.value.replace(/\s+/g, '')" disabled> </td>
<td> <input id="math-field-6" class="text-inp"
oninput="this.value = this.value.replace(/\s+/g, '')" disabled> </td>
<td> <input id="math-field-7" class="text-inp"
oninput="this.value = this.value.replace(/\s+/g, '')" disabled> </td>
<td> <input id="math-field-8" class="text-inp"
oninput="this.value = this.value.replace(/\s+/g, '')" disabled> </td>
<td> <input id="math-field-9" class="text-inp"
oninput="this.value = this.value.replace(/\s+/g, '')" disabled> &emsp;
<button class="v-button" role="button" id="sub3" form="form5" onClick="check3()"
<button class="v-button" role="button" id="sub2" form="form4" onClick="check2()"
disabled> Submit
</button>
</td>
Expand All @@ -302,7 +299,14 @@
<td> <b>0</b> </td>
<td> </td>
<td> </td>
<td> </td>
<form action="" method="get" id="form5" autocomplete="off" onsubmit="return false">
<td> <input id="math-field-9" class="text-inp"
oninput="this.value = this.value.replace(/\s+/g, '')" disabled> &emsp;
<button class="v-button" role="button" id="sub3" form="form5"
onClick="check3()" disabled>
Submit </button>
</td>
</form>
</tr>
</table>

Expand All @@ -312,7 +316,6 @@
</div>
</div>


<div class="column is-3-desktop is-4-tablet is-12-mobile">
<div class="v-datalist-container components-list">
<div class="v-datalist-title">Observations</div>
Expand Down
118 changes: 61 additions & 57 deletions experiment/simulation/js/euclidean-division.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ const mField4 = document.getElementById("m-field-4");
const mField5 = document.getElementById("m-field-5");

function confirm1() {

const obs1 = document.getElementById("observations1");
const inp1 = mField1.value;
const inp2 = mField2.value;
const inp3 = mField3.value;
const inp4 = mField4.value;

if (inp1.length == 0) {
if (inp1.length == "0" || inp2.length == "0" || inp3.length == "0" || inp4.length == "0") {
obs1.innerHTML = "Enter the answer."
obs1.style.color = "black";
}

else if (inp1 == "x^2+x" || inp1 == "x+x^2") {
obs1.innerHTML = "<b>Correct Answer!!!</b>";
else if ((inp1 == "x^2+1" || inp1 == "1+x^2") && inp2 == "1" && (inp3 == "x^2+x" || inp3 == "x+x^2") && (inp4 == "x+x^2" || inp4 == "x^2+x")) {
obs1.innerHTML = "<b>Correct Answer!!!</b> <br> Fill the next row";
obs1.style.color = "green";

document.getElementById("submit1").setAttribute("disabled", true);
document.getElementById("submit2").removeAttribute("disabled");

mField1.setAttribute("disabled", true);
mField2.removeAttribute("disabled");
mField3.removeAttribute("disabled");
mField4.removeAttribute("disabled");
mField2.setAttribute("disabled", true);
mField3.setAttribute("disabled", true);
mField4.setAttribute("disabled", true);
mField5.removeAttribute("disabled");

}

else {
Expand All @@ -38,24 +38,24 @@ function confirm1() {
obs1.innerHTML = "<b>Wrong Answer :(</b>";
}
}

}

function confirm2() {

const obs1 = document.getElementById("observations1");
const inp2 = mField2.value;
const inp3 = mField3.value;
const inp4 = mField4.value;
const inp5 = mField5.value;

if (inp2.length == "0" || inp3.length == "0" || inp4.length == "0" || inp5.length == "0") {
if (inp5.length == 0) {
obs1.innerHTML = "Enter the answer."
obs1.style.color = "black";
}

else if ((inp2 == "x^2+1" || inp2 == "1+x^2") && inp3 == "1" && (inp4 == "x^2+x" || inp4 == "x+x^2") && (inp5 == "1+x" || inp5 == "x+1")) {
obs1.innerHTML = "<b>Correct Answer!!!</b> <br> The GCD is x<sup>2</sup>+1";
else if (inp5 == "x+1" || inp5 == "1+x") {
obs1.innerHTML = "<b>Correct Answer!!!</b> <br> The GCD is x<sup>2</sup>+1";
obs1.style.color = "green";

mField5.setAttribute("disabled", true);
document.getElementById("submit2").setAttribute("disabled", true);
}

else {
Expand All @@ -67,11 +67,13 @@ function confirm2() {
obs1.innerHTML = "<b>Wrong Answer :(</b>";
}
}

}





// Second Example
const mathField1 = document.getElementById("math-field-1");
const mathField2 = document.getElementById("math-field-2");
Expand All @@ -85,27 +87,32 @@ const mathField9 = document.getElementById("math-field-9");


function check1() {

const obs2 = document.getElementById("observations2");
const inp1 = mathField1.value;
const inp2 = mathField2.value;
const inp3 = mathField3.value;
const inp4 = mathField4.value;

if (inp1.length == 0) {
obs2.innerHTML = "Enter the answer."
if (inp1.length == "0" || inp2.length == "0" || inp3.length == "0" || inp4.length == "0") {
obs2.innerHTML = "Enter all the fields."
obs2.style.color = "black";
}

else if (inp1 === "x^3") {
obs2.innerHTML = "<b>Correct Answer!!!</b>";
else if ((inp1 == "x^2+1" || inp1 == "1+x^2") && inp2 == "1" && inp3 == "x^3" && inp4 == "x^3") {
obs2.style.color = "green";
obs2.innerHTML = "<b>Correct Answer!!!</b> <br> Fill the next row";

document.getElementById("sub1").setAttribute("disabled", true);
document.getElementById("sub2").removeAttribute("disabled");

mathField1.setAttribute("disabled", true);
mathField2.removeAttribute("disabled");
mathField3.removeAttribute("disabled");
mathField4.removeAttribute("disabled");
mathField2.setAttribute("disabled", true);
mathField3.setAttribute("disabled", true);
mathField4.setAttribute("disabled", true);

mathField5.removeAttribute("disabled");
mathField6.removeAttribute("disabled");
mathField7.removeAttribute("disabled");
mathField8.removeAttribute("disabled");
}

else {
Expand All @@ -117,40 +124,36 @@ function check1() {
obs2.innerHTML = "<b>Wrong Answer :(</b>";
}
}

}

function check2() {
const obs2 = document.getElementById("observations2");
const inp2 = mathField2.value;
const inp3 = mathField3.value;
const inp4 = mathField4.value;
const inp5 = mathField5.value;
const inp6 = mathField6.value;
const inp7 = mathField7.value;
const inp8 = mathField8.value;

if (inp2.length == "0" || inp3.length == "0" || inp4.length == "0" || inp5.length == "0") {
if (inp5.length == "0" || inp6.length == "0" || inp7.length == "0" || inp8.length == "0") {
obs2.innerHTML = "Enter all the fields."
obs2.style.color = "black";
}
else if ((inp2 == "x^2+1" || inp2 == "1+x^2") && inp3 == "1" && inp4 == "x^3" && inp5 == "x") {
obs2.style.color = "green";
if (obs2.innerHTML == "<b>Correct Answer!!!</b>") {
obs2.innerHTML = "<b>Correct Again!!!</b>";
}
else {
obs2.innerHTML = "<b>Correct Answer!!!</b>";
else if ((inp5 == "x+1" || inp5 == "1+x") && inp6 == "x" && (inp7 == "1+x^4" || inp7 == "x^4+1") && inp8 == "x") {
if(obs2.innerHTML == "<b>Correct Answer!!!</b> <br> Fill the next row") {
obs2.innerHTML = "<b>Correct Again!!!</b> <br> Fill the next row";
obs2.style.color = "green";
}

else{
obs2.innerHTML = "<b>Correct Answer!!!</b> <br> Fill the next row";
obs2.style.color = "green";
}
document.getElementById("sub2").setAttribute("disabled", true);
document.getElementById("sub3").removeAttribute("disabled");

mathField2.setAttribute("disabled", true);
mathField3.setAttribute("disabled", true);
mathField4.setAttribute("disabled", true);
mathField5.setAttribute("disabled", true);
mathField6.setAttribute("disabled", true);
mathField7.setAttribute("disabled", true);
mathField8.setAttribute("disabled", true);

mathField6.removeAttribute("disabled");
mathField7.removeAttribute("disabled");
mathField8.removeAttribute("disabled");
mathField9.removeAttribute("disabled");
}

Expand All @@ -166,20 +169,20 @@ function check2() {
}

function check3() {

const obs2 = document.getElementById("observations2");
const inp6 = mathField6.value;
const inp7 = mathField7.value;
const inp8 = mathField8.value;
const inp9 = mathField9.value;

if (inp6.length == "0" || inp7.length == "0" || inp8.length == "0" || inp9.length == "0") {
obs2.innerHTML = "Enter all the fields."
if (inp9.length == 0) {
obs2.innerHTML = "Enter the answer."
obs2.style.color = "black";
}
else if ((inp6 == "x+1" || inp6 == "1+x") && inp7 == "x" && (inp8 == "1+x^4" || inp8 == "x^4+1") && (inp9 == "x+1" || inp9 == "1+x")) {

else if (inp9 === "1+x" || inp9 === "x+1") {
obs2.innerHTML = "<b>Correct Answer!!!</b> <br> The GCD is 1+x";
obs2.style.color = "green";

document.getElementById("sub3").setAttribute("disabled", true);
mathField9.setAttribute("disabled", true);
}

else {
Expand All @@ -191,6 +194,7 @@ function check3() {
obs2.innerHTML = "<b>Wrong Answer :(</b>";
}
}

}

function page1() {
Expand All @@ -205,9 +209,9 @@ function page1() {
obs1.innerHTML = "";

mField1.removeAttribute("disabled");
mField2.setAttribute("disabled", true);
mField3.setAttribute("disabled", true);
mField4.setAttribute("disabled", true);
mField2.removeAttribute("disabled");
mField3.removeAttribute("disabled");
mField4.removeAttribute("disabled");
mField5.setAttribute("disabled", true);


Expand All @@ -230,9 +234,9 @@ function page2() {
obs2.innerHTML = "";

mathField1.removeAttribute("disabled");
mathField2.setAttribute("disabled", true);
mathField3.setAttribute("disabled", true);
mathField4.setAttribute("disabled", true);
mathField2.removeAttribute("disabled");
mathField3.removeAttribute("disabled");
mathField4.removeAttribute("disabled");
mathField5.setAttribute("disabled", true);
mathField6.setAttribute("disabled", true);
mathField7.setAttribute("disabled", true);
Expand Down

0 comments on commit 0418d44

Please sign in to comment.