Search in sources :

Example 6 with SystemFileFilter

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;
}
Also used : ArrayList(java.util.ArrayList) SystemFileFilter(org.olat.core.util.io.SystemFileFilter) File(java.io.File)

Example 7 with SystemFileFilter

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);
    }
}
Also used : UserNodeAuditManager(org.olat.course.auditing.UserNodeAuditManager) ICourse(org.olat.course.ICourse) IOException(java.io.IOException) SystemFileFilter(org.olat.core.util.io.SystemFileFilter) File(java.io.File) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry)

Example 8 with SystemFileFilter

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;
}
Also used : ArrayList(java.util.ArrayList) SystemFileFilter(org.olat.core.util.io.SystemFileFilter) File(java.io.File)

Aggregations

File (java.io.File)8 SystemFileFilter (org.olat.core.util.io.SystemFileFilter)8 ArrayList (java.util.ArrayList)4 ICourse (org.olat.course.ICourse)4 UserNodeAuditManager (org.olat.course.auditing.UserNodeAuditManager)4 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)4 IOException (java.io.IOException)2 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)2 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)2 FormItem (org.olat.core.gui.components.form.flexible.FormItem)2 VFSItem (org.olat.core.util.vfs.VFSItem)2