use of org.olat.course.nodes.gta.GTAManager in project openolat by klemens.
the class GroupBulkDownloadResource method prepare.
@Override
public void prepare(HttpServletResponse hres) {
try {
hres.setCharacterEncoding(encoding);
} catch (Exception e) {
log.error("", e);
}
String label = StringHelper.transformDisplayNameToFileSystemName(courseNode.getShortName()) + "_" + Formatter.formatDatetimeWithMinutes(new Date()) + ".zip";
String urlEncodedLabel = StringHelper.urlEncodeUTF8(label);
hres.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + urlEncodedLabel);
hres.setHeader("Content-Description", urlEncodedLabel);
try (ZipOutputStream zout = new ZipOutputStream(hres.getOutputStream())) {
zout.setLevel(9);
ICourse course = CourseFactory.loadCourse(courseOres);
GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
if (courseNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_GRADING)) {
List<Identity> assessableIdentities = CoreSpringFactory.getImpl(BusinessGroupService.class).getMembers(groups, GroupRoles.participant.name());
String courseTitle = course.getCourseTitle();
String fileName = ExportUtil.createFileNameWithTimeStamp(courseTitle, "xlsx");
List<AssessableCourseNode> nodes = Collections.<AssessableCourseNode>singletonList(courseNode);
try (OutputStream out = new ShieldOutputStream(zout)) {
zout.putNextEntry(new ZipEntry(fileName));
ScoreAccountingHelper.createCourseResultsOverviewXMLTable(assessableIdentities, nodes, course, locale, out);
zout.closeEntry();
} catch (Exception e) {
log.error("", e);
}
}
TaskList taskList = gtaManager.getTaskList(course.getCourseEnvironment().getCourseGroupManager().getCourseEntry(), courseNode);
for (BusinessGroup businessGroup : groups) {
courseNode.archiveNodeData(course, businessGroup, taskList, "", zout);
}
} catch (Exception e) {
log.error("", e);
}
}
use of org.olat.course.nodes.gta.GTAManager in project OpenOLAT by OpenOLAT.
the class BulkAssessmentTask method getReturnBox.
/**
* Return the target folder of the assessed identity. This is a factory method which take care
* of the type of the course node.
*
* @param uce
* @param courseNode
* @param identity
* @return
*/
private VFSContainer getReturnBox(UserCourseEnvironment uce, CourseNode courseNode, Identity identity) {
VFSContainer returnContainer = null;
if (courseNode instanceof GTACourseNode) {
final GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
CourseEnvironment courseEnv = uce.getCourseEnvironment();
returnContainer = gtaManager.getCorrectionContainer(courseEnv, (GTACourseNode) courseNode, identity);
} else {
String returnPath = ReturnboxController.getReturnboxPathRelToFolderRoot(uce.getCourseEnvironment(), courseNode);
OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(returnPath, null);
VFSItem assessedItem = rootFolder.resolve(identity.getName());
if (assessedItem == null) {
returnContainer = rootFolder.createChildContainer(identity.getName());
} else if (assessedItem instanceof VFSContainer) {
returnContainer = (VFSContainer) assessedItem;
}
}
return returnContainer;
}
use of org.olat.course.nodes.gta.GTAManager in project OpenOLAT by OpenOLAT.
the class GTACourseNode method exportNode.
/**
* The files are exported in export/{node ident}/tasks and export/{node ident}/solutions
*/
@Override
public void exportNode(File fExportDirectory, ICourse course) {
File fNodeExportDir = new File(fExportDirectory, getIdent());
GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
// export the tasks
File tasksExportDir = new File(fNodeExportDir, "tasks");
File taskDirectory = gtaManager.getTasksDirectory(course.getCourseEnvironment(), this);
fNodeExportDir.mkdirs();
FileUtils.copyDirContentsToDir(taskDirectory, tasksExportDir, false, "export task course node");
File taskDefinitions = new File(taskDirectory.getParentFile(), GTAManager.TASKS_DEFINITIONS);
if (taskDefinitions.exists()) {
File copyTaskDefinitions = new File(tasksExportDir.getParentFile(), GTAManager.TASKS_DEFINITIONS);
FileUtils.copyFileToFile(taskDefinitions, copyTaskDefinitions, false);
}
// export the solutions
File fSolExportDir = new File(fNodeExportDir, "solutions");
File solutionsDirectory = gtaManager.getSolutionsDirectory(course.getCourseEnvironment(), this);
fSolExportDir.mkdirs();
FileUtils.copyDirContentsToDir(solutionsDirectory, fSolExportDir, false, "export task course node solutions");
File solutionDefinitions = new File(solutionsDirectory.getParentFile(), GTAManager.SOLUTIONS_DEFINITIONS);
if (solutionDefinitions.exists()) {
File copySolutionDefinitions = new File(fSolExportDir.getParentFile(), GTAManager.SOLUTIONS_DEFINITIONS);
FileUtils.copyFileToFile(solutionDefinitions, copySolutionDefinitions, false);
}
}
use of org.olat.course.nodes.gta.GTAManager in project OpenOLAT by OpenOLAT.
the class GTACourseNode method cleanupOnDelete.
@Override
public void cleanupOnDelete(ICourse course) {
super.cleanupOnDelete(course);
GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
// tasks
File taskDirectory = gtaManager.getTasksDirectory(course.getCourseEnvironment(), this);
FileUtils.deleteDirsAndFiles(taskDirectory, true, true);
// solutions
File solutionsDirectory = gtaManager.getSolutionsDirectory(course.getCourseEnvironment(), this);
FileUtils.deleteDirsAndFiles(solutionsDirectory, true, true);
// clean up database
RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
gtaManager.deleteTaskList(entry, this);
// clean subscription
SubscriptionContext subscriptionContext = gtaManager.getSubscriptionContext(course.getCourseEnvironment(), this);
NotificationsManager.getInstance().delete(subscriptionContext);
}
use of org.olat.course.nodes.gta.GTAManager in project OpenOLAT by OpenOLAT.
the class GTACourseNode method archiveNodeData.
public void archiveNodeData(ICourse course, BusinessGroup businessGroup, TaskList taskList, String dirName, ZipOutputStream exportStream) {
ModuleConfiguration config = getModuleConfiguration();
GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
// for beautiful ordering
int flow = 0;
String groupDirName = dirName + "/" + StringHelper.transformDisplayNameToFileSystemName(businessGroup.getName()) + "_" + businessGroup.getKey();
Task task = gtaManager.getTask(businessGroup, taskList);
if (task != null && task.getTaskName() != null && config.getBooleanSafe(GTASK_ASSIGNMENT)) {
File taskDirectory = gtaManager.getTasksDirectory(course.getCourseEnvironment(), this);
File taskFile = new File(taskDirectory, task.getTaskName());
if (taskFile.exists()) {
String path = groupDirName + "/" + (++flow) + "_task/" + taskFile.getName();
ZipUtil.addFileToZip(path, taskFile, exportStream);
}
}
if (config.getBooleanSafe(GTASK_SUBMIT)) {
File submitDirectory = gtaManager.getSubmitDirectory(course.getCourseEnvironment(), this, businessGroup);
String submissionDirName = groupDirName + "/" + (++flow) + "_submissions";
ZipUtil.addDirectoryToZip(submitDirectory.toPath(), submissionDirName, exportStream);
}
if (config.getBooleanSafe(GTACourseNode.GTASK_REVIEW_AND_CORRECTION)) {
File correctionsDir = gtaManager.getCorrectionDirectory(course.getCourseEnvironment(), this, businessGroup);
String correctionDirName = groupDirName + "/" + (++flow) + "_corrections";
ZipUtil.addDirectoryToZip(correctionsDir.toPath(), correctionDirName, exportStream);
}
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(), this, i, businessGroup);
String revisionDirName = groupDirName + "/" + (++flow) + "_revisions_" + i;
ZipUtil.addDirectoryToZip(revisionDirectory.toPath(), revisionDirName, exportStream);
File correctionDirectory = gtaManager.getRevisedDocumentsCorrectionsDirectory(course.getCourseEnvironment(), this, i, businessGroup);
String correctionDirName = groupDirName + "/" + (++flow) + "_corrections_" + i;
ZipUtil.addDirectoryToZip(correctionDirectory.toPath(), correctionDirName, exportStream);
}
}
// assessment documents for all participants of the group
if (config.getBooleanSafe(MSCourseNode.CONFIG_KEY_HAS_INDIVIDUAL_ASSESSMENT_DOCS, false)) {
List<Identity> assessedIdentities = CoreSpringFactory.getImpl(BusinessGroupService.class).getMembers(businessGroup, GroupRoles.participant.name());
String assessmentDirName = groupDirName + "/" + (++flow) + "_assessment";
for (Identity assessedIdentity : assessedIdentities) {
List<File> assessmentDocuments = course.getCourseEnvironment().getAssessmentManager().getIndividualAssessmentDocuments(this, assessedIdentity);
if (assessmentDocuments != null && !assessmentDocuments.isEmpty()) {
String name = assessedIdentity.getUser().getLastName() + "_" + assessedIdentity.getUser().getFirstName() + "_" + assessedIdentity.getName();
String userDirName = assessmentDirName + "/" + StringHelper.transformDisplayNameToFileSystemName(name);
for (File document : assessmentDocuments) {
String path = userDirName + "/" + document.getName();
ZipUtil.addFileToZip(path, document, exportStream);
}
}
}
}
}
Aggregations