Skip to content

Commit 20e0573

Browse files
authored
Fix bug where no bonus XP assignments would display additional XP message (#2821)
* Fix bug where 0xp assignments would display additional xp message * Rename hasBonusXp to earlySubmissionXp * Remove unnecessary console.log message
1 parent 9a026eb commit 20e0573

File tree

6 files changed

+31
-4
lines changed

6 files changed

+31
-4
lines changed

src/commons/XMLParser/XMLParserHelper.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const makeAssessmentOverview = (result: any, maxXpVal: number): AssessmentOvervi
7676
coverImage: rawOverview.coverimage,
7777
id: EDITING_ID,
7878
maxXp: maxXpVal,
79+
earlySubmissionXp: 0,
7980
number: rawOverview.number || '',
8081
openAt: rawOverview.startdate,
8182
title: rawOverview.title,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ test('updateAssessmentOverviews generates correct action object', () => {
537537
coverImage: 'test_string',
538538
id: 0,
539539
maxXp: 0,
540+
earlySubmissionXp: 0,
540541
openAt: 'test_string',
541542
title: 'test_string',
542543
shortSummary: 'test_string',

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ const assessmentOverviewsTest1: AssessmentOverview[] = [
335335
coverImage: 'test_string',
336336
id: 0,
337337
maxXp: 0,
338+
earlySubmissionXp: 0,
338339
openAt: 'test_string',
339340
title: 'test_string',
340341
shortSummary: 'test_string',
@@ -356,6 +357,7 @@ const assessmentOverviewsTest2: AssessmentOverview[] = [
356357
fileName: 'test_sting_0',
357358
id: 1,
358359
maxXp: 1,
360+
earlySubmissionXp: 0,
359361
openAt: 'test_string_0',
360362
title: 'test_string_0',
361363
shortSummary: 'test_string_0',

src/commons/assessment/Assessment.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,20 @@ const Assessment: React.FC<AssessmentProps> = props => {
349349
);
350350
}
351351

352+
// Define the warning text when finalising submissions
353+
const hasBonusXp = (betchaAssessment?.earlySubmissionXp as number) > 0;
354+
const warningText = hasBonusXp ? (
355+
<p>
356+
Finalising your submission early grants you additional XP, but{' '}
357+
<span className="warning">this action is irreversible.</span>
358+
</p>
359+
) : (
360+
<p>
361+
Finalising your submission early does not grant you additional XP, and{' '}
362+
<span className="warning">this action is irreversible.</span>
363+
</p>
364+
);
365+
352366
// Define the betcha dialog (in each card's menu)
353367
const submissionText = betchaAssessment ? (
354368
<p>
@@ -361,10 +375,7 @@ const Assessment: React.FC<AssessmentProps> = props => {
361375
const betchaText = (
362376
<>
363377
{submissionText}
364-
<p>
365-
Finalising your submission early grants you additional XP, but{' '}
366-
<span className="warning">this action is irreversible.</span>
367-
</p>
378+
{warningText}
368379
</>
369380
);
370381
const betchaDialog = (

src/commons/assessment/AssessmentTypes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export type AssessmentOverview = {
6565
hasVotingFeatures: boolean;
6666
hasTokenCounter?: boolean;
6767
maxXp: number;
68+
earlySubmissionXp: number;
6869
number?: string; // For mission control
6970
openAt: string;
7071
private?: boolean;
@@ -241,6 +242,7 @@ export const overviewTemplate = (): AssessmentOverview => {
241242
coverImage: 'https://fakeimg.pl/300/',
242243
id: -1,
243244
maxXp: 0,
245+
earlySubmissionXp: 0,
244246
openAt: '2000-01-01T00:00+08',
245247
title: 'Insert title here',
246248
reading: '',

src/commons/mocks/AssessmentMocks.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ const mockUnopenedAssessmentsOverviews: AssessmentOverview[] = [
109109
coverImage: 'https://fakeimg.pl/300/',
110110
id: 1,
111111
maxXp: 1000,
112+
earlySubmissionXp: 0,
112113
openAt: '2038-06-18T05:24:26.026Z',
113114
title: 'An Odessey to Runes (Duplicate)',
114115
shortSummary:
@@ -130,6 +131,7 @@ const mockOpenedAssessmentsOverviews: AssessmentOverview[] = [
130131
coverImage: 'https://fakeimg.pl/300/',
131132
id: 2,
132133
maxXp: 1000,
134+
earlySubmissionXp: 0,
133135
openAt: '2018-06-18T05:24:26.026Z',
134136
title: 'An Odessey to Runes',
135137
shortSummary: `
@@ -160,6 +162,7 @@ const mockOpenedAssessmentsOverviews: AssessmentOverview[] = [
160162
coverImage: 'https://fakeimg.pl/350x200/?text=World&font=lobster',
161163
id: 3,
162164
maxXp: 1000,
165+
earlySubmissionXp: 0,
163166
openAt: '2018-07-18T05:24:26.026Z',
164167
title: 'The Secret to Streams',
165168
shortSummary:
@@ -178,6 +181,7 @@ const mockOpenedAssessmentsOverviews: AssessmentOverview[] = [
178181
coverImage: 'https://fakeimg.pl/350x200/?text=Hello',
179182
id: 4,
180183
maxXp: 1000,
184+
earlySubmissionXp: 0,
181185
openAt: '2018-07-18T05:24:26.026Z',
182186
title: 'A sample Sidequest',
183187
shortSummary:
@@ -196,6 +200,7 @@ const mockOpenedAssessmentsOverviews: AssessmentOverview[] = [
196200
coverImage: 'https://fakeimg.pl/700x400/417678,64/?text=%E3%83%91%E3%82%B9&font=noto',
197201
id: 5,
198202
maxXp: 200,
203+
earlySubmissionXp: 0,
199204
openAt: '2018-01-01T00:00:00.000Z',
200205
title: 'Basic logic gates',
201206
shortSummary:
@@ -214,6 +219,7 @@ const mockOpenedAssessmentsOverviews: AssessmentOverview[] = [
214219
coverImage: 'https://fakeimg.pl/350x200/?text=Hello',
215220
id: 6,
216221
maxXp: 1000,
222+
earlySubmissionXp: 0,
217223
openAt: '2018-07-18T05:24:26.026Z',
218224
title: 'A sample Practical',
219225
shortSummary:
@@ -236,6 +242,7 @@ const mockClosedAssessmentOverviews: AssessmentOverview[] = [
236242
coverImage: 'https://fakeimg.pl/350x200/ff0000/000',
237243
id: 7,
238244
maxXp: 1000,
245+
earlySubmissionXp: 0,
239246
openAt: '2007-07-18T05:24:26.026Z',
240247
title: 'A closed Mission',
241248
shortSummary:
@@ -254,6 +261,7 @@ const mockClosedAssessmentOverviews: AssessmentOverview[] = [
254261
coverImage: 'https://fakeimg.pl/350x200/ff0000,128/000,255',
255262
id: 8,
256263
maxXp: 1000,
264+
earlySubmissionXp: 0,
257265
openAt: '2007-07-18T05:24:26.026Z',
258266
title: 'Closed (not graded) Sidequest',
259267
shortSummary:
@@ -272,6 +280,7 @@ const mockClosedAssessmentOverviews: AssessmentOverview[] = [
272280
coverImage: 'https://fakeimg.pl/350x200/ff0000,128/000,255',
273281
id: 9,
274282
maxXp: 500,
283+
earlySubmissionXp: 0,
275284
openAt: '2007-07-18T05:24:26.026Z',
276285
title: 'Closed (fully graded) Sidequest',
277286
shortSummary:
@@ -290,6 +299,7 @@ const mockClosedAssessmentOverviews: AssessmentOverview[] = [
290299
coverImage: 'https://fakeimg.pl/350x200/ff0000/000',
291300
id: 10,
292301
maxXp: 0,
302+
earlySubmissionXp: 0,
293303
openAt: '2007-07-18T05:24:26.026Z',
294304
title: 'Ungraded assessment',
295305
shortSummary:

0 commit comments

Comments
 (0)