@sourceloop/survey-service / Exports / QuestionHelperService
Class: QuestionHelperService¶
Table of contents¶
Constructors¶
Properties¶
- logger
- optionsRepository
- questionRepository
- surveyQuestionRepository
- surveyService
- templateQuestionRepository
Methods¶
- _addLeadingZero
- _createDefaultOptions
- _createFollowupQuestion
- _deleteAllOptionsByQuestion
- _handleQuestionTypeChange
- checkAndGetIfAllowedQuestionToUpdate
- checkIfAllowedToUpdate
- checkIfUsedInTemplateOrSurvey
- createQuestion
- deleteQuestion
- findQuestionWithOptions
- generateQuestionUuid
- handleApprove
- handleOnStatusChange
- updateAllChildStatus
- updateQuestion
- validateParentQuestion
Constructors¶
constructor¶
• new QuestionHelperService(questionRepository, optionsRepository, templateQuestionRepository, surveyQuestionRepository, surveyService, logger)
Parameters¶
| Name | Type |
|---|---|
questionRepository |
QuestionRepository |
optionsRepository |
OptionsRepository |
templateQuestionRepository |
TemplateQuestionRepository |
surveyQuestionRepository |
SurveyQuestionRepository |
surveyService |
SurveyService |
logger |
ILogger |
Defined in¶
services/survey-service/src/services/question-helper.service.ts:21
Properties¶
logger¶
• logger: ILogger
Defined in¶
services/survey-service/src/services/question-helper.service.ts:32
optionsRepository¶
• optionsRepository: OptionsRepository
Defined in¶
services/survey-service/src/services/question-helper.service.ts:25
questionRepository¶
• questionRepository: QuestionRepository
Defined in¶
services/survey-service/src/services/question-helper.service.ts:23
surveyQuestionRepository¶
• surveyQuestionRepository: SurveyQuestionRepository
Defined in¶
services/survey-service/src/services/question-helper.service.ts:29
surveyService¶
• surveyService: SurveyService
Defined in¶
services/survey-service/src/services/question-helper.service.ts:31
templateQuestionRepository¶
• templateQuestionRepository: TemplateQuestionRepository
Defined in¶
services/survey-service/src/services/question-helper.service.ts:27
Methods¶
_addLeadingZero¶
▸ _addLeadingZero(number, size): string
Parameters¶
| Name | Type |
|---|---|
number |
number |
size |
number |
Returns¶
string
Defined in¶
services/survey-service/src/services/question-helper.service.ts:169
_createDefaultOptions¶
▸ _createDefaultOptions(questionId, questionType): Promise<void>
Parameters¶
| Name | Type |
|---|---|
questionId |
string |
questionType |
QuestionType |
Returns¶
Promise<void>
Defined in¶
services/survey-service/src/services/question-helper.service.ts:179
_createFollowupQuestion¶
▸ _createFollowupQuestion(question, optionId): Promise<Question>
Parameters¶
| Name | Type |
|---|---|
question |
Question |
optionId |
string |
Returns¶
Promise<Question>
Defined in¶
services/survey-service/src/services/question-helper.service.ts:101
_deleteAllOptionsByQuestion¶
▸ _deleteAllOptionsByQuestion(question): Promise<void>
Parameters¶
| Name | Type |
|---|---|
question |
Question |
Returns¶
Promise<void>
Defined in¶
services/survey-service/src/services/question-helper.service.ts:238
_handleQuestionTypeChange¶
▸ _handleQuestionTypeChange(question, existingQuestion, questionId): Promise<void>
Parameters¶
| Name | Type |
|---|---|
question |
Question |
existingQuestion |
Question |
questionId |
string |
Returns¶
Promise<void>
Defined in¶
services/survey-service/src/services/question-helper.service.ts:305
checkAndGetIfAllowedQuestionToUpdate¶
▸ checkAndGetIfAllowedQuestionToUpdate(questionId, question?): Promise<{ existingQuestion: Question & QuestionRelations }>
Parameters¶
| Name | Type |
|---|---|
questionId |
string |
question? |
Question |
Returns¶
Promise<{ existingQuestion: Question & QuestionRelations }>
Defined in¶
services/survey-service/src/services/question-helper.service.ts:393
checkIfAllowedToUpdate¶
▸ checkIfAllowedToUpdate(existingQuestion, updateQuestion?): void
Parameters¶
| Name | Type |
|---|---|
existingQuestion |
Question |
updateQuestion? |
Question |
Returns¶
void
Defined in¶
services/survey-service/src/services/question-helper.service.ts:335
checkIfUsedInTemplateOrSurvey¶
▸ checkIfUsedInTemplateOrSurvey(questionId): Promise<void>
Parameters¶
| Name | Type |
|---|---|
questionId |
string |
Returns¶
Promise<void>
Defined in¶
services/survey-service/src/services/question-helper.service.ts:345
createQuestion¶
▸ createQuestion(question, status?): Promise<Question>
This function creates a new question with specified status and additional logic for handling follow-up questions and default options.
Parameters¶
| Name | Type | Default value | Description |
|---|---|---|---|
question |
QuestionDto |
undefined |
The createQuestion function you provided is an asynchronous function that creates a new question based on the provided QuestionDto object and a default status of QuestionStatus.DRAFT. Here's a breakdown of the function: |
status |
string |
QuestionStatus.DRAFT |
The status parameter in the createQuestion function is used to specify the status of the question being created. By default, if no status is provided, the question will be set to QuestionStatus.DRAFT. However, you can override this default value by providing a different status when calling |
Returns¶
Promise<Question>
The createQuestion function returns a Promise that resolves to a Question object.
Defined in¶
services/survey-service/src/services/question-helper.service.ts:47
deleteQuestion¶
▸ deleteQuestion(id): Promise<void>
Parameters¶
| Name | Type |
|---|---|
id |
string |
Returns¶
Promise<void>
Defined in¶
services/survey-service/src/services/question-helper.service.ts:208
findQuestionWithOptions¶
▸ findQuestionWithOptions(questionId): Promise<Question>
Parameters¶
| Name | Type |
|---|---|
questionId |
string |
Returns¶
Promise<Question>
Defined in¶
services/survey-service/src/services/question-helper.service.ts:246
generateQuestionUuid¶
▸ generateQuestionUuid(questionId?): Promise<string>
Parameters¶
| Name | Type |
|---|---|
questionId? |
string |
Returns¶
Promise<string>
Defined in¶
services/survey-service/src/services/question-helper.service.ts:146
handleApprove¶
▸ handleApprove(id): Promise<void>
Parameters¶
| Name | Type |
|---|---|
id |
string |
Returns¶
Promise<void>
Defined in¶
services/survey-service/src/services/question-helper.service.ts:322
handleOnStatusChange¶
▸ handleOnStatusChange(id, updateQuestion): Promise<void>
Parameters¶
| Name | Type |
|---|---|
id |
string |
updateQuestion |
Question |
Returns¶
Promise<void>
Defined in¶
services/survey-service/src/services/question-helper.service.ts:364
updateAllChildStatus¶
▸ updateAllChildStatus(id, status): Promise<void>
Parameters¶
| Name | Type |
|---|---|
id |
string |
status |
QuestionStatus |
Returns¶
Promise<void>
Defined in¶
services/survey-service/src/services/question-helper.service.ts:326
updateQuestion¶
▸ updateQuestion(questionId, question): Promise<Question & QuestionRelations>
Parameters¶
| Name | Type |
|---|---|
questionId |
string |
question |
Question |
Returns¶
Promise<Question & QuestionRelations>
Defined in¶
services/survey-service/src/services/question-helper.service.ts:265
validateParentQuestion¶
▸ validateParentQuestion(parentQuestionId): Promise<void>
Parameters¶
| Name | Type |
|---|---|
parentQuestionId |
undefined | string |
Returns¶
Promise<void>
Defined in¶
services/survey-service/src/services/question-helper.service.ts:372