-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5cd4361
commit 966b2cb
Showing
7 changed files
with
174 additions
and
120 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/components/CollapsibleFeedback/CollapsibleFeedback.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import { Collapsible } from '@edx/paragon'; | ||
import { useIntl } from '@edx/frontend-platform/i18n'; | ||
import messages from './messages'; | ||
|
||
const CollapsibleFeedback = ({ children, stepScore, stepLabel, defaultOpen }) => { | ||
const { formatMessage } = useIntl(); | ||
const [open, setOpen] = React.useState(defaultOpen); | ||
|
||
const toggle = () => setOpen(!open); | ||
|
||
return ( | ||
<Collapsible | ||
title={ | ||
<h3> | ||
{formatMessage(messages.grade, { stepLabel })} | ||
{stepScore && formatMessage(messages.gradePoints, stepScore)} | ||
</h3> | ||
} | ||
open={open} | ||
onToggle={toggle} | ||
> | ||
{children} | ||
</Collapsible> | ||
); | ||
}; | ||
CollapsibleFeedback.defaultProps = {}; | ||
CollapsibleFeedback.propTypes = { | ||
stepLabel: PropTypes.string.isRequired, | ||
stepScore: PropTypes.shape({ | ||
earned: PropTypes.number, | ||
possible: PropTypes.number, | ||
}), | ||
children: PropTypes.node.isRequired, | ||
defaultOpen: PropTypes.bool, | ||
}; | ||
|
||
export default CollapsibleFeedback; |
48 changes: 48 additions & 0 deletions
48
src/components/CollapsibleFeedback/MultipleAssessmentStep.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, { Fragment } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import CollapsibleFeedback from './CollapsibleFeedback'; | ||
import AssessmentCriterion from './AssessmentCriterion'; | ||
|
||
const MultipleAssessmentStep = ({ | ||
stepLabel, | ||
step, | ||
stepScore, | ||
assessments, | ||
defaultOpen, | ||
}) => ( | ||
<div className='my-2' key='peer'> | ||
<CollapsibleFeedback stepLabel={stepLabel} stepScore={stepScore} defaultOpen={defaultOpen}> | ||
{assessments?.map((assessment, index) => ( | ||
<Fragment key={index}> | ||
<p className='mb-0'> | ||
{stepLabel} {index + 1}: | ||
</p> | ||
<AssessmentCriterion {...assessment} stepLabel={stepLabel} /> | ||
<hr className='my-4' /> | ||
</Fragment> | ||
))} | ||
</CollapsibleFeedback> | ||
</div> | ||
); | ||
|
||
MultipleAssessmentStep.defaultProps = { | ||
defaultOpen: false, | ||
}; | ||
MultipleAssessmentStep.propTypes = { | ||
stepLabel: PropTypes.string.isRequired, | ||
stepScore: PropTypes.shape({ | ||
earned: PropTypes.number, | ||
possible: PropTypes.number, | ||
}), | ||
assessments: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
selectedOption: PropTypes.number, | ||
// selectedPoints: PropTypes.number, | ||
feedback: PropTypes.string, | ||
}) | ||
), | ||
defaultOpen: PropTypes.bool, | ||
}; | ||
|
||
export default MultipleAssessmentStep; |
40 changes: 40 additions & 0 deletions
40
src/components/CollapsibleFeedback/SingleAssessmentStep.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import CollapsibleFeedback from './CollapsibleFeedback'; | ||
import AssessmentCriterion from './AssessmentCriterion'; | ||
|
||
const SingleAssessmentStep = ({ | ||
stepLabel, | ||
step, | ||
stepScore, | ||
assessment, | ||
defaultOpen, | ||
}) => ( | ||
<CollapsibleFeedback | ||
stepLabel={stepLabel} | ||
stepScore={stepScore} | ||
defaultOpen={defaultOpen} | ||
> | ||
<AssessmentCriterion {...assessment} stepLabel={stepLabel} /> | ||
</CollapsibleFeedback> | ||
); | ||
|
||
SingleAssessmentStep.defaultProps = { | ||
defaultOpen: false, | ||
}; | ||
SingleAssessmentStep.propTypes = { | ||
stepLabel: PropTypes.string.isRequired, | ||
stepScore: PropTypes.shape({ | ||
earned: PropTypes.number, | ||
possible: PropTypes.number, | ||
}), | ||
assessment: PropTypes.shape({ | ||
selectedOption: PropTypes.number, | ||
// selectedPoints: PropTypes.number, | ||
feedback: PropTypes.string, | ||
}), | ||
defaultOpen: PropTypes.bool, | ||
}; | ||
|
||
export default SingleAssessmentStep; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,5 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import { Collapsible } from '@edx/paragon'; | ||
import { useIntl } from '@edx/frontend-platform/i18n'; | ||
import messages from './messages'; | ||
|
||
const CollapsibleFeedback = ({ children, stepScore, stepLabel, defaultOpen }) => { | ||
const { formatMessage } = useIntl(); | ||
const [open, setOpen] = React.useState(defaultOpen); | ||
|
||
const toggle = () => setOpen(!open); | ||
|
||
return ( | ||
<Collapsible | ||
title={ | ||
<h3> | ||
{formatMessage(messages.grade, { stepLabel })} | ||
{stepScore && formatMessage(messages.gradePoints, stepScore)} | ||
</h3> | ||
} | ||
open={open} | ||
onToggle={toggle} | ||
> | ||
{children} | ||
</Collapsible> | ||
); | ||
}; | ||
CollapsibleFeedback.defaultProps = {}; | ||
CollapsibleFeedback.propTypes = { | ||
stepLabel: PropTypes.string.isRequired, | ||
stepScore: PropTypes.shape({ | ||
earned: PropTypes.number, | ||
possible: PropTypes.number, | ||
}), | ||
children: PropTypes.node.isRequired, | ||
defaultOpen: PropTypes.bool, | ||
}; | ||
|
||
export default CollapsibleFeedback; | ||
export { default as CollapsibleFeedback } from './CollapsibleFeedback'; | ||
export { default as MultipleAssessmentStep } from './MultipleAssessmentStep'; | ||
export { default as SingleAssessmentStep } from './SingleAssessmentStep'; | ||
export { default as AssessmentCriterion } from './AssessmentCriterion'; | ||
export { default as Feedback } from './Feedback'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters