-
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
b1ffbbb
commit b18d722
Showing
21 changed files
with
416 additions
and
54 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import { Collapsible, Icon } from '@edx/paragon'; | ||
import { ExpandMore, ExpandLess } from '@edx/paragon/icons'; | ||
import { useIntl } from '@edx/frontend-platform/i18n'; | ||
import messages from './messages'; | ||
|
||
const Feedback = ({ criterion, selectedOption, selectedPoints, commentHeader, commentBody, defaultOpen }) => { | ||
const [isExpanded, setIsExpanded] = React.useState(defaultOpen); | ||
const { formatMessage } = useIntl(); | ||
|
||
return ( | ||
<> | ||
<div className='mt-2'> | ||
<h5>{criterion.name}</h5> | ||
{selectedOption && <p>{selectedOption} -- {selectedPoints} points</p>} | ||
</div> | ||
<div className='bg-gray-100 p-3'> | ||
<Collapsible.Advanced | ||
open={isExpanded} | ||
onToggle={() => setIsExpanded(!isExpanded)} | ||
> | ||
<Collapsible.Trigger className='d-flex justify-content-between'> | ||
<h5 className='mb-0'>{commentHeader} Comment</h5> | ||
{isExpanded ? ( | ||
<div className='d-flex mb-0 small'> | ||
<span>{formatMessage(messages.readLess)}</span> | ||
<Icon src={ExpandLess} /> | ||
</div> | ||
) : ( | ||
<div className='d-flex mb-0 small'> | ||
<span>{formatMessage(messages.readMore)}</span> | ||
<Icon src={ExpandMore} /> | ||
</div> | ||
)} | ||
</Collapsible.Trigger> | ||
<Collapsible.Body className='pt-2'> | ||
<p>{commentBody}</p> | ||
</Collapsible.Body> | ||
</Collapsible.Advanced> | ||
</div> | ||
</> | ||
); | ||
}; | ||
Feedback.defaultProps = { | ||
defaultOpen: false, | ||
}; | ||
Feedback.propTypes = { | ||
defaultOpen: PropTypes.bool, | ||
}; | ||
|
||
export default 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import { Collapsible } from '@edx/paragon'; | ||
import { useIntl } from '@edx/frontend-platform/i18n'; | ||
import Feedback from './Feedback'; | ||
import messages from './messages'; | ||
|
||
const CollapsibleFeedback = ({ assessment, stepScore, stepName }) => { | ||
const assessmentCriterions = assessment.assessmentCriterions; | ||
const { formatMessage } = useIntl(); | ||
|
||
return ( | ||
<Collapsible | ||
title={ | ||
<h3> | ||
{formatMessage(messages.grade, { | ||
stepName, | ||
})} | ||
{stepScore && formatMessage(messages.gradePoints, stepScore)} | ||
</h3> | ||
} | ||
> | ||
{assessmentCriterions.map((criterion) => { | ||
return ( | ||
<Feedback | ||
key={criterion.name} | ||
criterion={criterion.name} | ||
selectedOption={criterion.selectedOption} | ||
selectedPoints={criterion.selectedPoints} | ||
commentHeader={stepName} | ||
commentBody={criterion.feedback} | ||
/> | ||
); | ||
})} | ||
<Feedback | ||
criterion={{ name: 'Overall Feedback' }} | ||
commentHeader={stepName} | ||
commentBody={assessment.overallFeedback} | ||
/> | ||
</Collapsible> | ||
); | ||
}; | ||
CollapsibleFeedback.defaultProps = {}; | ||
CollapsibleFeedback.propTypes = { | ||
// assessment: PropTypes.shape({ | ||
// overallFeedback: PropTypes.string, | ||
// }), | ||
stepName: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default CollapsibleFeedback; |
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,31 @@ | ||
import { defineMessages } from '@edx/frontend-platform/i18n'; | ||
|
||
const messages = defineMessages({ | ||
readMore: { | ||
id: 'ora-collapsible-comment.readMore', | ||
defaultMessage: 'Read more', | ||
description: 'Read more button text', | ||
}, | ||
readLess: { | ||
id: 'ora-collapsible-comment.readLess', | ||
defaultMessage: 'Read less', | ||
description: 'Read less button text', | ||
}, | ||
grade: { | ||
id: 'ora-collapsible-comment.grade', | ||
defaultMessage: '{stepName} Grade:', | ||
description: 'Grade button text', | ||
}, | ||
gradePoints: { | ||
id: 'ora-collapsible-comment.gradePoints', | ||
defaultMessage: '{earned} / {possible}', | ||
description: 'Grade points button text', | ||
}, | ||
notWeightedGradeLabel: { | ||
id: 'ora-collapsible-comment.notWeightedGradeLabel', | ||
defaultMessage: '(Not weighted toward final grade))', | ||
description: 'Not weighted grade label', | ||
}, | ||
}); | ||
|
||
export default messages; |
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
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
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
Oops, something went wrong.