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) => { ...@@ -441,7 +441,7 @@ exports.getLangtrans = async (req, res) => {
//client side //client side
exports.getSurveykey = async (req, res) => { exports.getSurveykey = async (req, res) => {
try { // try {
const key=req.params.key; const key=req.params.key;
const proj={} const proj={}
proj[key]=1; proj[key]=1;
...@@ -461,6 +461,18 @@ exports.getSurveykey = async (req, res) => { ...@@ -461,6 +461,18 @@ exports.getSurveykey = async (req, res) => {
} }
survey = tmp; 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){ if (survey){
await res.status(201).json({payload:survey,message:key,status:"OK"}); await res.status(201).json({payload:survey,message:key,status:"OK"});
...@@ -468,9 +480,9 @@ exports.getSurveykey = async (req, res) => { ...@@ -468,9 +480,9 @@ exports.getSurveykey = async (req, res) => {
res.status(400).json({ message: "key doesn't exist",status:"Error"}); res.status(400).json({ message: "key doesn't exist",status:"Error"});
} }
} catch (err) { // } catch (err) {
res.status(400).json({ message: err,status:"Error"}); // res.status(400).json({ message: err,status:"Error"});
} // }
}; };
exports.getSurveyInfo= async (req, res) => { exports.getSurveyInfo= async (req, res) => {
......
...@@ -39,10 +39,9 @@ SurveyController.initSurveyTemplate(); ...@@ -39,10 +39,9 @@ SurveyController.initSurveyTemplate();
const index = express(); const index = express();
index.use(morgan("dev")); index.use(morgan("dev"));
index.use(cors()); index.use(cors());
index.use(bodyParser.urlencoded({ extended: true })); index.use(bodyParser.json({limit: "50mb"}));
index.use(bodyParser.json());
index.use(fileUpload()); index.use(fileUpload());
index.use(bodyParser.urlencoded({ limit: "50mb", extended: true, parameterLimit: 50000 }))
routes(index); routes(index);
routesAdminUsers(index); routesAdminUsers(index);
routesTokens(index); routesTokens(index);
......
...@@ -3,31 +3,27 @@ const mongoose = require("mongoose"); ...@@ -3,31 +3,27 @@ const mongoose = require("mongoose");
const { Schema } = mongoose; const { Schema } = mongoose;
const validator = require( "validator"); const validator = require( "validator");
const textinputs = new Schema( const textinputs = new Schema({
{
language:String, language:String,
html:{ html:{
content:String, content:String,
inputs:String, inputs:String, }
}, ,});
}
);
const text = new Schema(
{ const text = new Schema({
language:String, language:String,
html:{ html:{
content:String, content:String,
}, },});
}
); const textcaption = new Schema({
language:String,
html:{
caption:String,
content:String,
},});
const altschema = new Schema( const altschema = new Schema({
{
_id:mongoose.ObjectId, _id:mongoose.ObjectId,
short_name: { short_name: {
type: String, type: String,
...@@ -43,13 +39,34 @@ const altschema = new Schema( ...@@ -43,13 +39,34 @@ const altschema = new Schema(
type: Boolean, type: Boolean,
default: true default: true
}, },
contents:[textinputs], elements:{
items:[{
picture: String, 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({ const POCSchema = new Schema({
firstname: { firstname: {
...@@ -78,10 +95,8 @@ const POCSchema = new Schema({ ...@@ -78,10 +95,8 @@ const POCSchema = new Schema({
const SurveyGlobalOptSSchema = new Schema({ const SurveyGlobalOptSSchema = new Schema({
_id:Number, _id:Number,
poc: POCSchema, poc: POCSchema,});
});
SurveyGlobalOptSSchema.statics.checkExistingField = async function(field, value) { SurveyGlobalOptSSchema.statics.checkExistingField = async function(field, value) {
return await this.findOne({[`${field}`]: value}); return await this.findOne({[`${field}`]: value});
}; };
...@@ -122,9 +137,7 @@ const PrePostSurveySchema = new Schema({ ...@@ -122,9 +137,7 @@ const PrePostSurveySchema = new Schema({
type_attribut:Object, type_attribut:Object,
contents: [textinputs], contents: [textinputs],
} });
)
const SurveySchema = new Schema({ const SurveySchema = new Schema({
general:{ general:{
...@@ -173,15 +186,23 @@ const SurveySchema = new Schema({ ...@@ -173,15 +186,23 @@ const SurveySchema = new Schema({
postsurvey:[PrePostSurveySchema], postsurvey:[PrePostSurveySchema],
rational:{ rational:{
general: { general: {
learnloop:Boolean learnloop:{
}, type :Boolean,
alternatives:[altschema], required: true,
objectives:Array, default: true,
}, },
},
alternatives:{
content:[text],
items:[altschema]
},
objectives: {
content:[text],
items:[objschema],
},{ timestamps: true }); },
},},{ timestamps: true });
SurveySchema.statics.checkExistingField = async function(field, value) { SurveySchema.statics.checkExistingField = async function(field, value) {
return await this.findOne({[`${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", "type": "String",
"field": "WELCOME", "field": "WELCOME",
"description": "Welcome text", "description": "Welcome text",
"createdAt": "2021-01-20T21:56:23.148Z", "createdAt": "2021-01-20T21:56:23.148Z",
"updatedAt": "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", "type": "String",
...@@ -13,7 +29,7 @@ ...@@ -13,7 +29,7 @@
"description": "Next Btn", "description": "Next Btn",
"createdAt": "2021-01-20T21:56:17.093Z", "createdAt": "2021-01-20T21:56:17.093Z",
"updatedAt": "2021-01-20T21:56:17.093Z", "updatedAt": "2021-01-20T21:56:17.093Z",
"id": "6032c9f757ff477c472e182d" "id": "603412d38566fdbbefc1d577"
}, },
{ {
"type": "String", "type": "String",
...@@ -21,31 +37,31 @@ ...@@ -21,31 +37,31 @@
"description": "Text that user should accept on the welcome page", "description": "Text that user should accept on the welcome page",
"createdAt": "2021-02-09T19:15:48.034Z", "createdAt": "2021-02-09T19:15:48.034Z",
"updatedAt": "2021-02-09T19:15:48.034Z", "updatedAt": "2021-02-09T19:15:48.034Z",
"id": "6032c9f757ff477c472e182f" "id": "603412d38566fdbbefc1d578"
}, },
{ {
"type": "String", "type": "String",
"field": "AGREE", "field": "USEMIN",
"description": "AGREE btn", "description": "Validation Text : Please use at least",
"createdAt": "2021-02-09T19:16:03.364Z", "createdAt": "2021-02-14T12:39:26.095Z",
"updatedAt": "2021-02-09T19:16:03.364Z", "updatedAt": "2021-02-14T12:39:26.095Z",
"id": "6032c9f757ff477c472e1830" "id": "603412d38566fdbbefc1d57f"
}, },
{ {
"type": "String", "type": "String",
"field": "REFUSE", "field": "POC",
"description": "Refuse btn", "description": "PersoneOfContact Text",
"createdAt": "2021-02-09T19:16:11.618Z", "createdAt": "2021-02-09T19:16:43.101Z",
"updatedAt": "2021-02-09T19:16:11.618Z", "updatedAt": "2021-02-09T19:16:43.101Z",
"id": "6032c9f757ff477c472e1831" "id": "603412d38566fdbbefc1d57d"
}, },
{ {
"type": "String", "type": "String",
"field": "PREVIOUS", "field": "AGREE",
"description": "Previous Btn", "description": "AGREE btn",
"createdAt": "2021-02-09T19:16:21.393Z", "createdAt": "2021-02-09T19:16:03.364Z",
"updatedAt": "2021-02-09T19:16:21.393Z", "updatedAt": "2021-02-09T19:16:03.364Z",
"id": "6032c9f757ff477c472e1832" "id": "603412d38566fdbbefc1d579"
}, },
{ {
"type": "String", "type": "String",
...@@ -53,15 +69,7 @@ ...@@ -53,15 +69,7 @@
"description": "Agreement text title", "description": "Agreement text title",
"createdAt": "2021-02-09T19:17:15.957Z", "createdAt": "2021-02-09T19:17:15.957Z",
"updatedAt": "2021-02-09T19:17:15.957Z", "updatedAt": "2021-02-09T19:17:15.957Z",
"id": "6032c9f757ff477c472e1834" "id": "603412d38566fdbbefc1d57c"
},
{
"type": "String",
"field": "POC",
"description": "PersoneOfContact Text",
"createdAt": "2021-02-09T19:16:43.101Z",
"updatedAt": "2021-02-09T19:16:43.101Z",
"id": "6032c9f757ff477c472e1833"
}, },
{ {
"type": "String", "type": "String",
...@@ -69,15 +77,7 @@ ...@@ -69,15 +77,7 @@
"description": "Validation Text : You need to select one value", "description": "Validation Text : You need to select one value",
"createdAt": "2021-02-14T12:38:30.004Z", "createdAt": "2021-02-14T12:38:30.004Z",
"updatedAt": "2021-02-14T12:38:30.004Z", "updatedAt": "2021-02-14T12:38:30.004Z",
"id": "6032c9f757ff477c472e1835" "id": "603412d38566fdbbefc1d57e"
},
{
"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"
}, },
{ {
"type": "String", "type": "String",
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
"description": "Validation Text : Please use maximum", "description": "Validation Text : Please use maximum",
"createdAt": "2021-02-14T12:39:11.596Z", "createdAt": "2021-02-14T12:39:11.596Z",
"updatedAt": "2021-02-14T12:39:11.596Z", "updatedAt": "2021-02-14T12:39:11.596Z",
"id": "6032c9f757ff477c472e1836" "id": "603412d38566fdbbefc1d580"
}, },
{ {
"type": "String", "type": "String",
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
"description": "Word characters", "description": "Word characters",
"createdAt": "2021-02-14T12:39:47.817Z", "createdAt": "2021-02-14T12:39:47.817Z",
"updatedAt": "2021-02-14T12:39:47.817Z", "updatedAt": "2021-02-14T12:39:47.817Z",
"id": "6032c9f757ff477c472e1838" "id": "603412d38566fdbbefc1d581"
}, },
{ {
"type": "String", "type": "String",
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
"description": "Validation Text Allowed maximum is", "description": "Validation Text Allowed maximum is",
"createdAt": "2021-02-14T12:40:31.860Z", "createdAt": "2021-02-14T12:40:31.860Z",
"updatedAt": "2021-02-14T12:40:31.860Z", "updatedAt": "2021-02-14T12:40:31.860Z",
"id": "6032c9f757ff477c472e1839" "id": "603412d38566fdbbefc1d582"
}, },
{ {
"type": "String", "type": "String",
...@@ -109,7 +109,7 @@ ...@@ -109,7 +109,7 @@
"description": "Validation text : Mandatory field", "description": "Validation text : Mandatory field",
"createdAt": "2021-02-14T12:41:14.347Z", "createdAt": "2021-02-14T12:41:14.347Z",
"updatedAt": "2021-02-14T12:41:14.347Z", "updatedAt": "2021-02-14T12:41:14.347Z",
"id": "6032c9f757ff477c472e183b" "id": "603412d38566fdbbefc1d583"
}, },
{ {
"type": "String", "type": "String",
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
"description": "Validation text : Allowed miniumum is", "description": "Validation text : Allowed miniumum is",
"createdAt": "2021-02-14T12:40:47.527Z", "createdAt": "2021-02-14T12:40:47.527Z",
"updatedAt": "2021-02-14T12:40:47.527Z", "updatedAt": "2021-02-14T12:40:47.527Z",
"id": "6032c9f757ff477c472e183a" "id": "603412d38566fdbbefc1d584"
}, },
{ {
"type": "String", "type": "String",
...@@ -125,6 +125,54 @@ ...@@ -125,6 +125,54 @@
"description": "Validation text : You need to sort all the boxes", "description": "Validation text : You need to sort all the boxes",
"createdAt": "2021-02-17T15:19:24.085Z", "createdAt": "2021-02-17T15:19:24.085Z",
"updatedAt": "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 @@ ...@@ -4,223 +4,265 @@
"flag": "gb", "flag": "gb",
"fields": [ "fields": [
{ {
"_id": "602d34083d523f5ca9f794a3", "_id": "603bfd3d224e583cc75205ad",
"field": "NEXT", "field": "NEXT",
"text": "next", "text": "next",
"id": "602d34083d523f5ca9f794a3" "id": "603bfd3d224e583cc75205ad"
}, },
{ {
"_id": "602d34083d523f5ca9f794a4", "_id": "603bfd3d224e583cc75205ae",
"field": "WELCOME", "field": "WELCOME",
"text": "welcome", "text": "welcome",
"id": "602d34083d523f5ca9f794a4" "id": "603bfd3d224e583cc75205ae"
}, },
{ {
"_id": "602d34083d523f5ca9f794a5", "_id": "603bfd3d224e583cc75205af",
"field": "ACCEPT", "field": "ACCEPT",
"text": "accept", "text": "accept",
"id": "602d34083d523f5ca9f794a5" "id": "603bfd3d224e583cc75205af"
}, },
{ {
"_id": "602d34083d523f5ca9f794a6", "_id": "603bfd3d224e583cc75205b0",
"field": "REFUSE", "field": "REFUSE",
"text": "refuse", "text": "refuse",
"id": "602d34083d523f5ca9f794a6" "id": "603bfd3d224e583cc75205b0"
}, },
{ {
"_id": "602d34083d523f5ca9f794a7", "_id": "603bfd3d224e583cc75205b1",
"field": "PREVIOUS", "field": "PREVIOUS",
"text": "previous", "text": "previous",
"id": "602d34083d523f5ca9f794a7" "id": "603bfd3d224e583cc75205b1"
}, },
{ {
"_id": "602d34083d523f5ca9f794a8", "_id": "603bfd3d224e583cc75205b2",
"field": "POC", "field": "POC",
"text": "Person of Contact", "text": "Person of Contact",
"id": "602d34083d523f5ca9f794a8" "id": "603bfd3d224e583cc75205b2"
}, },
{ {
"_id": "602d34083d523f5ca9f794a9", "_id": "603bfd3d224e583cc75205b3",
"field": "AGREEMENT", "field": "AGREEMENT",
"text": "I accept that my data are used ...", "text": "I accept that my data are used ...",
"id": "602d34083d523f5ca9f794a9" "id": "603bfd3d224e583cc75205b3"
}, },
{ {
"_id": "602d34083d523f5ca9f794aa", "_id": "603bfd3d224e583cc75205b4",
"field": "AGREETITLE", "field": "AGREETITLE",
"text": "Data Use Agreements", "text": "Data Use Agreements",
"id": "602d34083d523f5ca9f794aa" "id": "603bfd3d224e583cc75205b4"
}, },
{ {
"_id": "602d34083d523f5ca9f794ab", "_id": "603bfd3d224e583cc75205b5",