Skip to content
Snippets Groups Projects
Commit be2978a1 authored by Christian's avatar Christian
Browse files

feat. dozentenbewertung in db speichern

parent 15c3dd0d
No related branches found
No related tags found
No related merge requests found
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
......@@ -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) {
}
......
......@@ -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")
......
......@@ -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>
......
......@@ -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);
}
}
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