Skip to content
Snippets Groups Projects
Commit d9f82c7d authored by Christoph Thelen's avatar Christoph Thelen
Browse files

Fix for #15617: Store learning progress options in Session

parent 35f0685d
No related merge requests found
...@@ -235,7 +235,7 @@ public class SessionController extends AbstractController { ...@@ -235,7 +235,7 @@ public class SessionController extends AbstractController {
public LearningProgressValues learningProgress( public LearningProgressValues learningProgress(
@PathVariable final String sessionkey, @PathVariable final String sessionkey,
@RequestParam(value = "type", defaultValue = "questions") final String progressType, @RequestParam(value = "type", defaultValue = "questions") final String progressType,
@RequestParam(value = "variant", required = false) final String questionVariant, @RequestParam(value = "questionVariant", required = false) final String questionVariant,
final HttpServletResponse response final HttpServletResponse response
) { ) {
return sessionService.getLearningProgress(sessionkey, progressType, questionVariant); return sessionService.getLearningProgress(sessionkey, progressType, questionVariant);
...@@ -245,7 +245,7 @@ public class SessionController extends AbstractController { ...@@ -245,7 +245,7 @@ public class SessionController extends AbstractController {
public LearningProgressValues myLearningProgress( public LearningProgressValues myLearningProgress(
@PathVariable final String sessionkey, @PathVariable final String sessionkey,
@RequestParam(value = "type", defaultValue = "questions") final String progressType, @RequestParam(value = "type", defaultValue = "questions") final String progressType,
@RequestParam(value = "variant", required = false) final String questionVariant, @RequestParam(value = "questionVariant", required = false) final String questionVariant,
final HttpServletResponse response final HttpServletResponse response
) { ) {
return sessionService.getMyLearningProgress(sessionkey, progressType, questionVariant); return sessionService.getMyLearningProgress(sessionkey, progressType, questionVariant);
......
...@@ -438,7 +438,7 @@ public class CouchDBDao implements IDatabaseDao, ApplicationEventPublisherAware ...@@ -438,7 +438,7 @@ public class CouchDBDao implements IDatabaseDao, ApplicationEventPublisherAware
sessionDocument.put("courseType", session.getCourseType()); sessionDocument.put("courseType", session.getCourseType());
sessionDocument.put("courseId", session.getCourseId()); sessionDocument.put("courseId", session.getCourseId());
sessionDocument.put("creationTime", session.getCreationTime()); sessionDocument.put("creationTime", session.getCreationTime());
sessionDocument.put("learningProgressType", session.getLearningProgressType()); sessionDocument.put("learningProgressOptions", JSONObject.fromObject(session.getLearningProgressOptions()));
sessionDocument.put("ppAuthorName", session.getPpAuthorName()); sessionDocument.put("ppAuthorName", session.getPpAuthorName());
sessionDocument.put("ppAuthorMail", session.getPpAuthorMail()); sessionDocument.put("ppAuthorMail", session.getPpAuthorMail());
sessionDocument.put("ppUniversity", session.getPpUniversity()); sessionDocument.put("ppUniversity", session.getPpUniversity());
...@@ -1411,7 +1411,7 @@ public class CouchDBDao implements IDatabaseDao, ApplicationEventPublisherAware ...@@ -1411,7 +1411,7 @@ public class CouchDBDao implements IDatabaseDao, ApplicationEventPublisherAware
s.put("name", session.getName()); s.put("name", session.getName());
s.put("shortName", session.getShortName()); s.put("shortName", session.getShortName());
s.put("active", session.isActive()); s.put("active", session.isActive());
s.put("learningProgressType", session.getLearningProgressType()); s.put("learningProgressOptions", JSONObject.fromObject(session.getLearningProgressOptions()));
s.put("features", JSONObject.fromObject(session.getFeatures())); s.put("features", JSONObject.fromObject(session.getFeatures()));
database.saveDocument(s); database.saveDocument(s);
session.set_rev(s.getRev()); session.set_rev(s.getRev());
......
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2015 The ARSnova Team
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ARSnova Backend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.entities;
public class LearningProgressOptions {
private String type;
private String questionVariant;
public LearningProgressOptions(LearningProgressOptions learningProgressOptions) {
this();
this.type = learningProgressOptions.getType();
this.questionVariant = learningProgressOptions.getQuestionVariant();
}
public LearningProgressOptions() {}
public String getType() {
return type;
}
public void setType(String learningProgressType) {
this.type = learningProgressType;
}
public String getQuestionVariant() {
return questionVariant;
}
public void setQuestionVariant(String questionVariant) {
this.questionVariant = questionVariant;
}
}
...@@ -25,7 +25,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; ...@@ -25,7 +25,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
public class Session implements Serializable { public class Session implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String type; private String type;
private String name; private String name;
private String shortName; private String shortName;
...@@ -37,7 +37,7 @@ public class Session implements Serializable { ...@@ -37,7 +37,7 @@ public class Session implements Serializable {
private String courseId; private String courseId;
private List<String> _conflicts; private List<String> _conflicts;
private long creationTime; private long creationTime;
private String learningProgressType = "questions"; private LearningProgressOptions learningProgressOptions;
private SessionFeature features; private SessionFeature features;
private String ppAuthorName; private String ppAuthorName;
...@@ -71,7 +71,7 @@ public class Session implements Serializable { ...@@ -71,7 +71,7 @@ public class Session implements Serializable {
copy.courseType = original.courseType; copy.courseType = original.courseType;
copy.courseId = original.courseId; copy.courseId = original.courseId;
copy.creationTime = original.creationTime; copy.creationTime = original.creationTime;
copy.learningProgressType = original.learningProgressType; copy.learningProgressOptions = new LearningProgressOptions(original.learningProgressOptions);
copy.features = new SessionFeature(original.features); copy.features = new SessionFeature(original.features);
// public pool // public pool
copy.ppAuthorName = original.ppAuthorName; copy.ppAuthorName = original.ppAuthorName;
...@@ -203,12 +203,12 @@ public class Session implements Serializable { ...@@ -203,12 +203,12 @@ public class Session implements Serializable {
this.creationTime = creationTime; this.creationTime = creationTime;
} }
public String getLearningProgressType() { public LearningProgressOptions getLearningProgressOptions() {
return learningProgressType; return learningProgressOptions;
} }
public void setLearningProgressType(String learningProgressType) { public void setLearningProgressOptions(LearningProgressOptions learningProgressOptions) {
this.learningProgressType = learningProgressType; this.learningProgressOptions = learningProgressOptions;
} }
public SessionFeature getFeatures() { public SessionFeature getFeatures() {
......
...@@ -17,11 +17,13 @@ ...@@ -17,11 +17,13 @@
*/ */
package de.thm.arsnova.entities.transport; package de.thm.arsnova.entities.transport;
public class LearningProgressType { public class LearningProgressOptions {
private String sessionKeyword; private String sessionKeyword;
private String learningProgressType; private String type;
private String questionVariant;
public String getSessionKeyword() { public String getSessionKeyword() {
return sessionKeyword; return sessionKeyword;
...@@ -31,11 +33,26 @@ public class LearningProgressType { ...@@ -31,11 +33,26 @@ public class LearningProgressType {
this.sessionKeyword = sessionKeyword; this.sessionKeyword = sessionKeyword;
} }
public String getLearningProgressType() { public String getType() {
return learningProgressType; return type;
}
public void setType(String learningProgressType) {
this.type = learningProgressType;
}
public String getQuestionVariant() {
return questionVariant;
}
public void setQuestionVariant(String questionVariant) {
this.questionVariant = questionVariant;
} }
public void setLearningProgressType(String learningProgressType) { public de.thm.arsnova.entities.LearningProgressOptions toEntity() {
this.learningProgressType = learningProgressType; de.thm.arsnova.entities.LearningProgressOptions entity = new de.thm.arsnova.entities.LearningProgressOptions();
entity.setType(this.getType());
entity.setQuestionVariant(this.getQuestionVariant());
return entity;
} }
} }
...@@ -48,7 +48,7 @@ import com.corundumstudio.socketio.protocol.PacketType; ...@@ -48,7 +48,7 @@ import com.corundumstudio.socketio.protocol.PacketType;
import de.thm.arsnova.entities.InterposedQuestion; import de.thm.arsnova.entities.InterposedQuestion;
import de.thm.arsnova.entities.User; import de.thm.arsnova.entities.User;
import de.thm.arsnova.entities.transport.LearningProgressType; import de.thm.arsnova.entities.transport.LearningProgressOptions;
import de.thm.arsnova.events.ChangeLearningProgress; import de.thm.arsnova.events.ChangeLearningProgress;
import de.thm.arsnova.events.DeleteAllLectureAnswersEvent; import de.thm.arsnova.events.DeleteAllLectureAnswersEvent;
import de.thm.arsnova.events.DeleteAllPreparationAnswersEvent; import de.thm.arsnova.events.DeleteAllPreparationAnswersEvent;
...@@ -200,17 +200,17 @@ public class ARSnovaSocketIOServer implements ARSnovaSocket, NovaEventVisitor { ...@@ -200,17 +200,17 @@ public class ARSnovaSocketIOServer implements ARSnovaSocket, NovaEventVisitor {
}); });
server.addEventListener( server.addEventListener(
"setLearningProgressType", "setLearningProgressOptions",
LearningProgressType.class, LearningProgressOptions.class,
new DataListener<LearningProgressType>() { new DataListener<LearningProgressOptions>() {
@Override @Override
public void onData(SocketIOClient client, LearningProgressType progressType, AckRequest ack) { public void onData(SocketIOClient client, LearningProgressOptions progressOptions, AckRequest ack) {
final User user = userService.getUser2SocketId(client.getSessionId()); final User user = userService.getUser2SocketId(client.getSessionId());
final de.thm.arsnova.entities.Session session = sessionService.getSessionInternal(progressType.getSessionKeyword(), user); final de.thm.arsnova.entities.Session session = sessionService.getSessionInternal(progressOptions.getSessionKeyword(), user);
if (session.isCreator(user)) { if (session.isCreator(user)) {
session.setLearningProgressType(progressType.getLearningProgressType()); session.setLearningProgressOptions(progressOptions.toEntity());
sessionService.updateSessionInternal(session, user); sessionService.updateSessionInternal(session, user);
broadcastInSession(session.getKeyword(), "learningProgressType", progressType.getLearningProgressType()); broadcastInSession(session.getKeyword(), "learningProgressOptions", progressOptions.toEntity());
} }
} }
}); });
...@@ -351,7 +351,7 @@ public class ARSnovaSocketIOServer implements ARSnovaSocket, NovaEventVisitor { ...@@ -351,7 +351,7 @@ public class ARSnovaSocketIOServer implements ARSnovaSocket, NovaEventVisitor {
client.sendEvent("countLectureQuestionAnswers", questionService.countLectureQuestionAnswersInternal(sessionKey)); client.sendEvent("countLectureQuestionAnswers", questionService.countLectureQuestionAnswersInternal(sessionKey));
client.sendEvent("countPreparationQuestionAnswers", questionService.countPreparationQuestionAnswersInternal(sessionKey)); client.sendEvent("countPreparationQuestionAnswers", questionService.countPreparationQuestionAnswersInternal(sessionKey));
client.sendEvent("activeUserCountData", sessionService.activeUsers(sessionKey)); client.sendEvent("activeUserCountData", sessionService.activeUsers(sessionKey));
client.sendEvent("learningProgressType", session.getLearningProgressType()); client.sendEvent("learningProgressOptions", session.getLearningProgressOptions());
final de.thm.arsnova.entities.Feedback fb = feedbackService.getFeedback(sessionKey); final de.thm.arsnova.entities.Feedback fb = feedbackService.getFeedback(sessionKey);
client.sendEvent("feedbackData", fb.getValues()); client.sendEvent("feedbackData", fb.getValues());
try { try {
......
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