Skip to content

Commit 6aeb6c6

Browse files
committed
Additional view modes for assignment solutions.
1 parent dd220be commit 6aeb6c6

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

src/locales/cs.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,12 @@
157157
"app.assignmentSolutions.pendingReviews": "V tuto chvíli {count, plural, one {je otevřena} =2 {jsou otevřeny} =3 {jsou otevřeny} =4 {jsou otevřeny} other {je otevřeno}} {count} {count, plural, one {revize} =2 {revize} =3 {revize} =4 {revize} other {revizí}} ze všech řešení vybrané úlohy. Nezapomeňte, že autoři úloh vidí vaše komentáře zdrojových kódů až poté, co jsou příslušné revize uzavřeny.",
158158
"app.assignmentSolutions.plagiarismsDetected": "V seznamu {count, plural, one {je zobrazeno} =2 {jsou zobrazena} =3 {jsou zobrazena} =4 {jsou zobrazena} other {je zobrazeno}} {count} řešení, {count, plural, one {ke kterému} other {ke kterým}} byla nelezena podobná řešení. V takových případech se může jednat o plagiáty.",
159159
"app.assignmentSolutions.title": "Všechna řešení zadané úlohy",
160+
"app.assignmentSolutions.viewModes.accepted": "Pouze akceptovaná řešení",
160161
"app.assignmentSolutions.viewModes.best": "Pouze nejlepší řešení",
161162
"app.assignmentSolutions.viewModes.default": "Všechna řešení (výchozí)",
162163
"app.assignmentSolutions.viewModes.grouped": "Seskupit dle uživatelů",
164+
"app.assignmentSolutions.viewModes.last": "Pouze poslední řešení",
165+
"app.assignmentSolutions.viewModes.reviewed": "Pouze revidovaná řešení",
163166
"app.assignmentSolutions.viewModesTitle": "Vyberte způsob zobrazení řešení",
164167
"app.assignments.deadline": "Termín odevzdání",
165168
"app.assignments.deleteAllButton": "Smazat",

src/locales/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,12 @@
157157
"app.assignmentSolutions.pendingReviews": "There {count, plural, one {is} other {are}} {count} pending {count, plural, one {review} other {reviews}} among the solutions of the selected assignment. Remember that the review comments are visible to the author after a review is closed.",
158158
"app.assignmentSolutions.plagiarismsDetected": "There {count, plural, one {is} other {are}} {count} {count, plural, one {solution} other {solutions}} with detected similarities. Such solutions may be plagiarisms.",
159159
"app.assignmentSolutions.title": "All Submissions of The Assignment",
160+
"app.assignmentSolutions.viewModes.accepted": "Accepted solutions only",
160161
"app.assignmentSolutions.viewModes.best": "Best solutions only",
161162
"app.assignmentSolutions.viewModes.default": "All solutions (default)",
162163
"app.assignmentSolutions.viewModes.grouped": "Grouped by users",
164+
"app.assignmentSolutions.viewModes.last": "Latest solutions only",
165+
"app.assignmentSolutions.viewModes.reviewed": "Reviewed solutions only",
163166
"app.assignmentSolutions.viewModesTitle": "Select solutions view filter",
164167
"app.assignments.deadline": "Deadline",
165168
"app.assignments.deleteAllButton": "Delete",

src/pages/AssignmentSolutions/AssignmentSolutions.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,14 @@ import { storageGetItem, storageSetItem } from '../../helpers/localStorage';
6969
import withLinks from '../../helpers/withLinks';
7070
import { safeGet, identity, arrayToObject, toPlainAscii, hasPermissions } from '../../helpers/common';
7171

72+
// View mode keys, labels, and filtering functions
7273
const VIEW_MODE_DEFAULT = 'default';
7374
const VIEW_MODE_GROUPED = 'grouped';
7475
const VIEW_MODE_BEST = 'best';
76+
const VIEW_MODE_LAST = 'last';
77+
const VIEW_MODE_ACCEPTED = 'accepted';
78+
const VIEW_MODE_REVIEWD = 'reviewed';
79+
7580
const viewModes = {
7681
[VIEW_MODE_DEFAULT]: (
7782
<FormattedMessage id="app.assignmentSolutions.viewModes.default" defaultMessage="All solutions (default)" />
@@ -82,6 +87,33 @@ const viewModes = {
8287
[VIEW_MODE_BEST]: (
8388
<FormattedMessage id="app.assignmentSolutions.viewModes.best" defaultMessage="Best solutions only" />
8489
),
90+
[VIEW_MODE_LAST]: (
91+
<FormattedMessage id="app.assignmentSolutions.viewModes.last" defaultMessage="Latest solutions only" />
92+
),
93+
[VIEW_MODE_ACCEPTED]: (
94+
<FormattedMessage id="app.assignmentSolutions.viewModes.accepted" defaultMessage="Accepted solutions only" />
95+
),
96+
[VIEW_MODE_REVIEWD]: (
97+
<FormattedMessage id="app.assignmentSolutions.viewModes.reviewed" defaultMessage="Reviewed solutions only" />
98+
),
99+
};
100+
101+
const _getLastAttemptIndices = defaultMemoize(solutions => {
102+
const lastAttemptIndices = {};
103+
solutions.filter(identity).forEach(s => {
104+
lastAttemptIndices[s.authorId] = Math.max(s.attemptIndex || 0, lastAttemptIndices[s.authorId] || 0);
105+
});
106+
return lastAttemptIndices;
107+
});
108+
109+
const viewModeFilters = {
110+
[VIEW_MODE_DEFAULT]: null,
111+
[VIEW_MODE_GROUPED]: null,
112+
[VIEW_MODE_BEST]: solution => solution && solution.isBestSolution,
113+
[VIEW_MODE_LAST]: (solution, _, solutions) =>
114+
solution && solution.attemptIndex === _getLastAttemptIndices(solutions)[solution.authorId],
115+
[VIEW_MODE_ACCEPTED]: solution => solution && solution.accepted,
116+
[VIEW_MODE_REVIEWD]: solution => solution && solution.review,
85117
};
86118

87119
const prepareTableColumnDescriptors = defaultMemoize((loggedUserId, assignmentId, groupId, viewMode, locale, links) => {
@@ -262,7 +294,7 @@ const prepareTableData = defaultMemoize(
262294
.toArray()
263295
.map(getJsData)
264296
.filter(solution => solution && usersIndex[solution.authorId])
265-
.filter(viewMode === VIEW_MODE_BEST ? solution => solution && solution.isBestSolution : identity)
297+
.filter(viewModeFilters[viewMode] || identity)
266298
.map(
267299
({
268300
id,

0 commit comments

Comments
 (0)