Skip to content
Snippets Groups Projects
Commit 9e2a2367 authored by wiepke's avatar wiepke
Browse files

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

parents 9513894c c0eaa918
No related branches found
No related tags found
No related merge requests found
Showing with 62 additions and 10 deletions
package unipotsdam.gf.interfaces; package unipotsdam.gf.interfaces;
import com.fasterxml.jackson.core.JsonProcessingException;
import unipotsdam.gf.exceptions.RocketChatDownException; import unipotsdam.gf.exceptions.RocketChatDownException;
import unipotsdam.gf.exceptions.UserDoesNotExistInRocketChatException; import unipotsdam.gf.exceptions.UserDoesNotExistInRocketChatException;
import unipotsdam.gf.exceptions.WrongNumberOfParticipantsException;
import unipotsdam.gf.modules.group.Group; import unipotsdam.gf.modules.group.Group;
import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier;
import unipotsdam.gf.modules.group.GroupFormationAlgorithm; import unipotsdam.gf.modules.group.GroupFormationAlgorithm;
...@@ -12,6 +14,7 @@ import unipotsdam.gf.modules.group.GroupfindingCriteria; ...@@ -12,6 +14,7 @@ import unipotsdam.gf.modules.group.GroupfindingCriteria;
import unipotsdam.gf.modules.user.User; import unipotsdam.gf.modules.user.User;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.xml.bind.JAXBException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -53,7 +56,8 @@ public interface IGroupFinding { ...@@ -53,7 +56,8 @@ public interface IGroupFinding {
void deleteGroups(Project project) throws RocketChatDownException, UserDoesNotExistInRocketChatException; void deleteGroups(Project project) throws RocketChatDownException, UserDoesNotExistInRocketChatException;
List<Group> createRandomGroups(Project project); List<Group> createRandomGroups(Project project)
throws WrongNumberOfParticipantsException, JAXBException, JsonProcessingException;
/** /**
* finish the groups in the db * finish the groups in the db
......
...@@ -22,6 +22,11 @@ public class BigGroupMatcher implements GroupFormationAlgorithm { ...@@ -22,6 +22,11 @@ public class BigGroupMatcher implements GroupFormationAlgorithm {
return groups; return groups;
} }
@Override
public List<Group> calculateGroups(Project project, int minGroupSize) {
return calculateGroups(project);
}
@Override @Override
public void addGroupRelevantData(Project project, User user, Object data) { public void addGroupRelevantData(Project project, User user, Object data) {
......
...@@ -6,6 +6,7 @@ import unipotsdam.gf.modules.project.Project; ...@@ -6,6 +6,7 @@ import unipotsdam.gf.modules.project.Project;
import unipotsdam.gf.modules.user.User; import unipotsdam.gf.modules.user.User;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import java.util.List;
/** todo route group relevant user data over interface /** todo route group relevant user data over interface
* *
...@@ -13,6 +14,9 @@ import javax.xml.bind.JAXBException; ...@@ -13,6 +14,9 @@ import javax.xml.bind.JAXBException;
public interface GroupFormationAlgorithm { public interface GroupFormationAlgorithm {
java.util.List<Group> calculateGroups(Project project) java.util.List<Group> calculateGroups(Project project)
throws WrongNumberOfParticipantsException, JAXBException, JsonProcessingException; throws WrongNumberOfParticipantsException, JAXBException, JsonProcessingException;
List<Group> calculateGroups(Project project, int minGroupSize);
// in case of compbase all the data is added iteratively over the interface // in case of compbase all the data is added iteratively over the interface
void addGroupRelevantData(Project project, User user, Object data) throws Exception; void addGroupRelevantData(Project project, User user, Object data) throws Exception;
// in case of groupal the data is added to the mysql db // in case of groupal the data is added to the mysql db
......
package unipotsdam.gf.modules.group; package unipotsdam.gf.modules.group;
import com.fasterxml.jackson.core.JsonProcessingException;
import unipotsdam.gf.exceptions.RocketChatDownException; import unipotsdam.gf.exceptions.RocketChatDownException;
import unipotsdam.gf.exceptions.UserDoesNotExistInRocketChatException; import unipotsdam.gf.exceptions.UserDoesNotExistInRocketChatException;
import unipotsdam.gf.exceptions.WrongNumberOfParticipantsException;
import unipotsdam.gf.interfaces.ICommunication; import unipotsdam.gf.interfaces.ICommunication;
import unipotsdam.gf.interfaces.IGroupFinding; import unipotsdam.gf.interfaces.IGroupFinding;
import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier;
...@@ -12,6 +14,7 @@ import unipotsdam.gf.modules.user.User; ...@@ -12,6 +14,7 @@ import unipotsdam.gf.modules.user.User;
import unipotsdam.gf.modules.user.UserDAO; import unipotsdam.gf.modules.user.UserDAO;
import javax.inject.Inject; import javax.inject.Inject;
import javax.xml.bind.JAXBException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -107,7 +110,8 @@ public class GroupfindingImpl implements IGroupFinding { ...@@ -107,7 +110,8 @@ public class GroupfindingImpl implements IGroupFinding {
} }
@Override @Override
public List<Group> createRandomGroups(Project project) { public List<Group> createRandomGroups(Project project)
throws WrongNumberOfParticipantsException, JAXBException, JsonProcessingException {
return randomGroupAlgorithm.calculateGroups(project); return randomGroupAlgorithm.calculateGroups(project);
} }
......
...@@ -25,6 +25,11 @@ public class SingleGroupMatcher implements GroupFormationAlgorithm { ...@@ -25,6 +25,11 @@ public class SingleGroupMatcher implements GroupFormationAlgorithm {
return groups; return groups;
} }
@Override
public List<Group> calculateGroups(Project project, int minGroupSize) {
return calculateGroups(project);
}
@Override @Override
public void addGroupRelevantData(Project project, User user, Object data) { public void addGroupRelevantData(Project project, User user, Object data) {
// do nothing // do nothing
......
...@@ -47,6 +47,11 @@ public class CompBaseMatcher implements GroupFormationAlgorithm { ...@@ -47,6 +47,11 @@ public class CompBaseMatcher implements GroupFormationAlgorithm {
return result; return result;
} }
@Override
public List<Group> calculateGroups(Project project, int minGroupSize) {
return calculateGroups(project);
}
@Override @Override
public void addGroupRelevantData(Project project, User user, Object data) throws Exception { public void addGroupRelevantData(Project project, User user, Object data) throws Exception {
Client client = ClientBuilder.newClient(); Client client = ClientBuilder.newClient();
......
...@@ -39,7 +39,13 @@ public class PGroupAlMatcher implements GroupFormationAlgorithm { ...@@ -39,7 +39,13 @@ public class PGroupAlMatcher implements GroupFormationAlgorithm {
private ProfileDAO profileDAO; private ProfileDAO profileDAO;
@Override @Override
public List<Group> calculateGroups(Project project) { public List<Group> calculateGroups(Project project)
throws WrongNumberOfParticipantsException, JAXBException, JsonProcessingException {
return calculateGroups(project, 3);
}
@Override
public List<Group> calculateGroups(Project project, int minGroupSize) {
// get all users // get all users
List<User> usersByProjectName = userDAO.getUsersByProjectName(project.getName()); List<User> usersByProjectName = userDAO.getUsersByProjectName(project.getName());
...@@ -56,8 +62,16 @@ public class PGroupAlMatcher implements GroupFormationAlgorithm { ...@@ -56,8 +62,16 @@ public class PGroupAlMatcher implements GroupFormationAlgorithm {
return new ArrayList<>(); return new ArrayList<>();
} }
// if they are less then 6, we cant calculate much
if (userCount < 6) { /**
* Der Satz von silvester minUserCount = (ab -a -b) +1
* minGroupSize = a
* maxGroupSize = b = a+1
*/
// if they are less then minUserCount, we cant calculate much
int maxGroupSize = minGroupSize + 1;
int minUserCount = minGroupSize * maxGroupSize - minGroupSize - maxGroupSize +1;
if (userCount < minUserCount) {
ArrayList<Group> groups = new ArrayList<>(); ArrayList<Group> groups = new ArrayList<>();
Group group = new Group(); Group group = new Group();
for (User user : usersByProjectName) { for (User user : usersByProjectName) {
...@@ -68,7 +82,7 @@ public class PGroupAlMatcher implements GroupFormationAlgorithm { ...@@ -68,7 +82,7 @@ public class PGroupAlMatcher implements GroupFormationAlgorithm {
return groups; return groups;
} }
int calculateCount = userCount - (userCount % 3); int calculateCount = userCount - (userCount % minGroupSize);
List<User> restUsers = usersByProjectName.subList(calculateCount, userCount); List<User> restUsers = usersByProjectName.subList(calculateCount, userCount);
responses = adjustUserCount(responses, restUsers); responses = adjustUserCount(responses, restUsers);
......
package unipotsdam.gf.modules.group.random; package unipotsdam.gf.modules.group.random;
import com.fasterxml.jackson.core.JsonProcessingException;
import unipotsdam.gf.exceptions.WrongNumberOfParticipantsException;
import unipotsdam.gf.modules.group.Group; import unipotsdam.gf.modules.group.Group;
import unipotsdam.gf.modules.group.GroupDAO; import unipotsdam.gf.modules.group.GroupDAO;
import unipotsdam.gf.modules.group.GroupFormationAlgorithm; import unipotsdam.gf.modules.group.GroupFormationAlgorithm;
...@@ -8,6 +10,7 @@ import unipotsdam.gf.modules.user.User; ...@@ -8,6 +10,7 @@ import unipotsdam.gf.modules.user.User;
import unipotsdam.gf.modules.user.UserDAO; import unipotsdam.gf.modules.user.UserDAO;
import javax.inject.Inject; import javax.inject.Inject;
import javax.xml.bind.JAXBException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -17,11 +20,19 @@ public class RandomGroupAlgorithm implements GroupFormationAlgorithm { ...@@ -17,11 +20,19 @@ public class RandomGroupAlgorithm implements GroupFormationAlgorithm {
private UserDAO userDAO; private UserDAO userDAO;
@Override @Override
public List<Group> calculateGroups(Project project) { public List<Group> calculateGroups(Project project)
throws WrongNumberOfParticipantsException, JAXBException, JsonProcessingException {
return calculateGroups(project, 3);
}
@Override
public List<Group> calculateGroups(Project project, int minGroupSize) {
ArrayList<Group> result = new ArrayList<>(); ArrayList<Group> result = new ArrayList<>();
List<User> usersByProjectName = userDAO.getUsersByProjectName(project.getName()); List<User> usersByProjectName = userDAO.getUsersByProjectName(project.getName());
int numberOfUsers = usersByProjectName.size(); int numberOfUsers = usersByProjectName.size();
if (usersByProjectName.size()<6){ int maxGroupSize = minGroupSize +1;
int minUserCount = minGroupSize * maxGroupSize - minGroupSize - maxGroupSize +1;
if (usersByProjectName.size()< minUserCount){
Group group = new Group(); Group group = new Group();
group.getMembers().addAll(usersByProjectName); group.getMembers().addAll(usersByProjectName);
result.add(group); result.add(group);
...@@ -36,14 +47,14 @@ public class RandomGroupAlgorithm implements GroupFormationAlgorithm { ...@@ -36,14 +47,14 @@ public class RandomGroupAlgorithm implements GroupFormationAlgorithm {
if (numberOf3Groups > 0) { if (numberOf3Groups > 0) {
numberOf3Groups--; numberOf3Groups--;
// TODO insert formula here for the correct groups // TODO insert formula here for the correct groups
if (group.getMembers().size() == 3) { if (group.getMembers().size() == minGroupSize) {
result.add(group); result.add(group);
group = new Group(); group = new Group();
i++; i++;
group.setName(i + ""); group.setName(i + "");
} }
} else { } else {
if (group.getMembers().size() == 4) { if (group.getMembers().size() == maxGroupSize) {
result.add(group); result.add(group);
group = new Group(); group = new Group();
i++; i++;
......
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