Skip to content

Commit

Permalink
change css site and use shortname to name file
Browse files Browse the repository at this point in the history
  • Loading branch information
as6325400 committed Oct 23, 2024
1 parent 74e36d9 commit dbe2363
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
5 changes: 5 additions & 0 deletions webapp/public/style_domjudge.css
Original file line number Diff line number Diff line change
Expand Up @@ -721,3 +721,8 @@ blockquote {
.editor-container:hover {
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.single-tab {
width: 100%;
display: inline-block;
}
27 changes: 13 additions & 14 deletions webapp/src/Controller/Team/SubmissionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,20 @@ public function createAction(Request $request, ?Problem $problem = null): Respon
$problem = $formPaste->get('problem')->getData();
$language = $formPaste->get('language')->getData();
$codeContent = $formPaste->get('code_content')->getData();

$problemShortName = $problem->getContestProblems()->first()->getShortName();

if ($codeContent == null || empty(trim($codeContent))) {
$this->addFlash('danger', 'No code content provided.');
return $this->redirectToRoute('team_index');
}

$tempDir = sys_get_temp_dir();
$tempFileName = sprintf(
'submission_%s_%s_%s.%s',
$user->getUsername(),
$problem->getName(),
date('Y-m-d_H-i-s'),
$saveFileDir = sys_get_temp_dir();
$saveFileName = sprintf(
'%s.%s',
$problemShortName,
$language->getExtensions()[0]
);
$tempFileName = preg_replace('/[^a-zA-Z0-9_.-]/', '_', $tempFileName);
$saveFileName = preg_replace('/[^a-zA-Z0-9_.-]/', '_', $saveFileName);

if ($language->getExtensions()[0] == 'java' || $language->getExtensions()[0] == 'kt') {
$entryPoint = $formPaste->get('entry_point')->getData() ?: null;
Expand All @@ -121,17 +120,17 @@ public function createAction(Request $request, ?Problem $problem = null): Respon
$this->addFlash('danger', 'Invalid entry point name.');
return $this->redirectToRoute('team_index');
}
$tempFileName = $entryPoint . '.' . $language->getExtensions()[0];
$saveFileName = $entryPoint . '.' . $language->getExtensions()[0];
} else {
$entryPoint = $tempFileName;
$entryPoint = $saveFileName;
}

$tempFilePath = $tempDir . DIRECTORY_SEPARATOR . $tempFileName;
file_put_contents($tempFilePath, $codeContent);
$saveFilePath = $saveFileDir . DIRECTORY_SEPARATOR . $saveFileName;
file_put_contents($saveFilePath, $codeContent);

$uploadedFile = new UploadedFile(
$tempFilePath,
$tempFileName,
$saveFilePath,
$saveFileName,
'application/octet-stream',
null,
true
Expand Down
7 changes: 0 additions & 7 deletions webapp/templates/team/submit_modal.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@
</div>
</div>

<style>
.single-tab {
width: 100%;
display: inline-block;
}
</style>

<script>
const fileInput = document.getElementById('submit_problem_code');
fileInput.addEventListener('change', (event) => {
Expand Down

0 comments on commit dbe2363

Please sign in to comment.