Search in sources :

Example 21 with EfficiencyStatement

use of org.olat.course.assessment.EfficiencyStatement in project openolat by klemens.

the class EfficiencyStatementManager method findEfficiencyStatements.

/**
 * Find all efficiency statements for a specific user
 * @param identity
 * @return List of efficiency statements
 */
protected List<EfficiencyStatement> findEfficiencyStatements(Identity identity) {
    List<EfficiencyStatement> efficiencyStatements = new ArrayList<EfficiencyStatement>();
    try {
        StringBuilder sb = new StringBuilder();
        sb.append("select statement from ").append(UserEfficiencyStatementImpl.class.getName()).append(" as statement ").append(" where statement.identity.key=:identityKey");
        List<UserEfficiencyStatementImpl> statements = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), UserEfficiencyStatementImpl.class).setParameter("identityKey", identity.getKey()).getResultList();
        for (UserEfficiencyStatementImpl statement : statements) {
            EfficiencyStatement s = (EfficiencyStatement) xstream.fromXML(statement.getStatementXml());
            efficiencyStatements.add(s);
        }
    } catch (Exception e) {
        log.error("findEfficiencyStatements: " + identity, e);
    }
    return efficiencyStatements;
}
Also used : ArrayList(java.util.ArrayList) UserEfficiencyStatementImpl(org.olat.course.assessment.model.UserEfficiencyStatementImpl) EfficiencyStatement(org.olat.course.assessment.EfficiencyStatement) UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement)

Example 22 with EfficiencyStatement

use of org.olat.course.assessment.EfficiencyStatement in project openolat by klemens.

the class EfficiencyStatementManager method updateUserEfficiencyStatement.

public void updateUserEfficiencyStatement(Identity assessedIdentity, final CourseEnvironment courseEnv, List<AssessmentNodeData> assessmentNodeList, AssessmentNodesLastModified lastModifications, final RepositoryEntry repoEntry) {
    List<Map<String, Object>> assessmentNodes = AssessmentHelper.assessmentNodeDataListToMap(assessmentNodeList);
    EfficiencyStatement efficiencyStatement = new EfficiencyStatement();
    efficiencyStatement.setAssessmentNodes(assessmentNodes);
    efficiencyStatement.setCourseTitle(courseEnv.getCourseTitle());
    efficiencyStatement.setCourseRepoEntryKey(repoEntry.getKey());
    String userInfos = userManager.getUserDisplayName(assessedIdentity);
    efficiencyStatement.setDisplayableUserInfo(userInfos);
    efficiencyStatement.setLastUpdated(System.currentTimeMillis());
    if (lastModifications != null) {
        if (lastModifications.getLastUserModified() != null) {
            efficiencyStatement.setLastUserModified(lastModifications.getLastUserModified().getTime());
        }
        if (lastModifications.getLastCoachModified() != null) {
            efficiencyStatement.setLastCoachModified(lastModifications.getLastCoachModified().getTime());
        }
    }
    boolean debug = log.isDebug();
    UserEfficiencyStatementImpl efficiencyProperty = getUserEfficiencyStatementFull(repoEntry, assessedIdentity);
    if (assessmentNodes != null) {
        if (efficiencyProperty == null) {
            // create new
            efficiencyProperty = new UserEfficiencyStatementImpl();
            efficiencyProperty.setIdentity(assessedIdentity);
            efficiencyProperty.setCourseRepoKey(repoEntry.getKey());
            if (repoEntry != null) {
                efficiencyProperty.setResource(repoEntry.getOlatResource());
                efficiencyProperty.setCourseRepoKey(repoEntry.getKey());
            }
            efficiencyProperty.setShortTitle(courseEnv.getRunStructure().getRootNode().getShortTitle());
            efficiencyProperty.setTitle(courseEnv.getRunStructure().getRootNode().getLongTitle());
            fillEfficiencyStatement(efficiencyStatement, lastModifications, efficiencyProperty);
            dbInstance.getCurrentEntityManager().persist(efficiencyProperty);
            if (debug) {
                log.debug("creating new efficiency statement property::" + efficiencyProperty.getKey() + " for id::" + assessedIdentity.getName() + " repoEntry::" + repoEntry.getKey());
            }
        } else {
            // update existing
            if (debug) {
                log.debug("updating efficiency statement property::" + efficiencyProperty.getKey() + " for id::" + assessedIdentity.getName() + " repoEntry::" + repoEntry.getKey());
            }
            efficiencyProperty.setShortTitle(courseEnv.getRunStructure().getRootNode().getShortTitle());
            efficiencyProperty.setTitle(courseEnv.getRunStructure().getRootNode().getLongTitle());
            fillEfficiencyStatement(efficiencyStatement, lastModifications, efficiencyProperty);
            dbInstance.getCurrentEntityManager().merge(efficiencyProperty);
        }
    } else {
        if (efficiencyProperty != null) {
            // remove existing since now empty efficiency statements
            if (debug) {
                log.debug("removing efficiency statement property::" + efficiencyProperty.getKey() + " for id::" + assessedIdentity.getName() + " repoEntry::" + repoEntry.getKey() + " since empty");
            }
            dbInstance.getCurrentEntityManager().remove(efficiencyProperty);
        }
    // else nothing to create and nothing to delete
    }
    // send modified event to everybody
    AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_EFFICIENCY_STATEMENT_CHANGED, assessedIdentity);
    OLATResourceable courseOres = OresHelper.createOLATResourceableInstance(CourseModule.class, courseEnv.getCourseResourceableId());
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, courseOres);
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) AssessmentChangedEvent(org.olat.course.assessment.AssessmentChangedEvent) UserEfficiencyStatementImpl(org.olat.course.assessment.model.UserEfficiencyStatementImpl) Map(java.util.Map) EfficiencyStatement(org.olat.course.assessment.EfficiencyStatement) UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement)

Example 23 with EfficiencyStatement

use of org.olat.course.assessment.EfficiencyStatement in project openolat by klemens.

the class CertificateAndEfficiencyStatementListController method doCollectArtefact.

private void doCollectArtefact(UserRequest ureq, String title, Long efficiencyStatementKey) {
    EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(EfficiencyStatementArtefact.ARTEFACT_TYPE);
    if (artHandler != null && artHandler.isEnabled() && assessedIdentity.equals(getIdentity())) {
        AbstractArtefact artefact = artHandler.createArtefact();
        // only author can create artefact
        artefact.setAuthor(getIdentity());
        // no business path becouse we cannot launch an efficiency statement
        artefact.setCollectionDate(new Date());
        artefact.setTitle(translate("artefact.title", new String[] { title }));
        EfficiencyStatement fullStatement = esm.getUserEfficiencyStatementByKey(efficiencyStatementKey);
        artHandler.prefillArtefactAccordingToSource(artefact, fullStatement);
        ePFCollCtrl = new ArtefactWizzardStepsController(ureq, getWindowControl(), artefact, (VFSContainer) null);
        listenTo(ePFCollCtrl);
    }
}
Also used : ArtefactWizzardStepsController(org.olat.portfolio.ui.artefacts.collect.ArtefactWizzardStepsController) VFSContainer(org.olat.core.util.vfs.VFSContainer) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) Date(java.util.Date) EfficiencyStatement(org.olat.course.assessment.EfficiencyStatement) CertificateAndEfficiencyStatement(org.olat.course.certificate.ui.CertificateAndEfficiencyStatementListModel.CertificateAndEfficiencyStatement)

Example 24 with EfficiencyStatement

use of org.olat.course.assessment.EfficiencyStatement in project openolat by klemens.

the class CertificateAndEfficiencyStatementListController method doShowStatement.

private void doShowStatement(UserRequest ureq, CertificateAndEfficiencyStatement statement) {
    RepositoryEntry entry = repositoryService.loadByResourceKey(statement.getResourceKey());
    EfficiencyStatement efficiencyStatment = esm.getUserEfficiencyStatementByKey(statement.getEfficiencyStatementKey());
    CertificateAndEfficiencyStatementController efficiencyCtrl = new CertificateAndEfficiencyStatementController(getWindowControl(), ureq, assessedIdentity, null, statement.getResourceKey(), entry, efficiencyStatment, false);
    listenTo(efficiencyCtrl);
    stackPanel.pushController(statement.getDisplayName(), efficiencyCtrl);
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) EfficiencyStatement(org.olat.course.assessment.EfficiencyStatement) CertificateAndEfficiencyStatement(org.olat.course.certificate.ui.CertificateAndEfficiencyStatementListModel.CertificateAndEfficiencyStatement)

Example 25 with EfficiencyStatement

use of org.olat.course.assessment.EfficiencyStatement in project openolat by klemens.

the class CertificateAndEfficiencyStatementListController method doCollectMedia.

private void doCollectMedia(UserRequest ureq, String title, Long efficiencyStatementKey) {
    if (collectorCtrl != null)
        return;
    EfficiencyStatement fullStatement = esm.getUserEfficiencyStatementByKey(efficiencyStatementKey);
    collectorCtrl = new CollectArtefactController(ureq, getWindowControl(), fullStatement, mediaHandler, "");
    listenTo(collectorCtrl);
    cmc = new CloseableModalController(getWindowControl(), null, collectorCtrl.getInitialComponent(), true, title, true);
    cmc.addControllerListener(this);
    cmc.activate();
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) CollectArtefactController(org.olat.modules.portfolio.ui.wizard.CollectArtefactController) EfficiencyStatement(org.olat.course.assessment.EfficiencyStatement) CertificateAndEfficiencyStatement(org.olat.course.certificate.ui.CertificateAndEfficiencyStatementListModel.CertificateAndEfficiencyStatement)

Aggregations

EfficiencyStatement (org.olat.course.assessment.EfficiencyStatement)26 UserEfficiencyStatement (org.olat.course.assessment.UserEfficiencyStatement)8 UserEfficiencyStatementImpl (org.olat.course.assessment.model.UserEfficiencyStatementImpl)6 CertificateAndEfficiencyStatementController (org.olat.course.certificate.ui.CertificateAndEfficiencyStatementController)6 CertificateAndEfficiencyStatement (org.olat.course.certificate.ui.CertificateAndEfficiencyStatementListModel.CertificateAndEfficiencyStatement)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6 Date (java.util.Date)4 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Consumes (javax.ws.rs.Consumes)2 PUT (javax.ws.rs.PUT)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 BaseSecurity (org.olat.basesecurity.BaseSecurity)2 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)2 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2 Identity (org.olat.core.id.Identity)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 AssessmentChangedEvent (org.olat.course.assessment.AssessmentChangedEvent)2