Skip to content

Commit

Permalink
Adding exam checkbox indicator in the (sub)group creation form.
Browse files Browse the repository at this point in the history
  • Loading branch information
krulis-martin committed Apr 11, 2024
1 parent 4c4d3b5 commit 3b4b80b
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 25 deletions.
58 changes: 37 additions & 21 deletions src/components/forms/EditGroupForm/EditGroupForm.js
Expand Up @@ -24,6 +24,7 @@ export const EDIT_GROUP_FORM_EMPTY_INITIAL_VALUES = {
publicStats: false,
hasThreshold: false,
isOrganizational: false,
isExam: false,
detaining: false,
makeMeAdmin: true,
threshold: 0,
Expand All @@ -47,6 +48,7 @@ const EditGroupForm = ({
reset,
isSuperAdmin,
isOrganizational = false,
isExam = false,
}) => (
<FormBox
title={
Expand Down Expand Up @@ -103,7 +105,7 @@ const EditGroupForm = ({
{isSuperAdmin && (
<Field
name="externalId"
tabIndex={2}
tabIndex={10}
component={TextField}
maxLength={255}
required
Expand All @@ -122,7 +124,7 @@ const EditGroupForm = ({
<Col lg={6}>
<Field
name="isPublic"
tabIndex={3}
tabIndex={20}
component={CheckboxField}
onOff
label={
Expand All @@ -138,7 +140,7 @@ const EditGroupForm = ({
<Col lg={6}>
<Field
name="publicStats"
tabIndex={4}
tabIndex={30}
component={CheckboxField}
onOff
label={
Expand All @@ -151,27 +153,40 @@ const EditGroupForm = ({
</Col>

{createNew && (
<Col lg={6}>
<Field
name="isOrganizational"
tabIndex={5}
component={CheckboxField}
onOff
label={
<FormattedMessage
id="app.createGroup.isOrganizational"
defaultMessage="Organizational (for structural purposes only)"
/>
}
/>
</Col>
<>
<Col lg={6}>
<Field
name="isOrganizational"
tabIndex={40}
component={CheckboxField}
onOff
label={
<FormattedMessage
id="app.createGroup.isOrganizational"
defaultMessage="Organizational (for structural purposes only)"
/>
}
disabled={isExam}
/>
</Col>
<Col lg={6}>
<Field
name="isExam"
tabIndex={45}
component={CheckboxField}
onOff
label={<FormattedMessage id="app.createGroup.isExam" defaultMessage="Exam" />}
disabled={isOrganizational}
/>
</Col>
</>
)}

{!isOrganizational && (
<Col lg={6}>
<Field
name="detaining"
tabIndex={6}
tabIndex={50}
component={CheckboxField}
onOff
label={
Expand All @@ -188,7 +203,7 @@ const EditGroupForm = ({
<Col lg={6}>
<Field
name="makeMeAdmin"
tabIndex={5}
tabIndex={60}
component={CheckboxField}
onOff
label={<FormattedMessage id="app.createGroup.makeMeAdmin" defaultMessage="Make me a group admin" />}
Expand All @@ -201,7 +216,7 @@ const EditGroupForm = ({
<Col lg={6}>
<Field
name="hasThreshold"
tabIndex={7}
tabIndex={70}
component={CheckboxField}
onOff
label={
Expand All @@ -216,7 +231,7 @@ const EditGroupForm = ({
{hasThreshold && (
<NumericTextField
name="threshold"
tabIndex={8}
tabIndex={80}
validateMin={0}
validateMax={100}
maxLength={3}
Expand Down Expand Up @@ -253,6 +268,7 @@ EditGroupForm.propTypes = {
reset: PropTypes.func,
isSuperAdmin: PropTypes.bool,
isOrganizational: PropTypes.bool,
isExam: PropTypes.bool,
};

const validate = ({ localizedTexts }) => {
Expand Down
1 change: 1 addition & 0 deletions src/locales/cs.json
Expand Up @@ -265,6 +265,7 @@
"app.createExerciseForm.title": "Vytvořit novou úlohu",
"app.createExerciseForm.validation.noGroupSelected": "Nebyla vybrána domovská skupina.",
"app.createGroup.detaining": "Zadržuje studenty (jen vedoucí může studenty odebrat)",
"app.createGroup.isExam": "Zkoušková",
"app.createGroup.externalId": "Externí identifikátor skupiny (aby bylo možné snáze vyrábět vazby na externí datové zdroje):",
"app.createGroup.hasThreshold": "Studenti potřebují určitý počet bodů pro splnění kurzu",
"app.createGroup.isOrganizational": "Organizační (pro vytváření hierarchie)",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en.json
Expand Up @@ -265,6 +265,7 @@
"app.createExerciseForm.title": "Create New Exercise",
"app.createExerciseForm.validation.noGroupSelected": "No group of residence has been selected.",
"app.createGroup.detaining": "Detaining students (only supervisor can remove them)",
"app.createGroup.isExam": "Exam",
"app.createGroup.externalId": "External ID of the group (helps create bindings to external data sources):",
"app.createGroup.hasThreshold": "Students require cetrain number of points to complete the course",
"app.createGroup.isOrganizational": "Organizational (for structural purposes only)",
Expand Down Expand Up @@ -2137,4 +2138,4 @@
"recodex-judge-shuffle-all": "Unordered-tokens-and-rows judge",
"recodex-judge-shuffle-newline": "Unordered-tokens judge (ignoring ends of lines)",
"recodex-judge-shuffle-rows": "Unordered-rows judge"
}
}
6 changes: 3 additions & 3 deletions src/locales/whitelist_cs.json
Expand Up @@ -109,6 +109,7 @@
"app.externalRegistrationForm.instance",
"app.failureList.headLink",
"app.faq.title",
"app.groupExamsTable.selectButton",
"app.homepage.githubLink",
"app.homepage.title",
"app.instancesTable.admin",
Expand Down Expand Up @@ -163,6 +164,5 @@
"app.systemMessagesList.text",
"generic.detail",
"generic.email",
"generic.role",
"app.groupExamsTable.selectButton"
]
"generic.role"
]
8 changes: 8 additions & 0 deletions src/pages/GroupInfo/GroupInfo.js
Expand Up @@ -104,6 +104,8 @@ class GroupInfo extends Component {
isStudent,
addSubgroup,
hasThreshold,
isOrganizational,
isExam,
pendingMemberships,
addAdmin,
addSupervisor,
Expand Down Expand Up @@ -248,6 +250,8 @@ class GroupInfo extends Component {
isOpen={false}
hasThreshold={hasThreshold}
isSuperAdmin={isSuperAdmin}
isOrganizational={isOrganizational}
isExam={isExam}
/>
)}
</Col>
Expand Down Expand Up @@ -283,6 +287,8 @@ GroupInfo.propTypes = {
addObserver: PropTypes.func.isRequired,
removeMember: PropTypes.func.isRequired,
hasThreshold: PropTypes.bool,
isOrganizational: PropTypes.bool,
isExam: PropTypes.bool,
pendingMemberships: ImmutablePropTypes.list,
links: PropTypes.object,
intl: PropTypes.shape({ locale: PropTypes.string.isRequired }).isRequired,
Expand All @@ -308,6 +314,8 @@ const mapStateToProps = (state, { params: { groupId } }) => {
isSuperAdmin: isLoggedAsSuperAdmin(state),
isStudent: loggedUserIsStudentOfSelector(state)(groupId),
hasThreshold: addSubgroupFormSelector(state, 'hasThreshold'),
isOrganizational: addSubgroupFormSelector(state, 'isOrganizational'),
isExam: addSubgroupFormSelector(state, 'isExam'),
pendingMemberships: pendingMembershipsSelector(state, groupId),
};
};
Expand Down
8 changes: 8 additions & 0 deletions src/pages/Instance/Instance.js
Expand Up @@ -64,6 +64,8 @@ class Instance extends Component {
isAdmin,
isSuperAdmin,
hasThreshold,
isOrganizational,
isExam,
links: { ADMIN_EDIT_INSTANCE_URI_FACTORY },
intl: { locale },
} = this.props;
Expand Down Expand Up @@ -146,6 +148,8 @@ class Instance extends Component {
collapsable
isOpen={false}
hasThreshold={hasThreshold}
isOrganizational={isOrganizational}
isExam={isExam}
isSuperAdmin={isSuperAdmin}
/>
)}
Expand Down Expand Up @@ -173,6 +177,8 @@ Instance.propTypes = {
isSuperAdmin: PropTypes.bool.isRequired,
links: PropTypes.object.isRequired,
hasThreshold: PropTypes.bool,
isOrganizational: PropTypes.bool,
isExam: PropTypes.bool,
intl: PropTypes.shape({ locale: PropTypes.string.isRequired }).isRequired,
};

Expand All @@ -190,6 +196,8 @@ export default withLinks(
isAdmin: isAdminOfInstance(userId, instanceId)(state),
isSuperAdmin: isLoggedAsSuperAdmin(state),
hasThreshold: addGroupFormSelector(state, 'hasThreshold'),
isOrganizational: addGroupFormSelector(state, 'isOrganizational'),
isExam: addGroupFormSelector(state, 'isExam'),
};
},
(dispatch, { params: { instanceId } }) => ({
Expand Down

0 comments on commit 3b4b80b

Please sign in to comment.