Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -37,4 +37,7 @@ public class CodeAssignmentGradingMetadataEntity {

@Column(nullable = true, columnDefinition = "TEXT")
private String feedbackTableHtml;

@Column(nullable = true)
private String lastProcessedCommitSha;
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@

import java.time.OffsetDateTime;

public record ExternalGrading(String externalUsername, String status, OffsetDateTime date, String tableHtml, Double achievedPoints, Double totalPoints) {
public record ExternalGrading(
String externalUsername,
String status,
OffsetDateTime date,
String tableHtml,
Double achievedPoints,
Double totalPoints,
String commitSha) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public List<ExternalGrading> syncGrades(final String externalAssignmentId, final
}
}

gradings.add(new ExternalGrading(username, null, submissionDate, null, achieved, total));
gradings.add(new ExternalGrading(username, null, submissionDate, null, achieved, total, null));
}

return gradings;
Expand Down Expand Up @@ -334,9 +334,10 @@ public ExternalGrading syncGradeForStudent(String repoLink, LoggedInUser current
String status = run.get("status").getAsString();
String logsUrl = run.get("logs_url").getAsString();
String lastlyTested = run.get("updated_at").getAsString();
String commitSha = run.has("head_sha") ? run.get("head_sha").getAsString() : null;

if (!status.equals("completed")){
return new ExternalGrading(null, status, OffsetDateTime.parse(lastlyTested), null, null, null);
return new ExternalGrading(null, status, OffsetDateTime.parse(lastlyTested), null, null, null, commitSha);
}

// Download logs
Expand Down Expand Up @@ -378,7 +379,7 @@ public ExternalGrading syncGradeForStudent(String repoLink, LoggedInUser current
double totalPoints = Double.parseDouble(matcher.group(1));
double maxPoints = Double.parseDouble(matcher.group(2));
String tableHtml = extractGradingTableAsHtml(logs);
return new ExternalGrading(null, status, OffsetDateTime.parse(lastlyTested), tableHtml, totalPoints, maxPoints);
return new ExternalGrading(null, status, OffsetDateTime.parse(lastlyTested), tableHtml, totalPoints, maxPoints, commitSha);
} else {
throw new ExternalPlatformConnectionException("Could not find totalPoints/maxPoints in logs.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ void testValidLogAssignmentCompletedSuccessful(final GraphQlTester tester) {
.correctness(35.0/50.0)
.hintsUsed(0)
.success(true)
.contentType(ContentProgressedEvent.ContentType.ASSIGNMENT)
.responses(responses)
.build();

Expand Down Expand Up @@ -207,6 +208,7 @@ void testValidLogAssignmentCompletedNotSuccessful(final GraphQlTester tester) {
.correctness(15.0/50.0)
.hintsUsed(0)
.success(false)
.contentType(ContentProgressedEvent.ContentType.ASSIGNMENT)
.responses(responses)
.build();

Expand Down Expand Up @@ -294,6 +296,7 @@ void testValidLogAssignmentCompletedNewPercentage(final GraphQlTester tester) {
.correctness(35.0/50.0)
.hintsUsed(0)
.success(false)
.contentType(ContentProgressedEvent.ContentType.ASSIGNMENT)
.responses(responses)
.build();

Expand Down Expand Up @@ -382,6 +385,7 @@ void testValidLogAssignmentCompletedZeroCredits(final GraphQlTester tester) {
.correctness(1.0f)
.hintsUsed(0)
.success(true)
.contentType(ContentProgressedEvent.ContentType.ASSIGNMENT)
.responses(responses)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void testStudentGetsCodeAssignmentGradingSynced(GraphQlTester tester) throws Ext
);

ExternalGrading externalGrading = new ExternalGrading("ext-user", gradingEntity.getCodeAssignmentGradingMetadata().getRepoLink(), OffsetDateTime.now(),
"<table>feedback</table>", 42.0, 60.0);
"<table>feedback</table>", 42.0, 60.0, "test-commit-sha");

when(codeAssessmentProvider.findRepository(eq(assignment.getExternalId()), any(), any())).thenReturn(gradingEntity.getCodeAssignmentGradingMetadata().getRepoLink());

Expand Down Expand Up @@ -227,7 +227,8 @@ void testStudentGetsCodeAssignmentGradingCreated(GraphQlTester tester)
OffsetDateTime.now().truncatedTo(ChronoUnit.SECONDS),
"<table>feedback</table>",
35.0,
50.0
50.0,
"test-commit-sha-2"
);
when(codeAssessmentProvider.syncGradeForStudent(eq("https://github.com/user/repo"), any()))
.thenReturn(externalGrading);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ void setUp() {

@Test
void testPublishStudentCodeSubmittedEvent_Success() throws Exception {
// Arrange
String repoUrl = "https://github.com/org/repo-student";
StudentCodeSubmission codeSubmission = createMockCodeSubmission(repoUrl);

// Create the event that would be published
StudentCodeSubmittedEvent event = StudentCodeSubmittedEvent.builder()
.studentId(codeSubmission.getStudentId())
.assignmentId(codeSubmission.getAssignmentId())
Expand All @@ -58,10 +56,8 @@ void testPublishStudentCodeSubmittedEvent_Success() throws Exception {
.branch(codeSubmission.getBranch())
.build();

// Act
topicPublisher.notifyStudentCodeSubmitted(event);

// Assert
ArgumentCaptor<StudentCodeSubmittedEvent> eventCaptor =
ArgumentCaptor.forClass(StudentCodeSubmittedEvent.class);
verify(topicPublisher, times(1)).notifyStudentCodeSubmitted(eventCaptor.capture());
Expand All @@ -80,7 +76,6 @@ void testPublishStudentCodeSubmittedEvent_Success() throws Exception {

@Test
void testCodeSubmissionEventContent_AllFieldsPresent() {
// Arrange
String repoUrl = "https://github.com/test/repo";
String commitSha = "abc123def456";
OffsetDateTime commitTime = OffsetDateTime.now();
Expand All @@ -89,7 +84,6 @@ void testCodeSubmissionEventContent_AllFieldsPresent() {
Map<String, String> files = new HashMap<>();
files.put("Test.java", "public class Test {}");

// Act
StudentCodeSubmittedEvent event = StudentCodeSubmittedEvent.builder()
.studentId(studentId)
.assignmentId(assignmentId)
Expand All @@ -101,7 +95,6 @@ void testCodeSubmissionEventContent_AllFieldsPresent() {
.branch(branch)
.build();

// Assert
assertEquals(studentId, event.getStudentId());
assertEquals(assignmentId, event.getAssignmentId());
assertEquals(courseId, event.getCourseId());
Expand All @@ -114,7 +107,6 @@ void testCodeSubmissionEventContent_AllFieldsPresent() {

@Test
void testCodeSubmission_MultipleFiles() {
// Arrange
StudentCodeSubmission codeSubmission = StudentCodeSubmission.builder()
.studentId(studentId)
.assignmentId(assignmentId)
Expand All @@ -126,7 +118,6 @@ void testCodeSubmission_MultipleFiles() {
.files(createMultipleFiles())
.build();

// Act
StudentCodeSubmittedEvent event = StudentCodeSubmittedEvent.builder()
.studentId(codeSubmission.getStudentId())
.assignmentId(codeSubmission.getAssignmentId())
Expand All @@ -138,7 +129,6 @@ void testCodeSubmission_MultipleFiles() {
.branch(codeSubmission.getBranch())
.build();

// Assert
assertNotNull(event.getFiles());
assertEquals(5, event.getFiles().size());
assertTrue(event.getFiles().containsKey("src/Main.java"));
Expand All @@ -150,7 +140,6 @@ void testCodeSubmission_MultipleFiles() {

@Test
void testCodeSubmission_EmptyFiles() {
// Arrange
StudentCodeSubmission codeSubmission = StudentCodeSubmission.builder()
.studentId(studentId)
.assignmentId(assignmentId)
Expand All @@ -162,7 +151,6 @@ void testCodeSubmission_EmptyFiles() {
.files(new HashMap<>())
.build();

// Act
StudentCodeSubmittedEvent event = StudentCodeSubmittedEvent.builder()
.studentId(codeSubmission.getStudentId())
.assignmentId(codeSubmission.getAssignmentId())
Expand All @@ -174,14 +162,12 @@ void testCodeSubmission_EmptyFiles() {
.branch(codeSubmission.getBranch())
.build();

// Assert
assertNotNull(event.getFiles());
assertTrue(event.getFiles().isEmpty());
}

@Test
void testCodeSubmission_VerifyMetadata() {
// Arrange
String repoUrl = "https://github.com/student/assignment-repo";
String commitSha = "1234567890abcdef";
OffsetDateTime timestamp = OffsetDateTime.parse("2025-12-15T10:30:00Z");
Expand All @@ -198,7 +184,6 @@ void testCodeSubmission_VerifyMetadata() {
.files(Map.of("Main.java", "code"))
.build();

// Assert
assertEquals(repoUrl, submission.getRepositoryUrl());
assertEquals(commitSha, submission.getCommitSha());
assertEquals(timestamp, submission.getCommitTimestamp());
Expand Down
Loading