use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class IdentityListCourseNodeController method doOpenTools.
private void doOpenTools(UserRequest ureq, AssessedIdentityElementRow row, FormLink link) {
removeAsListenerAndDispose(toolsCtrl);
removeAsListenerAndDispose(toolsCalloutCtrl);
Identity assessedIdentity = securityManager.loadIdentityByKey(row.getIdentityKey());
toolsCtrl = createCalloutController(ureq, assessedIdentity);
listenTo(toolsCtrl);
toolsCalloutCtrl = new CloseableCalloutWindowController(ureq, getWindowControl(), toolsCtrl.getInitialComponent(), link.getFormDispatchId(), "", true, "");
listenTo(toolsCalloutCtrl);
toolsCalloutCtrl.activate();
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class IdentityListCourseNodeController method loadModel.
protected void loadModel(@SuppressWarnings("unused") UserRequest ureq) {
SearchAssessedIdentityParams params = getSearchParameters();
List<Identity> assessedIdentities = assessmentToolManager.getAssessedIdentities(getIdentity(), params);
List<AssessmentEntry> assessmentEntries = assessmentToolManager.getAssessmentEntries(getIdentity(), params, null);
Map<Long, AssessmentEntry> entryMap = new HashMap<>();
assessmentEntries.stream().filter(entry -> entry.getIdentity() != null).forEach((entry) -> entryMap.put(entry.getIdentity().getKey(), entry));
List<AssessedIdentityElementRow> rows = new ArrayList<>(assessedIdentities.size());
for (Identity assessedIdentity : assessedIdentities) {
AssessmentEntry entry = entryMap.get(assessedIdentity.getKey());
CompletionItem currentCompletion = new CompletionItem("current-completion-" + (++counter), getLocale());
if (entry != null) {
currentCompletion.setCompletion(entry.getCurrentRunCompletion());
AssessmentRunStatus status = entry.getCurrentRunStatus();
currentCompletion.setEnded(status != null && AssessmentRunStatus.done.equals(status));
}
FormLink toolsLink = uifactory.addFormLink("tools_" + (++counter), "tools", "", null, null, Link.NONTRANSLATED);
toolsLink.setIconLeftCSS("o_icon o_icon_actions o_icon-lg");
AssessedIdentityElementRow row = new AssessedIdentityElementRow(assessedIdentity, entry, currentCompletion, toolsLink, userPropertyHandlers, getLocale());
toolsLink.setUserObject(row);
rows.add(row);
}
usersTableModel.setObjects(rows);
List<FlexiTableFilter> filters = tableEl.getSelectedFilters();
if (filters != null && filters.size() > 0 && filters.get(0) != null) {
usersTableModel.filter(Collections.singletonList(filters.get(0)));
}
tableEl.reset();
tableEl.reloadData();
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class CertificationWebService method deleteCertificateInfo.
@DELETE
@Path("{identityKey}")
public Response deleteCertificateInfo(@PathParam("identityKey") Long identityKey, @PathParam("resourceKey") Long resourceKey, @Context HttpServletRequest request) {
if (!isAdmin(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
CertificatesManager certificatesManager = CoreSpringFactory.getImpl(CertificatesManager.class);
BaseSecurity baseSecurity = CoreSpringFactory.getImpl(BaseSecurity.class);
Identity identity = baseSecurity.loadIdentityByKey(identityKey);
if (identity == null) {
return Response.serverError().status(Response.Status.NOT_FOUND).build();
}
OLATResourceable courseOres = OresHelper.createOLATResourceableInstance("CourseModule", resourceKey);
OLATResourceManager resourceManager = CoreSpringFactory.getImpl(OLATResourceManager.class);
OLATResource resource = resourceManager.findResourceable(courseOres);
if (resource == null) {
resource = resourceManager.findResourceById(resourceKey);
}
if (resource == null) {
return Response.serverError().status(Response.Status.NOT_FOUND).build();
}
Certificate certificate = certificatesManager.getLastCertificate(identity, resource.getKey());
if (certificate == null) {
return Response.serverError().status(Response.Status.NOT_FOUND).build();
}
certificatesManager.deleteCertificate(certificate);
return Response.ok().build();
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class CertificationWebService method getCertificateInfo.
@HEAD
@Path("{identityKey}")
@Produces({ "application/pdf" })
public Response getCertificateInfo(@PathParam("identityKey") Long identityKey, @PathParam("resourceKey") Long resourceKey, @Context HttpServletRequest request) {
if (!isAdmin(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
CertificatesManager certificatesManager = CoreSpringFactory.getImpl(CertificatesManager.class);
BaseSecurity baseSecurity = CoreSpringFactory.getImpl(BaseSecurity.class);
Identity identity = baseSecurity.loadIdentityByKey(identityKey);
if (identity == null) {
return Response.serverError().status(Response.Status.NOT_FOUND).build();
}
OLATResourceable courseOres = OresHelper.createOLATResourceableInstance("CourseModule", resourceKey);
OLATResourceManager resourceManager = CoreSpringFactory.getImpl(OLATResourceManager.class);
OLATResource resource = resourceManager.findResourceable(courseOres);
if (resource == null) {
resource = resourceManager.findResourceById(resourceKey);
}
if (resource == null) {
return Response.serverError().status(Response.Status.NOT_FOUND).build();
}
Certificate certificate = certificatesManager.getLastCertificate(identity, resource.getKey());
if (certificate == null) {
return Response.serverError().status(Response.Status.NOT_FOUND).build();
}
VFSLeaf certificateFile = certificatesManager.getCertificateLeaf(certificate);
if (certificateFile == null || !certificateFile.exists()) {
return Response.serverError().status(Response.Status.NOT_FOUND).build();
}
return Response.ok().build();
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class CertificatesSelectionController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
;
int colPos = 0;
if (isAdministrativeUser) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.name", CertificatesSelectionDataModel.USERNAME_COL));
}
List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(AssessedIdentitiesTableDataModel.usageIdentifyer, isAdministrativeUser);
List<UserPropertyHandler> resultingPropertyHandlers = new ArrayList<UserPropertyHandler>();
// followed by the users fields
for (int i = 0; i < userPropertyHandlers.size(); i++) {
UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
boolean visible = userManager.isMandatoryUserProperty(AssessedIdentitiesTableDataModel.usageIdentifyer, userPropertyHandler);
resultingPropertyHandlers.add(userPropertyHandler);
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos++, false, null));
}
if (hasAssessableNodes) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.passed", CertificatesSelectionDataModel.PASSED_COL, new PassedCellRenderer()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.score", CertificatesSelectionDataModel.SCORE_COL));
}
tableModel = new CertificatesSelectionDataModel(columnsModel, resultingPropertyHandlers);
Set<Integer> preselectedRows = new HashSet<>();
ICourse course = CourseFactory.loadCourse(courseEntry);
CourseNode rootNode = course.getRunStructure().getRootNode();
List<CertificateInfos> infos = new ArrayList<>(datas.size());
int count = 0;
for (AssessedIdentityWrapper data : datas) {
ScoreEvaluation scoreEval = data.getUserCourseEnvironment().getScoreAccounting().getScoreEvaluation(rootNode);
Float score = scoreEval == null ? null : scoreEval.getScore();
Boolean passed = scoreEval == null ? null : scoreEval.getPassed();
Identity assessedIdentity = data.getIdentity();
infos.add(new CertificateInfos(assessedIdentity, score, passed));
if (passed != null && passed.booleanValue()) {
preselectedRows.add(new Integer(count));
}
count++;
}
tableModel.setObjects(infos);
tableEl = uifactory.addTableElement(getWindowControl(), "selection", tableModel, getTranslator(), formLayout);
tableEl.setMultiSelect(true);
tableEl.setSelectAllEnable(true);
tableEl.setMultiSelectedIndex(preselectedRows);
}
Aggregations