Search in sources :

Example 1 with UserEfficiencyStatementLight

use of org.olat.course.assessment.model.UserEfficiencyStatementLight in project OpenOLAT by OpenOLAT.

the class CertificateAndEfficiencyStatementListController method doDelete.

private void doDelete(Long efficiencyStatementKey) {
    UserEfficiencyStatementLight efficiencyStatement = esm.getUserEfficiencyStatementLightByKey(efficiencyStatementKey);
    if (efficiencyStatement != null) {
        esm.deleteEfficiencyStatement(efficiencyStatement);
    }
    loadModel();
    tableEl.reset();
    showInfo("info.efficiencyStatement.deleted");
}
Also used : UserEfficiencyStatementLight(org.olat.course.assessment.model.UserEfficiencyStatementLight)

Example 2 with UserEfficiencyStatementLight

use of org.olat.course.assessment.model.UserEfficiencyStatementLight in project OpenOLAT by OpenOLAT.

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);
}
Also used : HashMap(java.util.HashMap) CertificateAndEfficiencyStatement(org.olat.course.certificate.ui.CertificateAndEfficiencyStatementListModel.CertificateAndEfficiencyStatement) ArrayList(java.util.ArrayList) UserEfficiencyStatementLight(org.olat.course.assessment.model.UserEfficiencyStatementLight) CertificateLight(org.olat.course.certificate.CertificateLight)

Example 3 with UserEfficiencyStatementLight

use of org.olat.course.assessment.model.UserEfficiencyStatementLight in project openolat by klemens.

the class RepositoryEntryMyCourseQueries method searchViews.

public List<RepositoryEntryMyView> searchViews(SearchMyRepositoryEntryViewParams params, int firstResult, int maxResults) {
    if (params.getIdentity() == null) {
        log.error("No identity defined for query");
        return Collections.emptyList();
    }
    TypedQuery<Object[]> query = creatMyViewQuery(params, Object[].class);
    query.setFirstResult(firstResult);
    if (maxResults > 0) {
        query.setMaxResults(maxResults);
    }
    // we don't need statistics when rating and comments are disabled unless
    // were searching for videos, there we want to see the launch counter
    // from the statistics
    boolean needStats = repositoryModule.isRatingEnabled() || repositoryModule.isCommentEnabled() || (params.getResourceTypes() != null && params.getResourceTypes().contains(VideoFileResource.TYPE_NAME));
    List<Long> effKeys = new ArrayList<>();
    List<Object[]> objects = query.getResultList();
    List<RepositoryEntryMyView> views = new ArrayList<>(objects.size());
    Map<OLATResource, RepositoryEntryMyCourseImpl> viewsMap = new HashMap<>();
    for (Object[] object : objects) {
        RepositoryEntry re = (RepositoryEntry) object[0];
        Number numOfMarks = (Number) object[1];
        boolean hasMarks = numOfMarks == null ? false : numOfMarks.longValue() > 0;
        Number numOffers = (Number) object[2];
        long offers = numOffers == null ? 0l : numOffers.longValue();
        Integer myRating = (Integer) object[3];
        RepositoryEntryStatistics stats;
        if (needStats) {
            stats = re.getStatistics();
        } else {
            stats = null;
        }
        RepositoryEntryMyCourseImpl view = new RepositoryEntryMyCourseImpl(re, stats, hasMarks, offers, myRating);
        views.add(view);
        viewsMap.put(re.getOlatResource(), view);
        Long effKey = (Long) object[4];
        if (effKey != null) {
            effKeys.add(effKey);
        }
    }
    if (effKeys.size() > 0) {
        List<UserEfficiencyStatementLight> efficiencyStatements = efficiencyStatementManager.findEfficiencyStatementsLight(effKeys);
        for (UserEfficiencyStatementLight efficiencyStatement : efficiencyStatements) {
            if (viewsMap.containsKey(efficiencyStatement.getResource())) {
                viewsMap.get(efficiencyStatement.getResource()).setEfficiencyStatement(efficiencyStatement);
            }
        }
    }
    return views;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RepositoryEntryMyView(org.olat.repository.RepositoryEntryMyView) OLATResource(org.olat.resource.OLATResource) UserEfficiencyStatementLight(org.olat.course.assessment.model.UserEfficiencyStatementLight) RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryEntryStatistics(org.olat.repository.model.RepositoryEntryStatistics) RepositoryEntryMyCourseImpl(org.olat.repository.model.RepositoryEntryMyCourseImpl)

Example 4 with UserEfficiencyStatementLight

use of org.olat.course.assessment.model.UserEfficiencyStatementLight in project openolat by klemens.

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();
}
Also used : UserEfficiencyStatementLight(org.olat.course.assessment.model.UserEfficiencyStatementLight) ICourse(org.olat.course.ICourse) STCourseNode(org.olat.course.nodes.STCourseNode) GTACourseNode(org.olat.course.nodes.GTACourseNode) MSCourseNode(org.olat.course.nodes.MSCourseNode) ScormCourseNode(org.olat.course.nodes.ScormCourseNode) CourseNode(org.olat.course.nodes.CourseNode) PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) BasicLTICourseNode(org.olat.course.nodes.BasicLTICourseNode) Identity(org.olat.core.id.Identity) TransientIdentity(org.olat.admin.user.imp.TransientIdentity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) BigDecimal(java.math.BigDecimal) CorruptedCourseException(org.olat.course.CorruptedCourseException) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) HashSet(java.util.HashSet)

Example 5 with UserEfficiencyStatementLight

use of org.olat.course.assessment.model.UserEfficiencyStatementLight in project openolat by klemens.

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);
            // 
            }
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) PopupBrowserWindow(org.olat.core.gui.control.generic.popup.PopupBrowserWindow) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) UserEfficiencyStatementLight(org.olat.course.assessment.model.UserEfficiencyStatementLight) CertificateAndEfficiencyStatementController(org.olat.course.certificate.ui.CertificateAndEfficiencyStatementController) WindowControl(org.olat.core.gui.control.WindowControl) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) UserRequest(org.olat.core.gui.UserRequest)

Aggregations

UserEfficiencyStatementLight (org.olat.course.assessment.model.UserEfficiencyStatementLight)14 Identity (org.olat.core.id.Identity)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 ICourse (org.olat.course.ICourse)4 UserEfficiencyStatement (org.olat.course.assessment.UserEfficiencyStatement)4 CoachingLargeTest (org.olat.modules.coach.CoachingLargeTest)4 BigDecimal (java.math.BigDecimal)2 HashSet (java.util.HashSet)2 TransientIdentity (org.olat.admin.user.imp.TransientIdentity)2 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)2 UserRequest (org.olat.core.gui.UserRequest)2 TableEvent (org.olat.core.gui.components.table.TableEvent)2 WindowControl (org.olat.core.gui.control.WindowControl)2 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)2 PopupBrowserWindow (org.olat.core.gui.control.generic.popup.PopupBrowserWindow)2 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)2