diff --git a/src/main/java/org/olat/course/nodes/gta/GTAManager.java b/src/main/java/org/olat/course/nodes/gta/GTAManager.java index 0499a8f79fd9f8c63b5e1e6ad4a3e6f8cbda6484..0140879b7c4ff4ed11ff0e03dd7aafa29f15941c 100644 --- a/src/main/java/org/olat/course/nodes/gta/GTAManager.java +++ b/src/main/java/org/olat/course/nodes/gta/GTAManager.java @@ -271,6 +271,8 @@ public interface GTAManager { public List<Task> getTasks(TaskList taskList, GTACourseNode gtaNode); + public List<Task> getTasks(IdentityRef identity); + public List<TaskLight> getTasksLight(RepositoryEntryRef entry, GTACourseNode gtaNode); public List<TaskRevisionDate> getTaskRevisions(Task task); diff --git a/src/main/java/org/olat/course/nodes/gta/manager/GTAManagerImpl.java b/src/main/java/org/olat/course/nodes/gta/manager/GTAManagerImpl.java index c0150d07c9a2cbfb46491ee9aea7e60bcb9191e0..f871cb355a65bac4aec6a8bf4076eceb0381e7e1 100644 --- a/src/main/java/org/olat/course/nodes/gta/manager/GTAManagerImpl.java +++ b/src/main/java/org/olat/course/nodes/gta/manager/GTAManagerImpl.java @@ -90,7 +90,6 @@ import org.olat.course.run.userview.UserCourseEnvironment; import org.olat.group.BusinessGroup; import org.olat.group.BusinessGroupRef; import org.olat.group.BusinessGroupService; -import org.olat.group.DeletableGroupData; import org.olat.group.area.BGAreaManager; import org.olat.group.manager.BusinessGroupRelationDAO; import org.olat.group.model.BusinessGroupRefImpl; @@ -117,7 +116,7 @@ import com.thoughtworks.xstream.XStream; * */ @Service -public class GTAManagerImpl implements GTAManager, DeletableGroupData { +public class GTAManagerImpl implements GTAManager { private static final OLog log = Tracing.createLoggerFor(GTAManagerImpl.class); @@ -735,17 +734,6 @@ public class GTAManagerImpl implements GTAManager, DeletableGroupData { return tasks.isEmpty() ? null : tasks.get(0); } - - @Override - public boolean deleteGroupDataFor(BusinessGroup group) { - log.audit("Delete tasks of business group: " + group.getKey()); - String deleteTasks = "delete from gtatask as task where task.businessGroup.key=:groupKey"; - dbInstance.getCurrentEntityManager() - .createQuery(deleteTasks) - .setParameter("groupKey", group.getKey()) - .executeUpdate(); - return true; - } @Override public int deleteTaskList(RepositoryEntryRef entry, GTACourseNode cNode) { @@ -813,6 +801,19 @@ public class GTAManagerImpl implements GTAManager, DeletableGroupData { .setParameter("taskListKey", taskList.getKey()) .getResultList(); } + + @Override + public List<Task> getTasks(IdentityRef identity) { + StringBuilder sb = new StringBuilder(); + sb.append("select task from gtatask task") + .append(" inner join task.taskList as tasklist") + .append(" inner join tasklist.entry as entry") + .append(" where task.identity.key=:identityKey"); + return dbInstance.getCurrentEntityManager() + .createQuery(sb.toString(), Task.class) + .setParameter("identityKey", identity.getKey()) + .getResultList(); + } @Override public List<TaskLight> getTasksLight(RepositoryEntryRef entry, GTACourseNode gtaNode) { diff --git a/src/main/java/org/olat/course/nodes/gta/manager/GTAUserDataManager.java b/src/main/java/org/olat/course/nodes/gta/manager/GTAUserDataManager.java new file mode 100644 index 0000000000000000000000000000000000000000..9c5d1962622009499d30c9bfe540907d41ff3771 --- /dev/null +++ b/src/main/java/org/olat/course/nodes/gta/manager/GTAUserDataManager.java @@ -0,0 +1,140 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<br> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * frentix GmbH, http://www.frentix.com + * <p> + */ +package org.olat.course.nodes.gta.manager; + +import java.io.File; +import java.util.List; +import java.util.Locale; + +import org.olat.core.commons.persistence.DB; +import org.olat.core.id.Identity; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; +import org.olat.core.util.FileUtils; +import org.olat.core.util.StringHelper; +import org.olat.core.util.io.SystemFileFilter; +import org.olat.course.CorruptedCourseException; +import org.olat.course.CourseFactory; +import org.olat.course.ICourse; +import org.olat.course.nodes.CourseNode; +import org.olat.course.nodes.GTACourseNode; +import org.olat.course.nodes.gta.GTAManager; +import org.olat.course.nodes.gta.Task; +import org.olat.course.nodes.gta.TaskList; +import org.olat.group.BusinessGroup; +import org.olat.group.DeletableGroupData; +import org.olat.modules.ModuleConfiguration; +import org.olat.user.UserDataExportable; +import org.olat.user.manager.ManifestBuilder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * + * Initial date: 28 mai 2018<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +@Service +public class GTAUserDataManager implements DeletableGroupData, UserDataExportable { + + private static final OLog log = Tracing.createLoggerFor(GTAUserDataManager.class); + + @Autowired + private DB dbInstance; + @Autowired + private GTAManager gtaManager; + + @Override + public boolean deleteGroupDataFor(BusinessGroup group) { + log.audit("Delete tasks of business group: " + group.getKey()); + String deleteTasks = "delete from gtatask as task where task.businessGroup.key=:groupKey"; + dbInstance.getCurrentEntityManager() + .createQuery(deleteTasks) + .setParameter("groupKey", group.getKey()) + .executeUpdate(); + return true; + } + + + @Override + public String getExporterID() { + return "gta"; + } + + @Override + public void export(Identity identity, ManifestBuilder manifest, File archiveDirectory, Locale locale) { + File tasksArchiveDir = new File(archiveDirectory, "Tasks"); + tasksArchiveDir.mkdir(); + + List<Task> tasks = gtaManager.getTasks(identity); + for(Task task:tasks) { + try { + TaskList taskList = task.getTaskList(); + ICourse course = CourseFactory.loadCourse(taskList.getEntry()); + if(course == null) continue; + + CourseNode node = course.getRunStructure().getNode(taskList.getCourseNodeIdent()); + if(node instanceof GTACourseNode) { + String archiveName = node.getIdent() + "_" + StringHelper.transformDisplayNameToFileSystemName(node.getShortName()); + File taskArchiveDir = new File(tasksArchiveDir, archiveName); + exportTask(identity, task, (GTACourseNode)node, course, taskArchiveDir); + } + } catch (CorruptedCourseException e) { + log.warn("", e); + } + } + } + + private void exportTask(Identity assessedIdentity, Task task, GTACourseNode node , ICourse course, File taskArchiveDir) { + int flow = 0;//for beautiful ordering + ModuleConfiguration config = node.getModuleConfiguration(); + if(config.getBooleanSafe(GTACourseNode.GTASK_SUBMIT)) { + File submitDirectory = gtaManager.getSubmitDirectory(course.getCourseEnvironment(), node, assessedIdentity); + String submissionDirName = (++flow) + "_submissions"; + copyDirContentToDir(submitDirectory, new File(taskArchiveDir, submissionDirName)); + } + + if(config.getBooleanSafe(GTACourseNode.GTASK_REVIEW_AND_CORRECTION)) { + File correctionsDir = gtaManager.getCorrectionDirectory(course.getCourseEnvironment(), node, assessedIdentity); + String correctionDirName = (++flow) + "_corrections"; + copyDirContentToDir(correctionsDir, new File(taskArchiveDir, correctionDirName)); + } + + if(task != null && config.getBooleanSafe(GTACourseNode.GTASK_REVISION_PERIOD)) { + int numOfIteration = task.getRevisionLoop(); + for(int i=1; i<=numOfIteration; i++) { + File revisionDirectory = gtaManager.getRevisedDocumentsDirectory(course.getCourseEnvironment(), node, i, assessedIdentity); + String revisionDirName = (++flow) + "_revisions_" + i; + copyDirContentToDir(revisionDirectory, new File(taskArchiveDir, revisionDirName)); + } + } + } + + private void copyDirContentToDir(File source, File target) { + File[] sourceFiles = source.listFiles(new SystemFileFilter(true, true)); + if(sourceFiles != null && sourceFiles.length > 0) { + target.mkdirs(); + for(File sourceFile:sourceFiles) { + FileUtils.copyFileToDir(sourceFile, target, ""); + } + } + } +} diff --git a/src/main/java/org/olat/modules/webFeed/manager/FeedUserDataManager.java b/src/main/java/org/olat/modules/webFeed/manager/FeedUserDataManager.java index 598c1e0ea6b50c2dea6d0780cba00f5062da6ecd..b627ee785f29525c6cdf88c6a7c74daa8f861799 100644 --- a/src/main/java/org/olat/modules/webFeed/manager/FeedUserDataManager.java +++ b/src/main/java/org/olat/modules/webFeed/manager/FeedUserDataManager.java @@ -1,3 +1,22 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<br> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * frentix GmbH, http://www.frentix.com + * <p> + */ package org.olat.modules.webFeed.manager; import java.io.File; diff --git a/src/main/java/org/olat/user/manager/UserDataExportTask.java b/src/main/java/org/olat/user/manager/UserDataExportTask.java index e72860883080806ca778beff7c017a323b62ea83..0bdc9e8e4490b9042fdf6614baebf9ca56e668e4 100644 --- a/src/main/java/org/olat/user/manager/UserDataExportTask.java +++ b/src/main/java/org/olat/user/manager/UserDataExportTask.java @@ -20,7 +20,6 @@ package org.olat.user.manager; import org.olat.core.CoreSpringFactory; -import org.olat.core.commons.services.taskexecutor.LongRunnable; import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; import org.olat.user.UserDataExportService; @@ -31,7 +30,7 @@ import org.olat.user.UserDataExportService; * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com * */ -public class UserDataExportTask implements LongRunnable { +public class UserDataExportTask implements /* Long */ Runnable { private static final long serialVersionUID = 6931074116105090545L; diff --git a/src/main/java/org/olat/user/ui/data/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/user/ui/data/_i18n/LocalStrings_de.properties index e0412f1a76af6e5dfce47709800ed505d1f40773..51e10dce60fc10fc4e6488d3d4de85b1be06a844 100644 --- a/src/main/java/org/olat/user/ui/data/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/user/ui/data/_i18n/LocalStrings_de.properties @@ -22,6 +22,7 @@ export.user.data.ready.text=<p>Export von "{0}" ist fertig. Es konnte unter <a h feeds=Blogs und Podcasts forums=Foren group.memberships=Zugeh\u00F6rigkeit zu Gruppen +gta=Aufgabe mail=Mail notes=Pers\u00F6nliche Notizen notifications=Abonnements diff --git a/src/main/java/org/olat/user/ui/data/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/user/ui/data/_i18n/LocalStrings_en.properties index 120edd31867f4128c3edfc8b77721fc1a01d6a67..98ff1e6bc0329cc39eebd5053d5c2bbdb4876484 100644 --- a/src/main/java/org/olat/user/ui/data/_i18n/LocalStrings_en.properties +++ b/src/main/java/org/olat/user/ui/data/_i18n/LocalStrings_en.properties @@ -8,8 +8,6 @@ comments.ratings=Comments and ratings disclaimer=Disclaimer display.portrait=Published image download.data=Download the data -dx=dr -dy=dr efficiency.statements=Evidences of achievement export.options=Export elements export.start=Start export @@ -17,8 +15,10 @@ export.url=Link to the data feeds=Blogs and podcasts forums=Forums group.memberships=Membership to groups +gta=Tasks mail=Emails notes=Notes notifications=Subscriptions personal.folders=All documents in private and public folders repository.memberships=Membership to courses +