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();
}
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);
}
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);
}
}
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;
}
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();
}
Aggregations