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