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

Programming exercises: Add ProgrammingExercise by ProjectKey endpoint #9406

Open
wants to merge 67 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
5dec295
enable bearer authentication
janthoXO Oct 1, 2024
fc69fca
Add ProgrammingExercise by ProjectKey endpoint
janthoXO Oct 1, 2024
b447b28
Add re-key endpoint
janthoXO Oct 1, 2024
a3d0fbb
Implement rabbit feedback
janthoXO Oct 2, 2024
83ef1a5
check for access to exercise
janthoXO Oct 2, 2024
069f2eb
Merge branch 'feature/bearer-support' of github.com:ls1intum/Artemis …
janthoXO Oct 4, 2024
39e4bad
make token theia specific
janthoXO Oct 4, 2024
ddd8802
fix conversion from day to millis
janthoXO Oct 4, 2024
07afea2
only respond as cookie if asked for
janthoXO Oct 4, 2024
b59f8ad
fix class cast error for websockets
janthoXO Oct 5, 2024
896fd4c
let login return json with token
janthoXO Oct 7, 2024
490692e
add @param to docs
janthoXO Oct 25, 2024
056fcc9
merge develop
janthoXO Oct 26, 2024
2e247db
add server test for bearer token
janthoXO Nov 6, 2024
e8bde67
Merge branch 'develop' into feature/bearer-support
iyannsch Nov 7, 2024
c36c6ec
Merge branch 'develop' into feature/re-key
iyannsch Nov 7, 2024
8743e73
Merge branch 'feature/bearer-support' of github.com:ls1intum/Artemis …
iyannsch Nov 7, 2024
02e63b7
change theia token to general tool token endpoint
janthoXO Nov 8, 2024
44ca43c
Apply suggestions from code review
janthoXO Nov 8, 2024
6cab497
add tool token annotation
janthoXO Nov 9, 2024
e2bb2d0
Merge remote-tracking branch 'origin/feature/re-key' into feature/re-key
janthoXO Nov 9, 2024
6e61b26
move interceptor registration
janthoXO Nov 9, 2024
149a53a
add tool token option to login
janthoXO Nov 11, 2024
b0ed73d
change filter chain to only accept one auth method
janthoXO Nov 11, 2024
6b19a87
Merge remote-tracking branch 'origin/feature/bearer-support' into fea…
janthoXO Nov 11, 2024
8df1a6b
write filter a bit nicer
janthoXO Nov 11, 2024
7fe83a9
Merge branch 'feature/bearer-support' of github.com:ls1intum/Artemis …
janthoXO Nov 12, 2024
9f61018
annotate endpoints required by Scorpio
janthoXO Nov 12, 2024
7d3b311
Merge branch 'feature/re-key' of github.com:ls1intum/Artemis into fea…
janthoXO Nov 12, 2024
932ae63
only allow scorpio tokens
janthoXO Nov 12, 2024
5908f73
change bad request behaviour
janthoXO Nov 12, 2024
5c7ef80
Merge branch 'feature/re-key' of github.com:ls1intum/Artemis into fea…
janthoXO Nov 12, 2024
288a1eb
Merge branch 'develop' of github.com:ls1intum/Artemis into feature/be…
iyannsch Nov 18, 2024
81f4739
Merge branch 'develop' of github.com:ls1intum/Artemis into feature/re…
iyannsch Nov 18, 2024
7a69620
fix server tests
Nov 19, 2024
5803813
Merge remote-tracking branch 'origin/feature/re-key' into feature/re-key
Nov 19, 2024
1cf7281
Merge branch 'develop' of github.com:ls1intum/Artemis into feature/be…
Nov 19, 2024
4dabd91
Merge branch 'feature/bearer-support' of github.com:ls1intum/Artemis …
Nov 19, 2024
52b816b
Merge branch 'feature/bearer-support' of github.com:ls1intum/Artemis …
Nov 19, 2024
9ca745b
adjust tests
Nov 19, 2024
277f8b1
merge from bearer support
Nov 19, 2024
3e93d8c
include rabbit feedback
Nov 19, 2024
8715557
Merge branch 'feature/bearer-support' of github.com:ls1intum/Artemis …
Nov 19, 2024
ca0aa32
include test for allowedTools annotation
Nov 20, 2024
f2f2851
change from Date to ZonedDateTime
Nov 20, 2024
fe7af6d
use system.currenttimemillis instead of zonedtimedate
Nov 20, 2024
28d0c44
Merge branch 'develop' of github.com:ls1intum/Artemis into feature/re…
Nov 20, 2024
1b257ed
allow scorpio to get vcs access token
Nov 20, 2024
e57a661
allow login and logout with scorpio
Nov 26, 2024
a3e0e63
Merge branch 'feature/re-key' of github.com:ls1intum/Artemis into fea…
Nov 26, 2024
f843afa
add server test
Nov 26, 2024
7172f9c
Merge branch 'develop' of github.com:ls1intum/Artemis into feature/be…
iyannsch Nov 26, 2024
30a8652
Merge branch 'feature/bearer-support' into feature/re-key
iyannsch Nov 26, 2024
44489c3
allow scorpio to fetch feedback
janthoXO Dec 5, 2024
cc95100
fetch programming exercise with results
janthoXO Dec 6, 2024
504b2d3
merge
Dec 9, 2024
02c62a5
Merge branch 'develop' into feature/re-key
janthoXO Dec 10, 2024
2214886
Merge branch 'develop' into feature/re-key
iyannsch Dec 13, 2024
49e988f
Merge branch 'develop' into feature/re-key
janthoXO Dec 21, 2024
62ebee9
allow plantUml for scorpio token
janthoXO Jan 6, 2025
3f8288d
Merge branch 'develop' of github.com:ls1intum/Artemis into feature/re…
janthoXO Jan 7, 2025
1a31996
limit tooltoken to api and not public api
janthoXO Jan 7, 2025
60ff240
Merge branch 'feature/re-key' of github.com:ls1intum/Artemis into fea…
janthoXO Jan 7, 2025
e9bb853
readd getClaim
janthoXO Jan 7, 2025
bb5fbca
Merge branch 'feature/re-key' of github.com:ls1intum/Artemis into fea…
janthoXO Jan 7, 2025
649a2d3
Merge branch 'develop' into feature/programming-exercise-by-projectkey
janthoXO Jan 21, 2025
e4abb95
use already existing query for project key query
janthoXO Jan 21, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,19 @@
import de.tum.cit.aet.artemis.core.domain.User;
import de.tum.cit.aet.artemis.core.dto.SearchResultPageDTO;
import de.tum.cit.aet.artemis.core.dto.pageablesearch.SearchTermPageableSearchDTO;
import de.tum.cit.aet.artemis.core.exception.AccessForbiddenException;
import de.tum.cit.aet.artemis.core.exception.BadRequestAlertException;
import de.tum.cit.aet.artemis.core.exception.ConflictException;
import de.tum.cit.aet.artemis.core.exception.ContinuousIntegrationException;
import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException;
import de.tum.cit.aet.artemis.core.repository.CourseRepository;
import de.tum.cit.aet.artemis.core.repository.UserRepository;
import de.tum.cit.aet.artemis.core.security.Role;
import de.tum.cit.aet.artemis.core.security.allowedTools.AllowedTools;
import de.tum.cit.aet.artemis.core.security.allowedTools.ToolTokenType;
import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastEditor;
import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastInstructor;
import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastStudent;
import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastTutor;
import de.tum.cit.aet.artemis.core.security.annotations.enforceRoleInExercise.EnforceAtLeastTutorInExercise;
import de.tum.cit.aet.artemis.core.service.AuthorizationCheckService;
Expand Down Expand Up @@ -547,6 +551,36 @@ public ResponseEntity<ProgrammingExercise> getProgrammingExerciseWithAuxiliaryRe
return ResponseEntity.ok(programmingExercise);
}

/**
* GET /programming-exercises/project-key/:projectKey : Queries a programming exercise by its project key.
*
*
* @param projectKey the project key of the programming exercise
*
* @return the ProgrammingExercise with this project key in an ResponseEntity or 404 Not Found if no exercise exists. It includes the students participation, submissions,
* results and feedbacks.
*/
@GetMapping("programming-exercises/project-key/{projectKey}")
@EnforceAtLeastStudent
@AllowedTools(ToolTokenType.SCORPIO)
public ResponseEntity<ProgrammingExercise> getExerciseByProjectKey(@PathVariable String projectKey) {
User user = userRepository.getUserWithGroupsAndAuthorities();

final ProgrammingExercise exercise = programmingExerciseRepository.findAllByProjectKey(projectKey).stream().findAny()
.orElseThrow(() -> new EntityNotFoundException("ProgrammingExercise", projectKey));

if (!authCheckService.isAllowedToSeeExercise(exercise, user)) {
throw new AccessForbiddenException("You are not allowed to access this exercise");
}

studentParticipationRepository.findByExerciseIdAndStudentIdAndTestRunWithEagerSubmissionsResultsFeedbacksTestCases(exercise.getId(), user.getId(), false)
.ifPresent(participation -> {
exercise.setStudentParticipations(Set.of(participation));
});

return ResponseEntity.ok(exercise);
}

/**
* DELETE /programming-exercises/:id : delete the "id" programmingExercise.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,32 @@ void testFindRelevantParticipations() {
}
}

@Test
@WithMockUser(username = TEST_PREFIX + "student1", roles = "USER")
void testGetProgrammingExerciseByProjectKey() throws Exception {
Course course = programmingExerciseUtilService.addCourseWithOneProgrammingExercise();
ProgrammingExercise programmingExercise = (ProgrammingExercise) course.getExercises().stream().findFirst().orElseThrow();

ProgrammingExercise programmingExerciseByProjectKey = request.get("/api/programming-exercises/project-key/" + programmingExercise.getProjectKey(), HttpStatus.OK,
ProgrammingExercise.class);
assertThat(programmingExerciseByProjectKey).isEqualTo(programmingExercise);
assertThat(programmingExerciseByProjectKey.getStudentParticipations()).isEmpty();
}

@Test
@WithMockUser(username = TEST_PREFIX + "student1", roles = "USER")
void testGetProgrammingExerciseByProjectKeyWithParticipation() throws Exception {
Course course = programmingExerciseUtilService.addCourseWithOneProgrammingExercise();
ProgrammingExercise programmingExercise = (ProgrammingExercise) course.getExercises().stream().findFirst().orElseThrow();
ProgrammingExerciseStudentParticipation participation = participationUtilService.addStudentParticipationForProgrammingExercise(programmingExercise,
TEST_PREFIX + "student1");

ProgrammingExercise programmingExerciseByProjectKey = request.get("/api/programming-exercises/project-key/" + programmingExercise.getProjectKey(), HttpStatus.OK,
ProgrammingExercise.class);
assertThat(programmingExerciseByProjectKey).isEqualTo(programmingExercise);
assertThat(programmingExerciseByProjectKey.getStudentParticipations().contains(participation)).isTrue();
}

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void testDeleteProgrammingExerciseChannel() throws Exception {
Expand Down
Loading