Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: open response assesment detail (problem steps) UI #263

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0788611
feat: grading details UI problem steps
johnvente Oct 9, 2023
14851b5
fix: status badge for step problems
johnvente Oct 9, 2023
0a728e1
refactor: format code
johnvente Oct 9, 2023
4242939
docs: update submissionuuid param type
johnvente Oct 9, 2023
e23dc31
fix: adding more test cases
johnvente Oct 9, 2023
2d2f88b
fix: adding more test coverage
johnvente Nov 8, 2023
3852a24
feat: adding unit test for responses list and assessemnts table compo…
johnvente Nov 9, 2023
375a6e8
fix: removing testid for rubric component
johnvente Nov 9, 2023
87dd3ca
fix: unit testing for not covered test cases
johnvente Nov 10, 2023
b374c4d
fix: remove unnecesary console
johnvente Nov 10, 2023
5cd90d4
fix: adding not covered tests
johnvente Nov 10, 2023
e43acc2
feat: integration backend
johnvente Nov 16, 2023
5c98341
refactor: adding more unit tests for all
johnvente Nov 23, 2023
df3423d
test: full unit test for review problem estep content hook and change…
johnvente Dec 26, 2023
949a9e8
fix: addresing pr comments
johnvente Dec 26, 2023
35250c1
fix: jest problems
johnvente Jan 30, 2024
06c5635
refactor: use individual endpoint to get assessments feedback
BryanttV Feb 22, 2024
c6f1933
chore: update dependencies and snapshots
BryanttV Feb 28, 2024
527d69b
test: replace edx/react-unit-test-utils for enzyme
BryanttV Feb 28, 2024
24d6df0
chore: replace idAssessment for assessmentId
BryanttV Feb 28, 2024
7ff03ef
test: update unit tests
BryanttV Feb 28, 2024
4c16376
refactor: replace @edx/paragon with @openedx/paragon
BryanttV Feb 28, 2024
6e41dee
chore: remove mock of paragon
BryanttV Feb 28, 2024
f19f7c0
chore: update snapshots
BryanttV May 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@ const config = createConfig('eslint', {
'import/no-named-as-default': 'off',
'import/no-named-as-default-member': 'off',
'import/no-import-module-exports': 'off',
'import/prefer-default-export': 'off',
'import/no-self-import': 'off',
'spaced-comment': ['error', 'always', { 'block': { 'exceptions': ['*'] } }],
'spaced-comment': ['error', 'always', { block: { exceptions: ['*'] } }],
'react-hooks/rules-of-hooks': 'off',
"react/forbid-prop-types": ["error", { "forbid": ["any", "array"] }], // arguable object proptype is use when I do not care about the shape of the object
'react/forbid-prop-types': ['error', { forbid: ['any', 'array'] }], // arguable object proptype is use when I do not care about the shape of the object
'no-import-assign': 'off',
'no-promise-executor-return': 'off',
'import/no-cycle': 'off',
},
});

config.settings = {
"import/resolver": {
'import/resolver': {
node: {
paths: ["src", "node_modules"],
extensions: [".js", ".jsx"],
paths: ['src', 'node_modules'],
extensions: ['.js', '.jsx'],
},
},
};
Expand Down
Empty file added mockParagon.js
Empty file.
6,441 changes: 2,596 additions & 3,845 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@
"@fortawesome/free-brands-svg-icons": "^5.15.4",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@fortawesome/react-fontawesome": "^0.2.0",
"@openedx/paragon": "21.11.3",
"@openedx/paragon": "^22.0.0",
"@redux-beacon/segment": "^1.1.0",
"@reduxjs/toolkit": "^1.6.1",
"@testing-library/react-hooks": "^8.0.1",
"@testing-library/user-event": "^14.0.0",
"@zip.js/zip.js": "^2.4.6",
"axios": "^0.28.0",
Expand Down Expand Up @@ -69,6 +70,7 @@
"regenerator-runtime": "^0.14.0",
"reselect": "^4.0.0",
"util": "^0.12.4",
"uuid": "^9.0.1",
"whatwg-fetch": "^3.6.2"
},
"devDependencies": {
Expand Down
6 changes: 4 additions & 2 deletions src/components/StatusBadge.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const statusVariants = StrictDict({
/**
* <StatusBadge />
*/
export const StatusBadge = ({ className, status }) => {
export const StatusBadge = ({ className, status, title }) => {
if (!Object.keys(statusVariants).includes(status)) {
return null;
}
Expand All @@ -34,16 +34,18 @@ export const StatusBadge = ({ className, status }) => {
className={className}
variant={statusVariants[status]}
>
<FormattedMessage {...messages[status]} />
{ title || <FormattedMessage {...messages[status]} /> }
</Badge>
);
};
StatusBadge.defaultProps = {
className: '',
title: '',
};
StatusBadge.propTypes = {
className: PropTypes.string,
status: PropTypes.string.isRequired,
title: PropTypes.string,
};

export default StatusBadge;
10 changes: 9 additions & 1 deletion src/components/StatusBadge.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@ import { StatusBadge } from './StatusBadge';

const className = 'test-className';
describe('StatusBadge component', () => {
const render = (status) => shallow(<StatusBadge className={className} status={status} />);
const render = (status, title) => shallow(<StatusBadge className={className} status={status} title={title} />);
describe('behavior', () => {
it('does not render if status does not have configured variant', () => {
const el = render('arbitrary');
expect(el.snapshot).toMatchSnapshot();
expect(el.isEmptyRender()).toEqual(true);
});
it('renders the title when title prop is passed', () => {
const title = 'Custom Title';
const wrapper = render('graded', title);

expect(wrapper.find('Badge').exists()).toBe(true);
expect(wrapper.find('Badge').prop('variant')).toBe('success');
expect(wrapper.text()).toContain(title);
});
describe('status snapshots: loads badge with configured variant and message.', () => {
test('`ungraded` shows primary button variant and message', () => {
const el = render(gradingStatuses.ungraded);
Expand Down
9 changes: 9 additions & 0 deletions src/containers/ListView/ListView.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,13 @@ span.pgn__icon.breadcrumb-arrow {
margin-bottom: 0;
}
}
.step-problems-button-badge {
margin-right: 8px;
padding: 0px !important;
}
.btn-view-details {
padding-left: 0px;
text-decoration: underline;
font-weight: bold;
}
}
94 changes: 88 additions & 6 deletions src/containers/ListView/SubmissionsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import {
DataTable,
TextFilter,
MultiSelectDropdownFilter,
Button,
Hyperlink,
} from '@openedx/paragon';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';

import { gradingStatuses, submissionFields } from 'data/services/lms/constants';
import lmsMessages from 'data/services/lms/messages';

import { selectors, thunkActions } from 'data/redux';
import { selectors, thunkActions, actions } from 'data/redux';

import StatusBadge from 'components/StatusBadge';
import FilterStatusComponent from './FilterStatusComponent';
Expand All @@ -22,19 +24,27 @@ import SelectedBulkAction from './SelectedBulkAction';

import messages from './messages';

const problemSteps = {
problemStepsTraining: true,
problemStepsPeers: false,
problemStepsSelf: true,
problemStepsStaff: true,
};
Comment on lines +27 to +32
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it does

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good! Thanks

/**
* <SubmissionsTable />
*/
export class SubmissionsTable extends React.Component {
get gradeStatusOptions() {
return Object.keys(gradingStatuses).map(statusKey => ({
return Object.keys(gradingStatuses).map((statusKey) => ({
name: this.translate(lmsMessages[gradingStatuses[statusKey]]),
value: gradingStatuses[statusKey],
}));
}

get userLabel() {
return this.translate(this.props.isIndividual ? messages.username : messages.teamName);
return this.translate(
this.props.isIndividual ? messages.username : messages.teamName,
);
}

get userAccessor() {
Expand All @@ -54,11 +64,56 @@ export class SubmissionsTable extends React.Component {
return date.toLocaleString();
};

formatGrade = ({ value: score }) => (
score === null ? '-' : `${score.pointsEarned}/${score.pointsPossible}`
formatGrade = ({ value: score }) => (score === null ? '-' : `${score.pointsEarned}/${score.pointsPossible}`);

formatStatus = ({ value }) => <StatusBadge status={value} />;

formatProblemStepsStatus = () => {
const stepProblems = Object.keys(problemSteps);
return (
<div>
{stepProblems.map((stepProblem) => (
<Button
variant="tertiary"
className="step-problems-button-badge"
key={stepProblem}
>
<StatusBadge
status={problemSteps[stepProblem] ? 'graded' : 'ungraded'}
title={this.translate(messages[stepProblem])}
/>
</Button>
))}
</div>
);
};

handleProblemStepsDetailClick = (data, currentRow) => {
const submissionUUIDs = data.map((row) => row.submissionUUID);
const submissionId = currentRow.original.submissionUUID;
const currentRowIndex = submissionUUIDs.indexOf(submissionId);
this.props.loadSelectionForReview(submissionUUIDs, false, submissionId);
this.props.setActiveSubmissionIndex(currentRowIndex);
this.props.setProblemStepsModal(true);
};

problemStepsViewDetails = ({ data, row: currentRow }) => (
<Button
variant="link"
className="btn-view-details"
data-testid="button-view-details"
size="sm"
onClick={() => this.handleProblemStepsDetailClick(data, currentRow)}
>
{this.translate(messages.actionDetail)}
</Button>
);

formatStatus = ({ value }) => (<StatusBadge status={value} />);
emailAddressCell = ({ value }) => (
<Hyperlink destination="#" showLaunchIcon={false}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the destination "#"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's a link but won't redirect to any destination

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! Thank you

{value}
</Hyperlink>
);

translate = (...args) => this.props.intl.formatMessage(...args);

Expand Down Expand Up @@ -95,6 +150,18 @@ export class SubmissionsTable extends React.Component {
{
Header: this.userLabel,
accessor: this.userAccessor,
filter: false,
},
{
Header: this.translate(messages.learnerFullname),
accessor: submissionFields.fullname,
disableFilters: true,
},
{
Header: this.translate(messages.emailLabel),
accessor: submissionFields.email,
Cell: this.emailAddressCell,
disableFilters: true,
},
{
Header: this.dateSubmittedLabel,
Expand All @@ -116,6 +183,17 @@ export class SubmissionsTable extends React.Component {
filter: 'includesValue',
filterChoices: this.gradeStatusOptions,
},
{
Header: this.translate(messages.problemSteps),
Cell: this.formatProblemStepsStatus,
},
]}
additionalColumns={[
{
id: 'action',
Header: this.translate(messages.action),
Cell: this.problemStepsViewDetails,
},
]}
>
<DataTable.TableControlBar />
Expand Down Expand Up @@ -144,6 +222,8 @@ SubmissionsTable.propTypes = {
}),
})),
loadSelectionForReview: PropTypes.func.isRequired,
setProblemStepsModal: PropTypes.func.isRequired,
setActiveSubmissionIndex: PropTypes.func.isRequired,
};

export const mapStateToProps = (state) => ({
Expand All @@ -153,6 +233,8 @@ export const mapStateToProps = (state) => ({

export const mapDispatchToProps = {
loadSelectionForReview: thunkActions.grading.loadSelectionForReview,
setProblemStepsModal: actions.problemSteps.setOpenReviewModal,
setActiveSubmissionIndex: actions.grading.setActiveIndex,
};

export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(SubmissionsTable));
Loading
Loading