Skip to content

Commit 1d42457

Browse files
committed
refactor: opt. donut test, rename field to optionalCompletion
1 parent 6d3359f commit 1d42457

File tree

9 files changed

+109
-14
lines changed

9 files changed

+109
-14
lines changed

src/course-home/data/__snapshots__/redux.test.js.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ Object {
428428
"complete": false,
429429
"courseId": "course-v1:edX+DemoX+Demo_Course",
430430
"id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@bcdabcdabcdabcdabcdabcdabcdabcd2",
431-
"optional": undefined,
431+
"optionalCompletion": undefined,
432432
"resumeBlock": false,
433433
"sequenceIds": Array [
434434
"block-v1:edX+DemoX+Demo_Course+type@sequential+block@bcdabcdabcdabcdabcdabcdabcdabcd1",
@@ -445,7 +445,7 @@ Object {
445445
"effortTime": 15,
446446
"icon": null,
447447
"id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@bcdabcdabcdabcdabcdabcdabcdabcd1",
448-
"optional": undefined,
448+
"optionalCompletion": undefined,
449449
"sectionId": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@bcdabcdabcdabcdabcdabcdabcdabcd2",
450450
"showLink": true,
451451
"title": "Title of Sequence",

src/course-home/data/api.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export function normalizeOutlineBlocks(courseId, blocks) {
136136
title: block.display_name,
137137
resumeBlock: block.resume_block,
138138
sequenceIds: block.children || [],
139-
optional: block.optional_completion,
139+
optionalCompletion: block.optional_completion,
140140
};
141141
break;
142142

@@ -153,7 +153,7 @@ export function normalizeOutlineBlocks(courseId, blocks) {
153153
// link in the outline (even though we ignore the given url and use an internal <Link> to ourselves).
154154
showLink: !!block.lms_web_url,
155155
title: block.display_name,
156-
optional: block.optional_completion,
156+
optionalCompletion: block.optional_completion,
157157
};
158158
break;
159159

src/course-home/outline-tab/Section.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const Section = ({
2727
complete,
2828
sequenceIds,
2929
title,
30-
optional,
30+
optionalCompletion,
3131
} = section;
3232
const {
3333
courseBlocks: {
@@ -75,7 +75,7 @@ const Section = ({
7575
</div>
7676
<div className="col-10 ml-3 p-0 font-weight-bold text-dark-500">
7777
<span className="align-middle">{title}</span>
78-
<Badge className="ml-2" variant="light" hidden={!optional}>{intl.formatMessage(messages.optionalCompletion)}</Badge>
78+
<Badge className="ml-2" variant="light" hidden={!optionalCompletion}>{intl.formatMessage(messages.optionalCompletion)}</Badge>
7979
<span className="sr-only">
8080
, {intl.formatMessage(complete ? messages.completedSection : messages.incompleteSection)}
8181
</span>

src/course-home/outline-tab/SequenceLink.jsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import classNames from 'classnames';
44
import { Link } from 'react-router-dom';
5+
import { Badge } from '@edx/paragon';
56
import {
67
FormattedMessage,
78
FormattedTime,
@@ -33,7 +34,7 @@ const SequenceLink = ({
3334
due,
3435
showLink,
3536
title,
36-
optional,
37+
optionalCompletion,
3738
} = sequence;
3839
const {
3940
userTimezone,
@@ -129,12 +130,14 @@ const SequenceLink = ({
129130
, {intl.formatMessage(complete ? messages.completedAssignment : messages.incompleteAssignment)}
130131
</span>
131132
<EffortEstimate className="ml-3 align-middle" block={sequence} />
133+
{optionalCompletion && (
134+
<Badge className="ml-2" variant="light">
135+
{intl.formatMessage(messages.optionalCompletion)}
136+
</Badge>
137+
)}
132138
</div>
133139
</div>
134140
<div className="row w-100 m-0 ml-3 pl-3">
135-
<small className="text-body pl-2 pr-0">
136-
{optional ? intl.formatMessage(messages.optionalCompletion) : ''}
137-
</small>
138141
<small className="text-body pl-2">
139142
{due ? dueDateMessage : noDueDateMessage}
140143
</small>

src/course-home/outline-tab/messages.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const messages = defineMessages({
102102
optionalCompletion: {
103103
id: 'learning.outline.optionalBlock',
104104
defaultMessage: 'Optional',
105-
description: 'Used as a label to indicate that a section, sequence, or unit is optional.',
105+
description: 'Used as a label to indicate that a section or sequence is optional.',
106106
},
107107
proctoringInfoPanel: {
108108
id: 'learning.proctoringPanel.header',

src/course-home/progress-tab/ProgressTab.test.jsx

+92
Original file line numberDiff line numberDiff line change
@@ -1379,4 +1379,96 @@ describe('Progress Tab', () => {
13791379
expect(screen.getByText('Course progress for otherstudent')).toBeInTheDocument();
13801380
});
13811381
});
1382+
1383+
describe('Completion Donut Chart', () => {
1384+
it('Renders optional completion donut chart', async () => {
1385+
setTabData({
1386+
completion_summary: {
1387+
complete_count: 1,
1388+
incomplete_count: 1,
1389+
locked_count: 1,
1390+
},
1391+
optional_completion_summary: {
1392+
complete_count: 1,
1393+
incomplete_count: 1,
1394+
locked_count: 0,
1395+
},
1396+
verified_mode: {
1397+
access_expiration_date: '2050-01-01T12:00:00',
1398+
currency: 'USD',
1399+
currency_symbol: '$',
1400+
price: 149,
1401+
sku: 'ABCD1234',
1402+
upgrade_url: 'edx.org/upgrade',
1403+
},
1404+
section_scores: [
1405+
{
1406+
display_name: 'First section',
1407+
subsections: [
1408+
{
1409+
assignment_type: 'Homework',
1410+
block_key: 'block-v1:edX+DemoX+Demo_Course+type@sequential+block@12345',
1411+
display_name: 'First subsection',
1412+
learner_has_access: false,
1413+
has_graded_assignment: true,
1414+
num_points_earned: 8,
1415+
num_points_possible: 10,
1416+
percent_graded: 1.0,
1417+
show_correctness: 'always',
1418+
show_grades: true,
1419+
url: 'http://learning.edx.org/course/course-v1:edX+Test+run/first_subsection',
1420+
},
1421+
],
1422+
},
1423+
],
1424+
});
1425+
await fetchAndRender();
1426+
expect(screen.getByText('optional')).toBeInTheDocument();
1427+
});
1428+
1429+
it('Hides optional completion donut chart', async () => {
1430+
setTabData({
1431+
completion_summary: {
1432+
complete_count: 1,
1433+
incomplete_count: 1,
1434+
locked_count: 1,
1435+
},
1436+
optional_completion_summary: {
1437+
complete_count: 0,
1438+
incomplete_count: 0,
1439+
locked_count: 0,
1440+
},
1441+
verified_mode: {
1442+
access_expiration_date: '2050-01-01T12:00:00',
1443+
currency: 'USD',
1444+
currency_symbol: '$',
1445+
price: 149,
1446+
sku: 'ABCD1234',
1447+
upgrade_url: 'edx.org/upgrade',
1448+
},
1449+
section_scores: [
1450+
{
1451+
display_name: 'First section',
1452+
subsections: [
1453+
{
1454+
assignment_type: 'Homework',
1455+
block_key: 'block-v1:edX+DemoX+Demo_Course+type@sequential+block@12345',
1456+
display_name: 'First subsection',
1457+
learner_has_access: false,
1458+
has_graded_assignment: true,
1459+
num_points_earned: 8,
1460+
num_points_possible: 10,
1461+
percent_graded: 1.0,
1462+
show_correctness: 'always',
1463+
show_grades: true,
1464+
url: 'http://learning.edx.org/course/course-v1:edX+Test+run/first_subsection',
1465+
},
1466+
],
1467+
},
1468+
],
1469+
});
1470+
await fetchAndRender();
1471+
expect(screen.queryByText('optional')).not.toBeInTheDocument();
1472+
});
1473+
});
13821474
});

src/courseware/course/sequence/Unit.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ const Unit = ({
143143
return (
144144
<div className="unit">
145145
<h1 className="mb-0 h3">{unit.title}</h1>
146-
<Badge className="ml-2" variant="light" hidden={!unit.optional}>{intl.formatMessage(messages.optionalCompletion)}</Badge>
146+
<Badge className="ml-2" variant="light" hidden={!unit.optionalCompletion}>{intl.formatMessage(messages.optionalCompletion)}</Badge>
147147
<h2 className="sr-only">{intl.formatMessage(messages.headerPlaceholder)}</h2>
148148
<BookmarkButton
149149
unitId={unit.id}

src/courseware/course/sequence/messages.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const messages = defineMessages({
3434
optionalCompletion: {
3535
id: 'learn.sequence.optionalBlock',
3636
defaultMessage: 'Optional',
37-
description: 'Used as a label to indicate that a section, sequence, or unit is optional.',
37+
description: 'Used as a label to indicate that a unit is optional.',
3838
},
3939
});
4040

src/courseware/data/api.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function normalizeSequenceMetadata(sequence) {
169169
contentType: unit.type,
170170
graded: unit.graded,
171171
containsContentTypeGatedContent: unit.contains_content_type_gated_content,
172-
optional: unit.optional_completion,
172+
optionalCompletion: unit.optional_completion,
173173
})),
174174
};
175175
}

0 commit comments

Comments
 (0)