use of org.olat.course.assessment.model.UserEfficiencyStatementLight in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_11_0_0 method convertUserEfficiencyStatemen.
private void convertUserEfficiencyStatemen(RepositoryEntry courseEntry) {
try {
final ICourse course = CourseFactory.loadCourse(courseEntry);
CourseNode rootNode = course.getRunStructure().getRootNode();
Set<Long> identityKeys = new HashSet<>(loadIdentityKeyOfAssessmentEntries(courseEntry, rootNode.getIdent()));
int count = 0;
List<UserEfficiencyStatementLight> statements = getUserEfficiencyStatements(courseEntry);
for (UserEfficiencyStatementLight statement : statements) {
Identity identity = statement.getIdentity();
if (!identityKeys.contains(identity.getKey())) {
AssessmentEntry entry = createAssessmentEntry(identity, null, course, courseEntry, rootNode.getIdent());
if (statement.getScore() != null) {
entry.setScore(new BigDecimal(statement.getScore()));
}
if (statement.getPassed() != null) {
entry.setPassed(statement.getPassed());
}
dbInstance.getCurrentEntityManager().persist(entry);
if (count++ % 25 == 0) {
dbInstance.commitAndCloseSession();
}
}
}
} catch (Exception e) {
log.error("Error with " + courseEntry.getKey() + " " + courseEntry, e);
}
dbInstance.commitAndCloseSession();
}
use of org.olat.course.assessment.model.UserEfficiencyStatementLight in project OpenOLAT by OpenOLAT.
the class EfficiencyStatementsPortletRunController method event.
/**
* @see org.olat.core.gui.control.ControllerEventListener#dispatchEvent(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
public void event(UserRequest ureq, Controller source, Event event) {
super.event(ureq, source, event);
if (source == tableCtr) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent te = (TableEvent) event;
String actionid = te.getActionId();
if (actionid.equals(CMD_LAUNCH)) {
int rowid = te.getRowId();
final UserEfficiencyStatementLight statement = efficiencyStatementsListModel.getEfficiencyStatementAt(rowid);
// will not be disposed on course run dispose, popus up as new browserwindow
ControllerCreator ctrlCreator = new ControllerCreator() {
public Controller createController(UserRequest lureq, WindowControl lwControl) {
CertificateAndEfficiencyStatementController efficiencyCtrl = new CertificateAndEfficiencyStatementController(lwControl, lureq, statement.getArchivedResourceKey());
return new LayoutMain3ColsController(lureq, getWindowControl(), efficiencyCtrl);
}
};
// wrap the content controller into a full header layout
ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, ctrlCreator);
// open in new browser window
PopupBrowserWindow pbw = getWindowControl().getWindowBackOffice().getWindowManager().createNewPopupBrowserWindowFor(ureq, layoutCtrlr);
pbw.open(ureq);
//
}
}
}
}
use of org.olat.course.assessment.model.UserEfficiencyStatementLight in project openolat by klemens.
the class EfficiencyStatementManagerTest method testEfficiencyStatement.
/**
* Create and reload an efficiency statement.
*
* @throws URISyntaxException
*/
@Test
public void testEfficiencyStatement() throws URISyntaxException {
RepositoryEntry re = deployTestcourse();
ICourse course = CourseFactory.loadCourse(re);
// add some members
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("Eff-Part-1");
repositoryService.addRole(participant, re, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// make statements
UserEfficiencyStatement statement = effManager.createUserEfficiencyStatement(new Date(), 6.0f, true, participant, re.getOlatResource());
dbInstance.commitAndCloseSession();
// load the efficiency statements
List<UserEfficiencyStatementLight> statementsLight = effManager.findEfficiencyStatementsLight(participant);
Assert.assertNotNull(statementsLight);
Assert.assertEquals(1, statementsLight.size());
UserEfficiencyStatementLight statementLight = statementsLight.get(0);
Assert.assertEquals(statement.getKey(), statementLight.getKey());
Assert.assertEquals(participant, statementLight.getIdentity());
Assert.assertEquals(statement.getCourseRepoKey(), statementLight.getCourseRepoKey());
Assert.assertEquals(re.getKey(), statementLight.getCourseRepoKey());
Assert.assertEquals(course.getCourseTitle(), statementLight.getShortTitle());
Assert.assertEquals(re.getOlatResource(), statementLight.getResource());
Assert.assertEquals(re.getOlatResource().getKey(), statementLight.getArchivedResourceKey());
Assert.assertNotNull(statementLight.getCreationDate());
Assert.assertNotNull(statementLight.getLastModified());
Assert.assertTrue(statementLight.getPassed());
Assert.assertEquals(6.0f, statementLight.getScore(), 0.00001);
}
use of org.olat.course.assessment.model.UserEfficiencyStatementLight in project openolat by klemens.
the class CertificateAndEfficiencyStatementListController method loadModel.
private void loadModel() {
Map<Long, CertificateAndEfficiencyStatement> resourceKeyToStatments = new HashMap<>();
List<CertificateAndEfficiencyStatement> statments = new ArrayList<>();
List<UserEfficiencyStatementLight> efficiencyStatementsList = esm.findEfficiencyStatementsLight(assessedIdentity);
for (UserEfficiencyStatementLight efficiencyStatement : efficiencyStatementsList) {
CertificateAndEfficiencyStatement wrapper = new CertificateAndEfficiencyStatement();
wrapper.setDisplayName(efficiencyStatement.getShortTitle());
wrapper.setPassed(efficiencyStatement.getPassed());
wrapper.setScore(efficiencyStatement.getScore());
wrapper.setEfficiencyStatementKey(efficiencyStatement.getKey());
wrapper.setResourceKey(efficiencyStatement.getArchivedResourceKey());
wrapper.setLastModified(efficiencyStatement.getLastModified());
statments.add(wrapper);
resourceKeyToStatments.put(efficiencyStatement.getArchivedResourceKey(), wrapper);
}
List<CertificateLight> certificates = certificatesManager.getLastCertificates(assessedIdentity);
for (CertificateLight certificate : certificates) {
Long resourceKey = certificate.getOlatResourceKey();
CertificateAndEfficiencyStatement wrapper = resourceKeyToStatments.get(resourceKey);
if (wrapper == null) {
wrapper = new CertificateAndEfficiencyStatement();
wrapper.setDisplayName(certificate.getCourseTitle());
resourceKeyToStatments.put(resourceKey, wrapper);
statments.add(wrapper);
} else {
if (!StringHelper.containsNonWhitespace(wrapper.getDisplayName())) {
wrapper.setDisplayName(certificate.getCourseTitle());
}
wrapper.setResourceKey(resourceKey);
}
if (resourceKey != null && wrapper.getResourceKey() == null) {
wrapper.setResourceKey(resourceKey);
}
wrapper.setCertificate(certificate);
}
for (CertificateAndEfficiencyStatement statment : statments) {
if (!StringHelper.containsNonWhitespace(statment.getDisplayName()) && statment.getResourceKey() != null) {
String displayName = repositoryManager.lookupDisplayNameByResourceKey(statment.getResourceKey());
statment.setDisplayName(displayName);
}
}
tableModel.setObjects(statments);
}
Aggregations