Optimisation des tests

ServeurDeTest
Noé GARNIER 3 years ago
parent 325d37a6e4
commit 8d8f636fdd

@ -65,13 +65,20 @@ function exec(code, id) {
const runner = new BrythonRunner({ const runner = new BrythonRunner({
stdout: { stdout: {
write(content) { write(content) {
retour.textContent = content; if (id == "code"){
retourCode = content;
}
if (id == "solution"){
retourSolution = content;
}
}, },
flush() {} flush() {}
}, },
stderr: { stderr: {
write(content) { write(content) {
retour.textContent = "ERROR"; if (id == "solution"){
retourSolution = "ERROR";
}
terminal.innerHTML += content; terminal.innerHTML += content;
terminal.scrollTop = terminal.scrollHeight; terminal.scrollTop = terminal.scrollHeight;
}, },
@ -93,8 +100,9 @@ function exec(code, id) {
//~ Function that check if the code in the editor as the same result as the solution. //~ Function that check if the code in the editor as the same result as the solution.
function check(){ function check(){
const retourCode = document.getElementById("code").textContent; console.log(retourSolution)
const retourSolution = document.getElementById("solution").textContent; console.log(retourCode)
console.log(retourSolution == retourCode)
if (retourSolution == "ERROR") { if (retourSolution == "ERROR") {
result.innerHTML = "Il semblerait qu'il y a une erreur dans ton code :/"; result.innerHTML = "Il semblerait qu'il y a une erreur dans ton code :/";
result.classList.remove('hidden'); result.classList.remove('hidden');

@ -32,9 +32,6 @@
<textarea id='console' readonly></textarea> <textarea id='console' readonly></textarea>
</div> </div>
<p id="code" class="hidden">code</p>
<p id="solution" class="hidden">solution</p>
<script src="https://ajaxorg.github.io/ace-builds/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script> <script src="https://ajaxorg.github.io/ace-builds/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="https://raw.githack.com/pythonpad/brython-runner/master/lib/brython-runner.bundle.js" type="text/javascript" charset="utf-8"></script> <script src="https://raw.githack.com/pythonpad/brython-runner/master/lib/brython-runner.bundle.js" type="text/javascript" charset="utf-8"></script>
<script src="../javascript/palindrome.js"></script> <script src="../javascript/palindrome.js"></script>

Loading…
Cancel
Save