Skip to content

Commit

Permalink
Suspected plagiarism indicator icon added in solutions tables.
Browse files Browse the repository at this point in the history
  • Loading branch information
krulis-martin committed Apr 23, 2023
1 parent 4615c37 commit 6027a15
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 9 deletions.
20 changes: 20 additions & 0 deletions src/components/Assignments/SolutionsTable/SolutionTableRowIcons.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import React from 'react';
import PropTypes from 'prop-types';
import { OverlayTrigger, Tooltip } from 'react-bootstrap';
import { FormattedMessage } from 'react-intl';

import SolutionReviewIcon from '../../Solutions/SolutionReviewIcon';
import AssignmentStatusIcon, { getStatusDesc } from '../Assignment/AssignmentStatusIcon';
import CommentsIcon from './CommentsIcon';
import { PlagiarismIcon } from '../../icons';

const SolutionTableRowIcons = ({
id,
Expand All @@ -14,6 +17,7 @@ const SolutionTableRowIcons = ({
lastSubmission,
commentsStats = null,
isReviewer = false,
plagiarism = false,
}) => (
<>
<AssignmentStatusIcon
Expand All @@ -25,6 +29,21 @@ const SolutionTableRowIcons = ({

{review && <SolutionReviewIcon id={`review-${id}`} review={review} isReviewer={isReviewer} gapLeft />}

{plagiarism && isReviewer && (
<OverlayTrigger
placement="right"
overlay={
<Tooltip id={id}>
<FormattedMessage
id="app.solutionsTable.icons.suspectedPlagiarism"
defaultMessage="Suspected plagiarism (similarities with other solutions were found)"
/>
</Tooltip>
}>
<PlagiarismIcon className="text-danger fa-beat" gapLeft />
</OverlayTrigger>
)}

<CommentsIcon id={id} commentsStats={commentsStats} gapLeft />
</>
);
Expand All @@ -47,6 +66,7 @@ SolutionTableRowIcons.propTypes = {
}),
}),
isReviewer: PropTypes.bool,
plagiarism: PropTypes.bool,
};

export default SolutionTableRowIcons;
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const SolutionsTableRow = ({
accepted = false,
review = null,
isBestSolution = false,
plagiarism = null,
runtimeEnvironment = null,
commentsStats = null,
permissionHints = null,
Expand Down Expand Up @@ -88,6 +89,7 @@ const SolutionsTableRow = ({
lastSubmission={lastSubmission}
commentsStats={commentsStats}
isReviewer={permissionHints && permissionHints.review}
plagiarism={Boolean(plagiarism)}
/>
</td>

Expand Down Expand Up @@ -227,6 +229,7 @@ SolutionsTableRow.propTypes = {
}),
isBestSolution: PropTypes.bool,
commentsStats: PropTypes.object,
plagiarism: PropTypes.string,
runtimeEnvironment: PropTypes.object,
permissionHints: PropTypes.object,
noteMaxlen: PropTypes.number,
Expand Down
1 change: 1 addition & 0 deletions src/components/icons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const ObserverIcon = props => <Icon {...props} icon="binoculars" />;
export const OutputIcon = props => <Icon {...props} icon="sign-out-alt" />;
export const PipelineIcon = props => <Icon {...props} icon="random" />;
export const PipelineStructureIcon = props => <Icon {...props} icon="sitemap" />;
export const PlagiarismIcon = props => <Icon icon="person-circle-exclamation" {...props} />;
export const PointsDecreasedIcon = props => <Icon icon="level-down-alt" className="text-muted" {...props} />;
export const PointsGraphIcon = props => <Icon icon={['far', 'chart-bar']} {...props} />;
export const PointsInterpolationIcon = props => (
Expand Down
1 change: 1 addition & 0 deletions src/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1713,6 +1713,7 @@
"app.solutionsTable.commentsIcon.last": "Poslední komentář: {last}",
"app.solutionsTable.environment": "Cílový jazyk",
"app.solutionsTable.failedLoading": "Nebylo možné načíst odevzdaná řešení.",
"app.solutionsTable.icons.suspectedPlagiarism": "Podezření na plagiátorství (byly nalezeny podobnosti s jinými řešeními)",
"app.solutionsTable.loading": "Načítají se odezvdaná řešení...",
"app.solutionsTable.noSolutionsFound": "Zatím nebyla odevzdána žádná řešení.",
"app.solutionsTable.note": "Poznámka",
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1713,6 +1713,7 @@
"app.solutionsTable.commentsIcon.last": "Last Comment: {last}",
"app.solutionsTable.environment": "Target language",
"app.solutionsTable.failedLoading": "Could not load this submission.",
"app.solutionsTable.icons.suspectedPlagiarism": "Suspected plagiarism (similarities with other solutions were found)",
"app.solutionsTable.loading": "Loading submitted solutions...",
"app.solutionsTable.noSolutionsFound": "No solutions were submitted yet.",
"app.solutionsTable.note": "Note",
Expand Down
36 changes: 27 additions & 9 deletions src/pages/AssignmentStats/AssignmentStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ import CommentThreadContainer from '../../containers/CommentThreadContainer';

import Page from '../../components/layout/Page';
import { AssignmentNavigation } from '../../components/layout/Navigation';
import Icon, { ChatIcon, DownloadIcon, DetailIcon, LoadingIcon, ResultsIcon, UserIcon } from '../../components/icons';
import Icon, {
ChatIcon,
DownloadIcon,
DetailIcon,
CodeFileIcon,
LoadingIcon,
ResultsIcon,
UserIcon,
} from '../../components/icons';
import SolutionTableRowIcons from '../../components/Assignments/SolutionsTable/SolutionTableRowIcons';
import UsersName from '../../components/Users/UsersName';
import Points from '../../components/Assignments/SolutionsTable/Points';
Expand Down Expand Up @@ -62,7 +70,7 @@ import withLinks from '../../helpers/withLinks';
import { safeGet, identity, arrayToObject, toPlainAscii, hasPermissions } from '../../helpers/common';

const prepareTableColumnDescriptors = defaultMemoize((loggedUserId, assignmentId, groupId, locale, links) => {
const { SOLUTION_DETAIL_URI_FACTORY, GROUP_USER_SOLUTIONS_URI_FACTORY } = links;
const { SOLUTION_DETAIL_URI_FACTORY, SOLUTION_SOURCE_CODES_URI_FACTORY, GROUP_USER_SOLUTIONS_URI_FACTORY } = links;
const nameComparator = createUserNameComparator(locale);

const columns = [
Expand All @@ -78,6 +86,7 @@ const prepareTableColumnDescriptors = defaultMemoize((loggedUserId, assignmentId
status={info.lastSubmission ? info.lastSubmission.evaluationStatus : null}
lastSubmission={info.lastSubmission}
commentsStats={info.commentsStats}
plagiarism={Boolean(info.plagiarism)}
/>
),
}),
Expand Down Expand Up @@ -170,12 +179,20 @@ const prepareTableColumnDescriptors = defaultMemoize((loggedUserId, assignmentId
cellRenderer: solution => (
<TheButtonGroup>
{solution.permissionHints && solution.permissionHints.viewDetail && (
<Link to={SOLUTION_DETAIL_URI_FACTORY(assignmentId, solution.id)}>
<Button size="xs" variant="secondary">
<DetailIcon gapRight />
<FormattedMessage id="generic.detail" defaultMessage="Detail" />
</Button>
</Link>
<>
<Link to={SOLUTION_DETAIL_URI_FACTORY(assignmentId, solution.id)}>
<Button size="xs" variant="secondary">
<DetailIcon gapRight />
<FormattedMessage id="generic.detail" defaultMessage="Detail" />
</Button>
</Link>
<Link to={SOLUTION_SOURCE_CODES_URI_FACTORY(assignmentId, solution.id)}>
<Button size="xs" variant="primary">
<CodeFileIcon fixedWidth gapRight />
<FormattedMessage id="generic.files" defaultMessage="Files" />
</Button>
</Link>
</>
)}
{solution.permissionHints && solution.permissionHints.setFlag && (
<AcceptSolutionContainer id={solution.id} locale={locale} shortLabel size="xs" />
Expand Down Expand Up @@ -218,12 +235,13 @@ const prepareTableData = defaultMemoize(
isBestSolution,
commentsStats,
permissionHints,
plagiarism = null,
}) => {
const statusEvaluated =
lastSubmission &&
(lastSubmission.evaluationStatus === 'done' || lastSubmission.evaluationStatus === 'failed');
return {
icon: { id, commentsStats, lastSubmission, accepted, review, permissionHints, isBestSolution },
icon: { id, commentsStats, lastSubmission, accepted, review, permissionHints, isBestSolution, plagiarism },
user: usersIndex[authorId],
date: createdAt,
validity: statusEvaluated ? safeGet(lastSubmission, ['evaluation', 'score']) : null,
Expand Down

0 comments on commit 6027a15

Please sign in to comment.