Search in sources :

Example 6 with AssessedBusinessGroup

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

the class AssessmentToolManagerTest method assessmentTool_coach.

@Test
public void assessmentTool_coach() {
    // course
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-author-1");
    ICourse course = CoursesWebService.createEmptyCourse(author, "course-assessment-tool", "course long name", null);
    // members as participant and coach
    Identity assessedIdentity1 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-1");
    Identity assessedIdentity2 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-2");
    Identity assessedIdentity3 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-3");
    Identity assessedIdentity4 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-4");
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-coach-1");
    RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    RepositoryEntry refEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    String subIdent = UUID.randomUUID().toString();
    BusinessGroup group1 = businessGroupDao.createAndPersist(null, "assessment-tool-bg-1", "assessment-tool-bg-1-desc", -1, -1, false, false, false, false, false);
    businessGroupRelationDao.addRelationToResource(group1, entry);
    BusinessGroup group2 = businessGroupDao.createAndPersist(null, "assessment-tool-bg-2", "assessment-tool-bg-2-desc", -1, -1, false, false, false, false, false);
    businessGroupRelationDao.addRelationToResource(group2, entry);
    businessGroupRelationDao.addRole(assessedIdentity1, group1, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(assessedIdentity2, group1, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(assessedIdentity3, group2, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(coach, group1, GroupRoles.coach.name());
    dbInstance.commitAndCloseSession();
    // some datas
    assessmentEntryDao.createAssessmentEntry(assessedIdentity1, null, entry, subIdent, refEntry, 3.0f, Boolean.FALSE, null, null);
    assessmentEntryDao.createAssessmentEntry(assessedIdentity2, null, entry, subIdent, refEntry, 5.0f, Boolean.TRUE, null, null);
    assessmentEntryDao.createAssessmentEntry(assessedIdentity3, null, entry, subIdent, refEntry, 8.0f, Boolean.TRUE, null, null);
    assessmentEntryDao.createAssessmentEntry(assessedIdentity4, null, entry, subIdent, refEntry, 9.0f, Boolean.TRUE, null, null);
    assessmentEntryDao.createAssessmentEntry(null, UUID.randomUUID().toString(), entry, subIdent, refEntry);
    dbInstance.commitAndCloseSession();
    // coach of group 1 with id 1 and id2
    List<BusinessGroup> coachedGroups = Collections.singletonList(group1);
    AssessmentToolSecurityCallback assessmentCallback = new AssessmentToolSecurityCallback(false, false, false, true, coachedGroups);
    SearchAssessedIdentityParams params = new SearchAssessedIdentityParams(entry, subIdent, refEntry, assessmentCallback);
    // statistics
    AssessmentStatistics statistics = assessmentToolManager.getStatistics(coach, params);
    Assert.assertEquals(4.0d, statistics.getAverageScore().doubleValue(), 0.0001);
    Assert.assertEquals(1, statistics.getCountFailed());
    Assert.assertEquals(1, statistics.getCountPassed());
    // check assessed identities list
    List<Identity> assessedIdentities = assessmentToolManager.getAssessedIdentities(coach, params);
    Assert.assertNotNull(assessedIdentities);
    Assert.assertEquals(2, assessedIdentities.size());
    // number of assessed identities
    int numOfAssessedIdentities = assessmentToolManager.getNumberOfAssessedIdentities(coach, params);
    Assert.assertEquals(2, numOfAssessedIdentities);
    // check only the queries
    AssessmentMembersStatistics participantStatistics = assessmentToolManager.getNumberOfParticipants(coach, params);
    Assert.assertNotNull(participantStatistics);
    int numOfInitialLanches = assessmentToolManager.getNumberOfInitialLaunches(coach, params);
    // not launched, only simulated
    Assert.assertEquals(0, numOfInitialLanches);
    List<IdentityShort> assessedShortIdentities = assessmentToolManager.getShortAssessedIdentities(coach, params, 120);
    Assert.assertNotNull(assessedShortIdentities);
    Assert.assertEquals(2, assessedShortIdentities.size());
    List<AssessmentEntry> assessmentEntries = assessmentToolManager.getAssessmentEntries(coach, params, AssessmentEntryStatus.notStarted);
    Assert.assertNotNull(assessmentEntries);
    Assert.assertEquals(0, assessmentEntries.size());
    // separate check with more options in the search parameters
    // add by group key
    params.setBusinessGroupKeys(Collections.singletonList(group1.getKey()));
    // assessed groups
    List<AssessedBusinessGroup> assessedGroups = assessmentToolManager.getBusinessGroupStatistics(coach, params);
    Assert.assertNotNull(assessedGroups);
    Assert.assertEquals(1, assessedGroups.size());
    // check assessed identities list
    List<Identity> assessedIdentitiesAlt = assessmentToolManager.getAssessedIdentities(coach, params);
    Assert.assertNotNull(assessedIdentitiesAlt);
    Assert.assertEquals(2, assessedIdentitiesAlt.size());
    // number of assessed identities
    int numOfAssessedIdentitiesAlt = assessmentToolManager.getNumberOfAssessedIdentities(coach, params);
    Assert.assertEquals(2, numOfAssessedIdentitiesAlt);
    List<IdentityShort> assessedShortIdentitiesAlt = assessmentToolManager.getShortAssessedIdentities(coach, params, 120);
    Assert.assertNotNull(assessedShortIdentitiesAlt);
    Assert.assertEquals(2, assessedShortIdentitiesAlt.size());
    List<AssessmentEntry> assessmentEntriesAlt = assessmentToolManager.getAssessmentEntries(coach, params, AssessmentEntryStatus.notStarted);
    Assert.assertNotNull(assessmentEntriesAlt);
    Assert.assertEquals(0, assessmentEntriesAlt.size());
}
Also used : AssessmentMembersStatistics(org.olat.modules.assessment.model.AssessmentMembersStatistics) BusinessGroup(org.olat.group.BusinessGroup) AssessedBusinessGroup(org.olat.course.assessment.model.AssessedBusinessGroup) IdentityShort(org.olat.basesecurity.IdentityShort) AssessmentToolSecurityCallback(org.olat.modules.assessment.ui.AssessmentToolSecurityCallback) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) AssessmentStatistics(org.olat.course.assessment.model.AssessmentStatistics) SearchAssessedIdentityParams(org.olat.course.assessment.model.SearchAssessedIdentityParams) AssessedBusinessGroup(org.olat.course.assessment.model.AssessedBusinessGroup) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 7 with AssessedBusinessGroup

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

the class AssessmentToolManagerTest method assessmentTool_coach.

@Test
public void assessmentTool_coach() {
    // course
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-author-1");
    ICourse course = CoursesWebService.createEmptyCourse(author, "course-assessment-tool", "course long name", null);
    // members as participant and coach
    Identity assessedIdentity1 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-1");
    Identity assessedIdentity2 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-2");
    Identity assessedIdentity3 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-3");
    Identity assessedIdentity4 = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-4");
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("ast-coach-1");
    RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    RepositoryEntry refEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    String subIdent = UUID.randomUUID().toString();
    BusinessGroup group1 = businessGroupDao.createAndPersist(null, "assessment-tool-bg-1", "assessment-tool-bg-1-desc", -1, -1, false, false, false, false, false);
    businessGroupRelationDao.addRelationToResource(group1, entry);
    BusinessGroup group2 = businessGroupDao.createAndPersist(null, "assessment-tool-bg-2", "assessment-tool-bg-2-desc", -1, -1, false, false, false, false, false);
    businessGroupRelationDao.addRelationToResource(group2, entry);
    businessGroupRelationDao.addRole(assessedIdentity1, group1, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(assessedIdentity2, group1, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(assessedIdentity3, group2, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(coach, group1, GroupRoles.coach.name());
    dbInstance.commitAndCloseSession();
    // some datas
    assessmentEntryDao.createAssessmentEntry(assessedIdentity1, null, entry, subIdent, refEntry, 3.0f, Boolean.FALSE, null, null);
    assessmentEntryDao.createAssessmentEntry(assessedIdentity2, null, entry, subIdent, refEntry, 5.0f, Boolean.TRUE, null, null);
    assessmentEntryDao.createAssessmentEntry(assessedIdentity3, null, entry, subIdent, refEntry, 8.0f, Boolean.TRUE, null, null);
    assessmentEntryDao.createAssessmentEntry(assessedIdentity4, null, entry, subIdent, refEntry, 9.0f, Boolean.TRUE, null, null);
    assessmentEntryDao.createAssessmentEntry(null, UUID.randomUUID().toString(), entry, subIdent, refEntry);
    dbInstance.commitAndCloseSession();
    // coach of group 1 with id 1 and id2
    List<BusinessGroup> coachedGroups = Collections.singletonList(group1);
    AssessmentToolSecurityCallback assessmentCallback = new AssessmentToolSecurityCallback(false, false, false, true, coachedGroups);
    SearchAssessedIdentityParams params = new SearchAssessedIdentityParams(entry, subIdent, refEntry, assessmentCallback);
    // statistics
    AssessmentStatistics statistics = assessmentToolManager.getStatistics(coach, params);
    Assert.assertEquals(4.0d, statistics.getAverageScore().doubleValue(), 0.0001);
    Assert.assertEquals(1, statistics.getCountFailed());
    Assert.assertEquals(1, statistics.getCountPassed());
    // check assessed identities list
    List<Identity> assessedIdentities = assessmentToolManager.getAssessedIdentities(coach, params);
    Assert.assertNotNull(assessedIdentities);
    Assert.assertEquals(2, assessedIdentities.size());
    // number of assessed identities
    int numOfAssessedIdentities = assessmentToolManager.getNumberOfAssessedIdentities(coach, params);
    Assert.assertEquals(2, numOfAssessedIdentities);
    // check only the queries
    AssessmentMembersStatistics participantStatistics = assessmentToolManager.getNumberOfParticipants(coach, params);
    Assert.assertNotNull(participantStatistics);
    int numOfInitialLanches = assessmentToolManager.getNumberOfInitialLaunches(coach, params);
    // not launched, only simulated
    Assert.assertEquals(0, numOfInitialLanches);
    List<IdentityShort> assessedShortIdentities = assessmentToolManager.getShortAssessedIdentities(coach, params, 120);
    Assert.assertNotNull(assessedShortIdentities);
    Assert.assertEquals(2, assessedShortIdentities.size());
    List<AssessmentEntry> assessmentEntries = assessmentToolManager.getAssessmentEntries(coach, params, AssessmentEntryStatus.notStarted);
    Assert.assertNotNull(assessmentEntries);
    Assert.assertEquals(0, assessmentEntries.size());
    // separate check with more options in the search parameters
    // add by group key
    params.setBusinessGroupKeys(Collections.singletonList(group1.getKey()));
    // assessed groups
    List<AssessedBusinessGroup> assessedGroups = assessmentToolManager.getBusinessGroupStatistics(coach, params);
    Assert.assertNotNull(assessedGroups);
    Assert.assertEquals(1, assessedGroups.size());
    // check assessed identities list
    List<Identity> assessedIdentitiesAlt = assessmentToolManager.getAssessedIdentities(coach, params);
    Assert.assertNotNull(assessedIdentitiesAlt);
    Assert.assertEquals(2, assessedIdentitiesAlt.size());
    // number of assessed identities
    int numOfAssessedIdentitiesAlt = assessmentToolManager.getNumberOfAssessedIdentities(coach, params);
    Assert.assertEquals(2, numOfAssessedIdentitiesAlt);
    List<IdentityShort> assessedShortIdentitiesAlt = assessmentToolManager.getShortAssessedIdentities(coach, params, 120);
    Assert.assertNotNull(assessedShortIdentitiesAlt);
    Assert.assertEquals(2, assessedShortIdentitiesAlt.size());
    List<AssessmentEntry> assessmentEntriesAlt = assessmentToolManager.getAssessmentEntries(coach, params, AssessmentEntryStatus.notStarted);
    Assert.assertNotNull(assessmentEntriesAlt);
    Assert.assertEquals(0, assessmentEntriesAlt.size());
}
Also used : AssessmentMembersStatistics(org.olat.modules.assessment.model.AssessmentMembersStatistics) BusinessGroup(org.olat.group.BusinessGroup) AssessedBusinessGroup(org.olat.course.assessment.model.AssessedBusinessGroup) IdentityShort(org.olat.basesecurity.IdentityShort) AssessmentToolSecurityCallback(org.olat.modules.assessment.ui.AssessmentToolSecurityCallback) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) AssessmentStatistics(org.olat.course.assessment.model.AssessmentStatistics) SearchAssessedIdentityParams(org.olat.course.assessment.model.SearchAssessedIdentityParams) AssessedBusinessGroup(org.olat.course.assessment.model.AssessedBusinessGroup) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 8 with AssessedBusinessGroup

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

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