Skip to content
Snippets Groups Projects
Commit cc4f8724 authored by wiepke's avatar wiepke
Browse files

dynamic annotationCategories for each project

parent 60f9d0bd
Branches vaMigration
No related tags found
No related merge requests found
...@@ -202,6 +202,15 @@ public class AnnotationController implements IAnnotation { ...@@ -202,6 +202,15 @@ public class AnnotationController implements IAnnotation {
AnnotationBody body = new AnnotationBody(title, comment, startCharacter, endCharacter); AnnotationBody body = new AnnotationBody(title, comment, startCharacter, endCharacter);
return new Annotation(id, timestamp, userEmail, targetId, targetCategory, body); return new Annotation(id, timestamp, userEmail, targetId, targetCategory, body);
}
public void setAnnotationCategories(Project project) {
connection.connect();
for (String category : project.getCategories()) {
String query = "INSERT INTO `categoriesselected`(`projectName`, `categorySelected`) VALUES (?,?)";
connection.issueUpdateStatement(
query, project.getName(), category);
}
connection.close();
} }
} }
...@@ -7,7 +7,7 @@ package unipotsdam.gf.modules.annotation.model; ...@@ -7,7 +7,7 @@ package unipotsdam.gf.modules.annotation.model;
public class AnnotationResponse { public class AnnotationResponse {
// variables // variables
String message; private String message;
// constructors // constructors
public AnnotationResponse(String message) { public AnnotationResponse(String message) {
......
...@@ -660,8 +660,12 @@ public class SubmissionController implements ISubmission, HasProgress { ...@@ -660,8 +660,12 @@ public class SubmissionController implements ISubmission, HasProgress {
} }
public GroupFeedbackTaskData getMyFeedback(User user, Project project) { public GroupFeedbackTaskData getMyFeedback(User user, Project project) {
connection.connect();
Integer groupId = groupDAO.getGroupByStudent(project, user); Integer groupId = groupDAO.getGroupByStudent(project, user);
return getMyFeedback(groupId, project);
}
public GroupFeedbackTaskData getMyFeedback(Integer groupId, Project project) {
connection.connect();
String query = "SELECT * from fullsubmissions where groupId = ? and projectName = ?"; String query = "SELECT * from fullsubmissions where groupId = ? and projectName = ?";
VereinfachtesResultSet vereinfachtesResultSet = connection.issueSelectStatement(query, groupId, VereinfachtesResultSet vereinfachtesResultSet = connection.issueSelectStatement(query, groupId,
project.getName()); project.getName());
...@@ -803,4 +807,18 @@ public class SubmissionController implements ISubmission, HasProgress { ...@@ -803,4 +807,18 @@ public class SubmissionController implements ISubmission, HasProgress {
connection.close(); connection.close();
return feedbackedGroup; return feedbackedGroup;
} }
public List<String> getAnnotationCategories(Project project) {
List<String> result = new ArrayList<>();
connection.connect();
String query = "select * from categoriesselected where projectName = ?";
VereinfachtesResultSet vereinfachtesResultSet = connection.issueSelectStatement(query,
project.getName());
while (vereinfachtesResultSet.next()) {
result.add(vereinfachtesResultSet.getString("categorySelected"));
}
connection.close();
return result;
}
} }
\ No newline at end of file
...@@ -215,8 +215,11 @@ public class SubmissionService { ...@@ -215,8 +215,11 @@ public class SubmissionService {
@GET @GET
@Path("categories/project/{projectName}") @Path("categories/project/{projectName}")
public List<String> getAnnotationCategories(@PathParam("projectName") String projectName) { public List<String> getAnnotationCategories(@PathParam("projectName") String projectName) {
//todo: for every project categories should be selectable List<String> result = submissionController.getAnnotationCategories(new Project(projectName));
return Categories.standardAnnotationCategories; if (result.size() == 0) {
return Categories.standardAnnotationCategories;
}
return result;
} }
@GET @GET
......
...@@ -5,6 +5,7 @@ import unipotsdam.gf.exceptions.UserDoesNotExistInRocketChatException; ...@@ -5,6 +5,7 @@ import unipotsdam.gf.exceptions.UserDoesNotExistInRocketChatException;
import unipotsdam.gf.exceptions.UserExistsInMysqlException; import unipotsdam.gf.exceptions.UserExistsInMysqlException;
import unipotsdam.gf.exceptions.UserExistsInRocketChatException; import unipotsdam.gf.exceptions.UserExistsInRocketChatException;
import unipotsdam.gf.interfaces.ICommunication; import unipotsdam.gf.interfaces.ICommunication;
import unipotsdam.gf.modules.annotation.controller.AnnotationController;
import unipotsdam.gf.modules.communication.model.RocketChatUser; import unipotsdam.gf.modules.communication.model.RocketChatUser;
import unipotsdam.gf.modules.group.GroupDAO; import unipotsdam.gf.modules.group.GroupDAO;
import unipotsdam.gf.modules.group.preferences.database.ProfileDAO; import unipotsdam.gf.modules.group.preferences.database.ProfileDAO;
...@@ -46,6 +47,9 @@ public class ProjectCreationProcess { ...@@ -46,6 +47,9 @@ public class ProjectCreationProcess {
@Inject @Inject
private GFContexts gfContexts; private GFContexts gfContexts;
@Inject
private AnnotationController annotationController;
/** /**
* STEP 1 * STEP 1
* *
...@@ -60,6 +64,7 @@ public class ProjectCreationProcess { ...@@ -60,6 +64,7 @@ public class ProjectCreationProcess {
} catch (Exception e) { } catch (Exception e) {
throw new WebApplicationException("Project already exists"); throw new WebApplicationException("Project already exists");
} }
annotationController.setAnnotationCategories(project);
profileDAO.createNewSurveyProject(project); profileDAO.createNewSurveyProject(project);
taskDao.createTaskWaitForParticipants(project, author); taskDao.createTaskWaitForParticipants(project, author);
......
...@@ -303,7 +303,10 @@ public class TaskDAO { ...@@ -303,7 +303,10 @@ public class TaskDAO {
} }
case REEDIT_DOSSIER: { case REEDIT_DOSSIER: {
result = getGeneralTask(vereinfachtesResultSet); result = getGeneralTask(vereinfachtesResultSet);
GroupFeedbackTaskData groupFeedbackTaskData = submissionController.getMyFeedback(groupId, project);
if (groupFeedbackTaskData == null) {
break;
}
Map<String, String> taskData = new HashMap<>(); Map<String, String> taskData = new HashMap<>();
taskData.put("fullSubmissionId", submissionController.getFullSubmissionId(groupId, project, ContributionCategory.DOSSIER, 1)); taskData.put("fullSubmissionId", submissionController.getFullSubmissionId(groupId, project, ContributionCategory.DOSSIER, 1));
result.setTaskData(taskData); result.setTaskData(taskData);
......
...@@ -137,9 +137,12 @@ function getProjectValues() { ...@@ -137,9 +137,12 @@ function getProjectValues() {
} }
let time = new Date().getTime(); let time = new Date().getTime();
let selectedCategories = []; let selectedCategories = [];
$(".category input:checked").each(function () { $("input:checked[class*='category']").each(function () {
selectedCategories.push($(this).val()); selectedCategories.push($(this).val());
}); });
if (selectedCategories.length === 0) {
stop();
}
return { return {
"name": projectName, "name": projectName,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment