Skip to content

Commit

Permalink
[BUG FIX] [MER-4117] Infinite loading and errors thrown on adaptive p…
Browse files Browse the repository at this point in the history
…ages (#5307)

* TRIAGE-1240

* trying to run the check again

* trying to run the check again
  • Loading branch information
dtiwarATS authored Dec 19, 2024
1 parent 2379d15 commit 1a28dfd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,16 @@ export const triggerCheck = createAsyncThunk(
}
//Even If the check result contains a wrong trap state and has a navigation to different screen, we should not create a new attempt for that screen because
// the student will be navigated to different screen so it does not make sense to create a new attempt for the current screen
if (!isCorrect && !doesCheckResultContainsNavigationToDifferentScreen) {
if (
!isCorrect &&
!doesCheckResultContainsNavigationToDifferentScreen &&
attempt?.hasMoreAttempts
) {
/* console.log('Incorrect, time for new attempt'); */
const { payload: newAttempt } = await dispatch(
createActivityAttempt({ sectionSlug, attemptGuid: currentActivityAttemptGuid }),
);
attempt = newAttempt;
if (attempt) attempt = newAttempt;
const updateSessionAttempt: ApplyStateOperation[] = [
{
target: 'session.attemptNumber',
Expand Down
21 changes: 17 additions & 4 deletions assets/src/apps/delivery/store/features/groups/actions/deck.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { createAsyncThunk } from '@reduxjs/toolkit';
import { ActivityState } from 'components/activities/types';
import { CapiVariableTypes } from 'adaptivity/capi';
import { applyState, setConditionsWithExpression, templatizeText } from 'adaptivity/scripting';
import {
applyState,
getValue,
setConditionsWithExpression,
templatizeText,
} from 'adaptivity/scripting';
import { handleValueExpression } from 'apps/delivery/layouts/deck/DeckLayoutFooter';
import {
getBulkActivitiesForAuthoring,
Expand Down Expand Up @@ -131,16 +136,24 @@ export const initializeActivity = createAsyncThunk(
operator: '=',
value: false,
};
const currentAttemptNumber = 1;
const isResumeMode = !!getValue('session.isResumeMode', defaultGlobalEnv);
const ongoingAttemptNumber = getValue('session.attemptNumber', defaultGlobalEnv);
const defaultActivityStartAttemptNumber = 1;
const attemptNumberOp: ApplyStateOperation = {
target: 'session.attemptNumber',
operator: '=',
value: currentAttemptNumber,
value:
isResumeMode && ongoingAttemptNumber
? ongoingAttemptNumber
: defaultActivityStartAttemptNumber,
};
const targettedAttemptNumberOp: ApplyStateOperation = {
target: `${currentSequenceId}|session.attemptNumber`,
operator: '=',
value: currentAttemptNumber,
value:
isResumeMode && ongoingAttemptNumber
? ongoingAttemptNumber
: defaultActivityStartAttemptNumber,
};
const tutorialScoreOp: ApplyStateOperation = {
target: 'session.tutorialScore',
Expand Down

0 comments on commit 1a28dfd

Please sign in to comment.