@@ -77,6 +77,10 @@ func RetrieveQuestions(c *fiber.Ctx) (err error) {
7777 return common .InternalServerError ("[retrieve questions]: number of campus questions invalid" )
7878 }
7979
80+ if number == 0 {
81+ return common .InternalServerError ("[retrieve questions]: number of questions too small" )
82+ }
83+
8084 var questionsResponse = QuestionConfig {
8185 Version : version ,
8286 Spec : QuestionSpec {
@@ -89,25 +93,8 @@ func RetrieveQuestions(c *fiber.Ctx) (err error) {
8993
9094 questionsResponse .Questions = make ([]Question , number )
9195 tmpQuestions := make ([]* Question , 0 , number )
92-
93- if number == 0 {
94- return common .InternalServerError ("[retrieve questions]: number of questions too small" )
95- }
96-
9796 tmpQuestions = append (tmpQuestions , requiredQuestions ... )
9897
99- jsonTmpQuestions , _ := json .Marshal (questionConfig )
100- log .Debug ().Msgf ("questionsResponse: %s" , string (jsonTmpQuestions ))
101-
102- jsonTmpQuestions , _ = json .Marshal (tmpQuestions )
103- log .Debug ().Msgf ("questionsResponse: %s" , string (jsonTmpQuestions ))
104-
105- // for i, question := range requiredQuestions {
106- // tmpQuestions[i] = question
107- // // questionsResponse.Questions[i] = *question
108- // }
109-
110- // questionConfig.Questions = append(questionConfig.Questions, optionalQuestions...)
11198 if numberOfOptionalQuestions == - 1 {
11299 // send all opntional questions
113100 tmpQuestions = append (tmpQuestions , optionalQuestions ... )
@@ -136,9 +123,6 @@ func RetrieveQuestions(c *fiber.Ctx) (err error) {
136123 tmpQuestions = append (tmpQuestions , chosenCampusQuestions [:numberOfCampusQuestions ]... )
137124 }
138125
139- jsonTmpQuestions , _ = json .Marshal (tmpQuestions )
140- log .Debug ().Msgf ("questionsResponse: %s" , string (jsonTmpQuestions ))
141-
142126 if ! inOrder {
143127 rand .Shuffle (len (tmpQuestions ), func (i , j int ) {
144128 tmpQuestions [i ], tmpQuestions [j ] = tmpQuestions [j ], tmpQuestions [i ]
@@ -149,9 +133,6 @@ func RetrieveQuestions(c *fiber.Ctx) (err error) {
149133 })
150134 }
151135
152- jsonTmpQuestions , _ = json .Marshal (tmpQuestions )
153- log .Debug ().Msgf ("questionsResponse: %s" , string (jsonTmpQuestions ))
154-
155136 for i , question := range tmpQuestions {
156137 questionsResponse .Questions [i ] = * question
157138 }
0 commit comments