From 87acb2f90c2fd42207ef12890c4ae98008c46222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kruli=C5=A1?= Date: Wed, 10 Apr 2024 17:34:27 +0200 Subject: [PATCH] Implementing group exams table which lists past exams. --- .../Groups/GroupExamsTable/GroupExamsTable.js | 83 +++++++++++++++++++ .../Groups/GroupExamsTable/index.js | 2 + src/locales/cs.json | 4 + src/locales/en.json | 4 + src/pages/GroupExams/GroupExams.js | 17 ++-- 5 files changed, 99 insertions(+), 11 deletions(-) create mode 100644 src/components/Groups/GroupExamsTable/GroupExamsTable.js create mode 100644 src/components/Groups/GroupExamsTable/index.js diff --git a/src/components/Groups/GroupExamsTable/GroupExamsTable.js b/src/components/Groups/GroupExamsTable/GroupExamsTable.js new file mode 100644 index 000000000..6cb90d22c --- /dev/null +++ b/src/components/Groups/GroupExamsTable/GroupExamsTable.js @@ -0,0 +1,83 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { FormattedMessage } from 'react-intl'; +import { Table } from 'react-bootstrap'; +import { defaultMemoize } from 'reselect'; + +import DateTime from '../../widgets/DateTime'; +import Button from '../../widgets/TheButton'; +import { VisibleIcon } from '../../icons'; + +const sortExams = defaultMemoize(exams => { + const sorted = [...exams]; + return sorted.sort((a, b) => a.end - b.end); +}); + +const GroupExamsTable = ({ exams = null, selected = null, setSelected = null }) => + exams && exams.length > 0 ? ( + + + + + + + {setSelected && + + + {sortExams(exams).map((exam, idx) => ( + + + + + + {setSelected && ( + + )} + + ))} + +
+ + + + + + + } +
#{idx + 1} + + + + + + {exam.strict ? ( + + ) : ( + + )} + + + +
+ ) : ( +
+ + + +
+ ); + +GroupExamsTable.propTypes = { + exams: PropTypes.array, + selected: PropTypes.string, + setSelected: PropTypes.func, +}; + +export default GroupExamsTable; diff --git a/src/components/Groups/GroupExamsTable/index.js b/src/components/Groups/GroupExamsTable/index.js new file mode 100644 index 000000000..21e00f983 --- /dev/null +++ b/src/components/Groups/GroupExamsTable/index.js @@ -0,0 +1,2 @@ +import GroupExamsTable from './GroupExamsTable'; +export default GroupExamsTable; diff --git a/src/locales/cs.json b/src/locales/cs.json index fe82555b8..45be72440 100644 --- a/src/locales/cs.json +++ b/src/locales/cs.json @@ -1092,6 +1092,10 @@ "app.groupExams.studentInfoStrict": "Navíc nebudete moct přistupovat k ostatním skupinám dokud budete v uzamčeném režimu.", "app.groupExams.timeAccuracyWarning": "Lokální hodiny na vašem systému musí být dostatečně seřízené, jinak nemusí tato komponenta fungovat zcela správně.", "app.groupExams.title": "Zkouškové termíny skupiny", + "app.groupExamsTable.begin": "Začala", + "app.groupExamsTable.end": "Skončila", + "app.groupExamsTable.lockType": "Typ zámku", + "app.groupExamsTable.selectButton": "Detail", "app.groupInfo.title": "Podrobnosti a metadata skupiny", "app.groupInvitationForm.expireAt": "Konec platnosti:", "app.groupInvitationForm.expireAtExplanation": "Odkaz pozvánky bude rozpoznatelný ReCodExem i po uplynutí doby platnosti, ale studenti jej nebudou moci použít.", diff --git a/src/locales/en.json b/src/locales/en.json index 93bbee7e4..1d02de1b5 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1092,6 +1092,10 @@ "app.groupExams.studentInfoStrict": "Furthermore, you will not be able to access other groups until the exam lock expires.", "app.groupExams.timeAccuracyWarning": "Your local system clock should be sufficiently synchronized or this component may not work properly.", "app.groupExams.title": "Group Exam Terms", + "app.groupExamsTable.begin": "Begun at", + "app.groupExamsTable.end": "Ended at", + "app.groupExamsTable.lockType": "Lock type", + "app.groupExamsTable.selectButton": "Detail", "app.groupInfo.title": "Group Details and Metadata", "app.groupInvitationForm.expireAt": "Expire at:", "app.groupInvitationForm.expireAtExplanation": "An invitation link will be still recognized by ReCodEx after the expiration date, but the students will not be allowed to use it.", diff --git a/src/pages/GroupExams/GroupExams.js b/src/pages/GroupExams/GroupExams.js index 92186dddd..65c852701 100644 --- a/src/pages/GroupExams/GroupExams.js +++ b/src/pages/GroupExams/GroupExams.js @@ -10,6 +10,7 @@ import Page from '../../components/layout/Page'; import { GroupNavigation } from '../../components/layout/Navigation'; import Box from '../../components/widgets/Box'; import GroupArchivedWarning from '../../components/Groups/GroupArchivedWarning'; +import GroupExamsTable from '../../components/Groups/GroupExamsTable'; import { GroupExamsIcon } from '../../components/icons'; import { fetchGroup, fetchGroupIfNeeded, setExamPeriod, removeExamPeriod } from '../../redux/modules/groups'; @@ -70,17 +71,11 @@ class GroupExams extends Component { - }> - {group.privateData.exams && group.privateData.exams.length > 0 ? null : ( -
- - - -
- )} + } + noPadding + unlimitedHeight> +