Skip to content

Commit 9a026eb

Browse files
Assessment Configurability in Ground Control (#2863)
* Change hasTokenCounter to hasVotingAttributes in Assessment Config. Enable tokencounter depending on assessment hasTokenCounter, not assessmentConfig * Rename hasVotingAttributes to hasVotingFeatures * Create dialog box for configuration in ground control * Create dialog box for configurations with voting config toggles * Combine toggleHasTokenCounter and toggleVotingFeatures into configureAssessment * Create backend request for updating configurations * Add message for updating assessment configurations * Isolate hastokencounter as its own field * Add non-functional voting controls * Fix tests * Add new column for token counter in admin panel * Fix bugs relating to tokencounter switch * Remove unnecessary maxwidth property on tokencounter switch * Fix bug where toggling tokencounter would request voting features to be true to backend * Create footer text to clarify usage of hastokencounter and hasVotingFeatures * Align text on configure dialogbox * Fix tests post-merge The stronger type checking had been causing compile errors. * Fix imports * Add close dialog upon saving * Uncapitalise letters in config dialog * Change label from has token counter to enable token counter * Code quality improvements * Create new section for team-related configurations * Fix code quality per suggestion * Fix errors post-merge * Fix lint errors --------- Co-authored-by: Richard Dominick <34370238+RichDom2185@users.noreply.github.com>
1 parent ec0aecb commit 9a026eb

File tree

20 files changed

+343
-31
lines changed

20 files changed

+343
-31
lines changed

src/commons/XMLParser/XMLParserHelper.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ const makeAssessmentOverview = (result: any, maxXpVal: number): AssessmentOvervi
8585
story: rawOverview.story,
8686
xp: 0,
8787
gradingStatus: 'none' as GradingStatuses,
88-
maxTeamSize: 1
88+
maxTeamSize: 1,
89+
hasVotingFeatures: false
8990
};
9091
};
9192

src/commons/application/actions/__tests__/SessionActions.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ test('setAssessmentConfigurations generates correct action object', () => {
335335
isManuallyGraded: true,
336336
displayInDashboard: true,
337337
hasTokenCounter: false,
338+
hasVotingFeatures: false,
338339
hoursBeforeEarlyXpDecay: 48,
339340
earlySubmissionXp: 200
340341
},
@@ -344,6 +345,7 @@ test('setAssessmentConfigurations generates correct action object', () => {
344345
isManuallyGraded: true,
345346
displayInDashboard: true,
346347
hasTokenCounter: false,
348+
hasVotingFeatures: false,
347349
hoursBeforeEarlyXpDecay: 48,
348350
earlySubmissionXp: 200
349351
},
@@ -353,6 +355,7 @@ test('setAssessmentConfigurations generates correct action object', () => {
353355
isManuallyGraded: true,
354356
displayInDashboard: true,
355357
hasTokenCounter: false,
358+
hasVotingFeatures: false,
356359
hoursBeforeEarlyXpDecay: 48,
357360
earlySubmissionXp: 200
358361
}
@@ -541,7 +544,8 @@ test('updateAssessmentOverviews generates correct action object', () => {
541544
story: null,
542545
xp: 0,
543546
gradingStatus: 'none',
544-
maxTeamSize: 1
547+
maxTeamSize: 1,
548+
hasVotingFeatures: false
545549
}
546550
];
547551
const action = updateAssessmentOverviews(overviews);
@@ -769,6 +773,7 @@ test('updateAssessmentTypes generates correct action object', () => {
769773
isManuallyGraded: true,
770774
displayInDashboard: true,
771775
hasTokenCounter: false,
776+
hasVotingFeatures: false,
772777
hoursBeforeEarlyXpDecay: 48,
773778
earlySubmissionXp: 200
774779
},
@@ -778,6 +783,7 @@ test('updateAssessmentTypes generates correct action object', () => {
778783
isManuallyGraded: true,
779784
displayInDashboard: true,
780785
hasTokenCounter: false,
786+
hasVotingFeatures: false,
781787
hoursBeforeEarlyXpDecay: 48,
782788
earlySubmissionXp: 200
783789
},
@@ -787,6 +793,7 @@ test('updateAssessmentTypes generates correct action object', () => {
787793
isManuallyGraded: true,
788794
displayInDashboard: true,
789795
hasTokenCounter: false,
796+
hasVotingFeatures: false,
790797
hoursBeforeEarlyXpDecay: 48,
791798
earlySubmissionXp: 200
792799
},
@@ -796,6 +803,7 @@ test('updateAssessmentTypes generates correct action object', () => {
796803
isManuallyGraded: true,
797804
displayInDashboard: true,
798805
hasTokenCounter: false,
806+
hasVotingFeatures: false,
799807
hoursBeforeEarlyXpDecay: 48,
800808
earlySubmissionXp: 200
801809
},
@@ -805,6 +813,7 @@ test('updateAssessmentTypes generates correct action object', () => {
805813
isManuallyGraded: true,
806814
displayInDashboard: true,
807815
hasTokenCounter: false,
816+
hasVotingFeatures: false,
808817
hoursBeforeEarlyXpDecay: 48,
809818
earlySubmissionXp: 200
810819
}
@@ -823,6 +832,7 @@ test('deleteAssessmentConfig generates correct action object', () => {
823832
isManuallyGraded: true,
824833
displayInDashboard: true,
825834
hasTokenCounter: false,
835+
hasVotingFeatures: false,
826836
hoursBeforeEarlyXpDecay: 48,
827837
earlySubmissionXp: 200
828838
};

src/commons/application/reducers/__tests__/SessionReducer.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ test('SET_ASSESSMENT_CONFIGURATIONS works correctly', () => {
159159
earlySubmissionXp: 200,
160160
isManuallyGraded: false,
161161
displayInDashboard: true,
162-
hasTokenCounter: false
162+
hasTokenCounter: false,
163+
hasVotingFeatures: false
163164
},
164165
{
165166
assessmentConfigId: 1,
@@ -171,7 +172,8 @@ test('SET_ASSESSMENT_CONFIGURATIONS works correctly', () => {
171172
earlySubmissionXp: 200,
172173
isManuallyGraded: false,
173174
displayInDashboard: true,
174-
hasTokenCounter: false
175+
hasTokenCounter: false,
176+
hasVotingFeatures: false
175177
},
176178
{
177179
assessmentConfigId: 1,
@@ -183,7 +185,8 @@ test('SET_ASSESSMENT_CONFIGURATIONS works correctly', () => {
183185
earlySubmissionXp: 200,
184186
isManuallyGraded: false,
185187
displayInDashboard: true,
186-
hasTokenCounter: false
188+
hasTokenCounter: false,
189+
hasVotingFeatures: false
187190
}
188191
];
189192

@@ -339,7 +342,8 @@ const assessmentOverviewsTest1: AssessmentOverview[] = [
339342
story: null,
340343
xp: 0,
341344
gradingStatus: GradingStatuses.none,
342-
maxTeamSize: 5
345+
maxTeamSize: 5,
346+
hasVotingFeatures: false
343347
}
344348
];
345349

@@ -359,7 +363,8 @@ const assessmentOverviewsTest2: AssessmentOverview[] = [
359363
story: null,
360364
xp: 1,
361365
gradingStatus: GradingStatuses.grading,
362-
maxTeamSize: 1
366+
maxTeamSize: 1,
367+
hasVotingFeatures: false
363368
}
364369
];
365370

src/commons/assessment/AssessmentTypes.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ export type AssessmentOverview = {
6262
gradingStatus: GradingStatus;
6363
id: number;
6464
isPublished?: boolean;
65+
hasVotingFeatures: boolean;
66+
hasTokenCounter?: boolean;
6567
maxXp: number;
6668
number?: string; // For mission control
6769
openAt: string;
@@ -98,6 +100,7 @@ export type AssessmentConfiguration = {
98100
hoursBeforeEarlyXpDecay: number;
99101
earlySubmissionXp: number;
100102
hasTokenCounter: boolean;
103+
hasVotingFeatures: boolean;
101104
};
102105

103106
export interface IProgrammingQuestion extends BaseQuestion {
@@ -246,7 +249,8 @@ export const overviewTemplate = (): AssessmentOverview => {
246249
story: 'mission',
247250
xp: 0,
248251
gradingStatus: 'none',
249-
maxTeamSize: 1
252+
maxTeamSize: 1,
253+
hasVotingFeatures: false
250254
};
251255
};
252256

src/commons/assessment/__tests__/Assessment.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const mockAssessmentProps = assertType<AssessmentProps>()({
1818
isManuallyGraded: true,
1919
displayInDashboard: true,
2020
hasTokenCounter: false,
21+
hasVotingFeatures: false,
2122
hoursBeforeEarlyXpDecay: 48,
2223
earlySubmissionXp: 200
2324
}

src/commons/assessmentWorkspace/AssessmentWorkspace.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,12 @@ const AssessmentWorkspace: React.FC<AssessmentWorkspaceProps> = props => {
274274
* Handles toggling enabling and disabling token counter depending on assessment properties
275275
*/
276276
useEffect(() => {
277-
if (props.assessmentConfiguration.hasTokenCounter) {
277+
if (assessment?.hasTokenCounter) {
278278
handleEnableTokenCounter();
279279
} else {
280280
handleDisableTokenCounter();
281281
}
282-
}, [
283-
props.assessmentConfiguration.hasTokenCounter,
284-
handleEnableTokenCounter,
285-
handleDisableTokenCounter
286-
]);
282+
}, [assessment?.hasTokenCounter, handleEnableTokenCounter, handleDisableTokenCounter]);
287283

288284
/**
289285
* Handles toggling of relevant SideContentTabs when mobile breakpoint it hit

src/commons/assessmentWorkspace/__tests__/AssessmentWorkspace.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const defaultProps = assertType<AssessmentWorkspaceProps>()({
2727
isManuallyGraded: true,
2828
displayInDashboard: true,
2929
hasTokenCounter: false,
30+
hasVotingFeatures: false,
3031
hoursBeforeEarlyXpDecay: 48,
3132
earlySubmissionXp: 200
3233
},

src/commons/mocks/AssessmentMocks.ts

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const mockAssessmentConfigurations: AssessmentConfiguration[][] = [
2323
displayInDashboard: true,
2424
hoursBeforeEarlyXpDecay: 48,
2525
hasTokenCounter: false,
26+
hasVotingFeatures: false,
2627
earlySubmissionXp: 200
2728
},
2829
{
@@ -32,6 +33,7 @@ export const mockAssessmentConfigurations: AssessmentConfiguration[][] = [
3233
displayInDashboard: true,
3334
hoursBeforeEarlyXpDecay: 48,
3435
hasTokenCounter: false,
36+
hasVotingFeatures: false,
3537
earlySubmissionXp: 200
3638
},
3739
{
@@ -41,6 +43,7 @@ export const mockAssessmentConfigurations: AssessmentConfiguration[][] = [
4143
displayInDashboard: true,
4244
hoursBeforeEarlyXpDecay: 48,
4345
hasTokenCounter: false,
46+
hasVotingFeatures: false,
4447
earlySubmissionXp: 200
4548
},
4649
{
@@ -49,7 +52,8 @@ export const mockAssessmentConfigurations: AssessmentConfiguration[][] = [
4952
isManuallyGraded: true,
5053
displayInDashboard: true,
5154
hoursBeforeEarlyXpDecay: 48,
52-
hasTokenCounter: true,
55+
hasTokenCounter: false,
56+
hasVotingFeatures: true,
5357
earlySubmissionXp: 200
5458
},
5559
{
@@ -59,6 +63,7 @@ export const mockAssessmentConfigurations: AssessmentConfiguration[][] = [
5963
displayInDashboard: true,
6064
hoursBeforeEarlyXpDecay: 48,
6165
hasTokenCounter: false,
66+
hasVotingFeatures: false,
6267
earlySubmissionXp: 200
6368
}
6469
],
@@ -70,6 +75,7 @@ export const mockAssessmentConfigurations: AssessmentConfiguration[][] = [
7075
displayInDashboard: true,
7176
hoursBeforeEarlyXpDecay: 48,
7277
hasTokenCounter: false,
78+
hasVotingFeatures: false,
7379
earlySubmissionXp: 200
7480
},
7581
{
@@ -79,6 +85,7 @@ export const mockAssessmentConfigurations: AssessmentConfiguration[][] = [
7985
displayInDashboard: true,
8086
hoursBeforeEarlyXpDecay: 48,
8187
hasTokenCounter: false,
88+
hasVotingFeatures: false,
8289
earlySubmissionXp: 200
8390
},
8491
{
@@ -88,6 +95,7 @@ export const mockAssessmentConfigurations: AssessmentConfiguration[][] = [
8895
displayInDashboard: true,
8996
hoursBeforeEarlyXpDecay: 48,
9097
hasTokenCounter: false,
98+
hasVotingFeatures: false,
9199
earlySubmissionXp: 200
92100
}
93101
]
@@ -109,7 +117,8 @@ const mockUnopenedAssessmentsOverviews: AssessmentOverview[] = [
109117
story: 'mission-1',
110118
xp: 0,
111119
gradingStatus: GradingStatuses.none,
112-
maxTeamSize: 1
120+
maxTeamSize: 1,
121+
hasVotingFeatures: false
113122
}
114123
];
115124

@@ -141,7 +150,8 @@ const mockOpenedAssessmentsOverviews: AssessmentOverview[] = [
141150
story: 'mission-1',
142151
xp: 1,
143152
gradingStatus: GradingStatuses.none,
144-
maxTeamSize: 4
153+
maxTeamSize: 4,
154+
hasVotingFeatures: false
145155
},
146156
{
147157
type: 'Missions',
@@ -158,7 +168,8 @@ const mockOpenedAssessmentsOverviews: AssessmentOverview[] = [
158168
story: 'mission-2',
159169
xp: 2,
160170
gradingStatus: GradingStatuses.none,
161-
maxTeamSize: 1
171+
maxTeamSize: 1,
172+
hasVotingFeatures: false
162173
},
163174
{
164175
type: 'Quests',
@@ -175,7 +186,8 @@ const mockOpenedAssessmentsOverviews: AssessmentOverview[] = [
175186
story: 'sidequest-2.1',
176187
xp: 3,
177188
gradingStatus: GradingStatuses.none,
178-
maxTeamSize: 2
189+
maxTeamSize: 2,
190+
hasVotingFeatures: false
179191
},
180192
{
181193
type: 'Paths',
@@ -192,7 +204,8 @@ const mockOpenedAssessmentsOverviews: AssessmentOverview[] = [
192204
story: null,
193205
xp: 0,
194206
gradingStatus: GradingStatuses.excluded,
195-
maxTeamSize: 2
207+
maxTeamSize: 2,
208+
hasVotingFeatures: false
196209
},
197210
{
198211
type: 'Others',
@@ -210,7 +223,8 @@ const mockOpenedAssessmentsOverviews: AssessmentOverview[] = [
210223
xp: 3,
211224
gradingStatus: GradingStatuses.none,
212225
private: true,
213-
maxTeamSize: 1
226+
maxTeamSize: 1,
227+
hasVotingFeatures: false
214228
}
215229
];
216230

@@ -230,7 +244,8 @@ const mockClosedAssessmentOverviews: AssessmentOverview[] = [
230244
story: 'mission-3',
231245
xp: 800,
232246
gradingStatus: GradingStatuses.grading,
233-
maxTeamSize: 1
247+
maxTeamSize: 1,
248+
hasVotingFeatures: false
234249
},
235250
{
236251
type: 'Quests',
@@ -247,7 +262,8 @@ const mockClosedAssessmentOverviews: AssessmentOverview[] = [
247262
story: null,
248263
xp: 500,
249264
gradingStatus: GradingStatuses.none,
250-
maxTeamSize: 1
265+
maxTeamSize: 1,
266+
hasVotingFeatures: false
251267
},
252268
{
253269
type: 'Quests',
@@ -264,7 +280,8 @@ const mockClosedAssessmentOverviews: AssessmentOverview[] = [
264280
story: null,
265281
xp: 150,
266282
gradingStatus: GradingStatuses.graded,
267-
maxTeamSize: 1
283+
maxTeamSize: 1,
284+
hasVotingFeatures: false
268285
},
269286
{
270287
type: 'Quests',
@@ -281,7 +298,8 @@ const mockClosedAssessmentOverviews: AssessmentOverview[] = [
281298
story: null,
282299
xp: 100,
283300
gradingStatus: GradingStatuses.excluded,
284-
maxTeamSize: 1
301+
maxTeamSize: 1,
302+
hasVotingFeatures: false
285303
}
286304
];
287305

src/commons/profile/__tests__/Profile.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const assessmentConfigurations: AssessmentConfiguration[] = [
2626
isManuallyGraded: false,
2727
displayInDashboard: false,
2828
hasTokenCounter: false,
29+
hasVotingFeatures: false,
2930
hoursBeforeEarlyXpDecay: 0,
3031
earlySubmissionXp: 0
3132
}));

0 commit comments

Comments
 (0)