From 00399b727d56b68c8ce022901048b5afdf6263c3 Mon Sep 17 00:00:00 2001
From: Paul-Christian Volkmer <github@pcvolkmer.de>
Date: Thu, 17 Sep 2015 19:48:35 +0200
Subject: [PATCH] Fixed NovaEvents to define non-serializable instance field
 question

NovaEvents is derived from ApplicationEvent which extends EventObject.
EventObject implements Serializable.

It is bad practice if defined instance fields within NovaEvents
derived classes do not implement Serializable.
---
 .../de/thm/arsnova/entities/Question.java     | 36 +++++++++++--------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/src/main/java/de/thm/arsnova/entities/Question.java b/src/main/java/de/thm/arsnova/entities/Question.java
index ce32f26e..9fa0a75e 100644
--- a/src/main/java/de/thm/arsnova/entities/Question.java
+++ b/src/main/java/de/thm/arsnova/entities/Question.java
@@ -17,8 +17,10 @@
  */
 package de.thm.arsnova.entities;
 
+import java.io.Serializable;
 import java.util.Date;
 import java.util.List;
+
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -26,7 +28,7 @@ import io.swagger.annotations.ApiModelProperty;
  * A question the teacher is asking.
  */
 @ApiModel(value = "lecturerquestion", description = "the Question API")
-public class Question {
+public class Question implements Serializable {
 
 	private String type;
 	private String questionType;
@@ -503,21 +505,21 @@ public class Question {
 
 	@ApiModelProperty(required = true, value = "used to display scale factor")
 	public String getScaleFactor() {
-		return this.scaleFactor;
+		return scaleFactor;
 	}
 
 	public void setGridScaleFactor(String scaleFactor) {
-		this.gridScaleFactor = scaleFactor;
+		gridScaleFactor = scaleFactor;
 	}
 
 	@ApiModelProperty(required = true, value = "used to display grid scale factor")
 	public String getGridScaleFactor() {
-		return this.gridScaleFactor;
+		return gridScaleFactor;
 	}
 
 	@ApiModelProperty(required = true, value = "enabled text nswer")
 	public boolean isTextAnswerEnabled() {
-		return this.textAnswerEnabled;
+		return textAnswerEnabled;
 	}
 
 	public void setTextAnswerEnabled(boolean textAnswerEnabled) {
@@ -566,8 +568,12 @@ public class Question {
 	@Override
 	public boolean equals(Object obj) {
 		// auto generated!
-		if (this == obj) return true;
-		if (obj == null) return false;
+		if (this == obj) {
+			return true;
+		}
+		if (obj == null) {
+			return false;
+		}
 		if (getClass() != obj.getClass()) {
 			return false;
 		}
@@ -585,9 +591,9 @@ public class Question {
 	public int calculateValue(Answer answer) {
 		if (answer.isAbstention()) {
 			return 0;
-		} else if (this.questionType.equals("mc")) {
+		} else if (questionType.equals("mc")) {
 			return calculateMultipleChoiceValue(answer);
-		} else if (this.questionType.equals("grid")) {
+		} else if (questionType.equals("grid")) {
 			return calculateGridValue(answer);
 		} else {
 			return calculateRegularValue(answer);
@@ -641,7 +647,7 @@ public class Question {
 
 	private int calculateRegularValue(Answer answer) {
 		String answerText = answer.getAnswerText();
-		for (PossibleAnswer p : this.possibleAnswers) {
+		for (PossibleAnswer p : possibleAnswers) {
 			if (answerText.equals(p.getText())) {
 				return p.getValue();
 			}
@@ -652,9 +658,9 @@ public class Question {
 	private int calculateGridValue(Answer answer) {
 		int value = 0;
 		String[] answers = answer.getAnswerText().split(",");
-		for (int i = 0; i < answers.length; i++) {
-			for (PossibleAnswer p : this.possibleAnswers) {
-				if (answers[i].equals(p.getText())) {
+		for (String answer2 : answers) {
+			for (PossibleAnswer p : possibleAnswers) {
+				if (answer2.equals(p.getText())) {
 					value += p.getValue();
 				}
 			}
@@ -665,9 +671,9 @@ public class Question {
 	private int calculateMultipleChoiceValue(Answer answer) {
 		int value = 0;
 		String[] answers = answer.getAnswerText().split(",");
-		for (int i = 0; i < this.possibleAnswers.size() && i < answers.length; i++) {
+		for (int i = 0; i < possibleAnswers.size() && i < answers.length; i++) {
 			if (answers[i].equals("1")) {
-				PossibleAnswer p = this.possibleAnswers.get(i);
+				PossibleAnswer p = possibleAnswers.get(i);
 				value += p.getValue();
 			}
 		}
-- 
GitLab