initial
This commit is contained in:
271
templates/solution.html
Normal file
271
templates/solution.html
Normal file
@@ -0,0 +1,271 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}{{ solution.task.name }}|решение{% endblock %}
|
||||
|
||||
{% block links %}
|
||||
<link rel="stylesheet" href="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.4.0/build/styles/default.min.css">
|
||||
<script src="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.4.0/build/highlight.min.js"></script>
|
||||
<script>hljs.initHighlightingOnLoad();</script>
|
||||
{% endblock %}
|
||||
|
||||
{% load filters %}
|
||||
|
||||
{% block scripts %}
|
||||
{% if can_edit %}
|
||||
function findGetParameter(parameterName) {
|
||||
var result = null,
|
||||
tmp = [];
|
||||
location.search
|
||||
.substr(1)
|
||||
.split("&")
|
||||
.forEach(function (item) {
|
||||
tmp = item.split("=");
|
||||
if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
function next() {
|
||||
const solutions_request = findGetParameter('solutions');
|
||||
const solutions = solutions_request.split(' ');
|
||||
const current = findGetParameter('id');
|
||||
const current_index = solutions.findIndex((element) => element == current);
|
||||
if (current_index != solutions.length - 1) {
|
||||
var next_element = document.getElementById('next');
|
||||
next_element.setAttribute('href', '/admin/solution?id=' + solutions[current_index + 1] + '&solutions=' + solutions_request);
|
||||
next_element.innerHTML = '->';
|
||||
}
|
||||
}
|
||||
function previous() {
|
||||
const solutions_request = findGetParameter('solutions');
|
||||
const solutions = solutions_request.split(' ');
|
||||
const current = findGetParameter('id');
|
||||
const current_index = solutions.findIndex((element) => element == current);
|
||||
if (current_index != 0) {
|
||||
var next_element = document.getElementById('previous');
|
||||
next_element.setAttribute('href', '/admin/solution?id=' + solutions[current_index - 1] + '&solutions=' + solutions_request);
|
||||
next_element.innerHTML = '<-';
|
||||
}
|
||||
}
|
||||
function fillContent() {
|
||||
next();
|
||||
previous();
|
||||
}
|
||||
{% if can_edit %}
|
||||
function showHideTests() {
|
||||
var text = document.getElementById('tests_text');
|
||||
var button = document.getElementById('tests_button');
|
||||
text.hidden = !text.hidden;
|
||||
if (text.hidden) {
|
||||
button.textContent = 'Показать тесты';
|
||||
} else {
|
||||
button.textContent = 'Скрыть тесты';
|
||||
}
|
||||
}
|
||||
function showHideLog() {
|
||||
var text = document.getElementById('log_text');
|
||||
var button = document.getElementById('log_button');
|
||||
text.hidden = !text.hidden;
|
||||
if (text.hidden) {
|
||||
button.textContent = 'Показать лог';
|
||||
} else {
|
||||
button.textContent = 'Скрыть лог';
|
||||
}
|
||||
}
|
||||
function retest() {
|
||||
let del = confirm("Подтвердите перетест");
|
||||
if (del) {
|
||||
const sols = findGetParameter('solutions');
|
||||
const link = '/admin/retest?block_id={{ solution.task.block.id }}&solution_id={{ solution.id }}&next={% autoescape off %}{{ path }}?id={{ solution.id }}{% if current_page == 'admin' %}%26solutions={% endif %}{% endautoescape %}'{% if current_page == 'admin' %} + sols.replaceAll(' ', '%20'){% endif %};
|
||||
window.location.href = link;
|
||||
}
|
||||
}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block onload %}{% if can_edit %}fillContent(){% endif %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<h5>
|
||||
<form method="POST">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td>
|
||||
Блок
|
||||
</td>
|
||||
<td>
|
||||
<a href="{% if current_page == 'admin' %}/admin{% endif %}/block?id={{ solution.task.block.id }}">{{ solution.task.block.name }}</a>
|
||||
{% if current_page == 'admin' %}
|
||||
| <a style="margin-top: 15px;" href="/admin/solutions?block_id={{ solution.task.block.id }}">К посылкам</a> | <a style="margin-top: 15px;" href="/admin/rating?block_id={{ solution.task.block.id }}">К рейтингу</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Таск
|
||||
</td>
|
||||
<td>
|
||||
<a href="{% if current_page == 'admin' %}/admin{% endif %}/task?id={{ solution.task.id }}">{{ solution.task.name }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Студент
|
||||
</td>
|
||||
<td>
|
||||
{{ solution.userinfo.surname }} {{ solution.userinfo.name }} {{ solution.userinfo.middle_name }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
id решения
|
||||
</td>
|
||||
<td>
|
||||
<div style="text-align: center;"></div>
|
||||
{% if can_edit %}
|
||||
<a id="previous"></a>
|
||||
{% endif %}
|
||||
{{ solution.id }}
|
||||
{% if can_edit %}
|
||||
<a id="next"></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Результат
|
||||
</td>
|
||||
<td>
|
||||
{% if can_edit or solution.task.show_details %}
|
||||
<!-- Button trigger modal -->
|
||||
<button type="button" class="btn btn-link" data-toggle="modal" data-target="#resultModalLong{{ solution.id }}">
|
||||
{{ solution.result }}
|
||||
</button>
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="resultModalLong{{ solution.id }}" tabindex="-1" role="dialog" aria-labelledby="resultModalLongTitle{{ solution.id }}" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="resultModalLongTitle{{ solution.id }}">Подробная информация о тестировании {{ solution.id }}</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
{% autoescape off %}
|
||||
{{ solution.details }}
|
||||
{% endautoescape %}
|
||||
{% if can_edit %}
|
||||
<hr>
|
||||
<pre id="tests_text" hidden>
|
||||
<h4>Тесты</h4><br>
|
||||
{{ solution.task.tests_text }}
|
||||
</pre>
|
||||
<hr>
|
||||
<pre id="log_text" hidden>
|
||||
<h4>Лог</h4><br>
|
||||
{{ solution.log_text }}
|
||||
</pre>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
{% if can_edit %}
|
||||
<button type="button" id="log_button" class="btn btn-warning" onclick="showHideLog()">Показать лог</button>
|
||||
<button type="button" id="tests_button" class="btn btn-primary" onclick="showHideTests()">Показать тесты</button>
|
||||
{% endif %}
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
{% if solution.task.show_result %}
|
||||
{{ solution.result }}
|
||||
{% else %}
|
||||
Accepted
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Оценка
|
||||
</td>
|
||||
<td>
|
||||
{% if can_edit %}
|
||||
{% csrf_token %}
|
||||
<label>
|
||||
<select name="mark">
|
||||
{% autoescape off %}
|
||||
{{ solution.mark_select }}
|
||||
{% endautoescape %}
|
||||
</select>
|
||||
</label>
|
||||
{% else %}
|
||||
{% if solution.task.show_result %}
|
||||
{{ solution.mark_property }}
|
||||
{% else %}
|
||||
{% if solution.mark == null %}
|
||||
Checking
|
||||
{% else %}
|
||||
Checked
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Комментарий
|
||||
</td>
|
||||
<td>
|
||||
{% if can_edit %}
|
||||
<textarea rows="10" cols="50" style="resize: none;" name="comment">{{ solution.comment }}</textarea>
|
||||
{% else %}
|
||||
<pre>
|
||||
{{ solution.comment_property }}
|
||||
</pre>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{% if can_edit %}
|
||||
<button type="submit" name="action" value="Зачесть" class="btn btn-dark"><i class="fa fa-check"></i> Зачесть</button>
|
||||
<button type="submit" name="action" value="Незачесть" class="btn btn-dark"><i class="fa fa-times"></i> Не зачесть</button>
|
||||
<button type="submit" name="action" value="Выставить макс. балл" class="btn btn-dark"><i class="fa fa-arrow-up"></i> Выставить макс. балл</button>
|
||||
<button type="button" class="btn btn-dark" onclick="retest()"><i class="fa fa-undo"></i> Перетест</button>
|
||||
{% endif %}
|
||||
<button type="button" class="btn btn-dark"><i class="fa fa-question-circle"></i> Помощь</button>
|
||||
</form>
|
||||
</h5>
|
||||
</div>
|
||||
</div>
|
||||
<h3>Files</h3>
|
||||
{% for filename, text in solution.files.items %}
|
||||
<h5>{{ filename }}</h5>
|
||||
{% if filename|is_code %}
|
||||
<pre>
|
||||
<code class="c# border border-dark">
|
||||
{{ text }}
|
||||
</code>
|
||||
</pre>
|
||||
{% else %}
|
||||
<div class="border border-dark bg-light" style="padding: 15px;">
|
||||
<pre>
|
||||
{{ text }}
|
||||
</pre>
|
||||
</div>
|
||||
{% endif %}
|
||||
<hr>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
Reference in New Issue
Block a user