ServeurDeTest
Noé GARNIER 2 years ago
parent 64e58f8cf0
commit 97d73fb1e3

@ -7,3 +7,104 @@
element.classList.remove("nav-button"); element.classList.remove("nav-button");
element.classList.add("currentText"); element.classList.add("currentText");
} }
function run() {
var terminal ="";
const runner = new BrythonRunner({
stdout: {
write(content) {
terminal += content;
},
flush() {},
},
stderr: {
write(content) {
terminal += content;
},
flush() {},
},
stdin: {
async readline() {
terminal += "\n";
var userInput = prompt();
return userInput;
},
flush() {},
},
});
var code = getElementById("solution").value;
runner.runCode(code);
setTimeout(() => {
runner.stopRunning();
}, 10 * 1000);
}
function run_init() {
if (terminal != "") {
terminal = "";
}
run();
}
//Function that execute given code and return the result in a given element by id
function exec(code, id) {
var terminal = "";
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 += content;
},
flush() {},
},
stdin: {
async readline() {
terminal += "\n";
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") {
alert("Il semblerait qu'il y a une erreur de python dans le code" + "Le terminal affiche : " + terminal);
} else if (retourSolution == retourCode) {
alert("Aucune erreur détectée");
} else {
alert("Il semblerait que le solution ne soit pas la bonne " + "Le terminal affiche : " + terminal);
}
}
async function submit(){
var test = document.getElementById("test").value;
exec("print ('True')", "code");
exec(test, "solution");
var result = document.getElementById("result");
result.innerHTML = "Test en cours...";
await new Promise(r => setTimeout(r, 1500));
check();
}

@ -79,6 +79,15 @@
<button class="left send py-1 px-2 d-flex align-items-center" type="submit"> <button class="left send py-1 px-2 d-flex align-items-center" type="submit">
Modifier Modifier
</button> </button>
<button onclick="submit()" class="left send py-1 px-2 d-flex align-items-center">
Verfier
</button>
<a class="left send py-1 px-2 d-flex align-items-center" href="<?php echo 'index.php?action=goToEnigme&ordre='. $enigme->getOrdre();?>">
Se rendre à l'énigme
</a>
<p id="result" p>
</p>
</form> </form>
<script src="View/src/JS/Admin.js">
</body> </body>

@ -1,59 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Admin</title>
<!-- Required meta tags -->
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<!-- CSS -->
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU"
crossorigin="anonymous"
/>
<link rel="stylesheet" href="./View/src/CSS/Admin2.css" />
</head>
<body>
<div class="container">
<div class="row">
<div class="col">
<a href="index.php?action=goToAdmin" class="send py-1 px-2 d-flex align-items-center">
Retour
</a>
<h1>Ordre des énigmes</h1>
</div>
</div>
<div class="row">
<div class="col">
<form action="index.php?action=modifOrdre" method="POST">
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Enigme</th>
<th scope="col">Ordre</th>
</tr>
</thead>
<tbody>
<?php
foreach ($lesEnigmes as $enigme) {
echo "<tr>";
echo "<td>".$enigme->getNom()."</td>";
echo '<td><input type="number" name="ordre'. $enigme->getIdEnigme() .'" value="'. $enigme->getOrdre() .'"></td>';
echo "</tr>";
}
?>
</tbody>
</table>
<button class="left send py-1 px-2 d-flex align-items-center" type="submit">
Modifier
</button>
</form>
</div>
</div>
</div>
</body>
Loading…
Cancel
Save