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