Search in sources :

Example 46 with Binder

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

the class DeletedBinderController method doRestore.

private void doRestore(BinderRow row) {
    Binder binder = portfolioService.getBinderByKey(row.getKey());
    binder.setBinderStatus(BinderStatus.open);
    binder = portfolioService.updateBinder(binder);
    showInfo("restore.binder.success");
}
Also used : Binder(org.olat.modules.portfolio.Binder)

Example 47 with Binder

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

the class PortfolioServiceImpl method changePageStatus.

@Override
public Page changePageStatus(Page page, PageStatus status, Identity identity, Role by) {
    PageStatus currentStatus = page.getPageStatus();
    Page reloadedPage = pageDao.loadByKey(page.getKey());
    ((PageImpl) reloadedPage).setPageStatus(status);
    if (status == PageStatus.published) {
        Date now = new Date();
        if (reloadedPage.getInitialPublicationDate() == null) {
            ((PageImpl) reloadedPage).setInitialPublicationDate(now);
        }
        ((PageImpl) reloadedPage).setLastPublicationDate(now);
        Section section = reloadedPage.getSection();
        // auto update the status of the evaluation form of the authors of the binder
        changeAssignmentStatus(page, section, EvaluationFormSessionStatus.done);
        if (section != null) {
            SectionStatus sectionStatus = section.getSectionStatus();
            if (currentStatus == PageStatus.closed) {
                if (sectionStatus == SectionStatus.closed) {
                    ((SectionImpl) section).setSectionStatus(SectionStatus.inProgress);
                    binderDao.updateSection(section);
                }
            } else if (sectionStatus == null || sectionStatus == SectionStatus.notStarted || sectionStatus == SectionStatus.closed) {
                ((SectionImpl) section).setSectionStatus(SectionStatus.inProgress);
                binderDao.updateSection(section);
            }
        }
    } else if (status == PageStatus.inRevision) {
        Section section = reloadedPage.getSection();
        changeAssignmentStatus(page, section, EvaluationFormSessionStatus.inProgress);
        if (section != null) {
            SectionStatus sectionStatus = section.getSectionStatus();
            if (sectionStatus == null || sectionStatus == SectionStatus.notStarted || sectionStatus == SectionStatus.closed) {
                if (sectionStatus == SectionStatus.closed) {
                    ((SectionImpl) section).setSectionStatus(SectionStatus.inProgress);
                    binderDao.updateSection(section);
                }
            }
        }
        pageUserInfosDao.updateStatus(reloadedPage, PageUserStatus.inProcess, PageUserStatus.done);
    } else if (status == PageStatus.closed) {
        // set user informations to done
        pageUserInfosDao.updateStatus(reloadedPage, PageUserStatus.done);
    }
    if (reloadedPage.getSection() != null && reloadedPage.getSection().getBinder() != null) {
        Binder binder = reloadedPage.getSection().getBinder();
        updateAssessmentEntryLastModification(binder, identity, by);
    }
    return pageDao.updatePage(reloadedPage);
}
Also used : PageImpl(org.olat.modules.portfolio.model.PageImpl) Binder(org.olat.modules.portfolio.Binder) AssessedBinder(org.olat.modules.portfolio.model.AssessedBinder) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) PageStatus(org.olat.modules.portfolio.PageStatus) AssessedPage(org.olat.modules.portfolio.model.AssessedPage) Page(org.olat.modules.portfolio.Page) SectionStatus(org.olat.modules.portfolio.SectionStatus) 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) Date(java.util.Date)

Example 48 with Binder

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

the class PortfolioServiceImpl method setAssessmentStatus.

@Override
public void setAssessmentStatus(Identity assessedIdentity, BinderRef binderRef, AssessmentEntryStatus status, Identity coachingIdentity) {
    Boolean fullyAssessed = Boolean.FALSE;
    if (status == AssessmentEntryStatus.done) {
        fullyAssessed = Boolean.TRUE;
    }
    Binder binder = binderDao.loadByKey(binderRef.getKey());
    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;
            UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
            AssessmentEvaluation eval = pfNode.getUserScoreEvaluation(userCourseEnv);
            ScoreEvaluation scoreEval = new ScoreEvaluation(eval.getScore(), eval.getPassed(), status, true, fullyAssessed, null, null, binder.getKey());
            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.setFullyAssessed(fullyAssessed);
        assessmentEntry.setAssessmentStatus(status);
        assessmentService.updateAssessmentEntry(assessmentEntry);
    }
}
Also used : Binder(org.olat.modules.portfolio.Binder) AssessedBinder(org.olat.modules.portfolio.model.AssessedBinder) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) AssessmentEvaluation(org.olat.course.run.scoring.AssessmentEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) OLATResource(org.olat.resource.OLATResource) BinderImpl(org.olat.modules.portfolio.model.BinderImpl) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) CourseNode(org.olat.course.nodes.CourseNode) PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry)

Example 49 with Binder

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

the class PortfolioServiceTest method createNewOwnedPorfolio.

@Test
public void createNewOwnedPorfolio() {
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-1");
    String title = "My portfolio";
    String summary = "My live";
    Binder binder = portfolioService.createNewBinder(title, summary, null, id);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(binder);
    Assert.assertNotNull(binder.getKey());
    Assert.assertNotNull(binder.getCreationDate());
    Assert.assertNotNull(binder.getLastModified());
    Assert.assertEquals(title, binder.getTitle());
    Assert.assertEquals(summary, binder.getSummary());
    List<Binder> ownedBinders = portfolioService.getOwnedBinders(id);
    Assert.assertNotNull(ownedBinders);
    Assert.assertEquals(1, ownedBinders.size());
    Binder ownedBinder = ownedBinders.get(0);
    Assert.assertNotNull(ownedBinder);
    Assert.assertEquals(binder, ownedBinder);
}
Also used : SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Binder(org.olat.modules.portfolio.Binder) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 50 with Binder

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

the class PortfolioServiceTest method deleteBinder.

@Test
public void deleteBinder() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("del-binder-");
    Binder binder = portfolioService.createNewBinder("Binder to delete", "Deletion", "", owner);
    SectionRef sectionRef1 = portfolioService.appendNewSection("1. section ", "Section 1", null, null, binder);
    dbInstance.commit();
    SectionRef sectionRef2 = portfolioService.appendNewSection("2. section ", "Section 2", null, null, binder);
    dbInstance.commit();
    portfolioService.updateBinderUserInformations(binder, owner);
    dbInstance.commit();
    Section reloadedSection1 = portfolioService.getSection(sectionRef1);
    Page page1 = portfolioService.appendNewPage(owner, "New page", "A brand new page.", null, null, reloadedSection1);
    Section reloadedSection2 = portfolioService.getSection(sectionRef2);
    Page page2 = portfolioService.appendNewPage(owner, "New page", "A brand new page.", null, null, reloadedSection2);
    Assert.assertNotNull(page1);
    Assert.assertNotNull(page2);
    dbInstance.commitAndCloseSession();
    // delete
    boolean deleted = portfolioService.deleteBinder(binder);
    dbInstance.commit();
    Assert.assertTrue(deleted);
}
Also used : SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Binder(org.olat.modules.portfolio.Binder) Page(org.olat.modules.portfolio.Page) Identity(org.olat.core.id.Identity) SectionRef(org.olat.modules.portfolio.SectionRef) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Aggregations

Binder (org.olat.modules.portfolio.Binder)144 Section (org.olat.modules.portfolio.Section)72 Identity (org.olat.core.id.Identity)70 Test (org.junit.Test)68 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)58 Page (org.olat.modules.portfolio.Page)44 RepositoryEntry (org.olat.repository.RepositoryEntry)34 Assignment (org.olat.modules.portfolio.Assignment)30 ArrayList (java.util.ArrayList)22 SectionRef (org.olat.modules.portfolio.SectionRef)22 AssessedBinder (org.olat.modules.portfolio.model.AssessedBinder)20 AssessmentSection (org.olat.modules.portfolio.AssessmentSection)16 OLATResourceable (org.olat.core.id.OLATResourceable)14 BinderSecurityCallback (org.olat.modules.portfolio.BinderSecurityCallback)14 PortfolioService (org.olat.modules.portfolio.PortfolioService)14 BinderImpl (org.olat.modules.portfolio.model.BinderImpl)14 AccessRights (org.olat.modules.portfolio.model.AccessRights)12 Date (java.util.Date)10 WindowControl (org.olat.core.gui.control.WindowControl)10 AssessmentSectionImpl (org.olat.modules.portfolio.model.AssessmentSectionImpl)8