Add source to submission status

This commit is contained in:
cuom1999 2022-08-18 22:47:41 -05:00
parent 04b9849b40
commit f5c124a2e9
4 changed files with 56 additions and 11 deletions

View file

@ -359,11 +359,6 @@ urlpatterns = [
r"^submissions/user/(?P<user>\w+)/", r"^submissions/user/(?P<user>\w+)/",
paged_list_view(submission.AllUserSubmissions, "all_user_submissions"), paged_list_view(submission.AllUserSubmissions, "all_user_submissions"),
), ),
url(
r"^src/(?P<submission>\d+)$",
submission.SubmissionSource.as_view(),
name="submission_source",
),
url( url(
r"^src/(?P<submission>\d+)/raw$", r"^src/(?P<submission>\d+)/raw$",
submission.SubmissionSourceRaw.as_view(), submission.SubmissionSourceRaw.as_view(),

View file

@ -230,6 +230,10 @@ class SubmissionStatus(SubmissionDetailBase):
context["batches"] = group_test_cases(submission.test_cases.all()) context["batches"] = group_test_cases(submission.test_cases.all())
context["time_limit"] = submission.problem.time_limit context["time_limit"] = submission.problem.time_limit
context["can_see_testcases"] = False context["can_see_testcases"] = False
context["raw_source"] = submission.source.source.rstrip("\n")
context["highlighted_source"] = highlight_code(
submission.source.source, submission.language.pygments, linenos=False
)
contest = submission.contest_or_none contest = submission.contest_or_none
prefix_length = 0 prefix_length = 0

View file

@ -185,6 +185,9 @@ label[for="language"], label[for="status"] {
.source-wrap { .source-wrap {
overflow-x: auto; overflow-x: auto;
padding: 1em;
border-radius: 10px;
border: double 4px darkgray;
} }
.statistics-table { .statistics-table {
@ -234,7 +237,7 @@ label[for="language"], label[for="status"] {
.testcases-table { .testcases-table {
width: 100%; width: 100%;
border: 1px solid grey; border: groove;
border-radius: 0.5em; border-radius: 0.5em;
border-spacing: 0; border-spacing: 0;
@ -249,7 +252,7 @@ label[for="language"], label[for="status"] {
td { td {
padding: 0.6em 0.8em; padding: 0.6em 0.8em;
width: 18.75%; width: 18.75%;
border-bottom: 0.7px grey solid;
} }
.case-row td:nth-child(2) { .case-row td:nth-child(2) {

View file

@ -1,5 +1,33 @@
{% extends "submission/info-base.html" %} {% extends "submission/info-base.html" %}
{% block js_media %} {% block media %}
<style>
.line {
position: relative;
}
.highlighter {
position: absolute;
width: 9999px;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
a:active .line .highlighter {
background: rgba(255, 212, 0, 0.48);
}
.copy-clipboard {
margin-top: 0;
}
.testcases-table tbody:last-child {
border-bottom: none;
}
</style>
{% endblock %}
{% block content_js_media %}
<script type="text/javascript" src="{{ static('event.js') }}"></script> <script type="text/javascript" src="{{ static('event.js') }}"></script>
{% if not submission.is_graded and last_msg %} {% if not submission.is_graded and last_msg %}
<script type="text/javascript">$(function () { <script type="text/javascript">$(function () {
@ -53,11 +81,9 @@
</script> </script>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block body %} {% block body %}
<div style="clear: both"></div> <div style="clear: both"></div>
<br> <br>
<div><a href="{{ url('submission_source', submission.id) }}">{{ _('View source') }}</a></div>
{% if request.user == submission.user.user or perms.judge.resubmit_other %} {% if request.user == submission.user.user or perms.judge.resubmit_other %}
<div><a href="{{ url('problem_submit', submission.problem.code, submission.id) }}">{{ _('Resubmit') }}</a></div> <div><a href="{{ url('problem_submit', submission.problem.code, submission.id) }}">{{ _('Resubmit') }}</a></div>
{% endif %} {% endif %}
@ -73,7 +99,24 @@
{% endif %} {% endif %}
<br> <br>
<hr> <br>
<div class="source-wrap">
<table style="width: 100%">
<tr>
<td class="source-ln" style="width: 0">
<div>
{% for line in raw_source.split('\n') %}
<a href="#line-{{ loop.index }}" name="line-{{ loop.index }}">
<pre class="line">{{ loop.index }}</pre>
</a>
{% endfor %}
</div>
</td>
<td class="source-code">{{ highlighted_source }}</td>
</tr>
</table>
</div>
<br>
<br> <br>
<div id="test-cases">{% include "submission/status-testcases.html" %}</div> <div id="test-cases">{% include "submission/status-testcases.html" %}</div>