@@ -11,6 +11,7 @@ import {
11
11
AssignmentProblem ,
12
12
AssignmentScore ,
13
13
NonContainerAutoGrader ,
14
+ ScoringType ,
14
15
Submission ,
15
16
SubmissionProblemScore ,
16
17
SubmissionScore ,
@@ -25,6 +26,7 @@ import { downloadFile, initializeMinio } from '../../fileStorage'
25
26
import { createNewLab , sendSubmission , waitForJob } from '../../autograders/leviathan.service'
26
27
import { DockerFile , LabData , LabFile , SubmissionFile } from 'leviathan-node-sdk'
27
28
import path from 'path'
29
+ import assignmentService from '../assignment/assignment.service'
28
30
29
31
async function grade ( submissionId : number ) {
30
32
const submissionModel = await submissionService . retrieve ( submissionId )
@@ -271,11 +273,27 @@ export async function callbackFailure(assignmentId: number, submissionId: number
271
273
//Currently just sets assignmentscore to the latest submission. Pulled this function out for easy future modification.
272
274
async function updateAssignmentScore ( submission : Submission , score : number ) {
273
275
const assignmentScoreModel = await assignmentScoreService . retrieveByUser ( submission . assignmentId , submission . userId )
276
+ const assignment = await assignmentService . retrieve ( submission . assignmentId , submission . courseId )
277
+
274
278
if ( assignmentScoreModel ) {
275
279
//If assignmentScore already exists, update existing entity
276
280
const assignmentScore = serializeAssignmentScore ( assignmentScoreModel )
277
281
assignmentScore . score = score
278
- assignmentScoreService . update ( assignmentScore )
282
+
283
+ // todo use scoring type in assignment entity, leaving this alone for now,
284
+ // grader endpoint needs to be refactored
285
+ switch ( assignment ! . scoringType ) {
286
+ case ScoringType . HIGHEST_SCORE :
287
+ break
288
+ case ScoringType . LATEST_SUBMISSION :
289
+ break
290
+ case ScoringType . NO_SCORE :
291
+ break
292
+ default :
293
+ break
294
+ }
295
+
296
+ await assignmentScoreService . update ( assignmentScore )
279
297
} else {
280
298
//Otherwise create a new one
281
299
const assignmentScore : AssignmentScore = {
0 commit comments