forked from openedx/frontend-app-ora-grading
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add turnitin displayer to submission preview
- Loading branch information
1 parent
1d924b4
commit 3d98f99
Showing
14 changed files
with
229 additions
and
4 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
12 changes: 12 additions & 0 deletions
12
src/containers/TurnitinDisplay/components/FileNameCell.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,12 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export const FileNameCell = ({ value }) => ( | ||
<div className="text-truncate">{value.split('.')?.shift()}</div> | ||
); | ||
|
||
FileNameCell.propTypes = { | ||
value: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default FileNameCell; |
19 changes: 19 additions & 0 deletions
19
src/containers/TurnitinDisplay/components/HyperlinkCell.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,19 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Hyperlink } from '@edx/paragon'; | ||
import { useIntl } from '@edx/frontend-platform/i18n'; | ||
import messages from './messages'; | ||
|
||
export const HyperlinkCell = ({ value }) => { | ||
const intl = useIntl(); | ||
return ( | ||
<Hyperlink destination={value} target="_blank"> | ||
{intl.formatMessage(messages.buttonViewerURLTitle)} | ||
</Hyperlink> | ||
) | ||
} | ||
HyperlinkCell.propTypes = { | ||
value: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default HyperlinkCell; |
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,41 @@ | ||
import { defineMessages } from '@edx/frontend-platform/i18n'; | ||
|
||
const messages = defineMessages({ | ||
fileNameTableHeader: { | ||
id: 'ora-grading.TurnitinDisplay.FileNameCell.fileNameTitle', | ||
defaultMessage: 'Responses', | ||
description: 'Title for files attached to the submission', | ||
}, | ||
URLTableHeader: { | ||
id: 'ora-grading.TurnitinDisplay.FileNameCell.tableNameHeader', | ||
defaultMessage: 'URL', | ||
description: 'Title for the file name column in the table', | ||
}, | ||
buttonViewerURLTitle: { | ||
id: 'ora-grading.TurnitinDisplay.ButtonCell.URLButtonCellTitle', | ||
defaultMessage: 'View in Turnitin', | ||
description: 'Title for the button that opens the viewer in a new tab', | ||
}, | ||
similarityReportsTitle: { | ||
id: 'ora-grading.TurnitinDisplay.SimilarityReportsTitle', | ||
defaultMessage: 'Turnitin Similarity Reports', | ||
description: 'Title for the Turnitin Similarity Reports section', | ||
}, | ||
noSimilarityReports: { | ||
id: 'ora-grading.TurnitinDisplay.NoSimilarityReports', | ||
defaultMessage: 'No Turnitin Similarity Reports to show', | ||
description: 'Message to display when there are no Turnitin Similarity Reports to show', | ||
}, | ||
viewerURLExpired: { | ||
id: 'ora-grading.TurnitinDisplay.ViewerURLExpired', | ||
defaultMessage: 'The Similarity Report URLs have a very short lifespan (less than 1 minute) after which it will no longer be valid. Once a user has been redirected to this URL, they will be given a session that will last for 1 hour. When expired, please refresh the page to get a new URL.', | ||
description: 'Message to display when the viewer URL has expired', | ||
}, | ||
viewerURLExpiredTitle: { | ||
id: 'ora-grading.TurnitinDisplay.ViewerURLExpiredTitle', | ||
defaultMessage: 'URLs expire quickly', | ||
description: 'Title for the warning message when the viewer URL has expired', | ||
}, | ||
}); | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import React, { useState } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { connect } from 'react-redux'; | ||
|
||
import { | ||
Card, Collapsible, Icon, DataTable, Alert, | ||
} from '@edx/paragon'; | ||
import { ArrowDropDown, ArrowDropUp, WarningFilled } from '@edx/paragon/icons'; | ||
import messages from './components/messages'; | ||
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; | ||
|
||
import FileNameCell from './components/FileNameCell'; | ||
import HyperlinkCell from './components/HyperlinkCell'; | ||
|
||
|
||
/** | ||
* <TurnitinDisplay /> | ||
*/ | ||
export const TurnitinDisplay = ({ viewers, intl }) => { | ||
const [isWarningOpen, setIsWarningOpen] = useState(true); | ||
return <Card className="submission-files p-3"> | ||
{viewers.length ? ( | ||
<> | ||
<Collapsible.Advanced defaultOpen> | ||
<Collapsible.Trigger className="submission-files-title"> | ||
<h3>{intl.formatMessage(messages.similarityReportsTitle)}</h3> | ||
<Collapsible.Visible whenClosed> | ||
<Icon src={ArrowDropDown} /> | ||
</Collapsible.Visible> | ||
<Collapsible.Visible whenOpen> | ||
<Icon src={ArrowDropUp} /> | ||
</Collapsible.Visible> | ||
</Collapsible.Trigger> | ||
<Collapsible.Body className="submission-files-body"> | ||
<Alert | ||
variant="warning" | ||
dismissible | ||
icon={WarningFilled} | ||
show={isWarningOpen} | ||
onClose={() => setIsWarningOpen(false)} | ||
> | ||
<Alert.Heading as="h4">{intl.formatMessage(messages.viewerURLExpiredTitle)}</Alert.Heading> | ||
<p className="small mb-0">{intl.formatMessage(messages.viewerURLExpired)}</p> | ||
</Alert> | ||
<div className="submission-files-table"> | ||
<DataTable | ||
columns={[ | ||
{ | ||
Header: intl.formatMessage(messages.fileNameTableHeader), | ||
accessor: "file_name", | ||
Cell: FileNameCell, | ||
}, | ||
{ | ||
Header: intl.formatMessage(messages.URLTableHeader), | ||
accessor: "url", | ||
Cell: HyperlinkCell, | ||
}, | ||
]} | ||
data={viewers} | ||
itemCount={viewers.length} | ||
> | ||
<DataTable.Table /> | ||
</DataTable> | ||
</div> | ||
</Collapsible.Body> | ||
</Collapsible.Advanced> | ||
<Card.Footer> | ||
</Card.Footer> | ||
</> | ||
) : ( | ||
<div className="submission-files-empty"> | ||
<WarningFilled /> | ||
<p>{intl.formatMessage(messages.noSimilarityReports)}</p> | ||
</div> | ||
)} | ||
</Card> | ||
}; | ||
|
||
|
||
TurnitinDisplay.defaultProps = { | ||
viewers: [], | ||
}; | ||
|
||
|
||
TurnitinDisplay.propTypes = { | ||
viewers: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
viewer_url: PropTypes.string.isRequired, | ||
}), | ||
), | ||
// injected | ||
intl: intlShape.isRequired, | ||
}; | ||
|
||
export const mapStateToProps = (state) => ({ | ||
viewers: selectors.grading.selected.turnitinViewers(state), | ||
}); | ||
|
||
export const mapDispatchToProps = {}; | ||
|
||
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(TurnitinDisplay)); |
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