test num
This commit is contained in:
parent
7f3ace4b45
commit
77f1d18d24
@ -19,6 +19,7 @@ class Solution(models.Model):
|
|||||||
language_id = models.IntegerField(default=0)
|
language_id = models.IntegerField(default=0)
|
||||||
time_sent = models.DateTimeField(default=timezone.now)
|
time_sent = models.DateTimeField(default=timezone.now)
|
||||||
result = models.TextField(default=CONSTS["in_queue_status"])
|
result = models.TextField(default=CONSTS["in_queue_status"])
|
||||||
|
test = models.IntegerField(default=None)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def language(self):
|
def language(self):
|
||||||
@ -57,6 +58,22 @@ class Solution(models.Model):
|
|||||||
def directory(self):
|
def directory(self):
|
||||||
return "solutions/" + str(self.id)
|
return "solutions/" + str(self.id)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def number_result(self):
|
||||||
|
if self.test is None:
|
||||||
|
return self.result
|
||||||
|
return f"{self.result} ({self.test})"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def badge_style(self):
|
||||||
|
if self.result == CONSTS["in_queue_status"]:
|
||||||
|
return "secondary"
|
||||||
|
if self.result == CONSTS["ok_status"]:
|
||||||
|
return "success"
|
||||||
|
if self.result == CONSTS["testing_status"]:
|
||||||
|
return "info"
|
||||||
|
return "danger"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def testing_directory(self):
|
def testing_directory(self):
|
||||||
return self.directory
|
return self.directory
|
||||||
|
@ -30,6 +30,8 @@ class BaseTester:
|
|||||||
raise TestException("CE")
|
raise TestException("CE")
|
||||||
|
|
||||||
def test(self, filename):
|
def test(self, filename):
|
||||||
|
self.solution.test = int(filename)
|
||||||
|
self.solution.save()
|
||||||
code = self.solution.exec_command(
|
code = self.solution.exec_command(
|
||||||
f"< {filename} {self.command} > output.txt",
|
f"< {filename} {self.command} > output.txt",
|
||||||
timeout=self.solution.task.time_limit / 1000,
|
timeout=self.solution.task.time_limit / 1000,
|
||||||
@ -97,6 +99,7 @@ class BaseTester:
|
|||||||
self.test(test.filename)
|
self.test(test.filename)
|
||||||
self.after_test()
|
self.after_test()
|
||||||
self.solution.result = CONSTS["ok_status"]
|
self.solution.result = CONSTS["ok_status"]
|
||||||
|
self.solution.test = None
|
||||||
progress = Progress.objects.get(
|
progress = Progress.objects.get(
|
||||||
user=self.solution.user, task=self.solution.task
|
user=self.solution.user, task=self.solution.task
|
||||||
)
|
)
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<h4>
|
<h4>
|
||||||
<span class="badge badge-{% if solution.result == in_queue_status %}secondary{% else %}{% if solution.result == ok_status %}success{% else %}{% if solution.result == testing_status %}info{% else %}danger{% endif %}{% endif %}{% endif %}">{% if solution.result == testing_status %}<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="circle-notch" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="width: 20px;" class="svg-inline--fa fa-circle-notch fa-w-16 fa-spin fa-lg"><path fill="currentColor" d="M288 39.056v16.659c0 10.804 7.281 20.159 17.686 23.066C383.204 100.434 440 171.518 440 256c0 101.689-82.295 184-184 184-101.689 0-184-82.295-184-184 0-84.47 56.786-155.564 134.312-177.219C216.719 75.874 224 66.517 224 55.712V39.064c0-15.709-14.834-27.153-30.046-23.234C86.603 43.482 7.394 141.206 8.003 257.332c.72 137.052 111.477 246.956 248.531 246.667C393.255 503.711 504 392.788 504 256c0-115.633-79.14-212.779-186.211-240.236C302.678 11.889 288 23.456 288 39.056z" class=""></path></svg> {% endif %}{{ solution.result }}</span>
|
<span class="badge badge-{{ solution.badge_style }}">{% if solution.result == testing_status %}<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="circle-notch" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="width: 20px;" class="svg-inline--fa fa-circle-notch fa-w-16 fa-spin fa-lg"><path fill="currentColor" d="M288 39.056v16.659c0 10.804 7.281 20.159 17.686 23.066C383.204 100.434 440 171.518 440 256c0 101.689-82.295 184-184 184-101.689 0-184-82.295-184-184 0-84.47 56.786-155.564 134.312-177.219C216.719 75.874 224 66.517 224 55.712V39.064c0-15.709-14.834-27.153-30.046-23.234C86.603 43.482 7.394 141.206 8.003 257.332c.72 137.052 111.477 246.956 248.531 246.667C393.255 503.711 504 392.788 504 256c0-115.633-79.14-212.779-186.211-240.236C302.678 11.889 288 23.456 288 39.056z" class=""></path></svg> {% endif %}{{ solution.number_result }}</span>
|
||||||
</h4>
|
</h4>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
Loading…
Reference in New Issue
Block a user