Gestion de la table résoudre en multi
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
adbe137e76
commit
9d0658013d
@ -0,0 +1,147 @@
|
|||||||
|
function run() {
|
||||||
|
const terminal = document.getElementById("console");
|
||||||
|
const runner = new BrythonRunner({
|
||||||
|
stdout: {
|
||||||
|
write(content) {
|
||||||
|
terminal.innerHTML += content;
|
||||||
|
terminal.scrollTop = terminal.scrollHeight;
|
||||||
|
},
|
||||||
|
flush() {},
|
||||||
|
},
|
||||||
|
stderr: {
|
||||||
|
write(content) {
|
||||||
|
terminal.innerHTML += content;
|
||||||
|
terminal.scrollTop = terminal.scrollHeight;
|
||||||
|
},
|
||||||
|
flush() {},
|
||||||
|
},
|
||||||
|
stdin: {
|
||||||
|
async readline() {
|
||||||
|
terminal.innerHTML += "\n";
|
||||||
|
terminal.scrollTop = terminal.scrollHeight;
|
||||||
|
var userInput = prompt();
|
||||||
|
return userInput;
|
||||||
|
},
|
||||||
|
flush() {},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
var code = editor.getValue();
|
||||||
|
runner.runCode(code);
|
||||||
|
setTimeout(() => {
|
||||||
|
runner.stopRunning();
|
||||||
|
}, 10 * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function run_init() {
|
||||||
|
if (document.getElementById("console") != "") {
|
||||||
|
document.getElementById("console").innerHTML = "";
|
||||||
|
}
|
||||||
|
run();
|
||||||
|
}
|
||||||
|
|
||||||
|
var editor = ace.edit("editor");
|
||||||
|
editor.container.style.opacity = 0.85;
|
||||||
|
editor.setTheme("ace/theme/vibrant_ink");
|
||||||
|
editor.getSession().setMode("ace/mode/python");
|
||||||
|
editor.setFontSize("16px");
|
||||||
|
editor.setOptions({
|
||||||
|
enableLiveAutocompletion: true,
|
||||||
|
copyWithEmptySelection: true,
|
||||||
|
showGutter: true,
|
||||||
|
useWrapMode: true, // wrap text to view
|
||||||
|
indentedSoftWrap: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
//Function that execute given code and return the result in a given element by id
|
||||||
|
|
||||||
|
function exec(code, id) {
|
||||||
|
const terminal = document.getElementById("console");
|
||||||
|
terminal.innerHTML = "";
|
||||||
|
const runner = new BrythonRunner({
|
||||||
|
stdout: {
|
||||||
|
write(content) {
|
||||||
|
if (id == "code") {
|
||||||
|
retourCode = content;
|
||||||
|
}
|
||||||
|
if (id == "solution") {
|
||||||
|
retourSolution = content;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
flush() {},
|
||||||
|
},
|
||||||
|
stderr: {
|
||||||
|
write(content) {
|
||||||
|
if (id == "solution") {
|
||||||
|
retourSolution = "ERROR";
|
||||||
|
}
|
||||||
|
terminal.innerHTML += content;
|
||||||
|
terminal.scrollTop = terminal.scrollHeight;
|
||||||
|
},
|
||||||
|
flush() {},
|
||||||
|
},
|
||||||
|
stdin: {
|
||||||
|
async readline() {
|
||||||
|
terminal.innerHTML += "\n";
|
||||||
|
terminal.scrollTop = terminal.scrollHeight;
|
||||||
|
var userInput = prompt();
|
||||||
|
return userInput;
|
||||||
|
},
|
||||||
|
flush() {},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
runner.runCode(code);
|
||||||
|
setTimeout(() => {
|
||||||
|
runner.stopRunning();
|
||||||
|
}, 10 * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It checks if the code in the editor as the same result as the solution.
|
||||||
|
*/
|
||||||
|
function check() {
|
||||||
|
if (retourSolution == "ERROR") {
|
||||||
|
result.innerHTML = "Il semblerait qu'il y a une erreur dans ton code :/";
|
||||||
|
} else if (retourSolution == retourCode) {
|
||||||
|
result.innerHTML = "Bien joué";
|
||||||
|
document.getElementById("next").style.display = "flex";
|
||||||
|
} else {
|
||||||
|
result.innerHTML = "Mauvaise réponse";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the help is displayed, hide it. Otherwise, display it.
|
||||||
|
*/
|
||||||
|
function displayHelp() {
|
||||||
|
var help = document.getElementsByClassName("help");
|
||||||
|
|
||||||
|
if (help[0].style.display == "block") {
|
||||||
|
for (var i = 0; i < help.length; i++) {
|
||||||
|
help[i].style.display = "none";
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < help.length; i++) {
|
||||||
|
help[i].style.display = "block";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// function saveCode() {
|
||||||
|
// var xhr = new XMLHttpRequest();
|
||||||
|
// // xhr.open('POST', 'http://localhost/Scripted/WEB/index.php?action=saveCode', true);
|
||||||
|
// xhr.open('POST', 'http://82.165.180.114/Scripted/WEB/index.php?action=saveCode', true);
|
||||||
|
// xhr.responseType = 'text';
|
||||||
|
// xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||||
|
// xhr.onload = function () {
|
||||||
|
// // console.log('saveCode'+xhr.responseText);
|
||||||
|
// };
|
||||||
|
// var searchParams = new URLSearchParams(window.location.search);
|
||||||
|
// var ordre = searchParams.get('ordre');
|
||||||
|
// xhr.send("code=" + editor.getValue() + "&ordre=" + ordre);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// document.getElementById ('editor').addEventListener('input', saveCode);
|
||||||
|
|
Loading…
Reference in new issue