Search in sources :

Example 1 with EfficiencyStatement

use of org.olat.course.assessment.EfficiencyStatement in project OpenOLAT by OpenOLAT.

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 2 with EfficiencyStatement

use of org.olat.course.assessment.EfficiencyStatement in project OpenOLAT by OpenOLAT.

the class EfficiencyStatementMediaHandler method createMedia.

@Override
public Media createMedia(String title, String description, Object mediaObject, String businessPath, Identity author) {
    Media media = null;
    if (mediaObject instanceof EfficiencyStatement) {
        EfficiencyStatement statement = (EfficiencyStatement) mediaObject;
        String xml = myXStream.toXML(statement);
        media = mediaDao.createMedia(title, description, xml, EFF_MEDIA, businessPath, null, 90, author);
        ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_MEDIA_ADDED, getClass(), LoggingResourceable.wrap(media));
    }
    return media;
}
Also used : Media(org.olat.modules.portfolio.Media) EfficiencyStatement(org.olat.course.assessment.EfficiencyStatement)

Example 3 with EfficiencyStatement

use of org.olat.course.assessment.EfficiencyStatement in project OpenOLAT by OpenOLAT.

the class EfficiencyStatementArtefactHandler method prefillArtefactAccordingToSource.

/**
 * @see org.olat.portfolio.EPAbstractHandler#prefillArtefactAccordingToSource(org.olat.portfolio.model.artefacts.AbstractArtefact, java.lang.Object)
 */
@Override
public void prefillArtefactAccordingToSource(AbstractArtefact artefact, Object source) {
    super.prefillArtefactAccordingToSource(artefact, source);
    if (source instanceof EfficiencyStatement) {
        EfficiencyStatement statement = (EfficiencyStatement) source;
        if (artefact.getTitle() == null) {
            artefact.setTitle(statement.getCourseTitle());
        }
        String efficiencyStatementX = myXStream.toXML(statement);
        artefact.setSource(statement.getCourseTitle());
        artefact.setFulltextContent(efficiencyStatementX);
        artefact.setSignature(90);
    }
}
Also used : EfficiencyStatement(org.olat.course.assessment.EfficiencyStatement)

Example 4 with EfficiencyStatement

use of org.olat.course.assessment.EfficiencyStatement in project OpenOLAT by OpenOLAT.

the class EfficiencyStatementWebService method putEfficiencyStatement.

/**
 * Create a new efficiency statement.
 *
 * @response.representation.200.doc If the statement was persisted
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @response.representation.404.doc The identity or the resource cannot be found
 * @param identityKey The owner of the certificate
 * @param resourceKey The primary key of the resource of the repository entry of the course.
 * @return Nothing special
 */
@PUT
@Path("{identityKey}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response putEfficiencyStatement(@PathParam("identityKey") Long identityKey, @PathParam("resourceKey") Long resourceKey, EfficiencyStatementVO efficiencyStatementVO, @Context HttpServletRequest request) {
    if (!isAdmin(request)) {
        return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    BaseSecurity baseSecurity = CoreSpringFactory.getImpl(BaseSecurity.class);
    Identity assessedIdentity = baseSecurity.loadIdentityByKey(identityKey);
    if (assessedIdentity == null) {
        return Response.serverError().status(Response.Status.NOT_FOUND).build();
    }
    EfficiencyStatementManager efficiencyStatementManager = CoreSpringFactory.getImpl(EfficiencyStatementManager.class);
    EfficiencyStatement efficiencyStatement = efficiencyStatementManager.getUserEfficiencyStatementByResourceKey(resourceKey, assessedIdentity);
    if (efficiencyStatement != null) {
        return Response.serverError().status(Response.Status.CONFLICT).build();
    }
    Date creationDate = efficiencyStatementVO.getCreationDate();
    Float score = efficiencyStatementVO.getScore();
    Boolean passed = efficiencyStatementVO.getPassed();
    OLATResourceManager resourceManager = CoreSpringFactory.getImpl(OLATResourceManager.class);
    OLATResource resource = resourceManager.findResourceById(resourceKey);
    if (resource == null) {
        String courseTitle = efficiencyStatementVO.getCourseTitle();
        efficiencyStatementManager.createStandAloneUserEfficiencyStatement(creationDate, score, passed, assessedIdentity, resourceKey, courseTitle);
    } else {
        efficiencyStatementManager.createUserEfficiencyStatement(creationDate, score, passed, assessedIdentity, resource);
    }
    return Response.ok().build();
}
Also used : EfficiencyStatementManager(org.olat.course.assessment.manager.EfficiencyStatementManager) OLATResourceManager(org.olat.resource.OLATResourceManager) OLATResource(org.olat.resource.OLATResource) Identity(org.olat.core.id.Identity) EfficiencyStatement(org.olat.course.assessment.EfficiencyStatement) UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) Date(java.util.Date) BaseSecurity(org.olat.basesecurity.BaseSecurity) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 5 with EfficiencyStatement

use of org.olat.course.assessment.EfficiencyStatement in project OpenOLAT by OpenOLAT.

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)

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