From 38e08774de7081afb19ee623873ba1126e1ef438 Mon Sep 17 00:00:00 2001
From: tekay <tom.kaesler@mni.thm.de>
Date: Thu, 7 Apr 2016 14:45:58 +0200
Subject: [PATCH] add bulk save method for questions (for importing via csv)

---
 .../controller/LecturerQuestionController.java    | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/main/java/de/thm/arsnova/controller/LecturerQuestionController.java b/src/main/java/de/thm/arsnova/controller/LecturerQuestionController.java
index aa0fad0a..1e50661e 100644
--- a/src/main/java/de/thm/arsnova/controller/LecturerQuestionController.java
+++ b/src/main/java/de/thm/arsnova/controller/LecturerQuestionController.java
@@ -90,6 +90,21 @@ public class LecturerQuestionController extends PaginationController {
 		throw new BadRequestException();
 	}
 
+	@ApiOperation(value = "Post provided questions", nickname = "bulkPostQuestions")
+	@ApiResponses(value = {
+		@ApiResponse(code = 400, message = HTML_STATUS_400)
+	})
+	@RequestMapping(value = "/bulk", method = RequestMethod.POST)
+	@ResponseStatus(HttpStatus.CREATED)
+	public List<Question> bulkPostQuestions(@RequestBody final List<Question> questions) {
+		for (final Question question : questions) {
+			if (questionService.saveQuestion(question) == null) {
+				throw new BadRequestException();
+			}
+		}
+		return questions;
+	}
+
 	@ApiOperation(value = "Update the question, identified by provided id, with the provided question in the Request Body",
 			nickname = "updateQuestion")
 	@ApiResponses(value = {
-- 
GitLab