tango-app-api-trax 3.3.1-beta-38 → 3.3.1-beta-39
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
|
@@ -269,6 +269,37 @@ export async function startChecklist( req, res ) {
|
|
|
269
269
|
getchecklist[index].questionAnswers[secIndex].questions = questions;
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
|
+
|
|
273
|
+
let orderedQuestions = [];
|
|
274
|
+
|
|
275
|
+
function processQuestion( question, section, questions, nested=false ) {
|
|
276
|
+
let findExists = orderedQuestions.find( ( item ) => item?.qno && item.qno == question.qno );
|
|
277
|
+
if ( findExists && nested && question.parentQuestion == findExists.parentQuestion ) {
|
|
278
|
+
let findIndex = orderedQuestions.findIndex( ( item ) => item?.qno && item.qno == question.qno );
|
|
279
|
+
orderedQuestions.splice( findIndex, 1 );
|
|
280
|
+
orderedQuestions.push( question );
|
|
281
|
+
}
|
|
282
|
+
if ( !findExists ) {
|
|
283
|
+
orderedQuestions.push( question );
|
|
284
|
+
for ( let answer of question.answers ) {
|
|
285
|
+
if ( answer.showLinked && answer?.linkedQuestion != '' ) {
|
|
286
|
+
let linkedQuestion = section.questions.find( ( item ) => item.qno == answer.linkedQuestion );
|
|
287
|
+
if ( linkedQuestion ) {
|
|
288
|
+
processQuestion( linkedQuestion, section, questions, true );
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
for ( let [ index, data ] of getchecklist.entries() ) {
|
|
295
|
+
for ( let [ secIndex, section ] of data.questionAnswers.entries() ) {
|
|
296
|
+
orderedQuestions = [];
|
|
297
|
+
for ( let question of section.questions ) {
|
|
298
|
+
processQuestion( question, section, questions );
|
|
299
|
+
}
|
|
300
|
+
getchecklist[index].questionAnswers[secIndex].questions = orderedQuestions;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
272
303
|
return res.sendSuccess( getchecklist );
|
|
273
304
|
} else {
|
|
274
305
|
return res.sendError( 'something went wrong please try again', 500 );
|
|
@@ -2681,6 +2712,37 @@ export async function questionList( req, res ) {
|
|
|
2681
2712
|
}
|
|
2682
2713
|
}
|
|
2683
2714
|
|
|
2715
|
+
let orderedQuestions = [];
|
|
2716
|
+
|
|
2717
|
+
function processQuestion( question, section, questions, nested=false ) {
|
|
2718
|
+
let findExists = orderedQuestions.find( ( item ) => item?.qno && item.qno == question.qno );
|
|
2719
|
+
if ( findExists && nested && question.parentQuestion == findExists.parentQuestion ) {
|
|
2720
|
+
let findIndex = orderedQuestions.findIndex( ( item ) => item?.qno && item.qno == question.qno );
|
|
2721
|
+
orderedQuestions.splice( findIndex, 1 );
|
|
2722
|
+
orderedQuestions.push( question );
|
|
2723
|
+
}
|
|
2724
|
+
if ( !findExists ) {
|
|
2725
|
+
orderedQuestions.push( question );
|
|
2726
|
+
for ( let answer of question.answers ) {
|
|
2727
|
+
if ( answer.showLinked && answer?.linkedQuestion != '' ) {
|
|
2728
|
+
let linkedQuestion = section.questions.find( ( item ) => item.qno == answer.linkedQuestion );
|
|
2729
|
+
if ( linkedQuestion ) {
|
|
2730
|
+
processQuestion( linkedQuestion, section, questions, true );
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
}
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
for ( let [ index, data ] of getchecklist.entries() ) {
|
|
2737
|
+
for ( let [ secIndex, section ] of data.questionAnswers.entries() ) {
|
|
2738
|
+
orderedQuestions = [];
|
|
2739
|
+
for ( let question of section.questions ) {
|
|
2740
|
+
processQuestion( question, section, questions );
|
|
2741
|
+
}
|
|
2742
|
+
getchecklist[index].questionAnswers[secIndex].questions = orderedQuestions;
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
|
|
2684
2746
|
return res.sendSuccess( getchecklist );
|
|
2685
2747
|
}
|
|
2686
2748
|
} catch ( e ) {
|