Skip to content
Snippets Groups Projects

Refac export

Merged Tom Käsler requested to merge Refac-Export/arsnova-backend:refac_export into master
Compare and
+ 272
8
Compare changes
  • Side-by-side
  • Inline
Files
@@ -17,6 +17,7 @@
@@ -17,6 +17,7 @@
*/
*/
package de.thm.arsnova.controller;
package de.thm.arsnova.controller;
 
import org.springframework.context.annotation.Import;
import de.thm.arsnova.connector.model.Course;
import de.thm.arsnova.connector.model.Course;
import de.thm.arsnova.entities.Session;
import de.thm.arsnova.entities.Session;
import de.thm.arsnova.entities.SessionFeature;
import de.thm.arsnova.entities.SessionFeature;
@@ -268,6 +269,40 @@ public class SessionController extends PaginationController {
@@ -268,6 +269,40 @@ public class SessionController extends PaginationController {
return sessionService.importSession(session);
return sessionService.importSession(session);
}
}
 
@ApiOperation(value = "export sessions", nickname = "exportSession")
 
@RequestMapping(value = "/export", method = RequestMethod.GET)
 
public List<ImportExportSession> exportSession(
 
@ApiParam(value = "sessionkey", required = true) @RequestParam(value = "sessionkey", defaultValue = "") final List<String> sessionkey,
 
@ApiParam(value = "wether statistics shall be exported", required = true) @RequestParam(value = "withAnswerStatistics", defaultValue = "false") final Boolean withAnswerStatistics,
 
@ApiParam(value = "wether interposed questions shall be exported", required = true) @RequestParam(value = "withFeedbackQuestions", defaultValue = "false") final Boolean withFeedbackQuestions,
 
@ApiParam(value = "http servlet response", required = true) final HttpServletResponse response
 
) {
 
List<ImportExportSession> sessions = new ArrayList<ImportExportSession>();
 
ImportExportSession temp;
 
for (String key : sessionkey) {
 
sessionService.setActive(key, false);
 
temp = sessionService.exportSession(key, withAnswerStatistics, withFeedbackQuestions);
 
if (temp != null) {
 
sessions.add(temp);
 
}
 
sessionService.setActive(key, true);
 
}
 
return sessions;
 
}
 
 
@ApiOperation(value = "copy a session to the public pool if enabled")
 
@RequestMapping(value = "/{sessionkey}/copytopublicpool", method = RequestMethod.POST)
 
public SessionInfo copyToPublicPool(
 
@ApiParam(value = "session-key from current session", required = true) @PathVariable final String sessionkey,
 
@ApiParam(value = "public pool attributes for session", required = true) @RequestBody final de.thm.arsnova.entities.transport.ImportExportSession.PublicPool publicPool
 
) {
 
sessionService.setActive(sessionkey, false);
 
SessionInfo sessionInfo = sessionService.copySessionToPublicPool(sessionkey, publicPool);
 
sessionService.setActive(sessionkey, true);
 
return sessionInfo;
 
}
 
 
@ApiOperation(value = "Locks or unlocks a Session",
@ApiOperation(value = "Locks or unlocks a Session",
nickname = "lockSession")
nickname = "lockSession")
@ApiResponses(value = {
@ApiResponses(value = {