@@ -170,27 +170,36 @@ class ExampleController(
170170 @PathVariable course : String ,
171171 @PathVariable example : String ,
172172 @RequestBody body : ExampleDurationDTO ,
173- ) {
173+ ): ExamplePublicationDTO {
174174 val activeExample = exampleService.getExamples(course).firstOrNull {
175175 it.status == TaskStatus .Interactive
176176 }
177177
178178 if (activeExample != null ) {
179179 throw ResponseStatusException (
180- HttpStatus .NOT_FOUND ,
180+ HttpStatus .CONFLICT ,
181181 " An interactive example already exists."
182182 )
183183 }
184184
185185 val updatedExample = exampleService.publishExampleBySlug(course, example, body.duration)
186186
187+ val start = updatedExample.start
188+ val end = updatedExample.end
189+
190+ if (start == null || end == null ) {
191+ throw ResponseStatusException (HttpStatus .INTERNAL_SERVER_ERROR , " Published example is missing required start or end time." )
192+ }
193+
187194 emitterService.sendPayload(EmitterType .STUDENT , course, " redirect" , " /courses/$course /examples/$example " )
188195 emitterService.sendPayload(
189196 EmitterType .EVERYONE ,
190197 course,
191198 " timer-update" ,
192- " ${updatedExample. start} /${updatedExample. end} "
199+ " ${start} /${end} "
193200 )
201+
202+ return ExamplePublicationDTO (start, end)
194203 }
195204
196205 // Invoked by the teacher when want to extend the time of an active example by a certain amount of seconds
0 commit comments