Skip to content
Snippets Groups Projects
Commit aaf3db96 authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

Fix migration and handling of of Room Settings

parent a8f6f444
Branches
No related merge requests found
......@@ -164,10 +164,11 @@ public class FromV2Migrator {
public de.thm.arsnova.entities.Room.Settings migrate(final RoomFeature feature) {
de.thm.arsnova.entities.Room.Settings settings = new de.thm.arsnova.entities.Room.Settings();
if (feature != null) {
settings.setCommentsEnabled(feature.isInterposed() || feature.isInterposedFeedback() || feature.isTotal());
settings.setCommentsEnabled(feature.isInterposed() || feature.isInterposedFeedback()
|| feature.isTwitterWall() || feature.isTotal());
settings.setQuestionsEnabled(feature.isLecture() || feature.isJitt() || feature.isClicker() || feature.isTotal());
settings.setSlidesEnabled(feature.isSlides() || feature.isTotal());
settings.setFlashcardsEnabled(feature.isFlashcard() || feature.isFlashcardFeature() || feature.isTotal());
settings.setFlashcardsEnabled(feature.isFlashcardFeature() || feature.isFlashcard() || feature.isTotal());
settings.setQuickSurveyEnabled(feature.isLiveClicker());
settings.setQuickFeedbackEnabled(feature.isFeedback() || feature.isLiveFeedback() || feature.isTotal());
settings.setMultipleRoundsEnabled(feature.isPi() || feature.isClicker() || feature.isTotal());
......
......@@ -81,6 +81,7 @@ public class ToV2Migrator {
to.setPpFaculty(from.getAuthor().getOrganizationUnit());
to.setPpLogo(from.getAuthor().getOrganizationLogo());
}
to.setFeatures(migrate(from.getSettings()));
return to;
}
......@@ -91,23 +92,30 @@ public class ToV2Migrator {
public RoomFeature migrate(final de.thm.arsnova.entities.Room.Settings settings) {
RoomFeature feature = new RoomFeature();
/* Features */
feature.setInterposed(settings.isCommentsEnabled());
feature.setLecture(settings.isQuestionsEnabled());
feature.setJitt(settings.isQuestionsEnabled());
feature.setSlides(settings.isSlidesEnabled());
feature.setFlashcard(settings.isFlashcardsEnabled());
feature.setFeedback(settings.isQuickSurveyEnabled());
feature.setFlashcardFeature(settings.isFlashcardsEnabled());
feature.setFeedback(settings.isQuickFeedbackEnabled());
feature.setPi(settings.isMultipleRoundsEnabled() || settings.isTimerEnabled());
feature.setLearningProgress(settings.isScoreEnabled());
/* Use cases */
int count = 0;
/* Single-feature use cases can be migrated */
if (settings.isCommentsEnabled()) {
feature.setTwitterWall(true);
feature.setInterposedFeedback(true);
count++;
}
if (settings.isFlashcardsEnabled()) {
feature.setFlashcardFeature(true);
feature.setFlashcard(true);
count++;
}
if (settings.isQuickFeedbackEnabled()) {
feature.setLiveFeedback(true);
count++;
}
if (settings.isQuickSurveyEnabled()) {
......@@ -134,8 +142,9 @@ public class ToV2Migrator {
if (count != 1) {
/* Reset single-feature use-cases since multiple features were detected */
feature.setTwitterWall(false);
feature.setFlashcardFeature(false);
feature.setInterposedFeedback(false);
feature.setFlashcard(false);
feature.setLiveFeedback(false);
feature.setLiveClicker(false);
if (count == 7) {
......
......@@ -30,7 +30,7 @@ import java.io.Serializable;
@ApiModel(value = "RoomFeature", description = "Room (Session) Feature entity - Represents feature/use case settings of a Room")
public class RoomFeature implements Serializable {
private boolean custom = true;
private boolean custom = false;
private boolean clicker = false;
private boolean peerGrading = false;
private boolean twitterWall = false;
......@@ -40,13 +40,13 @@ public class RoomFeature implements Serializable {
private boolean flashcard = false;
private boolean total = false;
private boolean jitt = true;
private boolean lecture = true;
private boolean feedback = true;
private boolean interposed = true;
private boolean pi = true;
private boolean learningProgress = true;
private boolean flashcardFeature = true;
private boolean jitt = false;
private boolean lecture = false;
private boolean feedback = false;
private boolean interposed = false;
private boolean pi = false;
private boolean learningProgress = false;
private boolean flashcardFeature = false;
private boolean slides = false;
public RoomFeature(RoomFeature features) {
......
......@@ -389,6 +389,8 @@ public class RoomServiceImpl extends DefaultEntityServiceImpl<Room> implements R
room.setOwnerId(existingRoom.getOwnerId());
handleLogo(room);
update(existingRoom, room);
/* TODO: only publish event when feedback has changed */
this.publisher.publishEvent(new FeatureChangeEvent(this, room));
return room;
}
......
......@@ -31,6 +31,7 @@ import com.corundumstudio.socketio.protocol.PacketType;
import de.thm.arsnova.entities.UserAuthentication;
import de.thm.arsnova.entities.Comment;
import de.thm.arsnova.entities.ScoreOptions;
import de.thm.arsnova.entities.migration.ToV2Migrator;
import de.thm.arsnova.events.*;
import de.thm.arsnova.exceptions.NoContentException;
import de.thm.arsnova.exceptions.NotFoundException;
......@@ -83,6 +84,9 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer, Arsnova
@Autowired
private CommentService commentService;
@Autowired
private ToV2Migrator toV2Migrator;
private static final Logger logger = LoggerFactory.getLogger(ArsnovaSocketioServerImpl.class);
private int portNumber;
......@@ -606,7 +610,7 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer, Arsnova
public void visit(FeatureChangeEvent event) {
final String roomId = event.getRoom().getId();
final de.thm.arsnova.entities.Room.Settings settings = event.getRoom().getSettings();
broadcastInRoom(roomId, "featureChange", settings);
broadcastInRoom(roomId, "featureChange", toV2Migrator.migrate(settings));
if (settings.isFlashcardsEnabled()) {
broadcastInRoom(roomId, "countFlashcards", contentService.countFlashcardsForUserInternal(roomId));
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment