diff --git a/controller/adapter.go b/controller/adapter.go index 23128efe..4a4a2633 100644 --- a/controller/adapter.go +++ b/controller/adapter.go @@ -152,7 +152,7 @@ func questionnaire2QuestionnaireDetail(questionnaires model.Questionnaires, admi Admins: createUsersAndGroups(adminUsers, adminGroups), CreatedAt: questionnaires.CreatedAt, Description: questionnaires.Description, - IsAllowingMultipleResponses: questionnaires.IsAllowingMultipleResponses, + // IsAllowingMultipleResponses: questionnaires.IsAllowingMultipleResponses, IsAnonymous: questionnaires.IsAnonymous, IsPublished: questionnaires.IsPublished, ModifiedAt: questionnaires.ModifiedAt, @@ -264,6 +264,12 @@ func respondentDetail2Response(ctx echo.Context, respondentDetail model.Responde oResponseBodies = append(oResponseBodies, oResponseBody) } + isAnonymous, err := model.NewQuestionnaire().GetResponseIsAnonymousByQuestionnaireID(ctx.Request().Context(), respondentDetail.QuestionnaireID) + if err != nil { + ctx.Logger().Errorf("failed to get response is anonymous: %+v", err) + return openapi.Response{}, err + } + res := openapi.Response{ Body: oResponseBodies, IsDraft: respondentDetail.SubmittedAt.Valid, @@ -272,6 +278,7 @@ func respondentDetail2Response(ctx echo.Context, respondentDetail model.Responde Respondent: &(respondentDetail.TraqID), ResponseId: respondentDetail.ResponseID, SubmittedAt: respondentDetail.SubmittedAt.Time, + IsAnonymous: &isAnonymous, } return res, nil diff --git a/controller/questionnaire.go b/controller/questionnaire.go index c907fb19..8d45d139 100644 --- a/controller/questionnaire.go +++ b/controller/questionnaire.go @@ -656,6 +656,8 @@ func (q Questionnaire) PostQuestionnaireResponse(c echo.Context, questionnaireID } } + isAnonymous, err := q.GetResponseIsAnonymousByQuestionnaireID(c.Request().Context(), questionnaireID) + res = openapi.Response{ QuestionnaireId: questionnaireID, ResponseId: resopnseID, @@ -663,6 +665,7 @@ func (q Questionnaire) PostQuestionnaireResponse(c echo.Context, questionnaireID SubmittedAt: submittedAt, ModifiedAt: modifiedAt, IsDraft: params.IsDraft, + IsAnonymous: &isAnonymous, Body: params.Body, } diff --git a/controller/response.go b/controller/response.go index 346f548e..425b874c 100644 --- a/controller/response.go +++ b/controller/response.go @@ -79,6 +79,7 @@ func (r Response) GetMyResponses(ctx echo.Context, params openapi.GetMyResponses Respondent: &userID, ResponseId: response.ResponseId, SubmittedAt: response.SubmittedAt, + IsAnonymous: response.IsAnonymous, } res = append(res, tmp) } @@ -244,6 +245,6 @@ func (r Response) EditResponse(ctx echo.Context, responseID openapi.ResponseIDIn return echo.NewHTTPError(http.StatusInternalServerError, fmt.Errorf("failed to insert responses: %w", err)) } } - + return nil -} \ No newline at end of file +}