Skip to content

Commit

Permalink
Brython code resolving completelly implemented on IDE
Browse files Browse the repository at this point in the history
  • Loading branch information
davbrican committed Jul 29, 2021
1 parent 97daeb6 commit ca938ff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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)
</script>
Expand Down
14 changes: 12 additions & 2 deletions src/pages/IDE.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<pre>$> {{ log }} </pre>
</p>
</div>
<pre style="visibility: hidden;" id="resultsToValidate"></pre>

<div class="mt-5">
<button
Expand All @@ -72,7 +73,7 @@
<div class="mt-5">
<button
class="bg-orange-600 hover:bg-orange-500 p-3 text-white shadow-md focus:outline-none focus:shadow-outline m-1"
@click="doit()"
@click="validPython()"
>
Execute python
</button>
Expand Down Expand Up @@ -106,6 +107,7 @@ export default {
println: window.println,
logs: window.logs,
inputs: [1,2,3,4],
solutions: [1,4,9,16],
};
},
methods: {
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit ca938ff

Please sign in to comment.