tango-app-api-trax 3.7.57 → 3.7.58

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.7.57",
3
+ "version": "3.7.58",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1268,6 +1268,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
1268
1268
  structure.questionReferenceImage = qaAnswers[j].questionReferenceImage || '';
1269
1269
  structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
1270
1270
  structure.descriptivetype = qaAnswers[j].descriptivetype;
1271
+ structure.allowMultiple = qaAnswers[j].allowMultiple;
1271
1272
  // structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
1272
1273
  structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
1273
1274
  if ( qaAnswers[j]?.taskId ) {
@@ -1328,6 +1329,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
1328
1329
  structure.questionReferenceImage = qaAnswers[j].questionReferenceImage || '';
1329
1330
  structure.multiQuestionReferenceImage = qaAnswers[j].multiQuestionReferenceImage || [];
1330
1331
  structure.descriptivetype = qaAnswers[j].descriptivetype;
1332
+ structure.allowMultiple = qaAnswers[j].allowMultiple;
1331
1333
  // structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
1332
1334
  structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
1333
1335
  if ( qaAnswers[j]?.taskId ) {
@@ -26,6 +26,7 @@ import * as teamsServices from '../services/teams.service.js';
26
26
  import * as runAIFeatureServices from '../services/runAIFeatures.services.js';
27
27
  import * as runAIRequestServices from '../services/runAIRequest.services.js';
28
28
  import * as processedTaskService from '../services/processedTaskList.service.js';
29
+ import ExcelJS from 'exceljs';
29
30
 
30
31
 
31
32
  export const checklist = async ( req, res ) => {
@@ -5075,3 +5076,71 @@ export async function updateOSProcessedData( req, res ) {
5075
5076
  return res.sendError( error, 500 );
5076
5077
  }
5077
5078
  }
5079
+
5080
+ export async function downloadQuestionTemplate( req, res ) {
5081
+ try {
5082
+ let questionDetails = await questionService.find( { checkListId: req.body.checklistId } );
5083
+ let answerType = {
5084
+ 'descriptive': 'Descriptive Answer',
5085
+ 'yes/no': 'A/B Question',
5086
+ 'multiplechoicesingle': 'Multiple Choice Single',
5087
+ 'multiplechoicemultiple': 'Multiple Choice Multiple',
5088
+ 'descriptiveImage': 'Capture Image with Description',
5089
+ 'image': 'Capture Image as answer',
5090
+ 'video': 'Capture video as answer',
5091
+ 'multipleImage': 'Capture Multiple Image',
5092
+ 'date': 'Date',
5093
+ 'linearscale': 'Linear Scale',
5094
+ 'image/video': 'Capture Image/Video as Answer',
5095
+ 'time': 'Time',
5096
+ 'dropdown': 'Dropdown',
5097
+ };
5098
+ const workbook = new ExcelJS.Workbook();
5099
+ const sheet = workbook.addWorksheet( 'Fixture Library' );
5100
+
5101
+ sheet.getRow( 1 ).values = [ 'Section Name', 'Question', 'Answer Type', 'Answer Options' ];
5102
+
5103
+ let rowStart = 2;
5104
+
5105
+ questionDetails.forEach( ( section ) => {
5106
+ section.question.forEach( ( qn ) => {
5107
+ sheet.getRow( rowStart ).values = [ section.section, qn.qname, answerType[`${qn.answerType}`], [ 'multiplechoicesingle', 'multiplechoicemultiple', 'dropdown' ].includes( qn.answerType ) ? qn.answers.map( ( ans ) => ans.answer )?.toString() : '' ];
5108
+ rowStart += 1;
5109
+ } );
5110
+ } );
5111
+
5112
+
5113
+ const maxRows = 500000;
5114
+
5115
+ let dropDownRange = [ { key: `C2:C${maxRows}`, optionList: [ '"Descriptive Answer,A/B Question,Multiple Choice Single,Multiple Choice Multiple,Capture Image with Description,Capture Image as answer,Capture video as answer,Capture Multiple Image,Date,Linear Scale,Capture Image/Video as Answer,Time,Dropdown,"' ] } ];
5116
+
5117
+ dropDownRange.forEach( ( ele ) => {
5118
+ sheet.dataValidations.add( ele.key, {
5119
+ type: 'list',
5120
+ allowBlank: true,
5121
+ formulae: ele.optionList,
5122
+ showErrorMessage: true,
5123
+ errorTitle: 'Invalid Choice',
5124
+ error: 'Please select from the dropdown list.',
5125
+ } );
5126
+ } );
5127
+
5128
+ sheet.columns.forEach( ( column ) => {
5129
+ let maxLength = 10;
5130
+ column.eachCell( { includeEmpty: true }, ( cell ) => {
5131
+ const cellValue = cell.value ? cell.value.toString() : '';
5132
+ if ( cellValue.length > maxLength ) {
5133
+ maxLength = cellValue.length;
5134
+ }
5135
+ } );
5136
+ column.width = maxLength + 2;
5137
+ } );
5138
+ const buffer = await workbook.xlsx.writeBuffer();
5139
+ res.setHeader( 'Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' );
5140
+ res.setHeader( 'Content-Disposition', 'attachment; filename="Checklist Question.xlsx"' );
5141
+ return res.send( buffer );
5142
+ } catch ( e ) {
5143
+ logger.error( { functionName: 'downloadQuestionTemplate', error: e } );
5144
+ return res.sendError( e, 500 );
5145
+ }
5146
+ }
@@ -35,6 +35,7 @@ traxRouter
35
35
  .post( '/updateRunAIFeatures', isAllowedSessionHandler, traxController.updateRunAIFeatures )
36
36
  .post( '/updateRunAIRequest', isAllowedSessionHandler, validate( runAIRequestValidation ), traxController.updateRunAIRequest )
37
37
  .post( '/createChecklistName', isAllowedSessionHandler, validate( createChecklistNameValidation ), traxController.createChecklistName )
38
- .post( '/updateOSProcessedData', isAllowedInternalAPIHandler, validate( updateOSDataValidation ), traxController.updateOSProcessedData );
38
+ .post( '/updateOSProcessedData', isAllowedInternalAPIHandler, validate( updateOSDataValidation ), traxController.updateOSProcessedData )
39
+ .post( '/exportQuestions', isAllowedSessionHandler, traxController.downloadQuestionTemplate );
39
40
 
40
41
  // isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ ] } ] } ),