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 7b0d3bd0d2e1ec4d998bc347f4193d3b7708a796..fe4f18458894221e7f0a57811089527d66e7f4c6 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 @@ -2,10 +2,9 @@ package unipotsdam.gf.modules.assessment.controller.service; import unipotsdam.gf.interfaces.IPeerAssessment; import unipotsdam.gf.modules.assessment.controller.model.*; -import unipotsdam.gf.core.database.mysql.MysqlConnect; -import unipotsdam.gf.modules.assessment.controller.service.QuizDBCommunication; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public class PeerAssessment implements IPeerAssessment { @@ -41,7 +40,49 @@ public class PeerAssessment implements IPeerAssessment { @Override public List<Grading> calculateAssessment(ArrayList<Performance> totalPerformance) { - return null; + List<Grading> quizMean = meanOfQuizzes(totalPerformance); + List<Grading> workRateMean = meanOfWorkRate(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(); + grading[i] = new Grading(totalPerformance.get(i).getStudentIdentifier(), grade); + } + + return Arrays.asList(grading); + } + + private List<Grading> meanOfQuizzes(ArrayList<Performance> totalPerformance){ + double[] allAssessments = 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).getQuizAnswer().length; j++) { + allAssessments[i] += totalPerformance.get(i).getQuizAnswer()[j]; + } + allAssessments[i] = 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]); + grading[i] = shuttle; + } + return Arrays.asList(grading); + } + + private List<Grading> meanOfWorkRate(ArrayList<Performance> totalPerformance){ + double[] allAssessments = 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]; + } + allAssessments[i] = allAssessments[i] / totalPerformance.get(i).getWorkRating().length; + } + for (int i = 0; i < totalPerformance.size(); i++) { + Grading shuttle = new Grading(totalPerformance.get(i).getStudentIdentifier(), allAssessments[i]); + grading[i] = shuttle; + } + return Arrays.asList(grading); } @Override 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 efe2cd75b1b0070ab0b7750611387b6c1fcb6236..f6fd95c5839117e19ad0c51fe5d555a9d5736766 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 @@ -88,7 +88,7 @@ public class PeerAssessmentDummy implements IPeerAssessment { Grading[] grading = new Grading[totalPerformance.size()]; for (int i = 0; i < totalPerformance.size(); i++) { - for (int j = 0; j < totalPerformance.get(i).getQuizAnswer().length; j++) { + for (int j = totalPerformance.get(i).getQuizAnswer().length; j > 0; j--) { allAssessments[i] += totalPerformance.get(i).getQuizAnswer()[j]; } allAssessments[i] = allAssessments[i] / totalPerformance.get(i).getQuizAnswer().length; 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 e34e1e9ab9cdbb504e9b3dd972b01a86aac18212..ef64442c2e041288f162f3964da3974a16ebce4b 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 @@ -3,6 +3,7 @@ package unipotsdam.gf.modules.assessment.controller.view; import unipotsdam.gf.interfaces.IPeerAssessment; import unipotsdam.gf.modules.assessment.controller.model.*; import unipotsdam.gf.modules.assessment.controller.service.PeerAssessment; +import unipotsdam.gf.modules.assessment.controller.service.PeerAssessmentDummy; import javax.ws.rs.*; import javax.ws.rs.core.MediaType;