Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exam mode: Change test case default visibility to after results release date #8451

Merged
merged 98 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from 97 commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
1df3004
Fix logging in setup script
florian-glombik Dec 4, 2023
09c1c0a
Adjust the default visibility for exam exercises to after due date by…
florian-glombik Dec 6, 2023
c4911ca
Adding TODO for reset functionality
florian-glombik Dec 6, 2023
eae0daa
Adjusting logic for reset exercise
florian-glombik Dec 6, 2023
c53dc54
Fixing warning
florian-glombik Dec 6, 2023
2ebce5f
Reduce code duplication and improve code quality
florian-glombik Dec 6, 2023
6eb9e95
Fixing test case
florian-glombik Dec 6, 2023
c1d8a8d
Fixing bugs from #7738
florian-glombik Dec 7, 2023
c819440
Displaying different name for option depending on exam or normal mode
florian-glombik Dec 7, 2023
7e1f32d
Adjusting the translations
florian-glombik Dec 7, 2023
33cfe04
Improve Javadoc readability
florian-glombik Dec 7, 2023
eb325ab
Merge branch 'develop' into enhancement/exam/change-test-case-default…
florian-glombik Dec 7, 2023
e149ae9
Adding tests for utils function
florian-glombik Dec 7, 2023
4022735
Removing unused import
florian-glombik Dec 7, 2023
e44527d
Adding test for resetting the exercise
florian-glombik Dec 7, 2023
0d4f09e
Adding tests for the initial generation
florian-glombik Dec 7, 2023
fccf70a
Reducing code duplication
florian-glombik Dec 7, 2023
a013a4b
Merge branch 'develop' into enhancement/exam/change-test-case-default…
florian-glombik Dec 7, 2023
131e7f6
Merge branch 'develop' into enhancement/exam/change-test-case-default…
florian-glombik Dec 9, 2023
5cf0a35
Fix mistake in documentation
florian-glombik Dec 9, 2023
e15df52
Fixing cypress tests
florian-glombik Dec 9, 2023
384d382
Cleanup code and add javadoc
florian-glombik Dec 10, 2023
ed85943
Merge branch 'develop' into enhancement/exam/change-test-case-default…
florian-glombik Dec 10, 2023
9355cdc
Increase timeout, as test must now wait until re-configuration is pos…
florian-glombik Dec 11, 2023
d73a74f
Merge branch 'develop' into enhancement/exam/change-test-case-default…
florian-glombik Dec 11, 2023
43abeef
Fixing E2E tests by increasing timeouts
florian-glombik Dec 11, 2023
e3ac5a4
Fixing client code style tests
florian-glombik Dec 11, 2023
d094fb0
Merge branch 'develop' into enhancement/exam/change-test-case-default…
florian-glombik Dec 11, 2023
32700c2
Fixing client style
florian-glombik Dec 12, 2023
037d424
Merge remote-tracking branch 'origin/enhancement/exam/change-test-cas…
florian-glombik Dec 12, 2023
ba16995
Try to fix cypress tests failing due to "Cypress detected that you re…
florian-glombik Dec 12, 2023
ff98087
Try to fix cypress tests
florian-glombik Dec 13, 2023
e6ecd14
Merge branch 'refs/heads/develop' into enhancement/exam/change-test-c…
florian-glombik Apr 20, 2024
ad4fd19
Fixing visibility import
florian-glombik Apr 20, 2024
c38077c
Fixing renaming mistake from merge
florian-glombik Apr 20, 2024
06b6aa4
Fixing test
florian-glombik Apr 20, 2024
8146e34
Merge branch 'develop' into enhancement/exam/change-test-case-default…
florian-glombik Apr 21, 2024
eea4149
Reverting change that led to failing exercise group creation
florian-glombik Apr 21, 2024
6c5a27d
Fixing cypress tests
florian-glombik Apr 21, 2024
f2d233b
Merge branch 'develop' into enhancement/exam/change-test-case-default…
florian-glombik Apr 24, 2024
58dd132
Fixing playwright tests
florian-glombik Apr 24, 2024
68ce9f2
Merge branch 'develop' into enhancement/exam/change-test-case-default…
florian-glombik Apr 26, 2024
afe001a
Reducing Maximum Timeout amount
florian-glombik Apr 26, 2024
345b260
Update src/main/webapp/i18n/de/programmingExercise.json
florian-glombik May 1, 2024
099ede6
Merge remote-tracking branch 'origin/enhancement/exam/change-test-cas…
florian-glombik May 2, 2024
1faed70
Addressing feedback from Johannes, passing programming exercise inste…
florian-glombik May 2, 2024
a008292
Merge branch 'refs/heads/develop' into enhancement/exam/change-test-c…
florian-glombik May 8, 2024
fbe5708
Simplifying help translation
florian-glombik May 8, 2024
4e8774b
Adding toggle to setReleaseDateOfResults to after due date on exercis…
florian-glombik May 8, 2024
d67c583
Adding toggle to setReleaseDateOfResults to after due date on exercis…
florian-glombik May 8, 2024
7d5425f
artemisTranslate vs jhiTranslate
florian-glombik May 8, 2024
793b087
Only display toggle for exam imports
florian-glombik May 8, 2024
03b21fb
Simplify translation
florian-glombik May 8, 2024
c45e07f
Add todo
florian-glombik May 8, 2024
98ff6c1
Only display the option to set the test cases to after release date o…
florian-glombik May 8, 2024
bbca50e
Pass import options down to lifecycle component
florian-glombik May 8, 2024
c2750ad
Moving javadoc and make sure to pass the flag to the server when impo…
florian-glombik May 8, 2024
35d1f84
Adding todo
florian-glombik May 8, 2024
200996d
Processing setTestCaseVisibilityToAfterReleaseDateOfResults
florian-glombik May 8, 2024
7f0f984
Set test case visibility to after due date if the parameter is passed
florian-glombik May 8, 2024
656a0de
Fixing javadoc
florian-glombik May 8, 2024
f24bac3
User vs var
florian-glombik May 8, 2024
babdb3c
Renaming variable for setTestCaseVisibilityToAfterDueDate
florian-glombik May 8, 2024
0e1ce48
Update exercise creation screenshot in documentation
florian-glombik May 8, 2024
67c31e7
Updating documentation
florian-glombik May 8, 2024
db9bf28
Fixing cypress E2E test by increasing max timeout duration
florian-glombik May 10, 2024
e97bbd0
Hiding option for import from files
florian-glombik May 10, 2024
189ada7
Trying to fix client tests remote by reverting change of passing down…
florian-glombik May 10, 2024
8e3b81a
Address codeRabbit comment, simplify updateIsImportBasedOnUrl
florian-glombik May 10, 2024
9f20751
Trying to fix memory leak that only seems to occur on remote for clie…
florian-glombik May 10, 2024
3197792
Fixing client tests
florian-glombik May 10, 2024
f32f3ef
Moving type export to programming exercise model.ts
florian-glombik May 10, 2024
626ccd8
Fixing import path of ImportOptions
florian-glombik May 10, 2024
bb83c64
Moving ImportOptions interface to own file to resolve conflicts
florian-glombik May 10, 2024
3febacf
Increase timeout to reduce flakyness
florian-glombik May 10, 2024
d981897
Merge branch 'refs/heads/develop' into enhancement/exam/change-test-c…
florian-glombik May 10, 2024
0bd6d4b
Merge branch 'develop' into enhancement/exam/change-test-case-default…
florian-glombik May 10, 2024
a858094
Removing outdated comment
florian-glombik May 10, 2024
ad253b9
Remove outdated todo
florian-glombik May 10, 2024
d4c189f
Revert translation change
florian-glombik May 10, 2024
365bb78
Make test cases mutable
florian-glombik May 10, 2024
eddc6a1
Removing TODO
florian-glombik May 10, 2024
85b4b03
Merge remote-tracking branch 'origin/enhancement/exam/change-test-cas…
florian-glombik May 10, 2024
8f9507b
Adding import for HashSet
florian-glombik May 10, 2024
a8a1470
jhi-translate vs jhiTranslate
florian-glombik May 10, 2024
c9a8aff
Adding setTestCaseVisibilityToAfterDueDate to ProgrammingExerciseCrea…
florian-glombik May 10, 2024
247a85b
Re adding Translate Pipe Mock
florian-glombik May 10, 2024
a2c16af
Using jhiTranslate instead of pipe
florian-glombik May 10, 2024
e865c86
Removing mock of pipe
florian-glombik May 10, 2024
b12c5b1
Trying to fix client tests failing remotely: removing setVisibility f…
florian-glombik May 10, 2024
bdaa9c2
Merge branch 'refs/heads/develop' into enhancement/exam/change-test-c…
florian-glombik May 11, 2024
c0ea276
Merge branch 'develop' into enhancement/exam/change-test-case-default…
florian-glombik May 12, 2024
97a1be3
Merge branch 'develop' into enhancement/exam/change-test-case-default…
florian-glombik May 14, 2024
833bfee
Addressing Ramonas review
florian-glombik May 15, 2024
0e218ff
Merge branch 'develop' into enhancement/exam/change-test-case-default…
florian-glombik May 16, 2024
47bffa2
Merge branch 'develop' into enhancement/exam/change-test-case-default…
florian-glombik May 16, 2024
b594f34
Merge branch 'develop' into enhancement/exam/change-test-case-default…
florian-glombik May 17, 2024
8a56815
Merge branch 'refs/heads/develop' into enhancement/exam/change-test-c…
florian-glombik May 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/dev/cypress.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Follow these steps to create your local cypress instance:
"studentGroupName": "students",
"tutorGroupName": "tutors",
"editorGroupName": "editors",
"instructorGroupName": "instructors"
"instructorGroupName": "instructors",
"createUsers": false
}

Expand Down
Binary file modified docs/user/exams/instructor/add_exercises.png
florian-glombik marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion docs/user/exams/instructors_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ During the exam creation and configuration, you can create your exam and configu


- In the *Configure Grading* screen, you can tweak the ``weight`` of the tests, the ``bonus multiplier`` and add ``bonus points``.
- You can hide tests so that they are not executed during the exam conduction. Students can not receive feedback from hidden tests during the exam conduction.
- You can hide tests so that they are not executed during the exam conduction by setting the test case visibility to `After Release Date of Results.` Students can not receive feedback from hidden tests during the exam conduction. This option is set by default when creating new programming exercises within an exam.

.. note::
When importing exercises, the test case visibility of imported exercise will equal the visibility of the original exercise. You can adjust the test case visibility in the import `Assessment` section to be set to `After Release Date of Results`.

.. note::
If you hide all tests, the students will only be able to see if their submission compiles during the conduction. Set the ``Run Tests once after Due Date`` after the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import de.tum.in.www1.artemis.domain.enumeration.ProjectType;
import de.tum.in.www1.artemis.domain.enumeration.RepositoryType;
import de.tum.in.www1.artemis.domain.enumeration.SubmissionType;
import de.tum.in.www1.artemis.domain.enumeration.Visibility;
import de.tum.in.www1.artemis.domain.hestia.ExerciseHint;
import de.tum.in.www1.artemis.domain.hestia.ProgrammingExerciseTask;
import de.tum.in.www1.artemis.domain.participation.Participation;
Expand Down Expand Up @@ -941,4 +942,15 @@ public String getBuildScript() {
public void setBuildScript(String buildScript) {
this.buildScript = buildScript;
}

/**
* In course exercises students shall receive immediate feedback. {@link Visibility#ALWAYS}
* In Exams misconfiguration and leaking test results to students during an exam shall be prevented by the default setting. {@link Visibility#AFTER_DUE_DATE}
*
* @return default visibility {@link Visibility} set after the first execution of a test case
* or when resetting the test case settings
*/
public Visibility getDefaultTestCaseVisibility() {
return this.isExamExercise() ? Visibility.AFTER_DUE_DATE : Visibility.ALWAYS;
}
florian-glombik marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ private void addExercisesToExerciseGroup(ExerciseGroup exerciseGroupToCopy, Exer
originalProgrammingExercise.setTasks(new ArrayList<>(templateTasks));

prepareProgrammingExerciseForExamImport((ProgrammingExercise) exerciseToCopy);
yield Optional.of(programmingExerciseImportService.importProgrammingExercise(originalProgrammingExercise, (ProgrammingExercise) exerciseToCopy, false, false));
yield Optional
.of(programmingExerciseImportService.importProgrammingExercise(originalProgrammingExercise, (ProgrammingExercise) exerciseToCopy, false, false, false));
florian-glombik marked this conversation as resolved.
Show resolved Hide resolved
}

case FILE_UPLOAD -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private String removeCIDirectoriesFromPath(String sourcePath) {
* Transforms static code analysis reports to feedback objects.
* As we reuse the Feedback entity to store static code analysis findings, a mapping to those attributes
* has to be defined, violating the first normal form.
* <p>
* <br>
* Mapping:
* - text: STATIC_CODE_ANALYSIS_FEEDBACK_IDENTIFIER
* - reference: Tool
Expand Down Expand Up @@ -353,10 +353,12 @@ public void setTestCaseType(Set<ProgrammingExerciseTestCase> testCases, Programm
}

private Set<ProgrammingExerciseTestCase> getTestCasesFromBuildResult(AbstractBuildResultNotificationDTO buildResult, ProgrammingExercise exercise) {
Visibility defaultVisibility = exercise.getDefaultTestCaseVisibility();

return buildResult.getBuildJobs().stream().flatMap(job -> Stream.concat(job.getFailedTests().stream(), job.getSuccessfulTests().stream()))
// we use default values for weight, bonus multiplier and bonus points
.map(testCase -> new ProgrammingExerciseTestCase().testName(testCase.getName()).weight(1.0).bonusMultiplier(1.0).bonusPoints(0.0).exercise(exercise).active(true)
.visibility(Visibility.ALWAYS))
.visibility(defaultVisibility))
.collect(Collectors.toSet());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

import org.eclipse.jgit.api.errors.GitAPIException;
import org.slf4j.Logger;
Expand All @@ -20,12 +22,15 @@

import de.tum.in.www1.artemis.domain.AuxiliaryRepository;
import de.tum.in.www1.artemis.domain.ProgrammingExercise;
import de.tum.in.www1.artemis.domain.ProgrammingExerciseTestCase;
import de.tum.in.www1.artemis.domain.Repository;
import de.tum.in.www1.artemis.domain.User;
import de.tum.in.www1.artemis.domain.VcsRepositoryUri;
import de.tum.in.www1.artemis.domain.enumeration.BuildPlanType;
import de.tum.in.www1.artemis.domain.enumeration.RepositoryType;
import de.tum.in.www1.artemis.domain.enumeration.Visibility;
import de.tum.in.www1.artemis.repository.AuxiliaryRepositoryRepository;
import de.tum.in.www1.artemis.repository.ProgrammingExerciseTestCaseRepository;
import de.tum.in.www1.artemis.repository.UserRepository;
import de.tum.in.www1.artemis.service.FileService;
import de.tum.in.www1.artemis.service.UriService;
Expand Down Expand Up @@ -65,11 +70,13 @@ public class ProgrammingExerciseImportService {

private final ProgrammingExerciseImportBasicService programmingExerciseImportBasicService;

private final ProgrammingExerciseTestCaseRepository programmingExerciseTestCaseRepository;

public ProgrammingExerciseImportService(Optional<VersionControlService> versionControlService, Optional<ContinuousIntegrationService> continuousIntegrationService,
Optional<ContinuousIntegrationTriggerService> continuousIntegrationTriggerService, ProgrammingExerciseService programmingExerciseService,
ProgrammingExerciseTaskService programmingExerciseTaskService, GitService gitService, FileService fileService, UserRepository userRepository,
AuxiliaryRepositoryRepository auxiliaryRepositoryRepository, UriService uriService, TemplateUpgradePolicyService templateUpgradePolicyService,
ProgrammingExerciseImportBasicService programmingExerciseImportBasicService) {
ProgrammingExerciseImportBasicService programmingExerciseImportBasicService, ProgrammingExerciseTestCaseRepository programmingExerciseTestCaseRepository) {
this.versionControlService = versionControlService;
this.continuousIntegrationService = continuousIntegrationService;
this.continuousIntegrationTriggerService = continuousIntegrationTriggerService;
Expand All @@ -82,6 +89,7 @@ public ProgrammingExerciseImportService(Optional<VersionControlService> versionC
this.uriService = uriService;
this.templateUpgradePolicyService = templateUpgradePolicyService;
this.programmingExerciseImportBasicService = programmingExerciseImportBasicService;
this.programmingExerciseTestCaseRepository = programmingExerciseTestCaseRepository;
}

/**
Expand Down Expand Up @@ -271,14 +279,15 @@ private void adjustProjectName(Map<String, String> replacements, String projectK
* Method to import a programming exercise, including all base build plans (template, solution) and repositories (template, solution, test).
* Referenced entities, s.a. the test cases or the hints will get cloned and assigned a new id.
*
* @param originalProgrammingExercise the Programming Exercise which should be used as a blueprint
* @param newProgrammingExercise The new exercise already containing values which should not get copied, i.e. overwritten
* @param updateTemplate if the template files should be updated
* @param recreateBuildPlans if the build plans should be recreated
* @param originalProgrammingExercise the Programming Exercise which should be used as a blueprint
* @param newProgrammingExercise The new exercise already containing values which should not get copied, i.e. overwritten
* @param updateTemplate if the template files should be updated
* @param recreateBuildPlans if the build plans should be recreated
* @param setTestCaseVisibilityToAfterDueDate if the test case visibility should be set to {@link Visibility#AFTER_DUE_DATE}
* @return the imported programming exercise
*/
public ProgrammingExercise importProgrammingExercise(ProgrammingExercise originalProgrammingExercise, ProgrammingExercise newProgrammingExercise, boolean updateTemplate,
boolean recreateBuildPlans) throws JsonProcessingException {
boolean recreateBuildPlans, boolean setTestCaseVisibilityToAfterDueDate) throws JsonProcessingException {
// remove all non-alphanumeric characters from the short name. This gets already done in the client, but we do it again here to be sure
newProgrammingExercise.setShortName(newProgrammingExercise.getShortName().replaceAll("[^a-zA-Z0-9]", ""));
newProgrammingExercise.generateAndSetProjectKey();
Expand All @@ -292,6 +301,15 @@ public ProgrammingExercise importProgrammingExercise(ProgrammingExercise origina
newProgrammingExercise = programmingExerciseImportBasicService.importProgrammingExerciseBasis(originalProgrammingExercise, newProgrammingExercise);
importRepositories(originalProgrammingExercise, newProgrammingExercise);

if (setTestCaseVisibilityToAfterDueDate) {
Set<ProgrammingExerciseTestCase> testCases = this.programmingExerciseTestCaseRepository.findByExerciseId(newProgrammingExercise.getId());
for (ProgrammingExerciseTestCase testCase : testCases) {
testCase.setVisibility(Visibility.AFTER_DUE_DATE);
}
List<ProgrammingExerciseTestCase> updatedTestCases = programmingExerciseTestCaseRepository.saveAll(testCases);
newProgrammingExercise.setTestCases(new HashSet<>(updatedTestCases));
}

// Update the template files
if (updateTemplate) {
TemplateUpgradeService upgradeService = templateUpgradePolicyService.getUpgradeService(newProgrammingExercise.getProgrammingLanguage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import de.tum.in.www1.artemis.domain.ProgrammingExercise;
import de.tum.in.www1.artemis.domain.ProgrammingExerciseTestCase;
import de.tum.in.www1.artemis.domain.User;
import de.tum.in.www1.artemis.domain.enumeration.Visibility;
import de.tum.in.www1.artemis.repository.ProgrammingExerciseRepository;
import de.tum.in.www1.artemis.repository.ProgrammingExerciseTestCaseRepository;
import de.tum.in.www1.artemis.service.hestia.ProgrammingExerciseTaskService;
Expand Down Expand Up @@ -125,21 +124,21 @@ private static void validateTestCase(ProgrammingExerciseTestCase testCase) {
/**
* Reset all tests to their initial configuration
*
* @param exerciseId to find exercise test cases
* @param programmingExercise that shall be reset
* @return test cases that have been reset
*/
public List<ProgrammingExerciseTestCase> reset(Long exerciseId) {
Set<ProgrammingExerciseTestCase> testCases = this.testCaseRepository.findByExerciseId(exerciseId);
public List<ProgrammingExerciseTestCase> reset(ProgrammingExercise programmingExercise) {
Set<ProgrammingExerciseTestCase> testCases = this.testCaseRepository.findByExerciseId(programmingExercise.getId());
for (ProgrammingExerciseTestCase testCase : testCases) {
testCase.setWeight(1.0);
testCase.setBonusMultiplier(1.0);
testCase.setBonusPoints(0.0);
testCase.setVisibility(Visibility.ALWAYS);
testCase.setVisibility(programmingExercise.getDefaultTestCaseVisibility());
}
List<ProgrammingExerciseTestCase> updatedTestCases = testCaseRepository.saveAll(testCases);

// The tests' weights were updated. We use this flag to inform the instructor about outdated student results.
programmingTriggerService.setTestCasesChangedAndTriggerTestCaseUpdate(exerciseId);
programmingTriggerService.setTestCasesChangedAndTriggerTestCaseUpdate(programmingExercise.getId());
return updatedTestCases;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import de.tum.in.www1.artemis.domain.ProgrammingExercise;
import de.tum.in.www1.artemis.domain.User;
import de.tum.in.www1.artemis.domain.enumeration.RepositoryType;
import de.tum.in.www1.artemis.domain.enumeration.Visibility;
import de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseStudentParticipation;
import de.tum.in.www1.artemis.domain.participation.StudentParticipation;
import de.tum.in.www1.artemis.repository.AuxiliaryRepositoryRepository;
Expand Down Expand Up @@ -166,21 +167,23 @@ private void validateStaticCodeAnalysisSettings(ProgrammingExercise programmingE
* This will import the whole exercise, including all base build plans (template, solution) and repositories
* (template, solution, test). Referenced entities, s.a. the test cases or the hints will get cloned and assigned
* a new id. For a concrete list of what gets copied and what not have a look
* at {@link ProgrammingExerciseImportService#importProgrammingExercise(ProgrammingExercise, ProgrammingExercise, boolean, boolean)}
* at {@link ProgrammingExerciseImportService#importProgrammingExercise(ProgrammingExercise, ProgrammingExercise, boolean, boolean, boolean)}
*
* @param sourceExerciseId The ID of the original exercise which should get imported
* @param newExercise The new exercise containing values that should get overwritten in the imported exercise, s.a. the title or difficulty
* @param recreateBuildPlans Option determining whether the build plans should be copied or re-created from scratch
* @param updateTemplate Option determining whether the template files should be updated with the most recent template version
* @param sourceExerciseId The ID of the original exercise which should get imported
* @param newExercise The new exercise containing values that should get overwritten in the imported exercise, s.a. the title or difficulty
* @param recreateBuildPlans Option determining whether the build plans should be copied or re-created from scratch
* @param updateTemplate Option determining whether the template files should be updated with the most recent template version
* @param setTestCaseVisibilityToAfterDueDate Option determining whether the test case visibility should be set to {@link Visibility#AFTER_DUE_DATE}
* @return The imported exercise (200), a not found error (404) if the template does not exist, or a forbidden error
* (403) if the user is not at least an instructor in the target course.
* @see ProgrammingExerciseImportService#importProgrammingExercise(ProgrammingExercise, ProgrammingExercise, boolean, boolean)
* @see ProgrammingExerciseImportService#importProgrammingExercise(ProgrammingExercise, ProgrammingExercise, boolean, boolean, boolean)
*/
@PostMapping("programming-exercises/import/{sourceExerciseId}")
@EnforceAtLeastEditor
@FeatureToggle(Feature.ProgrammingExercises)
public ResponseEntity<ProgrammingExercise> importProgrammingExercise(@PathVariable long sourceExerciseId, @RequestBody ProgrammingExercise newExercise,
@RequestParam(defaultValue = "false") boolean recreateBuildPlans, @RequestParam(defaultValue = "false") boolean updateTemplate) throws JsonProcessingException {
@RequestParam(defaultValue = "false") boolean recreateBuildPlans, @RequestParam(defaultValue = "false") boolean updateTemplate,
@RequestParam(defaultValue = "false") boolean setTestCaseVisibilityToAfterDueDate) throws JsonProcessingException {
if (sourceExerciseId < 0) {
throw new BadRequestAlertException("Invalid source id when importing programming exercises", ENTITY_NAME, "invalidSourceExerciseId");
}
Expand All @@ -194,7 +197,7 @@ public ResponseEntity<ProgrammingExercise> importProgrammingExercise(@PathVariab
newExercise.validateManualFeedbackSettings();
validateStaticCodeAnalysisSettings(newExercise);

final var user = userRepository.getUserWithGroupsAndAuthorities();
final User user = userRepository.getUserWithGroupsAndAuthorities();
Course course = courseService.retrieveCourseOverExerciseGroupOrCourseId(newExercise);
authCheckService.checkHasAtLeastRoleInCourseElseThrow(Role.EDITOR, course, user);

Expand Down Expand Up @@ -241,7 +244,7 @@ public ResponseEntity<ProgrammingExercise> importProgrammingExercise(@PathVariab

try {
ProgrammingExercise importedProgrammingExercise = programmingExerciseImportService.importProgrammingExercise(originalProgrammingExercise, newExercise, updateTemplate,
recreateBuildPlans);
recreateBuildPlans, setTestCaseVisibilityToAfterDueDate);

// remove certain properties which are not relevant for the client to keep the response small
importedProgrammingExercise.setTestCases(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import de.tum.in.www1.artemis.domain.ProgrammingExercise;
import de.tum.in.www1.artemis.domain.ProgrammingExerciseTestCase;
import de.tum.in.www1.artemis.domain.User;
import de.tum.in.www1.artemis.repository.ProgrammingExerciseRepository;
import de.tum.in.www1.artemis.repository.ProgrammingExerciseTestCaseRepository;
import de.tum.in.www1.artemis.repository.UserRepository;
Expand Down Expand Up @@ -120,13 +122,13 @@ public ResponseEntity<Set<ProgrammingExerciseTestCase>> updateTestCases(@PathVar
@EnforceAtLeastEditor
public ResponseEntity<List<ProgrammingExerciseTestCase>> resetTestCases(@PathVariable Long exerciseId) {
log.debug("REST request to reset the test case weights of exercise {}", exerciseId);
var programmingExercise = programmingExerciseRepository.findByIdElseThrow(exerciseId);
var user = userRepository.getUserWithGroupsAndAuthorities();
ProgrammingExercise programmingExercise = programmingExerciseRepository.findByIdElseThrow(exerciseId);
User user = userRepository.getUserWithGroupsAndAuthorities();

authCheckService.checkHasAtLeastRoleForExerciseElseThrow(Role.EDITOR, programmingExercise, user);
programmingExerciseTestCaseService.logTestCaseReset(user, programmingExercise, programmingExercise.getCourseViaExerciseGroupOrCourseMember());

List<ProgrammingExerciseTestCase> testCases = programmingExerciseTestCaseService.reset(exerciseId);
List<ProgrammingExerciseTestCase> testCases = programmingExerciseTestCaseService.reset(programmingExercise);
return ResponseEntity.ok(testCases);
}
}
Loading
Loading