diff --git a/public/index.html b/public/index.html index 96040e1..c5f2193 100644 --- a/public/index.html +++ b/public/index.html @@ -37,7 +37,7 @@ toEval += "\n return outputs\nf(json.loads(x))" - alert(eval(toEval)) + document["resultsToValidate"].innerHTML = eval(toEval) document['brythonButton'].bind('click', brythonButton) diff --git a/src/pages/IDE.vue b/src/pages/IDE.vue index b843d25..1907ef2 100644 --- a/src/pages/IDE.vue +++ b/src/pages/IDE.vue @@ -59,6 +59,7 @@
$> {{ log }} 

+
@@ -106,6 +107,7 @@ export default { println: window.println, logs: window.logs, inputs: [1,2,3,4], + solutions: [1,4,9,16], }; }, methods: { @@ -138,8 +140,16 @@ export default { window.logs = []; this.logs = window.logs; }, - doit() { + validPython() { document.getElementById("brythonButton").click(); + + if(document.getElementById("resultsToValidate").innerHTML == this.solutions+"") { + document.getElementById("resultsToValidate").innerHTML = "Your answer is correct!" + document.getElementById("resultsToValidate").style = "visibility: visible; background-color: hsla(89, 43%, 51%, 0.3); border-radius: 7px; color: green; padding: 5px; margin-top: 7px"; + } else { + document.getElementById("resultsToValidate").innerHTML = "Your answer is not correct" + document.getElementById("resultsToValidate").style = "visibility: visible; background-color: hsla(0, 100%, 51%, 0.3); border-radius: 7px; color: red; padding: 5px; margin-top: 7px"; + } /*Example: outputs = [] for i in inputs: