Files
QPP/templates/problem.html
2025-08-12 12:47:35 +02:00

67 lines
2.6 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ problem.title }}</title>
<link rel="stylesheet" href="/static/style.css">
<link href="https://fonts.cdnfonts.com/css/jetbrains-mono" rel="stylesheet">
</head>
<body>
<div class="problem-header">
<button class="back-btn" onclick="window.location.href='/'">← Back</button>
<h1 style="margin-bottom:0;">{{ problem.title }}</h1>
</div>
<div class="problem-desc">{{ problem.description | safe | markdown }}</div>
<div class="editor-section" style="max-width:1160;margin:0">
<h2 style="margin-top:0;">Submit Your Solution (Python)</h2>
<form method="post">
<label for="username">Username (optional):</label>
<input type="text" name="username" id="username" placeholder="Anonymous" style="margin-bottom:10px;">
<div id="editor"></div>
<textarea name="user_code" id="user_code" style="display:none;"></textarea>
<div class="editor-actions">
<button type="submit">Run & Submit</button>
</div>
</form>
</div>
<script src="https://cdn.jsdelivr.net/npm/monaco-editor@0.45.0/min/vs/loader.js"></script>
<script>
require.config({ paths: { 'vs': 'https://cdn.jsdelivr.net/npm/monaco-editor@0.45.0/min/vs' } });
require(['vs/editor/editor.main'], function() {
var editor = monaco.editor.create(document.getElementById('editor'), {
value: '',
language: 'python',
theme: 'vs-light',
fontFamily: 'JetBrains Mono, monospace',
fontLigatures: true,
automaticLayout: true,
fontSize: 16,
minimap: { enabled: false }
});
document.querySelector('form').addEventListener('submit', function(e) {
var code = editor.getValue();
if (!code.trim()) {
alert('Please enter your code before submitting.');
e.preventDefault();
return false;
}
document.getElementById('user_code').value = code;
});
});
</script>
{% if result %}
<div class="editor-section" style="max-width:1160;margin:0;margin-top: 5px;">
<h3>Result:</h3>
<b>Runtime:</b> {{ '%.4f'|format(result.runtime) }} seconds<br>
<b>Output:</b>
<pre>{{ result.output }}</pre>
{% if result.error %}
<b>Error:</b>
<pre>{{ result.error }}</pre>
{% endif %}
</div>
{% endif %}
</body>
</html>