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 #5

Draft
wants to merge 24 commits into
base: master
Choose a base branch
from
Draft
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
a9ce6ac
feat: grading details UI problem steps
johnvente Oct 9, 2023
61f45c3
fix: status badge for step problems
johnvente Oct 9, 2023
3877fab
refactor: format code
johnvente Oct 9, 2023
323c42f
docs: update submissionuuid param type
johnvente Oct 9, 2023
7bb2d60
fix: adding more test cases
johnvente Oct 9, 2023
50c9df5
fix: adding more test coverage
johnvente Nov 8, 2023
8345e7f
feat: adding unit test for responses list and assessemnts table compo…
johnvente Nov 9, 2023
3d39f41
fix: removing testid for rubric component
johnvente Nov 9, 2023
7fe9807
fix: unit testing for not covered test cases
johnvente Nov 10, 2023
a4fdbaa
fix: remove unnecesary console
johnvente Nov 10, 2023
2fe9c30
fix: adding not covered tests
johnvente Nov 10, 2023
798c6ae
feat: integration backend
johnvente Nov 16, 2023
7d9f6e6
refactor: adding more unit tests for all
johnvente Nov 23, 2023
c68ad73
test: full unit test for review problem estep content hook and change…
johnvente Dec 26, 2023
3b4d83e
fix: addresing pr comments
johnvente Dec 26, 2023
6d7ea83
fix: jest problems
johnvente Jan 30, 2024
772eb25
refactor: use individual endpoint to get assessments feedback
BryanttV Feb 22, 2024
8b2dbd5
chore: update dependencies and snapshots
BryanttV Feb 28, 2024
39010d0
test: replace edx/react-unit-test-utils for enzyme
BryanttV Feb 28, 2024
3f1ba8b
chore: replace idAssessment for assessmentId
BryanttV Feb 28, 2024
9123f0a
test: update unit tests
BryanttV Feb 28, 2024
212dd5b
chore: update package-lock
BryanttV Feb 28, 2024
e909587
refactor: replace @edx/paragon with @openedx/paragon
BryanttV Feb 28, 2024
1b9fa9d
chore: remove mock of paragon
BryanttV Feb 28, 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
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions 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,14 +70,15 @@
"regenerator-runtime": "^0.14.0",
"reselect": "^4.0.0",
"util": "^0.12.4",
"uuid": "^9.0.1",
"whatwg-fetch": "^3.6.2"
},
"devDependencies": {
"@edx/browserslist-config": "^1.2.0",
"@edx/react-unit-test-utils": "2.0.0",
"@edx/reactifex": "^2.1.1",
"@openedx/frontend-build": "13.0.28",
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/jest-dom": "^6.4.0",
"@testing-library/react": "12.1.5",
"axios-mock-adapter": "^1.20.0",
"fetch-mock": "^9.11.0",
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,
};
/**
* <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}>
{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