Search in sources :

Example 56 with BinderImpl

use of org.olat.modules.portfolio.model.BinderImpl in project openolat by klemens.

the class PortfolioServiceImpl method internalCopyTransientBinder.

private Binder internalCopyTransientBinder(Binder transientBinder, RepositoryEntry entry, String imagePath, boolean copy) {
    Binder binder = binderDao.createAndPersist(transientBinder.getTitle(), transientBinder.getSummary(), imagePath, entry);
    // copy sections
    for (Section transientSection : ((BinderImpl) transientBinder).getSections()) {
        SectionImpl section = binderDao.createSection(transientSection.getTitle(), transientSection.getDescription(), transientSection.getBeginDate(), transientSection.getEndDate(), binder);
        List<Assignment> transientAssignments = ((SectionImpl) transientSection).getAssignments();
        for (Assignment transientAssignment : transientAssignments) {
            if (transientAssignment != null) {
                File newStorage = portfolioFileStorage.generateAssignmentSubDirectory();
                String storage = portfolioFileStorage.getRelativePath(newStorage);
                assignmentDao.createAssignment(transientAssignment.getTitle(), transientAssignment.getSummary(), transientAssignment.getContent(), storage, transientAssignment.getAssignmentType(), transientAssignment.getAssignmentStatus(), section, transientAssignment.isOnlyAutoEvaluation(), transientAssignment.isReviewerSeeAutoEvaluation(), transientAssignment.isAnonymousExternalEvaluation(), transientAssignment.getFormEntry());
                // copy attachments
                File templateDirectory = portfolioFileStorage.getAssignmentDirectory(transientAssignment);
                if (copy && templateDirectory != null) {
                    FileUtils.copyDirContentsToDir(templateDirectory, newStorage, false, "Assignment attachments");
                }
            }
        }
    }
    return binder;
}
Also used : Assignment(org.olat.modules.portfolio.Assignment) Binder(org.olat.modules.portfolio.Binder) AssessedBinder(org.olat.modules.portfolio.model.AssessedBinder) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) BinderImpl(org.olat.modules.portfolio.model.BinderImpl) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) SectionImpl(org.olat.modules.portfolio.model.SectionImpl) AssessmentSectionImpl(org.olat.modules.portfolio.model.AssessmentSectionImpl) File(java.io.File)

Example 57 with BinderImpl

use of org.olat.modules.portfolio.model.BinderImpl in project openolat by klemens.

the class PortfolioServiceImpl method deleteBinderTemplate.

@Override
public boolean deleteBinderTemplate(Binder binder, RepositoryEntry templateEntry) {
    BinderImpl reloadedBinder = (BinderImpl) binderDao.loadByKey(binder.getKey());
    int deletedRows = binderDao.deleteBinderTemplate(reloadedBinder);
    return deletedRows > 0;
}
Also used : BinderImpl(org.olat.modules.portfolio.model.BinderImpl)

Example 58 with BinderImpl

use of org.olat.modules.portfolio.model.BinderImpl in project openolat by klemens.

the class PortfolioServiceImpl method updateAssessmentEntry.

private void updateAssessmentEntry(Identity assessedIdentity, Binder binder, Set<AssessmentSection> assessmentSections, Identity coachingIdentity) {
    boolean allPassed = true;
    int totalSectionPassed = 0;
    int totalSectionClosed = 0;
    BigDecimal totalScore = new BigDecimal("0.0");
    AssessmentEntryStatus binderStatus = null;
    for (AssessmentSection assessmentSection : assessmentSections) {
        if (assessmentSection.getScore() != null) {
            totalScore = totalScore.add(assessmentSection.getScore());
        }
        if (assessmentSection.getPassed() != null && assessmentSection.getPassed().booleanValue()) {
            allPassed &= true;
            totalSectionPassed++;
        }
        Section section = assessmentSection.getSection();
        if (section.getSectionStatus() == SectionStatus.closed) {
            totalSectionClosed++;
        }
    }
    Boolean totalPassed = null;
    if (totalSectionClosed == assessmentSections.size()) {
        totalPassed = new Boolean(allPassed);
    } else {
        if (assessmentSections.size() == totalSectionPassed) {
            totalPassed = Boolean.TRUE;
        }
        binderStatus = AssessmentEntryStatus.inProgress;
    }
    // order status from the entry / section
    RepositoryEntry entry = binder.getEntry();
    if ("CourseModule".equals(entry.getOlatResource().getResourceableTypeName())) {
        ICourse course = CourseFactory.loadCourse(entry);
        CourseNode courseNode = course.getRunStructure().getNode(binder.getSubIdent());
        if (courseNode instanceof PortfolioCourseNode) {
            PortfolioCourseNode pfNode = (PortfolioCourseNode) courseNode;
            ScoreEvaluation scoreEval = new ScoreEvaluation(totalScore.floatValue(), totalPassed, binderStatus, true, true, null, null, binder.getKey());
            UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
            pfNode.updateUserScoreEvaluation(scoreEval, userCourseEnv, coachingIdentity, false, Role.coach);
        }
    } else {
        OLATResource resource = ((BinderImpl) binder.getTemplate()).getOlatResource();
        RepositoryEntry referenceEntry = repositoryService.loadByResourceKey(resource.getKey());
        AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, binder.getEntry(), binder.getSubIdent(), referenceEntry);
        assessmentEntry.setScore(totalScore);
        assessmentEntry.setPassed(totalPassed);
        assessmentEntry.setAssessmentStatus(binderStatus);
        assessmentService.updateAssessmentEntry(assessmentEntry);
    }
}
Also used : PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) OLATResource(org.olat.resource.OLATResource) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) AssessmentEntryStatus(org.olat.modules.assessment.model.AssessmentEntryStatus) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) BigDecimal(java.math.BigDecimal) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) BinderImpl(org.olat.modules.portfolio.model.BinderImpl) CourseNode(org.olat.course.nodes.CourseNode) PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean)

Example 59 with BinderImpl

use of org.olat.modules.portfolio.model.BinderImpl in project openolat by klemens.

the class PortfolioServiceImpl method loadAndSyncBinder.

@Override
public SynchedBinder loadAndSyncBinder(BinderRef binder) {
    Binder reloadedBinder = binderDao.loadByKey(binder.getKey());
    AtomicBoolean changes = new AtomicBoolean(false);
    if (reloadedBinder.getTemplate() != null) {
        reloadedBinder = binderDao.syncWithTemplate((BinderImpl) reloadedBinder.getTemplate(), (BinderImpl) reloadedBinder, changes);
    }
    return new SynchedBinder(reloadedBinder, changes.get());
}
Also used : Binder(org.olat.modules.portfolio.Binder) AssessedBinder(org.olat.modules.portfolio.model.AssessedBinder) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) BinderImpl(org.olat.modules.portfolio.model.BinderImpl) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder)

Example 60 with BinderImpl

use of org.olat.modules.portfolio.model.BinderImpl in project openolat by klemens.

the class PortfolioServiceImpl method assignBinder.

@Override
public Binder assignBinder(Identity owner, BinderRef templateBinder, RepositoryEntry entry, String subIdent, Date deadline) {
    BinderImpl reloadedTemplate = (BinderImpl) binderDao.loadByKey(templateBinder.getKey());
    BinderImpl binder = binderDao.createCopy(reloadedTemplate, entry, subIdent);
    groupDao.addMembershipTwoWay(binder.getBaseGroup(), owner, PortfolioRoles.owner.name());
    return binder;
}
Also used : BinderImpl(org.olat.modules.portfolio.model.BinderImpl)

Aggregations

BinderImpl (org.olat.modules.portfolio.model.BinderImpl)64 Section (org.olat.modules.portfolio.Section)40 Test (org.junit.Test)38 Page (org.olat.modules.portfolio.Page)32 Identity (org.olat.core.id.Identity)22 Binder (org.olat.modules.portfolio.Binder)14 PageUserInformations (org.olat.modules.portfolio.PageUserInformations)12 RepositoryEntry (org.olat.repository.RepositoryEntry)12 OLATResource (org.olat.resource.OLATResource)10 ICourse (org.olat.course.ICourse)8 CourseNode (org.olat.course.nodes.CourseNode)8 PortfolioCourseNode (org.olat.course.nodes.PortfolioCourseNode)8 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)8 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)8 AssessedBinder (org.olat.modules.portfolio.model.AssessedBinder)8 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)8 Date (java.util.Date)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)6 PageBody (org.olat.modules.portfolio.PageBody)6 BigDecimal (java.math.BigDecimal)4