Skip to content
Snippets Groups Projects
Commit 3b74ad91 authored by Axel's avatar Axel
Browse files

feat: calculate Assessment on basis of DB.

parent c7061f04
No related branches found
No related tags found
No related merge requests found
Showing
with 327 additions and 193 deletions
......@@ -84,5 +84,5 @@ public interface IPeerAssessment {
void answerQuiz(StudentAndQuiz studentAndQuiz, QuizAnswer quizAnswer);
void deleteQuiz(String quizId);
Map<String, Double> calculateAssessment(String projectId, String method);
Map<StudentIdentifier, Double> calculateAssessment(String projectId, String method);
}
package unipotsdam.gf.modules.assessment.controller.model;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Categories {
public static final List<String> workRatingCategories = Collections.unmodifiableList(
new ArrayList<String>() {{
add("responsibility");
add("partOfWork");
add("cooperation");
add("communication");
add("autonomous");
}}
);
public static final List<String> contributionRatingCategories = Collections.unmodifiableList(
new ArrayList<String>() {{
add("Dossier");
add("eJournal");
add("research");
}}
);
}
\ No newline at end of file
package unipotsdam.gf.modules.assessment.controller.model;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Performance {
private StudentIdentifier studentIdentifier;
private int[] quizAnswer;
private String feedback;
private List<Integer> quizAnswer;
private Map workRating;
private Map contributionRating;
public Performance(){}
public Performance(StudentIdentifier student, int[] quiz, String feedback, Map workRating) {
public Performance(StudentIdentifier student, List<Integer> quiz, Map contributionRating, Map workRating) {
this.studentIdentifier = student;
this.quizAnswer = quiz;
this.feedback=feedback;
this.workRating=workRating;
this.contributionRating=contributionRating;
}
......@@ -27,21 +27,17 @@ public class Performance {
public void setStudentIdentifier(StudentIdentifier studentIdentifier) {
this.studentIdentifier = studentIdentifier;
}
public Map getContributionRating() { return contributionRating; }
public int[] getQuizAnswer() {
return quizAnswer;
}
public void setContributionRating(Map contributionRating) { this.contributionRating = contributionRating; }
public void setQuizAnswer(int[] quizAnswer) {
this.quizAnswer = quizAnswer;
}
public String getFeedback() {
return feedback;
public List<Integer> getQuizAnswer() {
return quizAnswer;
}
public void setFeedback(String feedback) {
this.feedback = feedback;
public void setQuizAnswer(List<Integer> quizAnswer) {
this.quizAnswer = quizAnswer;
}
public Map getWorkRating() {
......@@ -57,8 +53,8 @@ public class Performance {
public String toString() {
return "Performance{" +
"studentIdentifier=" + studentIdentifier +
", quizAnswer=" + Arrays.toString(quizAnswer) +
", feedback='" + feedback + '\'' +
", quizAnswer=" + quizAnswer +
", contributionRating='" + contributionRating + '\'' +
", workRating=" + workRating +
'}';
}
......
package unipotsdam.gf.modules.assessment.controller.model;
public enum cheatCheckerMethods {
variance("variance"),
median("median"),
none("");
private final String text;
cheatCheckerMethods(final String text){
this.text = text;
}
@Override
public String toString(){
return text;
}
}
......@@ -2,70 +2,85 @@ package unipotsdam.gf.modules.assessment.controller.service;
import unipotsdam.gf.core.database.mysql.MysqlConnect;
import unipotsdam.gf.core.database.mysql.VereinfachtesResultSet;
import unipotsdam.gf.modules.assessment.controller.model.Assessment;
import unipotsdam.gf.modules.assessment.controller.model.Performance;
import unipotsdam.gf.modules.assessment.controller.model.Quiz;
import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier;
import unipotsdam.gf.modules.assessment.controller.model.*;
import javax.annotation.ManagedBean;
import javax.annotation.Resource;
import javax.inject.Singleton;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ManagedBean
@Resource
@Singleton
public class AssessmentDBCommunication {
public Map getWorkRating(StudentIdentifier student) {
class AssessmentDBCommunication {
ArrayList<Map<String, Double>> getWorkRating(StudentIdentifier student) {
ArrayList<Map<String, Double>> result = new ArrayList<>();
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;
while (next) {
Map workRating = new HashMap();
for (String category: Categories.workRatingCategories){
workRating.put(category, (double) vereinfachtesResultSet.getInt(category));
}
result.add(workRating);
next = vereinfachtesResultSet.next();
}
return result;
}
public Assessment getAssessment(StudentIdentifier student){
List<String> getStudents(String projectID){
List<String> result = new ArrayList<>();
MysqlConnect connect = new MysqlConnect();
connect.connect();
String mysqlRequest = "SELECT * FROM `workrating` WHERE `projectId`=? AND `studentId`=?";
String mysqlRequest = "SELECT * FROM `projectuser` WHERE `projectId`=?";
VereinfachtesResultSet vereinfachtesResultSet =
connect.issueSelectStatement(mysqlRequest, projectID);
boolean next = vereinfachtesResultSet.next();
while (next) {
result.add(vereinfachtesResultSet.getString("userID"));
next = vereinfachtesResultSet.next();
}
return result;
}
ArrayList<Map<String, Double>> getContributionRating(StudentIdentifier student) {
ArrayList<Map<String, Double>> result = new ArrayList<>();
MysqlConnect connect = new MysqlConnect();
connect.connect();
String mysqlRequest = "SELECT * FROM `contributionrating` WHERE `projectId`=? AND `studentId`=?";
VereinfachtesResultSet vereinfachtesResultSet =
connect.issueSelectStatement(mysqlRequest, student.getProjectId(), student.getStudentId());
boolean next = vereinfachtesResultSet.next();
String question = "";
ArrayList<String> correctAnswers = new ArrayList<String>();
ArrayList<String> incorrectAnswers = new ArrayList<String>();
String answer;
Boolean correct;
String mcType = "";
while (next) {
mcType = vereinfachtesResultSet.getString("mcType");
question = vereinfachtesResultSet.getString("question");
answer = vereinfachtesResultSet.getString("answer");
correct = vereinfachtesResultSet.getBoolean("correct");
if (correct){
correctAnswers.add(answer);
}else{
incorrectAnswers.add(answer);
Map<String, Double> contributionRating = new HashMap<>();
for (String category: Categories.contributionRatingCategories){
contributionRating.put(category, (double) vereinfachtesResultSet.getInt(category));
}
result.add(contributionRating);
next = vereinfachtesResultSet.next();
}
Performance performance=null;
Assessment assessment = new Assessment(student, performance);
connect.close();
return assessment;
return result;
}
public void deleteQuiz(String quizId) {
ArrayList<Integer> getAnsweredQuizzes(StudentIdentifier student) {
ArrayList<Integer> result = new ArrayList<>();
MysqlConnect connect = new MysqlConnect();
connect.connect();
String mysqlRequest = "DELETE FROM quiz where question = (?)";
connect.issueInsertOrDeleteStatement(mysqlRequest, quizId);
connect.close();
String mysqlRequest = "SELECT * FROM `answeredquiz` WHERE `projectId`=? AND `studentId`=?";
VereinfachtesResultSet vereinfachtesResultSet =
connect.issueSelectStatement(mysqlRequest, student.getProjectId(), student.getStudentId());
boolean next = vereinfachtesResultSet.next();
while (next) {
result.add(vereinfachtesResultSet.getInt("correct"));
next = vereinfachtesResultSet.next();
}
return result;
}
}
......@@ -70,7 +70,7 @@ public class FBAssessement extends AssessmentDAO {
}
@Override
public Map<String, Double> calculateAssessment(String projectId, String method) {
public Map<StudentIdentifier, Double> calculateAssessment(String projectId, String method) {
return null;
}
}
......@@ -24,7 +24,7 @@ public class PeerAssessment implements IPeerAssessment {
@Override
public Assessment getAssessmentDataFromDB(StudentIdentifier student) {
return new AssessmentDBCommunication().getAssessment(student);
return null;
}
@Override
......@@ -40,20 +40,41 @@ public class PeerAssessment implements IPeerAssessment {
@Override
public Map<StudentIdentifier, Double> calculateAssessment(ArrayList<Performance> totalPerformance) {
Map<StudentIdentifier, Double> quizMean = new HashMap<>(quizGrade(totalPerformance));
Map<StudentIdentifier, Double> workRateMean = new HashMap<>(workRateGrade(totalPerformance));
Map<StudentIdentifier, Map<String, Double>> workRating = new HashMap<>();
Map<StudentIdentifier, Map<String, Double>> contributionRating = new HashMap<>();
for (Performance performance : totalPerformance) {
workRating.put(performance.getStudentIdentifier(), performance.getWorkRating());
contributionRating.put(performance.getStudentIdentifier(), performance.getContributionRating());
}
Map<StudentIdentifier, Double> workRateMean = new HashMap<>(mapToGrade(workRating));
Map<StudentIdentifier, Double> contributionMean = new HashMap<>(mapToGrade(contributionRating));
Map<StudentIdentifier, Double> result = new HashMap<>();
Grading[] grading = new Grading[totalPerformance.size()];
for (StudentIdentifier student : quizMean.keySet()) {
double grade = (quizMean.get(student) + workRateMean.get(student)) / 2.0;
double grade = (quizMean.get(student) + workRateMean.get(student) + contributionMean.get(student)) * 100 / 3. ;
result.put(student, grade);
}
return result;
}
@Override
public Map<String, Double> calculateAssessment(String projectId, String method) {
return null;
public Map<StudentIdentifier, Double> calculateAssessment(String projectId, String method) {
ArrayList<Performance> totalPerformance = new ArrayList<>();
//get all students in projectID from DB
List<String> students = new AssessmentDBCommunication().getStudents(projectId);
//for each student
for (String student : students) {
Performance performance = new Performance();
StudentIdentifier studentIdentifier = new StudentIdentifier(projectId, student);
List<Integer> answeredQuizzes = new AssessmentDBCommunication().getAnsweredQuizzes(studentIdentifier);
ArrayList<Map<String, Double>> workRating = new AssessmentDBCommunication().getWorkRating(studentIdentifier);
ArrayList<Map<String, Double>> contributionRating = new AssessmentDBCommunication().getContributionRating(studentIdentifier);
performance.setStudentIdentifier(studentIdentifier);
performance.setQuizAnswer(answeredQuizzes);
performance.setWorkRating(cheatChecker(workRating, cheatCheckerMethods.variance));
performance.setContributionRating(cheatChecker(contributionRating, cheatCheckerMethods.variance));
totalPerformance.add(performance);
}
return calculateAssessment(totalPerformance);
}
private Map<StudentIdentifier, Double> quizGrade(ArrayList<Performance> totalPerformance) {
......@@ -61,10 +82,10 @@ public class PeerAssessment implements IPeerAssessment {
Map<StudentIdentifier, Double> grading = new HashMap<>();
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];
for (Integer quiz : totalPerformance.get(i).getQuizAnswer()) {
allAssessments[i] += quiz;
}
allAssessments[i] = 6.0 - 5.0 * allAssessments[i] / totalPerformance.get(i).getQuizAnswer().length;
allAssessments[i] = allAssessments[i] / totalPerformance.get(i).getQuizAnswer().size();
}
for (int i = 0; i < totalPerformance.size(); i++) {
grading.put(totalPerformance.get(i).getStudentIdentifier(), allAssessments[i]);
......@@ -72,52 +93,52 @@ public class PeerAssessment implements IPeerAssessment {
return grading;
}
private Map<StudentIdentifier, Double> workRateGrade(ArrayList<Performance> totalPerformance) {
double[] allAssessments = new double[totalPerformance.size()];
private Map<StudentIdentifier, Double> mapToGrade(Map<StudentIdentifier, Map<String, Double>> ratings) {
Double allAssessments;
Map<StudentIdentifier, Double> grading = new HashMap<>();
for (int i = 0; i < totalPerformance.size(); i++) {
Map workRating = totalPerformance.get(i).getWorkRating();
Iterator it = workRating.entrySet().iterator();
int size = 0;
while (it.hasNext()) {
HashMap.Entry pair = (HashMap.Entry) it.next();
Double rating = (Double) pair.getValue();
allAssessments[i] += rating;
it.remove(); // avoids a ConcurrentModificationException
size++;
for (StudentIdentifier student : ratings.keySet()) {
if (ratings.get(student) != null){
allAssessments = sumOfDimensions(ratings.get(student));
Double countDimensions = (double) ratings.get(student).size();
grading.put(student, (allAssessments-1) / (countDimensions * 4));
}
else {
grading.put(student, 0.);
}
allAssessments[i] = 6 - allAssessments[i] / size;
}
for (int i = 0; i < totalPerformance.size(); i++) {
grading.put(totalPerformance.get(i).getStudentIdentifier(), allAssessments[i]);
return grading;
}
private Double sumOfDimensions(Map rating) {
Double sumOfDimensions = 0.;
for (Object o : rating.entrySet()) {
HashMap.Entry pair = (HashMap.Entry) o;
Double markForDimension = (Double) pair.getValue();
sumOfDimensions += markForDimension;
}
return grading;
return sumOfDimensions;
}
private Map<String, Double> meanOfWorkRatings(ArrayList<Map<String, Double>> 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();
HashMap<String, Double> mean = new HashMap<>();
Double size = (double) workRatings.size();
for (Object o : workRatings.get(0).entrySet()) {
Map.Entry pair = (Map.Entry) o;
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()));
for (Map<String, Double> rating : workRatings) {
for (Object o : rating.entrySet()) {
Map.Entry pair = (Map.Entry) o;
Double value = (double) pair.getValue();
mean.put((String) pair.getKey(), value / size + mean.get(pair.getKey()));
}
}
return mean;
}
public ArrayList<Map<String, Double>> cheatChecker(ArrayList<Map<String, Double>> workRatings, String method) {
private Map<String, Double> cheatChecker(ArrayList<Map<String, Double>> workRatings, cheatCheckerMethods method) {
ArrayList<Map<String, Double>> oneExcludedMeans = new ArrayList<>();
ArrayList<Map<String, Double>> result = new ArrayList<>();
Double threshold = 0.4;
Map<String, Double> result;
if (workRatings.size() > 1) {
for (Map rating : workRatings) {
ArrayList<Map<String, Double>> possiblyCheating = new ArrayList<>(workRatings);
......@@ -125,36 +146,43 @@ public class PeerAssessment implements IPeerAssessment {
oneExcludedMeans.add(meanOfWorkRatings(possiblyCheating));
}
} else {
if (workRatings.size() <1){
return null;
}
oneExcludedMeans.add(meanOfWorkRatings(workRatings));
}
if (method.equals("median")) {
if (method.equals(cheatCheckerMethods.median)) {
workRatings.sort(byMean);
result.add(workRatings.get(workRatings.size() / 2)); //in favor of student
}
if (method.equals("variance")) {
Map<String, Double> meanWorkRating = new HashMap<>(meanOfWorkRatings(oneExcludedMeans));
ArrayList<Map<String, Double>> elementwiseDeviation = new ArrayList<>();
for (Map<String, Double> rating: oneExcludedMeans){
HashMap<String, Double> shuttle = new HashMap<>();
for (String key: rating.keySet()){
Double value = (rating.get(key)-meanWorkRating.get(key))*(rating.get(key)-meanWorkRating.get(key));
shuttle.put(key, value);
}
elementwiseDeviation.add(shuttle);
}
Double deviationOld=0.;
Integer key=0;
for (Integer i=0; i<elementwiseDeviation.size(); i++){
Double deviationNew=0.;
for (Double devi: elementwiseDeviation.get(i).values()){
deviationNew += devi;
result = workRatings.get(workRatings.size() / 2); //in favor of student
} else {
if (method.equals(cheatCheckerMethods.variance)) {
Map<String, Double> meanWorkRating = new HashMap<>(meanOfWorkRatings(oneExcludedMeans));
ArrayList<Map<String, Double>> elementwiseDeviation = new ArrayList<>();
for (Map<String, Double> rating : oneExcludedMeans) {
HashMap<String, Double> shuttle = new HashMap<>();
for (String key : rating.keySet()) {
Double value = (rating.get(key) - meanWorkRating.get(key)) * (rating.get(key) - meanWorkRating.get(key));
shuttle.put(key, value);
}
elementwiseDeviation.add(shuttle);
}
if (deviationNew>deviationOld){
deviationOld=deviationNew;
key = i;
Double deviationOld = 0.;
Integer key = 0;
for (Integer i = 0; i < elementwiseDeviation.size(); i++) {
Double deviationNew = 0.;
for (Double devi : elementwiseDeviation.get(i).values()) {
deviationNew += devi;
}
if (deviationNew > deviationOld) {
deviationOld = deviationNew;
key = i;
}
}
result = oneExcludedMeans.get(key); //gets set of rates with highest deviation in data
//so without the cheater
} else { //without cheatChecking
result = meanOfWorkRatings(workRatings);
}
result.add(oneExcludedMeans.get(key)); //gets set of rates with smallest deviation in data
}
return result;
}
......@@ -180,7 +208,7 @@ public class PeerAssessment implements IPeerAssessment {
}
Comparator<Map<String, Double>> byMean = (o1, o2) -> {
private Comparator<Map<String, Double>> byMean = (o1, o2) -> {
Double sumOfO1 = 0.;
Double sumOfO2 = 0.;
for (String key : o1.keySet()) {
......
......@@ -15,8 +15,8 @@ public class PeerAssessmentDummy implements IPeerAssessment {
@Override
public Quiz getQuiz(String projectId, String quizId, String author) {
ArrayList<String> correctAnswers = new ArrayList<String>();
ArrayList<String> incorrectAnswers = new ArrayList<String>();
ArrayList<String> correctAnswers = new ArrayList<>();
ArrayList<String> incorrectAnswers = new ArrayList<>();
Quiz sampleQuiz;
if (quizId.equals("2")) {
correctAnswers.add("42");
......@@ -39,9 +39,9 @@ public class PeerAssessmentDummy implements IPeerAssessment {
}
public ArrayList<Quiz> getQuiz(String projectId) {
ArrayList<String> correctAnswers = new ArrayList<String>();
ArrayList<String> incorrectAnswers = new ArrayList<String>();
ArrayList<Quiz> sampleQuiz = new ArrayList<Quiz>();
ArrayList<String> correctAnswers = new ArrayList<>();
ArrayList<String> incorrectAnswers = new ArrayList<>();
ArrayList<Quiz> sampleQuiz = new ArrayList<>();
correctAnswers.add("42");
correctAnswers.add("" + projectId + " 24");
incorrectAnswers.add("a god created creature");
......@@ -76,17 +76,23 @@ public class PeerAssessmentDummy implements IPeerAssessment {
}
@Override
public Map<String, Double> calculateAssessment(String projectId, String method) {
public Map<StudentIdentifier, Double> calculateAssessment(String projectId, String method) {
return null;
}
@Override
public Assessment getAssessmentDataFromDB(StudentIdentifier student) {
int[] quizAnswer = {1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1};
List<Integer> quizAnswer = new ArrayList<>();
quizAnswer.add(0);
quizAnswer.add(1);
quizAnswer.add(1);
quizAnswer.add(1);
quizAnswer.add(0);
quizAnswer.add(0);
Map workRating = new HashMap<>();
Performance performance = new Performance(student, quizAnswer, "what a nice guy", workRating);
Assessment assessment = new Assessment(student, performance);
return assessment;
Map contributionRating = new HashMap<>();
Performance performance = new Performance(student, quizAnswer, contributionRating, workRating);
return new Assessment(student, performance);
}
@Override
......@@ -103,25 +109,44 @@ public class PeerAssessmentDummy implements IPeerAssessment {
public ArrayList<Performance> getTotalAssessment(StudentIdentifier studentIdentifier) {
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};
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);
ArrayList<Performance> performances = new ArrayList<>();
List<Integer> quiz = new ArrayList<>();
quiz.add(0);
quiz.add(1);
quiz.add(1);
quiz.add(1);
quiz.add(0);
quiz.add(0);
List<Integer> quiz2 = new ArrayList<>();
quiz2.add(0);
quiz2.add(1);
quiz2.add(1);
quiz2.add(1);
quiz2.add(0);
quiz2.add(0);
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.);
Map contribution1 = new HashMap<String, Double>();
contribution1.put("Dossier", 4.);
contribution1.put("eJournal", 2.);
contribution1.put("research", 4.);
Map contribution2 = new HashMap<String, Double>();
contribution2.put("Dossier", 2.);
contribution2.put("eJournal", 3.);
contribution2.put("research", 4.);
Performance performance = new Performance(student1, quiz, contribution1, work);
performances.add(performance);
Performance performance2 = new Performance(student2, quiz2, "passt schon", work2);
Performance performance2 = new Performance(student2, quiz2, contribution2, work2);
performances.add(performance2);
return performances;
}
......
......@@ -13,7 +13,7 @@ import java.util.ArrayList;
@Resource
@Singleton
public class QuizDBCommunication {
public Quiz getQuizByProjectQuizId(String projectId, String quizId, String author){
Quiz getQuizByProjectQuizId(String projectId, String quizId, String author){
MysqlConnect connect = new MysqlConnect();
connect.connect();
String mysqlRequest = "SELECT * FROM `quiz` WHERE `projectId`=? AND `question`=? AND `author`=?";
......@@ -21,8 +21,8 @@ public class QuizDBCommunication {
connect.issueSelectStatement(mysqlRequest, projectId,quizId,author);
boolean next = vereinfachtesResultSet.next();
String question = "";
ArrayList<String> correctAnswers = new ArrayList<String>();
ArrayList<String> incorrectAnswers = new ArrayList<String>();
ArrayList<String> correctAnswers = new ArrayList<>();
ArrayList<String> incorrectAnswers = new ArrayList<>();
String answer;
Boolean correct;
String mcType = "";
......@@ -43,22 +43,22 @@ public class QuizDBCommunication {
return quiz;
}
public ArrayList<Quiz> getQuizByProjectId(String projectId) {
ArrayList<Quiz> getQuizByProjectId(String projectId) {
MysqlConnect connect = new MysqlConnect();
ArrayList<Quiz> result= new ArrayList<Quiz>();
ArrayList<Quiz> result= new ArrayList<>();
connect.connect();
String mysqlRequest = "SELECT * FROM quiz where projectId= ?";
VereinfachtesResultSet vereinfachtesResultSet =
connect.issueSelectStatement(mysqlRequest, projectId);
boolean next = vereinfachtesResultSet.next();
String question = "";
ArrayList<String> correctAnswers = new ArrayList<String>();
ArrayList<String> incorrectAnswers = new ArrayList<String>();
String question;
ArrayList<String> correctAnswers = new ArrayList<>();
ArrayList<String> incorrectAnswers = new ArrayList<>();
String answer;
String oldQuestion="";
Boolean correct;
String mcType = "";
Quiz quiz =null;
Quiz quiz;
while (next) {
mcType = vereinfachtesResultSet.getString("mcType");
question = vereinfachtesResultSet.getString("question");
......@@ -73,9 +73,8 @@ public class QuizDBCommunication {
}else{
quiz = new Quiz(mcType,oldQuestion, correctAnswers, incorrectAnswers);
result.add(quiz);
quiz=null;
correctAnswers=new ArrayList<String>();
incorrectAnswers=new ArrayList<String>();
correctAnswers=new ArrayList<>();
incorrectAnswers=new ArrayList<>();
if (correct){
correctAnswers.add(answer);
}else{
......@@ -107,8 +106,8 @@ public class QuizDBCommunication {
String answer;
boolean correct;
ArrayList<String> correctAnswers = quiz.getCorrectAnswers();
for (int i=0; i<correctAnswers.size(); i++) {
answer = correctAnswers.get(i);
for (String correctAnswer : correctAnswers) {
answer = correctAnswer;
mcType = quiz.getType();
question = quiz.getQuestion();
correct = true;
......@@ -116,8 +115,8 @@ public class QuizDBCommunication {
connect.issueInsertOrDeleteStatement(mysqlRequest, author, projectId, question, mcType, answer, correct);
}
ArrayList<String> incorrectAnswers = quiz.getIncorrectAnswers();
for (int i=0; i<incorrectAnswers.size(); i++) {
answer = incorrectAnswers.get(i);
for (String incorrectAnswer : incorrectAnswers) {
answer = incorrectAnswer;
mcType = quiz.getType();
question = quiz.getQuestion();
correct = false;
......
......@@ -109,11 +109,11 @@ public class QuizView implements IPeerAssessment {
}
////////////////////////funktioniert primitiv/////////todo: nicht als jersey zu nutzen///////////////////////////////
@POST
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/calculate/projectId/{projectId}/cheatChecker/{method}")
public Map<String, Double> calculateAssessment(@PathParam("projectId") String projectId, @PathParam("method") String method) {
public Map<StudentIdentifier, Double> calculateAssessment(@PathParam("projectId") String projectId, @PathParam("method") String method) {
return peer.calculateAssessment(projectId, method);
}
......@@ -147,26 +147,41 @@ public class QuizView implements IPeerAssessment {
public List<Performance> getTotalAssessment() {
List<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);
List<Integer> quiz = new ArrayList<>();
quiz.add(1);
quiz.add(0);
quiz.add(1);
quiz.add(0);
quiz.add(1);
quiz.add(0);
quiz.add(1);
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.);
Map contribution1 = new HashMap<String, Double>();
contribution1.put("Dossier", 4.);
contribution1.put("eJournal", 2.);
contribution1.put("research", 4.);
Map contribution2 = new HashMap<String, Double>();
contribution2.put("Dossier", 2.);
contribution2.put("eJournal", 3.);
contribution2.put("research", 4.);
Performance pf = new Performance();
pf.setFeedback("ein toller typ");
pf.setContributionRating(contribution1);
pf.setQuizAnswer(quiz);
pf.setStudentIdentifier(student);
pf.setWorkRating(work);
Performance pf2 = new Performance();
pf2.setFeedback("feini feini");
pf2.setContributionRating(contribution2);
pf2.setQuizAnswer(quiz);
pf2.setStudentIdentifier(student);
pf2.setWorkRating(work2);
......
......@@ -179,26 +179,41 @@ public class HashMapTest {
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);
List<Integer> quiz = new ArrayList<>();
quiz.add(1);
quiz.add(0);
quiz.add(1);
quiz.add(0);
quiz.add(1);
quiz.add(0);
quiz.add(1);
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.);
Map contribution1 = new HashMap<String, Double>();
contribution1.put("Dossier", 4.);
contribution1.put("eJournal", 2.);
contribution1.put("research", 4.);
Map contribution2 = new HashMap<String, Double>();
contribution2.put("Dossier", 2.);
contribution2.put("eJournal", 3.);
contribution2.put("research", 4.);
Performance pf = new Performance();
pf.setFeedback("ein toller typ");
pf.setContributionRating(contribution1);
pf.setQuizAnswer(quiz);
pf.setStudentIdentifier(student);
pf.setWorkRating(work);
Performance pf2 = new Performance();
pf2.setFeedback("feini feini");
pf2.setContributionRating(contribution2);
pf2.setQuizAnswer(quiz);
pf2.setStudentIdentifier(student);
pf2.setWorkRating(work2);
......
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