tango-app-api-trax 3.4.1-alpha-3 → 3.4.1-alpha-5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-trax",
|
|
3
|
-
"version": "3.4.1-alpha-
|
|
3
|
+
"version": "3.4.1-alpha-5",
|
|
4
4
|
"description": "Trax",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"mongodb": "^6.8.0",
|
|
27
27
|
"nodemon": "^3.1.4",
|
|
28
28
|
"path": "^0.12.7",
|
|
29
|
-
"tango-api-schema": "^2.2.
|
|
29
|
+
"tango-api-schema": "^2.2.73",
|
|
30
30
|
"tango-app-api-middleware": "^3.1.55",
|
|
31
31
|
"url": "^0.11.4",
|
|
32
32
|
"winston": "^3.13.1",
|
|
@@ -1027,8 +1027,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1027
1027
|
try {
|
|
1028
1028
|
let requestData = req.body;
|
|
1029
1029
|
requestData.questionAnswers = typeof requestData.questionAnswers == 'string' ? JSON.parse( requestData.questionAnswers ) : requestData.questionAnswers;
|
|
1030
|
-
let
|
|
1031
|
-
let getChecklistQA = await PCLconfig.findOne( { _id: getDetails.checkListId }, { questionAnswers: 1 } );
|
|
1030
|
+
let getChecklistQA = await processedchecklist.findOne( { _id: new ObjectId( requestData.processedcheckListId ) }, { questionAnswers: 1 } );
|
|
1032
1031
|
let reqAnswers = requestData.questionAnswers;
|
|
1033
1032
|
logger.error( { functionName: 'updatedPayload', message: reqAnswers } );
|
|
1034
1033
|
let CLQAnswers = getChecklistQA.questionAnswers;
|
|
@@ -1112,11 +1111,17 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1112
1111
|
let requestSection = reqAnswers.filter( ( item ) => item.section_id == section.id );
|
|
1113
1112
|
for ( let i = 0; i < requestSection.length; i++ ) {
|
|
1114
1113
|
for ( let j = 0; j < qaAnswers.length; j++ ) {
|
|
1115
|
-
if ( requestSection[i].qname == qaAnswers[j].oldQname || requestSection[i].qname == qaAnswers[j].qname ) {
|
|
1114
|
+
if ( ( requestSection[i].qname == qaAnswers[j].oldQname || requestSection[i].qname == qaAnswers[j].qname ) && ( !qaAnswers[j].uniqueqno || ( qaAnswers[j].uniqueqno && requestSection[i].uniqueqno == qaAnswers[j].uniqueqno ) ) ) {
|
|
1116
1115
|
if ( qaAnswers[j].answerType == 'yes/no' ) {
|
|
1117
1116
|
let qaans = qaAnswers[j].answers;
|
|
1118
1117
|
let yn = [];
|
|
1119
1118
|
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1119
|
+
console.log( typeof requestSection[i].questionAnswers == 'string' );
|
|
1120
|
+
let requestAnswer = typeof requestSection[i].questionAnswers == 'string' ? JSON.parse( requestSection[i].questionAnswers ) : requestSection[i].questionAnswers;
|
|
1121
|
+
let findAnswer= requestAnswer.find( ( ele ) => ele.answer == qaans[k].answer );
|
|
1122
|
+
if ( findAnswer ) {
|
|
1123
|
+
qaans[k].nestedQuestion = typeof findAnswer.nestedQuestion == 'string' ? JSON.parse( findAnswer.nestedQuestion ) : findAnswer.nestedQuestion;
|
|
1124
|
+
}
|
|
1120
1125
|
if ( requestSection[i].answer == qaans[k].answer ) {
|
|
1121
1126
|
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1122
1127
|
if ( requestSection[i].validationAnswer ) {
|
|
@@ -1151,8 +1156,8 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1151
1156
|
structure.parentanswer = requestSection[i].parentanswer;
|
|
1152
1157
|
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
|
|
1153
1158
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1154
|
-
structure.uniqueqno = requestSection[i]?.uniqueqno;
|
|
1155
|
-
|
|
1159
|
+
structure.uniqueqno = parseInt( requestSection[i]?.uniqueqno );
|
|
1160
|
+
qaAnswers[j].nestedQuestion = requestSection[i]?.nestedlinkedQuestion;
|
|
1156
1161
|
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1157
1162
|
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1158
1163
|
if ( qaAnswers[j]?.taskId ) {
|
|
@@ -1172,6 +1177,11 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1172
1177
|
let qaans = qaAnswers[j].answers;
|
|
1173
1178
|
let ms = [];
|
|
1174
1179
|
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1180
|
+
let requestAnswer = typeof requestSection[i].questionAnswers == 'string' ? JSON.parse( requestSection[i].questionAnswers ) : requestSection[i].questionAnswers;
|
|
1181
|
+
let findAnswer= requestAnswer.find( ( ele ) => ele.answer == qaans[k].answer );
|
|
1182
|
+
if ( findAnswer ) {
|
|
1183
|
+
qaans[k].nestedQuestion = typeof findAnswer.nestedQuestion == 'string' ? JSON.parse( findAnswer.nestedQuestion ) : findAnswer.nestedQuestion;
|
|
1184
|
+
}
|
|
1175
1185
|
if ( requestSection[i].answer == qaans[k].answer ) {
|
|
1176
1186
|
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1177
1187
|
if ( requestSection[i].validationAnswer ) {
|
|
@@ -1206,7 +1216,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1206
1216
|
structure.parentanswer = requestSection[i].parentanswer;
|
|
1207
1217
|
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
|
|
1208
1218
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1209
|
-
structure.uniqueqno = requestSection[i]?.uniqueqno;
|
|
1219
|
+
structure.uniqueqno = parseInt( requestSection[i]?.uniqueqno );
|
|
1210
1220
|
structure.nestedlinkedQuestion = requestSection[i]?.nestedlinkedQuestion;
|
|
1211
1221
|
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1212
1222
|
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
@@ -1267,7 +1277,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1267
1277
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1268
1278
|
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1269
1279
|
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1270
|
-
structure.uniqueqno = requestSection[i]?.uniqueqno;
|
|
1280
|
+
structure.uniqueqno = parseInt( requestSection[i]?.uniqueqno );
|
|
1271
1281
|
structure.nestedlinkedQuestion = requestSection[i]?.nestedlinkedQuestion;
|
|
1272
1282
|
if ( qaAnswers[j]?.taskId ) {
|
|
1273
1283
|
structure.taskId = qaAnswers[j]?.taskId;
|
|
@@ -1329,7 +1339,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1329
1339
|
structure.parentanswer = requestSection[i].parentanswer;
|
|
1330
1340
|
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
|
|
1331
1341
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1332
|
-
structure.uniqueqno = requestSection[i]?.uniqueqno;
|
|
1342
|
+
structure.uniqueqno = parseInt( requestSection[i]?.uniqueqno );
|
|
1333
1343
|
structure.nestedlinkedQuestion = requestSection[i]?.nestedlinkedQuestion;
|
|
1334
1344
|
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1335
1345
|
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
@@ -1391,7 +1401,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1391
1401
|
structure.parentanswer = requestSection[i].parentanswer;
|
|
1392
1402
|
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
|
|
1393
1403
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1394
|
-
structure.uniqueqno = requestSection[i]?.uniqueqno;
|
|
1404
|
+
structure.uniqueqno = parseInt( requestSection[i]?.uniqueqno );
|
|
1395
1405
|
structure.nestedlinkedQuestion = requestSection[i]?.nestedlinkedQuestion;
|
|
1396
1406
|
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1397
1407
|
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
@@ -2522,7 +2532,7 @@ export async function checklistv1( req, res ) {
|
|
|
2522
2532
|
...projectExtraConditions,
|
|
2523
2533
|
client_id: { $ifNull: [ '$client_id', '' ] },
|
|
2524
2534
|
coverage: { $ifNull: [ '$coverage', '' ] },
|
|
2525
|
-
taskType: { $ifNull: [ '$
|
|
2535
|
+
taskType: { $ifNull: [ '$planoType', '' ] },
|
|
2526
2536
|
},
|
|
2527
2537
|
},
|
|
2528
2538
|
];
|
|
@@ -2745,17 +2755,31 @@ export async function questionList( req, res ) {
|
|
|
2745
2755
|
for ( let question of section.questions ) {
|
|
2746
2756
|
let linkedQuestions;
|
|
2747
2757
|
if ( !question.linkType ) {
|
|
2748
|
-
|
|
2758
|
+
if ( !question?.uniqueqno ) {
|
|
2759
|
+
question.uniqueNo = parseInt( getOtp() );
|
|
2760
|
+
}
|
|
2749
2761
|
questions.push( question );
|
|
2750
2762
|
linkedQuestions = [];
|
|
2751
|
-
let questionList
|
|
2763
|
+
let questionList;
|
|
2764
|
+
if ( !question?.uniqueqno ) {
|
|
2765
|
+
questionList = new Map( section.questions.map( ( ele ) => [ ele.qno, ele ] ) );
|
|
2766
|
+
} else {
|
|
2767
|
+
let uniqueList = question.answers.flatMap( ( ele ) => ele.nestedQuestion );
|
|
2768
|
+
let filteredQuestion = section.questions.filter( ( ele ) => uniqueList.includes( ele?.uniqueqno ) );
|
|
2769
|
+
questionList = new Map( filteredQuestion.map( ( ele ) => [ ele.uniqueqno, ele ] ) );
|
|
2770
|
+
}
|
|
2752
2771
|
question.answers.forEach( ( answer ) => {
|
|
2753
2772
|
if ( answer.linkedQuestion ) {
|
|
2754
2773
|
let nesedQuestion = [];
|
|
2755
2774
|
answer.nestedQuestion.forEach( ( qn, qidx ) => {
|
|
2756
2775
|
let getQn = questionList.get( qn );
|
|
2757
2776
|
if ( getQn ) {
|
|
2758
|
-
let randomNo
|
|
2777
|
+
let randomNo;
|
|
2778
|
+
if ( !getQn?.uniqueqno ) {
|
|
2779
|
+
randomNo = parseInt( getOtp() );
|
|
2780
|
+
} else {
|
|
2781
|
+
randomNo = getQn?.uniqueqno;
|
|
2782
|
+
}
|
|
2759
2783
|
getQn = JSON.parse( JSON.stringify( getQn ) );
|
|
2760
2784
|
getQn = { ...getQn, uniqueNo: randomNo };
|
|
2761
2785
|
nesedQuestion.push( getQn );
|