use of org.olat.core.util.io.SystemFileFilter in project OpenOLAT by OpenOLAT.
the class CourseAssessmentManagerImpl method getIndividualAssessmentDocuments.
@Override
public List<File> getIndividualAssessmentDocuments(CourseNode courseNode, Identity identity) {
File directory = getAssessmentDocumentsDirectory(courseNode, identity);
File[] documents = directory.listFiles(new SystemFileFilter(true, false));
List<File> documentList = new ArrayList<>();
if (documents != null && documents.length > 0) {
for (File document : documents) {
documentList.add(document);
}
}
return documentList;
}
use of org.olat.core.util.io.SystemFileFilter in project openolat by klemens.
the class CourseAssessmentManagerImpl method addIndividualAssessmentDocument.
@Override
public void addIndividualAssessmentDocument(CourseNode courseNode, Identity identity, Identity assessedIdentity, File document, String filename) {
if (document == null)
return;
if (!StringHelper.containsNonWhitespace(filename)) {
filename = document.getName();
}
try {
File directory = getAssessmentDocumentsDirectory(courseNode, assessedIdentity);
File targetFile = new File(directory, filename);
if (targetFile.exists()) {
String newName = FileUtils.rename(targetFile);
targetFile = new File(directory, newName);
}
Files.copy(document.toPath(), targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
// update counter
AssessmentEntry nodeAssessment = getOrCreate(assessedIdentity, courseNode);
File[] docs = directory.listFiles(new SystemFileFilter(true, false));
int numOfDocs = docs == null ? 0 : docs.length;
nodeAssessment.setNumberOfAssessmentDocuments(numOfDocs);
assessmentService.updateAssessmentEntry(nodeAssessment);
// node log
ICourse course = CourseFactory.loadCourse(cgm.getCourseEntry());
UserNodeAuditManager am = course.getCourseEnvironment().getAuditManager();
am.appendToUserNodeLog(courseNode, identity, assessedIdentity, "assessment document added: " + filename);
// user activity logging
ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_DOCUMENT_ADDED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.assessmentDocument, "", StringHelper.stripLineBreaks(filename)));
} catch (IOException e) {
log.error("", e);
}
}
use of org.olat.core.util.io.SystemFileFilter in project openolat by klemens.
the class CourseAssessmentManagerImpl method getIndividualAssessmentDocuments.
@Override
public List<File> getIndividualAssessmentDocuments(CourseNode courseNode, Identity identity) {
File directory = getAssessmentDocumentsDirectory(courseNode, identity);
File[] documents = directory.listFiles(new SystemFileFilter(true, false));
List<File> documentList = new ArrayList<>();
if (documents != null && documents.length > 0) {
for (File document : documents) {
documentList.add(document);
}
}
return documentList;
}
Aggregations