Mentions légales du service

Skip to content
Snippets Groups Projects
Commit f94dfd3b authored by VIAUD Nathan's avatar VIAUD Nathan
Browse files

feat: add custom question content

parent 4fb3ab43
No related branches found
No related tags found
1 merge request!114Resolve "Add custom question content"
Pipeline #943079 passed
......@@ -21,7 +21,34 @@ const emit = defineEmits<{
const currentNode = editorStore.getCurrentGraphNode;
const currentContent = currentNode.data.elements.find(({ id }) => id === editorStore.openedElementId);
const getOptions = () => (props.linkedOptions ? currentContent.formValues[props.linkedOptions] : props.options);
function getOptions() {
if(!props.linkedOptions) return props.options;
// In this case we have to change the epoc formValues
//? refactor this if another case is needed
if(props.id === 'plugin') {
const epocNode = editorStore.getEpocNode;
return walkObjectPath(epocNode.data.formValues, props.linkedOptions);
} else {
return currentContent.formValues[props.linkedOptions];
}
}
function walkObjectPath(object: any, path: string) {
const currentKey = path.split('.')[0];
if(!currentKey) {
return object;
}
if(currentKey === '*') {
return object.map((item: any) => walkObjectPath(item, path.slice(2)));
} else {
return walkObjectPath(object[currentKey], path.slice(currentKey.length + 1));
}
}
function onChange(event: Event) {
const target = event.target as HTMLInputElement;
......
......@@ -304,36 +304,23 @@ export const epocForm: Form = {
value: [],
inputs: [
{
id: '',
id: 'script',
type: 'file',
label: 'Fichier de plugin',
placeholder: 'Ajouter un plugin',
label: 'Fichier de script',
placeholder: 'Ajouter un script',
targetDirectory: 'plugins',
value: '',
accept: '.js',
},
],
},
],
},
{
name: 'Plugins templates',
inputs: [
{
id: 'templates',
label: 'Plugin templates',
type: 'repeat',
value: [],
inputs: [
{
id: '',
id: 'template',
type: 'file',
label: 'Template html de plugin',
label: 'Template html du plugin',
placeholder: 'Ajouter un template',
targetDirectory: 'plugins',
value: '',
accept: '.html',
},
accept: 'html'
}
],
},
],
......
......@@ -476,4 +476,69 @@ export const listForm: Form = {
],
};
export const questionForms: Form[] = [qcmForm, swipeForm, reorderForm, dragDropForm, listForm];
export const customQuestionForm: Form = {
type: 'custom-question',
name: 'Question personnalisée',
icon: 'icon-terminal',
displayFieldIndex: true,
buttons: contentButtons,
fields: [
{
name: "Configuration de l'activité",
inputs: [
{
id: 'score',
type: 'score',
label: 'Score',
value: 0,
},
],
},
{
name: 'Question',
inputs: [
{
id: 'label',
type: 'textarea',
label: 'Question',
value: '',
placeholder: 'Posez la question',
},
{
id: 'plugin',
type: 'select',
label: 'Selectionnez un plugin',
value: '',
options: [],
linkedOptions: "plugins.*.template",
}
],
},
{
name: 'Réponses',
inputs: [
{
id: 'response',
label: 'Réponse',
type: 'text',
value: ''
}
],
},
{
name: 'Explication',
inputs: [
{
id: 'explanation',
type: 'html',
label: '',
value: '',
placeholder: 'Saisissez une explication',
},
],
},
],
};
export const questionForms: Form[] = [qcmForm, swipeForm, reorderForm, dragDropForm, listForm, customQuestionForm];
......@@ -26,6 +26,11 @@ export const questions: SideAction[] = [
type: 'dropdown-list',
label: 'Liste déroulantes',
},
{
icon: 'icon-terminal',
type: 'custom-question',
label: 'Question personnalisée',
}
];
const contents: SideAction[] = [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment