Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
6743e56
Added Developer Guide doc
zoeyganzhorn Sep 4, 2025
384e3d7
Added extensionDays field to migration log
zoeyganzhorn Sep 5, 2025
536f51c
Merge branch 'main' of github.com:CSCI128/packtrain into jettzoeyExte…
jettMorrandez Sep 9, 2025
1c15a3d
adding number of days to the scoredDTO and adjusted handlescorerecived
jettMorrandez Sep 9, 2025
337bf55
set log number of extension days in handlescorereceived to dto getnum…
jettMorrandez Sep 9, 2025
ac8b017
Added a query in the MigrationTransactionLogRepo
zoeyganzhorn Sep 9, 2025
4b6a7d0
Created processExtensionApplied function in ExtensionService
zoeyganzhorn Sep 9, 2025
31c31c9
Updated postGradesToCanvasTask to use the extension service to update…
zoeyganzhorn Sep 9, 2025
0324b9a
Fixed logical error in processExtensionApplied function
zoeyganzhorn Sep 9, 2025
cfc0567
Missed a semicolon
zoeyganzhorn Sep 9, 2025
a3f409b
Fixed syntax errors
zoeyganzhorn Sep 9, 2025
c80542a
Fixing more errors
zoeyganzhorn Sep 9, 2025
34e4f5f
Fixed style issues
zoeyganzhorn Sep 9, 2025
2e291eb
implementation of process extension
jettMorrandez Sep 12, 2025
072c6fb
Trying to fix style issues
zoeyganzhorn Sep 12, 2025
2e3f3c9
Fixing white spaces issues in ExtensionService
zoeyganzhorn Sep 12, 2025
3543e32
Fixed LineLength error in MigrationService
zoeyganzhorn Sep 12, 2025
0706f7b
fixed the last style error
zoeyganzhorn Sep 12, 2025
031406e
pulled from main and solved merge conflicts
jettMorrandez Sep 19, 2025
9d07495
Merge branch 'jettzoeyExtensionApplication' of github.com:CSCI128/pac…
jettMorrandez Sep 19, 2025
52ff05a
deleted commented code
jettMorrandez Sep 19, 2025
be5a6a7
saved the late request to the repo
jettMorrandez Sep 19, 2025
df53ce6
extension service test
jettMorrandez Sep 21, 2025
e894d51
test fix
jettMorrandez Sep 21, 2025
a03a2a0
fix to test forgot mockito
jettMorrandez Sep 21, 2025
a692f9c
fix to test
jettMorrandez Sep 21, 2025
b2dea9e
fix to test
jettMorrandez Sep 21, 2025
d315cf9
fix to testforgot to mock save()
jettMorrandez Sep 21, 2025
02cb680
fix to testforgot to mock save()
jettMorrandez Sep 21, 2025
c890dcf
fix to test for svae()
jettMorrandez Sep 21, 2025
23dab5c
got rid of save
jettMorrandez Sep 21, 2025
1a6716c
added mock
jettMorrandez Sep 21, 2025
293d19e
mocked out mock
jettMorrandez Sep 21, 2025
7f3fa76
mocked out mock
jettMorrandez Sep 21, 2025
de67774
fixed extension service
jettMorrandez Sep 21, 2025
a677e5b
not sure what is wrong
jettMorrandez Sep 21, 2025
f4d4d32
Merge branch 'main' of github.com:CSCI128/packtrain into jettzoeyExte…
jettMorrandez Oct 2, 2025
86245be
Chagned @Mock to be @AutoWired for LateRequestRepo
zoeyganzhorn Oct 2, 2025
475674f
Got rid of InjectMocks in TestExtensionService
zoeyganzhorn Oct 2, 2025
7717c25
greg notes
jettMorrandez Oct 2, 2025
1c5f48c
more greg notes
jettMorrandez Oct 2, 2025
171baa9
even more greg comments
jettMorrandez Oct 2, 2025
7802a41
Merge branch 'jettzoeyExtensionApplication' of github.com:CSCI128/pac…
jettMorrandez Oct 2, 2025
f4153d3
Made changed to verifyProcessExtensionApplied test
zoeyganzhorn Oct 2, 2025
833de89
Made changes to the verifyProcessExtensionApplied Test
zoeyganzhorn Oct 2, 2025
ee6d19e
Inverted the logic in processExtensionAppied function
zoeyganzhorn Oct 2, 2025
ec70f6e
fixing style issues
zoeyganzhorn Oct 2, 2025
1677194
changed to have number days applied to be in all places
jettMorrandez Oct 6, 2025
dc285d8
Merge branch 'main' of github.com:CSCI128/packtrain into jettzoeyExte…
jettMorrandez Oct 9, 2025
d148ece
Merge branch 'jettzoeyExtensionApplication' of github.com:CSCI128/pac…
jettMorrandez Oct 9, 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
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ Packtrain is software for grading and student extension management.
src/Authentication
src/GradingPolicy
src/Migrations
src/DeveloperGuide
src/Assignments
4 changes: 4 additions & 0 deletions docs/src/DeveloperGuide.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.. _DeveloperGuide:

Developer Guide
==========================
3 changes: 3 additions & 0 deletions docs/src/GradingPolicy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ Your policy must return an object with these properties set:

**submissionMessage** *(nullable string)*
An optional message for the overall submission.

**numberExtensionDaysApplied** *(number)*
the number of extension days applied

An example for format is below:

Expand Down
5 changes: 4 additions & 1 deletion openapi/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2010,7 +2010,10 @@ components:
type: string
submissionMessage:
type: string

numberExtensionDaysApplied:
type: integer
format: int32
# add number extension days applied to match above.
PolicyDryRunResults:
properties:
policyResults:
Expand Down
7 changes: 7 additions & 0 deletions packtrain-frontend/apps/admin/src/pages/course/Policy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,13 @@ export function PolicyPage({
value={dryRunRes.policyResults.adjustedDaysLate}
disabled
/>
<NumberInput
pb={8}
label="Number extension days applied"
value={dryRunRes.policyResults.numberExtensionDaysApplied}
// make sure this is the same as open api
disabled
/>
</Group>
<Group grow>
<TextInput
Expand Down
3 changes: 2 additions & 1 deletion packtrain-policy-service/src/data/PolicyScoredDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export default class PolicyScoredDTO {
extensionStatus!: ExtensionStatus;
extensionMessage?: string;
submissionMessage?: string;
}
numberExtensionDaysApplied?: number;
}
1 change: 1 addition & 0 deletions packtrain-policy-service/src/data/ScoredDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export default class ScoredDTO {
extensionStatus!: ExtensionStatus;
extensionMessage!: string;
submissionMessage!: string;
numberExtensionDaysApplied!: number;
}
3 changes: 3 additions & 0 deletions packtrain-policy-service/src/services/policyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ function validateScoredDTO(scored: PolicyScoredDTO): string[] {
);
}

if (scored.numberExtensionDaysApplied == null){
errors.push("the number of extension days applied was not set by policy!")
}
return errors;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ public class ScoredDTO {
private LateRequestStatus extensionStatus;
private String extensionMessage;
private String submissionMessage;
private int numberExtensionDaysApplied;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make a policy server update to that this field actually gets applied.
We also need to update the docs for this

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,7 @@ public class MigrationTransactionLog {

@Column(name = "message", length = 1000)
private String message;

@Column(name = "number_extension_days")
private int extensionDays = 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ public interface MigrationTransactionLogRepo extends CrudRepository<MigrationTra
@Query("select l from migration_transaction_log l where l.migrationId = ?2 " +
"and l.cwid = ?1 order by l.revision asc")
List<MigrationTransactionLog> getByCwidAndMigrationId(String cwid, UUID migrationId);

@Query("select l from migration_transaction_log l where l.migrationId = ?1 " +
"and l.revision = (select max(l2.revision) from migration_transaction_log l2 where l2.cwid = l.cwid )")
// grabbing the latest revision from migration transaction log by migration id
// cursed subquery version (im so sorry)
List<MigrationTransactionLog> getLatestByMigrationId(UUID migrationId);
Comment on lines +20 to +24
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any tests covering this?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add stuff to the repo, use process function from migration service one to grab out and make sure we are getting back what we need, all of this goes into the same test

}
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,22 @@ public Map<String, LateRequest> getLateRequestsForAssignment(UUID assignment) {
.collect(Collectors.toUnmodifiableMap(
l -> l.getRequestingUser().getCwid(), l -> l));
}

public void processExtensionApplied(UUID extensionId, boolean extensionApplied, int extensionDays) {
LateRequest lateRequest = lateRequestRepo.getLateRequestById(extensionId);
LateRequestStatus status;
status = LateRequestStatus.IGNORED;
if (extensionApplied) {
status = LateRequestStatus.APPLIED;
}
if (lateRequest == null) {
return;
}

lateRequest.setStatus(status);
lateRequest.setDaysRequested(extensionDays);
lateRequestRepo.save(lateRequest);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ public void handleScoreReceived(User asUser, UUID migrationId, ScoredDTO dto) {
entry.setSubmissionStatus(dto.getSubmissionStatus());
entry.setScore(dto.getFinalScore());
entry.setSubmissionTime(dto.getAdjustedSubmissionTime());
entry.setExtensionDays(dto.getNumberExtensionDaysApplied());

StringBuilder msg = new StringBuilder();
Optional<LateRequest> lateRequest = extensionService.getLateRequest(entry.getExtensionId());
Expand Down Expand Up @@ -728,7 +729,7 @@ public void postGradesToCanvasTask(PostToCanvasTaskDef taskDef) {
.prepCanvasSubmissionsForPublish(String.valueOf(taskDef.getCanvasCourseId()),
taskDef.getCanvasAssignmentId());

List<MigrationTransactionLog> entries = transactionLogRepo.getAllByMigrationIdSorted(
List<MigrationTransactionLog> entries = transactionLogRepo.getLatestByMigrationId(
taskDef.getMigrationId());

log.info("Processing {} migration log entries for posting to canvas for migration '{}'",
Expand All @@ -737,6 +738,10 @@ public void postGradesToCanvasTask(PostToCanvasTaskDef taskDef) {
for (MigrationTransactionLog entry : entries) {
submissions.addSubmission(entry.getCanvasId(), entry.getMessage(), entry.getScore(),
entry.getSubmissionStatus().equals(SubmissionStatus.EXCUSED));
if (entry.getExtensionId() != null) {
extensionService.processExtensionApplied(entry.getExtensionId(),
entry.isExtensionApplied(), entry.getExtensionDays());
}
}

Optional<Progress> progress = canvasService.asUser(provider)
Expand All @@ -745,7 +750,7 @@ public void postGradesToCanvasTask(PostToCanvasTaskDef taskDef) {
if (progress.isEmpty()) {
throw new RuntimeException("Failed to post scores to Canvas!");
}

// We will probably want to periodically check in on this and then only flag this
// as completed once this is done
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,41 @@
package edu.mines.packtrain.services;

import edu.mines.packtrain.containers.PostgresTestContainer;
import edu.mines.packtrain.models.LateRequest;
import edu.mines.packtrain.models.enums.LateRequestStatus;
import edu.mines.packtrain.repositories.ExtensionRepo;
import edu.mines.packtrain.repositories.LateRequestRepo;
import edu.mines.packtrain.seeders.CourseSeeders;

import java.util.UUID;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class TestExtensionService implements PostgresTestContainer {

@Autowired ExtensionService extensionService;
@Autowired
private ExtensionService extensionService;

@Autowired
private ExtensionRepo extensionRepo;
@Autowired
private CourseSeeders courseSeeders;
@Autowired
private LateRequestRepo lateRequestRepo;

@BeforeAll
static void setupClass(){
postgres.start();
}


@AfterEach
void tearDown(){
extensionRepo.deleteAll();
Expand All @@ -38,4 +50,20 @@ void verifyGetAllExtensions(){

}

@Test
void verifyProcessExtensionApplied(){
LateRequest mockLateRequest = new LateRequest();
mockLateRequest.setDaysRequested(4);
mockLateRequest.setStatus(LateRequestStatus.IGNORED);

mockLateRequest = lateRequestRepo.save(mockLateRequest);

extensionService.processExtensionApplied(UUID.randomUUID(), true, 2);
LateRequest capturedRequest = lateRequestRepo.getLateRequestById(mockLateRequest.getId());

Assertions.assertEquals(capturedRequest.getStatus(), LateRequestStatus.APPLIED);
Assertions.assertEquals(capturedRequest.getDaysRequested(), 2);

}

}
Loading