Skip to content

Commit b9bf0b2

Browse files
fix: test data api updates
1 parent b1584f6 commit b9bf0b2

File tree

4 files changed

+118
-37
lines changed

4 files changed

+118
-37
lines changed

src/data/services/lms/fakeData/dataStates.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { StrictDict } from '@edx/react-unit-test-utils';
2-
import oraConfig from './oraConfig';
2+
import { routeSteps } from 'data/services/lms/constants';
33
import pageData from './pageData';
44

55
export const viewKeys = StrictDict({
66
xblock: 'xblock',
77
submission: 'submission',
8-
training: 'student_training',
8+
studentTraining: 'student_training',
99
self: 'self_assessment',
1010
peer: 'peer_assessment',
1111
myGrades: 'my_grades',
@@ -14,7 +14,7 @@ export const viewKeys = StrictDict({
1414
export const progressKeys = StrictDict({
1515
unsaved: 'unsaved',
1616
saved: 'saved',
17-
training: 'training',
17+
studentTraining: 'studentTraining',
1818
self: 'self',
1919
peer: 'peer',
2020
peerWaiting: 'peerWaiting',
@@ -25,7 +25,7 @@ export const progressKeys = StrictDict({
2525
export const progressStates = {
2626
unsaved: pageData.progressStates.submission,
2727
saved: pageData.progressStates.submission,
28-
training: pageData.progressStates.training(0),
28+
studentTraining: pageData.progressStates.training({ numCompleted: 0 }),
2929
self: pageData.progressStates.self,
3030
peer: pageData.progressStates.peer(),
3131
peerWaiting: pageData.progressStates.peer({ numCompleted: 1, isWaiting: true }),
@@ -37,7 +37,7 @@ export const submissionStatesByView = {
3737
[viewKeys.xblock]: null,
3838
[viewKeys.submission]: pageData.submissionStates.individualSubmission,
3939
[viewKeys.self]: pageData.submissionStates.individualSubmission,
40-
[viewKeys.training]: pageData.submissionStates.individualSubmission,
40+
[viewKeys.studentTraining]: pageData.submissionStates.individualSubmission,
4141
[viewKeys.peer]: pageData.submissionStates.individualSubmission,
4242
[viewKeys.myGrades]: pageData.submissionStates.individualSubmission,
4343
};
@@ -46,15 +46,21 @@ export const assessmentStatesByView = {
4646
[viewKeys.xblock]: null,
4747
[viewKeys.submission]: null,
4848
[viewKeys.self]: null,
49-
[viewKeys.training]: null,
49+
[viewKeys.studentTraining]: null,
5050
[viewKeys.peer]: null,
5151
[viewKeys.myGrades]: {
5252
effectiveAssessmentType: 'staff',
5353
...pageData.assessmentStates.graded,
5454
},
5555
};
5656

57-
export const loadState = ({ view, progressKey }) => {
57+
export const loadState = (opts) => {
58+
const { view } = opts;
59+
let progressKey = opts.progressKey || routeSteps[view];
60+
if (progressKey === routeSteps.submission) {
61+
progressKey = progressKeys.unsaved;
62+
}
63+
5864
const state = {
5965
progress: progressStates[progressKey],
6066
submission: submissionStatesByView[view],
@@ -63,5 +69,10 @@ export const loadState = ({ view, progressKey }) => {
6369
if (view === viewKeys.submission && progressKey === progressKeys.unsaved) {
6470
state.submission = pageData.submissionStates.emptySubmission;
6571
}
72+
console.log({
73+
progressKey,
74+
view,
75+
state,
76+
});
6677
return state;
6778
};

src/data/services/lms/fakeData/oraConfig.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,17 @@ const rubricConfig = {
7373
],
7474
};
7575

76-
const assessmentSteps = {
77-
order: ['practice', 'self', 'peer', 'staff'],
76+
export const assessmentSteps = {
77+
order: ['studentTraining', 'self', 'peer', 'staff'],
7878
settings: {
7979
peer: {
8080
start_time: '2023-04-14T20:00:00Z',
8181
end_time: '2023-04-14T20:00:00Z',
8282
required: true,
8383
// Additional fields per step
8484
data: {
85-
min_number_to_grade: 0,
86-
min_number_to_be_graded_by: 0,
85+
min_number_to_grade: 2,
86+
min_number_to_be_graded_by: 3,
8787
enable_flexible_grading: true,
8888
},
8989
},
@@ -100,7 +100,16 @@ const assessmentSteps = {
100100
data: {
101101
examples: [
102102
{
103-
response: 'response',
103+
response: 'response 1',
104+
criteria: [
105+
{
106+
name: 'criterion name',
107+
feedback: 'feedback',
108+
},
109+
],
110+
},
111+
{
112+
response: 'response 2',
104113
criteria: [
105114
{
106115
name: 'criterion name',
Lines changed: 81 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,104 @@
1+
import { assessmentSteps } from '../oraConfig';
12
/* eslint-disable camelcase */
23

34
// Progress
45
export const createProgressData = ({
56
active_step_name = null,
67
has_received_final_grade = false,
7-
active_step_info = {},
8+
step_info = {},
89
}) => ({
910
active_step_name,
1011
has_received_final_grade,
11-
active_step_info,
12+
step_info,
13+
});
14+
15+
export const closedStates = {
16+
open: { isClosed: false },
17+
notAvailable: { isClosed: true, closedReason: 'notAvailable' },
18+
closed: { isClosed: true, closedReason: 'pastDue' },
19+
};
20+
21+
export const genPeerStepInfo = ({
22+
closedState,
23+
numCompleted = 0,
24+
isWaiting = false,
25+
numReceived = 0,
26+
}) => ({
27+
...closedState,
28+
number_of_assessments_completed: numCompleted,
29+
is_waiting_for_submissions: isWaiting,
30+
number_of_received_assessments: numReceived,
31+
});
32+
33+
export const genTrainingStepInfo = ({ closedState, numCompleted }) => ({
34+
...closedState,
35+
number_of_assessments_completed: numCompleted,
36+
expected_rubric_selections: [
37+
{ name: 'Criterion 1 name', selection: 'Option 4 name' },
38+
{ name: 'Criterion 2 name', selection: 'Option 3 name' },
39+
{ name: 'Criterion 3 name', selection: 'Option 2 name' },
40+
{ name: 'Criterion 4 name', selection: 'Option 1 name' },
41+
],
42+
});
43+
44+
const finishedTrainingStepInfo = genTrainingStepInfo({
45+
closedState: closedStates.open,
46+
numCompleted: assessmentSteps.settings.training.data.examples.length,
47+
});
48+
49+
const finishedPeerStepInfo = genPeerStepInfo({
50+
closedState: closedStates.open,
51+
numCompleted: assessmentSteps.settings.peer.data.min_number_to_grade,
52+
isWaiting: false,
53+
numReceived: assessmentSteps.settings.peer.data.min_number_to_be_graded_by,
1254
});
1355

1456
export default {
1557
submission: createProgressData({}),
16-
training: (numCompleted) => createProgressData({
17-
active_step_name: 'training',
18-
active_step_info: {
19-
number_of_assessments_completed: numCompleted,
20-
expected_rubric_selections: [
21-
{ name: 'Criterion 1 name', selection: 'Option 4 name' },
22-
{ name: 'Criterion 2 name', selection: 'Option 3 name' },
23-
{ name: 'Criterion 3 name', selection: 'Option 2 name' },
24-
{ name: 'Criterion 4 name', selection: 'Option 1 name' },
25-
],
58+
training: ({
59+
closedState = closedStates.open,
60+
numCompleted,
61+
}) => createProgressData({
62+
active_step_name: 'studentTraining',
63+
step_info: {
64+
studentTraining: genTrainingStepInfo({ closedState, numCompleted }),
65+
self: null,
66+
peer: null,
67+
},
68+
}),
69+
self: createProgressData({
70+
active_step_name: 'self',
71+
step_info: {
72+
studentTraining: finishedTrainingStepInfo,
73+
self: closedStates.open,
74+
peer: null,
2675
},
2776
}),
2877
peer: ({
78+
closedState = closedStates.open,
2979
numCompleted = 0,
3080
isWaiting = false,
3181
numReceived = 0,
3282
} = {}) => createProgressData({
3383
active_step_name: 'peer',
34-
active_step_info: {
35-
number_of_assessments_completed: numCompleted,
36-
is_waiting_for_submissions: isWaiting,
37-
number_of_received_assessments: numReceived,
84+
step_info: {
85+
studentTraining: finishedTrainingStepInfo,
86+
self: closedStates.open,
87+
peer: genPeerStepInfo({
88+
closedState,
89+
numCompleted,
90+
isWaiting,
91+
numReceived,
92+
}),
3893
},
3994
}),
40-
self: createProgressData({
41-
active_step_name: 'self',
42-
active_step_info: {},
43-
}),
4495
staff: createProgressData({
4596
active_step_name: 'staff',
46-
active_step_info: {},
97+
step_info: {
98+
training: finishedTrainingStepInfo,
99+
self: closedStates.open,
100+
peer: finishedPeerStepInfo,
101+
},
47102
}),
48103
graded: createProgressData({
49104
active_step_name: null,
@@ -52,5 +107,10 @@ export default {
52107
peer: { earned: 5, possible: 25 },
53108
staff: { earned: 8, possible: 10 },
54109
},
110+
step_info: {
111+
training: finishedTrainingStepInfo,
112+
self: closedStates.open,
113+
peer: finishedPeerStepInfo,
114+
},
55115
}),
56116
};

src/data/services/lms/fakeData/pageData/submission.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable camelcase */
22
import { StrictDict } from '@edx/react-unit-test-utils';
3+
import { closedStates } from './progress';
34

45
/// Submission
56
export const createFiles = (numFiles) => Array.from(Array(numFiles)).map((_, i) => ({
@@ -26,9 +27,11 @@ export const createTeamInfo = ({
2627

2728
export const createSubmissionStatus = ({
2829
has_submitted = true,
29-
has_cancelled = true,
30-
has_recieved_grade = true,
30+
has_cancelled = false,
31+
has_recieved_grade = false,
32+
closedState = closedStates.open,
3133
} = {}) => ({
34+
...closedState,
3235
has_submitted,
3336
has_cancelled,
3437
has_recieved_grade,
@@ -52,8 +55,6 @@ export const createSubmission = ({
5255
...submissionStatus,
5356
});
5457

55-
// Rubric
56-
5758
export default StrictDict({
5859
emptySubmission: createSubmission({
5960
teamInfo: {},

0 commit comments

Comments
 (0)