Skip to content

Commit

Permalink
added suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonEntholzer committed Oct 31, 2024
1 parent e5f741b commit 3908163
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ private Path exportProgrammingExerciseMaterialWithStudentReposOptional(Programmi
exportErrors.add("Failed to export programming exercise repositories: " + e.getMessage());
}

exercise.setAuxiliaryRepositories(auxiliaryRepositoryRepository.findByExerciseId(exercise.getId()));

// Add problem statement as .md file
exportProblemStatementAndEmbeddedFilesAndExerciseDetails(exercise, exportErrors, exportDir.orElseThrow(), pathsToBeZipped);

Expand All @@ -188,6 +186,7 @@ protected void exportProblemStatementAndEmbeddedFilesAndExerciseDetails(Exercise
if (exercise instanceof ProgrammingExercise programmingExercise) {
// Used for a save typecast, this should always be true since this class only works with programming exercises.
programmingExerciseTaskService.replaceTestIdsWithNames(programmingExercise);
programmingExercise.setAuxiliaryRepositories(auxiliaryRepositoryRepository.findByExerciseId(exercise.getId()));
}
super.exportProblemStatementAndEmbeddedFilesAndExerciseDetails(exercise, exportErrors, exportDir, pathsToBeZipped);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
Expand Down Expand Up @@ -174,7 +175,7 @@ private void importRepositoriesFromFile(ProgrammingExercise newExercise, Path ba
Repository testRepo = gitService.getOrCheckoutRepository(new VcsRepositoryUri(newExercise.getTestRepositoryUri()), false);
List<Repository> auxiliaryRepositories = new ArrayList<>();
for (AuxiliaryRepository auxiliaryRepository : newExercise.getAuxiliaryRepositories()) {
auxiliaryRepositories.add(gitService.getOrCheckoutRepository(new VcsRepositoryUri(auxiliaryRepository.getRepositoryUri()), false));
auxiliaryRepositories.add(gitService.getOrCheckoutRepository(auxiliaryRepository.getVcsRepositoryUri(), false));
}

copyImportedExerciseContentToRepositories(templateRepo, solutionRepo, testRepo, auxiliaryRepositories, basePath);
Expand Down Expand Up @@ -216,8 +217,9 @@ private void copyImportedExerciseContentToRepositories(Repository templateRepo,
copyExerciseContentToRepository(solutionRepo, RepositoryType.SOLUTION.getName(), basePath);
copyExerciseContentToRepository(testRepo, RepositoryType.TESTS.getName(), basePath);
for (Repository auxRepo : auxiliaryRepositories) {
String auxRepoSuffix = auxRepo.getLocalPath().toString().split("-")[1];
copyExerciseContentToRepository(auxRepo, auxRepoSuffix, basePath);
String[] parts = auxRepo.getLocalPath().toString().split("-");
var auxRepoName = String.join("-", Arrays.copyOfRange(parts, 1, parts.length));
copyExerciseContentToRepository(auxRepo, auxRepoName, basePath);
}
}

Expand Down

0 comments on commit 3908163

Please sign in to comment.