Skip to content

Commit

Permalink
[Training] enhances registration
Browse files Browse the repository at this point in the history
  • Loading branch information
Elorfin committed Apr 15, 2023
1 parent 6f10d94 commit b2cf9d5
Show file tree
Hide file tree
Showing 105 changed files with 2,983 additions and 1,655 deletions.
4 changes: 2 additions & 2 deletions VERSION.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
13.7.0
13.8.0
882ae08e7824ac27c201482ea148afe13bb3f6a7
13.7
13.8
6 changes: 6 additions & 0 deletions changelogs/changelog-13.8.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Trainings:
- Add a custom registration form (as for the user profile or the database resource) on the courses.
- Add a "Statistics" view to see the answers given to the registration
- Possibility to choose the roles to be assigned to the participants (tutors and learners) of the courses.
- Added a Participants view at course level to view registrations in all sessions of the course.
- Other small improvements and fixes to the Training tool
6 changes: 6 additions & 0 deletions changelogs/changelog-13.8.fr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Formations:
- Ajout d'un formulaire d'inscription personnalisé (comme pour le profil utilisateur ou la ressource Base de données) sur les formations.
- Ajout d'une vue "Statistiques" pour visualiser les réponses données au formulaire d'inscription.
- Possibilité de choisir les rôles à affecter aux participants (tuteurs et apprenants) des formations.
- Ajout d'une vue Participants au niveau de la formation pour visualiser les inscriptions dans toutes les sessions de la formation.
- Autres petites améliorations et correctifs sur l'outil Formation
23 changes: 16 additions & 7 deletions src/main/app/API/Crud.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,31 @@ public function __construct(
*
* @return object|null
*/
public function get(string $class, $id, string $idProp = 'id')
public function get(string $class, $id, string $idProp = 'id', ?array $options = [])
{
$object = null;

if ('id' === $idProp) {
if (!is_numeric($id) && property_exists($class, 'uuid')) {
return $this->om->getRepository($class)->findOneBy(['uuid' => $id]);
$object = $this->om->getRepository($class)->findOneBy(['uuid' => $id]);
} else {
$object = $this->om->getRepository($class)->findOneBy(['id' => $id]);
}
} else {
$identifiers = $this->schema->getIdentifiers($class);
if (!in_array($idProp, $identifiers)) {
throw new \LogicException(sprintf('You can only get entities with an identifier property (identifiers: %s).', implode(', ', $identifiers)));
}

return $this->om->getRepository($class)->findOneBy(['id' => $id]);
$object = $this->om->getRepository($class)->findOneBy([$idProp => $id]);
}

$identifiers = $this->schema->getIdentifiers($class);
if (!in_array($idProp, $identifiers)) {
throw new \LogicException(sprintf('You can only get entities with an identifier property (identifiers: %s).', implode(', ', $identifiers)));
if ($object && !in_array(static::NO_PERMISSIONS, $options)) {
// creates the entity if allowed
$this->checkPermission('OPEN', $object, [], true);
}

return $this->om->getRepository($class)->findOneBy([$idProp => $id]);
return $object;
}

public function find(string $class, $data)
Expand Down
4 changes: 1 addition & 3 deletions src/main/app/Entity/Meta/Name.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ trait Name
{
/**
* @ORM\Column(name="entity_name")
*
* @var string
*/
protected $name;
protected ?string $name = null;

public function getName(): ?string
{
Expand Down
14 changes: 0 additions & 14 deletions src/main/app/Entity/Parameters/AbstractParameters.php

This file was deleted.

10 changes: 8 additions & 2 deletions src/main/app/Resources/modules/content/details/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import {DataProperty} from '#/main/app/data/types/prop-types'
const DataDetailsProperty = {
propTypes: merge({}, DataProperty.propTypes, {
hideLabel: T.bool,
displayed: T.bool
displayed: T.oneOfType([
T.bool,
T.func // a function that receives the whole details data and returns a bool
])
}),
defaultProps: merge({}, DataProperty.defaultProps, {
hideLabel: false,
Expand All @@ -21,7 +24,10 @@ const DataDetailsSection = {
title: T.string.isRequired,
className: T.string,
primary: T.bool,
displayed: T.bool,
displayed: T.oneOfType([
T.bool,
T.func // a function that receives the whole details data and returns a bool
]),
defaultOpened: T.bool,
fields: T.arrayOf(T.shape(
DataDetailsProperty.propTypes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ const FormData = (props) => {
<FormSections
level={hLevel}
displayLevel={hDisplay}
defaultOpened={openedSection ? (openedSection.id || toKey(openedSection.title)) : undefined}
defaultOpened={openedSection ? getSectionId(openedSection, props.id) : undefined}
>
{otherSections.map(section => (
<FormSection
id={`${getSectionId(section, props.id)}-section`}
id={getSectionId(section, props.id)}
className={section.className}
key={section.id || toKey(section.title)}
key={getSectionId(section, props.id)}
icon={section.icon}
title={section.title}
subtitle={section.subtitle}
Expand All @@ -182,7 +182,7 @@ const FormData = (props) => {
actions={section.actions}
>
<FormFieldset
id={getSectionId(section, props.id)}
id={`${getSectionId(section, props.id)}-fieldset`}
fill={true}
className="panel-body"
mode={props.mode}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {FormData} from '#/main/app/content/form/containers/data'
const SectionParameters = props =>
<FormSection
{...omit(props, ['name', 'dataPart', 'index', 'fields', 'remove'])}
title={props.title || trans('profile_facet_section')}
title={props.title || trans('facet_section')}
className="embedded-form-section"
actions={[
{
Expand All @@ -26,8 +26,8 @@ const SectionParameters = props =>
callback: props.remove,
dangerous: true,
confirm: {
title: trans('profile_remove_section'),
message: trans('profile_remove_section_question')
title: trans('facet_remove_section'),
message: trans('facet_remove_section_question')
}
}
]}
Expand All @@ -54,7 +54,7 @@ const SectionParameters = props =>
label: trans('fields_list'),
required: true,
options: {
placeholder: trans('profile_section_no_field'),
placeholder: trans('facet_section_no_field'),
fields: props.fields,
min: 1
}
Expand Down Expand Up @@ -112,15 +112,15 @@ const FormParameters = (props) =>
{0 === props.sections.length &&
<ContentPlaceholder
size="lg"
icon="fa fa-face-frown"
title={trans('profile_facet_no_section')}
title={trans('facet_no_section')}
help={trans('facet_no_section_help')}
/>
}

<Button
type={CALLBACK_BUTTON}
className="btn btn-block btn-emphasis component-container"
label={trans('profile_facet_section_add')}
label={trans('facet_section_add')}
callback={() => props.update(props.name, props.dataPart, [].concat(props.sections, [{
id: makeId(),
title: '',
Expand Down
20 changes: 20 additions & 0 deletions src/main/app/Resources/modules/content/form/parameters/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@ function formatField(fieldDef, allFields, dataPath = null, hasLockedRights = fal
return field
}

function formatListField(fieldDef, allFields, dataPath = null) {
const field = {
name: dataPath ? `${dataPath}.${fieldDef.id}` : fieldDef.id,
type: fieldDef.type,
label: fieldDef.label,
help: fieldDef.help,
options: fieldDef.options ? cloneDeep(fieldDef.options) : {}
}

if (fieldDef.type === 'choice') {
field.options.choices = fieldDef.options.choices ?
fieldDef.options.choices.reduce((acc, choice) => Object.assign(acc, {
[choice.value]: choice.value
}), {}) : {}
}

return field
}

function isFieldDisplayed(fieldDef, allFields, data) {
if (!isEmpty(get(fieldDef, 'display.condition'))) {
const parentField = allFields.find(f => f.id === fieldDef.display.condition.field)
Expand Down Expand Up @@ -78,5 +97,6 @@ function isFieldDisplayed(fieldDef, allFields, data) {
export {
formatSections,
formatField,
formatListField,
isFieldDisplayed
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, {createElement} from 'react'
import {PropTypes as T} from 'prop-types'
import get from 'lodash/get'
import merge from 'lodash/merge'
Expand Down Expand Up @@ -39,7 +39,7 @@ const DataCellContent = props => {
cellRendering = props.column.placeholder
} else if (get(props.definition, 'components.table', null)) {
// use custom component defined in the type definition
cellRendering = React.createElement(props.definition.components.table, merge({}, props.column.options || {}, {
cellRendering = createElement(props.definition.components.table, merge({}, props.column.options || {}, {
id: toKey(props.column.name + '-' + props.rowData.id),
label: props.column.label,
data: cellData
Expand Down
8 changes: 6 additions & 2 deletions src/main/app/Resources/translations/data.fr.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"boolean": "Booléen",
"boolean_desc": "Permet d'activer ou non une case à cocher représentant une valeur booléenne (oui/non, activé/désactivé, etc.).",
"choice": "Choix",
"choice_desc": "Permet de sélectionner une ou plusieurs valeurs dans une liste de choix prédéfinie.",
"collection": "Collection",
"country": "Pays",
"country_desc": "Permet de sélectionner un pays.",
"currency": "Monnaie",
"currency_desc": "Permet de saisir une valeur monétaire en utilisant la monnaie définie pour la plateforme.",
"date": "Date",
"date_desc": "Permet de saisir ou de sélectionner une date dans un calendrier.",
"date-range": "Période",
Expand All @@ -17,7 +19,7 @@
"html": "Texte riche",
"html_desc": "Permet de saisir un texte avec des contenus riches (images, liens, styles personnalisés).",
"image": "Image",
"image_desc": "\"Permet de télécharger un fichier d'image sur la plateforme.",
"image_desc": "Permet de télécharger un fichier d'image sur la plateforme.",
"ip": "Adresse IP",
"ip_desc": "Permet de saisir une adresse IP.",
"number": "Nombre",
Expand All @@ -28,5 +30,7 @@
"url_desc": "Permet de saisir une URL.",
"array_of": "Une liste de '%type%'",
"integer": "Nombre entier",
"object": "Objet"
"object": "Objet",
"cascade": "Choix à plusieurs niveaux",
"cascade_desc": "Permet de sélectionner une valeur parmis les groupes de choix prédéfinis."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react'
import isEmpty from 'lodash/isEmpty'

import {DataCell as DataCellTypes} from '#/main/app/data/types/prop-types'
import {UrlButton} from '#/main/app/buttons'

import {route} from '#/main/community/group/routing'

const GroupCell = props => {
if (!props.placeholder && isEmpty(props.data)) {
return '-'
}

return (
<UrlButton target={'#'+route(props.data)}>
{props.data.name}
</UrlButton>
)
}

GroupCell.propTypes = DataCellTypes.propTypes

GroupCell.defaultProps = {
data: {},
placeholder: true
}

export {
GroupCell
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {trans} from '#/main/app/intl/translation'

import {GroupCell} from '#/main/community/data/types/group/components/cell'
import {GroupDisplay} from '#/main/community/data/types/group/components/display'
import {GroupInput} from '#/main/community/data/types/group/components/input'

Expand All @@ -13,7 +14,8 @@ const dataType = {
},
components: {
details: GroupDisplay,
input: GroupInput
input: GroupInput,
table: GroupCell
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const dataType = {
meta: {
creatable: true,
icon: 'fa fa-fw fa fa-building',
label: trans('organization'),
description: trans('organization_desc')
label: trans('organization', {}, 'data'),
description: trans('organization_desc', {}, 'data')
},
/**
* The list of configuration fields.
Expand Down
4 changes: 4 additions & 0 deletions src/main/community/Resources/translations/data.en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"organization": "Organization",
"organization_desc": "Allows to select an Organization."
}
4 changes: 4 additions & 0 deletions src/main/community/Resources/translations/data.fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"organization": "Organisation",
"organization_desc": "Permet de sélectionner une Organisation."
}
Loading

0 comments on commit b2cf9d5

Please sign in to comment.