tango-app-api-trax 3.7.69 → 3.7.71
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
|
@@ -714,10 +714,13 @@ export async function sopMobileTaskQuestionValidator( req, res, next ) {
|
|
|
714
714
|
section.questions.forEach( ( question ) => {
|
|
715
715
|
question.answers.forEach( ( answer ) => {
|
|
716
716
|
let sectionQuestion = requestSection.filter( ( secQuestion ) => secQuestion.qno == question.qno );
|
|
717
|
-
if (
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
717
|
+
if ( sectionQuestion[0] ) {
|
|
718
|
+
const multianswerEmpty = sectionQuestion[0].Multianswer == null || sectionQuestion[0].Multianswer == '' || !sectionQuestion[0].Multianswer?.length;
|
|
719
|
+
const answerEmpty = ( !sectionQuestion[0].linkType && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) );
|
|
720
|
+
const usesMultianswer = [ 'multiplechoicemultiple', 'multipleImage', 'image/video' ].includes( question.answerType ) || ( question.answerType == 'dropdown' && question.allowMultiple );
|
|
721
|
+
if ( usesMultianswer && multianswerEmpty ) {
|
|
722
|
+
validationCount++;
|
|
723
|
+
} else if ( !usesMultianswer && answerEmpty ) {
|
|
721
724
|
validationCount++;
|
|
722
725
|
}
|
|
723
726
|
}
|
|
@@ -1210,6 +1213,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1210
1213
|
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage || '';
|
|
1211
1214
|
structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
|
|
1212
1215
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1216
|
+
structure.compliance = qaAnswers[j]?.compliance;
|
|
1213
1217
|
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1214
1218
|
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1215
1219
|
if ( qaAnswers[j]?.taskId ) {
|
|
@@ -1267,6 +1271,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1267
1271
|
structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
|
|
1268
1272
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1269
1273
|
structure.allowMultiple = qaAnswers[j].allowMultiple;
|
|
1274
|
+
structure.compliance = qaAnswers[j]?.compliance;
|
|
1270
1275
|
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1271
1276
|
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1272
1277
|
if ( qaAnswers[j]?.taskId ) {
|
|
@@ -1328,6 +1333,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1328
1333
|
structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
|
|
1329
1334
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1330
1335
|
structure.allowMultiple = qaAnswers[j].allowMultiple;
|
|
1336
|
+
structure.compliance = qaAnswers[j]?.compliance;
|
|
1331
1337
|
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1332
1338
|
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1333
1339
|
if ( qaAnswers[j]?.taskId ) {
|
|
@@ -1398,6 +1404,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1398
1404
|
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage || '';
|
|
1399
1405
|
structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
|
|
1400
1406
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1407
|
+
structure.compliance = qaAnswers[j]?.compliance;
|
|
1401
1408
|
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1402
1409
|
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1403
1410
|
if ( qaAnswers[j]?.taskId ) {
|
|
@@ -1444,9 +1451,40 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1444
1451
|
};
|
|
1445
1452
|
if ( qaAnswers[j].answerType == 'date' ) {
|
|
1446
1453
|
ansstructure.dateRangeType = requestSection[i].dateRangeType || false;
|
|
1454
|
+
if ( qaAnswers[j].compliance ) {
|
|
1455
|
+
if ( qaAnswers[j].compliance ) {
|
|
1456
|
+
let ansArray = requestSection[i].answer.split( ',' );
|
|
1457
|
+
if ( ansArray.includes( '-' ) ) {
|
|
1458
|
+
ansArray = requestSection[i].answer.split( '-' );
|
|
1459
|
+
}
|
|
1460
|
+
if ( ansArray.length > 1 && ansArray.some( ( date ) => dayjs( date, 'DD MMM YYYY' ).format( 'DD-MM-YYYY' ) >= qaAnswers[j]?.answers[0]?.startDate || dayjs( date, 'DD MMM YYYY' ) <= qaAnswers[j]?.answers[0]?.endDate ) ) {
|
|
1461
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1462
|
+
} else if ( ansArray.length > 1 && ( dayjs( ansArray?.[0], 'DD MMM YYYY' ).format( 'DD-MM-YYYY' ) >= qaAnswers[j]?.answers[0]?.startDate || dayjs( ansArray?.[1], 'DD MMM YYYY' ).format( 'DD-MM-YYYY' ) <= qaAnswers[j]?.answers[0]?.endDate ) ) {
|
|
1463
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1464
|
+
} else if ( dayjs( requestSection[i].answer, 'DD MMM YYYY' ) >= qaAnswers[j]?.answers[0]?.startDate || dayjs( requestSection[i].answer, 'DD MMM YYYY' ) <= qaAnswers[j]?.answers[0]?.startDate ) {
|
|
1465
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1466
|
+
} else {
|
|
1467
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1447
1471
|
}
|
|
1448
1472
|
if ( qaAnswers[j].answerType == 'linearscale' ) {
|
|
1473
|
+
if ( qaAnswers[j].compliance ) {
|
|
1474
|
+
let linearAnswer = requestSection[i].answer.split( 'to' );
|
|
1475
|
+
if ( parseInt( linearAnswer?.[0] ) >= qaAnswers[j]?.answers[0]?.minValue || parseInt( linearAnswer?.[1] ) <= qaAnswers[j]?.answers[0]?.maxValue ) {
|
|
1476
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1477
|
+
} else {
|
|
1478
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1449
1481
|
ansstructure.linearType = qaAnswers[j]?.answers[0]?.linearType;
|
|
1482
|
+
ansstructure.matchedCount = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1483
|
+
ansstructure.notMatchedCount = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1484
|
+
}
|
|
1485
|
+
if ( qaAnswers[j].answerType == 'image' ) {
|
|
1486
|
+
ansstructure.matchedCount = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1487
|
+
ansstructure.notMatchedCount = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1450
1488
|
}
|
|
1451
1489
|
des.push( ansstructure );
|
|
1452
1490
|
}
|
|
@@ -1470,6 +1508,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1470
1508
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1471
1509
|
// structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1472
1510
|
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1511
|
+
structure.compliance = qaAnswers[j]?.compliance;
|
|
1473
1512
|
if ( qaAnswers[j]?.taskId ) {
|
|
1474
1513
|
structure.taskId = qaAnswers[j]?.taskId;
|
|
1475
1514
|
structure.task = true;
|
|
@@ -1516,7 +1555,7 @@ export async function sopMobileTaskMultiSectionFormatter( req, res, next ) {
|
|
|
1516
1555
|
|
|
1517
1556
|
if ( requestData.submittype == 'submit' ) {
|
|
1518
1557
|
reqAnswers.forEach( ( reqA ) => {
|
|
1519
|
-
if ( ![ 'multiplechoicemultiple', 'multipleImage' ].includes( reqA?.answerType ) ) {
|
|
1558
|
+
if ( ![ 'multiplechoicemultiple', 'multipleImage', 'image/video' ].includes( reqA?.answerType ) && !( reqA?.answerType == 'dropdown' && reqA?.allowMultiple ) ) {
|
|
1520
1559
|
if ( ( !reqA.linkType && ( reqA.answer == null || reqA.answer == '' ) ) || ( reqA.linkType && reqA.linkquestionenabled && ( reqA.answer == null || reqA.answer == '' ) ) ) {
|
|
1521
1560
|
return res.sendError( 'Please Fill All Fields', 400 );
|
|
1522
1561
|
}
|
|
@@ -1697,8 +1736,64 @@ export async function sopMobileTaskMultiSectionFormatter( req, res, next ) {
|
|
|
1697
1736
|
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
1698
1737
|
};
|
|
1699
1738
|
newArray.push( structure );
|
|
1739
|
+
} else if ( qaAnswers[j].answerType == 'dropdown' && qaAnswers[j].allowMultiple ) {
|
|
1740
|
+
let qaans = qaAnswers[j].answers;
|
|
1741
|
+
let mcmo = [];
|
|
1742
|
+
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1743
|
+
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
|
|
1744
|
+
if ( separatedArray && separatedArray.length ) {
|
|
1745
|
+
for ( let s = 0; s < separatedArray.length; s++ ) {
|
|
1746
|
+
if ( separatedArray[s].answer == qaans[k].answer ) {
|
|
1747
|
+
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1748
|
+
if ( separatedArray[s].validationAnswer ) {
|
|
1749
|
+
let validationAnswer = decodeURIComponent( separatedArray[s].validationAnswer.split( '?' )[0] );
|
|
1750
|
+
if ( validationAnswer.length ) {
|
|
1751
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1752
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1753
|
+
splitImgUrl.splice( 0, 3 );
|
|
1754
|
+
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
} else {
|
|
1759
|
+
qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1760
|
+
qaans[k].validationAnswer = separatedArray[s].validationAnswer || '';
|
|
1761
|
+
}
|
|
1762
|
+
mcmo.push( qaans[k] );
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
let structure = {};
|
|
1768
|
+
structure.qno = qaAnswers[j].qno;
|
|
1769
|
+
structure.qname = qaAnswers[j].qname;
|
|
1770
|
+
if ( qaAnswers[j].qcomment && qaAnswers[j].qcomment!='' ) {
|
|
1771
|
+
structure.qcomment = qaAnswers[j].qcomment;
|
|
1772
|
+
}
|
|
1773
|
+
structure.answerType = qaAnswers[j].answerType;
|
|
1774
|
+
structure.runAI = qaAnswers[j].runAI;
|
|
1775
|
+
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1776
|
+
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1777
|
+
structure.remarks = requestSection[i].remarks;
|
|
1778
|
+
structure.answers = qaAnswers[j].answers;
|
|
1779
|
+
structure.userAnswer = mcmo;
|
|
1780
|
+
structure.linkType = qaAnswers[j].linkType;
|
|
1781
|
+
structure.linkquestionenabled = requestSection[i].linkquestionenabled;
|
|
1782
|
+
structure.parentanswer = requestSection[i].parentanswer;
|
|
1783
|
+
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
|
|
1784
|
+
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1785
|
+
structure.allowMultiple = qaAnswers[j].allowMultiple;
|
|
1786
|
+
if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1787
|
+
structure.redo = false;
|
|
1788
|
+
} else if ( requestData.submittype === 'draft' ) {
|
|
1789
|
+
structure.redo = qaAnswers[j]?.redo;
|
|
1790
|
+
}
|
|
1791
|
+
if ( qaAnswers[j]?.redoComment ) {
|
|
1792
|
+
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
1793
|
+
};
|
|
1794
|
+
newArray.push( structure );
|
|
1700
1795
|
} else if ( qaAnswers[j].answerType == 'multipleImage' ) {
|
|
1701
|
-
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
|
|
1796
|
+
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : ( requestSection[i].Multianswer || [] );
|
|
1702
1797
|
let mcmi = [];
|
|
1703
1798
|
// for (let k = 0; k < qaans.length; k++) {
|
|
1704
1799
|
for ( let s = 0; s < separatedArray.length; s++ ) {
|
|
@@ -1756,6 +1851,69 @@ export async function sopMobileTaskMultiSectionFormatter( req, res, next ) {
|
|
|
1756
1851
|
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
1757
1852
|
};
|
|
1758
1853
|
newArray.push( structure );
|
|
1854
|
+
} else if ( qaAnswers[j].answerType == 'image/video' ) {
|
|
1855
|
+
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
|
|
1856
|
+
let mcmi = [];
|
|
1857
|
+
if ( separatedArray && separatedArray.length ) {
|
|
1858
|
+
for ( let s = 0; s < separatedArray.length; s++ ) {
|
|
1859
|
+
if ( separatedArray[s].answer && separatedArray[s].answer !='' ) {
|
|
1860
|
+
let newAnswer = {};
|
|
1861
|
+
let validationAnswer = decodeURIComponent( separatedArray[s].answer.split( '?' )[0] );
|
|
1862
|
+
if ( validationAnswer.length ) {
|
|
1863
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1864
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1865
|
+
splitImgUrl.splice( 0, 3 );
|
|
1866
|
+
newAnswer.answer = splitImgUrl.join( '/' ) || '';
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
newAnswer.answeroptionNumber = 0;
|
|
1870
|
+
newAnswer.sopFlag = false;
|
|
1871
|
+
newAnswer.validation = false;
|
|
1872
|
+
newAnswer.validationType = '';
|
|
1873
|
+
newAnswer.referenceImage = '';
|
|
1874
|
+
newAnswer.allowUploadfromGallery = false;
|
|
1875
|
+
newAnswer.descriptivetype = '';
|
|
1876
|
+
newAnswer.showLinked = false;
|
|
1877
|
+
newAnswer.linkedQuestion = 0;
|
|
1878
|
+
newAnswer.nestedQuestion = [];
|
|
1879
|
+
newAnswer.index = s;
|
|
1880
|
+
newAnswer.runAI = qaAnswers[j].answers[0]?.runAI || false;
|
|
1881
|
+
newAnswer.runAIFeatures = qaAnswers[j].answers[0]?.runAIFeatures || [];
|
|
1882
|
+
newAnswer.runAIDescription = qaAnswers[j].answers[0]?.runAIDescription || '';
|
|
1883
|
+
if ( separatedArray[s].answerType ) {
|
|
1884
|
+
newAnswer.answerType = separatedArray[s].answerType;
|
|
1885
|
+
}
|
|
1886
|
+
mcmi.push( newAnswer );
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
let structure = {};
|
|
1891
|
+
structure.qno = qaAnswers[j].qno;
|
|
1892
|
+
structure.qname = qaAnswers[j].qname;
|
|
1893
|
+
if ( qaAnswers[j].qcomment && qaAnswers[j].qcomment!='' ) {
|
|
1894
|
+
structure.qcomment = qaAnswers[j].qcomment;
|
|
1895
|
+
}
|
|
1896
|
+
structure.answerType = qaAnswers[j].answerType;
|
|
1897
|
+
structure.runAI = qaAnswers[j].runAI;
|
|
1898
|
+
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1899
|
+
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1900
|
+
structure.remarks = requestSection[i].remarks;
|
|
1901
|
+
structure.answers = qaAnswers[j].answers;
|
|
1902
|
+
structure.userAnswer = mcmi;
|
|
1903
|
+
structure.linkType = qaAnswers[j].linkType;
|
|
1904
|
+
structure.linkquestionenabled = requestSection[i].linkquestionenabled;
|
|
1905
|
+
structure.parentanswer = requestSection[i].parentanswer;
|
|
1906
|
+
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
|
|
1907
|
+
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1908
|
+
if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1909
|
+
structure.redo = false;
|
|
1910
|
+
} else if ( requestData.submittype === 'draft' ) {
|
|
1911
|
+
structure.redo = qaAnswers[j]?.redo;
|
|
1912
|
+
}
|
|
1913
|
+
if ( qaAnswers[j]?.redoComment ) {
|
|
1914
|
+
structure.redoComment = qaAnswers[j]?.redoComment;
|
|
1915
|
+
};
|
|
1916
|
+
newArray.push( structure );
|
|
1759
1917
|
} else {
|
|
1760
1918
|
let des = [];
|
|
1761
1919
|
if ( requestSection[i].answer != 'null' && requestSection[i].answer != '' && requestSection[i].answer != null ) {
|
|
@@ -2013,7 +2171,6 @@ export async function submitChecklist( req, res ) {
|
|
|
2013
2171
|
logDetails: {},
|
|
2014
2172
|
userType: req.user.userType,
|
|
2015
2173
|
};
|
|
2016
|
-
console.log( 'inserttraxlogs =>', inserttraxlogs );
|
|
2017
2174
|
insertOpenSearchData( openSearch.traxActivityLog, inserttraxlogs );
|
|
2018
2175
|
if ( updateData.questionFlag ) {
|
|
2019
2176
|
let checklistDetails = await checklistService.findOne( { _id: getchecklist[0].sourceCheckList_id }, { notifyFlags: 1, approver: 1 } );
|
|
@@ -2023,7 +2180,7 @@ export async function submitChecklist( req, res ) {
|
|
|
2023
2180
|
let data = {
|
|
2024
2181
|
storeName: getchecklist[0].storeName,
|
|
2025
2182
|
flagCount: updateData.questionFlag,
|
|
2026
|
-
checklistName: getchecklist[0].checkListName
|
|
2183
|
+
checklistName: getchecklist[0].checkListName,
|
|
2027
2184
|
submittedBy: getchecklist[0].userName,
|
|
2028
2185
|
time: updateData.submitMobileTime,
|
|
2029
2186
|
domain: `${JSON.parse( process.env.URL ).domain}/manage/trax/flags`,
|
|
@@ -3705,10 +3862,14 @@ export async function taskQuestionList( req, res ) {
|
|
|
3705
3862
|
}
|
|
3706
3863
|
}
|
|
3707
3864
|
|
|
3708
|
-
if ( question.answerType == 'multiplechoicemultiple' ) {
|
|
3865
|
+
if ( question.answerType == 'multiplechoicemultiple' || ( question.answerType == 'dropdown' && question.allowMultiple ) ) {
|
|
3709
3866
|
let checkvalidation = null;
|
|
3710
3867
|
if ( answer.validationAnswer && answer.validationAnswer != '' ) {
|
|
3711
|
-
|
|
3868
|
+
if ( answer.validationType != 'Descriptive Answer' ) {
|
|
3869
|
+
checkvalidation = await signedUrl( { file_path: decodeURIComponent( answer.validationAnswer ), Bucket: bucket.sop } );
|
|
3870
|
+
} else {
|
|
3871
|
+
checkvalidation = answer.validationAnswer;
|
|
3872
|
+
}
|
|
3712
3873
|
}
|
|
3713
3874
|
Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation } );
|
|
3714
3875
|
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].index = ansIndex;
|
|
@@ -3729,7 +3890,7 @@ export async function taskQuestionList( req, res ) {
|
|
|
3729
3890
|
Bucket: bucket.sop,
|
|
3730
3891
|
} );
|
|
3731
3892
|
}
|
|
3732
|
-
if ( [ 'image', 'descriptiveImage', 'video' ].includes( question.answerType ) && userAns.answer != '' ) {
|
|
3893
|
+
if ( [ 'image', 'descriptiveImage', 'video', 'image/video' ].includes( question.answerType ) && userAns.answer != '' ) {
|
|
3733
3894
|
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].answer = await signedUrl( {
|
|
3734
3895
|
file_path: decodeURIComponent( userAns.answer ),
|
|
3735
3896
|
Bucket: bucket.sop,
|
|
@@ -3741,23 +3902,23 @@ export async function taskQuestionList( req, res ) {
|
|
|
3741
3902
|
Bucket: bucket.sop,
|
|
3742
3903
|
} );
|
|
3743
3904
|
}
|
|
3744
|
-
if ( question.answerType == 'multiplechoicemultiple' ) {
|
|
3905
|
+
if ( question.answerType == 'multiplechoicemultiple' || ( question.answerType == 'dropdown' && question.allowMultiple ) ) {
|
|
3745
3906
|
let ansIndex = Multianswer.findIndex( ( item ) => item.answer == userAns.answer );
|
|
3746
|
-
if ( ansIndex ) {
|
|
3907
|
+
if ( ansIndex >= 0 ) {
|
|
3747
3908
|
Multianswer[ansIndex].validationAnswer = userAns.validationAnswer;
|
|
3748
3909
|
}
|
|
3749
3910
|
}
|
|
3750
|
-
if ( question.answerType == 'multipleImage' ) {
|
|
3911
|
+
if ( question.answerType == 'multipleImage' || question.answerType == 'image/video' ) {
|
|
3751
3912
|
if ( userAns && userAns.answer && userAns.answer != '' ) {
|
|
3752
3913
|
let manswer = await signedUrl( { file_path: decodeURIComponent( userAns.answer ), Bucket: bucket.sop } );
|
|
3753
|
-
Multianswer.push( { 'answer': manswer, 'no': userAnsIndex, 'validationAnswer': '' } );
|
|
3914
|
+
Multianswer.push( { 'answer': manswer, 'no': userAnsIndex, 'validationAnswer': '', ...( question.answerType == 'image/video' && { answerType: userAns?.answerType } ) } );
|
|
3754
3915
|
} else {
|
|
3755
3916
|
|
|
3756
3917
|
}
|
|
3757
3918
|
}
|
|
3758
3919
|
}
|
|
3759
3920
|
}
|
|
3760
|
-
if ( question.answerType == 'multiplechoicemultiple' ) {
|
|
3921
|
+
if ( question.answerType == 'multiplechoicemultiple' || ( question.answerType == 'dropdown' && question.allowMultiple ) ) {
|
|
3761
3922
|
Multianswer.forEach( ( item ) => {
|
|
3762
3923
|
if ( item.validationAnswer == null ) {
|
|
3763
3924
|
item.answer = null;
|
|
@@ -3769,11 +3930,11 @@ export async function taskQuestionList( req, res ) {
|
|
|
3769
3930
|
question.Multianswer = Multianswer;
|
|
3770
3931
|
}
|
|
3771
3932
|
}
|
|
3772
|
-
if ( question.answerType == 'multipleImage' ) {
|
|
3933
|
+
if ( question.answerType == 'multipleImage' || question.answerType == 'image/video' ) {
|
|
3773
3934
|
if ( Multianswer.length ) {
|
|
3774
3935
|
question.Multianswer = Multianswer;
|
|
3775
3936
|
} else {
|
|
3776
|
-
Multianswer.push( { 'answer': null, 'no': 0, 'validationAnswer': null } );
|
|
3937
|
+
Multianswer.push( { 'answer': null, 'no': 0, 'validationAnswer': null, ...( question.answerType == 'image/video' && { answerType: null } ) } );
|
|
3777
3938
|
question.Multianswer = Multianswer;
|
|
3778
3939
|
}
|
|
3779
3940
|
}
|