Search in sources :

Example 16 with EfficiencyStatement

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

the class OLATUpgrade_8_1_0 method createStatement.

private void createStatement(Property property) {
    String repoKeyStr = property.getName();
    Long repoKey = new Long(repoKeyStr);
    RepositoryEntry re = repositoryManager.lookupRepositoryEntry(repoKey, false);
    UserEfficiencyStatementImpl impl = efficiencyStatementManager.getUserEfficiencyStatementFull(re, property.getIdentity());
    if (impl != null) {
        return;
    }
    UserEfficiencyStatementImpl statement = new UserEfficiencyStatementImpl();
    statement.setIdentity(property.getIdentity());
    statement.setStatementXml(property.getTextValue());
    if (re != null) {
        statement.setResource(re.getOlatResource());
        statement.setCourseRepoKey(re.getKey());
    }
    EfficiencyStatement s = (EfficiencyStatement) XStreamHelper.createXStreamInstance().fromXML(property.getTextValue());
    efficiencyStatementManager.fillEfficiencyStatement(s, null, statement);
    statement.setLastModified(property.getLastModified());
    dbInstance.saveObject(statement);
    dbInstance.commitAndCloseSession();
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) UserEfficiencyStatementImpl(org.olat.course.assessment.model.UserEfficiencyStatementImpl) EfficiencyStatement(org.olat.course.assessment.EfficiencyStatement)

Example 17 with EfficiencyStatement

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

the class EfficiencyStatementArtefactHandler method createDetailsController.

@Override
public Controller createDetailsController(UserRequest ureq, WindowControl wControl, AbstractArtefact artefact, boolean readOnlyMode) {
    EPFrontendManager ePFMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
    String statementXml = ePFMgr.getArtefactFullTextContent(artefact);
    EfficiencyStatement statement = null;
    if (StringHelper.containsNonWhitespace(statementXml)) {
        try {
            statement = (EfficiencyStatement) myXStream.fromXML(statementXml);
        } catch (Exception e) {
            log.error("Cannot load efficiency statement from artefact", e);
        }
    }
    CertificateAndEfficiencyStatementController efficiencyCtrl = new CertificateAndEfficiencyStatementController(wControl, ureq, statement);
    return new LayoutMain3ColsController(ureq, wControl, efficiencyCtrl);
}
Also used : LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) CertificateAndEfficiencyStatementController(org.olat.course.certificate.ui.CertificateAndEfficiencyStatementController) EfficiencyStatement(org.olat.course.assessment.EfficiencyStatement) EPFrontendManager(org.olat.portfolio.manager.EPFrontendManager)

Example 18 with EfficiencyStatement

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

the class EfficiencyStatementArtefactHandler method getContent.

@Override
protected void getContent(AbstractArtefact artefact, StringBuilder sb, SearchResourceContext context, EPFrontendManager ePFManager) {
    String statementXml = ePFManager.getArtefactFullTextContent(artefact);
    if (!StringHelper.containsNonWhitespace(statementXml))
        return;
    try {
        EfficiencyStatement statement = (EfficiencyStatement) myXStream.fromXML(statementXml);
        sb.append(statement.getCourseTitle()).append(' ');
        sb.append(statement.getDisplayableUserInfo()).append(' ');
    } catch (Exception ex) {
        log.error("Error while parsing " + artefact, ex);
    }
}
Also used : EfficiencyStatement(org.olat.course.assessment.EfficiencyStatement)

Example 19 with EfficiencyStatement

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

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

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

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)

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