diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/ManagementImpl.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/ManagementImpl.java index c86b8aa6d5db95159640747c314b4ba141c0fbae..e644878dcdff5f89c64804e3974f9b3d2e91d477 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/ManagementImpl.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/ManagementImpl.java @@ -1,5 +1,6 @@ package unipotsdam.gf.core.management; +import sun.misc.IOUtils; import unipotsdam.gf.core.database.mysql.MysqlConnect; import unipotsdam.gf.core.database.mysql.VereinfachtesResultSet; import unipotsdam.gf.core.management.group.Group; @@ -15,6 +16,9 @@ import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; import javax.annotation.ManagedBean; import javax.annotation.Resource; import javax.inject.Singleton; +import java.io.File; +import java.io.FileInputStream; +import java.sql.Blob; import java.sql.Timestamp; import java.util.ArrayList; import java.util.List; @@ -171,8 +175,10 @@ public class ManagementImpl implements Management { String adminPassword = vereinfachtesResultSet.getString("adminpassword"); String token = vereinfachtesResultSet.getString("token"); String phase = vereinfachtesResultSet.getString("phase"); - - return new Project(id, password, active, timestamp, author, adminPassword, token); + Project project = new Project(id, password, active, timestamp, author, adminPassword, token); + ProjectPhase projectPhase = ProjectPhase.valueOf(phase); + project.setPhase(projectPhase); + return project; } private Group getGroupFromResultSet(VereinfachtesResultSet vereinfachtesResultSet) { @@ -236,6 +242,9 @@ public class ManagementImpl implements Management { @Override public Project getProjectById(String id) { + if (id == null){ + return null; + } MysqlConnect connect = new MysqlConnect(); connect.connect(); String mysqlRequest = "SELECT * FROM projects where id = ?"; @@ -309,4 +318,13 @@ public class ManagementImpl implements Management { ProjectConfigurationDAO projectConfigurationDAO = new ProjectConfigurationDAO(); return projectConfigurationDAO.loadProjectConfiguration(project); } + + public String saveProfilePicture(FileInputStream image, String studentId){ + MysqlConnect connect = new MysqlConnect(); + connect.connect(); + Blob blobbedImage= (Blob) image; + String mysqlRequest = "INSERT INTO `profilepicture`(`studentId`, `image`) VALUES (?,?)"; + connect.issueInsertOrDeleteStatement(mysqlRequest, studentId, blobbedImage); + return "success"; + } } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/pageAppearance/Menu.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/pageAppearance/Menu.java new file mode 100644 index 0000000000000000000000000000000000000000..894babb0db1b7e6ba876ae5f0c700a9a0065792a --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/pageAppearance/Menu.java @@ -0,0 +1,112 @@ +package unipotsdam.gf.core.management.pageAppearance; + +import unipotsdam.gf.core.management.ManagementImpl; +import unipotsdam.gf.core.management.user.User; +import unipotsdam.gf.core.states.ProjectPhase; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.jsp.JspWriter; +import javax.servlet.jsp.PageContext; +import javax.servlet.jsp.tagext.SimpleTagSupport; +import java.io.IOException; + +public class Menu extends SimpleTagSupport { + public void doTag() throws IOException { + PageContext pageContext = (PageContext) getJspContext(); + HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); + String token = request.getParameter("token"); + String projectId = request.getParameter("projectId"); + ManagementImpl management = new ManagementImpl(); + ProjectPhase projectPhase; + try{ + projectPhase = management.getProjectById(projectId).getPhase(); + }catch(Exception e){ + projectPhase = null; + } + JspWriter out = getJspContext().getOut(); + if (token!=null){ + User user = management.getUserByToken(token); + Boolean isStudent = user.getStudent(); + if (isStudent){ + String menuString = "<div id=\"sidebar-wrapper\">\n" + + " <ul class=\"sidebar-nav\">\n" + + " <li class=\"sidebar-brand\"><a href=\"overview-student.jsp?token="+token+"&projectId="+projectId+"\">overview</a></li>\n" + + " <li><a href=\"profile.jsp?token="+token+"&projectId="+projectId+"\">Profil</a></li>\n"; + if (projectPhase!=null){ + if (projectPhase.equals(ProjectPhase.CourseCreation)){ + menuString += " <li><p>Quizfrage</p></li>\n" + + " <li><a href=\"eportfolio.jsp?token="+token+"&projectId="+projectId+"\">ePortfolio</a></li>\n" + + " <li><p>Beitrag</p></li>\n" + + " <li><p>Bewertung</p></li>\n"; + } + if (projectPhase.equals(ProjectPhase.GroupFormation)){ + menuString += " <li><p>Quizfrage</p></li>\n" + + " <li><a href=\"eportfolio.jsp?token="+token+"&projectId="+projectId+"\">ePortfolio</a></li>\n" + + " <li><p>Beitrag</p></li>\n" + + " <li><p>Bewertung</p></li>\n"; + } + if (projectPhase.equals(ProjectPhase.DossierFeedback)){ + menuString += " <li><p>Quizfrage</p></li>\n" + + " <li><a href=\"eportfolio.jsp?token="+token+"&projectId="+projectId+"\">ePortfolio</a></li>\n" + + " <li><a href=\"researchReportTitle.jsp?token="+token+"&projectId="+projectId+"\">Beitrag</a></li>\n" + + " <li><p>Bewertung</p></li>\n"; + } + if (projectPhase.equals(ProjectPhase.Execution)){ + menuString += " <li><a href=\"Quiz.jsp?token="+token+"&projectId="+projectId+"\">Quizfrage</a></li>\n" + + " <li><a href=\"eportfolio.jsp?token="+token+"&projectId="+projectId+"\">ePortfolio</a></li>\n" + + " <li><a href=\"researchReportTitle.jsp?token="+token+"&projectId="+projectId+"\">Beitrag</a></li>\n" + + " <li><p>Bewertung</p></li>\n"; + } + if (projectPhase.equals(ProjectPhase.Assessment)){ + menuString += " <li><p>Quizfrage</p></li>\n" + + " <li><p>ePortfolio</p></li>\n" + + " <li><p>Beitrag</p></li>\n" + + " <li><a id=\"assessment\" style=\"cursor:pointer\">Bewertung</a></li>\n"; + } + } + + menuString +="<li>" + + "<a id=\"logout\" style=\"cursor:pointer\">Logout</a></li>\n" + + "</ul>\n" + + " </div>"; + out.println(menuString); + out.println("<p id=\"userRole\" hidden>isStudent</p>"); + } else { + String menuString ="<div id=\"sidebar-wrapper\">\n" + + " <ul class=\"sidebar-nav\">\n" + + " <li class=\"sidebar-brand\"><a href=\"overview-docent.jsp?token="+token+"&projectId="+projectId+"\">overview</a></li>\n"; + if (projectPhase!=null) { + if (!projectPhase.equals(ProjectPhase.GroupFormation)) { + menuString += "<li><a href=\"Quiz-docent.jsp?token="+token+"&projectId="+projectId+"\">Quizfrage</a></li>\n" + + " <li><p>Gruppen erstellen</p></li>\n" + + " <li><a href=\"changePhase.jsp?token="+token+"&projectId="+projectId+"\">Projektphase ändern</a></li>\n"; + }else { + menuString += "<li><a href=\"Quiz-docent.jsp?token="+token+"&projectId="+projectId+"\">Quizfrage</a></li>\n" + + " <li><a href=\"createGroups.jsp?token="+token+"&projectId="+projectId+"\">Gruppen erstellen</a></li>\n" + + " <li><a href=\"changePhase.jsp?token="+token+"&projectId="+projectId+"\">Projektphase ändern</a></li>\n"; + } + } + menuString +="<li><a id=\"logout\" style=\"cursor:pointer\">Logout</a></li>\n" + + "</ul>\n" + + " </div>"; + out.println(menuString); + out.println("<p id=\"userRole\" hidden>isDocent</p>"); + } + }else{ + out.println("<div class='alert alert-warning'>" + + "You probably did not give the token to the url" + + "</div>"); + //in active System this will be the point to redirect to index.jsp, because token is "wrong" + } + if (projectId!=null) + out.println("<p id=\"projectId\" hidden>"+projectId+"</p>"); + User user = management.getUserByToken(token); + if (user != null) + out.println("<p id=\"user\" hidden>"+user.getName()+"</p>"); + + + + } + + +} \ No newline at end of file diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/pageAppearance/footer.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/pageAppearance/footer.java new file mode 100644 index 0000000000000000000000000000000000000000..29d366cb5ad8af659610937da34707c4c70d6628 --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/pageAppearance/footer.java @@ -0,0 +1,54 @@ +package unipotsdam.gf.core.management.pageAppearance; + +import unipotsdam.gf.core.management.ManagementImpl; +import unipotsdam.gf.core.states.ProjectPhase; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.jsp.JspWriter; +import javax.servlet.jsp.PageContext; +import javax.servlet.jsp.tagext.SimpleTagSupport; +import java.io.IOException; + +public class footer extends SimpleTagSupport { + public void doTag() throws IOException { + PageContext pageContext = (PageContext) getJspContext(); + HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); + String projectId = request.getParameter("projectId"); + ManagementImpl management = new ManagementImpl(); + ProjectPhase projectPhase; + try { + projectPhase = management.getProjectById(projectId).getPhase(); + } catch (Exception e) { + projectPhase = null; + } + JspWriter out = getJspContext().getOut(); + String footerString = "<footer>\n" + + " <div class=\"container\">\n"; + if (projectPhase != null) { + footerString += " <div class=\"progress\">\n" + + " <div class=\"progress-bar pg-" + projectPhase.toString().trim() + "\" role=\"progressbar\" id=\"progressbar\">\n" + + " </div>\n" + + " <div>\n"; + if (projectPhase.equals(ProjectPhase.GroupFormation)) + footerString +=" GroupFormation\n"; + if (projectPhase.equals(ProjectPhase.Execution)) + footerString +=" Execution\n"; + if (projectPhase.equals(ProjectPhase.Assessment)) + footerString +=" Assessment\n"; + if (projectPhase.equals(ProjectPhase.DossierFeedback)) + footerString +=" DossierFeedback\n"; + if (projectPhase.equals(ProjectPhase.Projectfinished)) + footerString +=" Projectfinished\n"; + footerString +=" </div>\n" + + " <div class=\"progress-bar pg-rest\" role=\"progressbar\">\n" + + " </div>\n" + + " </div>\n"; + } + + footerString += "<button id=\"btnUnstructuredUpload\" class=\"btn btn-light\">Unstrukturierte Abgabe</button>\n" + + "<button id=\"footerBack\" class=\"btn btn-light\">zurück</button>\n" + + " </div>\n" + + " </footer>"; + out.println(footerString); + } +} \ No newline at end of file diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/user/headLine.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/pageAppearance/headLine.java similarity index 95% rename from gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/user/headLine.java rename to gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/pageAppearance/headLine.java index 087a26f8dfd29728abc9de226ef1511a26c59c82..36f2e74bcc9ebd0708ee4225d60a6c54a0a22a52 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/user/headLine.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/pageAppearance/headLine.java @@ -1,16 +1,16 @@ -package unipotsdam.gf.core.management.user; +package unipotsdam.gf.core.management.pageAppearance; import unipotsdam.gf.core.management.ManagementImpl; +import unipotsdam.gf.core.management.user.User; import javax.servlet.http.HttpServletRequest; -import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.SimpleTagSupport; import java.io.IOException; public class headLine extends SimpleTagSupport { - public void doTag() throws JspException, IOException { + public void doTag() throws IOException { PageContext pageContext = (PageContext) getJspContext(); HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); String projectId = request.getParameter("projectId"); @@ -58,6 +58,4 @@ public class headLine extends SimpleTagSupport { " </table>\n" + " </div>"); } - - -}; \ No newline at end of file +} \ No newline at end of file diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/user/omniDependencies.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/pageAppearance/omniDependencies.java similarity index 73% rename from gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/user/omniDependencies.java rename to gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/pageAppearance/omniDependencies.java index e4b3272b2dac3479a79f5271598981a0e04db3d6..ac6ce6fcd31cfc5ae79f42c26bc644404077970d 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/user/omniDependencies.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/pageAppearance/omniDependencies.java @@ -1,17 +1,11 @@ -package unipotsdam.gf.core.management.user; +package unipotsdam.gf.core.management.pageAppearance; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspWriter; -import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.SimpleTagSupport; import java.io.IOException; public class omniDependencies extends SimpleTagSupport { - public void doTag() throws JspException, IOException { - PageContext pageContext = (PageContext) getJspContext(); - HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); - String projectId = request.getParameter("projectId"); + public void doTag() throws IOException { JspWriter out = getJspContext().getOut(); out.println("<meta charset=\"utf-8\">\n" + " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n" + @@ -28,8 +22,6 @@ public class omniDependencies extends SimpleTagSupport { " <script src=\"../assets/js/utility.js\"></script>\n" + " <script src=\"../assets/js/footer.js\"></script>\n" + " <link rel=\"stylesheet\" href=\"https://use.fontawesome.com/releases/v5.1.0/css/all.css\"\n" + - " integrity=\"sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt\" crossorigin=\"anonymous\">"); + " integrity=\"sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt\" crossorigin=\"anonymous\">"); } - - -}; \ No newline at end of file +} \ No newline at end of file diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/project/Project.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/project/Project.java index 2fb7b840289b1b9056c7da73329bb2bbef6de38d..b329533304fc335bc6c0ccf69d8d8d577e15ad09 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/project/Project.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/project/Project.java @@ -19,7 +19,7 @@ public class Project { private String adminPassword; private String token; // using enum ProjectPhase - private String phase; + private ProjectPhase phase; public Project() { } @@ -35,7 +35,7 @@ public class Project { this.setPhase(ProjectPhase.CourseCreation); } - public String getPhase() { + public ProjectPhase getPhase() { return phase; } @@ -44,7 +44,7 @@ public class Project { * @param phase */ public void setPhase(ProjectPhase phase) { - this.phase = phase.name(); + this.phase = phase; } public Project(String id, String password, Boolean active, String author, String adminPassword, String token) { diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/user/UserService.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/user/UserService.java index c457c47cbc5f6e5a115d7d44fc9fe4cb59858e12..d5ecb66497c7e4d5588e945c3bc04de7c69019ae 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/user/UserService.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/management/user/UserService.java @@ -1,17 +1,20 @@ package unipotsdam.gf.core.management.user; +import org.glassfish.grizzly.streams.BufferedInput; import unipotsdam.gf.core.management.ManagementImpl; +import unipotsdam.gf.core.states.ProjectPhase; import unipotsdam.gf.interfaces.ICommunication; import unipotsdam.gf.modules.communication.service.CommunicationDummyService; import javax.annotation.ManagedBean; import javax.inject.Inject; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import java.awt.image.BufferedImage; +import java.awt.image.BufferedImageOp; +import java.io.File; +import java.io.FileInputStream; import java.net.URI; import java.net.URISyntaxException; @@ -72,7 +75,20 @@ public class UserService { } else { return loginError(); } + } + @POST + @Produces(MediaType.TEXT_PLAIN) + @Path("/student/{studentId}") + public String getQuiz(@FormParam("image") File file, @PathParam("studentId") String studentId) { + ManagementImpl management = new ManagementImpl(); + try{ + FileInputStream fis = new FileInputStream(file); + + return management.saveProfilePicture(fis, studentId); + }catch(Exception e){ + return e.toString(); + } } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/PhasesImpl.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/PhasesImpl.java index 7bcf8a20fdb75120b33e7dae2b5cba48013ec3d7..ed289b311cfa75b30f22102953bd3ea80d17b49e 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/PhasesImpl.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/PhasesImpl.java @@ -46,16 +46,16 @@ public class PhasesImpl implements IPhases { } @Override - public void endPhase(ProjectPhase currentPhase, Project project) { - switch (currentPhase) { + public void endPhase(ProjectPhase changeToPhase, Project project) { + switch (changeToPhase) { case CourseCreation: // saving the state - saveState(project,getNextPhase(currentPhase)); + saveState(project,changeToPhase); break; case GroupFormation: // inform users about the formed groups, optionally giving them a hint on what happens next iCommunication.sendMessageToUsers(project, Messages.GroupFormation(project)); - saveState(project,getNextPhase(currentPhase)); + saveState(project,changeToPhase); break; case DossierFeedback: // check if everybody has uploaded a dossier @@ -65,7 +65,7 @@ public class PhasesImpl implements IPhases { } else { // send a message to the users informing them about the start of the new phase iCommunication.sendMessageToUsers(project, Messages.NewFeedbackTask(project)); - saveState(project,getNextPhase(currentPhase)); + saveState(project,changeToPhase); } break; case Execution: @@ -74,7 +74,7 @@ public class PhasesImpl implements IPhases { if (portfoliosReady) { // inform users about the end of the phase iCommunication.sendMessageToUsers(project, Messages.AssessmentPhaseStarted(project)); - saveState(project,getNextPhase(currentPhase)); + saveState(project,changeToPhase); } else { iJournal.assignMissingPortfolioTasks(project); } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/PhasesService.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/PhasesService.java index e3ad42205b6ae45070ae70f643a9f6e662757a18..c0d45a7532c298206bfd8a3ef371cfd5ae4381a0 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/PhasesService.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/PhasesService.java @@ -1,6 +1,7 @@ package unipotsdam.gf.core.states; import unipotsdam.gf.core.management.Management; +import unipotsdam.gf.core.management.ManagementImpl; import unipotsdam.gf.core.management.project.Project; import unipotsdam.gf.interfaces.IPhases; @@ -15,11 +16,9 @@ import javax.ws.rs.core.MediaType; @Path("/phases") public class PhasesService { - @Inject - private IPhases phases; + private IPhases phases = new PhasesImpl(); - @Inject - private Management management; + private Management management = new ManagementImpl(); /** * end phase @@ -38,10 +37,10 @@ public class PhasesService { * @param projectId * @return */ - @Path("/{projectPhase}/projects/{projectId}") + @Path("/projects/{projectId}") @GET - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Produces({MediaType.TEXT_PLAIN}) public String getCurrentPhase(@PathParam("projectId") String projectId) { - return management.getProjectById(projectId).getPhase(); + return management.getProjectById(projectId).getPhase().toString(); } } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/ProjectPhase.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/ProjectPhase.java index 328b415f28a8379e81258b79eb671e16614e0417..ba8bffad7c29716ddfd9bbb5f049e3f19b0241c4 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/ProjectPhase.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/ProjectPhase.java @@ -2,5 +2,5 @@ package unipotsdam.gf.core.states; public enum ProjectPhase { CourseCreation, GroupFormation, DossierFeedback, Execution, Assessment, - Projectfinished; + Projectfinished } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/configPhaseShift.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/configPhaseShift.java new file mode 100644 index 0000000000000000000000000000000000000000..b988f6f75f45b5bc04929a0cfe2d93b2fabd85a1 --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/core/states/configPhaseShift.java @@ -0,0 +1,11 @@ +package unipotsdam.gf.core.states; + +public class configPhaseShift { + Boolean DossierWritten; + Integer FeedbackCount =1; + Integer QuizCount =10; + Integer JournalCount=5; + Boolean DossierFinalized; + Boolean JournalFinalized; + Boolean AssessmentDone; +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/IAnnotation.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/IAnnotation.java index d8957a0d393696650cc86ad0216d05ea68bcfa65..0378153de66a916d195a5b498f4654a88d49d671 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/IAnnotation.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/IAnnotation.java @@ -3,6 +3,7 @@ package unipotsdam.gf.interfaces; import unipotsdam.gf.modules.annotation.model.Annotation; import unipotsdam.gf.modules.annotation.model.AnnotationPatchRequest; import unipotsdam.gf.modules.annotation.model.AnnotationPostRequest; +import unipotsdam.gf.modules.peer2peerfeedback.Category; import java.util.ArrayList; @@ -44,12 +45,13 @@ public interface IAnnotation { Annotation getAnnotation(String annotationId); /** - * Returns all annotations from a target + * Returns all annotations for a specific target id and category * - * @param targetId the target id - * @return Returns all annotations + * @param targetId The if of the target + * @param targetCategory The category of the target + * @return Returns all annotations for a target */ - ArrayList<Annotation> getAnnotations(int targetId); + ArrayList<Annotation> getAnnotations(String targetId, Category targetCategory); /** * Checks if an annotation id already exists in the database diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/IJournal.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/IJournal.java index 1750b873a33a184cee3e9a1b911ab48ea53c4762..e53ddc887eac0127b51f629a31e14e7fc76586d6 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/IJournal.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/IJournal.java @@ -3,13 +3,10 @@ package unipotsdam.gf.interfaces; import unipotsdam.gf.core.management.project.Project; import unipotsdam.gf.core.management.user.User; -import unipotsdam.gf.assignments.NotImplementedLogger; -import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; -import unipotsdam.gf.modules.journal.model.EPorfolio; +import unipotsdam.gf.modules.journal.model.EPortfolio; import unipotsdam.gf.modules.journal.model.Journal; import unipotsdam.gf.modules.researchreport.ResearchReport; -import javax.swing.text.html.HTML; import java.io.File; import java.util.List; @@ -19,13 +16,6 @@ import java.util.List; public interface IJournal { - /** - * Exports the learning journal - * @param student StudentIdentifier - * @return the journal as String (may change) - */ - String exportJournal (StudentIdentifier student) ; - /** * check if all students have prepared their portfolios to be evaluated * @return @@ -64,5 +54,5 @@ public interface IJournal { * @return EPortfolio (containing Report, ProjectDescription and Journal) */ - EPorfolio getFinalPortfolioForAssessment(Project project, User user) ; + EPortfolio getFinalPortfolioForAssessment(Project project, User user) ; } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/IPeerAssessment.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/IPeerAssessment.java index d2109728546943d36eed575156a7af37f5e3309b..b07b990870b655615e72a1447eb09df9df642e98 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/IPeerAssessment.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/IPeerAssessment.java @@ -1,6 +1,5 @@ package unipotsdam.gf.interfaces; -import unipotsdam.gf.modules.assessment.QuizAnswer; import unipotsdam.gf.modules.assessment.controller.model.*; import java.util.ArrayList; @@ -19,7 +18,7 @@ public interface IPeerAssessment { */ void addAssessmentDataToDB(Assessment assessment); - Quiz getQuiz(String projectId, String groupId, String author); + Quiz getQuiz(String projectId, String quizId, String author); /** * will return a saved assessment from the DB * @@ -76,7 +75,14 @@ public interface IPeerAssessment { */ void postPeerRating(ArrayList<PeerRating> peerRatings, String projectId); - void postContributionRating(StudentIdentifier student, + /** + * + * @param student + * @return + */ + Integer whichGroupToRate(StudentIdentifier student); + + void postContributionRating(String groupId, String fromPeer, Map<String, Integer> contributionRating); @@ -88,5 +94,6 @@ public interface IPeerAssessment { void answerQuiz(Map<String, List<String>> questions, StudentIdentifier student); void deleteQuiz(String quizId); + String whatToRate(StudentIdentifier student); Map<StudentIdentifier, Double> calculateAssessment(String projectId, String method); } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/ISubmission.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/ISubmission.java new file mode 100644 index 0000000000000000000000000000000000000000..01a450025cfcf1e1cddf4b6b8bc059ffb29da3a0 --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/interfaces/ISubmission.java @@ -0,0 +1,80 @@ +package unipotsdam.gf.interfaces; + +import unipotsdam.gf.modules.peer2peerfeedback.Category; +import unipotsdam.gf.modules.submission.model.*; + +import java.util.ArrayList; + +/** + * @author Sven Kästle + * skaestle@uni-potsdam.de + */ +public interface ISubmission { + + /** + * Store the full submission text in the database + * + * @param request The full submission post request + * @return The new full submission + */ + FullSubmission addFullSubmission(FullSubmissionPostRequest request); + + /** + * Get the entire submission from the databse + * + * @param fullSubmissionId The id of the submission + * @return The full submission + */ + FullSubmission getFullSubmission(String fullSubmissionId); + + /** + * Checks if a full submission id already exists in the database + * + * @param fullSubmissionId The id of the full submission + * @return Returns true if the id exists + */ + boolean existsFullSubmissionId(String fullSubmissionId); + + /** + * Store the submission part text in the database + * + * @param submissionPartPostRequest The submission part post request + * @return The new submission part + */ + SubmissionPart addSubmissionPart(SubmissionPartPostRequest submissionPartPostRequest); + + /** + * Get the entire submission part from database + * + * @param fullSubmissionId The id of the full submission + * @param category The category of the submission + * @return The returned submission part + */ + SubmissionPart getSubmissionPart(String fullSubmissionId, Category category); + + /** + * Get all submission parts based on an id + * + * @param fullSubmissionId The id of a full submission + * @return An ArrayList holding the submission parts + */ + ArrayList<SubmissionPart> getAllSubmissionParts(String fullSubmissionId); + + /** + * Get all project representations of submission part for a given project id + * + * @param projectId The given project id + * @return An ArrayList of submission project representations + */ + ArrayList<SubmissionProjectRepresentation> getSubmissionPartsByProjectId(String projectId); + + /** + * Checks if a submission part already exists in the database + * + * @param fullSubmissionId The id of the full submission + * @param category The category of the submission + * @return Returns true if the submission part exists + */ + boolean existsSubmissionPart(String fullSubmissionId, Category category); + +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/controller/AnnotationController.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/controller/AnnotationController.java index ce29362c3f10354b41d3802bd945d638e62b52c9..394ccf69df9e554a136704c2221a0f4e1b3a4bfe 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/controller/AnnotationController.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/controller/AnnotationController.java @@ -7,6 +7,7 @@ import unipotsdam.gf.modules.annotation.model.Annotation; import unipotsdam.gf.modules.annotation.model.AnnotationBody; import unipotsdam.gf.modules.annotation.model.AnnotationPatchRequest; import unipotsdam.gf.modules.annotation.model.AnnotationPostRequest; +import unipotsdam.gf.modules.peer2peerfeedback.Category; import java.time.ZonedDateTime; import java.util.ArrayList; @@ -27,8 +28,8 @@ public class AnnotationController implements IAnnotation { connection.connect(); // build and execute request - String request = "INSERT INTO annotations (`id`, `userToken`, `targetId`, `title`, `comment`, `startCharacter`, `endCharacter`) VALUES (?,?,?,?,?,?,?);"; - connection.issueInsertOrDeleteStatement(request, uuid, annotationPostRequest.getUserToken(), annotationPostRequest.getTargetId(), annotationPostRequest.getBody().getTitle(), annotationPostRequest.getBody().getComment(),annotationPostRequest.getBody().getStartCharacter(), annotationPostRequest.getBody().getEndCharacter()); + String request = "INSERT INTO annotations (`id`, `userToken`, `targetId`, `targetCategory`, `title`, `comment`, `startCharacter`, `endCharacter`) VALUES (?,?,?,?,?,?,?,?);"; + connection.issueInsertOrDeleteStatement(request, uuid, annotationPostRequest.getUserToken(), annotationPostRequest.getTargetId(), annotationPostRequest.getTargetCategory().toString().toUpperCase(), annotationPostRequest.getBody().getTitle(), annotationPostRequest.getBody().getComment(),annotationPostRequest.getBody().getStartCharacter(), annotationPostRequest.getBody().getEndCharacter()); // close connection connection.close(); @@ -104,7 +105,7 @@ public class AnnotationController implements IAnnotation { } @Override - public ArrayList<Annotation> getAnnotations(int targetId) { + public ArrayList<Annotation> getAnnotations(String targetId, Category category) { // declare annotation ArrayList ArrayList<Annotation> annotations = new ArrayList<>(); @@ -114,8 +115,8 @@ public class AnnotationController implements IAnnotation { connection.connect(); // build and execute request - String request = "SELECT * FROM annotations WHERE targetId = ?;"; - VereinfachtesResultSet rs = connection.issueSelectStatement(request, targetId); + String request = "SELECT * FROM annotations WHERE targetId = ? AND targetCategory = ?;"; + VereinfachtesResultSet rs = connection.issueSelectStatement(request, targetId, category.toString().toUpperCase()); while (rs.next()) { annotations.add(getAnnotationFromResultSet(rs)); @@ -171,7 +172,8 @@ public class AnnotationController implements IAnnotation { String id = rs.getString("id"); long timestamp = rs.getTimestamp(2).getTime(); String userToken = rs.getString("userToken"); - int targetId = rs.getInt("targetId"); + String targetId = rs.getString("targetId"); + Category targetCategory = Category.valueOf(rs.getString("targetCategory")); // initialize new annotation body String title = rs.getString("title"); @@ -180,7 +182,7 @@ public class AnnotationController implements IAnnotation { int endCharacter = rs.getInt("endCharacter"); AnnotationBody body = new AnnotationBody(title, comment, startCharacter, endCharacter); - return new Annotation(id, timestamp, userToken, targetId, body); + return new Annotation(id, timestamp, userToken, targetId, targetCategory, body); } } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/model/Annotation.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/model/Annotation.java index 699ec3eda8ad469fda08b6688311fabb9a17bc5b..950959d31d5820e480aeefb57852c9dbecb4cfa4 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/model/Annotation.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/model/Annotation.java @@ -1,5 +1,7 @@ package unipotsdam.gf.modules.annotation.model; +import unipotsdam.gf.modules.peer2peerfeedback.Category; + /** * @author Sven Kästle * skaestle@uni-potsdam.de @@ -10,15 +12,17 @@ public class Annotation { private String id; private long timestamp; private String userToken; - private int targetId; + private String targetId; + private Category targetCategory; private AnnotationBody body; // constructor - public Annotation(String id, long timestamp, String userToken, int targetId, AnnotationBody body) { + public Annotation(String id, long timestamp, String userToken, String targetId, Category targetCategory, AnnotationBody body) { this.id = id; this.timestamp = timestamp; this.userToken = userToken; this.targetId = targetId; + this.targetCategory = targetCategory; this.body = body; } @@ -47,14 +51,22 @@ public class Annotation { this.userToken = userToken; } - public int getTargetId() { + public String getTargetId() { return targetId; } - public void setTargetId(int targetId) { + public void setTargetId(String targetId) { this.targetId = targetId; } + public Category getTargetCategory() { + return targetCategory; + } + + public void setTargetCategory(Category targetCategory) { + this.targetCategory = targetCategory; + } + public AnnotationBody getBody() { return body; } @@ -70,6 +82,7 @@ public class Annotation { ", timestamp=" + timestamp + ", userToken='" + userToken + '\'' + ", targetId=" + targetId + + ", targetCategory=" + targetCategory + ", body=" + body + '}'; } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/model/AnnotationMessage.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/model/AnnotationMessage.java index 60d895b66b293668f4b505684a46d75ebea88dbe..f8e3f913afcdae8ec44cfe720eb26165bcd296f4 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/model/AnnotationMessage.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/model/AnnotationMessage.java @@ -1,9 +1,12 @@ package unipotsdam.gf.modules.annotation.model; +import unipotsdam.gf.modules.peer2peerfeedback.Category; + public class AnnotationMessage { // variables private String from; private String targetId; + private Category targetCategory; private AnnotationMessageType type; private String annotationId; @@ -30,6 +33,14 @@ public class AnnotationMessage { this.targetId = targetId; } + public Category getTargetCategory() { + return targetCategory; + } + + public void setTargetCategory(Category targetCategory) { + this.targetCategory = targetCategory; + } + public AnnotationMessageType getType() { return type; } @@ -51,8 +62,10 @@ public class AnnotationMessage { return "AnnotationMessage{" + "from='" + from + '\'' + ", targetId='" + targetId + '\'' + + ", targetCategory=" + targetCategory + ", type=" + type + ", annotationId='" + annotationId + '\'' + '}'; } + } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/model/AnnotationPostRequest.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/model/AnnotationPostRequest.java index 5dfe6e206f1f014eb3ce88fbc22e401323b2c422..1ae3c2b6b5137b7877367c3342b1f2eaab7584f4 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/model/AnnotationPostRequest.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/model/AnnotationPostRequest.java @@ -1,5 +1,7 @@ package unipotsdam.gf.modules.annotation.model; +import unipotsdam.gf.modules.peer2peerfeedback.Category; + /** * @author Sven Kästle * skaestle@uni-potsdam.de @@ -8,13 +10,15 @@ public class AnnotationPostRequest { // variables private String userToken; - private int targetId; + private String targetId; + private Category targetCategory; private AnnotationBody body; // constructors - public AnnotationPostRequest(String userToken, int targetId, AnnotationBody body) { + public AnnotationPostRequest(String userToken, String targetId, Category targetCategory, AnnotationBody body) { this.userToken = userToken; this.targetId = targetId; + this.targetCategory = targetCategory; this.body = body; } @@ -30,14 +34,22 @@ public class AnnotationPostRequest { this.userToken = userToken; } - public int getTargetId() { + public String getTargetId() { return targetId; } - public void setTargetId(int targetId) { + public void setTargetId(String targetId) { this.targetId = targetId; } + public Category getTargetCategory() { + return targetCategory; + } + + public void setTargetCategory(Category targetCategory) { + this.targetCategory = targetCategory; + } + public AnnotationBody getBody() { return body; } @@ -51,8 +63,9 @@ public class AnnotationPostRequest { return "AnnotationPostRequest{" + "userToken='" + userToken + '\'' + ", targetId=" + targetId + - ", body=" + body.toString() + + ", targetCategory=" + targetCategory + + ", body=" + body + '}'; } - + } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/view/AnnotationService.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/view/AnnotationService.java index 1072cd55891857bc8fa1d2d9ece561f5b105da81..9a4656e6dc7098c0c7563a57a162ef5d3bc782ae 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/view/AnnotationService.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/view/AnnotationService.java @@ -6,6 +6,7 @@ import unipotsdam.gf.modules.annotation.model.Annotation; import unipotsdam.gf.modules.annotation.model.AnnotationPatchRequest; import unipotsdam.gf.modules.annotation.model.AnnotationPostRequest; import unipotsdam.gf.modules.annotation.model.AnnotationResponse; +import unipotsdam.gf.modules.peer2peerfeedback.Category; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; @@ -108,12 +109,12 @@ public class AnnotationService { } @GET - @Path("/target/{id}") - public Response getAnnotations(@PathParam("id") int targetId) { + @Path("/targetid/{id}/targetcategory/{category}") + public Response getAnnotations(@PathParam("id") String targetId, @PathParam("category") String category) { // receive the annotation AnnotationController controller = new AnnotationController(); - ArrayList<Annotation> annotations = controller.getAnnotations(targetId); + ArrayList<Annotation> annotations = controller.getAnnotations(targetId, Category.valueOf(category.toUpperCase())); if (!annotations.isEmpty()) { return Response.ok(annotations).build(); diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/websocket/AnnotationWSTarget.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/websocket/AnnotationWSTarget.java new file mode 100644 index 0000000000000000000000000000000000000000..09409309c304231d50a4e472cba639dd60d5dd6a --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/websocket/AnnotationWSTarget.java @@ -0,0 +1,46 @@ +package unipotsdam.gf.modules.annotation.websocket; + +import unipotsdam.gf.modules.peer2peerfeedback.Category; + +/** + * @author Sven Kästle + * skaestle@uni-potsdam.de + */ +public class AnnotationWSTarget { + + // variables + String targetId; + Category targetCategory; + + // constructor + public AnnotationWSTarget(String targetId, Category targetCategory) { + this.targetId = targetId; + this.targetCategory = targetCategory; + } + + // methods + public String getTargetId() { + return targetId; + } + + public void setTargetId(String targetId) { + this.targetId = targetId; + } + + public Category getTargetCategory() { + return targetCategory; + } + + public void setTargetCategory(Category targetCategory) { + this.targetCategory = targetCategory; + } + + @Override + public String toString() { + return "AnnotationWSTarget{" + + "targetId='" + targetId + '\'' + + ", targetCategory=" + targetCategory.toString() + + '}'; + } + +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/websocket/AnnotationWebSocketEndpoint.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/websocket/AnnotationWebSocketEndpoint.java index 29c2d3f61ebc6da8e99be59dfdff206c8e1810b0..b30743913672d6770337c6d4b5ca5dcebfeda1a5 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/websocket/AnnotationWebSocketEndpoint.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/annotation/websocket/AnnotationWebSocketEndpoint.java @@ -1,6 +1,7 @@ package unipotsdam.gf.modules.annotation.websocket; import unipotsdam.gf.modules.annotation.model.AnnotationMessage; +import unipotsdam.gf.modules.peer2peerfeedback.Category; import javax.websocket.*; import javax.websocket.server.PathParam; @@ -10,26 +11,27 @@ import java.util.HashMap; import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; -@ServerEndpoint(value = "/ws/annotation/{targetId}", decoders = AnnotationMessageDecoder.class, encoders = AnnotationMessageEncoder.class) +@ServerEndpoint(value = "/ws/annotation/{targetId}/{targetCategory}", decoders = AnnotationMessageDecoder.class, encoders = AnnotationMessageEncoder.class) public class AnnotationWebSocketEndpoint { private Session session; private static final Set<AnnotationWebSocketEndpoint> endpoints = new CopyOnWriteArraySet<>(); - private static HashMap<String, String> targets = new HashMap<>(); + private static HashMap<String, AnnotationWSTarget> targets = new HashMap<>(); @OnOpen - public void onOpen(Session session, @PathParam("targetId") String targetId) throws IOException { + public void onOpen(Session session, @PathParam("targetId") String targetId, @PathParam("targetCategory") String targetCategory) throws IOException { // initialize session this.session = session; // save endpoint in set of endpoints endpoints.add(this); - // save mapping of session and target id - targets.put(session.getId(), targetId); + // save mapping of session and target (id + category) + targets.put(session.getId(), new AnnotationWSTarget(targetId, Category.valueOf(targetCategory.toUpperCase()))); } @OnMessage public void onMessage(Session session, AnnotationMessage annotationMessage) throws IOException, EncodeException { - annotationMessage.setTargetId(targets.get(session.getId())); + annotationMessage.setTargetId(targets.get(session.getId()).getTargetId()); + annotationMessage.setTargetCategory(targets.get(session.getId()).getTargetCategory()); annotationMessage.setFrom(session.getId()); broadcast(annotationMessage); @@ -49,7 +51,8 @@ public class AnnotationWebSocketEndpoint { endpoints.forEach(endpoint -> { synchronized (endpoint) { try { - if (targets.get(endpoint.session.getId()).equals(annotationMessage.getTargetId()) + if (targets.get(endpoint.session.getId()).getTargetId().equals(annotationMessage.getTargetId()) + && targets.get(endpoint.session.getId()).getTargetCategory() == annotationMessage.getTargetCategory() && !endpoint.session.getId().equals(annotationMessage.getFrom())) { System.out.println("Send message to session" + endpoint.session.getId() + " from session " + annotationMessage.getFrom()); endpoint.session.getBasicRemote().sendObject(annotationMessage); diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/model/Categories.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/model/Categories.java index 2937b2e3766b6fc3a15fd4595e2878d540dea5cd..66608a7d713d6dde0db06566e77a13313f7ed80b 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/model/Categories.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/model/Categories.java @@ -16,8 +16,7 @@ public class Categories { ); public static final List<String> contributionRatingCategories = Collections.unmodifiableList( new ArrayList<String>() {{ - add("Dossier"); - add("eJournal"); + add("dossier"); add("research"); }} ); diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/model/Performance.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/model/Performance.java index c5bdd8cb17e438fcfc4865cb9e97de9476b7a325..4f97bdb7384a3e37deb26bf85e60d31573c027d4 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/model/Performance.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/model/Performance.java @@ -1,6 +1,5 @@ package unipotsdam.gf.modules.assessment.controller.model; -import java.util.Arrays; import java.util.List; import java.util.Map; diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/AssessmentDBCommunication.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/AssessmentDBCommunication.java index c5e803245536598c1664156205fb56e1067eb4b2..5f05a39f3c6c9920be80265daa497acbbba0e849 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/AssessmentDBCommunication.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/AssessmentDBCommunication.java @@ -36,6 +36,15 @@ class AssessmentDBCommunication { return result; } + Boolean getWorkRating(StudentIdentifier student, String fromStudent){ + MysqlConnect connect = new MysqlConnect(); + connect.connect(); + String mysqlRequest = "SELECT * FROM `workrating` WHERE `projectId`=? AND `studentId`=? AND `fromPeer`=?"; + VereinfachtesResultSet vereinfachtesResultSet = + connect.issueSelectStatement(mysqlRequest, student.getProjectId(), student.getStudentId(), fromStudent); + return vereinfachtesResultSet.next(); + } + List<String> getStudents(String projectID) { List<String> result = new ArrayList<>(); MysqlConnect connect = new MysqlConnect(); @@ -51,13 +60,40 @@ class AssessmentDBCommunication { return result; } - ArrayList<Map<String, Double>> getContributionRating(StudentIdentifier student) { - ArrayList<Map<String, Double>> result = new ArrayList<>(); + Integer getGroupByStudent(StudentIdentifier student) { + Integer result; MysqlConnect connect = new MysqlConnect(); connect.connect(); - String mysqlRequest = "SELECT * FROM `contributionrating` WHERE `projectId`=? AND `studentId`=?"; + String mysqlRequest = "SELECT groupId FROM `groupuser` WHERE `projectId`=? AND `studentId`=?"; VereinfachtesResultSet vereinfachtesResultSet = connect.issueSelectStatement(mysqlRequest, student.getProjectId(), student.getStudentId()); + vereinfachtesResultSet.next(); + result = vereinfachtesResultSet.getInt("groupId"); + return result; + } + + ArrayList<String> getStudentsByGroupAndProject(Integer groupId, String projectId){ + ArrayList<String> result = new ArrayList<>(); + MysqlConnect connect = new MysqlConnect(); + connect.connect(); + String mysqlRequest = "SELECT * FROM `groupuser` WHERE `groupId`=? AND `projectId`=?"; + VereinfachtesResultSet vereinfachtesResultSet = + connect.issueSelectStatement(mysqlRequest, groupId, projectId); + Boolean next = vereinfachtesResultSet.next(); + while (next){ + result.add(vereinfachtesResultSet.getString("studentId")); + next = vereinfachtesResultSet.next(); + } + return result; + } + + ArrayList<Map<String, Double>> getContributionRating(Integer groupId) { + ArrayList<Map<String, Double>> result = new ArrayList<>(); + MysqlConnect connect = new MysqlConnect(); + connect.connect(); + String mysqlRequest = "SELECT * FROM `contributionrating` WHERE `groupId`=?"; + VereinfachtesResultSet vereinfachtesResultSet = + connect.issueSelectStatement(mysqlRequest, groupId); boolean next = vereinfachtesResultSet.next(); while (next) { Map<String, Double> contributionRating = new HashMap<>(); @@ -71,6 +107,15 @@ class AssessmentDBCommunication { return result; } + Boolean getContributionRating(Integer groupId, String fromStudent) { + MysqlConnect connect = new MysqlConnect(); + connect.connect(); + String mysqlRequest = "SELECT * FROM `contributionrating` WHERE `groupId`=? AND `fromPeer`=?"; + VereinfachtesResultSet vereinfachtesResultSet = + connect.issueSelectStatement(mysqlRequest, groupId, fromStudent); + return vereinfachtesResultSet.next(); + } + ArrayList<Integer> getAnsweredQuizzes(StudentIdentifier student) { ArrayList<Integer> result = new ArrayList<>(); MysqlConnect connect = new MysqlConnect(); @@ -122,23 +167,49 @@ class AssessmentDBCommunication { connect.close(); } - void writeContributionRatingToDB(StudentIdentifier student, String fromStudent, Map<String, Integer> contributionRating) { + Integer getWhichGroupToRate(StudentIdentifier student){ + Integer result; + MysqlConnect connect = new MysqlConnect(); + connect.connect(); + String mysqlRequest1 = "SELECT groupId FROM `groupuser` WHERE `projectId`=? AND `studentId`=? "; + VereinfachtesResultSet vereinfachtesResultSet1 = + connect.issueSelectStatement(mysqlRequest1, student.getProjectId(),student.getStudentId()); + vereinfachtesResultSet1.next(); + Integer groupId = vereinfachtesResultSet1.getInt("groupId"); + + String mysqlRequest2 = "SELECT DISTINCT groupId FROM `groupuser` WHERE `projectId`=? "; + VereinfachtesResultSet vereinfachtesResultSet2 = + connect.issueSelectStatement(mysqlRequest2, student.getProjectId()); + Boolean next = vereinfachtesResultSet2.next(); + result = vereinfachtesResultSet2.getInt("groupId"); + while(next){ + if (vereinfachtesResultSet2.getInt("groupId") == groupId){ + next = vereinfachtesResultSet2.next(); + if (next){ + result = vereinfachtesResultSet2.getInt("groupId"); + } + }else{ + next = vereinfachtesResultSet2.next(); + } + + } + connect.close(); + return result; + } + + void writeContributionRatingToDB(String groupId, String fromStudent, Map<String, Integer> contributionRating) { MysqlConnect connect = new MysqlConnect(); connect.connect(); String mysqlRequest = "INSERT INTO `contributionrating`(" + - "`studentId`, " + - "`projectId`, " + + "`groupId`, " + "`fromPeer`, " + "`dossier`, " + - "`eJournal`, " + "`research`) " + - "VALUES (?,?,?,?,?,?)"; + "VALUES (?,?,?,?)"; connect.issueInsertOrDeleteStatement(mysqlRequest, - student.getStudentId(), - student.getProjectId(), + groupId, fromStudent, contributionRating.get("dossier"), - contributionRating.get("eJournal"), contributionRating.get("research") ); connect.close(); @@ -156,7 +227,7 @@ class AssessmentDBCommunication { connect.close(); } - public Map<String, Boolean> getAnswers(String projectId, String question) { + Map<String, Boolean> getAnswers(String projectId, String question) { MysqlConnect connect = new MysqlConnect(); connect.connect(); Map<String, Boolean> result = new HashMap<>(); diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/FBAssessement.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/FBAssessement.java index ef9dd768e6d5890a7790156a62a5aa6b44986c30..8283f9a231c6c558032e108968a4386d379d9b8c 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/FBAssessement.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/FBAssessement.java @@ -1,6 +1,5 @@ package unipotsdam.gf.modules.assessment.controller.service; -import unipotsdam.gf.modules.assessment.QuizAnswer; import unipotsdam.gf.modules.assessment.controller.model.*; import java.util.ArrayList; @@ -61,7 +60,12 @@ public class FBAssessement extends AssessmentDAO { } @Override - public void postContributionRating(StudentIdentifier student, String fromStudent, Map<String, Integer> contributionRating) { + public Integer whichGroupToRate(StudentIdentifier student) { + return null; + } + + @Override + public void postContributionRating(String groupId, String fromStudent, Map<String, Integer> contributionRating) { } @@ -75,6 +79,11 @@ public class FBAssessement extends AssessmentDAO { } + @Override + public String whatToRate(StudentIdentifier student) { + return null; + } + @Override public Map<StudentIdentifier, Double> calculateAssessment(String projectId, String method) { return null; diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/PeerAssessment.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/PeerAssessment.java index 820adb76b897dc5028f45c13e8aba944aa6a09fc..d65c047ccced3756dd13292542eac5f58f09f901 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/PeerAssessment.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/PeerAssessment.java @@ -1,8 +1,6 @@ package unipotsdam.gf.modules.assessment.controller.service; -import unipotsdam.gf.core.management.user.User; import unipotsdam.gf.interfaces.IPeerAssessment; -import unipotsdam.gf.modules.assessment.QuizAnswer; import unipotsdam.gf.modules.assessment.controller.model.*; import java.util.*; @@ -38,6 +36,29 @@ public class PeerAssessment implements IPeerAssessment { new QuizDBCommunication().deleteQuiz(quizId); } + @Override + public String whatToRate(StudentIdentifier student) { + Integer groupId = new AssessmentDBCommunication().getGroupByStudent(student); + ArrayList<String> groupMembers = new AssessmentDBCommunication().getStudentsByGroupAndProject(groupId, student.getProjectId()); + for (String peer: groupMembers){ + if (!peer.equals(student.getStudentId())){ + StudentIdentifier groupMember = new StudentIdentifier(student.getProjectId(), peer); + if (!new AssessmentDBCommunication().getWorkRating(groupMember, student.getStudentId())){ + return "workRating"; + } + } + } + ArrayList<Integer> answers = new AssessmentDBCommunication().getAnsweredQuizzes(student); + if (answers==null){ + return "quiz"; + } + Integer groupToRate = new AssessmentDBCommunication().getWhichGroupToRate(student); + if (!new AssessmentDBCommunication().getContributionRating(groupToRate, student.getStudentId())){ + return "contributionRating"; + } + return "done"; + } + @Override public Map<StudentIdentifier, Double> calculateAssessment(ArrayList<Performance> totalPerformance) { Map<StudentIdentifier, Double> quizMean = new HashMap<>(quizGrade(totalPerformance)); @@ -64,11 +85,14 @@ public class PeerAssessment implements IPeerAssessment { List<String> students = new AssessmentDBCommunication().getStudents(projectId); //for each student for (String student : students) { + Integer groupId; Performance performance = new Performance(); StudentIdentifier studentIdentifier = new StudentIdentifier(projectId, student); + groupId = new AssessmentDBCommunication().getGroupByStudent(studentIdentifier); 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); + ArrayList<Map<String, Double>> contributionRating = + new AssessmentDBCommunication().getContributionRating(groupId); performance.setStudentIdentifier(studentIdentifier); performance.setQuizAnswer(answeredQuizzes); performance.setWorkRating(cheatChecker(workRating, cheatCheckerMethods.variance)); @@ -208,10 +232,15 @@ public class PeerAssessment implements IPeerAssessment { } @Override - public void postContributionRating(StudentIdentifier student, + public Integer whichGroupToRate(StudentIdentifier student) { + return new AssessmentDBCommunication().getWhichGroupToRate(student); + } + + @Override + public void postContributionRating(String groupId, String fromStudent, Map<String, Integer> contributionRating) { - new AssessmentDBCommunication().writeContributionRatingToDB(student, fromStudent, contributionRating); + new AssessmentDBCommunication().writeContributionRatingToDB(groupId, fromStudent, contributionRating); } @Override diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/PeerAssessmentDummy.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/PeerAssessmentDummy.java index 78291cecd72583f82ec78bc02859cbf36ec4a01b..74bac433e2e831ea9fe23b6d18a754c66490e517 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/PeerAssessmentDummy.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/service/PeerAssessmentDummy.java @@ -3,7 +3,6 @@ package unipotsdam.gf.modules.assessment.controller.service; import unipotsdam.gf.assignments.Assignee; import unipotsdam.gf.assignments.NotImplementedLogger; import unipotsdam.gf.interfaces.IPeerAssessment; -import unipotsdam.gf.modules.assessment.QuizAnswer; import unipotsdam.gf.modules.assessment.controller.model.*; import java.util.*; @@ -66,7 +65,12 @@ public class PeerAssessmentDummy implements IPeerAssessment { } @Override - public void postContributionRating(StudentIdentifier student, String fromStudent, Map<String, Integer> contributionRating) { + public Integer whichGroupToRate(StudentIdentifier student) { + return null; + } + + @Override + public void postContributionRating(String groupId, String fromStudent, Map<String, Integer> contributionRating) { } @@ -80,6 +84,11 @@ public class PeerAssessmentDummy implements IPeerAssessment { } + @Override + public String whatToRate(StudentIdentifier student) { + return null; + } + @Override public Map<StudentIdentifier, Double> calculateAssessment(String projectId, String method) { return null; diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/view/QuizView.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/view/QuizView.java index e41b15a6dda0f0a60aa833c0682112d82e3edc4a..1a484981db9ba3e13241412482670db23acd32af 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/view/QuizView.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/assessment/controller/view/QuizView.java @@ -1,10 +1,14 @@ package unipotsdam.gf.modules.assessment.controller.view; +import unipotsdam.gf.core.management.Management; +import unipotsdam.gf.core.management.ManagementImpl; import unipotsdam.gf.interfaces.IPeerAssessment; +import unipotsdam.gf.interfaces.IPhases; import unipotsdam.gf.modules.assessment.QuizAnswer; import unipotsdam.gf.modules.assessment.controller.model.*; import unipotsdam.gf.modules.assessment.controller.service.PeerAssessment; +import javax.inject.Inject; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import java.io.IOException; @@ -39,6 +43,7 @@ public class QuizView { } //////////////////////////////////////////funktioniert/////////////////////////////////////// + @POST @Consumes(MediaType.APPLICATION_JSON) @Path("/peerRating/project/{projectId}") @@ -46,15 +51,22 @@ public class QuizView { peer.postPeerRating(peerRatings, projectId); } + @GET + @Produces(MediaType.APPLICATION_JSON) + @Path("/groupRate/project/{projectId}/student/{studentId}") + public Integer whichGroupToRate(@PathParam("projectId") String projectId, @PathParam("studentId") String studentId) + { + StudentIdentifier student = new StudentIdentifier(projectId,studentId); + return peer.whichGroupToRate(student); + } + @POST @Consumes(MediaType.APPLICATION_JSON) - @Path("/contributionRating/projectId/{projectId}/studentId/{studentId}/fromPeer/{fromPeer}") + @Path("/contributionRating/group/{groupId}/fromPeer/{fromPeer}") public void postContributionRating(Map<String, Integer> contributionRatings, - @PathParam("projectId") String projectId, - @PathParam("studentId") String studentId, + @PathParam("groupId") String groupId, @PathParam("fromPeer") String fromPeer) throws IOException { - StudentIdentifier student = new StudentIdentifier(projectId, studentId); - peer.postContributionRating(student, fromPeer, contributionRatings); + peer.postContributionRating(groupId, fromPeer, contributionRatings); } @POST @@ -77,6 +89,15 @@ public class QuizView { } } + @GET + @Produces(MediaType.TEXT_HTML) + @Path("/whatToRate/project/{projectId}/student/{studentId}") + public String whatToRate(@PathParam("projectId") String projectId, @PathParam("studentId") String studentId) + { + StudentIdentifier student = new StudentIdentifier(projectId,studentId); + return peer.whatToRate(student); + } + @POST @Produces(MediaType.TEXT_PLAIN) @Consumes(MediaType.APPLICATION_JSON) @@ -140,7 +161,7 @@ public class QuizView { return getTotalAssessment(studentIdentifier); } //////////dummy/////////////funktioniert wie geplant////////////////////////////////// - public ArrayList<Performance> getTotalAssessment(StudentIdentifier studentIdentifier) { + private ArrayList<Performance> getTotalAssessment(StudentIdentifier studentIdentifier) { return peer.getTotalAssessment(studentIdentifier); } /////////dummy/////////////funktioniert wie geplant////////////////////////////////// @@ -193,5 +214,4 @@ public class QuizView { result.add(pf2); return result; } /////////dummy////////////returns what i expect it to return!!!!!////////////////////////////////// - } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/groupfinding/GroupfindingImpl.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/groupfinding/GroupfindingImpl.java index 8987f63c3863e21673bbf067fccced65dbff08ed..78f8621f3d2b9ba1fbaffc207a8970e05b56cb17 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/groupfinding/GroupfindingImpl.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/groupfinding/GroupfindingImpl.java @@ -3,7 +3,11 @@ package unipotsdam.gf.modules.groupfinding; import unipotsdam.gf.core.management.group.Group; import unipotsdam.gf.core.management.project.Project; import unipotsdam.gf.interfaces.IGroupFinding; +import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; +import unipotsdam.gf.modules.groupfinding.service.GroupCreationService; +import unipotsdam.gf.modules.groupfinding.service.GroupDAO; +import java.util.ArrayList; import java.util.List; public class GroupfindingImpl implements IGroupFinding { @@ -27,4 +31,8 @@ public class GroupfindingImpl implements IGroupFinding { public void formGroups(GroupFormationMechanism groupFindingMechanism) { } + + public ArrayList<String> getStudentsInSameGroup(StudentIdentifier student){ + return new GroupDAO().getStudentsInSameGroupAs(student); + } } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/groupfinding/service/GroupDAO.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/groupfinding/service/GroupDAO.java new file mode 100644 index 0000000000000000000000000000000000000000..ffa94b4e83f1e00ff63e59692c956bc19e70403d --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/groupfinding/service/GroupDAO.java @@ -0,0 +1,34 @@ +package unipotsdam.gf.modules.groupfinding.service; + +import unipotsdam.gf.core.database.mysql.MysqlConnect; +import unipotsdam.gf.core.database.mysql.VereinfachtesResultSet; +import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; + +import java.util.ArrayList; + +public class GroupDAO { + + public ArrayList<String> getStudentsInSameGroupAs(StudentIdentifier student) { + MysqlConnect connect = new MysqlConnect(); + connect.connect(); + ArrayList<String> result = new ArrayList<>(); + Integer groupId; + String mysqlRequest1 = "SELECT groupId FROM `groupuser` WHERE `projectId`=? AND `studentId`=?"; + VereinfachtesResultSet vereinfachtesResultSet1 = + connect.issueSelectStatement(mysqlRequest1, student.getProjectId(), student.getStudentId()); + vereinfachtesResultSet1.next(); + groupId = vereinfachtesResultSet1.getInt("groupId"); + String mysqlRequest2 = "SELECT * FROM `groupuser` WHERE `groupId`=?"; + VereinfachtesResultSet vereinfachtesResultSet2 = + connect.issueSelectStatement(mysqlRequest2, groupId); + boolean next2 = vereinfachtesResultSet2.next(); + while(next2){ + String peer = vereinfachtesResultSet2.getString("studentId"); + if (!peer.equals( student.getStudentId())) + result.add(peer); + next2=vereinfachtesResultSet2.next(); + } + connect.close(); + return result; + } +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/groupfinding/view/GroupView.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/groupfinding/view/GroupView.java new file mode 100644 index 0000000000000000000000000000000000000000..0a9f8c6602e980ec97825126b7f322cad1bb9719 --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/groupfinding/view/GroupView.java @@ -0,0 +1,24 @@ +package unipotsdam.gf.modules.groupfinding.view; + +import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; +import unipotsdam.gf.modules.groupfinding.GroupfindingImpl; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import java.io.IOException; +import java.util.ArrayList; + +@Path("/group") +public class GroupView { + private GroupfindingImpl groupfinding = new GroupfindingImpl(); + + @GET + @Produces(MediaType.APPLICATION_JSON) + @Path("/project/{projectId}/student/{studentId}") + public ArrayList<String> getStudentsInSameGroup(@PathParam("projectId") String projectId, @PathParam("studentId") String studentId) throws IOException { + //peer.postPeerRating(peerRatings, projectId); + StudentIdentifier student = new StudentIdentifier(projectId, studentId); + return groupfinding.getStudentsInSameGroup(student); + } + +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/DummyJournalImpl.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/DummyJournalImpl.java deleted file mode 100644 index 50da0c81b96dd2a5501eab940ce84682ac2d72c8..0000000000000000000000000000000000000000 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/DummyJournalImpl.java +++ /dev/null @@ -1,59 +0,0 @@ -package unipotsdam.gf.modules.journal; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import unipotsdam.gf.core.management.project.Project; -import unipotsdam.gf.core.management.user.User; -import unipotsdam.gf.assignments.Assignee; -import unipotsdam.gf.assignments.NotImplementedLogger; -import unipotsdam.gf.interfaces.IJournal; -import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; -import unipotsdam.gf.modules.journal.model.EPorfolio; -import unipotsdam.gf.modules.journal.model.Journal; -import unipotsdam.gf.modules.researchreport.ResearchReport; - -import javax.swing.text.html.HTML; -import java.io.File; -import java.util.List; - -public class DummyJournalImpl implements IJournal { - - - private Logger log = LoggerFactory.getLogger(DummyJournalImpl.class); - - @Override - public String exportJournal(StudentIdentifier student) { - NotImplementedLogger.logAssignment(Assignee.THOMAS, IJournal.class); - return null; - } - - @Override - public Boolean getPortfoliosForEvaluationPrepared(Project project) { - NotImplementedLogger.logAssignment(Assignee.THOMAS, IJournal.class); - return false; - } - - @Override - public void assignMissingPortfolioTasks(Project project) { - NotImplementedLogger.logAssignment(Assignee.THOMAS, IJournal.class); - } - - @Override - public void uploadJournalEntry(Journal journalEntry, User student) { - NotImplementedLogger.logAssignment(Assignee.THOMAS, IJournal.class); - } - - @Override - public void uploadFinalPortfolio( - Project project, List<Journal> journalEntries, ResearchReport finalResearchReport, File presentation, - User user) { - NotImplementedLogger.logAssignment(Assignee.THOMAS, IJournal.class); - } - - @Override - public EPorfolio getFinalPortfolioForAssessment( - Project project, User user) { - NotImplementedLogger.logAssignment(Assignee.THOMAS, IJournal.class); - return null; - } -} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/EPorfolio.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/EPortfolio.java similarity index 61% rename from gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/EPorfolio.java rename to gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/EPortfolio.java index 1377afb417a9b58a14ef68d4c0524daf2aa63f9a..be23df134dd8e3f8f8c56d6c04f5e118fba3bf01 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/EPorfolio.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/EPortfolio.java @@ -9,21 +9,21 @@ import java.util.ArrayList; * Class for passing e-portfolio to assessment */ -public class EPorfolio { +public class EPortfolio { - StudentIdentifier student; - ProjectDescription descrition; - ArrayList<Journal> journals; - ResearchReport report; - //TODO mehr? + private StudentIdentifier student; + private ProjectDescription description; + private ArrayList<Journal> journals; + private ResearchReport report; - public EPorfolio() { + + public EPortfolio() { } - public EPorfolio(StudentIdentifier student, ProjectDescription descrition, ArrayList<Journal> journals, ResearchReport report) { + public EPortfolio(StudentIdentifier student, ProjectDescription description, ArrayList<Journal> journals, ResearchReport report) { this.student = student; - this.descrition = descrition; + this.description = description; this.journals = journals; this.report = report; } @@ -36,12 +36,12 @@ public class EPorfolio { this.student = student; } - public ProjectDescription getDescrition() { - return descrition; + public ProjectDescription getDescription() { + return description; } - public void setDescrition(ProjectDescription descrition) { - this.descrition = descrition; + public void setDescription(ProjectDescription description) { + this.description = description; } public ArrayList<Journal> getJournals() { diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/Journal.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/Journal.java index 499c53d55036a3618d391d74052d0524c1d3be19..7c098dbb1aac9b0aa9f9a7aca2db9b54ab889d28 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/Journal.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/Journal.java @@ -9,7 +9,7 @@ import java.util.Date; import static unipotsdam.gf.view.MarkdownUtils.convertMarkdownToHtml; /** - * Model Class for the learnig journal of the e-portfolio + * Model Class for the learning journal of the e-portfolio */ public class Journal { diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/Link.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/Link.java index 2a4b7e63cb02c70f5f58bfe78f519e5d4b2298da..1d7d8006da568b5e497305f3b19f48328e308715 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/Link.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/Link.java @@ -2,10 +2,10 @@ package unipotsdam.gf.modules.journal.model; public class Link { - String id; - String projectDescription; - String name; - String link; + private String id; + private String projectDescription; + private String name; + private String link; public Link() { } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/ProjectDescription.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/ProjectDescription.java index d1e0558be5e4e8fe473137a497be85416c13c8a9..aad24cdcafd882b5dc7288323e7a7358c8400535 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/ProjectDescription.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/ProjectDescription.java @@ -1,10 +1,9 @@ package unipotsdam.gf.modules.journal.model; -import unipotsdam.gf.core.management.project.Project; import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; import java.util.ArrayList; -import java.util.Map; +import java.util.Date; import static unipotsdam.gf.view.MarkdownUtils.convertMarkdownToHtml; @@ -20,34 +19,32 @@ public class ProjectDescription { private String descriptionMD; private boolean open; private ArrayList<Link> links; - private ArrayList<String> group; private long timestamp; public ProjectDescription() { } - public ProjectDescription(String id, String name, String description, String project, ArrayList<Link> links, ArrayList<String> group, long timestamp) { + public ProjectDescription(String id, String name, String description, String project, ArrayList<Link> links) { this.id = id; - this.student = new StudentIdentifier(project,name); + this.student = new StudentIdentifier(project, name); this.descriptionHTML = convertMarkdownToHtml(description); - this.descriptionMD =description; + this.descriptionMD = description; this.links = links; - this.group = group; - this.timestamp = timestamp; - this.open =true; + this.timestamp = new Date().getTime(); + this.open = true; } - public ProjectDescription(String id, String name, String description, String project, ArrayList<Link> links, ArrayList<String> group, long timestamp, boolean open) { + + public ProjectDescription(String id, String name, String description, String project, ArrayList<Link> links, long timestamp, boolean open) { this.id = id; - this.student = new StudentIdentifier(project,name); + this.student = new StudentIdentifier(project, name); this.descriptionHTML = convertMarkdownToHtml(description); - this.descriptionMD =description; + this.descriptionMD = description; this.links = links; - this.group = group; this.timestamp = timestamp; this.open = open; } - public void setDescription (String description){ + public void setDescription(String description) { this.descriptionMD = description; this.descriptionHTML = convertMarkdownToHtml(description); } @@ -100,14 +97,6 @@ public class ProjectDescription { this.links = links; } - public ArrayList<String> getGroup() { - return group; - } - - public void setGroup(ArrayList<String> group) { - this.group = group; - } - public long getTimestamp() { return timestamp; } @@ -125,7 +114,6 @@ public class ProjectDescription { ", descriptionMD='" + descriptionMD + '\'' + ", open=" + open + ", links=" + links + - ", group=" + group + ", timestamp=" + timestamp + '}'; } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/JournalDAO.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/JournalDAO.java index f9ff960168c8515ae8c188aa2e3d87bb85d74be6..56a0943a832f092b74676dc6a5133f573404df7b 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/JournalDAO.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/JournalDAO.java @@ -1,5 +1,6 @@ package unipotsdam.gf.modules.journal.model.dao; +import unipotsdam.gf.core.management.project.Project; import unipotsdam.gf.modules.journal.model.Journal; import unipotsdam.gf.modules.journal.model.JournalFilter; @@ -16,10 +17,11 @@ public interface JournalDAO { Journal getJournal(String id); - ArrayList<Journal> getAllByProject(String project); + ArrayList<Journal> getAllByProject(String project, String student); ArrayList<Journal> getAllByProjectAndFilter(String project, String student, JournalFilter filter); void closeJournal(String id); + ArrayList<String> getOpenJournals(Project project); } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/JournalDAOImpl.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/JournalDAOImpl.java index 1c5ce831a639be436e37f2cbc7dce58bd1eebc34..0ea368909eb9cdb4679bf36b77d51ea11dc490e6 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/JournalDAOImpl.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/JournalDAOImpl.java @@ -2,6 +2,7 @@ package unipotsdam.gf.modules.journal.model.dao; import unipotsdam.gf.core.database.mysql.MysqlConnect; import unipotsdam.gf.core.database.mysql.VereinfachtesResultSet; +import unipotsdam.gf.core.management.project.Project; import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; import unipotsdam.gf.modules.journal.model.Journal; import unipotsdam.gf.modules.journal.model.JournalFilter; @@ -95,7 +96,7 @@ public class JournalDAOImpl implements JournalDAO { } @Override - public ArrayList<Journal> getAllByProject(String project) { + public ArrayList<Journal> getAllByProject(String project, String student) { ArrayList<Journal> journals = new ArrayList<>(); @@ -104,8 +105,8 @@ public class JournalDAOImpl implements JournalDAO { connection.connect(); // build and execute request - String request = "SELECT * FROM journals WHERE project= ?;"; - VereinfachtesResultSet rs = connection.issueSelectStatement(request, project); + String request = "SELECT * FROM journals WHERE project= ? AND (author = ? OR visibility = \"ALL\" or visibility = \"GROUP\");"; + VereinfachtesResultSet rs = connection.issueSelectStatement(request, project, student); while (rs.next()) { journals.add(getJournalFromResultSet(rs)); @@ -144,7 +145,7 @@ public class JournalDAOImpl implements JournalDAO { @Override public ArrayList<Journal> getAllByProjectAndFilter(String project, String student, JournalFilter filter) { if (filter == JournalFilter.ALL) { - return getAllByProject(project); + return getAllByProject(project, student); } else { return getAllByStudent(student); } @@ -165,6 +166,29 @@ public class JournalDAOImpl implements JournalDAO { connection.close(); } + @Override + public ArrayList<String> getOpenJournals(Project project) { + ArrayList<String> userIds = new ArrayList<>(); + + // establish connection + MysqlConnect connection = new MysqlConnect(); + connection.connect(); + + // build and execute request + String request = "SELECT * FROM journals WHERE project = ? AND open = ?;"; + VereinfachtesResultSet rs = connection.issueSelectStatement(request, project.getId(), true); + + while (rs.next()) { + userIds.add(getJournalFromResultSet(rs).getStudentIdentifier().getStudentId()); + } + + // close connection + connection.close(); + + return userIds; + + } + /** * extracts a journal from VereinfachtesResultSet * diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/LinkDAOImpl.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/LinkDAOImpl.java index f78a69f71a2db188392b540104f1c1e430785d13..3b7ff8613a52c7c616b82cc91be9ba514dba42e5 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/LinkDAOImpl.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/LinkDAOImpl.java @@ -36,7 +36,7 @@ public class LinkDAOImpl implements LinkDAO{ MysqlConnect connection = new MysqlConnect(); connection.connect(); - // build and execute requestxam + // build and execute request stream String request = "DELETE FROM links WHERE id = ?;"; connection.issueInsertOrDeleteStatement(request, linkId); diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/ProjectDescriptionDAO.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/ProjectDescriptionDAO.java index 3137a9fe0be906f35f38e23115190f14b3a0576a..0ebb749d4cf824e02a95646123595c3b2b0fc1b0 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/ProjectDescriptionDAO.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/ProjectDescriptionDAO.java @@ -1,8 +1,11 @@ package unipotsdam.gf.modules.journal.model.dao; +import unipotsdam.gf.core.management.project.Project; import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; import unipotsdam.gf.modules.journal.model.ProjectDescription; +import java.util.ArrayList; + public interface ProjectDescriptionDAO { void createDescription(ProjectDescription projectDescription); @@ -12,4 +15,6 @@ public interface ProjectDescriptionDAO { ProjectDescription getDescription(String id); void deleteDescription(StudentIdentifier projectDescription); void closeDescription(String projectDescriptionId); + + ArrayList<String> getOpenDescriptions(Project project); } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/ProjectDescriptionDAOImpl.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/ProjectDescriptionDAOImpl.java index ec76a9622ddbc43270f0ffefc0016aed8265bd9b..c0b07344e684abc9a2912d02f8be0b2486e12d06 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/ProjectDescriptionDAOImpl.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/ProjectDescriptionDAOImpl.java @@ -4,6 +4,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import unipotsdam.gf.core.database.mysql.MysqlConnect; import unipotsdam.gf.core.database.mysql.VereinfachtesResultSet; +import unipotsdam.gf.core.management.project.Project; import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; import unipotsdam.gf.modules.journal.model.ProjectDescription; import unipotsdam.gf.modules.journal.util.JournalUtils; @@ -13,8 +14,6 @@ import java.util.UUID; public class ProjectDescriptionDAOImpl implements ProjectDescriptionDAO { - private final Logger log = LoggerFactory.getLogger(ProjectDescriptionDAOImpl.class); - @Override public void createDescription(ProjectDescription projectDescription) { @@ -114,7 +113,7 @@ public class ProjectDescriptionDAOImpl implements ProjectDescriptionDAO { connection.connect(); // build and execute request - String request = "DELETE FROM projectdescription WHERE WHERE author = ? AND project = ?;"; + String request = "DELETE FROM projectdescription WHERE author = ? AND project = ?;"; connection.issueInsertOrDeleteStatement(request, studentIdentifier.getStudentId(),studentIdentifier.getProjectId()); // close connection @@ -137,6 +136,28 @@ public class ProjectDescriptionDAOImpl implements ProjectDescriptionDAO { connection.close(); } + @Override + public ArrayList<String> getOpenDescriptions(Project project) { + ArrayList<String> userIds = new ArrayList<>(); + + // establish connection + MysqlConnect connection = new MysqlConnect(); + connection.connect(); + + // build and execute request + String request = "SELECT * FROM projectdescription WHERE project = ? AND open = ?;"; + VereinfachtesResultSet rs = connection.issueSelectStatement(request, project.getId(), true); + + while (rs.next()) { + userIds.add(getDescriptionFromResultSet(rs).getStudent().getStudentId()); + } + + // close connection + connection.close(); + + return userIds; + } + private ProjectDescription getDescriptionFromResultSet(VereinfachtesResultSet rs) { String id = rs.getString("id"); long timestamp = rs.getTimestamp(2).getTime(); @@ -145,7 +166,7 @@ public class ProjectDescriptionDAOImpl implements ProjectDescriptionDAO { String text = rs.getString("text"); boolean open = rs.getBoolean("open"); - return new ProjectDescription(id,author,text,project,new ArrayList<>(),new ArrayList<>(),timestamp, open); + return new ProjectDescription(id,author,text,project,new ArrayList<>(), timestamp, open); } } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/IJournalImpl.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/IJournalImpl.java index 15ca144ac8807f6b12522242395d571b0118e99e..d4e9d8a8e99438365fa13c1b2ddad1c30c3d7957 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/IJournalImpl.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/IJournalImpl.java @@ -1,69 +1,79 @@ package unipotsdam.gf.modules.journal.service; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import unipotsdam.gf.core.management.project.Project; import unipotsdam.gf.core.management.user.User; import unipotsdam.gf.interfaces.IJournal; import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; -import unipotsdam.gf.modules.journal.model.EPorfolio; +import unipotsdam.gf.modules.journal.model.EPortfolio; import unipotsdam.gf.modules.journal.model.Journal; import unipotsdam.gf.modules.researchreport.ResearchReport; -import javax.swing.text.html.HTML; import java.io.File; import java.util.ArrayList; import java.util.List; public class IJournalImpl implements IJournal { - JournalService journalService = new JournalServiceImpl(); - ProjectDescriptionService descriptionService = new ProjectDescriptionImpl(); + private final Logger log = LoggerFactory.getLogger(IJournalImpl.class); + + private final JournalService journalService = new JournalServiceImpl(); + private final ProjectDescriptionService descriptionService = new ProjectDescriptionImpl(); + @Override - public String exportJournal(StudentIdentifier student) { - return null; + public Boolean getPortfoliosForEvaluationPrepared(Project project) { + return descriptionService.checkIfAllDescriptionsClosed(project) && journalService.checkIfAllJournalClosed(project); } + @Override - public Boolean getPortfoliosForEvaluationPrepared(Project project) { - //Teilnehmer suchen + public void assignMissingPortfolioTasks(Project project) { - //Hat jeder Teilnehmer ein geschlossenenes Portfolio + ArrayList<User> descUser = descriptionService.getOpenUserByProject(project); - //Hat jeder die nötigen Journal + for(User user : descUser){ - return null; - } + log.debug("Send close description message to user {}", user.getId()); + //TODO send message when implemented - @Override - public void assignMissingPortfolioTasks(Project project) { - //Teilnehmer suchen + } + + ArrayList<User> journalUser = journalService.getOpenUserByProject(project); + + for(User user : journalUser){ + + log.debug("Send close journal message to user {}", user.getId()); + //TODO send message when implemented - //Hat jeder Teilnehmer ein geschlossenenes Portfolio + } - //Hat jeder die nötigen Journal } @Override public void uploadJournalEntry(Journal journalEntry, User student) { - + //TODO } @Override public void uploadFinalPortfolio(Project project, List<Journal> journalEntries, ResearchReport finalResearchReport, File presentation, User user) { - + //TODO } @Override - public EPorfolio getFinalPortfolioForAssessment(Project project, User user) { + public EPortfolio getFinalPortfolioForAssessment(Project project, User user) { - EPorfolio result = new EPorfolio(); + EPortfolio result = new EPortfolio(); StudentIdentifier studentIdentifier = new StudentIdentifier(project.getId(),user.getId()); - result.setDescrition(descriptionService.getProjectbyStudent(studentIdentifier)); + result.setDescription(descriptionService.getProjectByStudent(studentIdentifier)); result.setJournals(journalService.getAllJournals(user.getId(),project.getId())); //TODO result.setReport(...); return result; } + + } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/JournalService.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/JournalService.java index 755b1cf594ca1fb3516d4096567bbc2eba522b8f..be8dc781a90624f648196f0a74a55203ae053215 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/JournalService.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/JournalService.java @@ -1,5 +1,7 @@ package unipotsdam.gf.modules.journal.service; +import unipotsdam.gf.core.management.project.Project; +import unipotsdam.gf.core.management.user.User; import unipotsdam.gf.modules.journal.model.Journal; import unipotsdam.gf.modules.journal.model.JournalFilter; @@ -54,4 +56,8 @@ public interface JournalService { void closeJournal(String journal); + + boolean checkIfAllJournalClosed(Project project); + + ArrayList<User> getOpenUserByProject(Project project); } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/JournalServiceImpl.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/JournalServiceImpl.java index 79bf05ed35a80df31fdf7f4c1cb93ad5a16c62c0..e6367199fb8ecea4fc583389ca7cef4b553027d1 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/JournalServiceImpl.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/JournalServiceImpl.java @@ -2,6 +2,9 @@ package unipotsdam.gf.modules.journal.service; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import unipotsdam.gf.core.management.ManagementImpl; +import unipotsdam.gf.core.management.project.Project; +import unipotsdam.gf.core.management.user.User; import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; import unipotsdam.gf.modules.journal.model.Journal; import unipotsdam.gf.modules.journal.model.JournalFilter; @@ -15,7 +18,7 @@ import java.util.ArrayList; public class JournalServiceImpl implements JournalService { private final Logger log = LoggerFactory.getLogger(JournalServiceImpl.class); - JournalDAO journalDAO = new JournalDAOImpl(); + private final JournalDAO journalDAO = new JournalDAOImpl(); @Override public Journal getJournal(String id) { @@ -42,7 +45,6 @@ public class JournalServiceImpl implements JournalService { } //If Visibility Group, show if student is in group and filter allows it - //TODO: project != Group, for testing ok, change for real Service if (j.getVisibility() == Visibility.GROUP && j.getStudentIdentifier().getProjectId().equals(project) && filter == JournalFilter.ALL) { result.add(j); } @@ -60,7 +62,7 @@ public class JournalServiceImpl implements JournalService { public ArrayList<Journal> getAllJournals(String student, String project) { log.debug(">> get all journals(" + student + "," + project + ")"); - return journalDAO.getAllByProject(project); + return journalDAO.getAllByProject(project, student); } @Override @@ -96,6 +98,23 @@ public class JournalServiceImpl implements JournalService { log.debug("<<< close journal"); } - //TODO Export for assessment -} + @Override + public boolean checkIfAllJournalClosed(Project project) { + return (journalDAO.getOpenJournals(project).size() == 0); + } + + @Override + public ArrayList<User> getOpenUserByProject(Project project) { + + ManagementImpl management = new ManagementImpl(); + + ArrayList<String> userId = journalDAO.getOpenJournals(project); + ArrayList<User> users = new ArrayList<>(); + + for(String id : userId){ + users.add(management.getUserByToken(id)); + } + return users; + } +} \ No newline at end of file diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/ProjectDescriptionImpl.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/ProjectDescriptionImpl.java index 77ed95bb2febbf0a04a3cb6399493e657ba68125..22ca2a4b63429bdda422f3be7547439caa8c1f0d 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/ProjectDescriptionImpl.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/ProjectDescriptionImpl.java @@ -1,5 +1,8 @@ package unipotsdam.gf.modules.journal.service; +import unipotsdam.gf.core.management.ManagementImpl; +import unipotsdam.gf.core.management.project.Project; +import unipotsdam.gf.core.management.user.User; import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; import unipotsdam.gf.modules.journal.model.Link; import unipotsdam.gf.modules.journal.model.ProjectDescription; @@ -8,20 +11,19 @@ import unipotsdam.gf.modules.journal.model.dao.LinkDAOImpl; import unipotsdam.gf.modules.journal.model.dao.ProjectDescriptionDAO; import unipotsdam.gf.modules.journal.model.dao.ProjectDescriptionDAOImpl; -import java.util.Date; +import java.util.ArrayList; public class ProjectDescriptionImpl implements ProjectDescriptionService { - ProjectDescriptionDAO descriptionDAO = new ProjectDescriptionDAOImpl(); - LinkDAO linkDAO = new LinkDAOImpl(); + private final ProjectDescriptionDAO descriptionDAO = new ProjectDescriptionDAOImpl(); + private final LinkDAO linkDAO = new LinkDAOImpl(); @Override - public ProjectDescription getProjectbyStudent(StudentIdentifier studentIdentifier) { + public ProjectDescription getProjectByStudent(StudentIdentifier studentIdentifier) { - //if no description exists, create a new + //if no description exists (when page is opened for the first time), create a new one if(descriptionDAO.getDescription(studentIdentifier)==null){ - //TODO richtige Daten, standartwerte über config? - ProjectDescription description = new ProjectDescription("0", studentIdentifier.getStudentId(), "Hier soll ein Turtorialtext stehen", studentIdentifier.getProjectId(), null, null, new Date().getTime()); + ProjectDescription description = new ProjectDescription("0", studentIdentifier.getStudentId(), "Hier soll ein Turtorialtext stehen", studentIdentifier.getProjectId(), null); descriptionDAO.createDescription(description); } @@ -32,7 +34,7 @@ public class ProjectDescriptionImpl implements ProjectDescriptionService { } @Override - public ProjectDescription getProjectbyId(String id) { + public ProjectDescription getProjectById(String id) { ProjectDescription returnDesc = descriptionDAO.getDescription(id); returnDesc.setLinks(linkDAO.getAllLinks(returnDesc.getId())); return returnDesc; @@ -41,7 +43,7 @@ public class ProjectDescriptionImpl implements ProjectDescriptionService { @Override public void saveProjectText(StudentIdentifier studentIdentifier, String text) { - ProjectDescription desc = getProjectbyStudent(studentIdentifier); + ProjectDescription desc = getProjectByStudent(studentIdentifier); desc.setDescription(text); descriptionDAO.updateDescription(desc); } @@ -61,4 +63,22 @@ public class ProjectDescriptionImpl implements ProjectDescriptionService { public void closeDescription(String projectDescrID) { descriptionDAO.closeDescription(projectDescrID); } + + @Override + public boolean checkIfAllDescriptionsClosed(Project project) { + return (descriptionDAO.getOpenDescriptions(project).size() == 0); + } + + @Override + public ArrayList<User> getOpenUserByProject(Project project) { + ManagementImpl management = new ManagementImpl(); + + ArrayList<String> userId = descriptionDAO.getOpenDescriptions(project); + ArrayList<User> users = new ArrayList<>(); + + for(String id : userId){ + users.add(management.getUserByToken(id)); + } + return users; + } } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/ProjectDescriptionService.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/ProjectDescriptionService.java index 2d76e6c454b6c745611742a95b734f9a9d7212a6..a99aef7d96d10670e5e6b580481b5df727a543cf 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/ProjectDescriptionService.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/service/ProjectDescriptionService.java @@ -1,8 +1,12 @@ package unipotsdam.gf.modules.journal.service; +import unipotsdam.gf.core.management.project.Project; +import unipotsdam.gf.core.management.user.User; import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; import unipotsdam.gf.modules.journal.model.ProjectDescription; +import java.util.ArrayList; + /** * Service for learning Journal */ @@ -10,9 +14,9 @@ import unipotsdam.gf.modules.journal.model.ProjectDescription; public interface ProjectDescriptionService { - ProjectDescription getProjectbyStudent(StudentIdentifier studentIdentifier); + ProjectDescription getProjectByStudent(StudentIdentifier studentIdentifier); - ProjectDescription getProjectbyId(String id); + ProjectDescription getProjectById(String id); void saveProjectText(StudentIdentifier studentIdentifier, String text); void addLink(String project, String link, String name); @@ -20,4 +24,8 @@ public interface ProjectDescriptionService { void deleteLink(String link); void closeDescription(String projectDescriptionId); + + boolean checkIfAllDescriptionsClosed(Project project); + + ArrayList<User> getOpenUserByProject(Project project); } diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/util/JournalUtils.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/util/JournalUtils.java index d38cf359ae62c553574bce825ea6b17abce99118..4133b81fc2b406d71f03ab56d3c4e9fd6f365744 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/util/JournalUtils.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/util/JournalUtils.java @@ -15,7 +15,7 @@ public class JournalUtils { public static final Logger log = LoggerFactory.getLogger(JournalUtils.class); /** - * Coverts a strirng to enum category + * Coverts a string to enum category * * @param category string * @return category, TITLE if string does not match @@ -30,7 +30,7 @@ public class JournalUtils { } catch (IllegalArgumentException e) { c = Category.TITEL; //TODO extra Category for fail? - JournalUtils.log.debug("Illegal argument for visibility, default to TITLR"); + JournalUtils.log.debug("Illegal argument for visibility, default to TITLE"); } return c; } @@ -67,10 +67,9 @@ public class JournalUtils { connection.connect(); // build and execute request - //TODO Formatstring String request = "SELECT COUNT(*) > 0 AS `exists` FROM " + table+ " WHERE id = ?;"; VereinfachtesResultSet rs = connection.issueSelectStatement(request,id); - log.debug("querry: " + rs.toString()); + JournalUtils.log.debug("query: " + rs.toString()); if (rs.next()) { // save the response int count = rs.getInt("exists"); @@ -79,11 +78,7 @@ public class JournalUtils { connection.close(); // return true if we found the id - if (count < 1) { - return false; - } else { - return true; - } + return count >= 1; } // something happened diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/view/JournalView.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/view/JournalView.java index 68059e911c2c6e91921895d1cc26bb9a837bd3ea..d85291ced130bb3ec0108c8f05e56d238b42c1b4 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/view/JournalView.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/view/JournalView.java @@ -60,8 +60,8 @@ public class JournalView { log.debug(">>> getJournals: student=" + student + " project=" + project +" filter=" + filter ); - JournalFilter filt = (filter.equals("ALL")) ? JournalFilter.ALL:JournalFilter.OWN; - ArrayList<Journal> result = journalService.getAllJournals(student,project,filt); + JournalFilter journalFilter = (filter.equals("ALL")) ? JournalFilter.ALL:JournalFilter.OWN; + ArrayList<Journal> result = journalService.getAllJournals(student,project,journalFilter); log.debug(">>> getJournals: size=" + result.size()); diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/view/ProjectDescriptionView.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/view/ProjectDescriptionView.java index 2b9fe312ee621cfb9ce686deeccfcce77f16c8e1..a8cb61a98d5c351f52b87ab03e817cd4d098de64 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/view/ProjectDescriptionView.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/view/ProjectDescriptionView.java @@ -32,7 +32,7 @@ public class ProjectDescriptionView { public Response getProjectDescription(@PathParam("project") String project, @PathParam("student") String student){ log.debug(">>> getProjectDescription: " + project + "/" + student); - ProjectDescription result = descriptionService.getProjectbyStudent(new StudentIdentifier(project, student)); + ProjectDescription result = descriptionService.getProjectByStudent(new StudentIdentifier(project, student)); log.debug(">>> getProjectDescription"); return Response.ok(result).build(); @@ -71,7 +71,7 @@ public class ProjectDescriptionView { public Response addLink(@FormParam("link") String link, @FormParam("name") String name, @FormParam("projectdescriptionId") String project){ log.debug(">>> addLink: " + name + ":" + link); - ProjectDescription desc = descriptionService.getProjectbyId(project); + ProjectDescription desc = descriptionService.getProjectById(project); descriptionService.addLink(project,link, name ); @@ -122,7 +122,7 @@ public class ProjectDescriptionView { public Response closeDescription(String desc){ log.debug(">>> closeDescription: " + desc); - StudentIdentifier student = descriptionService.getProjectbyId(desc).getStudent(); + StudentIdentifier student = descriptionService.getProjectById(desc).getStudent(); descriptionService.closeDescription(desc); try { URI location = new URI("../pages/eportfolio.jsp?token=" + student.getStudentId() + "&projectId=" + student.getProjectId()); diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/controller/SubmissionController.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/controller/SubmissionController.java new file mode 100644 index 0000000000000000000000000000000000000000..7f5b6a30279d55b5157c0b31ee285e68c077f528 --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/controller/SubmissionController.java @@ -0,0 +1,568 @@ +package unipotsdam.gf.modules.submission.controller; + +import com.google.common.base.Strings; +import unipotsdam.gf.core.database.mysql.MysqlConnect; +import unipotsdam.gf.core.database.mysql.VereinfachtesResultSet; +import unipotsdam.gf.interfaces.ISubmission; +import unipotsdam.gf.modules.peer2peerfeedback.Category; +import unipotsdam.gf.modules.submission.model.*; + +import java.sql.PreparedStatement; +import java.util.ArrayList; +import java.util.UUID; + +/** + * @author Sven Kästle + * skaestle@uni-potsdam.de + */ +public class SubmissionController implements ISubmission { + @Override + public FullSubmission addFullSubmission(FullSubmissionPostRequest fullSubmissionPostRequest) { + + // create a new id if we found no id. + String uuid = UUID.randomUUID().toString(); + while (existsFullSubmissionId(uuid)) { + uuid = UUID.randomUUID().toString(); + } + + // establish connection + MysqlConnect connection = new MysqlConnect(); + connection.connect(); + + // build and execute request + String request = "INSERT INTO fullsubmissions (`id`, `user`, `text`, `projectId`) VALUES (?,?,?,?);"; + connection.issueInsertOrDeleteStatement(request, uuid, fullSubmissionPostRequest.getUser(), fullSubmissionPostRequest.getText(), fullSubmissionPostRequest.getProjectId()); + + // get the new submission from database + FullSubmission fullSubmission = getFullSubmission(uuid); + + // close connection + connection.close(); + + return fullSubmission; + + } + + @Override + public FullSubmission getFullSubmission(String fullSubmissionId) { + + // establish connection + MysqlConnect connection = new MysqlConnect(); + connection.connect(); + + // build and execute request + String request = "SELECT * FROM fullsubmissions WHERE id = ?;"; + VereinfachtesResultSet rs = connection.issueSelectStatement(request, fullSubmissionId); + + if (rs.next()) { + // save submission + FullSubmission fullSubmission = getFullSubmissionFromResultSet(rs); + + // close connection + connection.close(); + + return fullSubmission; + } + else { + + // close connection + connection.close(); + + return null; + } + + } + + @Override + public boolean existsFullSubmissionId(String id) { + + // establish connection + MysqlConnect connection = new MysqlConnect(); + connection.connect(); + + // build and execute request + String request = "SELECT COUNT(*) > 0 AS `exists` FROM fullsubmissions WHERE id = ?;"; + VereinfachtesResultSet rs = connection.issueSelectStatement(request, id); + + if (rs.next()) { + // save the response + int count = rs.getInt("exists"); + + // close connection + connection.close(); + + // return true if we found the id + if (count < 1) { + return false; + } + else { + return true; + } + } + + // something happened + return true; + + } + + @Override + public SubmissionPart addSubmissionPart(SubmissionPartPostRequest submissionPartPostRequest) { + + // establish connection + MysqlConnect connection = new MysqlConnect(); + connection.connect(); + + // build and execute request + String request = "INSERT IGNORE INTO submissionparts (`userId`, `fullSubmissionId`, `category`) VALUES (?,?,?);"; + connection.issueInsertOrDeleteStatement(request, submissionPartPostRequest.getUserId(), submissionPartPostRequest.getFullSubmissionId(), submissionPartPostRequest.getCategory().toString().toUpperCase()); + + // declare request string + String requestElement; + for (SubmissionPartBodyElement element : submissionPartPostRequest.getBody()) { + + // calculate how many similar elements are next to the new element + int similarElements = numOfSimilarBodyElements(submissionPartPostRequest.getFullSubmissionId(), submissionPartPostRequest.getCategory(), element.getStartCharacter(), element.getEndCharacter()); + + switch (similarElements) { + // similar element on the left side + case -1: + requestElement = "UPDATE submissionpartbodyelements SET endCharacter = ? WHERE fullSubmissionId = ? AND category = ? AND endCharacter = ?;"; + connection.issueUpdateStatement(requestElement, element.getEndCharacter(), submissionPartPostRequest.getFullSubmissionId(), submissionPartPostRequest.getCategory(), element.getStartCharacter()); + break; + // no similar element + case 0: + if (!hasOverlappingBoundaries(submissionPartPostRequest.getFullSubmissionId(), submissionPartPostRequest.getCategory(), element)) { + requestElement = "INSERT IGNORE INTO submissionpartbodyelements (`fullSubmissionId`, `category`, `startCharacter`, `endCharacter`) VALUES (?,?,?,?);"; + connection.issueInsertOrDeleteStatement(requestElement, submissionPartPostRequest.getFullSubmissionId(), submissionPartPostRequest.getCategory().toString().toUpperCase(), element.getStartCharacter(), element.getEndCharacter()); + } + break; + // similar element on the right side + case 1: + requestElement = "UPDATE submissionpartbodyelements SET startCharacter = ? WHERE fullSubmissionId = ? AND category = ? AND startCharacter = ?;"; + connection.issueUpdateStatement(requestElement, element.getStartCharacter(), submissionPartPostRequest.getFullSubmissionId(), submissionPartPostRequest.getCategory(), element.getEndCharacter()); + break; + // similar elements on both sides + case 2: + // fetch end character from right element + requestElement = "SELECT endCharacter FROM submissionpartbodyelements WHERE fullSubmissionId = ? AND category = ? AND startCharacter = ?;"; + VereinfachtesResultSet rs = connection.issueSelectStatement(requestElement, submissionPartPostRequest.getFullSubmissionId(), submissionPartPostRequest.getCategory(), element.getEndCharacter()); + + // delete right element + String deleteElement = "DELETE FROM submissionpartbodyelements WHERE fullSubmissionId = ? AND category = ? AND startCharacter = ?;"; + connection.issueInsertOrDeleteStatement(deleteElement, submissionPartPostRequest.getFullSubmissionId(), submissionPartPostRequest.getCategory(), element.getEndCharacter()); + + if (rs.next()) { + int end = rs.getInt("endCharacter"); + + // update left element + String updateElement = "UPDATE submissionpartbodyelements SET endCharacter = ? WHERE fullSubmissionId = ? AND category = ? AND endCharacter = ?;"; + connection.issueUpdateStatement(updateElement, end, submissionPartPostRequest.getFullSubmissionId(), submissionPartPostRequest.getCategory(), element.getStartCharacter()); + + } + + } + + } + + // get the new submission from database + SubmissionPart submissionPart = getSubmissionPart(submissionPartPostRequest.getFullSubmissionId(), submissionPartPostRequest.getCategory()); + + // close connection + connection.close(); + + return submissionPart; + + } + + @Override + public SubmissionPart getSubmissionPart(String fullSubmissionId, Category category) { + + // establish connection + MysqlConnect connection = new MysqlConnect(); + connection.connect(); + + // declare text + String text; + + // build and execute request to receive text + String requestText = "SELECT text " + + "FROM fullsubmissions " + + "WHERE id = ?"; + VereinfachtesResultSet rsText = connection.issueSelectStatement(requestText, fullSubmissionId); + + if (rsText.next()) { + // save text + text = rsText.getString("text"); + + // build and execute request + String request = "SELECT * FROM submissionparts s " + + "LEFT JOIN submissionpartbodyelements b " + + "ON s.fullSubmissionId = b.fullSubmissionId " + + "AND s.category = b.category " + + "WHERE s.fullSubmissionId = ? " + + "AND s.category = ?;"; + VereinfachtesResultSet rs = connection.issueSelectStatement(request, fullSubmissionId, category); + + if (rs.next()) { + // save submission + SubmissionPart submissionPart = getSubmissionPartFromResultSet(rs, text); + + // close connection + connection.close(); + + return submissionPart; + } + else { + // close connection + connection.close(); + + return null; + } + } + + return null; + + } + + @Override + public ArrayList<SubmissionPart> getAllSubmissionParts(String fullSubmissionId) { + + // establish connection + MysqlConnect connection = new MysqlConnect(); + connection.connect(); + + // declare text + String text; + + // build and execute request to receive text + String requestText = "SELECT text " + + "FROM fullsubmissions " + + "WHERE id = ?"; + VereinfachtesResultSet rsText = connection.issueSelectStatement(requestText, fullSubmissionId); + + if (rsText.next()) { + // save text + text = rsText.getString("text"); + + // build and execute request + String request = "SELECT * " + + "FROM submissionparts sp " + + "LEFT JOIN submissionpartbodyelements spbe " + + "ON sp.fullSubmissionId = spbe.fullSubmissionId " + + "AND sp.category = spbe.category " + + "WHERE sp.fullSubmissionId = ? " + + "ORDER BY sp.timestamp;"; + VereinfachtesResultSet rs = connection.issueSelectStatement(request, fullSubmissionId); + + ArrayList<SubmissionPart> submissionParts = new ArrayList<>(); + + if (rs.next()) { + // save submission + submissionParts = getAllSubmissionPartsFromResultSet(rs, text); + } + + // close connection + connection.close(); + + return submissionParts; + } + + // close connection + connection.close(); + + return null; + + } + + @Override + public ArrayList<SubmissionProjectRepresentation> getSubmissionPartsByProjectId(String projectId) { + + // establish connection + MysqlConnect connection = new MysqlConnect(); + connection.connect(); + + // build and execute request + String request = "SELECT s.userId, s.category, s.fullSubmissionId " + + "FROM fullsubmissions f " + + "LEFT JOIN submissionparts s " + + "ON f.id = s.fullSubmissionId " + + "WHERE f.projectId = ?"; + VereinfachtesResultSet rs = connection.issueSelectStatement(request, projectId); + + ArrayList<SubmissionProjectRepresentation> representations; + + // save submission + representations = getAllSubmissionProjectRepresentationsFromResultSet(rs); + + // close connection + connection.close(); + + return representations; + + } + + @Override + public boolean existsSubmissionPart(String fullSubmissionId, Category category) { + + // establish connection + MysqlConnect connection = new MysqlConnect(); + connection.connect(); + + // build and execute request + String request = "SELECT COUNT(*) > 0 AS `exists` FROM submissionparts WHERE fullSubmissionId = ? AND category = ?;"; + VereinfachtesResultSet rs = connection.issueSelectStatement(request, fullSubmissionId, category); + + if (rs.next()) { + // save the response + int count = rs.getInt("exists"); + + // close connection + connection.close(); + + // return true if we found the id + if (count < 1) { + return false; + } + else { + return true; + } + } + + // something happened + return true; + + } + + /** + * Build a full submission object from a given result set + * + * @param rs The result set from a database query + * @return A new full submission object + */ + private FullSubmission getFullSubmissionFromResultSet(VereinfachtesResultSet rs) { + + String id = rs.getString("id"); + long timestamp = rs.getTimestamp("timestamp").getTime(); + String user = rs.getString("user"); + String text = rs.getString("text"); + String projectId = rs.getString("projectId"); + + return new FullSubmission(id, timestamp, user, text, projectId); + + } + + /** + * Build a submission part object from a given result set + * + * @param rs The result set from the database query + * @return A new submission part object + */ + private SubmissionPart getSubmissionPartFromResultSet(VereinfachtesResultSet rs, String text) { + + // declare variables + int start, end; + String textPart; + + // initialize variables + long timestamp = rs.getTimestamp("timestamp").getTime(); + String userId = rs.getString("userId"); + String fullSubmissionId = rs.getString("fullSubmissionId"); + Category category = Category.valueOf(rs.getString("category").toUpperCase()); + + // build body and iterate over result set + ArrayList<SubmissionPartBodyElement> body = new ArrayList<>(); + + do { + // initialize body variables + start = rs.getInt("startCharacter"); + end = rs.getInt("endCharacter"); + textPart = text.substring(start, end); + + // build element + SubmissionPartBodyElement element = new SubmissionPartBodyElement(textPart, start, end); + + body.add(element); + } while (rs.next()); + + return new SubmissionPart(timestamp, userId, fullSubmissionId, category, body); + } + + /** + * Build an array of submission part objects from a given result set + * + * @param rs The result set from the database query, holding different submission parts + * @return An array of submission parts + */ + private ArrayList<SubmissionPart> getAllSubmissionPartsFromResultSet(VereinfachtesResultSet rs, String text) { + + // declare variables + int start, end; + String textPart; + + ArrayList<SubmissionPart> submissionParts = new ArrayList<>(); + // tmp part + SubmissionPart tmpPart = null; + // tmp body element + SubmissionPartBodyElement tmpElement; + // tmp category + String tmpCategory = ""; + do { + + if (!tmpCategory.equals(rs.getString("category").toUpperCase())) { + // current tmp category + tmpCategory = rs.getString("category").toUpperCase(); + + // add last submission part + if (tmpPart != null) { + submissionParts.add(tmpPart); + } + + // build submission part with empty body + tmpPart = new SubmissionPart( + rs.getTimestamp("timestamp").getTime(), + rs.getString("userId"), + rs.getString("fullSubmissionId"), + Category.valueOf(tmpCategory), + new ArrayList<SubmissionPartBodyElement>() + ); + } + + // initialize body variables + start = rs.getInt("startCharacter"); + end = rs.getInt("endCharacter"); + textPart = text.substring(start, end); + + tmpElement = new SubmissionPartBodyElement(textPart, start, end); + + tmpPart.getBody().add(tmpElement); + + } while (rs.next()); + + // add last part + submissionParts.add(tmpPart); + + return submissionParts; + } + + private ArrayList<SubmissionProjectRepresentation> getAllSubmissionProjectRepresentationsFromResultSet(VereinfachtesResultSet rs) { + + ArrayList<SubmissionProjectRepresentation> representations = new ArrayList<>(); + + while (rs.next()) { + if (!Strings.isNullOrEmpty(rs.getString("category"))) { + representations.add(new SubmissionProjectRepresentation( + rs.getString("userId"), + Category.valueOf(rs.getString("category").toUpperCase()), + rs.getString("fullSubmissionId") + )); + } + } + + return representations; + + } + + /** + * Calculates how many similar body elements (based on start and end character) can be found in the database + * + * @param fullSubmissionId The id of the full submission + * @param category The category of the submission part + * @param startCharacter The start character of the new element + * @param endCharacter The end character of the old element + * @return Return 0 if there are no similar elements, 2 if we found two similar elements (right and left side), + * 1 if we found a similar element on the right side and -1 if we found a similar element on the left side. + */ + private int numOfSimilarBodyElements(String fullSubmissionId, Category category, int startCharacter, int endCharacter) { + // establish connection + MysqlConnect connection = new MysqlConnect(); + connection.connect(); + + // build and execute request + String request = "SELECT COUNT(*) AS `count` FROM submissionpartbodyelements WHERE fullSubmissionId = ? AND category = ? AND (endCharacter = ? OR startCharacter = ?);"; + VereinfachtesResultSet rs = connection.issueSelectStatement(request, fullSubmissionId, category.toString().toUpperCase(), startCharacter, endCharacter); + + if (rs.next()) { + // save the response + int count = rs.getInt("count"); + + // found one element; left or right side + if (count == 1) { + + // build and execute request to find out on which side we found a similar body element + String requestSide = "SELECT COUNT(*) AS `side` FROM submissionpartbodyelements WHERE fullSubmissionId = ? AND category = ? AND endCharacter = ?;"; + VereinfachtesResultSet rsSide = connection.issueSelectStatement(requestSide, fullSubmissionId, category.toString().toUpperCase(), startCharacter); + + if (rsSide.next()) { + // save the response + int side = rsSide.getInt("side"); + + // close connection + connection.close(); + + if (side == 1) { + return -1; + } + else { + return 1; + } + + } + } + else { + // close connection + connection.close(); + + return count; + } + } + + return 0; + + } + + /** + * Checks if a new body element has overlapping boundaries with an already existing element + * + * @param fullSubmissionId The id of the full submission + * @param category The category + * @param element The new element + * @return Returns true if overlapping boundaries have been found + */ + private boolean hasOverlappingBoundaries(String fullSubmissionId, Category category, SubmissionPartBodyElement element) { + + // establish connection + MysqlConnect connection = new MysqlConnect(); + connection.connect(); + + // initialize start and end character + int start = element.getStartCharacter(); + int end = element.getEndCharacter(); + + // build and execute request + String request = "SELECT COUNT(*) > 0 AS `exists` FROM submissionpartbodyelements WHERE fullSubmissionId = ? AND category = ? AND (" + + "(startCharacter <= ? AND ? <= endCharacter) OR " + // start character overlapping + "(startCharacter <= ? AND ? <= endCharacter));"; // end character overlapping + VereinfachtesResultSet rs = connection.issueSelectStatement(request, fullSubmissionId, category.toString(), start, start, end, end); + + if (rs.next()) { + // save the response + int count = rs.getInt("exists"); + + // close connection + connection.close(); + + // return true if we found the id + if (count < 1) { + return false; + } + else { + return true; + } + } + + // something happened + return true; + + } + +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/model/FullSubmission.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/model/FullSubmission.java new file mode 100644 index 0000000000000000000000000000000000000000..37b35c9fb9809ee409548f374c3623d73e204170 --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/model/FullSubmission.java @@ -0,0 +1,77 @@ +package unipotsdam.gf.modules.submission.model; + +/** + * @author Sven Kästle + * skaestle@uni-potsdam.de + */ +public class FullSubmission { + + // variables + private String id; + private long timestamp; + private String user; + private String text; + private String projectId; + + // constructor + public FullSubmission(String id, long timestamp, String user, String text, String projectId) { + this.id = id; + this.timestamp = timestamp; + this.user = user; + this.text = text; + this.projectId = projectId; + } + + // methods + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } + + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public String getProjectId() { + return projectId; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + @Override + public String toString() { + return "FullSubmission{" + + "id='" + id + '\'' + + ", timestamp=" + timestamp + + ", user='" + user + '\'' + + ", text='" + text + '\'' + + ", projectId='" + projectId + '\'' + + '}'; + } + +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/model/FullSubmissionPostRequest.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/model/FullSubmissionPostRequest.java new file mode 100644 index 0000000000000000000000000000000000000000..48a2dfe748498fcd1f672ac5eb6ed2bc126af227 --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/model/FullSubmissionPostRequest.java @@ -0,0 +1,57 @@ +package unipotsdam.gf.modules.submission.model; + +/** + * @author Sven Kästle + * skaestle@uni-potsdam.de + */ +public class FullSubmissionPostRequest { + + // variables + private String user; + private String text; + private String projectId; + + // constructors + public FullSubmissionPostRequest(String user, String text, String projectId) { + this.user = user; + this.text = text; + this.projectId = projectId; + } + + public FullSubmissionPostRequest() {} + + // methods + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public String getProjectId() { + return projectId; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + @Override + public String toString() { + return "FullSubmissionPostRequest{" + + "user='" + user + '\'' + + ", text='" + text + '\'' + + ", projectId='" + projectId + '\'' + + '}'; + } + +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/model/SubmissionPart.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/model/SubmissionPart.java new file mode 100644 index 0000000000000000000000000000000000000000..1a0b7644d1f69f2c5490f1bc7ac9ab6111eb6daa --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/model/SubmissionPart.java @@ -0,0 +1,83 @@ +package unipotsdam.gf.modules.submission.model; + +import unipotsdam.gf.modules.peer2peerfeedback.Category; + +import java.util.ArrayList; + +/** + * @author Sven Kästle + * skaestle@uni-potsdam.de + */ +public class SubmissionPart { + + // variables + private long timestamp; + private String userId; + private String fullSubmissionId; + private Category category; + private ArrayList<SubmissionPartBodyElement> body; + + // constructor + public SubmissionPart(long timestamp, String userId, String fullSubmissionId, Category category, ArrayList<SubmissionPartBodyElement> body) { + this.timestamp = timestamp; + this.userId = userId; + this.fullSubmissionId = fullSubmissionId; + this.category = category; + this.body = body; + } + + public SubmissionPart(){} + + // methods + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getFullSubmissionId() { + return fullSubmissionId; + } + + public void setFullSubmissionId(String fullSubmissionId) { + this.fullSubmissionId = fullSubmissionId; + } + + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + public ArrayList<SubmissionPartBodyElement> getBody() { + return body; + } + + public void setBody(ArrayList<SubmissionPartBodyElement> body) { + this.body = body; + } + + @Override + public String toString() { + return "SubmissionPart{" + + "timestamp=" + timestamp + + ", userId='" + userId + '\'' + + ", fullSubmissionId='" + fullSubmissionId + '\'' + + ", category=" + category + + ", body=" + body + + '}'; + } + +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/model/SubmissionPartBodyElement.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/model/SubmissionPartBodyElement.java new file mode 100644 index 0000000000000000000000000000000000000000..7448d70ab6c9704057c71b257482bf904c74ee0a --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/model/SubmissionPartBodyElement.java @@ -0,0 +1,57 @@ +package unipotsdam.gf.modules.submission.model; + +/** + * @author Sven Kästle + * skaestle@uni-potsdam.de + */ +public class SubmissionPartBodyElement { + + // variables + private String text; + private int startCharacter; + private int endCharacter; + + // constructors + public SubmissionPartBodyElement(String text, int startCharacter, int endCharacter) { + this.text = text; + this.startCharacter = startCharacter; + this.endCharacter = endCharacter; + } + + public SubmissionPartBodyElement() {} + + // methods + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public int getStartCharacter() { + return startCharacter; + } + + public void setStartCharacter(int startCharacter) { + this.startCharacter = startCharacter; + } + + public int getEndCharacter() { + return endCharacter; + } + + public void setEndCharacter(int endCharacter) { + this.endCharacter = endCharacter; + } + + @Override + public String toString() { + return "SubmissionPartBodyElement{" + + ", text='" + text + '\'' + + ", startCharacter=" + startCharacter + + ", endCharacter=" + endCharacter + + '}'; + } + +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/model/SubmissionPartPostRequest.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/model/SubmissionPartPostRequest.java new file mode 100644 index 0000000000000000000000000000000000000000..07ac839bb6ca8927c00e5b766d05e1f4a50e6763 --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/model/SubmissionPartPostRequest.java @@ -0,0 +1,72 @@ +package unipotsdam.gf.modules.submission.model; + +import unipotsdam.gf.modules.peer2peerfeedback.Category; + +import java.util.ArrayList; + +/** + * @author Sven Kästle + * skaestle@uni-potsdam.de + */ +public class SubmissionPartPostRequest { + + // variables + private String userId; + private String fullSubmissionId; + private Category category; + private ArrayList<SubmissionPartBodyElement> body; + + // constructors + public SubmissionPartPostRequest(String userId, String fullSubmissionId, Category category, ArrayList<SubmissionPartBodyElement> body) { + this.userId = userId; + this.fullSubmissionId = fullSubmissionId; + this.category = category; + this.body = body; + } + + public SubmissionPartPostRequest(){} + + // methods + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getFullSubmissionId() { + return fullSubmissionId; + } + + public void setFullSubmissionId(String fullSubmissionId) { + this.fullSubmissionId = fullSubmissionId; + } + + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + public ArrayList<SubmissionPartBodyElement> getBody() { + return body; + } + + public void setBody(ArrayList<SubmissionPartBodyElement> body) { + this.body = body; + } + + @Override + public String toString() { + return "SubmissionPartPostRequest{" + + "userId='" + userId + '\'' + + ", fullSubmissionId='" + fullSubmissionId + '\'' + + ", category=" + category + + ", body=" + body + + '}'; + } + +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/model/SubmissionProjectRepresentation.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/model/SubmissionProjectRepresentation.java new file mode 100644 index 0000000000000000000000000000000000000000..998bc1fb6c567e7d30fa0fa06cd91f3808afcdf6 --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/model/SubmissionProjectRepresentation.java @@ -0,0 +1,55 @@ +package unipotsdam.gf.modules.submission.model; + +import unipotsdam.gf.modules.peer2peerfeedback.Category; + +public class SubmissionProjectRepresentation { + + // variables + private String user; + private Category category; + private String fullSubmissionId; + + // constructor + public SubmissionProjectRepresentation(String user, Category category, String fullSubmissionId) { + this.user = user; + this.category = category; + this.fullSubmissionId = fullSubmissionId; + } + + public SubmissionProjectRepresentation(){} + + // methods + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + public String getFullSubmissionId() { + return fullSubmissionId; + } + + public void setFullSubmissionId(String fullSubmissionId) { + this.fullSubmissionId = fullSubmissionId; + } + + @Override + public String toString() { + return "SubmissionProjectRepresentation{" + + "user='" + user + '\'' + + ", category=" + category + + ", fullSubmissionId='" + fullSubmissionId + '\'' + + '}'; + } + +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/model/SubmissionResponse.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/model/SubmissionResponse.java new file mode 100644 index 0000000000000000000000000000000000000000..51990953829fab6fde864683722c758e9e5a7d98 --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/model/SubmissionResponse.java @@ -0,0 +1,35 @@ +package unipotsdam.gf.modules.submission.model; + +/** + * @author Sven Kästle + * skaestle@uni-potsdam.de + */ +public class SubmissionResponse { + + // variables + String message; + + // constructors + public SubmissionResponse(String message) { + this.message = message; + } + + public SubmissionResponse(){} + + // methods + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + @Override + public String toString() { + return "SubmissionResponse{" + + "message='" + message + '\'' + + '}'; + } + +} diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/view/SubmissionService.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/view/SubmissionService.java new file mode 100644 index 0000000000000000000000000000000000000000..6b6bfd25b9aa141526009e46153c799c87b0acea --- /dev/null +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/submission/view/SubmissionService.java @@ -0,0 +1,117 @@ +package unipotsdam.gf.modules.submission.view; + +import unipotsdam.gf.modules.peer2peerfeedback.Category; +import unipotsdam.gf.modules.submission.controller.SubmissionController; +import unipotsdam.gf.modules.submission.model.*; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.ArrayList; + +/** + * @author Sven Kästle + * skaestle@uni-potsdam.de + */ + +@Path("/submissions") +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public class SubmissionService { + + @POST + @Path("/full") + public Response addFullSubmission(FullSubmissionPostRequest fullSubmissionPostRequest) { + // save full submission request in database and return the new full submission + SubmissionController controller = new SubmissionController(); + FullSubmission fullSubmission = controller.addFullSubmission(fullSubmissionPostRequest); + + return Response.ok(fullSubmission).build(); + } + + @GET + @Path("/full/{id}") + public Response getFullSubmission(@PathParam("id") String fullSubmissionId) { + + // get full submission from database based by id + SubmissionController controller = new SubmissionController(); + FullSubmission fullSubmission = controller.getFullSubmission(fullSubmissionId); + + if (fullSubmission != null) { + return Response.ok(fullSubmission).build(); + } + else { + // declare response + SubmissionResponse response = new SubmissionResponse(); + response.setMessage("Submission with the id '" + fullSubmissionId + "' can't be found"); + + return Response.status(Response.Status.NOT_FOUND).entity(response).build(); + } + + } + + @POST + @Path("/part") + public Response addSubmissionPart(SubmissionPartPostRequest submissionPartPostRequest) { + // save submission part request in the database and return the new submission part + SubmissionController controller = new SubmissionController(); + SubmissionPart submissionPart = controller.addSubmissionPart(submissionPartPostRequest); + + return Response.ok(submissionPart).build(); + } + + @GET + @Path("/full/{id}/category/{category}") + public Response getSubmissionPart(@PathParam("id") String fullSubmissionId, @PathParam("category") String category) { + // get submission part from database based by id + SubmissionController controller = new SubmissionController(); + SubmissionPart submissionPart = controller.getSubmissionPart(fullSubmissionId, Category.valueOf(category.toUpperCase())); + + if (submissionPart != null) { + return Response.ok(submissionPart).build(); + } + else { + // declare response + SubmissionResponse response = new SubmissionResponse(); + response.setMessage("Submission part with the full submission id '" + fullSubmissionId + "' and the category '" + category.toUpperCase() + "' can't be found"); + + return Response.status(Response.Status.NOT_FOUND).entity(response).build(); + } + } + + @GET + @Path("/full/{id}/parts") + public Response getAllSubmissionParts(@PathParam("id") String fullSubmissionId) { + // get submission parts from database based by id + SubmissionController controller = new SubmissionController(); + ArrayList<SubmissionPart> parts = controller.getAllSubmissionParts(fullSubmissionId); + + if (parts.size() > 0) { + return Response.ok(parts).build(); + } + else { + SubmissionResponse response = new SubmissionResponse(); + response.setMessage("No submission parts found for submission with the id '" + fullSubmissionId + "'"); + + return Response.status(Response.Status.NOT_FOUND).entity(response).build(); + } + } + + @GET + @Path("/project/{id}") + public Response getSubmissionPartsByProjectId(@PathParam("id") String projectId) { + // get submission project representation from database based by project id + SubmissionController controller = new SubmissionController(); + ArrayList<SubmissionProjectRepresentation> representations = controller.getSubmissionPartsByProjectId(projectId); + + if (representations.size() > 0) { + return Response.ok(representations).build(); + } + else { + SubmissionResponse response = new SubmissionResponse(); + response.setMessage("No submission parts found for project id '" + projectId + "'"); + + return Response.status(Response.Status.NOT_FOUND).entity(response).build(); + } + } +} diff --git a/gemeinsamforschen/src/main/webapp/assets/css/annotationStyle.css b/gemeinsamforschen/src/main/webapp/assets/css/annotationStyle.css index 0dbf610d881507005fe7c9e4ff0bf8475356f093..a9ed0b540fd86a20c6375dfd3e602bd0d0f8a35b 100644 --- a/gemeinsamforschen/src/main/webapp/assets/css/annotationStyle.css +++ b/gemeinsamforschen/src/main/webapp/assets/css/annotationStyle.css @@ -148,10 +148,20 @@ ol { float: right; margin: 20px; } +.leftcontent-buttons-back { + float: left; + margin: 20px; +} .leftcontent-text { overflow: scroll; + white-space: pre-line; + color: lightgrey; } .resize-vertical { resize: vertical; } +.categoryText { + color: black; + font-weight: bold; +} diff --git a/gemeinsamforschen/src/main/webapp/assets/css/footer.css b/gemeinsamforschen/src/main/webapp/assets/css/footer.css index 2e2c0e2201dbb15067036094d7b3347845b22d96..beb5cbc6a2d2f0a9015b498d756e4a0531d77ca8 100644 --- a/gemeinsamforschen/src/main/webapp/assets/css/footer.css +++ b/gemeinsamforschen/src/main/webapp/assets/css/footer.css @@ -2,42 +2,37 @@ background:#DDDDDD; } -.pg-enrollment { +.pg-CourseCreation { background: #777777; width:5%; } -.pg-groups { +.pg-GroupFormation { background: #AAAA77; width:15%; } -.pg-dossier { +.pg-test { + background: #4F3A3E; + width: 50%; +} + +.pg-DossierFeedback { background: #AA77AA; width:30%; } -.pg-feedback { +.pg-Execution { background: #77AAAA; - width:45%; -} - -.pg-reflection { - background: #55AA55; - width:60%; -} - -.pg-presentation { - background: #5555AA; - width:70%; + width:55%; } -.pg-assessment { +.pg-Assessment { background: #AA5555; - width:85%; + width:75%; } -.pg-done { +.pg-Projectfinished { background: #34DD44; width:100%; } diff --git a/gemeinsamforschen/src/main/webapp/assets/css/unstructured-annotation.css b/gemeinsamforschen/src/main/webapp/assets/css/unstructured-annotation.css new file mode 100644 index 0000000000000000000000000000000000000000..53ad932cba2ed091225f101c0e1a72c5be1dbc18 --- /dev/null +++ b/gemeinsamforschen/src/main/webapp/assets/css/unstructured-annotation.css @@ -0,0 +1,165 @@ +body, html { + height: 100vh; + width: 100vw; +} +.content-mainpage { + display: flex; + box-sizing: border-box; + font-family: Arial; + height: 100%; + overflow-y: hidden; +} +.rightcolumn { + float: right; + width: 25%; + height: 100%; + padding: 10px; + display: inline-block; + overflow: scroll; +} +.leftcolumn { + padding: 10px; + float: left; + width: 75%; + display: inline-block; + /* background-color: yellow; */ +} +.rightcontent { + height: 100%; +} +.rightcontent ol { + padding: 0px; + margin: 0px; + list-style-type: none; + height: 100%; +} +.rightcontent li { + height: calc((100% - 70px) / 8); + min-height: 40px; +} +.leftcontent { + max-height: 100%; + display: flex; + flex-flow: column; + /* background-color: white; */ +} +.spacing { + margin-bottom: 10px; + /* background-color: orange; */ +} +.container-fluid-content { + display: flex; + flex-flow: column; + height: 100%; +} +.flex { + display: flex; +} +.flex .container-fluid{ + flex: 1; +} +.full-height { + height: 100%; +} +.leftcontent-buttons-save { + float: right; + margin: 20px; +} +.leftcontent-text { + overflow: scroll; + white-space: pre-line; +} +.category-card { + min-height: 30px; + height: 100%; + width: 100%; + border-radius: 5px; + font-weight: bold; + font-size: large; + overflow: hidden; +} +.category-card p { + position: relative; + float: left; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + max-width: 100%; +} +.not-added{ + border-style: dashed; + border-color: lightgray; + color: lightgray; +} + +.titel { + background-color: #ba68c8; +} +.added-titel { + border-style: solid; + border-color: #ba68c8; + color: #ba68c8; +} + +.recherche { + background-color: #7986cb; +} +.added-recherche { + border-style: solid; + border-color: #7986cb; + color: #7986cb; +} + +.literaturverzeichnis { + background-color: #4dd0e1; +} +.added-literaturverzeichnis { + border-style: solid; + border-color: #4dd0e1; + color: #4dd0e1; +} + +.forschungsfrage { + background-color: #81c784; +} +.added-forschungsfrage { + border-style: solid; + border-color: #81c784; + color: #81c784; +} + +.untersuchungskonzept { + background-color: #dce775; +} +.added-untersuchungskonzept { + border-style: solid; + border-color: #dce775; + color: #dce775; +} + +.methodik { + background-color: #ffd54f; +} +.added-methodik { + border-style: solid; + border-color: #ffd54f; + color: #ffd54f; +} + +.durchfuehrung { + background-color: #ff8a65; +} +.added-durchfuehrung { + border-style: solid; + border-color: #ff8a65; + color: #ff8a65; +} + +.auswertung { + background-color: #a1887f; +} +.added-auswertung { + border-style: solid; + border-color: #a1887f; + color: #a1887f; +} \ No newline at end of file diff --git a/gemeinsamforschen/src/main/webapp/assets/css/unstructured-upload.css b/gemeinsamforschen/src/main/webapp/assets/css/unstructured-upload.css new file mode 100644 index 0000000000000000000000000000000000000000..9b1c11047b5335b7f030735c5730f38debfc1afb --- /dev/null +++ b/gemeinsamforschen/src/main/webapp/assets/css/unstructured-upload.css @@ -0,0 +1,58 @@ +body, html { + height: 100vh; + width: 100vw; +} +.content-mainpage { + display: flex; + box-sizing: border-box; + font-family: Arial; + height: 100%; + overflow-y: scroll; + flex-flow: column nowrap; +} +.container-fluid-content { + display: flex; + flex-flow: column; + height: 100%; +} +.full-height { + height: 100%; +} +.flex { + display: flex; +} +.document-text-buttons { + margin-bottom: 15px; + margin-top: 15px; + display: inline; +} +.document-text-buttons-back { + float: left; +} +.document-text-buttons-next { + float: right; +} +.file-upload-area { + height: 20%; +} + +.upload-text { + display: flex; + flex-flow: column; + height: 100%; +} +.upload-text-textarea { + resize: none; + flex: 1; +} +#upload-textarea-form { + height: 100%; + margin-bottom: 15px; +} +label.error { + color: red; +} +.flex .container-fluid{ + flex: 1; +} + diff --git a/gemeinsamforschen/src/main/webapp/assets/css/upload-unstructured.css b/gemeinsamforschen/src/main/webapp/assets/css/upload-unstructured.css deleted file mode 100644 index 16ff7e4ce9ecbb4d462b22445ac2bbe064279705..0000000000000000000000000000000000000000 --- a/gemeinsamforschen/src/main/webapp/assets/css/upload-unstructured.css +++ /dev/null @@ -1,143 +0,0 @@ -ol { - padding: 0px; - margin: 0px; - list-style-type: none; -} -.mainpage { - display: flex; - box-sizing: border-box; - font-family: Arial; - height: 100%; -} -.rightcolumn { - float: right; - width: 25%; - display: inline-block; - /* background-color: blue; */ -} -.leftcolumn { - float: left; - width: 75%; - display: inline-block; - /* background-color: yellow; */ -} -.rightcontent { - margin: 10px; -} -.leftcontent { - margin: 10px; - /* background-color: white; */ -} -.spacing { - height: 10px; - /* background-color: orange; */ -} - -.annotation-card { - width: 100%; - box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2); - transition: 0.3s; - border-radius: 5px; - display: inline-block; - background-color: white; -} -.annotation-card:hover { - box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2); -} -.annotation-header { - padding: 5px; - display: flex; - flex-wrap: wrap; - align-items: center; - border-top-right-radius: 5px; - border-top-left-radius: 5px; - color: white; } -.annotation-header i { - font-size: 11px; -} -.annotation-header span { - font-size: 11px; - margin-left: 5px; - margin-right: 5px; -} -.annotation-header a:link { - color: white; - text-decoration: none; -} -.annotation-header a:visited { - color: white; - text-decoration: none; -} -.annotation-header a:active { - color: white; - text-decoration: none; -} -.annotation-header a:hover { - color: #e6e6e6; - text-decoration: none; -} -.annotation-header-title { - display: flex; - flex-flow: column; - width: calc(100% - 40px); -} -.annotation-header-toggle { - height: 40px; - width: 40px; - display: flex; - align-items: center; - justify-content: center; - cursor: pointer; -} -.annotation-body { - padding: 8px; - border-bottom-right-radius: 5px; - border-bottom-left-radius: 5px; -} -.annotation-body p { - margin: 0px; - font-size: 13px; -} -.overflow-hidden { - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; -} -.annotation-footer { - padding: 5px; - padding-top: 0px; - text-align: right; - font-size: 9px; - color: lightgrey; - display: flex; -} -.annotation-footer span { - margin-left: 5px; -} -.annotation-footer-delete { - margin-right: 5px; - cursor: pointer; -} -.annotation-footer-date { - flex: 1 -} - - - -.unstructured-textarea { - resize: none; -} -.document-text-buttons { - margin-top: 10px; - display: inline; -} -.document-text-buttons-lock { - float: left; -} -.document-text-buttons-back { - float: left; -} -.document-text-buttons-save { - float: right; -} - diff --git a/gemeinsamforschen/src/main/webapp/assets/img/noImg.png b/gemeinsamforschen/src/main/webapp/assets/img/noImg.png new file mode 100644 index 0000000000000000000000000000000000000000..efc3eb6959ce4f5badd7802c54bccfeccbf2ecf3 Binary files /dev/null and b/gemeinsamforschen/src/main/webapp/assets/img/noImg.png differ diff --git a/gemeinsamforschen/src/main/webapp/assets/js/annotationRest.js b/gemeinsamforschen/src/main/webapp/assets/js/annotationRest.js index 787ccd96b74c391cd417e4733b5281611012720b..76fd89c8f25a0d29e923f2e03d617e50890707df 100644 --- a/gemeinsamforschen/src/main/webapp/assets/js/annotationRest.js +++ b/gemeinsamforschen/src/main/webapp/assets/js/annotationRest.js @@ -81,10 +81,11 @@ function getAnnotation(id, responseHandler) { * GET: Get all annotations from database for a specific target * * @param targetId The target id + * @param targetCategory The category of the target * @param responseHandler The response handler */ -function getAnnotations(targetId, responseHandler) { - var url = "../rest/annotations/target/" + targetId; +function getAnnotations(targetId, targetCategory, responseHandler) { + var url = "../rest/annotations/targetid/" + targetId + "/targetcategory/" + targetCategory; $.ajax({ url: url, type: "GET", diff --git a/gemeinsamforschen/src/main/webapp/assets/js/annotationScript.js b/gemeinsamforschen/src/main/webapp/assets/js/annotationScript.js index 5150c1f92e7e23ebe6045b9df333dce7667093a9..b6f25d8c8adba325836a6a282a147429b155dd34 100644 --- a/gemeinsamforschen/src/main/webapp/assets/js/annotationScript.js +++ b/gemeinsamforschen/src/main/webapp/assets/js/annotationScript.js @@ -1,19 +1,52 @@ -// initialize userToken, userColors and targetId -var userToken = getUserTokenFromUrl(); +// initialize userToken, userColors var userColors = new Map(); var userColorsDark = new Map(); -var targetId = 200; // declare document text, start and end character -var documentText, startCharacter, endCharacter; +var startCharacter, endCharacter; /** * This function will fire when the DOM is ready */ $(document).ready(function() { + let fullSubmissionId = getQueryVariable("fullSubmissionId"); + let category = getQueryVariable("category"); + + // fetch full submission from database + getFullSubmission(getQueryVariable("fullSubmissionId"), function (response) { + + // set text + $('#documentText').html(response.text); + + // fetch submission parts + getSubmissionPart(fullSubmissionId, category, function (response) { + + let body = response.body; + // save body + $('#documentText').data("body", body); + let offset = 0; + for (let i = 0; i < body.length; i++) { + addHighlightedSubmissionPart(body[i].startCharacter, body[i].endCharacter, offset); + // add char count of '<span class="categoryText"></span>' + offset += 34; + } + + // scroll document text to first span element + let documentText = $('#documentText'); + let span = $('#documentText span').first(); + documentText.scrollTo(span); + + + }, function () { + // error + }) + + }, function () { + // error + }); // connect to websocket on page ready - connect(targetId); + connect(fullSubmissionId, category); /** * Context menu handler @@ -22,17 +55,8 @@ $(document).ready(function() { selector: '.context-menu-one', callback: function(key, options) { - // action for 'annotation' click - if (key == 'annotation') { - // show modal if something is selected - if (getSelectedText().length > 0) { - startCharacter = window.getSelection().getRangeAt(0).startOffset; - endCharacter = window.getSelection().getRangeAt(0).endOffset; - - // display annotation create modal - $('#annotation-create-modal').modal("show"); - } - } + // handle annotation context click + handleAnnotationClick() }, items: { @@ -47,6 +71,13 @@ $(document).ready(function() { location.href="givefeedback.jsp?token=" + getUserTokenFromUrl(); }); + /** + * back button + */ + $('#btnBack').click(function () { + location.href="project-student.jsp?token=" + getUserTokenFromUrl() + "&projectId=" + getQueryVariable("projectId"); + }); + /** * validation of annotation create form inside the modal */ @@ -201,10 +232,8 @@ $(document).ready(function() { $('#annotation-edit-form-comment').val('') }); - documentText = $('#documentText').html(); - // fetch annotations from server on page start - getAnnotations(targetId, function (response) { + getAnnotations(fullSubmissionId, category, function (response) { // iterate over annotations and display each $.each(response, function (i, annotation) { displayAnnotation(annotation); @@ -305,7 +334,7 @@ function displayAnnotation(annotation) { .append( // edit function () { - if (userToken == annotation.userToken) { + if (getUserTokenFromUrl() === annotation.userToken) { return $('<div>').attr('class', 'annotation-footer-edit') .append( $('<i>').attr('class', editIcon) @@ -332,7 +361,12 @@ function displayAnnotation(annotation) { ) .data('annotation', annotation) .mouseenter(function () { - addHighlightedText(annotation.body.startCharacter, annotation.body.endCharacter, annotation.userToken); + addHighlightedAnnotation(annotation.body.startCharacter, annotation.body.endCharacter, annotation.userToken); + + // scroll document text to anchor element + let documentText = $('#documentText'); + let anchor = $('#anchor'); + documentText.scrollTo(anchor); }) .mouseleave(function () { deleteHighlightedText(); @@ -352,25 +386,84 @@ function displayAnnotation(annotation) { * @param endCharacter The offset of the end character * @param userToken The user token */ -function addHighlightedText(startCharacter, endCharacter, userToken) { +function addHighlightedAnnotation(startCharacter, endCharacter, userToken) { + let offset = calculateExtraOffset(startCharacter); + + // initialize variables + let documentText = $('#documentText').text(); + let documentHtml = $('#documentText').html(); + // create <span> tag with the annotated text - var replacement = $('<span></span>').css('background-color', getUserColor(userToken)).html(documentText.slice(startCharacter, endCharacter)); + var replacement = $('<span></span>').attr('id', 'anchor').css('background-color', getUserColor(userToken)).html(documentText.slice(startCharacter, endCharacter)); // wrap an <p> tag around the replacement, get its parent (the <p>) and ask for the html var replacementHtml = replacement.wrap('<p/>').parent().html(); // insert the replacementHtml - var newDocument = documentText.slice(0, startCharacter) + replacementHtml + documentText.slice(endCharacter); + var newDocument = documentHtml.slice(0, startCharacter + offset) + replacementHtml + documentHtml.slice(endCharacter + offset); // set new document text $('#documentText').html(newDocument); } +/** + * Add a highlighted text at specific position + * + * @param startCharacter The offset of the start character + * @param endCharacter The offset of the end character + * @param offset The calculated extra offset depending on already highlighted text + */ +function addHighlightedSubmissionPart(startCharacter, endCharacter, offset) { + + var documentText = $('#documentText').text(); + var documentHtml = $('#documentText').html(); + + // create <span> tag with the annotated text + var replacement = $('<span></span>').attr('class', 'categoryText').html(documentText.slice(startCharacter, endCharacter)); + + // wrap an <p> tag around the replacement, get its parent (the <p>) and ask for the html + var replacementHtml = replacement.wrap('<p/>').parent().html(); + + // insert the replacementHtml + var newDocument = documentHtml.slice(0, startCharacter + offset) + replacementHtml + documentHtml.slice(endCharacter + offset); + + // set new document text + $('#documentText').html(newDocument); +} + +/** + * Iterate over all data arrays and calculate the offset for a given start character + * + * @param startCharacter The given start character + * @returns {number} The offset + */ +function calculateExtraOffset(startCharacter) { + // get submission part body + let body = $('#documentText').data("body"); + let extraOffset = 0; + + for (let i = 0; i < body.length; i++) { + if (body[i].startCharacter <= startCharacter) { + extraOffset += 27; + } + if (body[i].endCharacter <= startCharacter) { + extraOffset += 7; + } + } + + return extraOffset; +} + /** * Restore the base text */ function deleteHighlightedText() { - $('#documentText').html(documentText); + + let documentText = $('#documentText'); + let highlight = documentText.find('#anchor'); + let text = highlight.text(); + highlight.replaceWith(text); + } /** @@ -522,10 +615,17 @@ function toggleButtonHandler(id) { * @param endCharacter The endCharacter based on the annotated text */ function saveNewAnnotation(title, comment, startCharacter, endCharacter) { + + // initialize target + let targetId = getQueryVariable("fullSubmissionId"); + let targetCategory = getQueryVariable("category"); + let userToken = getUserTokenFromUrl(); + // build annotationPostRequest var annotationPostRequest = { userToken: userToken, targetId: targetId, + targetCategory: targetCategory, body: { title: title, comment: comment, @@ -640,3 +740,54 @@ function showAndHideToggleButtonById(id) { annotationElement.find('.annotation-header-data').css('width', '100%'); } } + +/** + * Handle the annotation click and show the modal + * + */ +function handleAnnotationClick() { + + // if saved selection's range count is > 0 + let sel = rangy.getSelection(); + if (sel.rangeCount > 0) { + // calculate character range offset from range + let range = sel.getRangeAt(0); + let offsets = range.toCharacterRange($('#documentText')[0]); + + // if selected text's length is > 0 + let selectedText = getSelectedText(); + if (selectedText.length > 0) { + // save start and end character and handle the selection + startCharacter = offsets.start; + endCharacter = offsets.end; + + if (isAnnotationInRange(startCharacter, endCharacter)) { + // display annotation create modal + $('#annotation-create-modal').modal("show"); + } + else { + window.alert("Annotationen sind nur in vorgehobenen Bereichen möglich") + } + + + } + } + +} + +/** + * Checks if user selected area is inside submission part range + * + * @param start The start character of the selection + * @param end The end character of the selection + * @returns {boolean} Returns true if the selection is in range + */ +function isAnnotationInRange(start, end) { + let body = $('#documentText').data("body"); + for (let i = 0; i < body.length; i++) { + if (body[i].startCharacter <= start && end <= body[i].endCharacter) { + return true; + } + } + return false; +} diff --git a/gemeinsamforschen/src/main/webapp/assets/js/annotationWebsocket.js b/gemeinsamforschen/src/main/webapp/assets/js/annotationWebsocket.js index 62bbd2f33c69daada2c18e08614c9ab718ad6c00..5c3ced1b8d2017cf5e7365a17306d90c6ba37d49 100644 --- a/gemeinsamforschen/src/main/webapp/assets/js/annotationWebsocket.js +++ b/gemeinsamforschen/src/main/webapp/assets/js/annotationWebsocket.js @@ -1,10 +1,10 @@ var ws; -function connect(targetId) { +function connect(targetId, targetCategory) { var host = document.location.host; var pathname = document.location.pathname; - ws = new WebSocket("ws://" + host + "/ws/annotation/" + targetId); + ws = new WebSocket("ws://" + host + "/ws/annotation/" + targetId + "/" + targetCategory); ws.onmessage = function (e) { var message = JSON.parse(e.data); diff --git a/gemeinsamforschen/src/main/webapp/assets/js/changePhase.js b/gemeinsamforschen/src/main/webapp/assets/js/changePhase.js new file mode 100644 index 0000000000000000000000000000000000000000..d35d4ceb258534952e37a952450705f2c0f24b4d --- /dev/null +++ b/gemeinsamforschen/src/main/webapp/assets/js/changePhase.js @@ -0,0 +1,58 @@ +$(document).ready(function () { + let projectId = $('#projectId').html().trim(); + $.ajax({ + url: '../rest/phases/projects/'+projectId, + headers: { + "Content-Type": "application/json", + "Cache-Control": "no-cache" + }, + type: 'GET', + success: function (response) { + let phaseDiv = $('#'+response); + if (phaseDiv !== null){ + phaseDiv.toggleClass('alert-info'); + } else { + $('#end').toggleClass('alert-info'); + } + }, + error: function (a) { + + } + }); + $('#btnAssessment').on('click', function(){ + changePhase('Assessment'); + }); + $('#btnExecution').on('click', function(){ + changePhase('Execution'); + }); + $('#btnGroupformation').on('click', function(){ + changePhase('GroupFormation'); + }); + $('#btnCourseCreation').on('click', function(){ + changePhase('CourseCreation'); + }); + $('#btnDossierFeedback').on('click', function(){ + changePhase('DossierFeedback'); + }); + $('#btnProjectfinished').on('click', function(){ + changePhase('Projectfinished'); + }); +}); + +function changePhase(toPhase){ + let projectId = $('#projectId').html().trim(); + $.ajax({ + url: '../rest/phases/'+toPhase+'/projects/'+projectId, + headers: { + "Content-Type": "application/json", + "Cache-Control": "no-cache" + }, + type: 'POST', + success: function () { + location.href="#" + }, + error: function (a) { + + } + }); +} \ No newline at end of file diff --git a/gemeinsamforschen/src/main/webapp/assets/js/createProject.js b/gemeinsamforschen/src/main/webapp/assets/js/createProject.js index 409171b0173bbcbd105b0d9955123fc78570d606..696572480960c61746fcf08f4f70d407a9037d95 100644 --- a/gemeinsamforschen/src/main/webapp/assets/js/createProject.js +++ b/gemeinsamforschen/src/main/webapp/assets/js/createProject.js @@ -2,4 +2,25 @@ $(document).ready(function(){ $('#submit').on('click', function(){ location.href="specificRequirement.jsp?token="+getUserTokenFromUrl(); }); + let projectId = $('#projectId').html().trim(); + $.ajax({ + url: '../rest/phases/projects/'+projectId, + headers: { + "Content-Type": "application/json", + "Cache-Control": "no-cache" + }, + type: 'GET', + success: function (response) { + let phaseDiv = $('#'+response); + if (phaseDiv !== null){ + phaseDiv.toggleClass('alert','alert-info'); + } else { + $('#end').addClass('alert-info'); + } + + }, + error: function (a) { + + } + }); }); \ No newline at end of file diff --git a/gemeinsamforschen/src/main/webapp/assets/js/createQuiz.js b/gemeinsamforschen/src/main/webapp/assets/js/createQuiz.js index b8e097d0a5e1ae22d441c4cc3ac79d3d04c21ab6..37413173379a5a73600abf21938d1ef9be06dede 100644 --- a/gemeinsamforschen/src/main/webapp/assets/js/createQuiz.js +++ b/gemeinsamforschen/src/main/webapp/assets/js/createQuiz.js @@ -1,34 +1,34 @@ $(document).ready(function () { $('#addCorrectAnswer').on('click', function(){ - var divCorrectAnswer = document.getElementById('correctAnswers'); - var i = divCorrectAnswer.children.length; - var inputCorrectAnswer = document.createElement('INPUT'); + let divCorrectAnswer = document.getElementById('correctAnswers'); + let i = divCorrectAnswer.children.length; + let inputCorrectAnswer = document.createElement('INPUT'); inputCorrectAnswer.id='correctAnswer'+i; divCorrectAnswer.appendChild(inputCorrectAnswer); }); $('#addIncorrectAnswer').on('click', function(){ - var divIncorrectAnswer = document.getElementById('incorrectAnswers'); - var i = divIncorrectAnswer.children.length; - var inputIncorrectAnswer = document.createElement('INPUT'); + let divIncorrectAnswer = document.getElementById('incorrectAnswers'); + let i = divIncorrectAnswer.children.length; + let inputIncorrectAnswer = document.createElement('INPUT'); inputIncorrectAnswer.id='incorrectAnswer'+i; divIncorrectAnswer.appendChild(inputIncorrectAnswer); }); $('#deleteCorrectAnswer').on('click', function(){ - var divCorrectAnswer = document.getElementById('correctAnswers'); + let divCorrectAnswer = document.getElementById('correctAnswers'); divCorrectAnswer.removeChild(divCorrectAnswer.lastChild); }); $('#deleteIncorrectAnswer').on('click', function(){ - var divIncorrectAnswer = document.getElementById('incorrectAnswers'); + let divIncorrectAnswer = document.getElementById('incorrectAnswers'); divIncorrectAnswer.removeChild(divIncorrectAnswer.lastChild); }); $("#save").on('click', function () { - var correctAnswers= []; - var incorrectAnswers= []; - var shuttleList = document.getElementById('correctAnswers'); + let correctAnswers= []; + let incorrectAnswers= []; + let shuttleList = document.getElementById('correctAnswers'); for (var i=0; i<shuttleList.children.length; i++) { correctAnswers.push(shuttleList.children[i].value.trim()) @@ -38,17 +38,17 @@ $(document).ready(function () { { incorrectAnswers.push(shuttleList.children[i].value.trim()) } - var quiz = { + let quiz = { question: $('#question').val().trim(), type: 'mc', correctAnswers: correctAnswers, incorrectAnswers: incorrectAnswers }; - var studentIdentifier = { + let studentIdentifier = { studentId: $('#user').html().trim(), projectId: $('#projectId').html().trim() }; - var data = JSON.stringify({ + let data = JSON.stringify({ studentIdentifier: studentIdentifier, quiz: quiz }); diff --git a/gemeinsamforschen/src/main/webapp/assets/js/finalAssessment.js b/gemeinsamforschen/src/main/webapp/assets/js/finalAssessment.js index a56e8a766a20f895dd8674056e796e5613bbc5b0..0f57c3bec407e642306c68bb0fed7651af94a53b 100644 --- a/gemeinsamforschen/src/main/webapp/assets/js/finalAssessment.js +++ b/gemeinsamforschen/src/main/webapp/assets/js/finalAssessment.js @@ -1,57 +1,180 @@ -$(document).ready(function() { +$(document).ready(function () { + checkAssessementPhase(); + + $('#notAllRated').hide(); $(".carousel").carousel({ interval: false }); + buildTablesForPeers(); + $('#assessThePeer').on("click", function () { assessPeer(); }); }); -function assessPeer(){ - let peerStudents =$('.peerStudent'); + +function buildTablesForPeers() { + let studentId = $('#user').html().trim(); + let projectId = $('#projectId').html().trim(); + $.ajax({ + url: '../rest/group/project/' + projectId + '/student/' + studentId, + type: 'GET', + headers: { + "Content-Type": "text/javascript", + "Cache-Control": "no-cache" + }, + success: function (peers) { + let div = document.getElementById('peerTable'); + for (let peer = 0; peer < peers.length; peer++) { + let tablePeer = document.createElement('DIV'); + if (peer === 0) { + tablePeer.className = "item active"; + } else { + tablePeer.className = "item"; + } + let innerPeerTable = '<table class="table-striped peerStudent" id="' + peers[peer] + '">' + + '<tr>' + + '<td align="center">' + + '<img src="../assets/img/noImg.png" alt="' + peers[peer] + '" style="width:20%;">' + + '</td>' + + '</tr>' + + '<tr>' + + '<td align="center">' + + '<h3>Verantwortungsbewusstsein</h3>' + + '</td>' + + '</tr>' + + '<tr>' + + '<td align="center">' + + '<label>stark ausgeprägt<input type="radio" value="5" name="responsibility' + peers[peer] + '"></label>' + + '<input type="radio" value="4" name="responsibility' + peers[peer] + '">' + + '<input type="radio" value="3" name="responsibility' + peers[peer] + '">' + + '<input type="radio" value="2" name="responsibility' + peers[peer] + '">' + + '<label><input type="radio" value="1" name="responsibility' + peers[peer] + '">ungenügend</label>' + + '</td>' + + '</tr>' + + '<tr>' + + '<td align="center">' + + '<h3>Anteil am Produkt</h3>' + + '</td>' + + '</tr>' + + '<tr>' + + '<td align="center">' + + '<label>großer Anteil<input type="radio" value="5" name="partOfWork' + peers[peer] + '"></label>' + + '<input type="radio" value="4" name="partOfWork' + peers[peer] + '">' + + '<input type="radio" value="3" name="partOfWork' + peers[peer] + '">' + + '<input type="radio" value="2" name="partOfWork' + peers[peer] + '">' + + '<label><input type="radio" value="1" name="partOfWork' + peers[peer] + '">geringer Anteil</label>' + + '</td>' + + '</tr>' + + '<tr>' + + '<td align="center">' + + '<h3>Kooperationsbereitschaft</h3>' + + '</td>' + + '</tr>' + + '<tr>' + + '<td align="center">' + + '<label>sehr kooperativ<input type="radio" value="5" name="cooperation' + peers[peer] + '">' + + '</label>' + + '<input type="radio" value="4" name="cooperation' + peers[peer] + '">' + + '<input type="radio" value="3" name="cooperation' + peers[peer] + '">' + + '<input type="radio" value="2" name="cooperation' + peers[peer] + '">' + + '<label><input type="radio" value="1" name="cooperation' + peers[peer] + '">nicht kooperativ</label>' + + '</td>' + + '</tr>' + + '<tr>' + + '<td align="center">' + + '<h3>Disskusionsfähigkeit</h3>' + + '</td>' + + '</tr>' + + '<tr>' + + '<td align="center">' + + '<label>gut kommuniziert und Meinung vertreten<input type="radio" value="5" name="communication' + peers[peer] + '">' + + '</label>' + + '<input type="radio" value="4" name="communication' + peers[peer] + '">' + + '<input type="radio" value="3" name="communication' + peers[peer] + '">' + + '<input type="radio" value="2" name="communication' + peers[peer] + '">' + + '<label><input type="radio" value="1" name="communication' + peers[peer] + '">keine Meinung und schlecht kommuniziert</label>' + + '</td>' + + '</tr>' + + '<tr>' + + '<td align="center">' + + '<h3>Selbstständigkeit</h3>' + + '</td>' + + '</tr>' + + '<tr>' + + '<td align="center">' + + '<label>selbstständig<input type="radio" value="5" name="autonomous' + peers[peer] + '">' + + '</label>' + + '<input type="radio" value="4" name="autonomous' + peers[peer] + '">' + + '<input type="radio" value="3" name="autonomous' + peers[peer] + '">' + + '<input type="radio" value="2" name="autonomous' + peers[peer] + '">' + + '<label><input type="radio" value="1" name="autonomous' + peers[peer] + '">abhängig</label>' + + '</td>' + + '</tr>' + + '</table>' + + '<div align="center">' + + ' <button class="btn btn-primary" id="btnJournal' + peers[peer] + '">' + + ' zeige Lernzieltagebuch</button>' + + ' <div id="eJournal' + peers[peer] + '">Fasel Blubba Bla</div>' + + '</div>'; + tablePeer.innerHTML = innerPeerTable; + div.appendChild(tablePeer); + $('#btnJournal' + peers[peer]).on("click", function () { + $('#eJournal' + peers[peer]).toggle(); + }); + } + }, + error: function () { + } + } + ); +} + +function assessPeer() { + let peerStudents = $('.peerStudent'); ///////initialize variables/////// - let dataP = new Array(peerStudents.size()); - let rateThis = ['responsibility','partOfWork','cooperation','communication','autonomous']; + let dataP = new Array(peerStudents.length); + let rateThis = ['responsibility', 'partOfWork', 'cooperation', 'communication', 'autonomous']; ///////read values from html/////// - for (let peer=0; peer< peerStudents.length; peer++){ + for (let peer = 0; peer < peerStudents.length; peer++) { let workRating = {}; let peerRating = { "fromPeer": $('#user').html().trim(), "toPeer": peerStudents[peer].id, "workRating": {} }; - for (let rate=0; rate<rateThis.length; rate++ ){ + for (let rate = 0; rate < rateThis.length; 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()); } peerRating.workRating = workRating; //////write values in Post-Variable - dataP[peer]=peerRating; + dataP[peer] = peerRating; } - for (let peer=0; peer< dataP.length; peer++){ - for (let workRating=0; workRating<rateThis.length;workRating++){ - if(dataP[peer].workRating[rateThis[workRating]]===undefined){ + for (let peer = 0; peer < dataP.length; peer++) { + for (let workRating = 0; workRating < rateThis.length; workRating++) { + if (dataP[peer].workRating[rateThis[workRating]] === undefined) { $('#notAllRated').show(); return; } } } - let projectId=$('#projectId').html().trim(); + let projectId = $('#projectId').html().trim(); $.ajax({ - url:'../rest/assessments/peerRating/project/'+projectId, + url: '../rest/assessments/peerRating/project/' + projectId, type: 'POST', headers: { "Content-Type": "application/json", "Cache-Control": "no-cache" }, data: JSON.stringify(dataP), - success: function(){ - location.href="takeQuiz.jsp?token="+getUserTokenFromUrl()+"&projectId="+$('#projectId').html().trim(); + success: function () { + location.href = "takeQuiz.jsp?token=" + getUserTokenFromUrl() + "&projectId=" + $('#projectId').html().trim(); }, - error: function(a,b,c){ + error: function (a, b, c) { } }); diff --git a/gemeinsamforschen/src/main/webapp/assets/js/footer.js b/gemeinsamforschen/src/main/webapp/assets/js/footer.js index 33e3ada606d22727234e01d6fa131f67e1240009..9407ef60d1a1c1af5d8bce6c5dc1e9c1835645bc 100644 --- a/gemeinsamforschen/src/main/webapp/assets/js/footer.js +++ b/gemeinsamforschen/src/main/webapp/assets/js/footer.js @@ -1,31 +1,3 @@ $(document).ready(function(){ - $('#nextPhase').click(function(){ - var progressbar =$('#progressbar'); - switch (progressbar.attr('class')){ - case 'progress-bar pg-groups': - progressbar.removeClass('pg-groups'); - progressbar.addClass('pg-dossier'); - break; - case 'progress-bar pg-dossier': - progressbar.removeClass('pg-dossier'); - progressbar.addClass('pg-feedback'); - break; - case 'progress-bar pg-feedback': - progressbar.removeClass('pg-feedback'); - progressbar.addClass('pg-reflection'); - break; - case 'progress-bar pg-reflection': - progressbar.removeClass('pg-reflection'); - progressbar.addClass('pg-presentation'); - break; - case 'progress-bar pg-presentation': - progressbar.removeClass('pg-presentation'); - progressbar.addClass('pg-assessment'); - break; - case 'progress-bar pg-assessment': - progressbar.removeClass('pg-assessment'); - progressbar.addClass('pg-done'); - break; - } - }); + }); diff --git a/gemeinsamforschen/src/main/webapp/assets/js/profile.js b/gemeinsamforschen/src/main/webapp/assets/js/profile.js new file mode 100644 index 0000000000000000000000000000000000000000..63b2a09e747bacbc099f3f188ccc0d1222799881 --- /dev/null +++ b/gemeinsamforschen/src/main/webapp/assets/js/profile.js @@ -0,0 +1,49 @@ +$(document).ready(function (e) { + /*$("#uploadimage").on('submit',(function(e) { + e.preventDefault(); + $("#message").empty(); + $('#loading').show(); + $.ajax({ + url: "../rest/user/student/wiepke", // Url to which the request is send + method: "POST", + type: "POST", // Type of request to be send, called as method + data: new FormData(this), // Data sent to server, a set of key/value pairs (i.e. form fields and values) + contentType: false, // The content type used when sending data to the server. + cache: false, // To unable request pages to be cached + processData:false, // To send DOMDocument or non processed data file it is set to false + success: function(data) // A function to be called if request succeeds + { + $('#loading').hide(); + $("#message").html(data); + } + }); + }));*/ + +// Function to preview image after validation + $(function() { + $("#file").change(function() { + $("#message").empty(); // To remove the previous error message + let file = this.files[0]; + let match= ["image/jpeg","image/png","image/jpg"]; + if(!((file.type===match[0]) || (file.type===match[1]) || (file.type===match[2]))) + { + $('#previewing').attr('src','noimage.png'); + $("#message").html("<p id='error'>Please Select A valid Image File</p>"+"<h4>Note</h4>"+"<span id='error_message'>Only jpeg, jpg and png Images type allowed</span>"); + return false; + } + else + { + var reader = new FileReader(); + reader.onload = imageIsLoaded; + reader.readAsDataURL(this.files[0]); + } + }); + }); + function imageIsLoaded(e) { + $("#file").css("color","green"); + $('#image_preview').css("display", "block"); + $('#previewing').attr('src', e.target.result); + $('#previewing').attr('width', '250px'); + $('#previewing').attr('height', '230px'); + }; +}); \ No newline at end of file diff --git a/gemeinsamforschen/src/main/webapp/assets/js/project-student.js b/gemeinsamforschen/src/main/webapp/assets/js/project-student.js index ffc7facbdd443de53ce28d7faeb0cefd84298e7a..520600a93a3444968585c2d382cd2497acb5c0b5 100644 --- a/gemeinsamforschen/src/main/webapp/assets/js/project-student.js +++ b/gemeinsamforschen/src/main/webapp/assets/js/project-student.js @@ -1,4 +1,27 @@ $(document).ready(function(){ + // fetch all submission part project representations from database + getSubmissionPartsByProjectId(getQueryVariable("projectId"), function (response) { + + // iterate over response and display each element + for (let i = 0; i < response.length; i++) { + displaySubmission(response[i].user, response[i].category, response[i].fullSubmissionId); + } + + // add click listener to feedback buttons + $('.annotationview').click(function () { + let fullSubmissionId = $(this).closest("li").data("fullSubmissionId"); + let category = $(this).closest("li").data("category"); + location.href="annotation-document.jsp?token=" + getUserTokenFromUrl() + + "&projectId=" + getQueryVariable("projectId") + + "&fullSubmissionId=" + fullSubmissionId + + "&category=" + category; + }); + + }, function () { + // display empty view + displayEmptyView() + }); + /* var memberTable = $('#myGroupMembers'); memberTable.hide(); @@ -13,11 +36,67 @@ $(document).ready(function(){ location.href="viewfeedback.jsp?token="+getUserTokenFromUrl(); }); - $('.annotationview').click(function () { - location.href="annotation-document.jsp?token="+getUserTokenFromUrl(); - }); - $('#btnUnstructuredUpload').click(function () { - location.href="upload-unstructured.jsp?token="+getUserTokenFromUrl(); + location.href="unstructured-upload.jsp?token="+getUserTokenFromUrl() + "&projectId=" + getQueryVariable("projectId"); + }) +}); + +/** + * Display category of submission part in list + * + * @param user The user of the submission part + * @param category The category of the submission part + * @param fullSubmissionId The id of the full submission the submission part belongs to + */ +function displaySubmission(user, category, fullSubmissionId) { + // build link + $('#submissionUpload').append( + $('<li>') + .append($('<span>').append(category.toUpperCase() + " eingereicht")) + .append($('<a>').attr("class", "annotationview").attr("role", "button") + .append($('<label>').css("font-size", "10px") + .append($('<i>').attr("class", "far fa-comments").css("font-size", "15px")) + .append("feedback") + ) + ) + // add data to link + .data("fullSubmissionId", fullSubmissionId) + .data("category", category) + ); + +} + +/** + * Display a not found message if there are no submission parts in the database (or on error) + */ +function displayEmptyView() { + // build link + $('#submissionUpload').append( + $('<li>') + .append($('<span>').append("keine Daten gefunden")) + ); +} + +/** + * GET: Get all representations of a submission part for a given project id + * + * @param projectId The id of the project + * @param responseHandler The response handler + * @param errorHandler The error handler + */ +function getSubmissionPartsByProjectId(projectId, responseHandler, errorHandler) { + var url = "../rest/submissions/project/" + projectId; + $.ajax({ + url: url, + type: "GET", + dataType: "json", + success: function (response) { + // handle the response + responseHandler(response); + }, + error: function () { + // handle the error + errorHandler(); + } }) -}); \ No newline at end of file +} \ No newline at end of file diff --git a/gemeinsamforschen/src/main/webapp/assets/js/rateContribution.js b/gemeinsamforschen/src/main/webapp/assets/js/rateContribution.js index b7e3c6b5fcaafd34e8c7c7066027d6d1a7d6069c..402b474a1d1d3f9816757b53e8d7b3fed725e750 100644 --- a/gemeinsamforschen/src/main/webapp/assets/js/rateContribution.js +++ b/gemeinsamforschen/src/main/webapp/assets/js/rateContribution.js @@ -1,10 +1,4 @@ $(document).ready(function () { - new InscrybMDE({ - element: document.getElementById("ejournalFeedback"), - spellChecker: false, - //toolbar: ["bold", "italic", "heading", "|", "quote", "table", "code", "|" , "side-by-side", "fullscreen"], - minHeight: "80px", - }); new InscrybMDE({ element: document.getElementById("presentationFeedback"), spellChecker: false, @@ -18,6 +12,7 @@ $(document).ready(function () { minHeight: "80px", }); + whichGroupToRate(); //editor.style = "min-height: 100px"; @@ -27,6 +22,25 @@ $(document).ready(function () { }); }); +function whichGroupToRate(){ + let projectId = $('#projectId').html().trim(); + let studentId = $('#user').html().trim(); + $.ajax({ + url: '../rest/assessments/groupRate/project/'+projectId+'/student/'+studentId, + type: 'GET', + headers: { + "Content-Type": "application/json", + "Cache-Control": "no-cache" + }, + success: function (groupId) { + $('#groupId').html(groupId); + }, + error: function () { + + } + }) +} + function safeContributionRating() { let contributions = $('.contributionRating'); ///////initialize variables/////// @@ -37,12 +51,10 @@ function safeContributionRating() { 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'); + let groupId = $('#groupId').html().trim(); $.ajax({ - url: '../rest/assessments/contributionRating/projectId/' + projectId + - '/studentId/' + toStudent + '/fromPeer/' + fromPeer, + url: '../rest/assessments/contributionRating/group/'+groupId+'/fromPeer/' + fromPeer, type: 'POST', headers: { "Content-Type": "application/json", diff --git a/gemeinsamforschen/src/main/webapp/assets/js/unstructuredAnnotation.js b/gemeinsamforschen/src/main/webapp/assets/js/unstructuredAnnotation.js new file mode 100644 index 0000000000000000000000000000000000000000..f420bbbd12047f018cbba3c6c4d306e03b3cf3e3 --- /dev/null +++ b/gemeinsamforschen/src/main/webapp/assets/js/unstructuredAnnotation.js @@ -0,0 +1,320 @@ +/** + * This function will fire when the DOM is ready + */ +$(document).ready(function() { + + // fetch the document text of the given id + getFullSubmission(getSubmissionIdFromUrl(), function (response) { + // set text in div + $('#documentText').html(response.text); + + // get submissions parts from database + getAllSubmissionParts(getSubmissionIdFromUrl(), function (response) { + + // iterate over response + for (let i = 0; i < response.length; i++) { + // save current category and body + let category = response[i].category; + let body = response[i].body; + // iterate over body and handle every selection + for (let j = 0; j < body.length; j++) { + handleCategorySelection(category.toLowerCase(), body[j].startCharacter, body[j].endCharacter); + } + } + + }); + + }, function () { + // jump to upload page on error + location.href="unstructured-upload.jsp?token=" + getUserTokenFromUrl() + "&projectId=" + getQueryVariable("projectId"); + }); + + // set click listener to save button + $('#btnSave').click(function () { + saveButtonHandler(); + }); + + /** + * Context menu handler + */ + $.contextMenu({ + selector: '.context-menu-one', + callback: function(key, options) { + + // handle the category click + handleCategoryClick(key); + + }, + items: { + "annotation": { + name: "Annotation", + icon: "edit", + items: { + "titel": {name: "Titel"}, + "recherche": {name: "Recherche"}, + "literaturverzeichnis": {name: "Literaturverzeichnis"}, + "forschungsfrage": {name: "Forschungsfrage"}, + "untersuchungskonzept": {name: "Untersuchungskonzept"}, + "methodik": {name: "Methodik"}, + "durchfuehrung": {name: "Durchführung"}, + "auswertung": {name: "Auswertung"} + } + } + + } + }); + +}); + +/** + * Get the id of a full submission from url + * + * @returns The id of the full submission + */ +function getSubmissionIdFromUrl() { + var parts = window.location.search.substr(1).split("&"); + var $_GET = {}; + for (var i = 0; i < parts.length; i++) { + var temp = parts[i].split("="); + $_GET[decodeURIComponent(temp[0])] = decodeURIComponent(temp[1]); + } + return $_GET['submission']; + +} + +/** + * Handel the category selection + * + * @param category The chosen category + * @param startCharacter The start character of the selected range + * @param endCharacter The end character of the selected range + */ +function handleCategorySelection(category, startCharacter, endCharacter) { + + // if highlighting is possible + if (!isAlreadyHighlighted(startCharacter, endCharacter)) { + + // check if element has 'not-added' class + var elem = $('#' + category); + if (elem.hasClass("not-added")) { + elem.toggleClass("not-added added-" + category); + } + + // add highlighted text based on selected text + addHighlightedText(startCharacter, endCharacter, category, calculateExtraOffset(startCharacter)); + + // update data from category list + addSelectionDataToList(startCharacter, endCharacter, category); + } + else { + // show error message to user + window.alert("Dieser Bereich wurde bereits zugeordnet.") + } + +} + +/** + * Get the text value of the selected text + * + * @returns {string} The text + */ +function getSelectedText() { + if(window.getSelection){ + return window.getSelection().toString(); + } + else if(document.getSelection){ + return document.getSelection(); + } + else if(document.selection){ + return document.selection.createRange().text; + } +} + +/** + * Add a highlighted text at specific position + * + * @param startCharacter The offset of the start character + * @param endCharacter The offset of the end character + * @param category The category selected by user + * @param offset The calculated extra offset depending on already highlighted text + */ +function addHighlightedText(startCharacter, endCharacter, category, offset) { + + var documentText = $('#documentText').text(); + var documentHtml = $('#documentText').html(); + + // create <span> tag with the annotated text + var replacement = $('<span></span>').attr('class', category).html(documentText.slice(startCharacter, endCharacter)); + + // wrap an <p> tag around the replacement, get its parent (the <p>) and ask for the html + var replacementHtml = replacement.wrap('<p/>').parent().html(); + + // insert the replacementHtml + var newDocument = documentHtml.slice(0, startCharacter + offset) + replacementHtml + documentHtml.slice(endCharacter + offset); + + // set new document text + $('#documentText').html(newDocument); +} + +/** + * Check if the selected range is already highlighted + * + * @param startCharacter The start character of the range + * @param endCharacter The end character of the range + * @returns {boolean} Returns true if the selected range ist already highlighted + */ +function isAlreadyHighlighted(startCharacter, endCharacter) { + let isHighlighted = false; + $('#annotations').find('.category-card').each(function () { + let array = $(this).data('array'); + if (array != null) { + for (let i = 0; i < array.length; i++) { + if ((array[i].start <= startCharacter && startCharacter <= array[i].end - 1) || // startCharacter inside highlighted range + (array[i].start <= endCharacter - 1 && endCharacter - 1 <= array[i].end - 1) || // endCharacter inside highlighted range + (startCharacter <= array[i].start && array[i].end - 1 <= endCharacter - 1)) { // new range overlaps hightlighted range + isHighlighted = true; + } + } + } + }); + return isHighlighted; +} + +/** + * Iterate over all data arrays and calculate the offset for a given start character + * + * @param startCharacter The given start character + * @returns {number} The offset + */ +function calculateExtraOffset(startCharacter) { + let extraOffset = 0; + $('#annotations').find('.category-card').each(function () { + let array = $(this).data('array'); + if (array != null) { + for (let i = 0; i < array.length; i++) { + if (array[i].end <= startCharacter) { + extraOffset += 22 + $(this).attr('id').length; + } + } + } + }); + return extraOffset; +} + +/** + * Save start and end character to the data array of a category + * + * @param startCharacter The start character of the body element + * @param endCharacter The end character of the body element + * @param category The chosen category + */ +function addSelectionDataToList(startCharacter, endCharacter, category) { + let elem = $('#' + category); + let array = elem.data('array'); + + if (array != null) { + // define new object + let newElement = { + start: startCharacter, + end: endCharacter + }; + // update array + array.push(newElement); + } + else { + // store first element in array + array = [ + { + "start": startCharacter, + "end": endCharacter + } + ] + } + + // sort array + array.sort(function (a, b) { + return a.start - b.start; + }); + // store updated array + elem.data('array', array); +} + +/** + * Handel the save button click + * Iterate over the category cards and send each post request to the back-end + */ +function saveButtonHandler() { + // show alert message + if (window.confirm("Möchten Sie wirklich ihre Annotationen speichern?")) { + // declare array of promises + let promises = [] + $('#annotations').find('.category-card').each(function () { + let array = $(this).data('array'); + if (array != null) { + + // initialize the post request + let category = $(this).attr('id').toUpperCase(); + let submissionPartPostRequest = { + userId: getUserTokenFromUrl(), + fullSubmissionId: getSubmissionIdFromUrl(), + category: category, + body: [] + }; + + // iterate over the array + for (let i = 0; i < array.length; i++) { + + // initialize a body element + let submissionPartBodyElement = { + text: $('#documentText').text().slice(array[i].start, array[i].end), + startCharacter: array[i].start, + endCharacter: array[i].end + }; + + // store the body element in the post request + submissionPartPostRequest.body.push(submissionPartBodyElement); + } + + // send the post request to the back-end and save promise + promises.push(createSubmissionPart(submissionPartPostRequest, function (response) { + console.log("send " + response.category + "'s post request to back-end") + })); + + } + }); + + $.when.apply($, promises).then(function () { + // redirect user to project page after saving + location.href="project-student.jsp?token=" + getUserTokenFromUrl() + "&projectId=" + getQueryVariable("projectId"); + }); + + // redirect user to project page after saving + // location.href="project-student.jsp?token=" + getUserTokenFromUrl() + "&projectId=" + getProjectIdFromUrl(); + } +} + +/** + * Handle the category click and start the saving event + * + * @param key The selected category + */ +function handleCategoryClick(key) { + + // if saved selection's range count is > 0 + let sel = rangy.getSelection(); + if (sel.rangeCount > 0) { + // calculate character range offset from range + let range = sel.getRangeAt(0); + let offsets = range.toCharacterRange($('#documentText')[0]); + + // if selected text's length is > 0 + let selectedText = getSelectedText(); + if (selectedText.length > 0) { + // save start and end character and handle the selection + let startCharacter = offsets.start; + let endCharacter = offsets.end; + handleCategorySelection(key, startCharacter, endCharacter); + } + } + +} diff --git a/gemeinsamforschen/src/main/webapp/assets/js/unstructuredRest.js b/gemeinsamforschen/src/main/webapp/assets/js/unstructuredRest.js new file mode 100644 index 0000000000000000000000000000000000000000..7124c244f062ebe2413829d82e72c79617c1796d --- /dev/null +++ b/gemeinsamforschen/src/main/webapp/assets/js/unstructuredRest.js @@ -0,0 +1,113 @@ +/** + * POST: Save an full submission in the database + * + * @param fullSubmissionPostRequest The post request + * @param responseHandler The response handler + */ +function createFullSubmission(fullSubmissionPostRequest, responseHandler) { + var url = "../rest/submissions/full/"; + var json = JSON.stringify(fullSubmissionPostRequest); + $.ajax({ + url: url, + type: "POST", + data: json, + contentType: "application/json", + dataType: "json", + success: function (response) { + responseHandler(response); + } + }); +} + +/** + * GET: Get a specific full submission for a given id + * + * @param id The id of the full submission + * @param responseHandler The response handler + * @param errorHandler The error handler + */ +function getFullSubmission(id, responseHandler, errorHandler) { + var url = "../rest/submissions/full/" + id; + $.ajax({ + url: url, + type: "GET", + dataType: "json", + success: function (response) { + // handle the response + responseHandler(response); + }, + error: function () { + // handle the error + errorHandler(); + } + }) +} + +/** + * POST: Save an submission part in the database + * + * @param submissionPartPostRequest The post request + * @param responseHandler The response handler + * @returns A promise object + */ +function createSubmissionPart(submissionPartPostRequest, responseHandler) { + var url = "../rest/submissions/part/"; + var json = JSON.stringify(submissionPartPostRequest); + return $.ajax({ + url: url, + type: "POST", + data: json, + contentType: "application/json", + dataType: "json", + success: function (response) { + responseHandler(response); + }, + error: function (e) { + console.log(e); + } + }); +} + +/** + * GET: Get a specific submission part for a given full submission id and its category + * + * @param id The id of the full submission + * @param category The category of the submission part + * @param responseHandler The response handler + * @param errorHandler The error handler + */ +function getSubmissionPart(id, category, responseHandler, errorHandler) { + var url = "../rest/submissions/full/" + id + "/category/" + category; + $.ajax({ + url: url, + type: "GET", + dataType: "json", + success: function (response) { + // handle the response + responseHandler(response); + }, + error: function () { + // handle the error + errorHandler(); + } + }) +} + +/** + * GET: Get all submission parts for a given full submission id + * + * @param id The id of the full submission + * @param responseHandler The response handler + */ +function getAllSubmissionParts(id, responseHandler) { + var url = "../rest/submissions/full/" + id + "/parts"; + $.ajax({ + url: url, + type: "GET", + dataType: "json", + success: function (response) { + // handle the response + responseHandler(response); + } + }) +} \ No newline at end of file diff --git a/gemeinsamforschen/src/main/webapp/assets/js/unstructuredUpload.js b/gemeinsamforschen/src/main/webapp/assets/js/unstructuredUpload.js new file mode 100644 index 0000000000000000000000000000000000000000..66ef3253fb067df445fa217227415361f9b0ed33 --- /dev/null +++ b/gemeinsamforschen/src/main/webapp/assets/js/unstructuredUpload.js @@ -0,0 +1,68 @@ +/** + * This function will fire when the DOM is ready + */ +$(document).ready(function() { + + $('#btnNext').click(function () { + if ($('#upload-textarea-form').valid()) { + + // fetch user and text + let user = getUserTokenFromUrl(); + let text = $('#upload-textarea').val(); + + // build request + var fullSubmissionPostRequest = { + user: user, + text: text, + projectId: getQueryVariable("projectId") + }; + + // save request in database + createFullSubmission(fullSubmissionPostRequest, function (response) { + // clear textarea + $('#upload-textarea').val(""); + + // jump to next page + location.href="unstructured-annotation.jsp?token=" + getUserTokenFromUrl() + "&projectId=" + getQueryVariable("projectId") + "&submission=" + response.id; + }); + } + }); + + $('#btnBack').click(function () { + // if there is text inside the textarea + if ($('#upload-textarea').val().trim().length > 0) { + // show user alert message that the text will be lost + if (window.confirm("Möchten Sie zur vorherigen Seite zurückkehren? \nIhr bisheriger Text wird nicht gespeichert.")) { + // clear textarea + $('#upload-textarea').val(""); + + // jump to previous page + window.history.back(); + //location.href="project-student.jsp?token=" + getUserTokenFromUrl() + "&projectId=" + getProjectIdFromUrl(); + } + } + // nothing to check + else { + // jump to previous page + window.history.back(); + //location.href="project-student.jsp?token=" + getUserTokenFromUrl() + "&projectId=" + getProjectIdFromUrl(); + } + }); + + /** + * validation of upload textarea + */ + $('#upload-textarea-form').validate({ + rules: { + uploadtextarea: { + required: true + } + }, + messages: { + uploadtextarea: { + required: "Ein Text wird benötigt" + } + } + }); + +}); diff --git a/gemeinsamforschen/src/main/webapp/assets/js/uploadUnstructured.js b/gemeinsamforschen/src/main/webapp/assets/js/uploadUnstructured.js deleted file mode 100644 index dd85243d662c9bf71e25212e89c42597e830c3d9..0000000000000000000000000000000000000000 --- a/gemeinsamforschen/src/main/webapp/assets/js/uploadUnstructured.js +++ /dev/null @@ -1,490 +0,0 @@ -// initialize userId, userColors and targetId -var userId = randomUserId(); -var userColors = new Map(); -var userColorsDark = new Map(); -var targetId = 200; - -// declare document text -var documentText; - -/** - * This function will fire when the DOM is ready - */ -$(document).ready(function() { - - /** - * Context menu handler - */ - $.contextMenu({ - selector: '.context-menu-one', - callback: function(key, options) { - - // close context menu - window.close; - - // initialize selected body - var body = getSelectedTextFromTextArea(); - - // if user selected something - if (body.length > 0) { - // annotationPostRequest - var request = { - userId: userId, - targetId: targetId, - body: body, - startCharacter: window.getSelection().getRangeAt(0).startOffset, - endCharacter: window.getSelection().getRangeAt(0).endOffset - }; - - console.log(request); - - createAnnotation(request, function(response) { - // display the new annotation - displayAnnotation(response); - - }); - } - - }, - items: { - "annotation": {name: "Annotation", icon: "edit"} - } - }); - - $('#btnSave').click(function () { - location.href="project-student.jsp?token="+getUserTokenFromUrl(); - }); - - $('#btnBack').click(function () { - location.href="project-student.jsp?token="+getUserTokenFromUrl(); - }); - - documentText = $('#documentText').html(); - - // fetch annotations from server on page start - getAnnotations(targetId, function (response) { - // iterate over annotations and display each - $.each(response, function (i, annotation) { - displayAnnotation(annotation); - }) - }); - -}); - -/** - * POST: Save an annotation in the database - * - * @param annotationPostRequest The post request - * @param responseHandler The response handler - */ -function createAnnotation(annotationPostRequest, responseHandler) { - var url = "http://localhost:8080/rest/annotations/"; - var json = JSON.stringify(annotationPostRequest); - $.ajax({ - url: url, - type: "POST", - data: json, - contentType: "application/json", - dataType: "json", - success: function (response) { - responseHandler(response); - } - }); -} - -/** - * PATCH: Alter an annotation in database - * - * @param id The annotation id - * @param annotationPatchRequest The patch request - * @param responseHandler The response handler - */ -function alterAnnotation(id, annotationPatchRequest, responseHandler) { - var url = "http://localhost:8080/rest/annotations/" + id; - var json = JSON.stringify(annotationPatchRequest); - $.ajax({ - url: url, - type: "PATCH", - data: json, - contentType: "application/json", - dataType: "json", - success: function (response) { - responseHandler(response); - } - }); -} - -/** - * DELETE: Delete an annotation from database - * - * @param id The annotation id - */ -function deleteAnnotation(id) { - var url = "http://localhost:8080/rest/annotations/" + id; - $.ajax({ - url: url, - type: "DELETE", - dataType: "json", - success: function (response) { - // Nothing to do - } - }); -} - -/** - * GET: Get all annotations from database for a specific target - * - * - * @param targetId The target id - * @param responseHandler The response handler - */ -function getAnnotations(targetId, responseHandler) { - var url = "http://localhost:8080/rest/annotations/target/" + targetId; - $.ajax({ - url: url, - type: "GET", - dataType: "json", - success: function (response) { - // sort the responding annotations by timestamp (DESC) - response.sort(function (a, b) { - return a.timestamp - b.timestamp; - }); - // handle the response - responseHandler(response); - } - }); -} - -/** - * Delete annotation from list - * - * @param elem The parent li element - * @param id The id of the annotation - */ -function deleteUnstructuredAnnotationHandler(elem, id) { - // remove annotation from list - elem.remove() - // remove annotation from database - deleteAnnotation(id) -} - -/** - * Display annotation in the list - * - * @param annotation The annotation to be displayed - */ -function displayAnnotation(annotation) { - // fetch list of annotations - var list = $('#annotations') - - var deleteIcon = "fas fa-trash"; - var dateIcon = "fas fa-calendar"; - if (isTimestampToday(annotation.timestamp)) { - dateIcon = "fas fa-clock"; - } - - // insert annotation card - list.prepend( - $('<li>') - .attr('class', 'listelement') - .append( - $('<div>').attr('class', 'annotation-card') - .mouseenter(function () { - $(this).children('.annotation-header').css('background-color', getDarkUserColor(annotation.userId)); - }) - .mouseleave(function () { - $(this).children('.annotation-header').css('background-color', getUserColor(annotation.userId)); - }) - .append( - $('<div>').attr('class', 'annotation-header') - .css('background-color', getUserColor(annotation.userId)) - .append( - $('<div>').attr('class', 'annotation-header-title') - .append( - $('<div>').attr('class', 'overflow-hidden') - .append( - $('<i>').attr('class', 'fas fa-user') - ) - .append( - $('<span>').append(annotation.userId) - ) - ) - .append( - $('<div>').attr('class', 'overflow-hidden') - .append( - $('<i>').attr('class', 'fas fa-bookmark') - ) - .append( - $('<span>').append('title' + annotation.userId) - ) - ) - ) - .append( - $('<div>').attr('class', 'annotation-header-toggle') - .click(function () { - toggleButtonHandler($(this)); - }) - .append( - $('<i>').attr('class', 'fas fa-chevron-down') - ) - ) - ) - .append( - $('<div>').attr('class', 'annotation-body') - .append( - $('<p>').attr('class', 'overflow-hidden').append(annotation.body) - ) - ) - .append( - $('<div>').attr('class', 'annotation-footer') - .append( - function () { - if (userId == annotation.userId) { - return $('<div>').attr('class', 'annotation-footer-delete') - .append( - $('<i>').attr('class', deleteIcon) - ) - .click(function () { - deleteUnstructuredAnnotationHandler($(this).closest('li'), annotation.id) - }) - } - } - ) - .append( - $('<div>').attr('class', 'annotation-footer-date overflow-hidden') - .append( - $('<i>').attr('class', dateIcon) - ) - .append( - $('<span>').append(timestampToReadableTime(annotation.timestamp)) - ) - ) - - - ) - ) - .data('annotation', annotation) - .append(function () { - if ($('#annotations li').filter( ".listelement" ).length > 0) { - return $('<div>').attr('class', 'spacing') - } - }) - ); -} - -/** - * Add a highlighted text at specific position - * - * @param startCharacter The offset of the start character - * @param endCharacter The offset of the end character - * @param userId The user id - */ -function addHighlightedText(startCharacter, endCharacter, userId) { - // create <span> tag with the annotated text - var replacement = $('<span></span>').css('background-color', getUserColor(userId)).html(documentText.slice(startCharacter, endCharacter)); - - // wrap an <p> tag around the replacement, get its parent (the <p>) and ask for the html - var replacementHtml = replacement.wrap('<p/>').parent().html(); - - // insert the replacementHtml - var newDocument = documentText.slice(0, startCharacter) + replacementHtml + documentText.slice(endCharacter); - - // set new document text - $('#documentText').html(newDocument); -} - -/** - * Restore the base text - */ -function deleteHighlightedText() { - $('#documentText').html(documentText); -} - -/** - * Get the text value of the selected text - * - * @returns {string} The text - */ -function getSelectedText() { - if(window.getSelection){ - return window.getSelection().toString(); - } - else if(document.getSelection){ - return document.getSelection(); - } - else if(document.selection){ - return document.selection.createRange().text; - } -} - -/** - * Get the text value of the selected text from a textarea - * - * @returns {string} The text - */ -function getSelectedTextFromTextArea() { - // if firefox - if( navigator.userAgent.toLowerCase().indexOf('firefox') > -1 ){ - // reference to the textarea - var txtarea = document.getElementById("upload-area"); - // get index of first character - var start = txtarea.selectionStart; - // get index of last character - var end = txtarea.selectionEnd; - // return substring from start to end - return txtarea.value.substring(start, end); - } - else if(window.getSelection){ - return window.getSelection().toString(); - } - else if(document.getSelection){ - return document.getSelection(); - } - else if(document.selection){ - return document.selection.createRange().text; - } -} - -/** - * Get color based on user id - * - * @param userId The id of the user - * @returns {string} The user color - */ -function getUserColor(userId) { - // insert new color if there is no userId key - if (userColors.get(userId) == null) { - generateRandomColor(userId); - } - // return the color - return userColors.get(userId); -} - -/** - * Get dark color based on user id - * - * @param userId The id of the user - * @returns {string} The dark user color - */ -function getDarkUserColor(userId) { - // insert new color if there is no userId key - if (userColorsDark.get(userId) == null) { - generateRandomColor(userId); - } - // return the color - return userColorsDark.get(userId); -} - -/** - * Generate a random color of the format 'rgb(r, g, b)' - * - * @param userId The given user id - */ -function generateRandomColor(userId) { - var r = Math.floor(Math.random()*56)+170; - var g = Math.floor(Math.random()*56)+170; - var b = Math.floor(Math.random()*56)+170; - var r_d = r - 50; - var g_d = g - 50; - var b_d = b - 50; - - var color = 'rgb(' + r + ',' + g + ',' + b + ')'; - var colorDark = 'rgb(' + r_d + ',' + g_d + ',' + b_d + ')'; - - userColors.set(userId, color); - userColorsDark.set(userId, colorDark); -} - -/** - * Calculate and build a readable timestamp from an unix timestamp - * - * @param timestamp A unix timestamp - * @returns {string} A readable timestamp - */ -function timestampToReadableTime(timestamp) { - // build Date object from timestamp - var annotationDate = new Date(timestamp); - // declare response - var responseTimestamp; - - // if annotation is from today - if (isTimestampToday(timestamp)) { - // get hours from date - var hours = annotationDate.getHours(); - // get minutes from date - var minutes = "0" + annotationDate.getMinutes(); - // get seconds from date - // var seconds = "0" + annotationDate.getSeconds(); - - // build readable timestamp - responseTimestamp = hours + ":" + minutes.substr(-2); - } - // else annotation is not from today - else { - // get date - var date = annotationDate.getDate(); - // get month - var month = annotationDate.getMonth(); - // get year - var year = annotationDate.getFullYear(); - - // build readable timestamp - responseTimestamp = date + "." + month + "." + year; - } - - return responseTimestamp; -} - -/** - * Check if given timestamp is from today - * - * @param timestamp The given timestamp in milliseconds - * @returns {boolean} Returns true if the timestamp is from today - */ -function isTimestampToday(timestamp) { - // now - var now = new Date(); - // build Date object from timestamp - var date = new Date(timestamp); - - // return true if timestamp is today - if (now.getDate() == date.getDate() && now.getMonth() == date.getMonth() && now.getFullYear() == date.getFullYear()) { - return true; - } - else { - return false; - } -} - -/** - * Toggle between the toggle button status - * - * @param element The given toggle button - */ -function toggleButtonHandler(element) { - // open and close annotation text - element.parent().siblings(".annotation-body").children("p").toggleClass("overflow-hidden"); - // toggle between up and down button - element.children("i").toggleClass("fa-chevron-down fa-chevron-up") -} - -function lockButtonHandler() { - var lock = $('#btnLock').children('i') - lock.toggleClass("fa-lock-open fa-lock") - - var area = $('#upload-area') - if (area.attr('readonly')) { - area.attr('readonly', false); - } - else { - area.attr('readonly', true); - } -} - -/* - MOCKUP FUNCTIONS - */ -function randomUserId() { - return Math.floor((Math.random() * 12) + 1);; -} - diff --git a/gemeinsamforschen/src/main/webapp/assets/js/utility.js b/gemeinsamforschen/src/main/webapp/assets/js/utility.js index c5b8b37d083e2cc80f2260ded050c6c710143ade..3f21a38cd0eb8e61357a783869a2db3cc4e4f57d 100644 --- a/gemeinsamforschen/src/main/webapp/assets/js/utility.js +++ b/gemeinsamforschen/src/main/webapp/assets/js/utility.js @@ -1,12 +1,61 @@ $(document).ready(function(){ $('#headLineProject').html($('#projectId').html()); + $('#logout').click(function(){ + //todo: delete cookies / reset session + document.location="../index.jsp"; + }); + $('#assessment').click(function(){ + checkAssessementPhase(); + }); + $('#footerBack').click(function(){ + goBack(); + }); }); +function goBack() { + window.history.back(); +} + +function checkAssessementPhase(){ + let studentId = $('#user').html().trim(); + let projectId = $('#projectId').html().trim(); + $.ajax({ + url: '../rest/assessments/whatToRate/project/'+projectId+'/student/'+studentId, + type: 'GET', + headers: { + "Content-Type": "application/json", + "Cache-Control": "no-cache" + }, + success: function (phase) { + switch (phase){ + case "workRating":{ + document.location="finalAssessment.jsp?token=" + getUserTokenFromUrl() + "&projectId=" + $('#projectId').html().trim(); + break; + } + case "quiz":{ + location.href = "takeQuiz.jsp?token=" + getUserTokenFromUrl() + "&projectId=" + $('#projectId').html().trim(); + break; + } + case "contributionRating":{ + location.href = "rateContribution.jsp?token=" + getUserTokenFromUrl() + "&projectId=" + $('#projectId').html().trim(); + break; + } + case "done":{ + location.href = "project-student.jsp?token=" + getUserTokenFromUrl() + "&projectId=" + $('#projectId').html().trim(); + break; + } + } + }, + error: function(a){ + } + }); +} + function getUserTokenFromUrl() { - var parts = window.location.search.substr(1).split("&"); - var $_GET = {}; - for (var i = 0; i < parts.length; i++) { - var temp = parts[i].split("="); + let parts = window.location.search.substr(1).split("&"); + let $_GET = {}; + for (let i = 0; i < parts.length; i++) { + let temp = parts[i].split("="); $_GET[decodeURIComponent(temp[0])] = decodeURIComponent(temp[1]); } return $_GET['token']; @@ -14,11 +63,11 @@ function getUserTokenFromUrl() { } function getQueryVariable(variable) { - var query = window.location.search.substring(1); - var vars = query.split("&"); - for (var i = 0; i < vars.length; i++) { - var pair = vars[i].split("="); - if (pair[0] == variable) { + let query = window.location.search.substring(1); + let vars = query.split("&"); + for (let i = 0; i < vars.length; i++) { + let pair = vars[i].split("="); + if (pair[0] === variable) { return pair[1]; } } diff --git a/gemeinsamforschen/src/main/webapp/core/pages/gemeinsamForschen.tld b/gemeinsamforschen/src/main/webapp/core/pages/gemeinsamForschen.tld index 3c2db0269960c9ff430c6e6d82e74a225d195972..b32f459cea3a6a036b622c85cb47749d45a1d3a0 100644 --- a/gemeinsamforschen/src/main/webapp/core/pages/gemeinsamForschen.tld +++ b/gemeinsamforschen/src/main/webapp/core/pages/gemeinsamForschen.tld @@ -11,7 +11,7 @@ <tag> <name>menu</name> - <tag-class>unipotsdam.gf.core.management.user.Menu</tag-class> + <tag-class>unipotsdam.gf.core.management.pageAppearance.Menu</tag-class> <body-content>empty</body-content> </tag> @@ -23,13 +23,19 @@ <tag> <name>omniDependencies</name> - <tag-class>unipotsdam.gf.core.management.user.omniDependencies</tag-class> + <tag-class>unipotsdam.gf.core.management.pageAppearance.omniDependencies</tag-class> <body-content>empty</body-content> </tag> <tag> <name>headLine</name> - <tag-class>unipotsdam.gf.core.management.user.headLine</tag-class> + <tag-class>unipotsdam.gf.core.management.pageAppearance.headLine</tag-class> + <body-content>empty</body-content> + </tag> + + <tag> + <name>footer</name> + <tag-class>unipotsdam.gf.core.management.pageAppearance.footer</tag-class> <body-content>empty</body-content> </tag> diff --git a/gemeinsamforschen/src/main/webapp/core/pages/gemeinsamForschen.tld.orig b/gemeinsamforschen/src/main/webapp/core/pages/gemeinsamForschen.tld.orig index 464689080655114907b3461748349ae320db9d88..24e3cda55c35f4136e26d14751eee2747723d997 100644 --- a/gemeinsamforschen/src/main/webapp/core/pages/gemeinsamForschen.tld.orig +++ b/gemeinsamforschen/src/main/webapp/core/pages/gemeinsamForschen.tld.orig @@ -11,14 +11,14 @@ <tag> <name>menu</name> - <tag-class>unipotsdam.gf.core.management.user.Menu</tag-class> + <tag-class>unipotsdam.gf.core.management.pageAppearance.Menu</tag-class> <body-content>empty</body-content> </tag> <tag> <<<<<<< HEAD <name>headLine</name> - <tag-class>unipotsdam.gf.core.management.user.headLine</tag-class> + <tag-class>unipotsdam.gf.core.management.pageAppearance.headLine</tag-class> ======= <name>session</name> <tag-class>unipotsdam.gf.core.session.SessionTag</tag-class> @@ -29,7 +29,7 @@ <tag> <<<<<<< HEAD <name>omniDependencies</name> - <tag-class>unipotsdam.gf.core.management.user.omniDependencies</tag-class> + <tag-class>unipotsdam.gf.core.management.pageAppearance.omniDependencies</tag-class> ======= <name>context</name> <tag-class>unipotsdam.gf.core.session.ContextTag</tag-class> diff --git a/gemeinsamforschen/src/main/webapp/pages/Quiz-docent.jsp b/gemeinsamforschen/src/main/webapp/pages/Quiz-docent.jsp index 64db788d2e1fb91279b7fa9f339d33d0b232c26e..6d693e27525436354f12e04005d2f59850d4e3e0 100644 --- a/gemeinsamforschen/src/main/webapp/pages/Quiz-docent.jsp +++ b/gemeinsamforschen/src/main/webapp/pages/Quiz-docent.jsp @@ -1,7 +1,8 @@ -<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ page contentType="text/html;charset=UTF-8" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="menu" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="headLine" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="omniDependencies" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="footer" %> <html> <head> @@ -22,7 +23,7 @@ <button class="btn btn-primary" id="newQuiz">neues Quiz</button> </div> + <footer:footer/> </div> - </body> </html> diff --git a/gemeinsamforschen/src/main/webapp/pages/Quiz.jsp b/gemeinsamforschen/src/main/webapp/pages/Quiz.jsp index f5f04d45e484bec9d965916f9910f85a5fb176cf..5e7341363506343927281caf860275bcb48080c6 100644 --- a/gemeinsamforschen/src/main/webapp/pages/Quiz.jsp +++ b/gemeinsamforschen/src/main/webapp/pages/Quiz.jsp @@ -1,7 +1,8 @@ -<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ page contentType="text/html;charset=UTF-8" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="menu" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="headLine" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="omniDependencies" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="footer" %> <html> <head> @@ -22,7 +23,7 @@ <button class="btn btn-primary" id="newQuiz">neues Quiz</button> </div> + <footer:footer/> </div> - </body> </html> diff --git a/gemeinsamforschen/src/main/webapp/pages/annotation-document.jsp b/gemeinsamforschen/src/main/webapp/pages/annotation-document.jsp index 0feb17e00df908ca0fc388249264ee4a220b6bf3..d8e499fe40ffe6c526d9785794e086efae0434a0 100644 --- a/gemeinsamforschen/src/main/webapp/pages/annotation-document.jsp +++ b/gemeinsamforschen/src/main/webapp/pages/annotation-document.jsp @@ -20,10 +20,20 @@ <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js" type="text/javascript"></script> <!-- js - contextMenu script --> <script src="https://swisnl.github.io/jQuery-contextMenu/dist/jquery.contextMenu.js" type="text/javascript"></script> + <!-- js - scrollTo --> + <script src="//cdn.jsdelivr.net/npm/jquery.scrollto@2.1.2/jquery.scrollTo.min.js"></script> + <!-- js - rangy Core --> + <script src="https://cdnjs.cloudflare.com/ajax/libs/rangy/1.3.0/rangy-core.js" type="text/javascript"></script> + <!-- js - rangy TextRange Module --> + <script src="https://cdnjs.cloudflare.com/ajax/libs/rangy/1.3.0/rangy-textrange.js" type="text/javascript"></script> + <!-- js - utility --> + <script src="../assets/js/utility.js"></script> <!-- js - annotation websocket script --> <script src="../assets/js/annotationWebsocket.js"></script> <!-- js - annotation REST script --> <script src="../assets/js/annotationRest.js"></script> + <!-- js - unstructuredRest --> + <script src="../assets/js/unstructuredRest.js"></script> <!-- js - annotationScript --> <script src="../assets/js/annotationScript.js"></script> </head> @@ -40,13 +50,13 @@ <div class="content-mainpage"> <div class="leftcolumn"> <div class="leftcontent"> - <div class="leftcontent-text context-menu-one" id="documentText"> - Style never met and those among great. At no or september sportsmen he perfectly happiness attending. Depending listening delivered off new she procuring satisfied sex existence. Person plenty answer to exeter it if. Law use assistance especially resolution cultivated did out sentiments unsatiable. Way necessary had intention happiness but september delighted his curiosity. Furniture furnished or on strangers neglected remainder engrossed. Shot what able cold new the see hold. Friendly as an betrayed formerly he. Morning because as to society behaved moments. Put ladies design mrs sister was. Play on hill felt john no gate. Am passed figure to marked in. Prosperous middletons is ye inhabiting as assistance me especially. For looking two cousins regular amongst. - Style never met and those among great. At no or september sportsmen he perfectly happiness attending. Depending listening delivered off new she procuring satisfied sex existence. Person plenty answer to exeter it if. Law use assistance especially resolution cultivated did out sentiments unsatiable. Way necessary had intention happiness but september delighted his curiosity. Furniture furnished or on strangers neglected remainder engrossed. Shot what able cold new the see hold. Friendly as an betrayed formerly he. Morning because as to society behaved moments. Put ladies design mrs sister was. Play on hill felt john no gate. Am passed figure to marked in. Prosperous middletons is ye inhabiting as assistance me especially. For looking two cousins regular amongst. - </div> + <div class="leftcontent-text context-menu-one" id="documentText"></div> <div class="leftcontent-buttons"> + <div class="leftcontent-buttons-back"> + <button id="btnBack" type="button" class="btn btn-secondary">Zurück</button> + </div> <div class="leftcontent-buttons-next"> - <button id="btnContinue" type="button" class="btn btn-secondary">Weiter</button> + <button id="btnContinue" type="button" class="btn btn-primary">Weiter</button> </div> </div> </div> diff --git a/gemeinsamforschen/src/main/webapp/pages/changePhase.jsp b/gemeinsamforschen/src/main/webapp/pages/changePhase.jsp new file mode 100644 index 0000000000000000000000000000000000000000..c3d7c07a1f47ed3e1a855ef454dca240d92fb8c7 --- /dev/null +++ b/gemeinsamforschen/src/main/webapp/pages/changePhase.jsp @@ -0,0 +1,41 @@ +<%@ page contentType="text/html;charset=UTF-8" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="menu" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="headLine" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="omniDependencies" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="footer" %> + + +<html> +<head> + <omniDependencies:omniDependencies/> + <script src="../assets/js/changePhase.js"></script> +</head> + +<body> +<div id="wrapper"> + <menu:menu/> + <div class="page-content-wrapper"> + <headLine:headLine/> + <div class="alert"id="CourseCreation"> + <button id="btnCourseCreation" class="btn btn-secondary">Projekterstellungsphase</button> + </div> + <div class="alert" id="GroupFormation"> + <button id="btnGroupformation" class="btn btn-secondary">Gruppen erstellen</button> + </div> + <div class="alert" id="DossierFeedback"> + <button id="btnDossierFeedback" class="btn btn-secondary">Feedbackphase</button> + </div> + <div class="alert" id="Execution"> + <button id="btnExecution" class="btn btn-secondary">Durchführungsphase</button> + </div> + <div class="alert" id="Assessment"> + <button id="btnAssessment" class="btn btn-secondary">Bewertungsphase</button> + </div> + <div class="alert" id="end"> + <button id="btnProjectfinished" class="btn btn-secondary">Ende</button> + </div> + </div> + <footer:footer/> +</div> +</body> +</html> diff --git a/gemeinsamforschen/src/main/webapp/pages/createGroups.jsp b/gemeinsamforschen/src/main/webapp/pages/createGroups.jsp new file mode 100644 index 0000000000000000000000000000000000000000..4b22ba4e92ae53aeaf9abfc1a7a2ebdd16469a75 --- /dev/null +++ b/gemeinsamforschen/src/main/webapp/pages/createGroups.jsp @@ -0,0 +1,24 @@ +<%@ page contentType="text/html;charset=UTF-8" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="menu" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="headLine" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="omniDependencies" %> + +<html> +<head> + <omniDependencies:omniDependencies/> + <script src="../assets/js/changePhase.js"></script> +</head> + +<body> +<div id="wrapper"> + <menu:menu/> + <div class="page-content-wrapper"> + <headLine:headLine/> + student1<br> + student2<br> + <br> + in Gruppe 1 2 3 + </div> +</div> +</body> +</html> diff --git a/gemeinsamforschen/src/main/webapp/pages/createProject.jsp b/gemeinsamforschen/src/main/webapp/pages/createProject.jsp index 3984538cbfcaa344fa73305dcfd271d368ce6209..84f529a57f133988191875eac3c9f327d3217b23 100644 --- a/gemeinsamforschen/src/main/webapp/pages/createProject.jsp +++ b/gemeinsamforschen/src/main/webapp/pages/createProject.jsp @@ -2,6 +2,8 @@ <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="menu" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="headLine" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="omniDependencies" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="omniDependencies" %> + <!DOCTYPE html> <html> @@ -26,7 +28,7 @@ </div> </div> - +<footer:footer/> </body> </html> \ No newline at end of file diff --git a/gemeinsamforschen/src/main/webapp/pages/createQuiz.jsp b/gemeinsamforschen/src/main/webapp/pages/createQuiz.jsp index 512844f6c308bac4903aaa02e3f92af58f0405a1..7601ff88f154ff2df7613bfc1c2f55a5de1a2c25 100644 --- a/gemeinsamforschen/src/main/webapp/pages/createQuiz.jsp +++ b/gemeinsamforschen/src/main/webapp/pages/createQuiz.jsp @@ -1,7 +1,8 @@ -<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ page contentType="text/html;charset=UTF-8" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="menu" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="headLine" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="omniDependencies" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="footer" %> <html> <head> @@ -28,7 +29,7 @@ <button id="save">speichern</button> </div> </div> + <footer:footer/> </div> - </body> </html> diff --git a/gemeinsamforschen/src/main/webapp/pages/finalAssessments.jsp b/gemeinsamforschen/src/main/webapp/pages/finalAssessments.jsp index 1273a5887b11dd21268eb8c61084693d21ef565c..4a6908591abadfecd0fcd915e9743637d29d0442 100644 --- a/gemeinsamforschen/src/main/webapp/pages/finalAssessments.jsp +++ b/gemeinsamforschen/src/main/webapp/pages/finalAssessments.jsp @@ -1,7 +1,8 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> +<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="menu" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="headLine" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="omniDependencies" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="footer" %> <!DOCTYPE html> <html> @@ -43,20 +44,13 @@ <!-- here will be all the content --> <div class="container"> <div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="false"> - <!-- Indicators --> - <ol class="carousel-indicators"> - <li data-target="#myCarousel" data-slide-to="0" class="active"></li> - <li data-target="#myCarousel" data-slide-to="1"></li> - <li data-target="#myCarousel" data-slide-to="2"></li> - </ol> - <!-- Wrapper for slides --> <div class="alert alert-info" id="notAllRated"> Es wurden noch nicht alle Studenten vollständig bewertet </div> - <div class="carousel-inner"> - <div class="item active"> + <div class="carousel-inner" id="peerTable"> + <!--<div class="item active"> <table class="table-striped peerStudent" style="width:70%;border:1px solid; margin:auto;" id="Student1"> <tr> @@ -146,6 +140,12 @@ </td> </tr> </table> + <div align="center"> + <button class="btn btn-primary" id="btnJournalStudent1" >zeige Lernzieltagebuch</button> + <div id="eJournalStudent1"> + Fasel Blubba Bla + </div> + </div> </div> <div class="item"> @@ -238,6 +238,12 @@ </td> </tr> </table> + <div align="center"> + <button class="btn btn-primary" id="btnJournalStudent2">zeige Lernzieltagebuch</button> + <div id="eJournalStudent2"> + Fasel Blubba Bla + </div> + </div> </div> <div class="item"> @@ -330,7 +336,13 @@ </td> </tr> </table> - </div> + <div align="center"> + <button class="btn btn-primary" id="btnJournalStudent3">zeige Lernzieltagebuch</button> + <div id="eJournalStudent3" align="center"> + Fasel Blubba Bla + </div> + </div> + </div>--> </div> <!-- Left and right controls --> @@ -408,11 +420,9 @@ </table> </div> </div> + <footer:footer/> </div> -<script src="../assets/js/jquery.min.js"></script> -<script src="../assets/bootstrap/js/bootstrap.min.js"></script> -<script src="../assets/js/Sidebar-Menu.js"></script> </body> </html> \ No newline at end of file diff --git a/gemeinsamforschen/src/main/webapp/pages/profile.jsp b/gemeinsamforschen/src/main/webapp/pages/profile.jsp index 7f37281156d4d10c858001fff953e5d9c5aa6b29..18dfc349ff5b1a81f358595049b136b573734040 100644 --- a/gemeinsamforschen/src/main/webapp/pages/profile.jsp +++ b/gemeinsamforschen/src/main/webapp/pages/profile.jsp @@ -1,22 +1,18 @@ <%@ page import="unipotsdam.gf.core.management.ManagementImpl" %> <%@ page import="unipotsdam.gf.core.management.user.User" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="menu"%> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="headLine" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="omniDependencies" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="footer" %> + <!DOCTYPE html> <html> <head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <title>Profil</title> - <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> - <link rel="stylesheet" href="../assets/css/styles.css"> - <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> - <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> - <link rel="stylesheet" href="../assets/fonts/font-awesome.min.css"> - <link rel="stylesheet" href="../assets/css/Community-ChatComments.css"> - <link rel="stylesheet" href="../assets/css/Sidebar-Menu-1.css"> - <link rel="stylesheet" href="../assets/css/Sidebar-Menu.css"> + <omniDependencies:omniDependencies/> + <link href='http://fonts.googleapis.com/css?family=Roboto+Condensed|Open+Sans+Condensed:300' rel='stylesheet' type='text/css'> + <script src="../assets/js/profile.js"></script> </head> @@ -29,25 +25,10 @@ <body> <div id="wrapper"> - <menu:menu></menu:menu> + <menu:menu/> <div class="page-content-wrapper"> - <div class="container-fluid"> - <h1 id="projectId"> - <a href="#"> - <span class="glyphicon glyphicon-envelope" - style="font-size:27px;margin-top:-17px;margin-left:600px;"></span> - </a> - <a href="#"> - <span class="glyphicon glyphicon-cog" style="font-size:29px;margin-left:5px;margin-top:-25px;"></span> - </a></h1> - </div> - <div id="content"> - - <div class="page-header text-center"> - <h1>Mein Profil</h1> - </div> - + <headLine:headLine/> <div class="container"> <div class="row"> <%-- about --%> @@ -60,6 +41,16 @@ </li> <li class="list-group-item"> <p>Sonstiges:</p> + <form id="uploadimage" method="post" action="../rest/user/student/wiepke"> + <div id="image_preview"><img id="previewing" src="../assets/img/noImg.png" /></div> + <hr id="line"> + <div id="selectImage"> + <label>Select Your Image</label><br/> + <input type="file" name="image" id="file" required /> + <input type="submit" value="Upload" class="submit" /> + </div> + </form> + <p id="message"></p> </li> </ul> @@ -123,13 +114,8 @@ </div> </div> + <footer:footer/> </div> -</div> - -<script src="../assets/js/jquery.min.js"></script> -<script src="../assets/bootstrap/js/bootstrap.min.js"></script> -<script src="../assets/js/Sidebar-Menu.js"></script> - </body> </html> \ No newline at end of file diff --git a/gemeinsamforschen/src/main/webapp/pages/project-docent.jsp b/gemeinsamforschen/src/main/webapp/pages/project-docent.jsp index 9dbf5687f892d59a4d44927e6bce2832aed4d305..5aafa19554988dc0438d51b9bd5fe573390cc479 100644 --- a/gemeinsamforschen/src/main/webapp/pages/project-docent.jsp +++ b/gemeinsamforschen/src/main/webapp/pages/project-docent.jsp @@ -3,6 +3,8 @@ <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="menu" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="headLine" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="omniDependencies" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="footer" %> + <!DOCTYPE html> @@ -86,74 +88,13 @@ </table> </div> </div> - <div class="col-md-6"> - <div class="panel panel-default"> - <div class="panel-heading"> - <h3 class="panel-title">ProjektChat</h3> - </div> - <div class="panel-body" style="height:233px;"> - <ul class="list-group"> - <li class="list-group-item" style="margin-bottom:6px;"> - <div class="media"> - <div class="media-left"><a></a></div> - <div class="media-body"> - <div class="media" style="overflow:visible;"> - <div class="media-left"><a><img src="../assets/img/1.jpg" - class="img-rounded" - style="width: 25px; height:25px;"></a> - </div> - <div class="media-body" style="overflow:visible;"> - <div class="row"> - <div class="col-md-12"> - <p><a href="#">Sara Doe:</a> This guy has been going - 100+ MPH on side streets. <br> - <small class="text-muted">August 6, 2016 @ 10:35am - </small> - </p> - </div> - </div> - </div> - </div> - </div> - </div> - </li> - <li class="list-group-item" style="margin-bottom:6px;"> - <div class="media"> - <div class="media-left"><a></a></div> - <div class="media-body"> - <div class="media" style="overflow:visible;"> - <div class="media-left"><a><img src="../assets/img/1.jpg" - class="img-rounded" - style="width: 25px; height:25px;"></a> - </div> - <div class="media-body" style="overflow:visible;"> - <div class="row"> - <div class="col-md-12"> - <p><a href="#">Brennan Prill:</a> This guy has been - going 100+ MPH on side streets. <br> - <small class="text-muted">August 6, 2016 @ 10:35am - </small> - </p> - </div> - </div> - </div> - </div> - </div> - </div> - </li> - </ul> - <button class="btn btn-default" type="button" - style="margin-left:601px;margin-top:-9px;">Add Comment - </button> - </div> - </div> - </div> </div> </div> </div> </div> </div> <communication:chatWindow orientation="right" /> +<footer:footer/> </body> </html> \ No newline at end of file diff --git a/gemeinsamforschen/src/main/webapp/pages/project-student.jsp b/gemeinsamforschen/src/main/webapp/pages/project-student.jsp index 55567371949904fc7116ef7cf01bab56f50def4a..a4ff66173013c070fb9a27c01d8279db77fbfdc2 100644 --- a/gemeinsamforschen/src/main/webapp/pages/project-student.jsp +++ b/gemeinsamforschen/src/main/webapp/pages/project-student.jsp @@ -1,8 +1,10 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> +<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <%--suppress XmlDuplicatedId --%> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="menu" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="headLine" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="omniDependencies" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="footer" %> + <!--todo: E-mail an Studenten als Notifikation für Phasenwechsel --> @@ -54,7 +56,6 @@ style="font-size:15px;"></i>feedback</label> </a> </li> - </a> </ul> </td> <td></td> @@ -95,14 +96,7 @@ <img src="../assets/img/3.jpg"> <a href="#">student3@uni.de</a> <hr> - <ul> - <li> - "Viva la Floristika" - Titel hochgeladen - <a class="annotationview" role="button"> - <label style="font-size:10px;"><i class="far fa-comments" - style="font-size:15px;"></i>feedback</label> - </a> - </li> + <ul id="submissionUpload"> </ul> </td> @@ -110,91 +104,13 @@ </table> <button onclick="goBack()" class="btn btn-secondary">Zurueck</button> - - <script> - function goBack() { - window.history.back(); - } - </script> - - </td> - <td id="chat"> - <div class="card"> - <div class="card-header"> - <h6 class="mb-0">Gruppen+Projekt Chat</h6> - </div> - <div class="card-body"> - <ul class="list-group"> - <li class="list-group-item"> - <div class="media"> - <div></div> - <div class="media-body"> - <div class="media" style="overflow:visible;"> - <div><img src="../assets/img/1.jpg" class="mr-3" - style="width: 25px; height:25px;"></div> - <div class="media-body" style="overflow:visible;"> - <div class="row"> - <div class="col-md-12"> - <p><a href="#">Sara Doe:</a> This guy has been going - 100+ MPH on side streets. <br> - <small class="text-muted">August 6, 2016 @ 10:35am - </small> - </p> - </div> - </div> - </div> - </div> - </div> - </div> - </li> - <li class="list-group-item"> - <div class="media"> - <div></div> - <div class="media-body"> - <div class="media" style="overflow:visible;"> - <div><img src="../assets/img/2.jpg" class="mr-3" - style="width: 25px; height:25px;"></div> - <div class="media-body" style="overflow:visible;"> - <div class="row"> - <div class="col-md-12"> - <p><a href="#">Brennan Prill:</a> This guy has been - going 100+ MPH on side streets. <br> - <small class="text-muted">August 6, 2016 @ 10:35am - </small> - </p> - </div> - </div> - </div> - </div> - </div> - </div> - </li> - </ul> - <button class="btn btn-light"> - Add Comment - </button> - </div> - </div> </td> </tr> </table> </div> </div> - <footer> - <div class="container"> - <div class="progress"> - <div class="progress-bar pg-groups" role="progressbar" id="progressbar"> - </div> - <div> - Assessment - Präsentationsphase - Dossier - Reflexionsphase - Feedbackphase - Gruppenbildung - </div> - <div class="progress-bar pg-rest" role="progressbar"> - </div> - </div> - <button id="nextPhase" class="btn btn-light">nächste Phase</button> - <button id="btnUnstructuredUpload" class="btn btn-light">Unstrukturierte Abgabe</button> - </div> - </footer> + <footer:footer/> + </div> </body> diff --git a/gemeinsamforschen/src/main/webapp/pages/rateContribution.jsp b/gemeinsamforschen/src/main/webapp/pages/rateContribution.jsp index 50431a5333efaf8cfbe617b8c561a1828a63aac2..cfda957fd875e6dcc394162b2031fe301bf6ff53 100644 --- a/gemeinsamforschen/src/main/webapp/pages/rateContribution.jsp +++ b/gemeinsamforschen/src/main/webapp/pages/rateContribution.jsp @@ -1,7 +1,8 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> +<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="menu" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="headLine" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="omniDependencies" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="footer" %> <!DOCTYPE html> <html> @@ -16,35 +17,19 @@ <body> <div id="wrapper"> <menu:menu/> + <p id="groupId" hidden>Hier steht jetzt das richtige</p> <div class="page-content-wrapper"> <headLine:headLine/> <div> <table> <tr> <td id="yourContent"> - <h1>letzter Schritt im Projekt1 </h1> + <h2>letzter Schritt im Projekt1 </h2> <table class="table-striped peerStudent" - style="width:100%;border:1px solid; margin:auto;" id="student1"> + style="width:100%;border:1px solid; margin:auto;" id="2"> <tr> <td align="center"> - <img src="../assets/img/1.jpg" alt="student1" - style="width:20%;"> - </td> - </tr> - <tr> - <td> - <div class="contributionRating" id="eJournal"> - Lernzieltagebuch: - Lernen ist wie Rudern gegen den Strom. Hört man damit auf, treibt man zurück. - <textarea id="ejournalFeedback"> - meine Bewertung - </textarea> - <label><input type="radio" name="eJournal" value="5">Perfekt</label> - <label><input type="radio" name="eJournal" value="4">Makellos</label> - <label><input type="radio" name="eJournal" value="3">regulär</label> - <label><input type="radio" name="eJournal" value="2">Makelhaft</label> - <label><input type="radio" name="eJournal" value="1">Lädiert</label> - </div> + <h3>Gruppe 4</h3> </td> </tr> <tr> @@ -83,68 +68,11 @@ </table> <button id="submit" class="btn btn-success">Feedback hochladen</button> </td> - <td id="chat"> - <div class="card"> - <div class="card-header"> - <h6 class="mb-0">Gruppen+Projekt Chat</h6> - </div> - <div class="card-body"> - <ul class="list-group"> - <li class="list-group-item"> - <div class="media"> - <div></div> - <div class="media-body"> - <div class="media" style="overflow:visible;"> - <div><img src="../assets/img/1.jpg" class="mr-3" - style="width: 25px; height:25px;"></div> - <div class="media-body" style="overflow:visible;"> - <div class="row"> - <div class="col-md-12"> - <p><a href="#">Sara Doe:</a> This guy has been going - 100+ MPH on side streets. <br> - <small class="text-muted">August 6, 2016 @ 10:35am - </small> - </p> - </div> - </div> - </div> - </div> - </div> - </div> - </li> - <li class="list-group-item"> - <div class="media"> - <div></div> - <div class="media-body"> - <div class="media" style="overflow:visible;"> - <div><img src="../assets/img/2.jpg" class="mr-3" - style="width: 25px; height:25px;"></div> - <div class="media-body" style="overflow:visible;"> - <div class="row"> - <div class="col-md-12"> - <p><a href="#">Brennan Prill:</a> This guy has been - going 100+ MPH on side streets. <br> - <small class="text-muted">August 6, 2016 @ 10:35am - </small> - </p> - </div> - </div> - </div> - </div> - </div> - </div> - </li> - </ul> - <button class="btn btn-light"> - Add Comment - </button> - </div> - </div> - </td> </tr> </table> </div> </div> + <footer:footer/> </div> </body> diff --git a/gemeinsamforschen/src/main/webapp/pages/takeQuiz.jsp b/gemeinsamforschen/src/main/webapp/pages/takeQuiz.jsp index 0eb33c1eaf3afbddc608bf14f0ce7c50692e380d..a0c99526f7d16fcef2a3473c6f5d5f098ed016de 100644 --- a/gemeinsamforschen/src/main/webapp/pages/takeQuiz.jsp +++ b/gemeinsamforschen/src/main/webapp/pages/takeQuiz.jsp @@ -2,6 +2,7 @@ <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="menu" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="headLine" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="omniDependencies" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="footer" %> <!DOCTYPE html> <html> @@ -32,68 +33,11 @@ </table> <button id="submitQuiz" class="btn btn-success">Antwort speichern</button> </td> - <td id="chat"> - <div class="card"> - <div class="card-header"> - <h6 class="mb-0">Gruppen+Projekt Chat</h6> - </div> - <div class="card-body"> - <ul class="list-group"> - <li class="list-group-item"> - <div class="media"> - <div></div> - <div class="media-body"> - <div class="media" style="overflow:visible;"> - <div><img src="../assets/img/1.jpg" class="mr-3" - style="width: 25px; height:25px;"></div> - <div class="media-body" style="overflow:visible;"> - <div class="row"> - <div class="col-md-12"> - <p><a href="#">Sara Doe:</a> This guy has been going - 100+ MPH on side streets. <br> - <small class="text-muted">August 6, 2016 @ 10:35am - </small> - </p> - </div> - </div> - </div> - </div> - </div> - </div> - </li> - <li class="list-group-item"> - <div class="media"> - <div></div> - <div class="media-body"> - <div class="media" style="overflow:visible;"> - <div><img src="../assets/img/2.jpg" class="mr-3" - style="width: 25px; height:25px;"></div> - <div class="media-body" style="overflow:visible;"> - <div class="row"> - <div class="col-md-12"> - <p><a href="#">Brennan Prill:</a> This guy has been - going 100+ MPH on side streets. <br> - <small class="text-muted">August 6, 2016 @ 10:35am - </small> - </p> - </div> - </div> - </div> - </div> - </div> - </div> - </li> - </ul> - <button class="btn btn-light"> - Add Comment - </button> - </div> - </div> - </td> </tr> </table> </div> </div> + <footer:footer/> </div> </body> diff --git a/gemeinsamforschen/src/main/webapp/pages/unstructured-annotation.jsp b/gemeinsamforschen/src/main/webapp/pages/unstructured-annotation.jsp new file mode 100644 index 0000000000000000000000000000000000000000..94b29c07de3adfa1681dd11423e4607e69700e7e --- /dev/null +++ b/gemeinsamforschen/src/main/webapp/pages/unstructured-annotation.jsp @@ -0,0 +1,108 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="menu" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="headLine" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="omniDependencies" %> + +<!DOCTYPE html> +<html> + +<head> + <omniDependencies:omniDependencies/> + + <!-- css - unstructured-annotation --> + <link rel="stylesheet" type="text/css" href="../assets/css/unstructured-annotation.css"> + <!-- css - contextMenu --> + <link href="https://swisnl.github.io/jQuery-contextMenu/dist/jquery.contextMenu.css" rel="stylesheet" type="text/css" /> + + <!-- js - jQuery validation plugin --> + <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.14.0/jquery.validate.min.js"></script> + <!-- js - jQuery ui position --> + <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js" type="text/javascript"></script> + <!-- js - contextMenu script --> + <script src="https://swisnl.github.io/jQuery-contextMenu/dist/jquery.contextMenu.js" type="text/javascript"></script> + <!-- js - rangy Core --> + <script src="https://cdnjs.cloudflare.com/ajax/libs/rangy/1.3.0/rangy-core.js" type="text/javascript"></script> + <!-- js - rangy TextRange Module --> + <script src="https://cdnjs.cloudflare.com/ajax/libs/rangy/1.3.0/rangy-textrange.js" type="text/javascript"></script> + <!-- js - unstructuredRest --> + <script src="../assets/js/unstructuredRest.js"></script> + <!-- js - unstructuredUpload --> + <script src="../assets/js/unstructuredAnnotation.js"></script> + + +</head> + +<body> +<div id="wrapper" class="full-height"> + <menu:menu></menu:menu> + <div class="page-content-wrapper full-height"> + <div class="container-fluid full-height"> + <div class="container-fluid-content"> + <div class="flex"> + <headLine:headLine/> + </div> + <div class="content-mainpage"> + <div class="leftcolumn"> + <div class="leftcontent"> + <div class="leftcontent-text context-menu-one" id="documentText"></div> + <div class="leftcontent-buttons"> + <div class="leftcontent-buttons-save"> + <button id="btnSave" type="button" class="btn btn-secondary">Speichern</button> + </div> + </div> + </div> + </div> + <div class="rightcolumn"> + <div class="rightcontent"> + <ol id="annotations"> + <li class="spacing"> + <div id="titel" class="category-card not-added"> + <p>Titel</p> + </div> + </li> + <li class="spacing"> + <div id="recherche" class="category-card not-added"> + <p>Recherche</p> + </div> + </li> + <li class="spacing"> + <div id="literaturverzeichnis" class="category-card not-added"> + <p>Literaturverzeichnis</p> + </div> + </li> + <li class="spacing"> + <div id="forschungsfrage" class="category-card not-added"> + <p>Forschungsfrage</p> + </div> + </li> + <li class="spacing"> + <div id="untersuchungskonzept" class="category-card not-added"> + <p>Untersuchungskonzept</p> + </div> + </li> + <li class="spacing"> + <div id="methodik" class="category-card not-added"> + <p>Methodik</p> + </div> + </li> + <li class="spacing"> + <div id="durchfuehrung" class="category-card not-added"> + <p>Durchführung</p> + </div> + </li> + <li> + <div id="auswertung" class="category-card not-added"> + <p>Auswertung</p> + </div> + </li> + </ol> + </div> + </div> + </div> + </div> + </div> + </div> +</div> +</body> + +</html> diff --git a/gemeinsamforschen/src/main/webapp/pages/unstructured-upload.jsp b/gemeinsamforschen/src/main/webapp/pages/unstructured-upload.jsp new file mode 100644 index 0000000000000000000000000000000000000000..083f71f4cd99bffc55a20c3f311eae53d1fd2bb9 --- /dev/null +++ b/gemeinsamforschen/src/main/webapp/pages/unstructured-upload.jsp @@ -0,0 +1,58 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="menu" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="headLine" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="omniDependencies" %> + +<!DOCTYPE html> +<html> + +<head> + <omniDependencies:omniDependencies/> + + <!-- js - jQuery validation plugin --> + <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.14.0/jquery.validate.min.js"></script> + <!-- js - jQuery ui position --> + <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js" type="text/javascript"></script> + + <!-- css - upload-unstructured --> + <link rel="stylesheet" type="text/css" href="../assets/css/unstructured-upload.css"> + <!-- js - unstructuredUpload --> + <script src="../assets/js/unstructuredUpload.js"></script> + <!-- js - unstructuredRest --> + <script src="../assets/js/unstructuredRest.js"></script> + +</head> + +<body> +<div id="wrapper" class="full-height"> + <menu:menu></menu:menu> + <div class="page-content-wrapper full-height"> + <div class="container-fluid full-height"> + <div class="container-fluid-content"> + <div class="flex"> + <headLine:headLine/> + </div> + <div class="content-mainpage"> + <form id="upload-textarea-form"> + <div class="form-group upload-text" id="documentText"> + <label for="upload-textarea">Texteingabe</label> + <textarea class="upload-text-textarea form-control" placeholder="Text einfügen..." id="upload-textarea" name="uploadtextarea"></textarea> + </div> + </form> + + <div> + <label for="file">Alternativ bitte Datei wählen</label> + <input type="file" id="file" name="file"> + </div> + <div class="document-text-buttons"> + <button type="button" class="btn btn-secondary document-text-buttons-back" id="btnBack">Zurück</button> + <button type="button" class="btn btn-primary document-text-buttons-next" id="btnNext">Weiter</button> + </div> + </div> + </div> + </div> + </div> +</div> +</body> + +</html> diff --git a/gemeinsamforschen/src/main/webapp/pages/upload-unstructured.html b/gemeinsamforschen/src/main/webapp/pages/upload-unstructured.html deleted file mode 100644 index 092ea377d8a07edd36cb249bbf8fb6d665072304..0000000000000000000000000000000000000000 --- a/gemeinsamforschen/src/main/webapp/pages/upload-unstructured.html +++ /dev/null @@ -1,93 +0,0 @@ -<!DOCTYPE html> -<html> - -<head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <title>muster-gemeinsam-forschen</title> - - <!-- css - annotationStyle --> - <link rel="stylesheet" type="text/css" href="../assets/css/upload-unstructured.css"> - <!-- css - contextMenu --> - <link href="https://swisnl.github.io/jQuery-contextMenu/dist/jquery.contextMenu.css" rel="stylesheet" type="text/css" /> - <!-- css - bootstrap --> - <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> - <!-- css - styles --> - <link rel="stylesheet" href="../assets/css/styles.css"> - <!-- css - font awesome --> - <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous"> - <!-- css - sidebar --> - <link rel="stylesheet" href="../assets/css/Sidebar-Menu.css"> - - <!-- js - jQuery --> - <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> - <!-- js - bootstrap --> - <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> - <!-- js - jQuery ui position --> - <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js" type="text/javascript"></script> - <!-- js - contextMenu script --> - <script src="https://swisnl.github.io/jQuery-contextMenu/dist/jquery.contextMenu.js" type="text/javascript"></script> - <!-- js - annotationScript --> - <script src="../assets/js/uploadUnstructured.js"></script> - -</head> - -<body> -<div id="wrapper"> - <div id="sidebar-wrapper"> - <ul class="sidebar-nav"> - <li class="sidebar-brand"><a href="#">overview</a></li> - <li><a href="#">Quizfrage</a></li> - <li><a href="#">ePortfolio</a></li> - <li><a href="#">Beitrag</a></li> - <li><a href="#">Bewertung</a></li> - <li><a href="#">Logout</a></li> - </ul> - </div> - <div class="page-content-wrapper"> - <div class="container-fluid"> - <h1>Unstrukturierte Abgabe - <a href="#"> - <span class="glyphicon glyphicon-envelope" - style="font-size:27px;margin-top:-17px;margin-left:600px;"></span> - </a> - <a href="#"> - <span class="glyphicon glyphicon-cog" style="font-size:29px;margin-left:5px;margin-top:-25px;"></span> - </a> - </h1> - <div class="mainpage"> - <div class="leftcolumn"> - <div class="leftcontent "> - <div class="context-menu-one form-group" id="documentText"> - <label for="upload-area">Texteingabe:</label> - <textarea class="unstructured-textarea form-control" rows="20" id="upload-area"> -Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. - -Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. - -Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. - -Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. - -At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. - </textarea> - </div> - <div class="document-text-buttons"> - <button onclick="lockButtonHandler()" type="button" class="btn btn-secondary document-text-buttons-lock" id="btnLock"><i class="fas fa-lock-open" id="lock"></i></button> - <button type="button" class="btn btn-secondary document-text-buttons-save" id="btnSave">Speichern</i></button> - </div> - </div> - </div> - <div class="rightcolumn"> - <div class="rightcontent"> - <ol id="annotations"> - </ol> - </div> - </div> - </div> - </div> - </div> -</div> -</body> - -</html> \ No newline at end of file diff --git a/gemeinsamforschen/src/main/webapp/pages/upload-unstructured.jsp b/gemeinsamforschen/src/main/webapp/pages/upload-unstructured.jsp deleted file mode 100644 index 98dba6d3b364f74390ee3854c86089c0fec1f224..0000000000000000000000000000000000000000 --- a/gemeinsamforschen/src/main/webapp/pages/upload-unstructured.jsp +++ /dev/null @@ -1,90 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="menu"%> - -<!DOCTYPE html> -<html> - -<head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <title>muster-gemeinsam-forschen</title> - - <!-- css - annotationStyle --> - <link rel="stylesheet" type="text/css" href="../assets/css/upload-unstructured.css"> - <!-- css - contextMenu --> - <link href="https://swisnl.github.io/jQuery-contextMenu/dist/jquery.contextMenu.css" rel="stylesheet" type="text/css" /> - <!-- css - bootstrap --> - <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> - <!-- css - styles --> - <link rel="stylesheet" href="../assets/css/styles.css"> - <!-- css - font awesome --> - <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous"> - <!-- css - sidebar --> - <link rel="stylesheet" href="../assets/css/Sidebar-Menu.css"> - - <!-- js - jQuery --> - <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> - <!-- js - bootstrap --> - <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> - <!-- js - jQuery ui position --> - <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js" type="text/javascript"></script> - <!-- js - contextMenu script --> - <script src="https://swisnl.github.io/jQuery-contextMenu/dist/jquery.contextMenu.js" type="text/javascript"></script> - <!-- js - utility script --> - <script src="../assets/js/utility.js"></script> - <!-- js - annotationScript --> - <script src="../assets/js/uploadUnstructured.js"></script> - -</head> - -<body> -<div id="wrapper"> - <menu:menu></menu:menu> - <div class="page-content-wrapper"> - <div class="container-fluid"> - <h1>Unstrukturierte Abgabe - <a href="#"> - <span class="glyphicon glyphicon-envelope" - style="font-size:27px;margin-top:-17px;margin-left:600px;"></span> - </a> - <a href="#"> - <span class="glyphicon glyphicon-cog" style="font-size:29px;margin-left:5px;margin-top:-25px;"></span> - </a> - </h1> - <div class="mainpage"> - <div class="leftcolumn"> - <div class="leftcontent "> - <div class="context-menu-one form-group" id="documentText"> - <label for="upload-area">Texteingabe:</label> - <textarea class="unstructured-textarea form-control" rows="20" id="upload-area"> -Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. - -Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. - -Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. - -Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. - -At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. - </textarea> - </div> - <div class="document-text-buttons"> - <button onclick="lockButtonHandler()" type="button" class="btn btn-secondary document-text-buttons-lock" id="btnLock"><i class="fas fa-lock-open" id="lock"></i></button> - <button type="button" class="btn btn-secondary document-text-buttons-back" id="btnBack">Zurück</button> - <button type="button" class="btn btn-primary document-text-buttons-save" id="btnSave">Speichern</button> - </div> - </div> - </div> - <div class="rightcolumn"> - <div class="rightcontent"> - <ol id="annotations"> - </ol> - </div> - </div> - </div> - </div> - </div> -</div> -</body> - -</html> \ No newline at end of file diff --git a/gemeinsamforschen/src/main/webapp/pages/viewQuiz.jsp b/gemeinsamforschen/src/main/webapp/pages/viewQuiz.jsp index e105590e4a126bb3c2c390e9c9db96ff145dee07..8cadd01e748a2be689f85d9fec370d4d97e2d4a6 100644 --- a/gemeinsamforschen/src/main/webapp/pages/viewQuiz.jsp +++ b/gemeinsamforschen/src/main/webapp/pages/viewQuiz.jsp @@ -1,7 +1,9 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="menu" %> <%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="headLine" %> -<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="omniDependencies" %><!DOCTYPE html> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="omniDependencies" %> +<%@ taglib uri="../core/pages/gemeinsamForschen.tld" prefix="footer" %> +<!DOCTYPE html> <html> <head> @@ -30,68 +32,11 @@ </table> <button id="deleteQuiz" class="btn btn-danger">Quiz löschen</button> </td> - <td id="chat"> - <div class="card"> - <div class="card-header"> - <h6 class="mb-0">Gruppen+Projekt Chat</h6> - </div> - <div class="card-body"> - <ul class="list-group"> - <li class="list-group-item"> - <div class="media"> - <div></div> - <div class="media-body"> - <div class="media" style="overflow:visible;"> - <div><img src="../assets/img/1.jpg" class="mr-3" - style="width: 25px; height:25px;"></div> - <div class="media-body" style="overflow:visible;"> - <div class="row"> - <div class="col-md-12"> - <p><a href="#">Sara Doe:</a> This guy has been going - 100+ MPH on side streets. <br> - <small class="text-muted">August 6, 2016 @ 10:35am - </small> - </p> - </div> - </div> - </div> - </div> - </div> - </div> - </li> - <li class="list-group-item"> - <div class="media"> - <div></div> - <div class="media-body"> - <div class="media" style="overflow:visible;"> - <div><img src="../assets/img/2.jpg" class="mr-3" - style="width: 25px; height:25px;"></div> - <div class="media-body" style="overflow:visible;"> - <div class="row"> - <div class="col-md-12"> - <p><a href="#">Brennan Prill:</a> This guy has been - going 100+ MPH on side streets. <br> - <small class="text-muted">August 6, 2016 @ 10:35am - </small> - </p> - </div> - </div> - </div> - </div> - </div> - </div> - </li> - </ul> - <button class="btn btn-light"> - Add Comment - </button> - </div> - </div> - </td> </tr> </table> </div> </div> + <footer:footer/> </div> </body> diff --git a/gemeinsamforschen/src/scripts/dbschema/fltrail.sql b/gemeinsamforschen/src/scripts/dbschema/fltrail.sql index 0d5dfe1643c376e6ac1cdfa6f56451bbc9809633..21bacdb616a1795e4087d2cefe617b36a380406b 100644 --- a/gemeinsamforschen/src/scripts/dbschema/fltrail.sql +++ b/gemeinsamforschen/src/scripts/dbschema/fltrail.sql @@ -1,248 +1,137 @@ -CREATE DATABASE IF NOT EXISTS `fltrail` +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET AUTOCOMMIT = 0; +START TRANSACTION; +SET time_zone = "+00:00"; - DEFAULT CHARACTER SET utf8 +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; - COLLATE utf8_general_ci; -USE `fltrail`; - -CREATE TABLE if not exists `projects` ( - - `id` varchar(100) NOT NULL, - - `password` varchar(400) NOT NULL, - - `active` tinyint(1) NOT NULL, - - `timecreated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP - ON UPDATE CURRENT_TIMESTAMP, - - `author` varchar(400) NOT NULL, - - `adminPassword` varchar(400) NOT NULL, - - `token` varchar(400) NOT NULL, - - `phase` varchar(400) NOT NULL - -) - - ENGINE = InnoDB - - DEFAULT CHARSET = utf8; - -CREATE TABLE if not exists `groups` ( - - `id` int NOT NULL AUTO_INCREMENT, - - `projectId` varchar(400) NOT NULL, - - `chatRoomId` varchar(400) NOT NULL, - - PRIMARY KEY (id) - -) - - ENGINE = InnoDB - - DEFAULT CHARSET = utf8; - -CREATE TABLE if not exists groupuser - -( - - userEmail varchar(400) NOT NULL, - - groupId int NOT NULL - -) - - ENGINE = InnoDB - - DEFAULT CHARSET = utf8; - -CREATE TABLE if not exists `tags` ( - - `projectId` varchar(100) NOT NULL, - - `tag` varchar(400) NOT NULL - -) - - ENGINE = InnoDB - - DEFAULT CHARSET = utf8; - -CREATE TABLE if not exists `users` ( - - `name` varchar(100) NOT NULL, - - `password` varchar(200) NOT NULL, - - `email` varchar(255) NOT NULL, - - `token` varchar(800) NOT NULL, - - `rocketChatId` varchar(400) NOT NULL, - - `rocketChatAuthToken` varchar(800) NOT NULL, - - UNIQUE (email) - -) - - ENGINE = InnoDB - - DEFAULT CHARSET = utf8; - -CREATE TABLE if not exists projectuser - -( - - projectId varchar(100) NOT NULL, - - userId varchar(100) NOT NULL - -) - - ENGINE = InnoDB - - DEFAULT CHARSET = utf8; - -CREATE TABLE if not exists `annotations` ( +CREATE TABLE `annotations` ( `id` varchar(120) NOT NULL, `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `userToken` varchar(120) DEFAULT NULL, + `userId` int(11) DEFAULT NULL, `targetId` int(11) DEFAULT NULL, - `title` varchar(120) DEFAULT NULL, - `comment` varchar(400) DEFAULT NULL, + `body` varchar(280) DEFAULT NULL, `startCharacter` int(11) DEFAULT NULL, - `endCharacter` int(11) DEFAULT NULL, - PRIMARY KEY (`id`) + `endCharacter` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -alter table users - - add isStudent tinyint(1) default '1' null; - -CREATE TABLE if not exists quiz - -( - - author varchar(400) NOT NULL, - - projectId varchar(400) NOT NULL, - - question varchar(400) NOT NULL, - - mcType varchar(400) NOT NULL, - - answer varchar(400) NOT NULL, - - correct tinyint(1) NOT NULL - -) - - ENGINE = InnoDB - - DEFAULT CHARSET = utf8; -CREATE TABLE if not exists grades - -( - - projectId varchar(400) NOT NULL, - - studentId varchar(400) NOT NULL, - - grade double NOT NULL -) +CREATE TABLE `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=latin1; + +CREATE TABLE `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` ( + `projectId` varchar(400) NOT NULL, + `studentId` varchar(400) NOT NULL, + `grade` double NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE `groups` ( + `id` int(11) NOT NULL, + `projectId` varchar(400) NOT NULL, + `chatRoomId` varchar(400) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; - ENGINE = InnoDB +CREATE TABLE `groupuser` ( + `studentId` varchar(400) NOT NULL, + `projectId` varchar(400) NOT NULL, + `groupId` int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; - DEFAULT CHARSET = utf8; +CREATE TABLE `phasesselected` ( + `projectId` varchar(100) NOT NULL, + `phaseSelected` varchar(200) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE `profilepicture` ( + `studentId` varchar(200) NOT NULL, + `image` longblob NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE `projects` ( + `id` varchar(400) NOT NULL, + `password` varchar(400) NOT NULL, + `active` tinyint(1) NOT NULL, + `timecreated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `author` varchar(400) NOT NULL, + `adminPassword` varchar(400) NOT NULL, + `token` varchar(400) NOT NULL, + `phase` varchar(400) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE if not exists tasks +CREATE TABLE `projectuser` ( + `projectId` varchar(400) NOT NULL, + `userId` varchar(400) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -( +CREATE TABLE `quiz` ( + `author` varchar(400) NOT NULL, + `projectId` varchar(400) NOT NULL, + `question` varchar(400) NOT NULL, + `mcType` varchar(400) NOT NULL, + `answer` varchar(400) NOT NULL, + `correct` tinyint(1) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; - userId varchar(400) NOT NULL, +CREATE TABLE `tags` ( + `projectId` varchar(400) NOT NULL, + `tag` varchar(400) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; - projectId varchar(400) NOT NULL, +CREATE TABLE `tasks` ( + `userId` varchar(400) NOT NULL, + `projectId` varchar(400) NOT NULL, + `taskUrl` varchar(400) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; - taskUrl varchar(400) NOT NULL -) +CREATE TABLE `users` ( + `name` varchar(400) NOT NULL, + `password` varchar(200) NOT NULL, + `email` varchar(255) NOT NULL, + `token` varchar(800) NOT NULL, + `rocketChatId` varchar(400) NOT NULL, + `rocketChatAuthToken` varchar(800) NOT NULL, + `isStudent` tinyint(1) DEFAULT '1' +) ENGINE=InnoDB DEFAULT CHARSET=utf8; - ENGINE = InnoDB +CREATE TABLE `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=latin1; - DEFAULT CHARSET = utf8; +ALTER TABLE `annotations` + ADD PRIMARY KEY (`id`); -CREATE TABLE if not exists phasesSelected ( - `projectId` varchar(100) NOT NULL, - phaseSelected varchar(200) NOT NULL -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; +ALTER TABLE `groups` + ADD PRIMARY KEY (`id`); -CREATE TABLE if not exists categoriesSelected ( - `projectId` varchar(100) NOT NULL, - categorySelected varchar(200) NOT NULL -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; +ALTER TABLE `projectuser` + ADD KEY `projectId` (`projectId`(255),`userId`(255)); -CREATE TABLE if not exists groupfindingMechanismSelected ( - `projectId` varchar(100) NOT NULL, - gfmSelected varchar(200) NOT NULL -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; +ALTER TABLE `users` + ADD UNIQUE KEY `email` (`email`); -CREATE TABLE if not exists assessmentMechanismSelected ( - `projectId` varchar(100) NOT NULL, - amSelected varchar(200) NOT NULL -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; -ALTER TABLE `projectuser` - ADD INDEX (`projectId`, `userId`); -ALTER TABLE `projectuser` - ADD UNIQUE (`projectId`, `userId`); -ALTER TABLE `projects` - ADD UNIQUE (`id`); - -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 +ALTER TABLE `groups` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; +COMMIT; \ No newline at end of file diff --git a/gemeinsamforschen/src/test/java/unipotsdam/gf/interfaces/AnnotationTest.java b/gemeinsamforschen/src/test/java/unipotsdam/gf/interfaces/AnnotationTest.java index d0fde6c5871fd1533cc8e37308ec2e3068343327..7faee3414dc619219b3c9e98604dd4b69c4670bb 100644 --- a/gemeinsamforschen/src/test/java/unipotsdam/gf/interfaces/AnnotationTest.java +++ b/gemeinsamforschen/src/test/java/unipotsdam/gf/interfaces/AnnotationTest.java @@ -7,6 +7,7 @@ import unipotsdam.gf.modules.annotation.model.Annotation; import unipotsdam.gf.modules.annotation.model.AnnotationBody; import unipotsdam.gf.modules.annotation.model.AnnotationPatchRequest; import unipotsdam.gf.modules.annotation.model.AnnotationPostRequest; +import unipotsdam.gf.modules.peer2peerfeedback.Category; import java.util.ArrayList; @@ -37,7 +38,7 @@ public class AnnotationTest { String comment = "comment_testAddAnnotation"; // prepare and execute request - AnnotationPostRequest annotationPostRequest = new AnnotationPostRequest("userToken", 1, new AnnotationBody(title, comment, 1, 2)); + AnnotationPostRequest annotationPostRequest = new AnnotationPostRequest("userToken", "1", Category.TITEL, new AnnotationBody(title, comment, 1, 2)); Annotation response = controller.addAnnotation(annotationPostRequest); // the new annotation should be found in the database @@ -58,7 +59,7 @@ public class AnnotationTest { String commentNew = "commentNew_testAlterAnnotation"; // save new annotation in database - AnnotationPostRequest annotationPostRequest = new AnnotationPostRequest("userToken", 0, new AnnotationBody(titleOld, commentOld, 1, 2)); + AnnotationPostRequest annotationPostRequest = new AnnotationPostRequest("userToken", "0", Category.TITEL, new AnnotationBody(titleOld, commentOld, 1, 2)); Annotation response = controller.addAnnotation(annotationPostRequest); // the new annotation should be found in the database @@ -96,7 +97,7 @@ public class AnnotationTest { String comment = "comment_testDeleteAnnotation"; // prepare and execute request - AnnotationPostRequest annotationPostRequest = new AnnotationPostRequest("userToken", 1, new AnnotationBody(title, comment, 1, 2)); + AnnotationPostRequest annotationPostRequest = new AnnotationPostRequest("userToken", "1", Category.TITEL, new AnnotationBody(title, comment, 1, 2)); Annotation response = controller.addAnnotation(annotationPostRequest); // the new annotation should be found in the database @@ -118,7 +119,7 @@ public class AnnotationTest { String comment = "comment_testGetAnnotation"; // prepare and execute request - AnnotationPostRequest annotationPostRequest = new AnnotationPostRequest("userToken", 1, new AnnotationBody(title, comment, 1, 2)); + AnnotationPostRequest annotationPostRequest = new AnnotationPostRequest("userToken", "1", Category.TITEL, new AnnotationBody(title, comment, 1, 2)); Annotation response = controller.addAnnotation(annotationPostRequest); // receive the new annotation @@ -143,26 +144,26 @@ public class AnnotationTest { String comment = "comment_testGetAnnotations"; // initialize targetIds - ArrayList<Integer> targetIds = new ArrayList<>(); - targetIds.add(-1); - targetIds.add(-2); + ArrayList<String> targetIds = new ArrayList<>(); + targetIds.add("-1"); + targetIds.add("-2"); // save new annotations in database - AnnotationPostRequest request1 = new AnnotationPostRequest("userToken", targetIds.get(0), new AnnotationBody(title, comment, 1, 2)); - AnnotationPostRequest request2 = new AnnotationPostRequest("userToken", targetIds.get(1), new AnnotationBody(title, comment, 1, 2)); - AnnotationPostRequest request3 = new AnnotationPostRequest("userToken", targetIds.get(1), new AnnotationBody(title, comment, 1, 2)); + AnnotationPostRequest request1 = new AnnotationPostRequest("userToken", targetIds.get(0), Category.TITEL, new AnnotationBody(title, comment, 1, 2)); + AnnotationPostRequest request2 = new AnnotationPostRequest("userToken", targetIds.get(1), Category.TITEL, new AnnotationBody(title, comment, 1, 2)); + AnnotationPostRequest request3 = new AnnotationPostRequest("userToken", targetIds.get(1), Category.TITEL, new AnnotationBody(title, comment, 1, 2)); controller.addAnnotation(request1); controller.addAnnotation(request2); controller.addAnnotation(request3); // receive the new annotations with targetId = -2 - ArrayList<Annotation> getResponse = controller.getAnnotations(targetIds.get(1)); + ArrayList<Annotation> getResponse = controller.getAnnotations(targetIds.get(1), Category.TITEL); // the size of the getResponse should be 2 assertEquals("The size of the response should be 2 but was " + getResponse.size(), 2, getResponse.size()); // receive the new annotations with targetId = -1 - ArrayList<Annotation> getResponseNew = controller.getAnnotations(targetIds.get(0)); + ArrayList<Annotation> getResponseNew = controller.getAnnotations(targetIds.get(0), Category.TITEL); // the size of the getResponse should be 1 assertEquals("The size of the response should be 1 but was " + getResponseNew.size(), 1, getResponseNew.size()); @@ -183,7 +184,7 @@ public class AnnotationTest { String badId = "badId"; // save new annotation in database - AnnotationPostRequest annotationPostRequest = new AnnotationPostRequest("userToken", 0, new AnnotationBody(title, comment, 1, 2)); + AnnotationPostRequest annotationPostRequest = new AnnotationPostRequest("userToken", "0", Category.TITEL, new AnnotationBody(title, comment, 1, 2)); Annotation response = controller.addAnnotation(annotationPostRequest); // the annotation shouldn't be found in the database 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 9426d94804ed8b6f42600286e659fae1276d045a..cb7e6b830ee9af24b2b7f60c99e7a1bb45fc0cf2 100644 --- a/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/assessment/TestAddAssessment.java +++ b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/assessment/TestAddAssessment.java @@ -2,13 +2,71 @@ package unipotsdam.gf.modules.assessment; import org.junit.Test; import unipotsdam.gf.interfaces.IPeerAssessment; -import unipotsdam.gf.modules.assessment.controller.model.Assessment; +import unipotsdam.gf.modules.assessment.controller.model.*; 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 unipotsdam.gf.modules.assessment.controller.service.PeerAssessment; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class TestAddAssessment { + private IPeerAssessment peer = new PeerAssessment(); + private String studentId = "Kevin"; + private String projectId = "test a la test"; + private String quizId = "Whats a good Test?"; + + @Test + public void createQuiz(){ + StudentAndQuiz studentAndQuiz = new StudentAndQuiz(); + StudentIdentifier student = new StudentIdentifier(projectId, studentId); + studentAndQuiz.setStudentIdentifier(student); + Quiz quiz = new Quiz(); + ArrayList<String> correctAnswers = new ArrayList<>(); + correctAnswers.add("1"); + correctAnswers.add("2"); + correctAnswers.add("3"); + ArrayList<String> incorrectAnswers = new ArrayList<>(); + incorrectAnswers.add("4"); + incorrectAnswers.add("5"); + incorrectAnswers.add("6"); + quiz.setQuestion(quizId); + quiz.setIncorrectAnswers(incorrectAnswers); + quiz.setType("mc"); + quiz.setCorrectAnswers(correctAnswers); + studentAndQuiz.setQuiz(quiz); + peer.createQuiz(studentAndQuiz); + } + + @Test + public void getAllQuizzesInProject(){ + peer.getQuiz(projectId); + } + + @Test + public void getQuiz(){ + peer.getQuiz(projectId, quizId, studentId); + } + + @Test + public void answerQuiz(){ + Map<String, List<String>> questions = new HashMap<>(); + StudentIdentifier student = new StudentIdentifier(projectId, studentId); + List<String> answers = new ArrayList<>(); + answers.add("1"); + answers.add("2"); + answers.add("3"); + questions.put(quizId, answers); + peer.answerQuiz(questions, student); + } + + @Test + public void deleteQuiz(){ + peer.deleteQuiz(quizId); + } + @Test public void addTestAssessment() { IPeerAssessment iPeerAssessment = new FBAssessement(); diff --git a/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/model/dao/JournalDAOImplTest.java b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/model/dao/JournalDAOImplTest.java new file mode 100644 index 0000000000000000000000000000000000000000..008ec65f6695807383dfcf4290acc293ef65e41a --- /dev/null +++ b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/model/dao/JournalDAOImplTest.java @@ -0,0 +1,317 @@ +package unipotsdam.gf.modules.journal.model.dao; + +import org.junit.Test; +import unipotsdam.gf.core.database.mysql.MysqlConnect; +import unipotsdam.gf.core.database.mysql.VereinfachtesResultSet; +import unipotsdam.gf.core.management.project.Project; +import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; +import unipotsdam.gf.modules.journal.model.Journal; +import unipotsdam.gf.modules.journal.model.JournalFilter; +import unipotsdam.gf.modules.journal.model.Visibility; +import unipotsdam.gf.modules.journal.util.JournalUtils; +import unipotsdam.gf.modules.peer2peerfeedback.Category; + +import java.util.ArrayList; + +import static org.junit.Assert.*; + +public class JournalDAOImplTest { + + private final JournalDAO journalDAO = new JournalDAOImpl(); + private final MysqlConnect connection = new MysqlConnect(); + private final String testId = "-1"; + private final String testStudent = "testStudent"; + private final String testProject = "testProject"; + private final String testEntry = "This is a Test"; + private final Visibility testVisibility = Visibility.ALL; + private final Category testCategory = Category.TITEL; + private final Journal testJournal = new Journal(testId, new StudentIdentifier(testProject, testStudent), testEntry, testVisibility, testCategory); + + @Test + public void createJournal() { + + // Create Journal + Journal createJournal = testJournal; + journalDAO.createJournal(createJournal); + + connection.connect(); + + // Get that Journal + ArrayList<Journal> resultJournals = getJournals(); + + //Only one Journal should exist + assertEquals(1, resultJournals.size()); + + Journal resultJournal = resultJournals.get(0); + + //check if data correct + assertEquals(resultJournal.getStudentIdentifier().getStudentId(), testStudent); + assertEquals(resultJournal.getStudentIdentifier().getProjectId(), testProject); + assertEquals(resultJournal.getEntryMD(), testEntry); + + //Journal should get real id while create + assertFalse(resultJournal.getId().equals(testId)); + + assertEquals(resultJournal.getVisibility(), testVisibility); + assertEquals(resultJournal.getCategory(), testCategory); + + //cleanup + cleanup(resultJournal.getId()); + + connection.close(); + } + + @Test + public void updateJournal() { + + Journal updateJournal = testJournal; + //createJournal + + connection.connect(); + + // build and execute request + create(updateJournal); + + //change Data + Visibility newVisibility = Visibility.MINE; + Category newCategory = Category.DURCHFUEHRUNG; + String newEntry = "Still a test"; + + updateJournal.setVisibility(newVisibility); + updateJournal.setCategory(newCategory); + updateJournal.setEntry(newEntry); + + //update that Journal + journalDAO.updateJournal(updateJournal); + + //check if update successful + ArrayList<Journal> resultJournals = getJournals(); + + //Only one Journal should exist + assertEquals(1, resultJournals.size()); + + Journal resultJournal = resultJournals.get(0); + + //check if data correct + assertEquals(resultJournal.getStudentIdentifier().getStudentId(), testStudent); + assertEquals(resultJournal.getStudentIdentifier().getProjectId(), testProject); + assertEquals(resultJournal.getEntryMD(), newEntry); + assertEquals(resultJournal.getId(), testId); + assertEquals(resultJournal.getVisibility(), newVisibility); + assertEquals(resultJournal.getCategory(), newCategory); + + //cleanup + cleanup(updateJournal.getId()); + connection.close(); + + } + + @Test + public void deleteJournal() { + Journal deleteJournal = testJournal; + + //createJournal + connection.connect(); + + // build and execute request + create(deleteJournal); + + //check if Journal was added + ArrayList<Journal> resultJournals = getJournals(); + + assertEquals(1, resultJournals.size()); + + Journal resultJournal = resultJournals.get(0); + + + //delete Journal + journalDAO.deleteJournal(resultJournal.getId()); + + //check if deleted + resultJournals = getJournals(); + + assertEquals(0, resultJournals.size()); + + connection.close(); + } + + @Test + public void getJournal() { + + //create Journal + Journal getJournal = testJournal; + //createJournal + + connection.connect(); + + // build and execute request + create(getJournal); + + //get that Journal + Journal resultJournal = journalDAO.getJournal(testId); + + //check data + assertEquals(resultJournal.getStudentIdentifier().getStudentId(), testStudent); + assertEquals(resultJournal.getStudentIdentifier().getProjectId(), testProject); + assertEquals(resultJournal.getEntryMD(), testEntry); + assertEquals(resultJournal.getId(), testId); + assertEquals(resultJournal.getVisibility(), testVisibility); + assertEquals(resultJournal.getCategory(), testCategory); + + //cleanup + cleanup(resultJournal.getId()); + + connection.close(); + + } + + @Test + public void getAllByProject() { + connection.connect(); + + //add Some Journals + Journal j1 = testJournal; + create(j1); + j1.setId("-2"); + create(j1); + j1.setId("-3"); + j1.getStudentIdentifier().setProjectId("otherProject"); + create(j1); + + //get for project + ArrayList<Journal> resultJournals = journalDAO.getAllByProject(testProject, testStudent); + + //should be 2 Journals + assertEquals(2, resultJournals.size()); + + //should be j1 and j2 + for (Journal j : resultJournals) { + assertTrue(j.getId().equals("-1") || j.getId().equals("-2")); + } + + //cleanup + cleanup("-1", "-2", "-3"); + } + + @Test + public void getAllByProjectAndFilter() { + + connection.connect(); + + //Create some journals + Journal j1 = testJournal; + create(j1); + j1.getStudentIdentifier().setStudentId("otherStudent"); + j1.setId("-2"); + create(j1); + j1.setId("-3"); + j1.setVisibility(Visibility.MINE); + create(j1); + + //all should return 2 Journals + assertEquals(2, journalDAO.getAllByProjectAndFilter(testProject, testStudent, JournalFilter.ALL).size()); + + //Own should return 1 Journal + assertEquals(1, journalDAO.getAllByProjectAndFilter(testProject, testStudent, JournalFilter.OWN).size()); + + //Cleanup + cleanup("-1", "-2", "-3"); + connection.close(); + } + + @Test + public void closeJournal() { + connection.connect(); + + //create Journal + Journal closeJournal = testJournal; + create(closeJournal); + + Journal resultJournal = getJournals().get(0); + + //check if open + assertTrue(resultJournal.isOpen()); + + //close Journal + journalDAO.closeJournal(resultJournal.getId()); + + //check if closed + resultJournal = getJournals().get(0); + assertFalse(resultJournal.isOpen()); + + //cleanup + cleanup(resultJournal.getId()); + } + + @Test + public void getOpenJournals() { + connection.connect(); + + Project openProject = new Project(); + openProject.setId(testProject); + + //create some Journals + Journal j1 = testJournal; + create(j1); + j1.setOpen(false); + j1.setId("-2"); + create(j1); + j1.setId("-3"); + j1.getStudentIdentifier().setProjectId("otherProject"); + create(j1); + + //getOpenJournals + ArrayList<String> resultJournals = journalDAO.getOpenJournals(openProject); + + //should be 1 Journal + assertEquals(1, resultJournals.size()); + + //should be journal -1 + assertEquals(testStudent, resultJournals.get(0)); + + cleanup("-1", "-2", "-3"); + connection.close(); + } + + + //utility + + private ArrayList<Journal> getJournals() { + String request = "SELECT * FROM journals WHERE project= ?;"; + VereinfachtesResultSet rs = connection.issueSelectStatement(request, testProject); + + ArrayList<Journal> resultJournals = new ArrayList<>(); + while (rs.next()) { + resultJournals.add(getJournalFromResultSet(rs)); + } + return resultJournals; + } + + private void create(Journal getJournal) { + String createRequest = "INSERT INTO journals (`id`, `author`, `project`, `text`, `visibility`,`category`, `open` ) VALUES (?,?,?,?,?,?,?);"; + connection.issueInsertOrDeleteStatement(createRequest, getJournal.getId(), getJournal.getStudentIdentifier().getStudentId(), + getJournal.getStudentIdentifier().getProjectId(), getJournal.getEntryMD(), getJournal.getVisibility(), getJournal.getCategory(), getJournal.isOpen()); + } + + private void cleanup(String... ids) { + for (String id : ids) { + String deleteRequest = "DELETE FROM journals WHERE id = ?;"; + connection.issueInsertOrDeleteStatement(deleteRequest, id); + } + } + + private Journal getJournalFromResultSet(VereinfachtesResultSet rs) { + + String id = rs.getString("id"); + long timestamp = rs.getTimestamp(2).getTime(); + String student = rs.getString("author"); + String project = rs.getString("project"); + String text = rs.getString("text"); + String visibility = rs.getString("visibility"); + String category = rs.getString("category"); + boolean open = rs.getBoolean("open"); + + return new Journal(id, new StudentIdentifier(project, student), text, timestamp, JournalUtils.stringToVisibility(visibility), JournalUtils.stringToCategory(category), open); + + } +} \ No newline at end of file diff --git a/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/model/dao/LinkDAOImplTest.java b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/model/dao/LinkDAOImplTest.java new file mode 100644 index 0000000000000000000000000000000000000000..82b1b95d2e5711e2df937329a858027e26e3e982 --- /dev/null +++ b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/model/dao/LinkDAOImplTest.java @@ -0,0 +1,166 @@ +package unipotsdam.gf.modules.journal.model.dao; + +import org.junit.Test; +import unipotsdam.gf.core.database.mysql.MysqlConnect; +import unipotsdam.gf.core.database.mysql.VereinfachtesResultSet; +import unipotsdam.gf.modules.journal.model.Link; + +import java.util.ArrayList; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +public class LinkDAOImplTest { + + MysqlConnect connection = new MysqlConnect(); + LinkDAO linkDAO = new LinkDAOImpl(); + + String testId = "-1"; + String testProjectDescription = "testproject"; + String testName = "testname"; + String testLink = "https://www.test.de"; + Link testLinkObj = new Link(testId, testProjectDescription, testName, testLink); + + @Test + public void addLink() { + + connection.connect(); + + //add Link + Link addLink = testLinkObj; + + linkDAO.addLink(addLink); + + //check if added + ArrayList<Link> resultLinks = getLinks(addLink.getProjectDescription()); + + assertEquals(1, resultLinks.size()); + + //check data + Link resultLink = resultLinks.get(0); + + assertEquals(testLink, resultLink.getLink()); + assertEquals(testName, resultLink.getName()); + assertEquals(testProjectDescription, resultLink.getProjectDescription()); + + assertFalse(testId.equals(resultLink.getId())); + + //cleanup + cleanup(resultLink.getId()); + + connection.close(); + } + + @Test + public void deleteLink() { + connection.connect(); + + //add Link + Link deleteLink = testLinkObj; + + create(deleteLink); + + + //check if Link was created + ArrayList<Link> reultLinks = getLinks(deleteLink.getProjectDescription()); + assertEquals(1, reultLinks.size()); + + //delete link + linkDAO.deleteLink(deleteLink.getId()); + + //check if Link deleted + reultLinks = getLinks(deleteLink.getProjectDescription()); + assertEquals(0, reultLinks.size()); + + //cleanup + cleanup(deleteLink.getId()); + + connection.close(); + } + + @Test + public void getLink() { + connection.connect(); + + //addLink + Link getLink = testLinkObj; + create(getLink); + + //get Link + Link resultLink = linkDAO.getLink(getLink.getId()); + + //check Data + assertEquals(testLink, resultLink.getLink()); + assertEquals(testName, resultLink.getName()); + assertEquals(testProjectDescription, resultLink.getProjectDescription()); + + //cleanup + cleanup(getLink.getId()); + + connection.close(); + + } + + @Test + public void getAllLinks() { + connection.connect(); + + //addLinks + Link l = testLinkObj; + create(l); + l.setId("-2"); + l.setName("othername"); + create(l); + l.setId("-3"); + l.setLink("404"); + create(l); + + //gettLinks + ArrayList<Link> resultLinks = getLinks(testProjectDescription); + + //check + assertEquals(3, resultLinks.size()); + + //cleanup + cleanup("-1", "-2", "-3"); + + connection.close(); + } + + //Utility + private void create(Link deleteLink) { + String request = "INSERT INTO links (`id`, `projecdesription`, `name`, `link`) VALUES (?,?,?,?);"; + connection.issueInsertOrDeleteStatement(request, deleteLink.getId(), deleteLink.getProjectDescription(), deleteLink.getName(), deleteLink.getLink()); + } + + private void cleanup(String... addLinks) { + + for (String addLink : addLinks) { + + String request = "DELETE FROM links WHERE id = ?;"; + connection.issueInsertOrDeleteStatement(request, addLink); + } + } + + private Link getLinkFromResultSet(VereinfachtesResultSet rs) { + + String id = rs.getString("id"); + String project = rs.getString("projecdesription"); + String name = rs.getString("name"); + String link = rs.getString("link"); + return new Link(id, project, name, link); + } + + private ArrayList<Link> getLinks(String addLink) { + ArrayList<Link> resultLinks = new ArrayList<>(); + + String request = "SELECT * FROM links WHERE projecdesription= ?;"; + VereinfachtesResultSet rs = connection.issueSelectStatement(request, addLink); + + while (rs.next()) { + resultLinks.add(getLinkFromResultSet(rs)); + } + + return resultLinks; + } +} \ No newline at end of file diff --git a/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/model/dao/ProjectDescriptionImplDAOTest.java b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/model/dao/ProjectDescriptionImplDAOTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c63a1b8d70c2fd9251cab2852516f55a11966741 --- /dev/null +++ b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/model/dao/ProjectDescriptionImplDAOTest.java @@ -0,0 +1,225 @@ +package unipotsdam.gf.modules.journal.model.dao; + +import org.junit.Test; +import unipotsdam.gf.core.database.mysql.MysqlConnect; +import unipotsdam.gf.core.database.mysql.VereinfachtesResultSet; +import unipotsdam.gf.core.management.project.Project; +import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; +import unipotsdam.gf.modules.journal.model.ProjectDescription; + +import java.util.ArrayList; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class ProjectDescriptionImplDAOTest { + + private final ProjectDescriptionDAO descriptionDAO = new ProjectDescriptionDAOImpl(); + private final MysqlConnect connection = new MysqlConnect(); + + private String testId = "-1"; + private String testStudent = "testStudent"; + private String testDescription = "testDescription"; + private String testProjekt = "testProjekt"; + + private ProjectDescription testProjectDescription = new ProjectDescription(testId, testStudent, testDescription, testProjekt, null /*Links are added in Service*/); + + @Test + public void createDescription() { + + connection.connect(); + + descriptionDAO.createDescription(testProjectDescription); + + ArrayList<ProjectDescription> resultProjectDescriptions = getProjectDescription(); + + //should be 1 + assertEquals(1, resultProjectDescriptions.size()); + + ProjectDescription result = resultProjectDescriptions.get(0); + + //check data + assertFalse(testId.equals(result.getId())); + assertEquals(testDescription, result.getDescriptionMD()); + assertEquals(testStudent, result.getStudent().getStudentId()); + assertEquals(testProjekt, result.getStudent().getProjectId()); + + cleanup(result.getId()); + connection.close(); + } + + @Test + public void updateDescription() { + + connection.connect(); + + ProjectDescription updateDescription = testProjectDescription; + + create(updateDescription); + + updateDescription.setDescription(testDescription + testDescription); + + descriptionDAO.updateDescription(updateDescription); + + ArrayList<ProjectDescription> resultProjectDescriptions = getProjectDescription(); + + //should be 1 + assertEquals(1, resultProjectDescriptions.size()); + + ProjectDescription result = resultProjectDescriptions.get(0); + + //check data + assertEquals(testId, result.getId()); + assertEquals(testDescription + testDescription, result.getDescriptionMD()); + + cleanup(testId); + connection.close(); + + } + + @Test + public void getDescriptionSI() { + connection.connect(); + + ProjectDescription getDescription = testProjectDescription; + + create(getDescription); + + ProjectDescription result = descriptionDAO.getDescription(new StudentIdentifier(testProjekt, testStudent)); + + assertEquals(testId, result.getId()); + assertEquals(testDescription, result.getDescriptionMD()); + assertEquals(testStudent, result.getStudent().getStudentId()); + assertEquals(testProjekt, result.getStudent().getProjectId()); + + cleanup(result.getId()); + connection.close(); + } + + @Test + public void getDescriptionID() { + connection.connect(); + + ProjectDescription getDescription = testProjectDescription; + + create(getDescription); + + ProjectDescription result = descriptionDAO.getDescription(testId); + + assertEquals(testId, result.getId()); + assertEquals(testDescription, result.getDescriptionMD()); + assertEquals(testStudent, result.getStudent().getStudentId()); + assertEquals(testProjekt, result.getStudent().getProjectId()); + + cleanup(result.getId()); + connection.close(); + } + + @Test + public void deleteDescription() { + connection.connect(); + + ProjectDescription deleteDescription = testProjectDescription; + + create(deleteDescription); + + ArrayList<ProjectDescription> resultDescriptions = getProjectDescription(); + + //should be 1 + assertEquals(1, resultDescriptions.size()); + + descriptionDAO.deleteDescription(new StudentIdentifier(testProjekt, testStudent)); + + resultDescriptions = getProjectDescription(); + + //should be 0 + assertEquals(0, resultDescriptions.size()); + + connection.close(); + } + + @Test + public void closeDescription() { + connection.connect(); + + ProjectDescription closeDescription = testProjectDescription; + + create(closeDescription); + + ArrayList<ProjectDescription> resultDescriptions = getProjectDescription(); + + //should be 1 + assertEquals(1, resultDescriptions.size()); + assertTrue(resultDescriptions.get(0).isOpen()); + + descriptionDAO.closeDescription(testId); + + resultDescriptions = getProjectDescription(); + + //should be 1 + assertEquals(1, resultDescriptions.size()); + assertFalse(resultDescriptions.get(0).isOpen()); + + connection.close(); + } + + @Test + public void getOpenDescriptions() { + connection.connect(); + + ProjectDescription openDescription = testProjectDescription; + create(openDescription); + openDescription.setId("-2"); + create(openDescription); + openDescription.setId("-3"); + openDescription.setOpen(false); + create(openDescription); + + Project project = new Project(); + project.setId(testProjekt); + + ArrayList<String> resultDescriptions = descriptionDAO.getOpenDescriptions(project); + assertEquals(2, resultDescriptions.size()); + + cleanup("-1","-2","-3"); + connection.close(); + } + + + //Utility + private ArrayList<ProjectDescription> getProjectDescription() { + String request = "SELECT * FROM projectdescription WHERE project=?;"; + VereinfachtesResultSet rs = connection.issueSelectStatement(request, testProjekt); + + ArrayList<ProjectDescription> resultDescriptions = new ArrayList<>(); + while (rs.next()) { + resultDescriptions.add(getDescriptionFromResultSet(rs)); + } + return resultDescriptions; + } + + private void create(ProjectDescription projectDescription) { + String request = "INSERT INTO projectdescription(`id`, `author`, `project`, `text`, `open`) VALUES (?,?,?,?,?);"; + connection.issueInsertOrDeleteStatement(request, projectDescription.getId(), projectDescription.getStudent().getStudentId(), projectDescription.getStudent().getProjectId(), projectDescription.getDescriptionMD(), projectDescription.isOpen()); + } + + private void cleanup(String... ids) { + for (String id : ids) { + String request = "DELETE FROM projectdescription WHERE id = ? ;"; + connection.issueInsertOrDeleteStatement(request, id); + } + } + + private ProjectDescription getDescriptionFromResultSet(VereinfachtesResultSet rs) { + String id = rs.getString("id"); + long timestamp = rs.getTimestamp(2).getTime(); + String author = rs.getString("author"); + String project = rs.getString("project"); + String text = rs.getString("text"); + boolean open = rs.getBoolean("open"); + + return new ProjectDescription(id, author, text, project, new ArrayList<>(), timestamp, open); + } + +} diff --git a/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/service/JournalServiceImplTest.java b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/service/JournalServiceImplTest.java new file mode 100644 index 0000000000000000000000000000000000000000..05ce97fb48f7880edf0b40c40b79be515661bc81 --- /dev/null +++ b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/service/JournalServiceImplTest.java @@ -0,0 +1,212 @@ +package unipotsdam.gf.modules.journal.service; + +import org.junit.After; +import org.junit.Test; +import unipotsdam.gf.core.management.Management; +import unipotsdam.gf.core.management.ManagementImpl; +import unipotsdam.gf.core.management.project.Project; +import unipotsdam.gf.core.management.user.User; +import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; +import unipotsdam.gf.modules.journal.model.Journal; +import unipotsdam.gf.modules.journal.model.Visibility; +import unipotsdam.gf.modules.journal.model.dao.JournalDAO; +import unipotsdam.gf.modules.journal.model.dao.JournalDAOImpl; +import unipotsdam.gf.modules.peer2peerfeedback.Category; + +import java.util.ArrayList; + +import static org.junit.Assert.*; + +public class JournalServiceImplTest { + + private final String testId = "-1"; + private final String testStudent = "testStudent"; + private final String testProject = "testProject"; + private final String testEntry = "This is a Test"; + private final Visibility testVisibility = Visibility.ALL; + private final Category testCategory = Category.TITEL; + private final Journal testJournal = new Journal(testId, new StudentIdentifier(testProject, testStudent), testEntry, testVisibility, testCategory); + private JournalService journalService = new JournalServiceImpl(); + private JournalDAO journalDAO = new JournalDAOImpl(); + private Management management = new ManagementImpl(); + + @After + public void cleanUp() { + + ArrayList<Journal> deleteJournals = journalDAO.getAllByProject(testProject, testStudent); + + for (Journal j : deleteJournals) { + journalDAO.deleteJournal(j.getId()); + } + } + + @Test + public void getJournal() { + + journalDAO.createJournal(testJournal); + + //get id of added Journal + String journalID = journalDAO.getAllByProject(testProject, testStudent).get(0).getId(); + + Journal resultJournal = journalService.getJournal(journalID); + + assertNotNull(resultJournal); + + assertEquals(resultJournal.getStudentIdentifier().getStudentId(), testStudent); + assertEquals(resultJournal.getStudentIdentifier().getProjectId(), testProject); + assertEquals(resultJournal.getEntryMD(), testEntry); + assertEquals(resultJournal.getId(), journalID); + assertEquals(resultJournal.getVisibility(), testVisibility); + assertEquals(resultJournal.getCategory(), testCategory); + + } + + @Test + public void getAllJournalsSi() { + + journalDAO.createJournal(testJournal); + journalDAO.createJournal(testJournal); + journalDAO.createJournal(testJournal); + testJournal.setStudentIdentifier(new StudentIdentifier("a", "b")); + journalDAO.createJournal(testJournal); + + ArrayList<Journal> resultJurnals = journalService.getAllJournals(testStudent, testProject); + + assertEquals(3, resultJurnals.size()); + + //Delete extra Journal + String jId = journalDAO.getAllByProject("a", "b").get(0).getId(); + journalDAO.deleteJournal(jId); + } + + @Test + public void getAllJournalsFilter() { + journalDAO.createJournal(testJournal); + testJournal.setVisibility(Visibility.MINE); + journalDAO.createJournal(testJournal); + testJournal.setVisibility(Visibility.GROUP); + journalDAO.createJournal(testJournal); + testJournal.setStudentIdentifier(new StudentIdentifier(testProject, "b")); + testJournal.setVisibility(Visibility.ALL); + journalDAO.createJournal(testJournal); + + ArrayList<Journal> resultJournals = journalService.getAllJournals("b", testProject); + + assertEquals(3, resultJournals.size()); + + //Delete extra Journal + String jId = journalDAO.getAllByProject(testProject, "b").get(0).getId(); + journalDAO.deleteJournal(jId); + + } + + @Test + public void saveJournal() { + //Create new + + journalService.saveJournal("0",testStudent,testProject,testEntry,testVisibility.toString(),testVisibility.toString()); + + String journalID = journalDAO.getAllByProject(testProject, testStudent).get(0).getId(); + + Journal resultJournal = journalDAO.getJournal(journalID); + + assertNotNull(resultJournal); + + assertEquals(resultJournal.getStudentIdentifier().getStudentId(), testStudent); + assertEquals(resultJournal.getStudentIdentifier().getProjectId(), testProject); + assertEquals(resultJournal.getEntryMD(), testEntry); + assertEquals(resultJournal.getId(), journalID); + assertEquals(resultJournal.getVisibility(), testVisibility); + assertEquals(resultJournal.getCategory(), testCategory); + + + //Update + + journalService.saveJournal(journalID,testStudent,testProject,testEntry+testEntry,Visibility.MINE.toString(),Category.AUSWERTUNG.toString()); + + resultJournal = journalDAO.getJournal(journalID); + + assertNotNull(resultJournal); + + assertEquals(resultJournal.getStudentIdentifier().getStudentId(), testStudent); + assertEquals(resultJournal.getStudentIdentifier().getProjectId(), testProject); + assertEquals(resultJournal.getEntryMD(), testEntry+testEntry); + assertEquals(resultJournal.getId(), journalID); + assertEquals(resultJournal.getVisibility(), Visibility.MINE); + assertEquals(resultJournal.getCategory(), Category.AUSWERTUNG); + + + } + + @Test + public void deleteJournal() { + + journalDAO.createJournal(testJournal); + + ArrayList<Journal> resultJournals = journalDAO.getAllByProject(testProject, testStudent); + assertEquals(1, resultJournals.size()); + + String jId = resultJournals.get(0).getId(); + + journalService.deleteJournal(jId); + + resultJournals = journalDAO.getAllByProject(testProject, testStudent); + assertEquals(0, resultJournals.size()); + + } + + @Test + public void closeJournal() { + + journalDAO.createJournal(testJournal); + + Journal resultJournal = journalDAO.getAllByProject(testProject, testStudent).get(0); + + assertTrue(resultJournal.isOpen()); + + journalService.closeJournal(resultJournal.getId()); + resultJournal = journalDAO.getAllByProject(testProject, testStudent).get(0); + + assertFalse(resultJournal.isOpen()); + } + + @Test + public void checkIfAllJournalClosed() { + + Project project = new Project(); + project.setId(testProject); + + journalDAO.createJournal(testJournal); + journalDAO.createJournal(testJournal); + + ArrayList<Journal> resultJournals = journalDAO.getAllByProject(testProject,testStudent); + + assertFalse(journalService.checkIfAllJournalClosed(project)); + + for(Journal j : resultJournals){ + journalDAO.closeJournal(j.getId()); + } + + assertTrue(journalService.checkIfAllJournalClosed(project)); + + } + + @Test + public void getOpenUserByProject() { + + User user = new User("Test", "Test", "test@test.de", true); + String token = management.getUserToken(user); + + Project project = new Project(); + + testJournal.getStudentIdentifier().setStudentId(token); + project.setId(testProject); + + journalDAO.createJournal(testJournal); + + ArrayList<User> resultUsers = journalService.getOpenUserByProject(project); + + assertEquals(1,resultUsers.size()); + assertEquals(user.getEmail(),resultUsers.get(0).getId()); + } +} \ No newline at end of file diff --git a/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/service/ProjectDescriptionImplTest.java b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/service/ProjectDescriptionImplTest.java new file mode 100644 index 0000000000000000000000000000000000000000..66b84406055c680e3c314354ec6897e9126eff5e --- /dev/null +++ b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/service/ProjectDescriptionImplTest.java @@ -0,0 +1,204 @@ +package unipotsdam.gf.modules.journal.service; + +import org.junit.After; +import org.junit.Test; +import unipotsdam.gf.core.management.Management; +import unipotsdam.gf.core.management.ManagementImpl; +import unipotsdam.gf.core.management.project.Project; +import unipotsdam.gf.core.management.user.User; +import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; +import unipotsdam.gf.modules.journal.model.Link; +import unipotsdam.gf.modules.journal.model.ProjectDescription; +import unipotsdam.gf.modules.journal.model.dao.LinkDAO; +import unipotsdam.gf.modules.journal.model.dao.LinkDAOImpl; +import unipotsdam.gf.modules.journal.model.dao.ProjectDescriptionDAO; +import unipotsdam.gf.modules.journal.model.dao.ProjectDescriptionDAOImpl; + +import java.util.ArrayList; + +import static org.junit.Assert.*; + +public class ProjectDescriptionImplTest { + + private ProjectDescriptionService projectDescriptionService = new ProjectDescriptionImpl(); + + private ProjectDescriptionDAO descriptionDAO = new ProjectDescriptionDAOImpl(); + private LinkDAO linkDAO = new LinkDAOImpl(); + private Management management = new ManagementImpl(); + + private String testId = "-1"; + private String testStudent = "testStudent"; + private String testDescription = "testDescription"; + private String testProject = "testProject"; + + private String testProjectDescription = "testproject"; + private String testName = "testname"; + private String testLink = "https://www.test.de"; + private Link testLinkObj = new Link(testId, testProjectDescription, testName, testLink); + + private ArrayList<Link> linkArrayList = new ArrayList<>(); + + private ProjectDescription testProjectDescriptionObj = new ProjectDescription(testId, testStudent, testDescription, testProject, linkArrayList); + + @After + public void cleanUp() { + StudentIdentifier deleteIdentifier = new StudentIdentifier(testProject, testStudent); + ProjectDescription deleteDescription = descriptionDAO.getDescription(deleteIdentifier); + descriptionDAO.deleteDescription(deleteIdentifier); + + if (deleteDescription != null) { + ArrayList<Link> deleteLinks = linkDAO.getAllLinks(deleteDescription.getId()); + + for (Link l : deleteLinks) { + linkDAO.deleteLink(l.getId()); + } + } + } + + @Test + public void getProjectbyStudent() { + //NO description exists + projectDescriptionService.getProjectByStudent(new StudentIdentifier(testProject, testStudent)); + + ProjectDescription resProjectDescription = descriptionDAO.getDescription(new StudentIdentifier(testProject, testStudent)); + String id = resProjectDescription.getId(); + + assertNotNull(resProjectDescription); + assertEquals("Hier soll ein Turtorialtext stehen", resProjectDescription.getDescriptionMD()); + assertEquals(testStudent, resProjectDescription.getStudent().getStudentId()); + assertEquals(testProject, resProjectDescription.getStudent().getProjectId()); + + //description exists + resProjectDescription = descriptionDAO.getDescription(new StudentIdentifier(testProject, testStudent)); + + assertNotNull(resProjectDescription); + assertEquals(id, resProjectDescription.getId()); + assertEquals("Hier soll ein Turtorialtext stehen", resProjectDescription.getDescriptionMD()); + assertEquals(testStudent, resProjectDescription.getStudent().getStudentId()); + assertEquals(testProject, resProjectDescription.getStudent().getProjectId()); + + } + + @Test + public void getProjectbyId() { + + descriptionDAO.createDescription(testProjectDescriptionObj); + String id = descriptionDAO.getDescription(new StudentIdentifier(testProject, testStudent)).getId(); + + testLinkObj.setProjectDescription(id); + linkDAO.addLink(testLinkObj); + + ProjectDescription resProjectDescription = projectDescriptionService.getProjectById(id); + + assertNotNull(resProjectDescription); + assertEquals(testDescription, resProjectDescription.getDescriptionMD()); + assertEquals(testStudent, resProjectDescription.getStudent().getStudentId()); + assertEquals(testProject, resProjectDescription.getStudent().getProjectId()); + + ArrayList<Link> links = resProjectDescription.getLinks(); + assertEquals(1, links.size()); + assertEquals(testLink, links.get(0).getLink()); + assertEquals(testName, links.get(0).getName()); + + } + + @Test + public void saveProjectText() { + descriptionDAO.createDescription(testProjectDescriptionObj); + + projectDescriptionService.saveProjectText(new StudentIdentifier(testProject, testStudent), testName); + + ProjectDescription resProjectDescription = descriptionDAO.getDescription(new StudentIdentifier(testProject, testStudent)); + + assertEquals(testName, resProjectDescription.getDescriptionMD()); + + } + + @Test + public void addLink() { + descriptionDAO.createDescription(testProjectDescriptionObj); + ProjectDescription resProjectDescription = descriptionDAO.getDescription(new StudentIdentifier(testProject, testStudent)); + + projectDescriptionService.addLink(resProjectDescription.getId(), testLink, testName); + + ArrayList<Link> resLinks = linkDAO.getAllLinks(resProjectDescription.getId()); + + assertEquals(1, resLinks.size()); + assertEquals(resProjectDescription.getId(), resLinks.get(0).getProjectDescription()); + assertEquals(testName, resLinks.get(0).getName()); + assertEquals(testLink, resLinks.get(0).getLink()); + + } + + @Test + public void deleteLink() { + descriptionDAO.createDescription(testProjectDescriptionObj); + ProjectDescription resProjectDescription = descriptionDAO.getDescription(new StudentIdentifier(testProject, testStudent)); + + testLinkObj.setProjectDescription(resProjectDescription.getId()); + linkDAO.addLink(testLinkObj); + + ArrayList<Link> resLinks = linkDAO.getAllLinks(resProjectDescription.getId()); + + assertEquals(1, resLinks.size()); + + projectDescriptionService.deleteLink(resLinks.get(0).getId()); + + resLinks = linkDAO.getAllLinks(resProjectDescription.getId()); + assertEquals(0, resLinks.size()); + + } + + @Test + public void closeDescription() { + + descriptionDAO.createDescription(testProjectDescriptionObj); + + ProjectDescription resDescription = descriptionDAO.getDescription(new StudentIdentifier(testProject, testStudent)); + + assertTrue(resDescription.isOpen()); + + projectDescriptionService.closeDescription(resDescription.getId()); + + resDescription = descriptionDAO.getDescription(new StudentIdentifier(testProject, testStudent)); + + assertFalse(resDescription.isOpen()); + } + + @Test + public void checkIfAllDescriptionsClosed() { + + descriptionDAO.createDescription(testProjectDescriptionObj); + + Project project = new Project(); + project.setId(testProject); + assertFalse(projectDescriptionService.checkIfAllDescriptionsClosed(project)); + + ProjectDescription resDescription = descriptionDAO.getDescription(new StudentIdentifier(testProject, testStudent)); + + descriptionDAO.closeDescription(resDescription.getId()); + + assertTrue(projectDescriptionService.checkIfAllDescriptionsClosed(project)); + + } + + @Test + public void getOpenUserByProject() { + User user = new User("Test", "Test", "test@test.de", true); + String token = management.getUserToken(user); + + Project project = new Project(); + project.setId(testProject); + + testProjectDescriptionObj.getStudent().setStudentId(token); + descriptionDAO.createDescription(testProjectDescriptionObj); + + ArrayList<User> resultUser = projectDescriptionService.getOpenUserByProject(project); + + assertEquals(1, resultUser.size()); + assertEquals(user.getEmail(), resultUser.get(0).getId()); + + StudentIdentifier delUser = new StudentIdentifier(testProject, token); + descriptionDAO.deleteDescription(delUser); + } +} \ No newline at end of file