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

fix: test phase4 works and DB-scheme updated

parent 82ee72aa
No related branches found
No related tags found
No related merge requests found
......@@ -23,11 +23,14 @@ public class PeerAssessment implements IPeerAssessment {
@Inject
private Management management;
@Inject
private AssessmentDBCommunication assessmentDBCommunication;
@Override
public void finalizeAssessment(String projectName){
cheatCheckerMethods method = new AssessmentDBCommunication().getAssessmentMethod(projectName);
cheatCheckerMethods method = assessmentDBCommunication.getAssessmentMethod(projectName);
Map<StudentIdentifier, Double> grading = calculateAssessment(projectName, method);
new AssessmentDBCommunication().writeGradesToDB(grading);
assessmentDBCommunication.writeGradesToDB(grading);
}
@Override//returns one quiz
......@@ -52,7 +55,7 @@ public class PeerAssessment implements IPeerAssessment {
@Override
public Double getAssessmentForStudent(StudentIdentifier student) {
return new AssessmentDBCommunication().getGradesFromDB(student);
return assessmentDBCommunication.getGradesFromDB(student);
}
@Override
......@@ -67,22 +70,22 @@ public class PeerAssessment implements IPeerAssessment {
@Override
public String whatToRate(StudentIdentifier student) {
Integer groupId = new AssessmentDBCommunication().getGroupByStudent(student);
ArrayList<String> groupMembers = new AssessmentDBCommunication().getStudentsByGroupAndProject(groupId, student.getProjectName());
Integer groupId = assessmentDBCommunication.getGroupByStudent(student);
ArrayList<String> groupMembers = assessmentDBCommunication.getStudentsByGroupAndProject(groupId, student.getProjectName());
for (String peer : groupMembers) {
if (!peer.equals(student.getUserEmail())) {
StudentIdentifier groupMember = new StudentIdentifier(student.getProjectName(), peer);
if (!new AssessmentDBCommunication().getWorkRating(groupMember, student.getUserEmail())) {
if (!assessmentDBCommunication.getWorkRating(groupMember, student.getUserEmail())) {
return "workRating";
}
}
}
ArrayList<Integer> answers = new AssessmentDBCommunication().getAnsweredQuizzes(student);
ArrayList<Integer> answers = assessmentDBCommunication.getAnsweredQuizzes(student);
if (answers == null) {
return "quiz";
}
Integer groupToRate = new AssessmentDBCommunication().getWhichGroupToRate(student);
if (!new AssessmentDBCommunication().getContributionRating(groupToRate, student.getUserEmail())) {
Integer groupToRate = assessmentDBCommunication.getWhichGroupToRate(student);
if (!assessmentDBCommunication.getContributionRating(groupToRate, student.getUserEmail())) {
return "contributionRating";
}
return "done";
......@@ -91,7 +94,7 @@ public class PeerAssessment implements IPeerAssessment {
@Override
public Map<StudentIdentifier, ConstraintsMessages> allAssessmentsDone(String projectName) {
Map<StudentIdentifier, ConstraintsMessages> result;
result = new AssessmentDBCommunication().missingAssessments(projectName);
result = assessmentDBCommunication.missingAssessments(projectName);
return result;
}
......@@ -121,22 +124,22 @@ public class PeerAssessment implements IPeerAssessment {
private Map<StudentIdentifier, Double> calculateAssessment(String projectName, cheatCheckerMethods method) {
ArrayList<Performance> totalPerformance = new ArrayList<>();
//get all students in projectID from DB
List<String> students = new AssessmentDBCommunication().getStudents(projectName);
List<String> students = assessmentDBCommunication.getStudents(projectName);
//for each student
for (String student : students) {
Integer groupId;
Performance performance = new Performance();
StudentIdentifier userNameentifier = new StudentIdentifier(projectName, student);
groupId = new AssessmentDBCommunication().getGroupByStudent(userNameentifier);
groupId = assessmentDBCommunication.getGroupByStudent(userNameentifier);
//todo: answered quizzes vervöllstandigen
Integer numberOfQuizzes = new AssessmentDBCommunication().getQuizCount(projectName);
List<Integer> answeredQuizzes = new AssessmentDBCommunication().getAnsweredQuizzes(userNameentifier);
Integer numberOfQuizzes = assessmentDBCommunication.getQuizCount(projectName);
List<Integer> answeredQuizzes = assessmentDBCommunication.getAnsweredQuizzes(userNameentifier);
for (Integer i=answeredQuizzes.size(); i<numberOfQuizzes;i++){
answeredQuizzes.add(0);
}
ArrayList<Map<String, Double>> workRating = new AssessmentDBCommunication().getWorkRating(userNameentifier);
ArrayList<Map<String, Double>> workRating = assessmentDBCommunication.getWorkRating(userNameentifier);
ArrayList<Map<String, Double>> contributionRating =
new AssessmentDBCommunication().getContributionRating(groupId);
assessmentDBCommunication.getContributionRating(groupId);
performance.setStudentIdentifier(userNameentifier);
performance.setQuizAnswer(answeredQuizzes);
performance.setWorkRating(cheatChecker(workRating, method));
......@@ -270,26 +273,26 @@ public class PeerAssessment implements IPeerAssessment {
public void postPeerRating(ArrayList<PeerRating> peerRatings, String projectName) {
for (PeerRating peer : peerRatings) {
StudentIdentifier student = new StudentIdentifier(projectName, peer.getToPeer());
new AssessmentDBCommunication().writeWorkRatingToDB(student, peer.getFromPeer(), peer.getWorkRating());
assessmentDBCommunication.writeWorkRatingToDB(student,peer.getFromPeer(), peer.getWorkRating());
}
}
@Override
public Integer whichGroupToRate(StudentIdentifier student) {
return new AssessmentDBCommunication().getWhichGroupToRate(student);
return assessmentDBCommunication.getWhichGroupToRate(student);
}
@Override
public void postContributionRating(String groupId,
String fromStudent,
Map<String, Integer> contributionRating) {
new AssessmentDBCommunication().writeContributionRatingToDB(groupId, fromStudent, contributionRating);
assessmentDBCommunication.writeContributionRatingToDB(groupId, fromStudent, contributionRating);
}
@Override
public void answerQuiz(Map<String, List<String>> questions, StudentIdentifier student) {
for (String question : questions.keySet()) {
Map<String, Boolean> whatAreAnswers = new AssessmentDBCommunication().getAnswers(student.getProjectName(), question);
Map<String, Boolean> whatAreAnswers = assessmentDBCommunication.getAnswers(student.getProjectName(), question);
Map<String, Boolean> wasQuestionAnsweredCorrectly = new HashMap<>();
Boolean correct = true;
for (String studentAnswer : questions.get(question)) {
......@@ -298,7 +301,7 @@ public class PeerAssessment implements IPeerAssessment {
}
}
wasQuestionAnsweredCorrectly.put(question, correct);
new AssessmentDBCommunication().writeAnsweredQuiz(student, wasQuestionAnsweredCorrectly);
assessmentDBCommunication.writeAnsweredQuiz(student, wasQuestionAnsweredCorrectly);
}
}
......
......@@ -10,7 +10,7 @@
<%@ taglib uri="../core/gemeinsamForschen.tld" prefix="menu" %>
<%@ taglib uri="../core/gemeinsamForschen.tld" prefix="omniDependencies" %>
<omniDependencies:omniDependencies hierarchy="1"></omniDependencies:omniDependencies>
<omniDependencies:omniDependencies hierarchy="1"/>
<script type="text/javascript" src="../libs/jQuery-Tags-Input-master/src/jquery.tagsinput.js"></script>
<html>
......
var allTheTags = [];
var projectToken = "";
let allTheTags = [];
let projectToken = "";
/**
* Created by fides-WHK on 19.02.2018.
......@@ -16,13 +16,13 @@ $(document).ready(function () {
// function that creates the project in the db
function createNewProject(allTheTags, activ) {
// again hiding the error messages
errorMessages()
errorMessages();
// getting the data from the form fields
var project = getProjectValues();
let project = getProjectValues();
// create the project
if (project) {
// create the project in local db
var localurl = "../../gemeinsamforschen/rest/project/create";
let localurl = "../../gemeinsamforschen/rest/project/create";
$.ajax({ //check local DB for existence of projectName
url: localurl,
contentType: 'application/json',
......@@ -75,20 +75,21 @@ function initTagsInput(allTheTags) {
function initSendButton(allTheTags) {
$('#sendProject').on('click', function () {
var activ = "1";
let activ = "1";
createNewProject(allTheTags, activ);
});
}
// it returns false and shows errors if input is not valid
function getProjectValues() {
var projectName = $("#nameProject").val().trim();
var password = $("#passwordProject").val().trim();
var adminPassword = $("#adminPassword").val().trim();
if (adminPassword == "") {
let projectName = $("#nameProject").val().trim();
let password = $("#passwordProject").val().trim();
let adminPassword = $("#adminPassword").val().trim();
if (adminPassword === "") {
adminPassword = "1234";
}
var reguexp = /^[a-zA-Z0-9äüöÄÜÖ\ ]+$/;
allTheTags = $("#tagsProject").tagsinput('items');
let reguexp = /^[a-zA-Z0-9äüöÄÜÖ\ ]+$/;
if (!reguexp.test(projectName)) {
$('#specialChars').show();
return false;
......@@ -105,8 +106,8 @@ function getProjectValues() {
}
// TODO find out author
var project = {
"id": projectName,
let project = {
"projectName": projectName,
"password": password,
"active": true,
"timecreated": null,
......@@ -115,21 +116,21 @@ function getProjectValues() {
"token": "",
"phase": "GroupFormation",
"tags": allTheTags
}
};
return project;
}
// creates project name in compbase where it is needed for learning goal oriented matching
function createProjectinCompbase(projectName) {
var url = compbaseUrl + "/api1/courses/" + $("#nameProject").val();
let url = compbaseUrl + "/api1/courses/" + $("#nameProject").val();
var obj = {
let obj = {
"courseId": projectName,
"printableName": projectName,
"competences": allTheTags
};
var dataString = JSON.stringify(obj);
var addProjectNeo4j = $.ajax({
let dataString = JSON.stringify(obj);
let addProjectNeo4j = $.ajax({
url: url,
contentType: 'application/json',
activ: true,
......
......@@ -80,7 +80,7 @@ CREATE TABLE IF NOT EXISTS `projects` (
`name` varchar(100) NOT NULL,
`password` varchar(400) NOT NULL,
`active` tinyint(1) NOT NULL,
`timecreated` long not null,
`timecreated` mediumtext not null,
`author` varchar(100) NOT NULL,
`adminPassword` varchar(400) NOT NULL,
`phase` varchar(400) NOT NULL,
......@@ -158,16 +158,45 @@ CREATE TABLE IF NOT EXISTS `workrating` (
`autonomous` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE if not exists `journals` (
`id` varchar(400) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP,
`userName` varchar(400) NOT NULL,
`projectName` varchar(400) NOT NULL,
`text` text,
`visibility` varchar(50),
`category` varchar(50),
`open` TINYINT(1)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
CREATE TABLE if not exists `projectDescription` (
`id` varchar(400) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP,
`userName` varchar(400) NOT NULL,
`projectName` varchar(400) NOT NULL,
`text` text,
`open` TINYINT(1)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
CREATE TABLE if not exists `links` (
`id` varchar(400) NOT NULL,
`projecdesription` varchar(400) NOT NULL,
`name` varchar(50) NOT NULL,
`link` varchar(50) NOT NULL
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
CREATE TABLE `projectdescription` ( `id` varchar(400) NOT NULL, `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `author` varchar(400) NOT NULL, `project` varchar(400) NOT NULL, `text` text, `open` tinyint(1) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8
Alter Table projectuser add FOREIGN KEY (`userEmail`) REFERENCES users(`email`);
Alter Table projectuser add FOREIGN KEY (`projectName`) REFERENCES projects(`name`);
ALTER TABLE groupuser add FOREIGN KEY (`userEmail`) REFERENCES users(`email`);
ALTER TABLE groupuser add FOREIGN KEY (`groupId`) REFERENCES groups(`id`);
ALTER TABLE projects add foreign key (`author`) REFERENCES users(`email`);
COMMIT;
ALTER TABLE projects add foreign key (`author`) REFERENCES users(`email`);
\ No newline at end of file
......@@ -43,42 +43,42 @@ CREATE TABLE if not exists `submissionpartbodyelements` (
PRIMARY KEY (`fullSubmissionId`, `category`, `startCharacter`, `endCharacter`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `answeredquiz` (
Create Table if not exists `answeredquiz` (
`projectName` varchar(400) NOT NULL,
`userName` varchar(400) NOT NULL,
`question` varchar(400) NOT NULL,
`correct` tinyint(4) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `contributionrating` (
Create Table if not exists `contributionrating` (
`groupId` int(11) NOT NULL,
`fromPeer` varchar(400) NOT NULL,
`dossier` int(11) NOT NULL,
`research` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `grades` (
Create Table if not exists `grades` (
`projectName` varchar(400) NOT NULL,
`userEmail` varchar(400) NOT NULL,
`grade` double NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `groups` (
Create Table if not exists `groups` (
`id` int(11) NOT NULL,
`projectName` varchar(400) NOT NULL,
`chatRoomId` varchar(400) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `groupuser` (
Create Table if not exists `groupuser` (
`userName` varchar(400) NOT NULL,
`projectName` varchar(400) NOT NULL,
`groupId` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `phasesselected` (
Create Table if not exists `phasesselected` (
`projectName` varchar(100) NOT NULL,
`phaseSelected` varchar(200) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `profilepicture` (
Create Table if not exists `profilepicture` (
`userName` varchar(200) NOT NULL,
`image` longblob NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `projects` (
Create Table if not exists `projects` (
`id` varchar(400) NOT NULL,
`password` varchar(400) NOT NULL,
`active` tinyint(1) NOT NULL,
......@@ -89,13 +89,13 @@ CREATE TABLE `projects` (
`phase` varchar(400) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `projectuser` (
Create Table if not exists `projectuser` (
`projectName` varchar(400) NOT NULL,
`useremail` varchar(400) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT;
`id` int(11) NOT NULL AUTO_INCREMENT
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `quiz` (
Create Table if not exists `quiz` (
`userName` varchar(400) NOT NULL,
`projectName` varchar(400) NOT NULL,
`question` varchar(400) NOT NULL,
......@@ -103,17 +103,17 @@ CREATE TABLE `quiz` (
`answer` varchar(400) NOT NULL,
`correct` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `tags` (
Create Table if not exists `tags` (
`projectName` varchar(400) NOT NULL,
`tag` varchar(400) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `tasks` (
Create Table if not exists `tasks` (
`userEmail` varchar(400) NOT NULL,
`projectName` varchar(400) NOT NULL,
`taskUrl` varchar(400) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `users` (
Create Table if not exists `users` (
`name` varchar(400) NOT NULL,
`password` varchar(200) NOT NULL,
`email` varchar(255) NOT NULL,
......@@ -125,7 +125,7 @@ CREATE TABLE `users` (
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
CREATE TABLE `workrating` (
Create Table if not exists `workrating` (
`projectName` varchar(400) NOT NULL,
`userName` varchar(400) NOT NULL,
`fromPeer` varchar(400) NOT NULL,
......@@ -136,6 +136,51 @@ CREATE TABLE `workrating` (
`autonomous` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `projectdescription` (
`id` varchar(400) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`author` varchar(400) NOT NULL,
`projectName` varchar(400) NOT NULL,
`text` text,
`open` tinyint(1) DEFAULT NULL
)
CREATE TABLE if not exists `journals` (
`id` varchar(400) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP,
`userName` varchar(400) NOT NULL,
`projectName` varchar(400) NOT NULL,
`text` text,
`visibility` varchar(50),
`category` varchar(50),
`open` TINYINT(1)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
CREATE TABLE if not exists `projectDescription` (
`id` varchar(400) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP,
`userName` varchar(400) NOT NULL,
`projectName` varchar(400) NOT NULL,
`text` text,
`open` TINYINT(1)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
CREATE TABLE if not exists `links` (
`id` varchar(400) NOT NULL,
`projecdesription` varchar(400) NOT NULL,
`name` varchar(50) NOT NULL,
`link` varchar(50) NOT NULL
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
ALTER TABLE `groups`
ADD PRIMARY KEY (`id`);
......@@ -147,5 +192,5 @@ ALTER TABLE `users`
ALTER TABLE `groups`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT
COMMIT;
\ 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