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
Branches
Tags
No related merge requests found
......@@ -235,7 +235,7 @@ public class SessionController extends AbstractController {
public LearningProgressValues learningProgress(
@PathVariable final String sessionkey,
@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
) {
return sessionService.getLearningProgress(sessionkey, progressType, questionVariant);
......@@ -245,7 +245,7 @@ public class SessionController extends AbstractController {
public LearningProgressValues myLearningProgress(
@PathVariable final String sessionkey,
@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
) {
return sessionService.getMyLearningProgress(sessionkey, progressType, questionVariant);
......
......@@ -438,7 +438,7 @@ public class CouchDBDao implements IDatabaseDao, ApplicationEventPublisherAware
sessionDocument.put("courseType", session.getCourseType());
sessionDocument.put("courseId", session.getCourseId());
sessionDocument.put("creationTime", session.getCreationTime());
sessionDocument.put("learningProgressType", session.getLearningProgressType());
sessionDocument.put("learningProgressOptions", JSONObject.fromObject(session.getLearningProgressOptions()));
sessionDocument.put("ppAuthorName", session.getPpAuthorName());
sessionDocument.put("ppAuthorMail", session.getPpAuthorMail());
sessionDocument.put("ppUniversity", session.getPpUniversity());
......@@ -1411,7 +1411,7 @@ public class CouchDBDao implements IDatabaseDao, ApplicationEventPublisherAware
s.put("name", session.getName());
s.put("shortName", session.getShortName());
s.put("active", session.isActive());
s.put("learningProgressType", session.getLearningProgressType());
s.put("learningProgressOptions", JSONObject.fromObject(session.getLearningProgressOptions()));
s.put("features", JSONObject.fromObject(session.getFeatures()));
database.saveDocument(s);
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;
public class Session implements Serializable {
private static final long serialVersionUID = 1L;
private String type;
private String name;
private String shortName;
......@@ -37,7 +37,7 @@ public class Session implements Serializable {
private String courseId;
private List<String> _conflicts;
private long creationTime;
private String learningProgressType = "questions";
private LearningProgressOptions learningProgressOptions;
private SessionFeature features;
private String ppAuthorName;
......@@ -71,7 +71,7 @@ public class Session implements Serializable {
copy.courseType = original.courseType;
copy.courseId = original.courseId;
copy.creationTime = original.creationTime;
copy.learningProgressType = original.learningProgressType;
copy.learningProgressOptions = new LearningProgressOptions(original.learningProgressOptions);
copy.features = new SessionFeature(original.features);
// public pool
copy.ppAuthorName = original.ppAuthorName;
......@@ -203,12 +203,12 @@ public class Session implements Serializable {
this.creationTime = creationTime;
}
public String getLearningProgressType() {
return learningProgressType;
public LearningProgressOptions getLearningProgressOptions() {
return learningProgressOptions;
}
public void setLearningProgressType(String learningProgressType) {
this.learningProgressType = learningProgressType;
public void setLearningProgressOptions(LearningProgressOptions learningProgressOptions) {
this.learningProgressOptions = learningProgressOptions;
}
public SessionFeature getFeatures() {
......
......@@ -17,11 +17,13 @@
*/
package de.thm.arsnova.entities.transport;
public class LearningProgressType {
public class LearningProgressOptions {
private String sessionKeyword;
private String learningProgressType;
private String type;
private String questionVariant;
public String getSessionKeyword() {
return sessionKeyword;
......@@ -31,11 +33,26 @@ public class LearningProgressType {
this.sessionKeyword = sessionKeyword;
}
public String getLearningProgressType() {
return learningProgressType;
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;
}
public void setLearningProgressType(String learningProgressType) {
this.learningProgressType = learningProgressType;
public de.thm.arsnova.entities.LearningProgressOptions toEntity() {
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;
import de.thm.arsnova.entities.InterposedQuestion;
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.DeleteAllLectureAnswersEvent;
import de.thm.arsnova.events.DeleteAllPreparationAnswersEvent;
......@@ -200,17 +200,17 @@ public class ARSnovaSocketIOServer implements ARSnovaSocket, NovaEventVisitor {
});
server.addEventListener(
"setLearningProgressType",
LearningProgressType.class,
new DataListener<LearningProgressType>() {
"setLearningProgressOptions",
LearningProgressOptions.class,
new DataListener<LearningProgressOptions>() {
@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 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)) {
session.setLearningProgressType(progressType.getLearningProgressType());
session.setLearningProgressOptions(progressOptions.toEntity());
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 {
client.sendEvent("countLectureQuestionAnswers", questionService.countLectureQuestionAnswersInternal(sessionKey));
client.sendEvent("countPreparationQuestionAnswers", questionService.countPreparationQuestionAnswersInternal(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);
client.sendEvent("feedbackData", fb.getValues());
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