Skip to content
Snippets Groups Projects
Commit 71baf563 authored by wiepke's avatar wiepke
Browse files

Merge remote-tracking branch 'gitup/groupfinding_module' into development_master

# Conflicts:
#	gemeinsamforschen/src/main/java/unipotsdam/gf/process/GroupFormationProcess.java
#	gemeinsamforschen/src/main/webapp/groupfinding/create-groups-manual.jsp
#	gemeinsamforschen/src/main/webapp/groupfinding/css/edit-groups.css
#	gemeinsamforschen/src/main/webapp/groupfinding/edit-groups.jsp
#	gemeinsamforschen/src/main/webapp/groupfinding/js/create-groups-manual.js
#	gemeinsamforschen/src/main/webapp/groupfinding/js/edit-groups.js
parents eb211308 f44062da
No related branches found
No related tags found
No related merge requests found
Showing
with 300 additions and 149 deletions
package unipotsdam.gf.config;
public interface Constants {
String ROCKET_CHAT_URL = "http://rocketchat.westeurope.cloudapp.azure.com";
}
......@@ -6,14 +6,11 @@ import unipotsdam.gf.modules.annotation.controller.AnnotationController;
import unipotsdam.gf.modules.annotation.controller.FeedbackImpl;
import unipotsdam.gf.modules.assessment.controller.service.AssessmentDBCommunication;
import unipotsdam.gf.modules.assessment.controller.service.PeerAssessment;
import unipotsdam.gf.modules.communication.service.CommunicationDummyService;
import unipotsdam.gf.modules.group.DummyProjectCreationService;
import unipotsdam.gf.modules.communication.service.CommunicationService;
import unipotsdam.gf.modules.communication.service.UnirestService;
import unipotsdam.gf.modules.group.GroupDAO;
import unipotsdam.gf.modules.group.GroupfindingImpl;
import unipotsdam.gf.modules.journal.service.IJournalImpl;
import unipotsdam.gf.modules.journal.service.JournalService;
import unipotsdam.gf.modules.journal.service.JournalServiceImpl;
import unipotsdam.gf.modules.journal.util.JournalUtils;
import unipotsdam.gf.modules.project.Management;
import unipotsdam.gf.modules.project.ManagementImpl;
import unipotsdam.gf.modules.project.ProjectConfigurationDAO;
......@@ -35,18 +32,17 @@ import unipotsdam.gf.session.GFContexts;
public class GFApplicationBinder extends AbstractBinder {
/**
* TODO replace DummyImplementation
*/
@Override
protected void configure() {
bind(CommunicationDummyService.class).to(ICommunication.class);
bind(CommunicationService.class).to(ICommunication.class);
bind(ManagementImpl.class).to(Management.class);
bind(PeerAssessment.class).to(IPeerAssessment.class);
bind(PhasesImpl.class).to(IPhases.class);
bind(GFContext.class).to(GFContext.class);
bind(JournalUtils.class).to(JournalUtils.class);
bind(JournalServiceImpl.class).to(JournalService.class);
bind(ManagementImpl.class).to(Management.class);
bind(FeedbackImpl.class).to(Feedback.class);
bind(DummyResearchReportManagement.class).to(ResearchReportManagement.class);
bind(IJournalImpl.class).to(IJournal.class);
bind(GroupfindingImpl.class).to(IGroupFinding.class);
......@@ -59,16 +55,20 @@ public class GFApplicationBinder extends AbstractBinder {
bind(SubmissionController.class).to(SubmissionController.class);
bind(AnnotationController.class).to(AnnotationController.class);
bind(ProjectConfigurationDAO.class).to(ProjectConfigurationDAO.class);
bind(DummyProjectCreationService.class).to(DummyProjectCreationService.class);
bind(UserDAO.class).to(UserDAO.class);
bind(ProjectDAO.class).to(ProjectDAO.class);
bind(GroupDAO.class).to(GroupDAO.class);
bind(TaskDAO.class).to(TaskDAO.class);
bind(FeedbackImpl.class).to(Feedback.class);
bind(UnirestService.class).to(UnirestService.class);
bindMore();
}
protected void bindMore() {
bind(MysqlConnectImpl.class).to(MysqlConnect.class);
bind(MysqlConnect.class).to(MysqlConnect.class);
bind(GroupfindingImpl.class).to(IGroupFinding.class);
bind(UnirestService.class).to(UnirestService.class);
}
}
......@@ -10,4 +10,5 @@ public class GFDatabaseConfig {
public static final String USER = "root";
public static final String PASS = "";
public static final String DB_NAME = "fltrail";
public static final String TEST_DB_NAME = "fltrail_test";
}
package unipotsdam.gf.config;
public class GFMailConfig {
public final static String SMTP_HOST = "";
public final static String SMTP_PORT = "";
public final static String SMTP_USERNAME = "";
public final static String SMTP_PASSWORD = "";
}
package unipotsdam.gf.config;
import unipotsdam.gf.modules.communication.model.RocketChatUser;
import unipotsdam.gf.modules.user.User;
/**
* ROCKET CHAT NEEDS TO KNOW THE ENDPOINT FOR THE SSO CONFIGURE LIKE IN README
*
* 1. FOR API URL: http://141.89.53.195:8080/gemeinsamforschen/rest/chat/sso
* localhost:8080/gemeinsamforschen/rest/chat/sso
*
* 1. FOR IFRAME URL: http://141.89.53.195:8080/gemeinsamforschen/rest/chat/login
* localhost:8080/gemeinsamforschen/rest/chat/login
*/
public class GFRocketChatConfig {
public static final String ROCKET_CHAT_LINK = "https://rocket.farm.uni-potsdam.de/";
public static final String ADMIN_USERNAME = "";
public static final String ADMIN_PASSWORD = "";
//private static final String ROCKET_CHAT_LINK = "http://rocketchat.westeurope.cloudapp.azure.com/";
// public static final String ROCKET_CHAT_LINK_0 = "https://rocket.farm-test.rz.uni-potsdam.de";
// public static final String ROCKET_CHAT_LINK = "https://rocket.farm-test.rz.uni-potsdam.de/";
public static final String ROCKET_CHAT_LINK_0 = "http://fleckenroller.cs.uni-potsdam.de:3000";
public static final String ROCKET_CHAT_LINK = "http://fleckenroller.cs.uni-potsdam.de:3000/";
/**
* username: fltrailadmin pw: GEbCM1Rso6TUGGMKtGmg6c5EydMQEu61K9zdD10F
*/
public static final String ROCKET_CHAT_ROOM_LINK = ROCKET_CHAT_LINK + "group/";
public static final String ROCKET_CHAT_API_LINK = ROCKET_CHAT_LINK + "api/v1/";
public static final RocketChatUser TEST_USER = new RocketChatUser("student1", "egal",
"student1@yolo.com", "student1", "",
"", "6ofqfp8J9ynfvspBJ", false);
/* public static final User ADMIN_USER = new User("admin nachname", "passwort",
"email", "rocketChatUsername", "rocketChatAuthToken",
"rocketChatPersonalAccessToken", "rocketChatUserId", false);*/
public static final RocketChatUser ADMIN_USER = new RocketChatUser("fltrailadmin", "GEbCM1Rso6TUGGMKtGmg6c5EydMQEu61K9zdD10F",
"julian.dehne@uni-potsdam.de", "rocketChatUsername", "rocketChatAuthToken",
"rocketChatPersonalAccessToken", "SuFbpF3P9aYEo634W", false);
/**
* curl -H "Content-type:application/json" \
* https://rocket.farm-test.rz.uni-potsdam.de/api/v1/login \
* -d '{ "user": "test@stuff.com", "password": "passwort" }'
* um
*/
}
package unipotsdam.gf.exceptions;
public class MysqlDownException {
}
package unipotsdam.gf.exceptions;
public class RocketChatDownException extends Exception {
}
package unipotsdam.gf.exceptions;
public class UserDoesNotExistInMysqlException extends Exception {
}
package unipotsdam.gf.exceptions;
public class UserDoesNotExistInRocketChatException extends Exception {
}
package unipotsdam.gf.exceptions;
public class UserExistsInMysqlException extends Exception {
@Override
public String getMessage() {
return "Tried to create User but exists in mysql";
}
}
package unipotsdam.gf.exceptions;
public class UserExistsInRocketChatException extends Exception {
@Override
public String getMessage() {
return "Tried to create User but exists in RocketChat";
}
}
package unipotsdam.gf.interfaces;
import unipotsdam.gf.exceptions.RocketChatDownException;
import unipotsdam.gf.exceptions.UserDoesNotExistInRocketChatException;
import unipotsdam.gf.exceptions.UserExistsInRocketChatException;
import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier;
import unipotsdam.gf.modules.communication.model.EMailMessage;
import unipotsdam.gf.modules.communication.model.RocketChatUser;
import unipotsdam.gf.modules.communication.model.chat.ChatMessage;
import unipotsdam.gf.modules.group.Group;
import unipotsdam.gf.modules.project.Project;
import unipotsdam.gf.modules.user.User;
import unipotsdam.gf.process.constraints.ConstraintsMessages;
import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier;
import unipotsdam.gf.modules.communication.model.Message;
import unipotsdam.gf.modules.communication.model.chat.ChatMessage;
import unipotsdam.gf.modules.communication.model.chat.ChatRoom;
import java.util.List;
import java.util.Map;
......@@ -23,21 +28,39 @@ public interface ICommunication {
* @param roomId ID of room of user
* @return List of Chat Messages
*/
@Deprecated
List<ChatMessage> getChatHistory(String roomId);
boolean sendMessageToChat(Message message, String roomId) ;
@Deprecated
boolean sendMessageToChat(EMailMessage EMailMessage, String roomId);
/**
* endpoint: https://rocket.chat/docs/developer-guides/rest-api/groups/create/
* creates chatroom
*
* @param name chat room name
* @param userList member of chat by id
* @param name chat room name
* @return chat room id
*/
String createChatRoom(String name, List<User> userList);
String createChatRoom(String name, boolean readOnly, List<User> users)
throws RocketChatDownException, UserDoesNotExistInRocketChatException;
/**
* creates chatRoom with name "group.projectId - group.id" and set chatRoomId for group
*
* @param group Object for information
* @return true if chatRoom was created, otherwise false
*/
boolean createChatRoom(Group group, boolean readOnly)
throws RocketChatDownException, UserDoesNotExistInRocketChatException;
String createEmptyChatRoom(String name, boolean readOnly)
throws RocketChatDownException, UserDoesNotExistInRocketChatException;
void deleteChatRoom(Group group) throws RocketChatDownException, UserDoesNotExistInRocketChatException;
void deleteChatRoom(Project project) throws RocketChatDownException, UserDoesNotExistInRocketChatException;
boolean deleteChatRoom(String roomId) throws RocketChatDownException, UserDoesNotExistInRocketChatException;
/**
* endpoint: https://rocket.chat/docs/developer-guides/rest-api/groups/invite/
......@@ -46,9 +69,11 @@ public interface ICommunication {
* @param user information about user
* @return if user was added successfully
*/
boolean addUserToChatRoom(String roomId, User user);
boolean addUserToChatRoom(User user, String roomId)
throws RocketChatDownException, UserDoesNotExistInRocketChatException;
boolean removeUserFromChatRoom(User user, String roomId) ;
boolean removeUserFromChatRoom(User user, String roomId)
throws RocketChatDownException, UserDoesNotExistInRocketChatException;
/**
* endpoint: https://rocket.chat/docs/developer-guides/rest-api/groups/settopic/
......@@ -57,6 +82,7 @@ public interface ICommunication {
* @param topic topic of chat room
* @return true, if topic was set correctly
*/
@Deprecated
boolean setChatRoomTopic(String roomId, String topic);
......@@ -67,7 +93,9 @@ public interface ICommunication {
* @param roomId chat room id
* @return chat room information
*/
ChatRoom getChatRoomInfo(String roomId);
String getChatRoomName(String roomId) throws RocketChatDownException, UserDoesNotExistInRocketChatException;
boolean exists(String roomId) throws RocketChatDownException, UserDoesNotExistInRocketChatException;
/**
* api: https://rocket.chat/docs/developer-guides/rest-api/authentication/login/
......@@ -75,26 +103,36 @@ public interface ICommunication {
* @param user username and password
* @return information about user, especially authtoken for later use of endpoints
*/
boolean loginUser(User user);
RocketChatUser loginUser(User user)
throws RocketChatDownException, UserDoesNotExistInRocketChatException;
/**
* api 1: https://rocket.chat/docs/developer-guides/rest-api/users/register/
* api 2: https://rocket.chat/docs/developer-guides/rest-api/users/generatepersonalaccesstoken/
* api 3: https://rocket.chat/docs/developer-guides/rest-api/users/getpersonalaccesstokens/
*
* registers new user to rocket chat
*
* @param user registers user to rocket.chat
* @return user id
*/
boolean registerUser(User user);
boolean registerUser(User user)
throws RocketChatDownException, UserExistsInRocketChatException;
boolean registerAndLoginUser(User user);
String getChatRoomLink(String userEmail, String projectId)
throws RocketChatDownException, UserDoesNotExistInRocketChatException;
String getChatRoomLink(String userEmail, String projectToken, String groupToken);
String getProjectChatRoomLink(String projectName);
// TODO implement as Email or whatever
void sendSingleMessage(Message message, User user);
boolean sendSingleMessage(EMailMessage EMailMessage, User user);
//added by Axel.
void informAboutMissingTasks(Map<StudentIdentifier, ConstraintsMessages> tasks, Project project);
boolean informAboutMissingTasks(Map<StudentIdentifier, ConstraintsMessages> tasks, Project project);
boolean sendMessageToUsers(Project project, EMailMessage eMailMessage);
public void delete(User user) throws RocketChatDownException, UserDoesNotExistInRocketChatException;
// TODO implement as Email or whatever
void sendMessageToUsers(Project project, String message);
}
package unipotsdam.gf.interfaces;
import unipotsdam.gf.exceptions.RocketChatDownException;
import unipotsdam.gf.exceptions.UserDoesNotExistInRocketChatException;
import unipotsdam.gf.modules.group.Group;
import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier;
import unipotsdam.gf.modules.project.Project;
......@@ -7,6 +9,7 @@ import unipotsdam.gf.modules.group.GroupFormationMechanism;
import unipotsdam.gf.modules.group.GroupfindingCriteria;
import java.util.ArrayList;
import java.util.List;
public interface IGroupFinding {
......@@ -18,6 +21,8 @@ public interface IGroupFinding {
void selectGroupfindingCriteria(
GroupfindingCriteria groupfindingCriteria, Project project);
GroupFormationMechanism getGFM(Project project);
/**
* Persist the selected manual groups
* @param groupComposition
......@@ -45,4 +50,13 @@ public interface IGroupFinding {
ArrayList<String> getStudentsInSameGroup(StudentIdentifier student);
int getMinNumberOfStudentsNeeded(Project project);
void deleteGroups(Project project);
List<Group> createRandomGroups(Project project);
/**
* finish the groups in the db
*/
void finalizeGroups(Project project) throws RocketChatDownException, UserDoesNotExistInRocketChatException;
}
package unipotsdam.gf.modules.communication;
import unipotsdam.gf.interfaces.ICommunication;
import unipotsdam.gf.modules.communication.service.CommunicationDummyService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;
public class ChatWindow extends SimpleTagSupport {
private String orientation;
public void doTag() throws IOException {
PageContext pageContext = (PageContext) getJspContext();
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
String token = request.getParameter("token");
//User user = management.getUserByEmail(token);
String groupToken = request.getParameter("groupToken");
String projectToken = request.getParameter("projectName");
//get ProjetbyToken
ICommunication communicationService = new CommunicationDummyService();
String chatRoomLink = communicationService.getChatRoomLink(token, projectToken, groupToken);
JspWriter out = getJspContext().getOut();
out.println("<iframe width=\"30%\" height=\"100%\" src=\"" + chatRoomLink + "\"/>");
}
public void setOrientation(String orientation) {
this.orientation = orientation;
}
public String getOrientation() {
return orientation;
}
}
package unipotsdam.gf.modules.communication;
import unipotsdam.gf.modules.communication.model.EMailMessage;
import unipotsdam.gf.modules.project.Project;
public class Messages {
public static String GroupFormation(Project project){
public static EMailMessage GroupFormation(Project project) {
// TODO add link to site + markup
return "Die Gruppen wurden für den Kurs "+ project.getName() + " erstellt";
EMailMessage eMailMessage = new EMailMessage();
eMailMessage.setSubject(project.getName() + ": Gruppenerstellung abgeschlossen");
eMailMessage.setBody("Die Gruppen wurden für den Kurs " + project.getName() + " erstellt");
return eMailMessage;
}
public static String NewFeedbackTask(Project project) {
public static EMailMessage NewFeedbackTask(Project project) {
// TODO add link to site + markup
return "Eine neue Feedbackaufgabe wurde für den Kurs "+ project.getName() + " erstellt";
EMailMessage eMailMessage = new EMailMessage();
eMailMessage.setSubject(project.getName() + ": Feedbackaufgabe erstellt");
eMailMessage.setBody("Eine neue Feedbackaufgabe wurde für den Kurs " + project.getName() + " erstellt");
return eMailMessage;
}
public static String AssessmentPhaseStarted(Project project) {
public static EMailMessage AssessmentPhaseStarted(Project project) {
// TODO add link to site + markup
return "Die Bewertungsphase hat begonnen. Bitte geht auf ... und macht ....";
EMailMessage eMailMessage = new EMailMessage();
eMailMessage.setSubject(project.getName() + ": Beginn der Bewertungsphase");
eMailMessage.setBody("Die Bewertungsphase hat begonnen. Bitte geht auf ... und macht ....");
return eMailMessage;
}
public static String CourseEnds(Project project) {
public static EMailMessage CourseEnds(Project project) {
// TODO add link to site + markup
return "Die Bewertung ist abgeschlossen. Sie erhalten ihre Bewertung in Kürze.";
EMailMessage eMailMessage = new EMailMessage();
eMailMessage.setSubject(project.getName() + ": Bewertungsphase abgeschlossen");
eMailMessage.setBody("Die Bewertung ist abgeschlossen. Sie erhalten ihre Bewertung in Kürze.");
return eMailMessage;
}
}
package unipotsdam.gf.modules.communication.model;
public class EMailMessage {
private String subject;
private String body;
public EMailMessage() {
}
public EMailMessage(String subject, String body) {
this.subject = subject;
this.body = body;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
}
package unipotsdam.gf.modules.communication.model;
public class LoginToken {
private String loginToken;
public LoginToken(String loginToken) {
this.loginToken = loginToken;
}
public LoginToken( ) {
}
public String getLoginToken() {
return loginToken;
}
public void setLoginToken(String loginToken) {
this.loginToken = loginToken;
}
}
package unipotsdam.gf.modules.communication.model;
public class Message {
private String roomIdOrChannel;
private String message;
public Message() {}
public Message(String roomIdOrChannel, String message) {
this.roomIdOrChannel = roomIdOrChannel;
this.message = message;
}
public String getRoomIdOrChannel() {
return roomIdOrChannel;
}
public void setRoomIdOrChannel(String roomIdOrChannel) {
this.roomIdOrChannel = roomIdOrChannel;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@Override
public String toString() {
return "Message{" +
"roomIdOrChannel='" + roomIdOrChannel + '\'' +
", message='" + message + '\'' +
'}';
}
}
package unipotsdam.gf.modules.communication.model;
import unipotsdam.gf.modules.user.User;
public class RocketChatUser extends User {
private String rocketChatAuthToken;
// not in this version
private String rocketChatPersonalAccessToken;
// the actual id that oculd be used instead of the email with the queries
private String rocketChatUserId;
public RocketChatUser(String name, String password, String email, String rocketChatUsername,
String rocketChatAuthToken, String rocketChatPersonalAccessToken, String rocketChatUserId,
Boolean isStudent) {
super(name, password,email,rocketChatUsername, isStudent);
this.rocketChatAuthToken = rocketChatAuthToken;
this.rocketChatPersonalAccessToken = rocketChatPersonalAccessToken;
this.rocketChatUserId = rocketChatUserId;
}
public RocketChatUser() {
}
public String getRocketChatUserId() {
return rocketChatUserId;
}
public void setRocketChatUserId(String rocketChatUserId) {
this.rocketChatUserId = rocketChatUserId;
}
public String getRocketChatAuthToken() {
return rocketChatAuthToken;
}
public void setRocketChatAuthToken(String rocketChatAuthToken) {
this.rocketChatAuthToken = rocketChatAuthToken;
}
public String getRocketChatPersonalAccessToken() {
return rocketChatPersonalAccessToken;
}
public void setRocketChatPersonalAccessToken(String rocketChatPersonalAccessToken) {
this.rocketChatPersonalAccessToken = rocketChatPersonalAccessToken;
}
}
package unipotsdam.gf.modules.communication.model;
public class SampleAnswer {
private String answer;
public SampleAnswer() {
}
public String getAnswer() {
return answer;
}
public void setAnswer(String answer) {
this.answer = answer;
}
@Override
public String toString() {
return "SampleAnswer{" +
"answer='" + answer + '\'' +
'}';
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment