diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/config/GFDatabaseConfig.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/config/GFDatabaseConfig.java index cefe2e289c2727db459f27dc5606aa0ceb9f9d6b..252905102d2472eaa125f06499bbdfe1663ea254 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/config/GFDatabaseConfig.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/config/GFDatabaseConfig.java @@ -7,7 +7,7 @@ public class GFDatabaseConfig { public static final String JDBC_DRIVER = "com.mysql.jdbc.Driver"; public static final String DB_URL = "jdbc:mysql://localhost"; // Database credentials - public static final String USER = "root2"; - public static final String PASS = "voyager2"; + public static final String USER = "root"; + public static final String PASS = ""; public static final String DB_NAME = "fltrail"; } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/model/Performance.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/model/Performance.java index 41a74ef307f07b7f2953183ac2f1b18eba61159e..abf5251d0a4c559a89a133daafe46dc78dcd0a82 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/model/Performance.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/model/Performance.java @@ -1,16 +1,18 @@ package unipotsdam.gf.modules.assessment.controller.model; import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; public class Performance { private StudentIdentifier studentIdentifier; private int[] quizAnswer; private String feedback; - private int[] workRating; + private Map workRating; public Performance(){} - public Performance(StudentIdentifier student, int[] quiz, String feedback, int[] workRating) { + public Performance(StudentIdentifier student, int[] quiz, String feedback, Map workRating) { this.studentIdentifier = student; this.quizAnswer = quiz; this.feedback=feedback; @@ -42,11 +44,11 @@ public class Performance { this.feedback = feedback; } - public int[] getWorkRating() { + public Map getWorkRating() { return workRating; } - public void setWorkRating(int[] workRating) { + public void setWorkRating(Map workRating) { this.workRating = workRating; } @@ -57,7 +59,7 @@ public class Performance { "studentIdentifier=" + studentIdentifier + ", quizAnswer=" + Arrays.toString(quizAnswer) + ", feedback='" + feedback + '\'' + - ", workRating=" + Arrays.toString(workRating) + + ", workRating=" + workRating + '}'; } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/AssessmentDBCommunication.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/AssessmentDBCommunication.java index 24289a14da1aab0670e842e754f42bf7c18ee0d7..ca0d2ce966512127b0e198906c5761334b305b91 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/AssessmentDBCommunication.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/AssessmentDBCommunication.java @@ -11,15 +11,29 @@ import javax.annotation.ManagedBean; import javax.annotation.Resource; import javax.inject.Singleton; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; @ManagedBean @Resource @Singleton public class AssessmentDBCommunication { + public Map getWorkRating(StudentIdentifier student) { + MysqlConnect connect = new MysqlConnect(); + connect.connect(); + String mysqlRequest = "SELECT * FROM `workrating` WHERE `projectId`=? AND `studentId`=?"; + VereinfachtesResultSet vereinfachtesResultSet = + connect.issueSelectStatement(mysqlRequest, student.getProjectId(), student.getStudentId()); + boolean next = vereinfachtesResultSet.next(); + Map workRating = new HashMap(); + workRating.put("responsibility", 4); + return workRating; + } + public Assessment getAssessment(StudentIdentifier student){ MysqlConnect connect = new MysqlConnect(); connect.connect(); - String mysqlRequest = "SELECT * FROM `peerAssessment` WHERE `projectId`=? AND `studentId`=?"; + String mysqlRequest = "SELECT * FROM `workrating` WHERE `projectId`=? AND `studentId`=?"; VereinfachtesResultSet vereinfachtesResultSet = connect.issueSelectStatement(mysqlRequest, student.getProjectId(), student.getStudentId()); boolean next = vereinfachtesResultSet.next(); diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/PeerAssessment.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/PeerAssessment.java index 4faf3d93e2dd1ae3179fdbef6a2520e6c302c26f..e7e04d83a237457ec232db694cbab23a84cf84ad 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/PeerAssessment.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/PeerAssessment.java @@ -1,12 +1,12 @@ package unipotsdam.gf.modules.assessment.controller.service; +import sun.misc.Perf; import unipotsdam.gf.interfaces.IPeerAssessment; import unipotsdam.gf.modules.assessment.QuizAnswer; import unipotsdam.gf.modules.assessment.controller.model.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import java.lang.reflect.Array; +import java.util.*; public class PeerAssessment implements IPeerAssessment { @Override @@ -31,7 +31,7 @@ public class PeerAssessment implements IPeerAssessment { @Override public void createQuiz(StudentAndQuiz studentAndQuiz) { - new QuizDBCommunication().createQuiz(studentAndQuiz.getQuiz(),studentAndQuiz.getStudentIdentifier().getStudentId(), studentAndQuiz.getStudentIdentifier().getProjectId()); + new QuizDBCommunication().createQuiz(studentAndQuiz.getQuiz(), studentAndQuiz.getStudentIdentifier().getStudentId(), studentAndQuiz.getStudentIdentifier().getProjectId()); } @Override @@ -41,18 +41,17 @@ public class PeerAssessment implements IPeerAssessment { @Override public List<Grading> calculateAssessment(ArrayList<Performance> totalPerformance) { - List<Grading> quizMean = meanOfQuizzes(totalPerformance); - List<Grading> workRateMean = meanOfWorkRate(totalPerformance); + List<Grading> quizMean = quizGrade(totalPerformance); + List<Grading> workRateMean = workRateGrade(totalPerformance); Grading[] grading = new Grading[totalPerformance.size()]; - for (int i=0; i<quizMean.size(); i++){ - double grade = quizMean.get(i).getGrade() * workRateMean.get(i).getGrade(); + for (int i = 0; i < quizMean.size(); i++) { + double grade = (quizMean.get(i).getGrade() + workRateMean.get(i).getGrade()) / 2.0; grading[i] = new Grading(totalPerformance.get(i).getStudentIdentifier(), grade); } - return Arrays.asList(grading); } - private List<Grading> meanOfQuizzes(ArrayList<Performance> totalPerformance){ + private List<Grading> quizGrade(ArrayList<Performance> totalPerformance) { double[] allAssessments = new double[totalPerformance.size()]; Grading[] grading = new Grading[totalPerformance.size()]; @@ -60,7 +59,7 @@ public class PeerAssessment implements IPeerAssessment { for (int j = 0; j < totalPerformance.get(i).getQuizAnswer().length; j++) { allAssessments[i] += totalPerformance.get(i).getQuizAnswer()[j]; } - allAssessments[i] = allAssessments[i] / totalPerformance.get(i).getQuizAnswer().length; + allAssessments[i] = 6.0 - 5.0 * allAssessments[i] / totalPerformance.get(i).getQuizAnswer().length; } for (int i = 0; i < totalPerformance.size(); i++) { Grading shuttle = new Grading(totalPerformance.get(i).getStudentIdentifier(), allAssessments[i]); @@ -69,23 +68,65 @@ public class PeerAssessment implements IPeerAssessment { return Arrays.asList(grading); } - private List<Grading> meanOfWorkRate(ArrayList<Performance> totalPerformance){ - double[] allAssessments = new double[totalPerformance.size()]; + private List<Grading> workRateGrade(ArrayList<Performance> totalPerformance) { + double[] allGrades = new double[totalPerformance.size()]; Grading[] grading = new Grading[totalPerformance.size()]; - for (int i = 0; i < totalPerformance.size(); i++) { - for (int j = 0; j < totalPerformance.get(i).getWorkRating().length; j++) { - allAssessments[i] += 6-totalPerformance.get(i).getWorkRating()[j]; + Map workRating = totalPerformance.get(i).getWorkRating(); + Iterator it = workRating.entrySet().iterator(); + int size = 0; + while (it.hasNext()) { + HashMap.Entry pair = (HashMap.Entry) it.next(); + Integer rating = (Integer) pair.getValue(); + allGrades[i] += (double) rating; + it.remove(); // avoids a ConcurrentModificationException + size++; } - allAssessments[i] = allAssessments[i] / totalPerformance.get(i).getWorkRating().length; + allGrades[i] = 6 - allGrades[i] / size; } for (int i = 0; i < totalPerformance.size(); i++) { - Grading shuttle = new Grading(totalPerformance.get(i).getStudentIdentifier(), allAssessments[i]); + Grading shuttle = new Grading(totalPerformance.get(i).getStudentIdentifier(), allGrades[i]); grading[i] = shuttle; } return Arrays.asList(grading); } + private Map<String, Double> meanOfWorkRatings(ArrayList<Map<String, Integer>> workRatings) { + HashMap<String, Double> mean = new HashMap(); + double size = (double) workRatings.size(); + Iterator it = workRatings.get(0).entrySet().iterator(); + while (it.hasNext()) { + Map.Entry pair = (Map.Entry) it.next(); + mean.put((String) pair.getKey(), 0.0); + it.remove(); // avoids a ConcurrentModificationException + } + for (int i = 0; i < workRatings.size(); i++) { + it = workRatings.get(i).entrySet().iterator(); + while (it.hasNext()) { + Map.Entry pair = (Map.Entry) it.next(); + mean.put((String) pair.getKey(), (Double) pair.getValue() / size + mean.get(pair.getKey())); + } + } + return mean; + } +//todo: funktioniert noch nicht. Fliegt aus der foreach schleife, kA warum. + public ArrayList<Map> cheatChecker(ArrayList<Map<String, Integer>> workRatings) { + ArrayList<Map<String, Integer>> possiblyCheating; + ArrayList<Map<String, Double>> means = new ArrayList<>(); + Double threshold = 0.4; + boolean cheat; + for (Map rating : workRatings) { + possiblyCheating = workRatings; + possiblyCheating.remove(rating); + means.add(meanOfWorkRatings(possiblyCheating)); + } + means.sort(byResponsibility); + String resp = "responosibility"; + if (means.get(0).get(resp) - threshold > means.get(1).get(resp)) + cheat = true; + return null; + } + @Override public ArrayList<Performance> getTotalAssessment(StudentIdentifier studentIdentifier) { return null; @@ -97,7 +138,6 @@ public class PeerAssessment implements IPeerAssessment { } - @Override public void postPeerRating(ArrayList<PeerRating> peerRatings, String projectId, String groupId) { @@ -107,4 +147,57 @@ public class PeerAssessment implements IPeerAssessment { public void answerQuiz(StudentAndQuiz studentAndQuiz, QuizAnswer quizAnswer) { } +///todo: das ist nicht die feine englische. Kann ich das hübschivieren? + final String sortCase1 = "responsibility"; + Comparator<Map<String, Double>> byResponsibility = (o1, o2) -> { + Double first = o1.get(sortCase1); + Double second = o2.get(sortCase1); + if (first.equals(second)) { + return 0; + } else { + return first < second ? -1 : 1; + } + }; + final String sortCase2 = "partOfWork"; + Comparator<Map<String, Double>> byPartOfWork = (o1, o2) -> { + Double first = o1.get(sortCase2); + Double second = o2.get(sortCase2); + if (first.equals(second)) { + return 0; + } else { + return first < second ? -1 : 1; + } + }; + final String sortCase3 = "cooperation"; + Comparator<Map<String, Double>> byCooperation = (o1, o2) -> { + Double first = o1.get(sortCase3); + Double second = o2.get(sortCase3); + if (first.equals(second)) { + return 0; + } else { + return first < second ? -1 : 1; + } + }; + final String sortCase4 = "communication"; + Comparator<Map<String, Double>> byCommunication = (o1, o2) -> { + Double first = o1.get(sortCase4); + Double second = o2.get(sortCase4); + if (first.equals(second)) { + return 0; + } else { + return first < second ? -1 : 1; + } + }; + final String sortCase5 = "autonomous"; + Comparator<Map<String, Double>> byAutonomous = (o1, o2) -> { + Double first = o1.get(sortCase5); + Double second = o2.get(sortCase5); + if (first.equals(second)) { + return 0; + } else { + return first < second ? -1 : 1; + } + }; + + } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/PeerAssessmentDummy.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/PeerAssessmentDummy.java index 61f53cc8c15ee050db92d20c9b37be376684ac6a..83542ad1054ebd2f4ad015f77348d4ff30e653fa 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/PeerAssessmentDummy.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/PeerAssessmentDummy.java @@ -6,9 +6,7 @@ import unipotsdam.gf.interfaces.IPeerAssessment; import unipotsdam.gf.modules.assessment.QuizAnswer; import unipotsdam.gf.modules.assessment.controller.model.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import java.util.*; public class PeerAssessmentDummy implements IPeerAssessment { @Override @@ -80,7 +78,7 @@ public class PeerAssessmentDummy implements IPeerAssessment { @Override public Assessment getAssessmentDataFromDB(StudentIdentifier student) { int[] quizAnswer = {1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1}; - int[] workRating = {1, 5, 3, 4, 1, 5, 5}; + Map workRating = new HashMap<>(); Performance performance = new Performance(student, quizAnswer, "what a nice guy", workRating); Assessment assessment = new Assessment(student, performance); return assessment; @@ -111,18 +109,28 @@ public class PeerAssessmentDummy implements IPeerAssessment { @Override public ArrayList<Performance> getTotalAssessment(StudentIdentifier studentIdentifier) { - StudentIdentifier[] students = new StudentIdentifier[2]; StudentIdentifier student1 = new StudentIdentifier("gemeinsamForschen", "Haralf"); StudentIdentifier student2 = new StudentIdentifier("gemeinsamForschen", "Regine"); ArrayList<Performance> performances = new ArrayList<Performance>(); int[] quiz = {1, 0, 1, 0, 0, 0, 1}; int[] quiz2 = {0, 1, 0, 1, 1, 1, 0}; - int[] work = {5, 4, 3, 2, 1}; - int[] work2 = {1, 2, 3, 4, 5}; + Map work = new HashMap(); + work.put("responsibility", 1); + work.put("partOfWork", 1); + work.put("cooperation", 1); + work.put("communication", 1); + work.put("autonomous", 1); + Map work2 = new HashMap(); + work2.put("responsibility", 3); + work2.put("partOfWork", 4); + work2.put("cooperation", 5); + work2.put("communication", 3); + work2.put("autonomous", 4); + Performance performance = new Performance(student1, quiz, "toller dude", work); performances.add(performance); - performance = new Performance(student2, quiz2, "tolle dudine", work2); - performances.add(performance); + Performance performance2 = new Performance(student2, quiz2, "passt schon", work2); + performances.add(performance2); return performances; } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/view/QuizView.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/view/QuizView.java index e5d30daa824a778fcd03807afd55db8d000de145..32d6278b3263ede80ae10d96e315942cdeb13fd6 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/view/QuizView.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/view/QuizView.java @@ -1,5 +1,6 @@ package unipotsdam.gf.modules.assessment.controller.view; +import sun.misc.Perf; import unipotsdam.gf.interfaces.IPeerAssessment; import unipotsdam.gf.modules.assessment.QuizAnswer; import unipotsdam.gf.modules.assessment.controller.model.*; @@ -10,7 +11,9 @@ import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import java.io.UnsupportedEncodingException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; @Path("/assessments") public class QuizView implements IPeerAssessment { @@ -107,14 +110,13 @@ public class QuizView implements IPeerAssessment { public List<Grading> calculateAssessment(ArrayList<Performance> totalPerformance) { return peer.calculateAssessment(totalPerformance); } - ///////////////dummy/////////funktioniert glaube ich!?//////////////////////////////////////// + ////////////////////////funktioniert primitiv/////////todo: nicht als jersey zu nutzen/////////////////////////////// @GET @Produces(MediaType.APPLICATION_JSON) @Path("/mean/project/{projectId}") @Override public int meanOfAssessment(@PathParam("projectId") String ProjectId) { - return peer.meanOfAssessment(ProjectId); } ///////////////////////////////return 0////////////////////////////////// @@ -132,15 +134,36 @@ public class QuizView implements IPeerAssessment { } /////////dummy/////////////funktioniert wie geplant////////////////////////////////// + @GET @Produces(MediaType.APPLICATION_JSON) @Path("/dummy/totalperformance") public List<Performance> getTotalAssessment() { - ArrayList<Performance> result = new ArrayList<>(); + List<Performance> result = new ArrayList<>(); StudentIdentifier student = new StudentIdentifier("projekt","student"); int[] quiz = {1,0,1,1,1,0}; - Performance pf = new Performance(student,quiz,"toller dude",quiz); - Performance pf2 = new Performance(student,quiz,"super",quiz); + Map work = new HashMap<String, Integer>(); + work.put("responsibility", 1); + work.put("partOfWork", 1); + work.put("cooperation", 1); + work.put("communication", 1); + work.put("autonomous", 1); + Map work2 = new HashMap<String, Integer>(); + work2.put("responsibility", 3); + work2.put("partOfWork", 4); + work2.put("cooperation", 5); + work2.put("communication", 3); + work2.put("autonomous", 4); + Performance pf = new Performance(); + pf.setFeedback("ein toller typ"); + pf.setQuizAnswer(quiz); + pf.setStudentIdentifier(student); + pf.setWorkRating(work); + Performance pf2 = new Performance(); + pf2.setFeedback("feini feini"); + pf2.setQuizAnswer(quiz); + pf2.setStudentIdentifier(student); + pf2.setWorkRating(work2); result.add(pf); result.add(pf2); return result; diff --git a/gemeinsamforschen/src/main/webapp/assets/js/assessmentCalculator.js b/gemeinsamforschen/src/main/webapp/assets/js/assessmentCalculator.js index 743de6b60c639819d73547e300b8d46bd6b3b564..7e1ecd5f3739c8745360530f2ef5ab5e60823c0a 100644 --- a/gemeinsamforschen/src/main/webapp/assets/js/assessmentCalculator.js +++ b/gemeinsamforschen/src/main/webapp/assets/js/assessmentCalculator.js @@ -18,7 +18,7 @@ $(document).ready(function () { //todo: paths should be relative { "studentIdentifier": { "projectId": "projekt", - "studentId": "Keiler" + "studentId": "student" }, "quizAnswer": [ 1, @@ -28,38 +28,36 @@ $(document).ready(function () { //todo: paths should be relative 1, 0 ], - "feedback": "toller dude", - "workRating": [ - 5, - 4, - 3, - 2, - 1, - 0 - ] + "feedback": "ein toller typ", + "workRating": { + "responsibility": 1, + "partOfWork": 1, + "autonomous": 1, + "communication": 1, + "cooperation": 1 + } }, { "studentIdentifier": { "projectId": "projekt", - "studentId": "Glucke" + "studentId": "student" }, "quizAnswer": [ 1, - 1, + 0, 1, 1, 1, 0 ], - "feedback": "super", - "workRating": [ - 1, - 1, - 1, - 2, - 3, - 2 - ] + "feedback": "feini feini", + "workRating": { + "responsibility": 3, + "partOfWork": 4, + "autonomous": 4, + "communication": 3, + "cooperation": 5 + } } ]; diff --git a/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/assessment/TestAddAssessment.java b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/assessment/TestAddAssessment.java index 564d54cca5d699c5c93b3e56d64ee0e91bd8057a..9426d94804ed8b6f42600286e659fae1276d045a 100644 --- a/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/assessment/TestAddAssessment.java +++ b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/assessment/TestAddAssessment.java @@ -24,9 +24,9 @@ public class TestAddAssessment { workRating[2] = 4; //Hilfsbereitschaft oder so StudentIdentifier student = new StudentIdentifier("Spaß", "Haralf"); - Performance performance = new Performance(student, quizAnswers,"so ein toller Typ", workRating); - Assessment assessment = new Assessment(student, performance); - iPeerAssessment.addAssessmentDataToDB(assessment); + //Performance performance = new Performance(student, quizAnswers,"so ein toller Typ", workRating); + //Assessment assessment = new Assessment(student, performance); + //iPeerAssessment.addAssessmentDataToDB(assessment); } } diff --git a/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/peerassessment/HashMapTest.java b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/peerassessment/HashMapTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4e81b6cfe2ffb9752ac7694cada44014b69542a0 --- /dev/null +++ b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/peerassessment/HashMapTest.java @@ -0,0 +1,157 @@ +package unipotsdam.gf.modules.peerassessment; + +import org.junit.Test; +import unipotsdam.gf.modules.assessment.controller.model.Performance; +import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; + +import java.util.*; + +public class HashMapTest { + + private Map<String, Double> meanOfWorkRatings(ArrayList<Map<String, Integer>> workRatings) { + HashMap<String, Double> mean = new HashMap(); + double size = (double) workRatings.size(); + Iterator it = workRatings.get(0).entrySet().iterator(); + while (it.hasNext()) { + Map.Entry pair = (Map.Entry) it.next(); + mean.put((String) pair.getKey(), 0.0); + } + for (int i = 0; i < workRatings.size(); i++) { + it = workRatings.get(i).entrySet().iterator(); + while (it.hasNext()) { + Map.Entry pair = (Map.Entry) it.next(); + mean.put((String) pair.getKey(), (Double) pair.getValue() / size + mean.get(pair.getKey())); + } + } + return mean; + } + final String sortCase1 = "responsibility"; + Comparator<Map<String, Double>> byResponsibility = (o1, o2) -> { + Double first = o1.get(sortCase1); + Double second = o2.get(sortCase1); + if (first.equals(second)) { + return 0; + } else { + return first < second ? -1 : 1; + } + }; + + @Test + public void sortTest(){ + Map work = new HashMap<String, Double>(); + work.put("responsibility", 1.); + work.put("partOfWork", 1.); + work.put("cooperation", 1.); + work.put("communication", 1.); + work.put("autonomous", 1.); + Map work2 = new HashMap<String, Double>(); + work2.put("responsibility", 3.); + work2.put("partOfWork", 4.); + work2.put("cooperation", 5.); + work2.put("communication", 3.); + work2.put("autonomous", 4.); + ArrayList<Map<String,Integer>> workRatings = new ArrayList<>(); + workRatings.add(work); + workRatings.add(work2); + workRatings.add(work2); + ArrayList<Map<String, Integer>> possiblyCheating; + ArrayList<Map<String, Double>> means = new ArrayList<>(); + Double threshold = 0.4; + boolean cheat; + for (Map rating : workRatings) { + possiblyCheating = workRatings; + possiblyCheating.remove(rating); + means.add(meanOfWorkRatings(possiblyCheating)); + } + means.sort(byResponsibility); + String resp = "responosibility"; + if (means.get(0).get(resp) - threshold > means.get(1).get(resp)) + cheat = true; + System.out.println(means.toString()); + + } + + @Test + public void meanMap() { + Map work = new HashMap<String, Double>(); + work.put("responsibility", 1.); + work.put("partOfWork", 1.); + work.put("cooperation", 1.); + work.put("communication", 1.); + work.put("autonomous", 1.); + Map work2 = new HashMap<String, Double>(); + work2.put("responsibility", 3.); + work2.put("partOfWork", 4.); + work2.put("cooperation", 5.); + work2.put("communication", 3.); + work2.put("autonomous", 4.); + ArrayList<Map<String,Integer>> workRatings = new ArrayList<>(); + workRatings.add(work); + workRatings.add(work2); + workRatings.add(work2); + + Map mean = new HashMap(); + double size = (double) workRatings.size(); + Iterator it = workRatings.get(0).entrySet().iterator(); + while (it.hasNext()) { + Map.Entry pair = (Map.Entry) it.next(); + mean.put(pair.getKey(), 0.0); + } + for (int i = 0; i < workRatings.size(); i++) { + it = workRatings.get(i).entrySet().iterator(); + while (it.hasNext()) { + Map.Entry pair = (Map.Entry) it.next(); + mean.put(pair.getKey(), (Double) mean.get(pair.getKey()) + (Double) pair.getValue() / size); + } + } + System.out.println(mean.toString()); + } + + @Test + public void printMap() { + Map workWork = new HashMap<String, Integer>(); + workWork.put("horst", 2); + workWork.put("Stefan", 5); + Performance performance = new Performance(); + performance.setWorkRating(workWork); + Iterator it = workWork.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry pair = (Map.Entry) it.next(); + System.out.println(workWork.get(pair.getKey())); + System.out.println((double) 2 * (Integer) pair.getValue()); + it.remove(); // avoids a ConcurrentModificationException + } + } + + @Test + public void test1() { + ArrayList<Performance> result = new ArrayList<>(); + StudentIdentifier student = new StudentIdentifier("projekt", "student"); + int[] quiz = {1, 0, 1, 1, 1, 0}; + Map work = new HashMap<String, Integer>(); + work.put("responsibility", 1); + work.put("partOfWork", 1); + work.put("cooperation", 1); + work.put("communication", 1); + work.put("autonomous", 1); + Map work2 = new HashMap<String, Integer>(); + work2.put("responsibility", 3); + work2.put("partOfWork", 4); + work2.put("cooperation", 5); + work2.put("communication", 3); + work2.put("autonomous", 4); + Performance pf = new Performance(); + pf.setFeedback("ein toller typ"); + pf.setQuizAnswer(quiz); + pf.setStudentIdentifier(student); + pf.setWorkRating(work); + Performance pf2 = new Performance(); + pf2.setFeedback("feini feini"); + pf2.setQuizAnswer(quiz); + pf2.setStudentIdentifier(student); + pf2.setWorkRating(work2); + result.add(pf); + result.add(pf2); + } + +}