|
|
@ -6,14 +6,14 @@ function run() {
|
|
|
|
terminal.innerHTML += content;
|
|
|
|
terminal.innerHTML += content;
|
|
|
|
terminal.scrollTop = terminal.scrollHeight;
|
|
|
|
terminal.scrollTop = terminal.scrollHeight;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
flush() {}
|
|
|
|
flush() {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
stderr: {
|
|
|
|
stderr: {
|
|
|
|
write(content) {
|
|
|
|
write(content) {
|
|
|
|
terminal.innerHTML += content;
|
|
|
|
terminal.innerHTML += content;
|
|
|
|
terminal.scrollTop = terminal.scrollHeight;
|
|
|
|
terminal.scrollTop = terminal.scrollHeight;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
flush() {}
|
|
|
|
flush() {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
stdin: {
|
|
|
|
stdin: {
|
|
|
|
async readline() {
|
|
|
|
async readline() {
|
|
|
@ -22,24 +22,23 @@ function run() {
|
|
|
|
var userInput = prompt();
|
|
|
|
var userInput = prompt();
|
|
|
|
return userInput;
|
|
|
|
return userInput;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
flush() {}
|
|
|
|
flush() {},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
var code = editor.getValue();
|
|
|
|
var code = editor.getValue();
|
|
|
|
runner.runCode(code);
|
|
|
|
runner.runCode(code);
|
|
|
|
setTimeout(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
runner.stopRunning();
|
|
|
|
runner.stopRunning();
|
|
|
|
}, 10*1000);
|
|
|
|
}, 10 * 1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function run_init() {
|
|
|
|
function run_init() {
|
|
|
|
if (document.getElementById("console") != '') {
|
|
|
|
if (document.getElementById("console") != "") {
|
|
|
|
document.getElementById("console").innerHTML = '';
|
|
|
|
document.getElementById("console").innerHTML = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
run();
|
|
|
|
run();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var editor = ace.edit("editor");
|
|
|
|
var editor = ace.edit("editor");
|
|
|
|
editor.container.style.opacity = 0.85;
|
|
|
|
editor.container.style.opacity = 0.85;
|
|
|
|
editor.setTheme("ace/theme/vibrant_ink");
|
|
|
|
editor.setTheme("ace/theme/vibrant_ink");
|
|
|
@ -58,28 +57,28 @@ editor.setOptions({
|
|
|
|
|
|
|
|
|
|
|
|
function exec(code, id) {
|
|
|
|
function exec(code, id) {
|
|
|
|
const terminal = document.getElementById("console");
|
|
|
|
const terminal = document.getElementById("console");
|
|
|
|
terminal.innerHTML = '';
|
|
|
|
terminal.innerHTML = "";
|
|
|
|
const runner = new BrythonRunner({
|
|
|
|
const runner = new BrythonRunner({
|
|
|
|
stdout: {
|
|
|
|
stdout: {
|
|
|
|
write(content) {
|
|
|
|
write(content) {
|
|
|
|
if (id == "code"){
|
|
|
|
if (id == "code") {
|
|
|
|
retourCode = content;
|
|
|
|
retourCode = content;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (id == "solution"){
|
|
|
|
if (id == "solution") {
|
|
|
|
retourSolution = content;
|
|
|
|
retourSolution = content;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
flush() {}
|
|
|
|
flush() {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
stderr: {
|
|
|
|
stderr: {
|
|
|
|
write(content) {
|
|
|
|
write(content) {
|
|
|
|
if (id == "solution"){
|
|
|
|
if (id == "solution") {
|
|
|
|
retourSolution = "ERROR";
|
|
|
|
retourSolution = "ERROR";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
terminal.innerHTML += content;
|
|
|
|
terminal.innerHTML += content;
|
|
|
|
terminal.scrollTop = terminal.scrollHeight;
|
|
|
|
terminal.scrollTop = terminal.scrollHeight;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
flush() {}
|
|
|
|
flush() {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
stdin: {
|
|
|
|
stdin: {
|
|
|
|
async readline() {
|
|
|
|
async readline() {
|
|
|
@ -88,27 +87,35 @@ function exec(code, id) {
|
|
|
|
var userInput = prompt();
|
|
|
|
var userInput = prompt();
|
|
|
|
return userInput;
|
|
|
|
return userInput;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
flush() {}
|
|
|
|
flush() {},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
runner.runCode(code)
|
|
|
|
runner.runCode(code);
|
|
|
|
setTimeout(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
runner.stopRunning();
|
|
|
|
runner.stopRunning();
|
|
|
|
}, 10*1000);
|
|
|
|
}, 10 * 1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//~ Function that check if the code in the editor as the same result as the solution.
|
|
|
|
/**
|
|
|
|
|
|
|
|
* It checks if the code in the editor as the same result as the solution.
|
|
|
|
function check(){
|
|
|
|
*/
|
|
|
|
|
|
|
|
function check() {
|
|
|
|
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 :/";
|
|
|
|
}
|
|
|
|
} else if (retourSolution == retourCode) {
|
|
|
|
|
|
|
|
|
|
|
|
else if (retourSolution == retourCode) {
|
|
|
|
|
|
|
|
result.innerHTML = "Bien joué";
|
|
|
|
result.innerHTML = "Bien joué";
|
|
|
|
document.getElementById("fleche").style.display = "flex";
|
|
|
|
document.getElementById("next").style.display = "flex";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else {
|
|
|
|
|
|
|
|
result.innerHTML = "Mauvaise réponse";
|
|
|
|
result.innerHTML = "Mauvaise réponse";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* It gets all the elements with the class name "help" and sets their opacity to 1.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function displayHelp() {
|
|
|
|
|
|
|
|
var help = document.getElementsByClassName("help");
|
|
|
|
|
|
|
|
for (var i = 0; i < help.length; i++) {
|
|
|
|
|
|
|
|
help[i].style.opacity = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|