diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/model/Assessment.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/model/Assessment.java index 1e6abcd342e0d1617eedd61acad737e2ec0322f7..5e3278f87639b54d99d0484cc846925d88583c3a 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/model/Assessment.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/model/Assessment.java @@ -1,5 +1,6 @@ package unipotsdam.gf.modules.assessment.controller.model; +import com.fasterxml.jackson.annotation.JsonIgnore; import unipotsdam.gf.core.database.mysql.MysqlConnect; import unipotsdam.gf.core.database.mysql.VereinfachtesResultSet; import unipotsdam.gf.core.management.project.Project; @@ -15,46 +16,67 @@ import java.util.ArrayList; import javax.xml.bind.annotation.XmlRootElement; import java.util.ArrayList; +import java.util.Date; @XmlRootElement public class Assessment { - private StudentIdentifier student; + private StudentIdentifier student;// gemeint als Ziel der Bewertung, kann auch gruppe sein + @JsonIgnore private Performance performance; + private StudentIdentifier bewertender; + private String projektId; + private int bewertung; + private boolean adressat; + private Date deadline; public Assessment(StudentIdentifier student, Performance performance) { this.student = student; this.performance = performance; } - public Assessment(){} + public Assessment(boolean adressat,StudentIdentifier student, Date deadline, StudentIdentifier bewertender, String projektId, int bewertung) { + this.student = student; + this.deadline = deadline; + this.bewertender = bewertender; + this.projektId = projektId; + this.bewertung = bewertung; + this.adressat=adressat; + } + + public Assessment() { + } - public ArrayList<Performance> getTotalAssessment() { return null; } + public ArrayList<Performance> getTotalAssessment() { + return null; + } public StudentIdentifier getStudent() { return student; } + public StudentIdentifier getBewertender() { + return bewertender; + } + + public void setBewertender(StudentIdentifier bewertender) { + this.bewertender = bewertender; + } + public void setStudent(StudentIdentifier student) { this.student = student; } + @JsonIgnore public Performance getPerformance() { return performance; } - + @JsonIgnore public void setPerformance(Performance performance) { this.performance = performance; } - public void setAssessment(User user, Assessment assessment){ - MysqlConnect connect = new MysqlConnect(); - connect.connect(); - String mysqlRequest = "INSERT INTO assessments ( `BewertenderId`, `BewerteterId`, `Bewertung`,`StuoGrp`) values (?,?,?,?)"; - connect.issueInsertOrDeleteStatement(mysqlRequest, "tom" ,user.getName() , assessment.getPerformance().getWorkRating()[0], user.getStudent()); - connect.close(); - } @Override public String toString() { return "Assessment{" + @@ -62,4 +84,52 @@ public class Assessment { ", performance=" + performance + '}'; } -} + + public int getBewertung() { + return bewertung; + } + + public void setBewertung(int bewertung) { + this.bewertung = bewertung; + } + + public String getProjektId() { + return projektId; + } + + public void setProjektId(String projektId) { + this.projektId = projektId; + } + + + public void setAssessment(Assessment assessment) { + MysqlConnect connect = new MysqlConnect(); + connect.connect(); + String mysqlRequest = "INSERT INTO assessments ( `Adressat`, `Deadline`, `ErstellerId`,`EmpfängerId`, `ProjektId`, `Bewertung`) values (?,?,?,?,?,?)"; + connect.issueInsertOrDeleteStatement(mysqlRequest, + assessment.isAdressat(), + assessment.getDeadline(), + assessment.getBewertender().getStudentId(), + assessment.getStudent().getStudentId(), + assessment.getProjektId(), + assessment.getBewertung() + ); + connect.close(); + } + + public boolean isAdressat() { + return adressat; + } + + public void setAdressat(boolean adressat) { + this.adressat = adressat; + } + + public Date getDeadline() { + return deadline; + } + + public void setDeadline(Date deadline) { + this.deadline = deadline; + } +} \ No newline at end of file diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/view/AssessmentView.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/view/AssessmentView.java index f71b4144b42df273a88b80b32e1ff19c52bb27fb..f533477fc1ca13813732b1fcce4e4ec95dca8c56 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/view/AssessmentView.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/view/AssessmentView.java @@ -12,19 +12,48 @@ import javax.annotation.PostConstruct; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import java.util.ArrayList; +import java.util.Date; import java.util.List; -@Path("/assessments") +@Path("/assessments2") public class AssessmentView implements IPeerAssessment{ private static IPeerAssessment peer = new PeerAssessmentDummy(); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - @Path("/calculate2") + @Path("/calculate3") @Override public List<Grading> calculateAssessment(ArrayList<Performance> totalPerformance) { return peer.calculateAssessment(totalPerformance); } + + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.TEXT_PLAIN) + @Path("/calculate2") + public String testDesReturn(Assessment assessment){ + Assessment shuttle = new Assessment(); //neues Objekt, dass dann bearbeitet werden kann + //System.out.println(assessment.getBewertung()); + shuttle.setAssessment(assessment); //inhalte werden in die DB geschrieben und es wird erfolg zurückgemeldet + return "1"; + } + /*} + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("dummy/calculate2") + public Assessment dummyAssessment(){ + StudentIdentifier student = new StudentIdentifier("projectID", "StudentId"); + Performance performance; + StudentIdentifier bewertender; + String projektId; + int bewertung; + boolean adressat; + Date deadline; + Assessment shuttle = new Assessment(student, ) + + return null; + }*/ + @Override public void addAssessmentDataToDB(Assessment assessment) { } diff --git a/gemeinsamforschen/src/main/webapp/assets/js/AlertAssessmentOutlier.js b/gemeinsamforschen/src/main/webapp/assets/js/AlertAssessmentOutlier.js index 42c3692252f0e4ba25b6c8d1f2165cb5d75fdcb8..e0b6d5d75f3dd1fe6e6460630e54351676ff7116 100644 --- a/gemeinsamforschen/src/main/webapp/assets/js/AlertAssessmentOutlier.js +++ b/gemeinsamforschen/src/main/webapp/assets/js/AlertAssessmentOutlier.js @@ -12,18 +12,34 @@ $(document).ready(function () { $(document).ready(function () { $('#ProblemGrp1').on('click',function () { var alarm = prompt("hier gibt es Unstimmigeiten","Vorgeschlagene Note:") - if (alarm === "1") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "2") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "3") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "4") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "5") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "6") { - document.getElementById("demo").innerHTML = alarm; + if (alarm === "1"||alarm=="2"||alarm=="3"||alarm=="4"||alarm=="5"||alarm=="6") { + + var dataP= JSON.stringify({"adressat":true,"student": { + "projectId": "projekt2", + "studentId": "fgnxnw" + }, "deadline":new Date(), + "bewertender": { + "projectId": "projekt2", + "studentId": "christians" + }, + "projektId":"projekt2", + "bewertung":alarm + }); + $.ajax({ + url: "../rest/assessments2/calculate2", + type: 'POST', + headers: { + "Content-Type": "application/json", + "Cache-Control": "no-cache" + }, + data: dataP, + success: function (response) { + document.getElementById('ProblemGrp1').innerHTML=response; + }, + error: function (a,b,c) { + alert('some error' + b); + } + }) } else{ window.alert("Bitte eine Zahl zwischen eins und 6 angeben") @@ -34,18 +50,8 @@ $(document).ready(function () { $(document).ready(function () { $('#ProblemGrp1S1').on('click',function () { var alarm = prompt("hier gibt es Unstimmigeiten","Vorgeschlagene Note:") - if (alarm === "1") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "2") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "3") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "4") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "5") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "6") { - document.getElementById("demo").innerHTML = alarm; + if (alarm === "1"||alarm=="2"||alarm=="3"||alarm=="4"||alarm=="5"||alarm=="6") { + document.getElementById("ProblemGrp1S1").innerHTML = alarm; } else{ window.alert("Bitte eine Zahl zwischen eins und 6 angeben") @@ -55,18 +61,8 @@ $(document).ready(function () { $(document).ready(function () { $('#ProblemGrp1S2').on('click',function () { var alarm = prompt("hier gibt es Unstimmigeiten","Vorgeschlagene Note:") - if (alarm === "1") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "2") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "3") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "4") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "5") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "6") { - document.getElementById("demo").innerHTML = alarm; + if (alarm === "1"||alarm=="2"||alarm=="3"||alarm=="4"||alarm=="5"||alarm=="6") { + document.getElementById("ProblemGrp1S2").innerHTML = alarm; } else{ window.alert("Bitte eine Zahl zwischen eins und 6 angeben") @@ -76,18 +72,8 @@ $(document).ready(function () { $(document).ready(function () { $('#ProblemGrp2').on('click',function () { var alarm = prompt("hier gibt es Unstimmigeiten","Vorgeschlagene Note:") - if (alarm === "1") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "2") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "3") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "4") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "5") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "6") { - document.getElementById("demo").innerHTML = alarm; + if (alarm === "1"||alarm=="2"||alarm=="3"||alarm=="4"||alarm=="5"||alarm=="6") { + document.getElementById("ProblemGrp2").innerHTML = alarm; } else{ window.alert("Bitte eine Zahl zwischen eins und 6 angeben") @@ -97,18 +83,8 @@ $(document).ready(function () { $(document).ready(function () { $('#ProblemGrp2S3').on('click',function () { var alarm = prompt("hier gibt es Unstimmigeiten","Vorgeschlagene Note:") - if (alarm === "1") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "2") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "3") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "4") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "5") { - document.getElementById("demo").innerHTML = alarm; - } else if (alarm === "6") { - document.getElementById("demo").innerHTML = alarm; + if (alarm === "1"||alarm=="2"||alarm=="3"||alarm=="4"||alarm=="5"||alarm=="6") { + document.getElementById("ProblemGrp2S3").innerHTML = alarm; } else{ window.alert("Bitte eine Zahl zwischen eins und 6 angeben") diff --git a/gemeinsamforschen/src/main/webapp/pages/project-docent_CG.jsp b/gemeinsamforschen/src/main/webapp/pages/project-docent_CG.jsp index 5924b6747af2311b7570a3e241ee99db20673b82..377db7d892def59a7ee7d1abf47a4fac737d9e8c 100644 --- a/gemeinsamforschen/src/main/webapp/pages/project-docent_CG.jsp +++ b/gemeinsamforschen/src/main/webapp/pages/project-docent_CG.jsp @@ -42,7 +42,7 @@ <table class="table"> <thead> <tr> - <th>Gruppe1 </th> + <th id="testAjax">Gruppe1 </th> <th>Beiträge </th> <th> <button id="ProblemGrp1">!</button> </th> </tr> 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..2e5ff313f5360d4f072f24c568478e92b61c9d66 100644 --- a/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/assessment/TestAddAssessment.java +++ b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/assessment/TestAddAssessment.java @@ -7,6 +7,8 @@ import unipotsdam.gf.modules.assessment.controller.service.FBAssessement; import unipotsdam.gf.modules.assessment.controller.model.Performance; import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; +import java.util.Date; + public class TestAddAssessment { @Test @@ -26,7 +28,14 @@ public class TestAddAssessment { 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); + //iPeerAssessment.addAssessmentDataToDB(assessment); + } + @Test + public void testSetAssessment(){ + StudentIdentifier ersteller=new StudentIdentifier("projekt","christian"); + StudentIdentifier empfaenger=new StudentIdentifier("projekt","fgnxn"); + Assessment testAssessment=new Assessment(true,empfaenger,new Date(),ersteller,"projekt",4); + testAssessment.setAssessment(testAssessment); } }