Search in sources :

Example 1 with AssessedBusinessGroup

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

the class AssessmentToolManagerImpl method getBusinessGroupStatistics.

@Override
public List<AssessedBusinessGroup> getBusinessGroupStatistics(Identity coach, SearchAssessedIdentityParams params) {
    RepositoryEntry courseEntry = params.getEntry();
    StringBuilder sf = new StringBuilder();
    sf.append("select bgi.key, bgi.name, baseGroup.key,").append(" avg(aentry.score) as scoreAverage,").append(" sum(case when aentry.passed=true then 1 else 0 end) as numOfPassed,").append(" sum(case when aentry.passed=false then 1 else 0 end) as numOfFailed,").append(" sum(case when (aentry.status is null or not(aentry.status='").append(AssessmentEntryStatus.notStarted.name()).append("') or aentry.passed is null) then 1 else 0 end) as numOfNotAttempted,").append(" (select count(gmember.key) from bgroupmember as gmember").append("   where gmember.group.key=baseGroup.key and gmember.role='").append(GroupRoles.participant.name()).append("'").append(" ) as numOfParticipants").append(" from businessgroup as bgi").append(" inner join bgi.baseGroup as baseGroup").append(" inner join repoentrytogroup as rel on (rel.group.key=bgi.baseGroup.key and rel.entry.key=:repoEntryKey)").append(" left join baseGroup.members as bmember on (bmember.role='").append(GroupRoles.participant.name()).append("')").append(" left join assessmententry as aentry on (bmember.identity.key=aentry.identity.key and rel.entry.key = aentry.repositoryEntry.key)");
    boolean where = false;
    if (!params.isAdmin()) {
        where = PersistenceHelper.appendAnd(sf, where);
        sf.append(" bgi.key in (:groupKeys)");
    }
    if (params.getSubIdent() != null) {
        where = PersistenceHelper.appendAnd(sf, where);
        sf.append(" aentry.subIdent=:subIdent");
    }
    if (params.getReferenceEntry() != null) {
        where = PersistenceHelper.appendAnd(sf, where);
        sf.append(" aentry.referenceEntry.key=:referenceKey");
    }
    sf.append(" group by bgi.key, bgi.name, baseGroup.key");
    TypedQuery<Object[]> stats = dbInstance.getCurrentEntityManager().createQuery(sf.toString(), Object[].class).setParameter("repoEntryKey", courseEntry.getKey());
    if (!params.isAdmin()) {
        stats.setParameter("groupKeys", params.getBusinessGroupKeys());
    }
    if (params.getSubIdent() != null) {
        stats.setParameter("subIdent", params.getSubIdent());
    }
    if (params.getReferenceEntry() != null) {
        stats.setParameter("referenceKey", params.getReferenceEntry().getKey());
    }
    List<Object[]> results = stats.getResultList();
    List<AssessedBusinessGroup> rows = new ArrayList<>(results.size());
    for (Object[] result : results) {
        Long key = (Long) result[0];
        String name = (String) result[1];
        double averageScore = result[3] == null ? 0.0d : ((Number) result[3]).doubleValue();
        int numOfPassed = result[4] == null ? 0 : ((Number) result[4]).intValue();
        int numOfFailed = result[5] == null ? 0 : ((Number) result[5]).intValue();
        int numOfNotAttempted = result[6] == null ? 0 : ((Number) result[6]).intValue();
        int numOfParticipants = result[7] == null ? 0 : ((Number) result[7]).intValue();
        rows.add(new AssessedBusinessGroup(key, name, averageScore, numOfPassed, numOfFailed, numOfNotAttempted, numOfParticipants));
    }
    return rows;
}
Also used : ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) AssessedBusinessGroup(org.olat.course.assessment.model.AssessedBusinessGroup)

Example 2 with AssessedBusinessGroup

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

the class AssessedBusinessGroupCourseNodeListController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (tableEl == source) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            String cmd = se.getCommand();
            AssessedBusinessGroup row = tableModel.getObject(se.getIndex());
            if ("select".equals(cmd)) {
                doSelect(ureq, row);
            }
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) AssessedBusinessGroup(org.olat.course.assessment.model.AssessedBusinessGroup)

Example 3 with AssessedBusinessGroup

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

the class AssessmentToolManagerImpl method getBusinessGroupStatistics.

@Override
public List<AssessedBusinessGroup> getBusinessGroupStatistics(Identity coach, SearchAssessedIdentityParams params) {
    RepositoryEntry courseEntry = params.getEntry();
    StringBuilder sf = new StringBuilder();
    sf.append("select bgi.key, bgi.name, baseGroup.key,").append(" avg(aentry.score) as scoreAverage,").append(" sum(case when aentry.passed=true then 1 else 0 end) as numOfPassed,").append(" sum(case when aentry.passed=false then 1 else 0 end) as numOfFailed,").append(" sum(case when (aentry.status is null or not(aentry.status='").append(AssessmentEntryStatus.notStarted.name()).append("') or aentry.passed is null) then 1 else 0 end) as numOfNotAttempted,").append(" (select count(gmember.key) from bgroupmember as gmember").append("   where gmember.group.key=baseGroup.key and gmember.role='").append(GroupRoles.participant.name()).append("'").append(" ) as numOfParticipants").append(" from businessgroup as bgi").append(" inner join bgi.baseGroup as baseGroup").append(" inner join repoentrytogroup as rel on (rel.group.key=bgi.baseGroup.key and rel.entry.key=:repoEntryKey)").append(" left join baseGroup.members as bmember on (bmember.role='").append(GroupRoles.participant.name()).append("')").append(" left join assessmententry as aentry on (bmember.identity.key=aentry.identity.key and rel.entry.key = aentry.repositoryEntry.key)");
    boolean where = false;
    if (!params.isAdmin()) {
        where = PersistenceHelper.appendAnd(sf, where);
        sf.append(" bgi.key in (:groupKeys)");
    }
    if (params.getSubIdent() != null) {
        where = PersistenceHelper.appendAnd(sf, where);
        sf.append(" aentry.subIdent=:subIdent");
    }
    if (params.getReferenceEntry() != null) {
        where = PersistenceHelper.appendAnd(sf, where);
        sf.append(" aentry.referenceEntry.key=:referenceKey");
    }
    sf.append(" group by bgi.key, bgi.name, baseGroup.key");
    TypedQuery<Object[]> stats = dbInstance.getCurrentEntityManager().createQuery(sf.toString(), Object[].class).setParameter("repoEntryKey", courseEntry.getKey());
    if (!params.isAdmin()) {
        stats.setParameter("groupKeys", params.getBusinessGroupKeys());
    }
    if (params.getSubIdent() != null) {
        stats.setParameter("subIdent", params.getSubIdent());
    }
    if (params.getReferenceEntry() != null) {
        stats.setParameter("referenceKey", params.getReferenceEntry().getKey());
    }
    List<Object[]> results = stats.getResultList();
    List<AssessedBusinessGroup> rows = new ArrayList<>(results.size());
    for (Object[] result : results) {
        Long key = (Long) result[0];
        String name = (String) result[1];
        double averageScore = result[3] == null ? 0.0d : ((Number) result[3]).doubleValue();
        int numOfPassed = result[4] == null ? 0 : ((Number) result[4]).intValue();
        int numOfFailed = result[5] == null ? 0 : ((Number) result[5]).intValue();
        int numOfNotAttempted = result[6] == null ? 0 : ((Number) result[6]).intValue();
        int numOfParticipants = result[7] == null ? 0 : ((Number) result[7]).intValue();
        rows.add(new AssessedBusinessGroup(key, name, averageScore, numOfPassed, numOfFailed, numOfNotAttempted, numOfParticipants));
    }
    return rows;
}
Also used : ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) AssessedBusinessGroup(org.olat.course.assessment.model.AssessedBusinessGroup)

Example 4 with AssessedBusinessGroup

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

the class AssessedBusinessGroupCourseNodeListController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (tableEl == source) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            String cmd = se.getCommand();
            AssessedBusinessGroup row = tableModel.getObject(se.getIndex());
            if ("select".equals(cmd)) {
                doSelect(ureq, row);
            }
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) AssessedBusinessGroup(org.olat.course.assessment.model.AssessedBusinessGroup)

Example 5 with AssessedBusinessGroup

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

the class AssessedBusinessGroupCourseNodeListController method loadModel.

protected void loadModel() {
    if (assessmentCallback.canAssessBusinessGoupMembers()) {
        RepositoryEntry testEntry = null;
        if (courseNode.needsReferenceToARepositoryEntry()) {
            testEntry = courseNode.getReferencedRepositoryEntry();
        }
        SearchAssessedIdentityParams params = new SearchAssessedIdentityParams(courseEntry, courseNode.getIdent(), testEntry, assessmentCallback);
        if (assessmentCallback.getCoachedGroups() != null) {
            List<Long> groupKeys = assessmentCallback.getCoachedGroups().stream().map(c -> c.getKey()).collect(Collectors.toList());
            params.setBusinessGroupKeys(groupKeys);
        }
        List<AssessedBusinessGroup> rows = assessmentToolManager.getBusinessGroupStatistics(getIdentity(), params);
        Set<Long> keys = rows.stream().map(c -> c.getKey()).collect(Collectors.toSet());
        List<BusinessGroup> groups;
        if (assessmentCallback.isAdmin()) {
            CourseEnvironment courseEnv = CourseFactory.loadCourse(courseEntry).getCourseEnvironment();
            groups = courseEnv.getCourseGroupManager().getAllBusinessGroups();
        } else if (assessmentCallback.getCoachedGroups() != null) {
            groups = assessmentCallback.getCoachedGroups();
        } else {
            groups = Collections.emptyList();
        }
        for (BusinessGroup group : groups) {
            if (!keys.contains(group.getKey())) {
                rows.add(new AssessedBusinessGroup(group.getKey(), group.getName(), 0.0d, 0, 0, 0, 0));
            }
        }
        tableModel.setObjects(rows);
        tableEl.reset();
        tableEl.reloadData();
    }
}
Also used : FlexiTableElement(org.olat.core.gui.components.form.flexible.elements.FlexiTableElement) Util(org.olat.core.util.Util) TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) AssessmentToolManager(org.olat.course.assessment.AssessmentToolManager) FormEvent(org.olat.core.gui.components.form.flexible.impl.FormEvent) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) Autowired(org.springframework.beans.factory.annotation.Autowired) CourseFactory(org.olat.course.CourseFactory) CourseNode(org.olat.course.nodes.CourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry) AssessmentToolSecurityCallback(org.olat.modules.assessment.ui.AssessmentToolSecurityCallback) FormItem(org.olat.core.gui.components.form.flexible.FormItem) CourseNodeFactory(org.olat.course.nodes.CourseNodeFactory) Event(org.olat.core.gui.control.Event) OLATResourceable(org.olat.core.id.OLATResourceable) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer) ContextEntry(org.olat.core.id.context.ContextEntry) OresHelper(org.olat.core.util.resource.OresHelper) SortKey(org.olat.core.commons.persistence.SortKey) ScoreCellRenderer(org.olat.modules.assessment.ui.ScoreCellRenderer) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) StateEntry(org.olat.core.id.context.StateEntry) ABGCols(org.olat.course.assessment.ui.tool.AssessedBusinessGroupTableModel.ABGCols) FlexiTableDataModelFactory(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableDataModelFactory) BusinessGroupService(org.olat.group.BusinessGroupService) AssessmentModule(org.olat.course.assessment.AssessmentModule) ProgressRenderer(org.olat.modules.coach.ui.ProgressRenderer) CourseNodeEvent(org.olat.course.assessment.ui.tool.event.CourseNodeEvent) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) WindowControl(org.olat.core.gui.control.WindowControl) Set(java.util.Set) Collectors(java.util.stream.Collectors) Controller(org.olat.core.gui.control.Controller) BusinessControlFactory(org.olat.core.id.context.BusinessControlFactory) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) SearchAssessedIdentityParams(org.olat.course.assessment.model.SearchAssessedIdentityParams) List(java.util.List) AssessmentToolContainer(org.olat.modules.assessment.ui.AssessmentToolContainer) BusinessGroup(org.olat.group.BusinessGroup) FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) UserRequest(org.olat.core.gui.UserRequest) Collections(java.util.Collections) AssessedBusinessGroup(org.olat.course.assessment.model.AssessedBusinessGroup) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) BusinessGroup(org.olat.group.BusinessGroup) AssessedBusinessGroup(org.olat.course.assessment.model.AssessedBusinessGroup) SearchAssessedIdentityParams(org.olat.course.assessment.model.SearchAssessedIdentityParams) AssessedBusinessGroup(org.olat.course.assessment.model.AssessedBusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry)

Aggregations

AssessedBusinessGroup (org.olat.course.assessment.model.AssessedBusinessGroup)8 RepositoryEntry (org.olat.repository.RepositoryEntry)6 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)4 SearchAssessedIdentityParams (org.olat.course.assessment.model.SearchAssessedIdentityParams)4 BusinessGroup (org.olat.group.BusinessGroup)4 AssessmentToolSecurityCallback (org.olat.modules.assessment.ui.AssessmentToolSecurityCallback)4 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 List (java.util.List)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Test (org.junit.Test)2 IdentityShort (org.olat.basesecurity.IdentityShort)2 SortKey (org.olat.core.commons.persistence.SortKey)2 UserRequest (org.olat.core.gui.UserRequest)2 FormItem (org.olat.core.gui.components.form.flexible.FormItem)2 FormItemContainer (org.olat.core.gui.components.form.flexible.FormItemContainer)2 FlexiTableElement (org.olat.core.gui.components.form.flexible.elements.FlexiTableElement)2 FlexiTableSortOptions (org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions)2 FormBasicController (org.olat.core.gui.components.form.flexible.impl.FormBasicController)2