Skip to content

Commit c4f0238

Browse files
committed
Improving visualization of passing group points limits.
1 parent 1c3f0c8 commit c4f0238

File tree

6 files changed

+61
-71
lines changed

6 files changed

+61
-71
lines changed

src/components/Groups/ResultsTable/ResultsTable.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { createUserNameComparator } from '../../helpers/users.js';
2222
import { compareAssignments, compareShadowAssignments } from '../../helpers/assignments.js';
2323
import { downloadString } from '../../../redux/helpers/api/download.js';
2424
import Button from '../../widgets/TheButton';
25-
import Icon, { DownloadIcon, LoadingIcon, ReviewRequestIcon } from '../../icons';
25+
import Icon, { AcceptedIcon, DownloadIcon, LoadingIcon, ReviewRequestIcon } from '../../icons';
2626
import { safeGet, EMPTY_ARRAY, EMPTY_OBJ, hasPermissions } from '../../../helpers/common.js';
2727
import withLinks from '../../../helpers/withLinks.js';
2828
import { storageGetItem, storageSetItem } from '../../../helpers/localStorage.js';
@@ -382,6 +382,21 @@ class ResultsTable extends Component {
382382
)
383383
);
384384

385+
columns.push(
386+
new SortableTableColumnDescriptor('passed', '', {
387+
className: 'text-center shrink-col',
388+
headerSuffixClassName: styles.maxPointsRow,
389+
cellRenderer: stats => (
390+
<>
391+
{stats.hasLimit && stats.passesLimit && <AcceptedIcon className="text-success" />}
392+
{stats.hasLimit && !stats.passesLimit && (
393+
<Icon icon={['far', 'circle-xmark']} className="text-muted half-opaque" />
394+
)}
395+
</>
396+
),
397+
})
398+
);
399+
385400
if (hasPermissions(group, 'update')) {
386401
columns.push(
387402
new SortableTableColumnDescriptor('buttons', '', {
@@ -409,6 +424,7 @@ class ResultsTable extends Component {
409424
selected: !showOnlyMe && user.id === loggedUser.id,
410425
user,
411426
total: userStats && userStats.points,
427+
passed: userStats,
412428
buttons: renderActions && hasPermissions(group, 'update') ? renderActions(user.id) : '',
413429
// actually 'update' is not the right premission, but its sufficiently close :)
414430
};

src/components/Users/StudentsListItem/StudentsListItem.js

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,55 @@ const StudentsListItem = ({
1212
stats,
1313
renderActions,
1414
links: { GROUP_USER_SOLUTIONS_URI_FACTORY },
15-
}) => (
16-
<tr>
17-
<td>
18-
<UsersNameContainer userId={id} link={groupId && GROUP_USER_SOLUTIONS_URI_FACTORY(groupId, id)} listItem />
19-
</td>
20-
<td width={150}>
21-
{stats && (
22-
<ProgressBar
23-
className="progress-xs"
24-
now={stats.points.total > 0 ? Math.min(1, stats.points.gained / stats.points.total) * 100 : 0}
25-
variant={!stats.hasLimit ? 'info' : stats.passesLimit ? 'success' : 'danger'}
26-
/>
27-
)}
28-
</td>
29-
<td>
30-
{stats && (
31-
<FormattedMessage
32-
id="app.studentsList.gainedPointsOfWithoutBreakingSpaces"
33-
defaultMessage="{gained, number} of {total, number}"
34-
values={{ ...stats.points }}
35-
/>
36-
)}
37-
</td>
38-
{renderActions && <td>{renderActions(id)}</td>}
39-
</tr>
40-
);
15+
}) => {
16+
const totalPoints = (stats && stats && (stats.points.total || stats.points.limit)) || 0;
17+
return (
18+
<tr>
19+
<td>
20+
<UsersNameContainer userId={id} link={groupId && GROUP_USER_SOLUTIONS_URI_FACTORY(groupId, id)} listItem />
21+
</td>
22+
<td className="valign-middle">
23+
{stats && (
24+
<ProgressBar
25+
className="progress-xs"
26+
now={totalPoints > 0 ? Math.min(1, stats.points.gained / totalPoints) * 100 : 0}
27+
variant={!stats.hasLimit ? 'info' : stats.passesLimit ? 'success' : 'danger'}
28+
/>
29+
)}
30+
</td>
31+
<td className="text-nowrap shrink-col">
32+
{stats && (
33+
<>
34+
<FormattedMessage
35+
id="app.studentsList.gainedPointsOfWithoutBreakingSpaces"
36+
defaultMessage="{gained, number} of {total, number}"
37+
values={{ gained: stats.points.gained, total: totalPoints }}
38+
/>
39+
{Boolean(stats.points.limit && stats.points.total && stats.points.limit !== stats.points.total) && (
40+
<small className="ml-2 text-muted">
41+
{' '}
42+
<FormattedMessage
43+
id="app.studentsList.statsPointsLimit"
44+
defaultMessage="(required {limit, number})"
45+
values={{ limit: stats.points.limit }}
46+
/>
47+
</small>
48+
)}
49+
</>
50+
)}
51+
</td>
52+
{renderActions && <td>{renderActions(id)}</td>}
53+
</tr>
54+
);
55+
};
4156

4257
StudentsListItem.propTypes = {
4358
id: PropTypes.string.isRequired,
4459
groupId: PropTypes.string,
4560
stats: PropTypes.shape({
4661
points: PropTypes.shape({
4762
total: PropTypes.number.isRequired,
63+
limit: PropTypes.number,
4864
gained: PropTypes.number.isRequired,
4965
}),
5066
hasLimit: PropTypes.bool,

src/components/Users/UsersStats/UsersStats.js

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/components/Users/UsersStats/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/locales/cs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1949,6 +1949,7 @@
19491949
"app.sourceCodeViewer.utf8Warning": "Zdrojový soubor není v platném UTF-8 kódování. Některé znaky proto nemusí být zobrazeny správně. Pokud potřebujete soubor v původním kódování, použijte tlačítko k jeho stažení.",
19501950
"app.studentsList.gainedPointsOfWithoutBreakingSpaces": "{gained, number} z {total, number}",
19511951
"app.studentsList.noStudents": "V tomto seznamu nejsou žádní studenti.",
1952+
"app.studentsList.statsPointsLimit": "(požadováno {limit, number})",
19521953
"app.submission.evaluation.bonusPoints": "Bonusové body:",
19531954
"app.submission.evaluation.title": "Podrobnosti odevzdaného řešení",
19541955
"app.submission.evaluation.title.testResults": "Výsledky testů",
@@ -2090,7 +2091,6 @@
20902091
"app.users.title": "Seznam všech uživatelů",
20912092
"app.users.userCreatedAt": "Uživatel vytvořen",
20922093
"app.usersName.notVerified.title": "Tento účet nemá ověřenou e-mailovou adresu.",
2093-
"app.usersStats.description": "Body získané ve skupině {name}.",
20942094
"app.usersname.notVerified.description": "Tento uživatel si neověřil svou e-mailovou adresu přes aktivační odkaz, který mu byl na tuto adresu zaslán.",
20952095
"diff": "Sudí binárních dat",
20962096
"generic.accept": "Akceptovat",

src/locales/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1949,6 +1949,7 @@
19491949
"app.sourceCodeViewer.utf8Warning": "The source file is not a valid UTF-8 file. Some characters may be displayed incorrectly. Use the download button to see unaltered source file.",
19501950
"app.studentsList.gainedPointsOfWithoutBreakingSpaces": "{gained, number} of {total, number}",
19511951
"app.studentsList.noStudents": "There are no students in this list.",
1952+
"app.studentsList.statsPointsLimit": "(required {limit, number})",
19521953
"app.submission.evaluation.bonusPoints": "Bonus points:",
19531954
"app.submission.evaluation.title": "Solution Detail",
19541955
"app.submission.evaluation.title.testResults": "Test Results",
@@ -2090,7 +2091,6 @@
20902091
"app.users.title": "List of All Users",
20912092
"app.users.userCreatedAt": "User created",
20922093
"app.usersName.notVerified.title": "This account does not have a verified email address yet.",
2093-
"app.usersStats.description": "Points gained from {name}.",
20942094
"app.usersname.notVerified.description": "This user has not verified his/her email address via an activation link he has received to his email address.",
20952095
"diff": "Binary-safe judge",
20962096
"generic.accept": "Accept",

0 commit comments

Comments
 (0)