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

Deleting project

parent 4ae1842f
No related branches found
No related tags found
No related merge requests found
Showing
with 111 additions and 134 deletions
......@@ -12,13 +12,13 @@ public class ProjectConfiguration {
private HashMap<Phase, Boolean> phasesSelected;
private HashMap<Category, Boolean> criteriaSelected;
private HashMap<AssessmentMechanism, Boolean> assessmentMechanismSelected;
private AssessmentMechanism assessmentMechanismSelected;
private GroupFormationMechanism groupMechanismSelected;
public ProjectConfiguration(
HashMap<Phase, Boolean> phasesSelected,
HashMap<Category, Boolean> criteriaSelected,
HashMap<AssessmentMechanism, Boolean> assessmentMechanismSelected,
AssessmentMechanism assessmentMechanismSelected,
GroupFormationMechanism groupMechanismSelected) {
this.phasesSelected = phasesSelected;
this.criteriaSelected = criteriaSelected;
......@@ -43,12 +43,12 @@ public class ProjectConfiguration {
this.criteriaSelected = criteriaSelected;
}
public HashMap<AssessmentMechanism, Boolean> getAssessmentMechanismSelected() {
public AssessmentMechanism getAssessmentMechanismSelected() {
return assessmentMechanismSelected;
}
public void setAssessmentMechanismSelected(
HashMap<AssessmentMechanism, Boolean> assessmentMechanismSelected) {
AssessmentMechanism assessmentMechanismSelected) {
this.assessmentMechanismSelected = assessmentMechanismSelected;
}
......
package unipotsdam.gf.modules.project;
import unipotsdam.gf.modules.annotation.model.Category;
import unipotsdam.gf.modules.assessment.AssessmentMechanism;
import unipotsdam.gf.modules.group.GroupFormationMechanism;
import unipotsdam.gf.mysql.MysqlConnect;
import unipotsdam.gf.mysql.VereinfachtesResultSet;
import unipotsdam.gf.process.phases.Phase;
import unipotsdam.gf.modules.assessment.AssessmentMechanism;
import unipotsdam.gf.modules.group.GroupFormationMechanism;
import unipotsdam.gf.modules.annotation.model.Category;
import javax.inject.Inject;
import java.util.HashMap;
......@@ -31,7 +31,7 @@ public class ProjectConfigurationDAO {
String projectName = project.getName();
String categoryName = category.name();
String mysqlRequest = "insert INTO categoriesSelected (`projectName`,`categorySelected`) VALUES (?,?)";
connect.issueInsertOrDeleteStatement(mysqlRequest, projectName, categoryName );
connect.issueInsertOrDeleteStatement(mysqlRequest, projectName, categoryName);
}
}
......@@ -46,27 +46,24 @@ public class ProjectConfigurationDAO {
}
// persist GroupFinding
GroupFormationMechanism groupFindingMechanism =
GroupFormationMechanism groupFindingMechanism =
projectConfiguration.getGroupMechanismSelected();
if (groupFindingMechanism != null) {
String mysqlRequest =
"insert INTO groupfindingMechanismSelected (`projectName`,`gfmSelected`) VALUES (?,?)";
connect.issueInsertOrDeleteStatement(mysqlRequest, project.getName(), groupFindingMechanism.name());
}
if (groupFindingMechanism != null) {
String mysqlRequest =
"insert INTO groupfindingMechanismSelected (`projectName`,`gfmSelected`) VALUES (?,?)";
connect.issueInsertOrDeleteStatement(mysqlRequest, project.getName(), groupFindingMechanism.name());
}
// persist assessmentMechanismSelected
HashMap<AssessmentMechanism, Boolean> assessmentMechanismsSelected =
AssessmentMechanism assessmentMechanismsSelected =
projectConfiguration.getAssessmentMechanismSelected();
for (AssessmentMechanism assessmentMechanism : assessmentMechanismsSelected.keySet()) {
Boolean asmSelected = assessmentMechanismsSelected.get(assessmentMechanism);
if (asmSelected != null && asmSelected) {
String mysqlRequest =
"insert INTO assessmentMechanismSelected (`projectName`,`amSelected`) VALUES (?,?)";
connect.issueInsertOrDeleteStatement(mysqlRequest, project.getName(), assessmentMechanism.name());
}
if (assessmentMechanismsSelected != null) {
String mysqlRequest =
"insert INTO assessmentMechanismSelected (`projectName`,`amSelected`) VALUES (?,?)";
connect.issueInsertOrDeleteStatement(mysqlRequest, project.getName(), assessmentMechanismsSelected.name());
}
connect.close();
}
......@@ -80,16 +77,15 @@ public class ProjectConfigurationDAO {
HashMap<Category, Boolean> categorySelected =
getSelectionFromTable(connect, Category.class, project, "categoriesSelected");
HashMap<AssessmentMechanism, Boolean> asmSelected =
getSelectionFromTable(connect, AssessmentMechanism.class, project, "assessmentMechanismSelected");
AssessmentMechanism asmSelected = AssessmentMechanism.PEER_ASSESSMENT;
HashMap<AssessmentMechanism, Boolean> aMBHM = getSelectionFromTable(connect, AssessmentMechanism.class, project, "assessmentMechanismSelected");
for (AssessmentMechanism am : aMBHM.keySet()){
asmSelected =am;
}
HashMap<GroupFormationMechanism, Boolean> groupfindingMechanismSelected =
getSelectionFromTable(connect, GroupFormationMechanism.class, project, "groupfindingMechanismSelected");
GroupFormationMechanism gfmSelected = null;
for (GroupFormationMechanism groupFormationMechanism : groupfindingMechanismSelected.keySet()) {
......@@ -100,7 +96,7 @@ public class ProjectConfigurationDAO {
connect.close();
ProjectConfiguration projectConfiguration = new ProjectConfiguration(projectPhasesSelected, categorySelected,
asmSelected,gfmSelected);
asmSelected, gfmSelected);
return projectConfiguration;
}
......@@ -124,7 +120,7 @@ public class ProjectConfigurationDAO {
VereinfachtesResultSet vereinfachtesResultSet = connect.issueSelectStatement(mysqlRequest, id);
HashMap<T, Boolean> projectPhaseBoolean = new HashMap<>();
while (!vereinfachtesResultSet.isLast()) {
Boolean next = vereinfachtesResultSet.next();
boolean next = vereinfachtesResultSet.next();
if (next) {
String phaseSelected = vereinfachtesResultSet.getObject(2).toString();
T phaseSelected1 = Enum.valueOf(selectionclass, phaseSelected);
......
......@@ -50,8 +50,6 @@ public class ProjectView {
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.TEXT_PLAIN)
@Path("/delete/project/{projectName}")
public void deleteProject(@Context HttpServletRequest req, @PathParam("projectName") String projectName) throws URISyntaxException, IOException {
String userEmail1 = gfContexts.getUserEmail(req);
......
package unipotsdam.gf.process;
import unipotsdam.gf.interfaces.IPhases;
import unipotsdam.gf.modules.annotation.model.Category;
import unipotsdam.gf.modules.assessment.AssessmentMechanism;
import unipotsdam.gf.modules.group.GroupDAO;
import unipotsdam.gf.modules.group.GroupFormationMechanism;
import unipotsdam.gf.modules.group.GroupfindingCriteria;
import unipotsdam.gf.modules.project.Management;
import unipotsdam.gf.modules.project.Project;
import unipotsdam.gf.modules.project.ProjectConfiguration;
import unipotsdam.gf.modules.user.User;
import unipotsdam.gf.process.constraints.ConstraintsImpl;
import unipotsdam.gf.process.phases.Phase;
......@@ -17,6 +21,11 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.WebApplicationException;
import java.io.IOException;
import java.util.HashMap;
import static unipotsdam.gf.modules.assessment.AssessmentMechanism.PEER_ASSESSMENT;
import static unipotsdam.gf.modules.group.GroupFormationMechanism.SingleUser;
import static unipotsdam.gf.process.phases.Phase.CourseCreation;
@Singleton
......@@ -51,6 +60,16 @@ public class ProjectCreationProcess {
throw new WebApplicationException("Project already exists");
}
taskDao.createTaskWaitForParticipants(project, author);
HashMap<Phase, Boolean> phase = new HashMap<>();
phase.put(project.getPhase(), true);
HashMap<Category, Boolean> category = new HashMap<>();
category.put(Category.TITEL, true);
ProjectConfiguration projectConfiguration = new ProjectConfiguration(
phase,
category,
AssessmentMechanism.PEER_ASSESSMENT, //todo: its just a default by now. correct this
GroupFormationMechanism.SingleUser); //todo: its just a default by now. fix it
iManagement.create(projectConfiguration, project);
}
/**
......@@ -72,7 +91,7 @@ public class ProjectCreationProcess {
Boolean groupsCanBeFormed = constraintsImpl.checkIfGroupsCanBeFormed(project);
if (groupsCanBeFormed) {
GroupFormationMechanism groupFormationMechanism = groupDAO.getGroupFormationMechanism(project);
if (!groupFormationMechanism.equals(GroupFormationMechanism.SingleUser) && !groupFormationMechanism
if (!groupFormationMechanism.equals(SingleUser) && !groupFormationMechanism
.equals(GroupFormationMechanism.Manual)) {
taskDao.persistTeacherTask(project, TaskName.EDIT_FORMED_GROUPS, Phase.GroupFormation);
} else {
......
......@@ -58,9 +58,6 @@
<p> Passwort zum Teilnehmen (optional) </p>
<div class="form-group"><input class="form-control" name="password" placeholder="Passwort"
style="width:287px;margin-left:51px;" id="passwordProject"></div>
<p> Passwort zum Löschen (sonst: 1234) </p>
<div class="form-group"><input class="form-control" name="adminpassword" placeholder="Passwort"
style="width:287px;margin-left:51px;" id="adminPassword"></div>
<p>Gruppenarbeitseinstellungen</p>
<input type="radio" id="lg" name="gfm" value="Basierend auf Lernzielen">
<label for="lg">Basierend auf Lernzielen</label>
......
......@@ -22,38 +22,16 @@
<body>
<div class="loader-inactive" id="loader"></div>
<menu:menu hierarchy="1"/>
<div class="page-content-wrapper">
<div class="container-fluid"><a class="btn btn-link" role="button" href="#menu-toggle" id="menu-toggle"></a>
<div class="row">
<div class="col-md-12">
<h3>Projekt löschen! </h3>
<div class="page-header"></div>
</div>
</div>
</div>
</div>
<fieldset>
<legend style="margin-left:13px;">Projektnamen</legend>
<input class="form-control" type="text" id="projectName" name="Project" required=""
placeholder="Projekt1" autofocus=""
style="max-width:417px;margin-left:14px;padding-top:10px;margin-top:2px;margin-bottom:13px;">
<div class="alert alert-warning" role="alert" id="projectIsMissing">
Dieser Projektname existiert nicht oder das Passwort ist falsch.
</div>
</fieldset>
<fieldset>
<legend style="margin-left:13px;">Passwort zum löschen</legend>
<input class="form-control" type="password" id="projectPassword" name="Password" required=""
placeholder="******"
style="max-width:417px;margin-left:14px;padding-top:10px;margin-top:2px;margin-bottom:13px;">
<div class="alert alert-warning" role="alert" id="projectWrongPassword">
Falsches Passwort.
</div>
</fieldset>
<button id="deleteProject" class="btn btn-danger">löschen</button>
<footer:footer/>
<headLine:headLine/>
<legend style="margin-left:13px;">Projektnamen</legend>
<input class="form-control" type="text" id="projectName" name="Project" required
placeholder="Projekt1" autofocus
style="max-width:417px;margin-left:14px;padding-top:10px;margin-top:2px;margin-bottom:13px;">
<div class="alert alert-warning" role="alert" id="projectIsMissing">
Dieser Projektname existiert nicht
</div>
<button id="deleteProject" class="btn btn-danger">löschen</button>
<footer:footer/>
</body>
</html>
\ No newline at end of file
......@@ -85,10 +85,6 @@ function initSendButton(allTheTags) {
function getProjectValues() {
projectName = $("#nameProject").val().trim();
let password = $("#passwordProject").val().trim();
let adminPassword = $("#adminPassword").val().trim();
if (adminPassword === "") {
adminPassword = "1234";
}
//allTheTags = $("#tagsProject").tagsInput('items');
//allTheTags = $("#tagsProject").val();
let reguexp = /^[a-zA-Z0-9äüöÄÜÖ\ ]+$/;
......@@ -113,7 +109,6 @@ function getProjectValues() {
"active" : true,
"timecreated" : time,
"authorEmail": $('#userEmail').text().trim(),
"adminPassword": adminPassword,
"phase" : "CourseCreation",
"tags": allTheTags
};
......@@ -124,7 +119,6 @@ function getProjectValues() {
"active" : true,
"timecreated" : 356122661234038,
"authorEmail" : "7DoIYf4tWV",
"adminPassword" : "bJFmgTGMdY",
"phase" : "Execution",
"tags" : [ "JjwWui3r2a", "J23BLwqlXa", "NOVk1tcaN0", "RTXTACSHLx", "BbMtdrXPi2" ]
};
......
......@@ -6,52 +6,45 @@ $(document).ready(function () {
$("#projectIsMissing").hide();
$("#deleteProject").on('click', function () {
deleteProject($('#projectName').val().trim());
let projectName = $('#projectName').text().trim();
deleteProject(projectName);
});
});
function deleteProject(projectName) {
let localurl = "../rest/project/delete/project/";
let localurl = "../rest/project/delete/project/" + projectName;
if (projectName === "") {
return false;
} else {
$.ajax({
url: localurl,
data: "",
projectName: projectName,
Accept: "text/plain; charset=utf-8",
contentType: "text/plain",
type: 'POST',
success: function (response) {
if (response === "project missing") {
$("#projectIsMissing").show();
} else {
if (response !== "wrong password") { //if response !== project missing and not wrong password, its the projectName
$.ajax({
url: compbaseUrl + "/api1/courses/" + projectName,
Accept: "text/plain; charset=utf-8",
type: 'DELETE',
contentType: "text/plain",
async: false,
success: function (response) {
$.ajax({
url: compbaseUrl + "/api1/courses/" + projectName,
Accept: "text/plain; charset=utf-8",
type: 'DELETE',
contentType: "text/plain",
async: false,
success: function (response) {
},
error: function (a, b, c) {
console.log(a);
}
});
window.location.href = " ../pages/projects.php" + getUserEmail();
} else {
$("#projectIsMissing").hide();
$('#projectWrongPassword').show();
}
},
error: function (a, b, c) {
console.log(a);
}
});
window.location.href = " ../projects/overview-docent.jsp";
}
},
error: function (a, b, c) {
console.log(a);
}
});
}
}
......@@ -19,7 +19,11 @@ function fillTasks(projectName, userEmail){
let object = fillObjectWithTasks(response);
for (let task in object){
let tmplObject = fitObjectInTmpl(object[task]);
$('#taskTemplate').tmpl(tmplObject).appendTo('#listOfTasks');
if (tmplObject.taskProgress === "FINISHED"){
$('#finishedTaskTemplate').tmpl(tmplObject).appendTo('#listOfTasks');
}else{
$('#taskTemplate').tmpl(tmplObject).appendTo('#listOfTasks');
}
}
},
error: function(a){}
......
......@@ -14,39 +14,37 @@
</head>
<body>
<menu:menu hierarchy="1"/>
<headLine:headLine/>
<headLine:headLine/>
<div id="listOfTasks">
</div>
<script id="taskTemplate" type="text/x-jQuery-tmpl">
{{if taskProgress === "FINISHED"}}
<div class="card-finished"><h4 class="icon closed">${infoText}</h4>
{{html timeFrame}}
</div>
{{else}}
<div class="card ${phase}">
<div class="col span_s_of_2 icon ${taskType}">
</div>
<div class="col span_l_of_2" id="${taskName}">
{{if infoText}}
<h4>${infoText}</h4>
{{/if}}
{{if solveTaskWith}}
<button class='primary' onClick='${solveTaskWithLink}'>${solveTaskWith}</button>
{{/if}}
{{if helpLink}}
<div style="width:100%"><a href='${helpLink}'>Hier</a> bekommst du Hilfe.</div>
{{/if}}
</div>
{{if timeFrame}}
{{html timeFrame}}
{{/if}}
<div style="clear:left"></div>
</div>
</div>
{{/if}}
<div class="card ${phase}">
<div class="col span_s_of_2 icon ${taskType}">
</div>
<div class="col span_l_of_2" id="${taskName}">
{{if infoText}}
<h4>${infoText}</h4>
{{/if}}
{{if solveTaskWith}}
<button class='primary' onClick='${solveTaskWithLink}'>${solveTaskWith}</button>
{{/if}}
{{if helpLink}}
<div style="width:100%"><a href='${helpLink}'>Hier</a> bekommst du Hilfe.</div>
{{/if}}
</div>
{{if timeFrame}}
{{html timeFrame}}
{{/if}}
<div style="clear:left"></div>
</div>
</div>
</script>
<script id="finishedTaskTemplate" type="text/x-jQuery-tmpl">
<div class="card-finished"><h4 class="icon closed">${infoText}</h4>
{{html timeFrame}}
</div>
</script>
<footer:footer/>
</body>
......
......@@ -287,7 +287,7 @@ ALTER TABLE `projects`
ALTER TABLE `projectuser`
ADD CONSTRAINT `projectuser_ibfk_1` FOREIGN KEY (`userEmail`) REFERENCES `users` (`email`),
ADD CONSTRAINT `projectuser_ibfk_2` FOREIGN KEY (`projectName`) REFERENCES `projects` (`name`);
ADD CONSTRAINT `projectuser_ibfk_2` FOREIGN KEY (`projectName`) REFERENCES `projects` (`name`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `quiz`
ADD CONSTRAINT `quiz_projects_name_fk` FOREIGN KEY (`projectName`) REFERENCES `projects` (`name`) ON DELETE CASCADE ON UPDATE CASCADE;
......
INSERT IGNORE INTO projects (name, password, active, timecreated, author, adminPassword, phase) VALUES ("test1", "", 1,
current_timestamp, "vodka@yolo.com", "", "GroupFormation" );
INSERT IGNORE INTO projects (name, password, active, timecreated, author, phase) VALUES ("test1", "", 1,
current_timestamp, "vodka@yolo.com", "GroupFormation" );
INSERT IGNORE INTO projects (name, password, active, timecreated, author, adminPassword, phase) VALUES ("test2", "", 1,
current_timestamp, "vodka@yolo.com", "", "GroupFormation" );
INSERT IGNORE INTO projects (name, password, active, timecreated, author, phase) VALUES ("test2", "", 1,
current_timestamp, "vodka@yolo.com", "GroupFormation" );
insert IGNORE into projectuser (projectName, userEmail) VALUES ("test1", "vodkas@yolo.com");
insert IGNORE into projectuser (projectName, userEmail) VALUES ("test1", "vodkass@yolo.com");
......
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