diff --git a/webapp/src/Controller/Jury/SubmissionController.php b/webapp/src/Controller/Jury/SubmissionController.php index 0bec479332..f145a19f3c 100644 --- a/webapp/src/Controller/Jury/SubmissionController.php +++ b/webapp/src/Controller/Jury/SubmissionController.php @@ -1207,13 +1207,17 @@ public function verifyShadowDifferenceAction( * @param SubmissionFile[] $files * @param SubmissionFile[] $oldFiles * @return array{'changed': string[], 'changedfiles': array, - * 'unchanged': string[], 'added': string[], 'removed': string[]} + * 'unchanged': string[], 'added': string[], 'removed': string[], + * 'unchangedfiles' : array, + * 'addedfiles' : array} */ protected function determineFileChanged(array $files, array $oldFiles): array { $result = [ 'changed' => [], 'changedfiles' => [], // These will be shown, so we will add pairs of files here. + 'unchangedfiles' => [], + 'addedfiles' => [], 'unchanged' => [], ]; @@ -1223,16 +1227,22 @@ protected function determineFileChanged(array $files, array $oldFiles): array $result['removed'] = array_diff($oldFilenames, $newFilenames); foreach ($files as $newfile) { + $isNewFile = true; foreach ($oldFiles as $oldFile) { if ($newfile->getFilename() === $oldFile->getFilename()) { + $isNewFile = false; if ($oldFile->getSourcecode() === $newfile->getSourcecode()) { $result['unchanged'][] = $newfile->getFilename(); + $result['unchangedfiles'][] = $newfile; } else { $result['changed'][] = $newfile->getFilename(); $result['changedfiles'][] = [$newfile, $oldFile]; } } } + if($isNewFile) { + $result['addedfiles'][] = $newfile; + } } // Special case: if there's just a single file (before and after) that has been renamed, use that for diffing. diff --git a/webapp/templates/jury/partials/submission_diff.html.twig b/webapp/templates/jury/partials/submission_diff.html.twig index 051db3baa0..baaabc96e4 100644 --- a/webapp/templates/jury/partials/submission_diff.html.twig +++ b/webapp/templates/jury/partials/submission_diff.html.twig @@ -18,7 +18,6 @@ {% endif %} -
{%- for filePair in oldFileStats.changedfiles %} -
- - Download - - {% if allowEdit %} +
+ + {{ showDiff("diff" ~ filePair.1.submitfileid, filePair.0, filePair.1) }}
- -
- {{ showDiff("diff" ~ filePair.1.submitfileid, filePair.0, filePair.1) }} +
+ + Download + + {% if allowEdit %} + + Edit + + {% endif %} +
+
+ {%- endfor %} + {%- for file in oldFileStats.addedfiles %} +
+
+ + Download + + {% if allowEdit %} + + Edit + + {% endif %} +
{%- endfor %}