Commit d0ea04b9 authored by antoine masson's avatar antoine masson
Browse files

v0.5

-fix bug of limiting file size for sending pic
- new language templates
-new schemas for objectives and alternatives
- controler for alternatives on client


Todo 
- controler for objective on client
parent b868a717
......@@ -441,7 +441,7 @@ exports.getLangtrans = async (req, res) => {
//client side
exports.getSurveykey = async (req, res) => {
try {
// try {
const key=req.params.key;
const proj={}
proj[key]=1;
......@@ -461,6 +461,18 @@ exports.getSurveykey = async (req, res) => {
}
survey = tmp;
} else if (key === "rational"){
tmp=[]
survey.alternatives.content = survey.alternatives.content.find(o => o.language === req.userData.language)
for(let item of survey.alternatives.items){
if(item.enable) {
item.elements.contents = item.elements.contents.find(o => o.language === req.userData.language)
delete item.description
delete item.comments
tmp.push(item);
}
}
survey.alternatives.items = tmp;
}
if (survey){
await res.status(201).json({payload:survey,message:key,status:"OK"});
......@@ -468,9 +480,9 @@ exports.getSurveykey = async (req, res) => {
res.status(400).json({ message: "key doesn't exist",status:"Error"});
}
} catch (err) {
res.status(400).json({ message: err,status:"Error"});
}
// } catch (err) {
// res.status(400).json({ message: err,status:"Error"});
// }
};
exports.getSurveyInfo= async (req, res) => {
......
......@@ -39,10 +39,9 @@ SurveyController.initSurveyTemplate();
const index = express();
index.use(morgan("dev"));
index.use(cors());
index.use(bodyParser.urlencoded({ extended: true }));
index.use(bodyParser.json());
index.use(bodyParser.json({limit: "50mb"}));
index.use(fileUpload());
index.use(bodyParser.urlencoded({ limit: "50mb", extended: true, parameterLimit: 50000 }))
routes(index);
routesAdminUsers(index);
routesTokens(index);
......
......@@ -3,31 +3,27 @@ const mongoose = require("mongoose");
const { Schema } = mongoose;
const validator = require( "validator");
const textinputs = new Schema(
{
const textinputs = new Schema({
language:String,
html:{
content:String,
inputs:String,
},
}
);
const text = new Schema(
inputs:String, }
,});
{
const text = new Schema({
language:String,
html:{
content:String,
},
}
},});
);
const textcaption = new Schema({
language:String,
html:{
caption:String,
content:String,
},});
const altschema = new Schema(
{
const altschema = new Schema({
_id:mongoose.ObjectId,
short_name: {
type: String,
......@@ -43,13 +39,34 @@ const altschema = new Schema(
type: Boolean,
default: true
},
contents:[textinputs],
items:[{
elements:{
picture: String,
contents:[text],
}],
}
)
contents:[textcaption],
},
});
const objschema = new Schema({
_id:mongoose.ObjectId,
short_name: {
type: String,
index: { unique: true, sparse: true }
},
description: {
type: String,
},
comments: {
type: String,
},
enable: {
type: Boolean,
default: true
},
type:{
type: String,
enum:['objective','category'],
required:true
},
elements:Object,
});
const POCSchema = new Schema({
firstname: {
......@@ -78,10 +95,8 @@ const POCSchema = new Schema({
const SurveyGlobalOptSSchema = new Schema({
_id:Number,
poc: POCSchema,
poc: POCSchema,});
});
SurveyGlobalOptSSchema.statics.checkExistingField = async function(field, value) {
return await this.findOne({[`${field}`]: value});
};
......@@ -122,9 +137,7 @@ const PrePostSurveySchema = new Schema({
type_attribut:Object,
contents: [textinputs],
}
)
});
const SurveySchema = new Schema({
general:{
......@@ -173,15 +186,23 @@ const SurveySchema = new Schema({
postsurvey:[PrePostSurveySchema],
rational:{
general: {
learnloop:Boolean
},
alternatives:[altschema],
objectives:Array,
},
learnloop:{
type :Boolean,
required: true,
default: true,
},
},
alternatives:{
content:[text],
items:[altschema]
},
objectives: {
content:[text],
items:[objschema],
},{ timestamps: true });
},
},},{ timestamps: true });
SurveySchema.statics.checkExistingField = async function(field, value) {
return await this.findOne({[`${field}`]: value});
......
[
{
"type": "String",
"field": "REFUSE",
"description": "Refuse btn",
"createdAt": "2021-02-09T19:16:11.618Z",
"updatedAt": "2021-02-09T19:16:11.618Z",
"id": "603412d38566fdbbefc1d57a"
},
{
"type": "String",
"field": "WELCOME",
"description": "Welcome text",
"createdAt": "2021-01-20T21:56:23.148Z",
"updatedAt": "2021-01-20T21:56:23.148Z",
"id": "6032c9f757ff477c472e182e"
"id": "603412d38566fdbbefc1d576"
},
{
"type": "String",
"field": "PREVIOUS",
"description": "Previous Btn",
"createdAt": "2021-02-09T19:16:21.393Z",
"updatedAt": "2021-02-09T19:16:21.393Z",
"id": "603412d38566fdbbefc1d57b"
},
{
"type": "String",
......@@ -13,7 +29,7 @@
"description": "Next Btn",
"createdAt": "2021-01-20T21:56:17.093Z",
"updatedAt": "2021-01-20T21:56:17.093Z",
"id": "6032c9f757ff477c472e182d"
"id": "603412d38566fdbbefc1d577"
},
{
"type": "String",
......@@ -21,31 +37,31 @@
"description": "Text that user should accept on the welcome page",
"createdAt": "2021-02-09T19:15:48.034Z",
"updatedAt": "2021-02-09T19:15:48.034Z",
"id": "6032c9f757ff477c472e182f"
"id": "603412d38566fdbbefc1d578"
},
{
"type": "String",
"field": "AGREE",
"description": "AGREE btn",
"createdAt": "2021-02-09T19:16:03.364Z",
"updatedAt": "2021-02-09T19:16:03.364Z",
"id": "6032c9f757ff477c472e1830"
"field": "USEMIN",
"description": "Validation Text : Please use at least",
"createdAt": "2021-02-14T12:39:26.095Z",
"updatedAt": "2021-02-14T12:39:26.095Z",
"id": "603412d38566fdbbefc1d57f"
},
{
"type": "String",
"field": "REFUSE",
"description": "Refuse btn",
"createdAt": "2021-02-09T19:16:11.618Z",
"updatedAt": "2021-02-09T19:16:11.618Z",
"id": "6032c9f757ff477c472e1831"
"field": "POC",
"description": "PersoneOfContact Text",
"createdAt": "2021-02-09T19:16:43.101Z",
"updatedAt": "2021-02-09T19:16:43.101Z",
"id": "603412d38566fdbbefc1d57d"
},
{
"type": "String",
"field": "PREVIOUS",
"description": "Previous Btn",
"createdAt": "2021-02-09T19:16:21.393Z",
"updatedAt": "2021-02-09T19:16:21.393Z",
"id": "6032c9f757ff477c472e1832"
"field": "AGREE",
"description": "AGREE btn",
"createdAt": "2021-02-09T19:16:03.364Z",
"updatedAt": "2021-02-09T19:16:03.364Z",
"id": "603412d38566fdbbefc1d579"
},
{
"type": "String",
......@@ -53,15 +69,7 @@
"description": "Agreement text title",
"createdAt": "2021-02-09T19:17:15.957Z",
"updatedAt": "2021-02-09T19:17:15.957Z",
"id": "6032c9f757ff477c472e1834"
},
{
"type": "String",
"field": "POC",
"description": "PersoneOfContact Text",
"createdAt": "2021-02-09T19:16:43.101Z",
"updatedAt": "2021-02-09T19:16:43.101Z",
"id": "6032c9f757ff477c472e1833"
"id": "603412d38566fdbbefc1d57c"
},
{
"type": "String",
......@@ -69,15 +77,7 @@
"description": "Validation Text : You need to select one value",
"createdAt": "2021-02-14T12:38:30.004Z",
"updatedAt": "2021-02-14T12:38:30.004Z",
"id": "6032c9f757ff477c472e1835"
},
{
"type": "String",
"field": "USEMIN",
"description": "Validation Text : Please use at least",
"createdAt": "2021-02-14T12:39:26.095Z",
"updatedAt": "2021-02-14T12:39:26.095Z",
"id": "6032c9f757ff477c472e1837"
"id": "603412d38566fdbbefc1d57e"
},
{
"type": "String",
......@@ -85,7 +85,7 @@
"description": "Validation Text : Please use maximum",
"createdAt": "2021-02-14T12:39:11.596Z",
"updatedAt": "2021-02-14T12:39:11.596Z",
"id": "6032c9f757ff477c472e1836"
"id": "603412d38566fdbbefc1d580"
},
{
"type": "String",
......@@ -93,7 +93,7 @@
"description": "Word characters",
"createdAt": "2021-02-14T12:39:47.817Z",
"updatedAt": "2021-02-14T12:39:47.817Z",
"id": "6032c9f757ff477c472e1838"
"id": "603412d38566fdbbefc1d581"
},
{
"type": "String",
......@@ -101,7 +101,7 @@
"description": "Validation Text Allowed maximum is",
"createdAt": "2021-02-14T12:40:31.860Z",
"updatedAt": "2021-02-14T12:40:31.860Z",
"id": "6032c9f757ff477c472e1839"
"id": "603412d38566fdbbefc1d582"
},
{
"type": "String",
......@@ -109,7 +109,7 @@
"description": "Validation text : Mandatory field",
"createdAt": "2021-02-14T12:41:14.347Z",
"updatedAt": "2021-02-14T12:41:14.347Z",
"id": "6032c9f757ff477c472e183b"
"id": "603412d38566fdbbefc1d583"
},
{
"type": "String",
......@@ -117,7 +117,7 @@
"description": "Validation text : Allowed miniumum is",
"createdAt": "2021-02-14T12:40:47.527Z",
"updatedAt": "2021-02-14T12:40:47.527Z",
"id": "6032c9f757ff477c472e183a"
"id": "603412d38566fdbbefc1d584"
},
{
"type": "String",
......@@ -125,6 +125,54 @@
"description": "Validation text : You need to sort all the boxes",
"createdAt": "2021-02-17T15:19:24.085Z",
"updatedAt": "2021-02-17T15:19:24.085Z",
"id": "6032c9f757ff477c472e183c"
"id": "603412d38566fdbbefc1d585"
},
{
"type": "String",
"field": "ALTERNATIVES_INPUTS",
"description": "Text display on top of the alternative when user needs to movee them",
"createdAt": "2021-02-25T20:55:58.906Z",
"updatedAt": "2021-02-25T20:55:58.906Z",
"id": "60380edef9db7d8a25a45b1f"
},
{
"type": "String",
"field": "RESTART",
"description": "Restart btn",
"createdAt": "2021-02-28T20:25:57.348Z",
"updatedAt": "2021-02-28T20:25:57.348Z",
"id": "603bfc556fbde221723a7e8b"
},
{
"type": "String",
"field": "INTROALT",
"description": "Rational Survey : Intro to Alternatives",
"createdAt": "2021-02-28T20:28:02.986Z",
"updatedAt": "2021-02-28T20:28:02.986Z",
"id": "603bfcd26fbde221723a7e8c"
},
{
"type": "String",
"field": "ALTERNATIVES",
"description": "Rational Survey : Alternatives ",
"createdAt": "2021-02-28T20:28:21.306Z",
"updatedAt": "2021-02-28T20:28:21.306Z",
"id": "603bfce56fbde221723a7e8d"
},
{
"type": "String",
"field": "SORTALT",
"description": "Rational Survey : Sort Alternatives",
"createdAt": "2021-02-28T20:28:38.606Z",
"updatedAt": "2021-02-28T20:28:38.606Z",
"id": "603bfcf66fbde221723a7e8e"
},
{
"type": "String",
"field": "INTROOBJ",
"description": "Rational Survey : Intro to Objectives",
"createdAt": "2021-02-28T20:29:00.286Z",
"updatedAt": "2021-02-28T20:29:00.286Z",
"id": "603bfd0c6fbde221723a7e8f"
}
]
\ No newline at end of file
......@@ -4,223 +4,265 @@
"flag": "gb",
"fields": [
{
"_id": "602d34083d523f5ca9f794a3",
"_id": "603bfd3d224e583cc75205ad",
"field": "NEXT",
"text": "next",
"id": "602d34083d523f5ca9f794a3"
"id": "603bfd3d224e583cc75205ad"
},
{
"_id": "602d34083d523f5ca9f794a4",
"_id": "603bfd3d224e583cc75205ae",
"field": "WELCOME",
"text": "welcome",
"id": "602d34083d523f5ca9f794a4"
"id": "603bfd3d224e583cc75205ae"
},
{
"_id": "602d34083d523f5ca9f794a5",
"_id": "603bfd3d224e583cc75205af",
"field": "ACCEPT",
"text": "accept",
"id": "602d34083d523f5ca9f794a5"
"id": "603bfd3d224e583cc75205af"
},
{
"_id": "602d34083d523f5ca9f794a6",
"_id": "603bfd3d224e583cc75205b0",
"field": "REFUSE",
"text": "refuse",
"id": "602d34083d523f5ca9f794a6"
"id": "603bfd3d224e583cc75205b0"
},
{
"_id": "602d34083d523f5ca9f794a7",
"_id": "603bfd3d224e583cc75205b1",
"field": "PREVIOUS",
"text": "previous",
"id": "602d34083d523f5ca9f794a7"
"id": "603bfd3d224e583cc75205b1"
},
{
"_id": "602d34083d523f5ca9f794a8",
"_id": "603bfd3d224e583cc75205b2",
"field": "POC",
"text": "Person of Contact",
"id": "602d34083d523f5ca9f794a8"
"id": "603bfd3d224e583cc75205b2"
},
{
"_id": "602d34083d523f5ca9f794a9",
"_id": "603bfd3d224e583cc75205b3",
"field": "AGREEMENT",
"text": "I accept that my data are used ...",
"id": "602d34083d523f5ca9f794a9"
"id": "603bfd3d224e583cc75205b3"
},
{
"_id": "602d34083d523f5ca9f794aa",
"_id": "603bfd3d224e583cc75205b4",
"field": "AGREETITLE",
"text": "Data Use Agreements",
"id": "602d34083d523f5ca9f794aa"
"id": "603bfd3d224e583cc75205b4"
},
{
"_id": "602d34083d523f5ca9f794ab",
"_id": "603bfd3d224e583cc75205b5",
"field": "AGREE",
"text": "agree",
"id": "602d34083d523f5ca9f794ab"
"id": "603bfd3d224e583cc75205b5"
},
{
"_id": "602d34083d523f5ca9f794ac",
"_id": "603bfd3d224e583cc75205b6",
"field": "SELECTONE",
"text": "You need to select one value",
"id": "602d34083d523f5ca9f794ac"
"id": "603bfd3d224e583cc75205b6"
},
{
"_id": "602d34083d523f5ca9f794ad",
"_id": "603bfd3d224e583cc75205b7",
"field": "USEMAX",
"text": "Please use maximum",
"id": "602d34083d523f5ca9f794ad"
"id": "603bfd3d224e583cc75205b7"
},
{
"_id": "602d34083d523f5ca9f794ae",
"_id": "603bfd3d224e583cc75205b8",
"field": "USEMIN",
"text": "Please use maximum",
"id": "602d34083d523f5ca9f794ae"
"id": "603bfd3d224e583cc75205b8"
},
{
"_id": "602d34083d523f5ca9f794af",
"_id": "603bfd3d224e583cc75205b9",
"field": "CHARACTERS",
"text": "characters",
"id": "602d34083d523f5ca9f794af"
"id": "603bfd3d224e583cc75205b9"
},
{
"_id": "602d34083d523f5ca9f794b0",
"_id": "603bfd3d224e583cc75205ba",
"field": "ALLOWEDMAX",
"text": "Allowed maximum is",
"id": "602d34083d523f5ca9f794b0"
"id": "603bfd3d224e583cc75205ba"
},
{
"_id": "602d34083d523f5ca9f794b1",
"_id": "603bfd3d224e583cc75205bb",
"field": "ALLOWEDMIN",
"text": "Allowed miniumum is",
"id": "602d34083d523f5ca9f794b1"
"id": "603bfd3d224e583cc75205bb"
},
{
"_id": "602d34083d523f5ca9f794b2",
"_id": "603bfd3d224e583cc75205bc",
"field": "MANDATORYFIELD",
"text": "Mandatory field",
"id": "602d34083d523f5ca9f794b2"
"id": "603bfd3d224e583cc75205bc"
},
{
"_id": "602d34083d523f5ca9f794b3",
"_id": "603bfd3d224e583cc75205bd",
"field": "MOVEBOX",
"text": "You need to sort all the boxes",
"id": "602d34083d523f5ca9f794b3"
"id": "603bfd3d224e583cc75205bd"
},
{
"_id": "603bfd3d224e583cc75205be",
"field": "ALTERNATIVES_INPUTS",
"text": "Please move element according to your preference ; one is the most prefered",
"id": "603bfd3d224e583cc75205be"
},
{
"_id": "603bfd3d224e583cc75205bf",
"field": "RESTART",
"text": "Restart",
"id": "603bfd3d224e583cc75205bf"
},
{
"_id": "603bfd3d224e583cc75205c0",
"field": "INTROALT",
"text": "Introduction to Alternatives",
"id": "603bfd3d224e583cc75205c0"
},
{
"_id": "603bfd3d224e583cc75205c1",
"field": "ALTERNATIVES",
"text": "Alternatives",
"id": "603bfd3d224e583cc75205c1"
},
{
"_id": "603bfd3d224e583cc75205c2",
"field": "SORTALT",
"text": "Sort Alternatives",
"id": "603bfd3d224e583cc75205c2"
},
{
"_id": "603bfd3d224e583cc75205c3",
"field": "INTROOBJ",
"text": "Introduction to Objectives",
"id": "603bfd3d224e583cc75205c3"
}
],
"updatedAt": "2021-02-17T15:19:36.676Z",
"createdAt": "2021-02-17T15:19:36.676Z",
"updatedAt": "2021-02-28T20:29:49.288Z",
"createdAt": "2021-02-28T20:29:49.288Z",
"status": "TODO",
"id": "6032bcaa6ebb9c7a9092f188"
"id": "6034171c10a7dcbd297bd67d"
},
{
"language": "FRENCH",
"flag": "fr",
"fields": [
{
"_id": "602d341b3d523f5ca9f794b4",
"_id": "60380f10f9db7d8a25a45b39",
"field": "NEXT",
"text": "suivant",
"id": "602d341b3d523f5ca9f794b4"
"id": "60380f10f9db7d8a25a45b39"
},
{
"_id": "602d341b3d523f5ca9f794b5",
"_id": "60380f10f9db7d8a25a45b3a",
"field": "WELCOME",
"text": "bienvenue",
"id": "602d341b3d523f5ca9f794b5"