use of org.olat.course.assessment.EfficiencyStatement in project OpenOLAT by OpenOLAT.
the class EfficiencyStatementMediaHandler method getMediaController.
@Override
public Controller getMediaController(UserRequest ureq, WindowControl wControl, Media media, MediaRenderingHints hints) {
String statementXml = media.getContent();
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 ctrl = new CertificateAndEfficiencyStatementController(wControl, ureq, statement);
ctrl.disableMediaCollector();
return ctrl;
}
use of org.olat.course.assessment.EfficiencyStatement in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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 OpenOLAT.
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 OpenOLAT.
the class UserDetailsController method doOpenEfficiencyStatementController.
private CertificateAndEfficiencyStatementController doOpenEfficiencyStatementController(UserRequest ureq) {
if (statementCtrl == null || hasChanged) {
removeAsListenerAndDispose(statementCtrl);
RepositoryEntry entry = statementEntry.getCourse();
UserEfficiencyStatement statement = statementEntry.getUserEfficencyStatement();
EfficiencyStatement efficiencyStatement = null;
if (statement != null) {
RepositoryEntry re = statementEntry.getCourse();
efficiencyStatement = efficiencyStatementManager.getUserEfficiencyStatementByCourseRepositoryEntry(re, assessedIdentity);
}
statementCtrl = new CertificateAndEfficiencyStatementController(getWindowControl(), ureq, assessedIdentity, null, entry.getOlatResource().getKey(), entry, efficiencyStatement, true);
listenTo(statementCtrl);
hasChanged = false;
}
mainVC.put("segmentCmp", statementCtrl.getInitialComponent());
segmentView.select(efficiencyStatementLink);
return statementCtrl;
}
Aggregations