Skip to content
Snippets Groups Projects
Commit 153fa6ba authored by Axel's avatar Axel
Browse files

fix: updated DB-scheme. feat: DB-communication works for assessment.

parent 62550567
No related branches found
No related tags found
No related merge requests found
Showing
with 192 additions and 86 deletions
...@@ -76,6 +76,10 @@ public interface IPeerAssessment { ...@@ -76,6 +76,10 @@ public interface IPeerAssessment {
*/ */
void postPeerRating(ArrayList<PeerRating> peerRatings, String projectId); void postPeerRating(ArrayList<PeerRating> peerRatings, String projectId);
void postContributionRating(StudentIdentifier student,
String fromPeer,
Map<String, Integer> contributionRating);
/** /**
* *
* @param questions * @param questions
......
...@@ -124,8 +124,8 @@ class AssessmentDBCommunication { ...@@ -124,8 +124,8 @@ class AssessmentDBCommunication {
void writeContributionRatingToDB(StudentIdentifier student, String fromStudent, Map<String, Integer> contributionRating) { void writeContributionRatingToDB(StudentIdentifier student, String fromStudent, Map<String, Integer> contributionRating) {
MysqlConnect connect = new MysqlConnect(); MysqlConnect connect = new MysqlConnect();
connect.connect(); connect.connect();
String mysqlRequest = "INSERT INTO `contributionrating`(`studentID`, `projectID`, `fromStudentID`, " + String mysqlRequest = "INSERT INTO `contributionrating`(`studentId`, `projectId`, `fromPeer`, " +
"`Dossier`, " + "`dossier`, " +
"`eJournal`, " + "`eJournal`, " +
"`research`" + "`research`" +
") VALUES (?,?,?,?,?,?)"; ") VALUES (?,?,?,?,?,?)";
......
...@@ -60,6 +60,11 @@ public class FBAssessement extends AssessmentDAO { ...@@ -60,6 +60,11 @@ public class FBAssessement extends AssessmentDAO {
} }
@Override
public void postContributionRating(StudentIdentifier student, String fromStudent, Map<String, Integer> contributionRating) {
}
@Override @Override
public void answerQuiz(Map<String, List<String>> questions, StudentIdentifier student) { public void answerQuiz(Map<String, List<String>> questions, StudentIdentifier student) {
......
...@@ -206,6 +206,13 @@ public class PeerAssessment implements IPeerAssessment { ...@@ -206,6 +206,13 @@ public class PeerAssessment implements IPeerAssessment {
} }
} }
@Override
public void postContributionRating(StudentIdentifier student,
String fromStudent,
Map<String, Integer> contributionRating) {
new AssessmentDBCommunication().writeContributionRatingToDB(student, fromStudent, contributionRating);
}
@Override @Override
public void answerQuiz(Map<String, List<String>> questions, StudentIdentifier student) { public void answerQuiz(Map<String, List<String>> questions, StudentIdentifier student) {
for (String question: questions.keySet()){ for (String question: questions.keySet()){
......
...@@ -65,6 +65,11 @@ public class PeerAssessmentDummy implements IPeerAssessment { ...@@ -65,6 +65,11 @@ public class PeerAssessmentDummy implements IPeerAssessment {
int breakpoint = 0; //todo: print an http-answer for the ajax-request to receive int breakpoint = 0; //todo: print an http-answer for the ajax-request to receive
} }
@Override
public void postContributionRating(StudentIdentifier student, String fromStudent, Map<String, Integer> contributionRating) {
}
@Override @Override
public void answerQuiz(Map<String, List<String>> questions, StudentIdentifier student) { public void answerQuiz(Map<String, List<String>> questions, StudentIdentifier student) {
NotImplementedLogger.logAssignment(Assignee.AXEL, IPeerAssessment.class); NotImplementedLogger.logAssignment(Assignee.AXEL, IPeerAssessment.class);
......
...@@ -46,6 +46,17 @@ public class QuizView { ...@@ -46,6 +46,17 @@ public class QuizView {
peer.postPeerRating(peerRatings, projectId); peer.postPeerRating(peerRatings, projectId);
} }
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Path("/contributionRating/projectId/{projectId}/studentId/{studentId}/fromPeer/{fromPeer}")
public void postContributionRating(Map<String, Integer> contributionRatings,
@PathParam("projectId") String projectId,
@PathParam("studentId") String studentId,
@PathParam("fromPeer") String fromPeer) throws IOException {
StudentIdentifier student = new StudentIdentifier(projectId, studentId);
peer.postContributionRating(student, fromPeer, contributionRatings);
}
@POST @POST
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Path("/quizAnswer/projectId/{projectId}/studentId/{studentId}/") @Path("/quizAnswer/projectId/{projectId}/studentId/{studentId}/")
......
...@@ -9,34 +9,37 @@ $(document).ready(function() { ...@@ -9,34 +9,37 @@ $(document).ready(function() {
}); });
function assessPeer(){ function assessPeer(){
var peerStudents =$('.peerStudent'); let peerStudents =$('.peerStudent');
///////initialize variables/////// ///////initialize variables///////
var dataP = new Array(peerStudents.size()); let dataP = new Array(peerStudents.size());
var rateThis = ['responsibility','partOfWork','cooperation','communication','autonomous']; let rateThis = ['responsibility','partOfWork','cooperation','communication','autonomous'];
///////read values from html/////// ///////read values from html///////
for (var peer=0; peer< peerStudents.length; peer++){ for (let peer=0; peer< peerStudents.length; peer++){
var workRating = {}; let workRating = {};
var peerRating = { let peerRating = {
"fromPeer": $('#user').html().trim(), "fromPeer": $('#user').html().trim(),
"toPeer": peerStudents[peer].id, "toPeer": peerStudents[peer].id,
"workRating": {} "workRating": {}
}; };
for (var rate=0; rate<rateThis.length; rate++ ){ for (let rate=0; rate<rateThis.length; rate++ ){
var category = rateThis[rate]; let category = rateThis[rate];
workRating[category]=($('input[name='+rateThis[rate]+peerStudents[peer].id+']:checked').val()); workRating[category]=($('input[name='+rateThis[rate]+peerStudents[peer].id+']:checked').val());
} }
for (var i=0; i<workRating.length; i++){
if(workRating[i]===undefined){ peerRating.workRating = workRating;
//////write values in Post-Variable
dataP[peer]=peerRating;
}
for (let peer=0; peer< dataP.length; peer++){
for (let workRating=0; workRating<rateThis.length;workRating++){
if(dataP[peer][workRating]===undefined){
$('#notAllRated').show(); $('#notAllRated').show();
return; return;
} }
} }
peerRating.workRating = workRating;
//////write values in Post-Variable
dataP[peer]=peerRating;
} }
var projectId=$('#projectId').html().trim(); let projectId=$('#projectId').html().trim();
$.ajax({ $.ajax({
url:'../rest/assessments/peerRating/project/'+projectId, url:'../rest/assessments/peerRating/project/'+projectId,
type: 'POST', type: 'POST',
......
$(document).ready(function () { $(document).ready(function () {
var ejournalFeedback = new InscrybMDE({ new InscrybMDE({
element: document.getElementById("ejournalFeedback"), element: document.getElementById("ejournalFeedback"),
spellChecker: false, spellChecker: false,
//toolbar: ["bold", "italic", "heading", "|", "quote", "table", "code", "|" , "side-by-side", "fullscreen"], //toolbar: ["bold", "italic", "heading", "|", "quote", "table", "code", "|" , "side-by-side", "fullscreen"],
minHeight: "80px", minHeight: "80px",
}); });
var presentationFeedback = new InscrybMDE({ new InscrybMDE({
element: document.getElementById("presentationFeedback"), element: document.getElementById("presentationFeedback"),
spellChecker: false, spellChecker: false,
//toolbar: ["bold", "italic", "heading", "|", "quote", "table", "code", "|" , "side-by-side", "fullscreen"], //toolbar: ["bold", "italic", "heading", "|", "quote", "table", "code", "|" , "side-by-side", "fullscreen"],
minHeight: "80px", minHeight: "80px",
}); });
var dossierFeedback = new InscrybMDE({ new InscrybMDE({
element: document.getElementById("dossierFeedback"), element: document.getElementById("dossierFeedback"),
spellChecker: false, spellChecker: false,
//toolbar: ["bold", "italic", "heading", "|", "quote", "table", "code", "|" , "side-by-side", "fullscreen"], //toolbar: ["bold", "italic", "heading", "|", "quote", "table", "code", "|" , "side-by-side", "fullscreen"],
...@@ -19,10 +19,41 @@ $(document).ready(function () { ...@@ -19,10 +19,41 @@ $(document).ready(function () {
}); });
editor.style = "min-height: 100px"; //editor.style = "min-height: 100px";
$('#submit').on('click',function(){ $('#submit').on('click', function () {
document.location="project-student.jsp?token="+getUserTokenFromUrl(); safeContributionRating();
}); });
}); });
\ No newline at end of file
function safeContributionRating() {
let contributions = $('.contributionRating');
///////initialize variables///////
let dataP = {};
///////read values from html///////
for (let contribution = 0; contribution < contributions.length; contribution++) {
let checkbox = $("#" + contributions[contribution].id + " input:checked");
dataP[checkbox.attr('name')] = checkbox.val();
}
let projectId = $('#projectId').html().trim();
let fromPeer = $('#user').html().trim();
let toStudent = $('.peerStudent').attr('id');
$.ajax({
url: '../rest/assessments/contributionRating/projectId/' + projectId +
'/studentId/' + toStudent + '/fromPeer/' + fromPeer,
type: 'POST',
headers: {
"Content-Type": "application/json",
"Cache-Control": "no-cache"
},
data: JSON.stringify(dataP),
success: function () {
location.href = "project-student.jsp?token=" + getUserTokenFromUrl() + "&projectId=" + $('#projectId').html().trim();
},
error: function (a, b, c) {
}
});
}
\ No newline at end of file
$(document).ready(function () { $(document).ready(function () {
var loading = $('#loadbar').hide(); let loading = $('#loadbar').hide();
$(document) $(document)
.ajaxStart(function () { .ajaxStart(function () {
loading.show(); loading.show();
...@@ -8,7 +8,7 @@ $(document).ready(function () { ...@@ -8,7 +8,7 @@ $(document).ready(function () {
}); });
$("label.btn").on('click',function () { $("label.btn").on('click',function () {
var choice = $(this).find('input:radio').val(); let choice = $(this).find('input:radio').val();
$('#loadbar').show(); $('#loadbar').show();
$('#quiz').fadeOut(); $('#quiz').fadeOut();
setTimeout(function(){ setTimeout(function(){
...@@ -21,40 +21,37 @@ $(document).ready(function () { ...@@ -21,40 +21,37 @@ $(document).ready(function () {
$ans = 3; $ans = 3;
$.fn.checking = function(ck) { let projectId = document.getElementById('projectId').innerText.trim();
if (ck != $ans)
return 'INCORRECT';
else
return 'CORRECT';
};
var projectId = document.getElementById('projectId').innerText.trim();
var studentId = document.getElementById('user').innerText.trim();
$.ajax({ $.ajax({
url: '../rest/assessments/project/'+projectId+'/quiz/', url: '../rest/assessments/project/'+projectId+'/quiz/',
type: 'GET', type: 'GET',
success: function (data) { success: function (data) {
var table = document.getElementById('tableQuiz'); let table = document.getElementById('tableQuiz');
for (var quiz = 0; quiz < data.length; quiz++){ for (let quiz = 0; quiz < data.length; quiz++){
var question = data[quiz].question.replace(/ /g,"").replace("?","").replace(",",""); let question = data[quiz].question.replace(/ /g,"").replace("?","").replace(",","");
var answers = data[quiz].correctAnswers.concat(data[quiz].incorrectAnswers); let answers = data[quiz].correctAnswers.concat(data[quiz].incorrectAnswers);
var colspan = answers.length; let colspan = answers.length;
var trQuestion = document.createElement('TR'); let trQuestion = document.createElement('TR');
var tdQuestion = '<td colspan="' + colspan + '"' + let tdQuestion = '<td colspan="' + colspan + '"' +
' data-toggle="collapse" href="#'+question+'" aria-expanded="false" aria-controls="'+question+'">' + ' data-toggle="collapse" href="#'+question+'" aria-expanded="false" aria-controls="'+question+'">' +
'' + data[quiz].question + '</td>'; '' + data[quiz].question + '</td>';
trQuestion.innerHTML = tdQuestion; trQuestion.innerHTML = tdQuestion;
var trAnswers = document.createElement('TR'); let trAnswers = document.createElement('TR');
answers = shuffle(answers); answers = shuffle(answers);
var answersTd='<td style="display: block;"><div class="quiz collapse" id="'+question+'" data-toggle="buttons">'; let answersTd='<td style="display: block;">' +
for (var i = 0; i < answers.length; i++) { '<div ' +
'class="quiz collapse" ' +
'id="'+question+'" ' +
'data-toggle="buttons">' +
'<p hidden>'+data[quiz].question+'</p>';
for (let i = 0; i < answers.length; i++) {
answersTd = answersTd + '<div>' + answersTd = answersTd + '<div>' +
'<label class="element-animation1 btn btn-lg btn-primary btn-block">' + '<label class="element-animation1 btn btn-lg btn-primary btn-block">' +
'<span class="btn-label">' + '<span class="btn-label">' +
'<i class="glyphicon glyphicon-chevron-right">' + '<i class="glyphicon glyphicon-chevron-right">' +
'</i>' + '</i>' +
'</span>' + '</span>' +
'<input type="checkbox">' + answers[i] + '' + '<input type="checkbox" value="'+answers[i]+'">' + answers[i] + '' +
'</label>' + '</label>' +
'</div>'; '</div>';
} }
...@@ -75,7 +72,7 @@ $(document).ready(function () { ...@@ -75,7 +72,7 @@ $(document).ready(function () {
}); });
function shuffle(a) { function shuffle(a) {
var j, x, i; let j, x, i;
for (i = a.length - 1; i > 0; i--) { for (i = a.length - 1; i > 0; i--) {
j = Math.floor(Math.random() * (i + 1)); j = Math.floor(Math.random() * (i + 1));
x = a[i]; x = a[i];
...@@ -85,24 +82,25 @@ function shuffle(a) { ...@@ -85,24 +82,25 @@ function shuffle(a) {
return a; return a;
} }
function safeQuizAnswers(){ //todo: just written before going home. not tested yet, wont work function safeQuizAnswers(){
var quizzes = $('.quiz'); let quizzes = $('.quiz');
///////initialize variables/////// ///////initialize variables///////
var dataP = new Array(quizzes.size()); let dataP = {};
///////read values from html/////// ///////read values from html///////
for (var quiz=0; quiz<quizzes.size(); quiz++){ for (let quiz=0; quiz<quizzes.length; quiz++){
var answerList = []; let answerList = [];
$(quizzes[quiz]+":input:checkbox[name=type]:checked").each(function(){ if (quizzes[quiz].id !== ""){
answerList.push($(this).val()); let checkedBoxes = $("#"+quizzes[quiz].id+" input:checked");
}); checkedBoxes.each(function(){
var question = quizzes[quiz].id; answerList.push($(this).val());
var quizAnswers={question: answerList}; });
//////write values in Post-Variable let question = $("#"+quizzes[quiz].id+" p").html().trim();
dataP[quiz]=quizAnswers; dataP[question]= answerList;
}
} }
var projectId=$('#projectId').html().trim(); let projectId=$('#projectId').html().trim();
var studentId=$('#user').html().trim(); let studentId=$('#user').html().trim();
$.ajax({ $.ajax({
url:'../rest/assessments/quizAnswer/projectId/'+projectId+'/studentId/'+studentId, url:'../rest/assessments/quizAnswer/projectId/'+projectId+'/studentId/'+studentId,
type: 'POST', type: 'POST',
...@@ -112,7 +110,7 @@ function safeQuizAnswers(){ //todo: just written before going home. not tested ...@@ -112,7 +110,7 @@ function safeQuizAnswers(){ //todo: just written before going home. not tested
}, },
data: JSON.stringify(dataP), data: JSON.stringify(dataP),
success: function(){ success: function(){
location.href="takeQuiz.jsp?token="+getUserTokenFromUrl()+"&projectId="+$('#projectId').html().trim(); location.href="rateContribution.jsp?token="+getUserTokenFromUrl()+"&projectId="+$('#projectId').html().trim();
}, },
error: function(a,b,c){ error: function(a,b,c){
......
...@@ -33,44 +33,51 @@ ...@@ -33,44 +33,51 @@
</tr> </tr>
<tr> <tr>
<td> <td>
Lernzieltagebuch: <div class="contributionRating" id="eJournal">
Lernen ist wie Rudern gegen den Strom. Hört man damit auf, treibt man zurück. Lernzieltagebuch:
<textarea id="ejournalFeedback"> Lernen ist wie Rudern gegen den Strom. Hört man damit auf, treibt man zurück.
<textarea id="ejournalFeedback">
meine Bewertung meine Bewertung
</textarea> </textarea>
<label><input type="radio" name="ejournalRating">Perfekt</label> <label><input type="radio" name="eJournal" value="5">Perfekt</label>
<label><input type="radio" name="ejournalRating">Makellos</label> <label><input type="radio" name="eJournal" value="4">Makellos</label>
<label><input type="radio" name="ejournalRating">regulär</label> <label><input type="radio" name="eJournal" value="3">regulär</label>
<label><input type="radio" name="ejournalRating">Makelhaft</label> <label><input type="radio" name="eJournal" value="2">Makelhaft</label>
<label><input type="radio" name="ejournalRating">Lädiert</label> <label><input type="radio" name="eJournal" value="1">Lädiert</label>
</div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
Dossier: <div class="contributionRating" id="Dossier">
Die meisten Menschen sind bereit zu lernen, aber nur die wenigsten, sich belehren zu Dossier:
lassen. Die meisten Menschen sind bereit zu lernen, aber nur die wenigsten, sich
<textarea id="dossierFeedback"> belehren zu
lassen.
<textarea id="dossierFeedback">
meine Bewertung meine Bewertung
</textarea> </textarea>
<label><input type="radio" name="dossierlRating">Perfekt</label> <label><input type="radio" name="dossier" value="5">Perfekt</label>
<label><input type="radio" name="dossierRating">Makellos</label> <label><input type="radio" name="dossier" value="4">Makellos</label>
<label><input type="radio" name="dossierRating">regulär</label> <label><input type="radio" name="dossier" value="3">regulär</label>
<label><input type="radio" name="dossierRating">Makelhaft</label> <label><input type="radio" name="dossier" value="2">Makelhaft</label>
<label><input type="radio" name="dossierRating">Lädiert</label> <label><input type="radio" name="dossier" value="1">Lädiert</label>
</div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
Präsentation: <a href="#"><i class="fa fa-paperclip"></i></a> <div class="contributionRating" id="research">
<textarea id="presentationFeedback"> Präsentation: <a href="#"><i class="fa fa-paperclip"></i></a>
<textarea id="presentationFeedback">
meine Bewertung meine Bewertung
</textarea> </textarea>
<label><input type="radio" name="presentationRating">Perfekt</label> <label><input type="radio" name="research" value="5">Perfekt</label>
<label><input type="radio" name="presentationRating">Makellos</label> <label><input type="radio" name="research" value="4">Makellos</label>
<label><input type="radio" name="presentationRating">regulär</label> <label><input type="radio" name="research" value="3">regulär</label>
<label><input type="radio" name="presentationRating">Makelhaft</label> <label><input type="radio" name="research" value="2">Makelhaft</label>
<label><input type="radio" name="presentationRating">Lädiert</label> <label><input type="radio" name="research" value="1">Lädiert</label>
</div>
</td> </td>
</tr> </tr>
</table> </table>
......
...@@ -210,4 +210,39 @@ ALTER TABLE `projectuser` ...@@ -210,4 +210,39 @@ ALTER TABLE `projectuser`
ALTER TABLE `projectuser` ALTER TABLE `projectuser`
ADD UNIQUE (`projectId`, `userId`); ADD UNIQUE (`projectId`, `userId`);
ALTER TABLE `projects` ALTER TABLE `projects`
ADD UNIQUE (`id`); ADD UNIQUE (`id`);
\ No newline at end of file
CREATE TABLE if not exists answeredquiz (
`projectId` varchar(400) NOT NULL,
`studentId` varchar(400) NOT NULL,
`question` varchar(400) NOT NULL,
`correct` tinyint(4) NOT NULL
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
CREATE TABLE if not exists workrating (
`projectId` varchar(400) NOT NULL,
`studentId` varchar(400) NOT NULL,
`fromPeer` varchar(400) NOT NULL,
`responsibility` int(11) NOT NULL,
`partOfWork` int(11) NOT NULL,
`cooperation` int(11) NOT NULL,
`communication` int(11) NOT NULL,
`autonomous` int(11) NOT NULL
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
CREATE TABLE if not exists contributionrating (
`projectId` varchar(400) NOT NULL,
`studentId` varchar(400) NOT NULL,
`fromPeer` varchar(400) NOT NULL,
`dossier` int(11) NOT NULL,
`eJournal` int(11) NOT NULL,
`research` int(11) NOT NULL
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
\ No newline at end of file
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