use of org.olat.course.nodes.gta.GTAManager in project OpenOLAT by OpenOLAT.
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 GTACourseNode method postCopy.
@Override
public void postCopy(CourseEnvironmentMapper envMapper, Processing processType, ICourse course, ICourse sourceCourse) {
super.postCopy(envMapper, processType, course, sourceCourse);
// change groups and areas mapping
postImportCopy(envMapper);
GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
// copy tasks
File sourceTaskDirectory = gtaManager.getTasksDirectory(sourceCourse.getCourseEnvironment(), this);
File copyTaskDirectory = gtaManager.getTasksDirectory(course.getCourseEnvironment(), this);
FileUtils.copyDirContentsToDir(sourceTaskDirectory, copyTaskDirectory, false, "copy task course node");
File taskDefinitions = new File(sourceTaskDirectory.getParentFile(), GTAManager.TASKS_DEFINITIONS);
if (taskDefinitions.exists()) {
File copyTaskDefinitions = new File(copyTaskDirectory.getParentFile(), GTAManager.TASKS_DEFINITIONS);
FileUtils.copyFileToFile(taskDefinitions, copyTaskDefinitions, false);
}
// copy solutions
File sourceSolutionsDirectory = gtaManager.getSolutionsDirectory(sourceCourse.getCourseEnvironment(), this);
File copySolutionsDirectory = gtaManager.getSolutionsDirectory(course.getCourseEnvironment(), this);
FileUtils.copyDirContentsToDir(sourceSolutionsDirectory, copySolutionsDirectory, false, "copy task course node solutions");
File solutionDefinitions = new File(sourceSolutionsDirectory.getParentFile(), GTAManager.SOLUTIONS_DEFINITIONS);
if (solutionDefinitions.exists()) {
File copySolutionDefinitions = new File(copySolutionsDirectory.getParentFile(), GTAManager.SOLUTIONS_DEFINITIONS);
FileUtils.copyFileToFile(solutionDefinitions, copySolutionDefinitions, false);
}
RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
gtaManager.createIfNotExists(entry, this);
}
use of org.olat.course.nodes.gta.GTAManager in project OpenOLAT by OpenOLAT.
the class GTACourseNode method archiveNodeData.
@Override
public boolean archiveNodeData(Locale locale, ICourse course, ArchiveOptions options, ZipOutputStream exportStream, String charset) {
final GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
final ModuleConfiguration config = getModuleConfiguration();
String prefix;
if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
prefix = "grouptask_";
} else {
prefix = "ita_";
}
String dirName = prefix + StringHelper.transformDisplayNameToFileSystemName(getShortName()) + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis()));
TaskList taskList = gtaManager.getTaskList(course.getCourseEnvironment().getCourseGroupManager().getCourseEntry(), this);
// save assessment datas
List<Identity> users = null;
if (config.getBooleanSafe(GTASK_GRADING)) {
users = ScoreAccountingHelper.loadUsers(course.getCourseEnvironment(), options);
String courseTitle = course.getCourseTitle();
String fileName = ExportUtil.createFileNameWithTimeStamp(courseTitle, "xlsx");
List<AssessableCourseNode> nodes = Collections.<AssessableCourseNode>singletonList(this);
try (OutputStream out = new ShieldOutputStream(exportStream)) {
exportStream.putNextEntry(new ZipEntry(dirName + "/" + fileName));
ScoreAccountingHelper.createCourseResultsOverviewXMLTable(users, nodes, course, locale, out);
exportStream.closeEntry();
} catch (Exception e) {
log.error("", e);
}
}
// copy tasks
if (taskList != null) {
if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
List<BusinessGroup> selectedGroups;
if (options != null && options.getGroup() != null) {
selectedGroups = Collections.singletonList(options.getGroup());
} else {
selectedGroups = gtaManager.getBusinessGroups(this);
}
for (BusinessGroup businessGroup : selectedGroups) {
archiveNodeData(course, businessGroup, taskList, dirName, exportStream);
}
} else {
if (users == null) {
users = ScoreAccountingHelper.loadUsers(course.getCourseEnvironment(), options);
}
Set<Identity> uniqueUsers = new HashSet<>(users);
for (Identity user : uniqueUsers) {
archiveNodeData(course, user, taskList, dirName, exportStream);
}
}
}
// copy solutions
if (config.getBooleanSafe(GTACourseNode.GTASK_SAMPLE_SOLUTION)) {
VFSContainer solutions = gtaManager.getSolutionsContainer(course.getCourseEnvironment(), this);
if (solutions.exists()) {
String solutionDirName = dirName + "/solutions";
for (VFSItem solution : solutions.getItems(new SystemItemFilter())) {
ZipUtil.addToZip(solution, solutionDirName, exportStream);
}
}
}
return true;
}
use of org.olat.course.nodes.gta.GTAManager in project OpenOLAT by OpenOLAT.
the class GTACourseNode method createInstanceForCopy.
@Override
public CourseNode createInstanceForCopy(boolean isNewTitle, ICourse course, Identity author) {
GTACourseNode cNode = (GTACourseNode) super.createInstanceForCopy(isNewTitle, course, author);
GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
// copy tasks
File taskDirectory = gtaManager.getTasksDirectory(course.getCourseEnvironment(), this);
File copyTaskDirectory = gtaManager.getTasksDirectory(course.getCourseEnvironment(), cNode);
FileUtils.copyDirContentsToDir(taskDirectory, copyTaskDirectory, false, "copy task course node");
File taskDefinitions = new File(taskDirectory.getParentFile(), GTAManager.TASKS_DEFINITIONS);
if (taskDefinitions.exists()) {
File copyTaskDefinitions = new File(copyTaskDirectory.getParentFile(), GTAManager.TASKS_DEFINITIONS);
FileUtils.copyFileToFile(taskDefinitions, copyTaskDefinitions, false);
}
// copy solutions
File solutionsDirectory = gtaManager.getSolutionsDirectory(course.getCourseEnvironment(), this);
File copySolutionsDirectory = gtaManager.getSolutionsDirectory(course.getCourseEnvironment(), cNode);
FileUtils.copyDirContentsToDir(solutionsDirectory, copySolutionsDirectory, false, "copy task course node solutions");
File solutionDefinitions = new File(solutionsDirectory.getParentFile(), GTAManager.SOLUTIONS_DEFINITIONS);
if (solutionDefinitions.exists()) {
File copySolutionDefinitions = new File(copySolutionsDirectory.getParentFile(), GTAManager.SOLUTIONS_DEFINITIONS);
FileUtils.copyFileToFile(solutionDefinitions, copySolutionDefinitions, false);
}
return cNode;
}
use of org.olat.course.nodes.gta.GTAManager in project OpenOLAT by OpenOLAT.
the class GTACourseNode method archiveNodeData.
private void archiveNodeData(ICourse course, Identity assessedIdentity, TaskList taskList, String dirName, ZipOutputStream exportStream) {
ModuleConfiguration config = getModuleConfiguration();
GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
String name = assessedIdentity.getUser().getLastName() + "_" + assessedIdentity.getUser().getFirstName() + "_" + assessedIdentity.getName();
// for beautiful ordering
int flow = 0;
String userDirName = dirName + "/" + StringHelper.transformDisplayNameToFileSystemName(name);
Task task = gtaManager.getTask(assessedIdentity, 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 = userDirName + "/" + (++flow) + "_task/" + taskFile.getName();
ZipUtil.addFileToZip(path, taskFile, exportStream);
}
}
if (config.getBooleanSafe(GTASK_SUBMIT)) {
File submitDirectory = gtaManager.getSubmitDirectory(course.getCourseEnvironment(), this, assessedIdentity);
String submissionDirName = userDirName + "/" + (++flow) + "_submissions";
ZipUtil.addDirectoryToZip(submitDirectory.toPath(), submissionDirName, exportStream);
}
if (config.getBooleanSafe(GTACourseNode.GTASK_REVIEW_AND_CORRECTION)) {
File correctionsDir = gtaManager.getCorrectionDirectory(course.getCourseEnvironment(), this, assessedIdentity);
String correctionDirName = userDirName + "/" + (++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, assessedIdentity);
String revisionDirName = userDirName + "/" + (++flow) + "_revisions_" + i;
ZipUtil.addDirectoryToZip(revisionDirectory.toPath(), revisionDirName, exportStream);
File correctionDirectory = gtaManager.getRevisedDocumentsCorrectionsDirectory(course.getCourseEnvironment(), this, i, assessedIdentity);
String correctionDirName = userDirName + "/" + (++flow) + "_corrections_" + i;
ZipUtil.addDirectoryToZip(correctionDirectory.toPath(), correctionDirName, exportStream);
}
}
// assessment documents
if (config.getBooleanSafe(MSCourseNode.CONFIG_KEY_HAS_INDIVIDUAL_ASSESSMENT_DOCS, false)) {
List<File> assessmentDocuments = course.getCourseEnvironment().getAssessmentManager().getIndividualAssessmentDocuments(this, assessedIdentity);
if (assessmentDocuments != null && !assessmentDocuments.isEmpty()) {
String assessmentDir = userDirName + "/" + (++flow) + "_assessment/";
for (File document : assessmentDocuments) {
String path = assessmentDir + document.getName();
ZipUtil.addFileToZip(path, document, exportStream);
}
}
}
}
Aggregations