@@ -25,7 +25,7 @@ import {getTaskPlatformMode, recordingProgressSteps, TaskPlatformMode} from '../
2525import { TaskActionTypes , updateCurrentTestId } from '../task/task_slice' ;
2626import { LibraryTestResult } from '../task/libs/library_test_result' ;
2727import { DeferredPromise } from '../utils/app' ;
28- import { getTaskLevelTests , selectSubmissionsPaneEnabled } from './submission_selectors' ;
28+ import { getTaskLevelTests , selectSubmissionsPaneEnabled , selectTaskTests } from './submission_selectors' ;
2929import { isServerTask , isTestPublic , TaskAnswer , TaskTestGroupType } from '../task/task_types' ;
3030import { platformAnswerGraded } from '../task/platform/actionTypes' ;
3131import { getMessage } from '../lang' ;
@@ -217,7 +217,7 @@ class TaskSubmissionExecutor {
217217 }
218218
219219 * gradeAnswerServer ( parameters : PlatformTaskGradingParameters ) : Generator < any , PlatformTaskGradingResult , any > {
220- const { level , answer, answerToken, scope} = parameters ;
220+ const { answer, answerToken, scope} = parameters ;
221221 const state = yield * appSelect ( ) ;
222222 const platform = answer . platform ;
223223 const userTests = SubmissionExecutionScope . MyTests === scope ? getTaskLevelTests ( state ) . filter ( test => TaskTestGroupType . User === test . groupType ) : [ ] ;
@@ -253,7 +253,7 @@ class TaskSubmissionExecutor {
253253 const submissionId = submissionData . submissionId ;
254254 submissionExecutionTasks [ submissionIndex ] = yield * fork ( [ this , this . gradeAnswerLongPolling ] , submissionIndex , serverSubmission , submissionId ) ;
255255
256- return submissionExecutionTasks [ submissionIndex ] . result ( ) ;
256+ return submissionExecutionTasks [ submissionIndex ] . toPromise ( ) ;
257257 } catch ( ex : any ) {
258258 yield * put ( submissionUpdateTaskSubmission ( {
259259 id : submissionIndex ,
@@ -288,8 +288,30 @@ class TaskSubmissionExecutor {
288288 if ( submissionResult . compilationError ) {
289289 yield * put ( submissionChangeDisplayedError ( SubmissionErrorType . CompilationError ) ) ;
290290 } else {
291- const selectedTestId = yield * appSelect ( state => state . task . currentTestId ) ;
292- // Refresh display by showing the test id that was previously selected
291+ let selectedTestId = yield * appSelect ( state => state . task . currentTestId ) ;
292+
293+ // Refresh display by showing the first test of the submission that is failing
294+ if ( submissionResult . tests ?. length ) {
295+ const newTaskTests = yield * appSelect ( selectTaskTests ) ;
296+ let newTestId = null ;
297+ for ( let i = 0 ; i < newTaskTests . length ; i ++ ) {
298+ const submissionTestResult = submissionResult . tests . find ( test => test . testId === newTaskTests [ i ] . id ) ;
299+ if ( submissionTestResult ) {
300+ if ( null === newTestId ) {
301+ newTestId = i ;
302+ }
303+ if ( submissionResult ?. score < 1 ) {
304+ newTestId = i ;
305+ break ;
306+ }
307+ }
308+ }
309+
310+ if ( null !== newTestId ) {
311+ selectedTestId = newTestId
312+ }
313+ }
314+
293315 if ( null !== selectedTestId ) {
294316 yield * put ( updateCurrentTestId ( { testId : selectedTestId } ) ) ;
295317 }
0 commit comments