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+)/",
paged_list_view(submission.AllUserSubmissions, "all_user_submissions"),
),
url(
r"^src/(?P<submission>\d+)$",
submission.SubmissionSource.as_view(),
name="submission_source",
),
url(
r"^src/(?P<submission>\d+)/raw$",
submission.SubmissionSourceRaw.as_view(),

View file

@ -230,6 +230,10 @@ class SubmissionStatus(SubmissionDetailBase):
context["batches"] = group_test_cases(submission.test_cases.all())
context["time_limit"] = submission.problem.time_limit
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
prefix_length = 0

View file

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

View file

@ -1,5 +1,33 @@
{% 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>
{% if not submission.is_graded and last_msg %}
<script type="text/javascript">$(function () {
@ -53,11 +81,9 @@
</script>
{% endif %}
{% endblock %}
{% block body %}
<div style="clear: both"></div>
<br>
<div><a href="{{ url('submission_source', submission.id) }}">{{ _('View source') }}</a></div>
{% 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>
{% endif %}
@ -73,7 +99,24 @@
{% endif %}
<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>
<div id="test-cases">{% include "submission/status-testcases.html" %}</div>