Search in sources :

Example 6 with AssessmentModeToGroup

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

the class AssessmentModeManagerTest method getAssessedIdentities_course_groups.

@Test
public void getAssessedIdentities_course_groups() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-15");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-16");
    Identity coach1 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-17");
    BusinessGroup businessGroup = businessGroupService.createBusinessGroup(null, "as-mode-4", "", null, null, null, null, false, false, entry);
    businessGroupRelationDao.addRole(participant1, businessGroup, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(coach1, businessGroup, GroupRoles.coach.name());
    Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-18");
    Identity coach2 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-19");
    repositoryEntryRelationDao.addRole(participant2, entry, GroupRoles.participant.name());
    repositoryEntryRelationDao.addRole(coach2, entry, GroupRoles.coach.name());
    repositoryEntryRelationDao.addRole(author, entry, GroupRoles.owner.name());
    AssessmentMode mode = createMinimalAssessmentmode(entry);
    mode.setTargetAudience(AssessmentMode.Target.courseAndGroups);
    mode.setApplySettingsForCoach(true);
    mode = assessmentModeMgr.persist(mode);
    AssessmentModeToGroup modeToGroup = assessmentModeMgr.createAssessmentModeToGroup(mode, businessGroup);
    mode.getGroups().add(modeToGroup);
    mode = assessmentModeMgr.merge(mode, true);
    dbInstance.commitAndCloseSession();
    Set<Long> assessedIdentityKeys = assessmentModeMgr.getAssessedIdentityKeys(mode);
    Assert.assertNotNull(assessedIdentityKeys);
    Assert.assertEquals(4, assessedIdentityKeys.size());
    Assert.assertFalse(assessedIdentityKeys.contains(author.getKey()));
    Assert.assertTrue(assessedIdentityKeys.contains(coach1.getKey()));
    Assert.assertTrue(assessedIdentityKeys.contains(participant1.getKey()));
    Assert.assertTrue(assessedIdentityKeys.contains(coach2.getKey()));
    Assert.assertTrue(assessedIdentityKeys.contains(participant2.getKey()));
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) BusinessGroup(org.olat.group.BusinessGroup) AssessmentModeToGroup(org.olat.course.assessment.AssessmentModeToGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 7 with AssessmentModeToGroup

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

the class AssessmentModeEditController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    formLayout.setElementCssClass("o_sel_assessment_mode_edit_form");
    setFormContextHelp("Assessment mode");
    if (StringHelper.containsNonWhitespace(assessmentMode.getName())) {
        setFormTitle("form.mode.title", new String[] { assessmentMode.getName() });
    } else {
        setFormTitle("form.mode.title.add");
    }
    setFormDescription("form.mode.description");
    ICourse course = CourseFactory.loadCourse(courseOres);
    if (StringHelper.containsNonWhitespace(assessmentMode.getStartElement())) {
        CourseNode startElement = course.getRunStructure().getNode(assessmentMode.getStartElement());
        if (startElement == null) {
            setFormWarning("warning.missing.start.element");
        }
    }
    if (StringHelper.containsNonWhitespace(assessmentMode.getElementList())) {
        String elements = assessmentMode.getElementList();
        for (String element : elements.split(",")) {
            CourseNode node = course.getRunStructure().getNode(element);
            if (node == null) {
                setFormWarning("warning.missing.element");
            }
        }
    }
    Status status = assessmentMode.getStatus();
    String name = assessmentMode.getName();
    nameEl = uifactory.addTextElement("mode.name", "mode.name", 255, name, formLayout);
    nameEl.setElementCssClass("o_sel_assessment_mode_name");
    nameEl.setMandatory(true);
    nameEl.setEnabled(status != Status.followup && status != Status.end);
    String desc = assessmentMode.getDescription();
    descriptionEl = uifactory.addRichTextElementForStringData("mode.description", "mode.description", desc, 6, -1, false, null, null, formLayout, ureq.getUserSession(), getWindowControl());
    descriptionEl.setEnabled(status != Status.followup && status != Status.end);
    beginEl = uifactory.addDateChooser("mode.begin", assessmentMode.getBegin(), formLayout);
    beginEl.setElementCssClass("o_sel_assessment_mode_begin");
    beginEl.setDateChooserTimeEnabled(true);
    beginEl.setMandatory(true);
    beginEl.setEnabled(status == Status.none || status == Status.leadtime);
    int leadTime = assessmentMode.getLeadTime();
    if (leadTime < 0) {
        leadTime = 0;
    }
    leadTimeEl = uifactory.addIntegerElement("mode.leadTime", leadTime, formLayout);
    leadTimeEl.setElementCssClass("o_sel_assessment_mode_leadtime");
    leadTimeEl.setDisplaySize(3);
    leadTimeEl.setEnabled(status == Status.none || status == Status.leadtime);
    endEl = uifactory.addDateChooser("mode.end", assessmentMode.getEnd(), formLayout);
    endEl.setElementCssClass("o_sel_assessment_mode_end");
    endEl.setDateChooserTimeEnabled(true);
    endEl.setDefaultValue(beginEl);
    endEl.setMandatory(true);
    endEl.setEnabled(status != Status.end);
    int followupTime = assessmentMode.getFollowupTime();
    if (followupTime < 0) {
        followupTime = 0;
    }
    followupTimeEl = uifactory.addIntegerElement("mode.followupTime", followupTime, formLayout);
    followupTimeEl.setElementCssClass("o_sel_assessment_mode_followuptime");
    followupTimeEl.setDisplaySize(3);
    followupTimeEl.setEnabled(status != Status.end);
    String[] startModeValues = new String[] { translate("mode.beginend.automatic"), translate("mode.beginend.manual") };
    startModeEl = uifactory.addDropdownSingleselect("mode.beginend", formLayout, startModeKeys, startModeValues, null);
    startModeEl.setElementCssClass("o_sel_assessment_mode_start_mode");
    if (assessmentMode.isManualBeginEnd()) {
        startModeEl.select(startModeKeys[1], true);
    } else {
        startModeEl.select(startModeKeys[0], true);
    }
    startModeEl.setEnabled(status != Status.end);
    String[] audienceKeys = new String[] { AssessmentMode.Target.courseAndGroups.name(), AssessmentMode.Target.course.name(), AssessmentMode.Target.groups.name() };
    String[] audienceValues = new String[] { translate("target.courseAndGroups"), translate("target.course"), translate("target.groups") };
    targetEl = uifactory.addRadiosVertical("audience", "mode.target", formLayout, audienceKeys, audienceValues);
    targetEl.setElementCssClass("o_sel_assessment_mode_audience");
    targetEl.setEnabled(status != Status.end);
    Target target = assessmentMode.getTargetAudience();
    if (target != null) {
        for (String audienceKey : audienceKeys) {
            if (audienceKey.equals(target.name())) {
                targetEl.select(audienceKey, true);
            }
        }
    }
    if (!targetEl.isOneSelected()) {
        targetEl.select(audienceKeys[0], true);
    }
    // choose groups
    String groupPage = velocity_root + "/choose_groups.html";
    chooseGroupsCont = FormLayoutContainer.createCustomFormLayout("chooseGroups", getTranslator(), groupPage);
    chooseGroupsCont.setRootForm(mainForm);
    formLayout.add(chooseGroupsCont);
    chooseGroupsButton = uifactory.addFormLink("choose.groups", chooseGroupsCont, Link.BUTTON);
    chooseGroupsButton.setEnabled(status != Status.end);
    chooseAreasButton = uifactory.addFormLink("choose.areas", chooseGroupsCont, Link.BUTTON);
    chooseAreasButton.setEnabled(status != Status.end);
    groupKeys = new ArrayList<>();
    groupNames = new ArrayList<>();
    for (AssessmentModeToGroup modeToGroup : assessmentMode.getGroups()) {
        BusinessGroup group = modeToGroup.getBusinessGroup();
        groupKeys.add(group.getKey());
        groupNames.add(StringHelper.escapeHtml(group.getName()));
    }
    chooseGroupsCont.getFormItemComponent().contextPut("groupNames", groupNames);
    areaKeys = new ArrayList<>();
    areaNames = new ArrayList<>();
    for (AssessmentModeToArea modeToArea : assessmentMode.getAreas()) {
        BGArea area = modeToArea.getArea();
        areaKeys.add(area.getKey());
        areaNames.add(StringHelper.escapeHtml(area.getName()));
    }
    chooseGroupsCont.getFormItemComponent().contextPut("areaNames", areaNames);
    // course elements
    courseElementsRestrictionEl = uifactory.addCheckboxesHorizontal("cer", "mode.course.element.restriction", formLayout, onKeys, onValues);
    courseElementsRestrictionEl.addActionListener(FormEvent.ONCHANGE);
    courseElementsRestrictionEl.select(onKeys[0], assessmentMode.isRestrictAccessElements());
    courseElementsRestrictionEl.setEnabled(status != Status.end);
    String coursePage = velocity_root + "/choose_elements.html";
    chooseElementsCont = FormLayoutContainer.createCustomFormLayout("chooseElements", getTranslator(), coursePage);
    chooseElementsCont.setRootForm(mainForm);
    formLayout.add(chooseElementsCont);
    chooseElementsCont.setVisible(assessmentMode.isRestrictAccessElements());
    CourseEditorTreeModel treeModel = course.getEditorTreeModel();
    elementKeys = new ArrayList<>();
    elementNames = new ArrayList<>();
    String elements = assessmentMode.getElementList();
    if (StringHelper.containsNonWhitespace(elements)) {
        for (String element : elements.split(",")) {
            String courseNodeName = getCourseNodeName(element, treeModel);
            if (StringHelper.containsNonWhitespace(courseNodeName)) {
                elementKeys.add(element);
                elementNames.add(courseNodeName);
            }
        }
    }
    chooseElementsCont.getFormItemComponent().contextPut("elementNames", elementNames);
    chooseElementsButton = uifactory.addFormLink("choose.elements", chooseElementsCont, Link.BUTTON);
    chooseElementsButton.setEnabled(status != Status.end);
    startElementKey = assessmentMode.getStartElement();
    String startElementName = "";
    if (StringHelper.containsNonWhitespace(startElementKey)) {
        startElementName = getCourseNodeName(startElementKey, treeModel);
    }
    startElementEl = uifactory.addStaticTextElement("mode.start.element", "mode.start.element", startElementName, formLayout);
    chooseStartElementButton = uifactory.addFormLink("choose.start.element", formLayout, Link.BUTTON);
    chooseStartElementButton.setEnabled(status != Status.end);
    // ips
    ipsEl = uifactory.addCheckboxesHorizontal("ips", "mode.ips", formLayout, onKeys, onValues);
    ipsEl.select(onKeys[0], assessmentMode.isRestrictAccessIps());
    ipsEl.addActionListener(FormEvent.ONCHANGE);
    ipsEl.setEnabled(status != Status.end);
    String ipList = assessmentMode.getIpList();
    ipListEl = uifactory.addTextAreaElement("mode.ips.list", "mode.ips.list", 4096, 4, 60, false, ipList, formLayout);
    ipListEl.setVisible(assessmentMode.isRestrictAccessIps());
    ipListEl.setEnabled(status != Status.end);
    safeExamBrowserEl = uifactory.addCheckboxesHorizontal("safeexam", "mode.safeexambrowser", formLayout, onKeys, onValues);
    safeExamBrowserEl.select(onKeys[0], assessmentMode.isSafeExamBrowser());
    safeExamBrowserEl.addActionListener(FormEvent.ONCHANGE);
    safeExamBrowserEl.setEnabled(status != Status.end);
    String key = assessmentMode.getSafeExamBrowserKey();
    safeExamBrowserKeyEl = uifactory.addTextAreaElement("safeexamkey", "mode.safeexambrowser.key", 4096, 6, 60, false, key, formLayout);
    safeExamBrowserKeyEl.setVisible(assessmentMode.isSafeExamBrowser());
    safeExamBrowserKeyEl.setEnabled(status != Status.end);
    String hint = assessmentMode.getSafeExamBrowserHint();
    safeExamBrowserHintEl = uifactory.addRichTextElementForStringData("safeexamhint", "mode.safeexambrowser.hint", hint, 10, -1, false, null, null, formLayout, ureq.getUserSession(), getWindowControl());
    safeExamBrowserHintEl.setVisible(assessmentMode.isSafeExamBrowser());
    safeExamBrowserHintEl.setEnabled(status != Status.end);
    forCoachEl = uifactory.addCheckboxesHorizontal("forcoach", "mode.for.coach", formLayout, onKeys, onValues);
    forCoachEl.select(onKeys[0], assessmentMode.isApplySettingsForCoach());
    forCoachEl.setEnabled(status != Status.end);
    FormLayoutContainer buttonCont = FormLayoutContainer.createButtonLayout("button", getTranslator());
    formLayout.add(buttonCont);
    if (status != Status.end) {
        uifactory.addFormSubmitButton("save", buttonCont);
    }
    uifactory.addFormCancelButton("cancel", buttonCont, ureq, getWindowControl());
}
Also used : Status(org.olat.course.assessment.AssessmentMode.Status) CourseEditorTreeModel(org.olat.course.tree.CourseEditorTreeModel) BusinessGroup(org.olat.group.BusinessGroup) AssessmentModeToGroup(org.olat.course.assessment.AssessmentModeToGroup) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) ICourse(org.olat.course.ICourse) AssessmentModeToArea(org.olat.course.assessment.AssessmentModeToArea) Target(org.olat.course.assessment.AssessmentMode.Target) BGArea(org.olat.group.area.BGArea) CourseNode(org.olat.course.nodes.CourseNode)

Example 8 with AssessmentModeToGroup

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

the class AssessmentModeManagerTest method loadAssessmentMode_identityInBusinessGroup_coach.

/**
 * Check an assessment linked to a group with one participant
 */
@Test
public void loadAssessmentMode_identityInBusinessGroup_coach() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-4");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-5");
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-6");
    BusinessGroup businessGroup = businessGroupService.createBusinessGroup(null, "as-mode-3", "", null, null, null, null, false, false, entry);
    businessGroupRelationDao.addRole(participant, businessGroup, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(coach, businessGroup, GroupRoles.coach.name());
    AssessmentMode mode = createMinimalAssessmentmode(entry);
    mode.setTargetAudience(AssessmentMode.Target.courseAndGroups);
    mode.setApplySettingsForCoach(true);
    mode = assessmentModeMgr.persist(mode);
    AssessmentModeToGroup modeToGroup = assessmentModeMgr.createAssessmentModeToGroup(mode, businessGroup);
    mode.getGroups().add(modeToGroup);
    mode = assessmentModeMgr.merge(mode, true);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(mode);
    // check participant
    List<AssessmentMode> currentModes = assessmentModeMgr.getAssessmentModeFor(participant);
    Assert.assertNotNull(currentModes);
    Assert.assertEquals(1, currentModes.size());
    Assert.assertTrue(currentModes.contains(mode));
    // check coach
    List<AssessmentMode> currentCoachModes = assessmentModeMgr.getAssessmentModeFor(coach);
    Assert.assertNotNull(currentCoachModes);
    Assert.assertEquals(1, currentCoachModes.size());
    Assert.assertTrue(currentCoachModes.contains(mode));
    // check author
    List<AssessmentMode> currentAuthorModes = assessmentModeMgr.getAssessmentModeFor(author);
    Assert.assertNotNull(currentAuthorModes);
    Assert.assertTrue(currentAuthorModes.isEmpty());
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) BusinessGroup(org.olat.group.BusinessGroup) AssessmentModeToGroup(org.olat.course.assessment.AssessmentModeToGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 9 with AssessmentModeToGroup

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

the class AssessmentModeManagerTest method loadAssessmentMode_identityInArea.

/**
 * Check an assessment linked to an area with one participant
 */
@Test
public void loadAssessmentMode_identityInArea() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-12");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-13");
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-14");
    BusinessGroup businessGroup = businessGroupService.createBusinessGroup(author, "as-mode-3", "", null, null, null, null, false, false, entry);
    businessGroupRelationDao.addRole(participant, businessGroup, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(coach, businessGroup, GroupRoles.coach.name());
    BGArea area = areaMgr.createAndPersistBGArea("area for people", "", entry.getOlatResource());
    areaMgr.addBGToBGArea(businessGroup, area);
    AssessmentMode mode = createMinimalAssessmentmode(entry);
    mode.setTargetAudience(AssessmentMode.Target.courseAndGroups);
    mode.setApplySettingsForCoach(false);
    mode = assessmentModeMgr.persist(mode);
    AssessmentModeToGroup modeToGroup = assessmentModeMgr.createAssessmentModeToGroup(mode, businessGroup);
    mode.getGroups().add(modeToGroup);
    mode = assessmentModeMgr.merge(mode, true);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(mode);
    // check participant
    List<AssessmentMode> currentModes = assessmentModeMgr.getAssessmentModeFor(participant);
    Assert.assertNotNull(currentModes);
    Assert.assertEquals(1, currentModes.size());
    Assert.assertTrue(currentModes.contains(mode));
    // check coach
    List<AssessmentMode> currentCoachModes = assessmentModeMgr.getAssessmentModeFor(coach);
    Assert.assertNotNull(currentCoachModes);
    Assert.assertTrue(currentCoachModes.isEmpty());
    // check author
    List<AssessmentMode> currentAuthorModes = assessmentModeMgr.getAssessmentModeFor(author);
    Assert.assertNotNull(currentAuthorModes);
    Assert.assertTrue(currentAuthorModes.isEmpty());
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) BusinessGroup(org.olat.group.BusinessGroup) BGArea(org.olat.group.area.BGArea) AssessmentModeToGroup(org.olat.course.assessment.AssessmentModeToGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 10 with AssessmentModeToGroup

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

the class AssessmentModeManagerTest method removeBusinessGroupFromRepositoryEntry.

@Test
public void removeBusinessGroupFromRepositoryEntry() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-4");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-5");
    Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-6");
    BusinessGroup businessGroup1 = businessGroupService.createBusinessGroup(author, "as-mode-7", "", null, null, null, null, false, false, entry);
    BusinessGroup businessGroup2 = businessGroupService.createBusinessGroup(author, "as-mode-8", "", null, null, null, null, false, false, entry);
    businessGroupRelationDao.addRole(participant1, businessGroup1, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(participant2, businessGroup2, GroupRoles.participant.name());
    AssessmentMode mode = createMinimalAssessmentmode(entry);
    mode.setTargetAudience(AssessmentMode.Target.groups);
    mode.setApplySettingsForCoach(false);
    mode = assessmentModeMgr.persist(mode);
    AssessmentModeToGroup modeToGroup1 = assessmentModeMgr.createAssessmentModeToGroup(mode, businessGroup1);
    AssessmentModeToGroup modeToGroup2 = assessmentModeMgr.createAssessmentModeToGroup(mode, businessGroup2);
    mode.getGroups().add(modeToGroup1);
    mode.getGroups().add(modeToGroup2);
    mode = assessmentModeMgr.merge(mode, true);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(mode);
    // check participant 1
    List<AssessmentMode> currentModes1 = assessmentModeMgr.getAssessmentModeFor(participant1);
    Assert.assertNotNull(currentModes1);
    Assert.assertEquals(1, currentModes1.size());
    Assert.assertTrue(currentModes1.contains(mode));
    // check participant 2
    List<AssessmentMode> currentModes2 = assessmentModeMgr.getAssessmentModeFor(participant2);
    Assert.assertNotNull(currentModes2);
    Assert.assertEquals(1, currentModes2.size());
    Assert.assertTrue(currentModes2.contains(mode));
    // remove business group 1
    businessGroupRelationDao.deleteRelation(businessGroup1, entry);
    dbInstance.commitAndCloseSession();
    // check participant 1
    List<AssessmentMode> afterDeleteModes1 = assessmentModeMgr.getAssessmentModeFor(participant1);
    Assert.assertNotNull(afterDeleteModes1);
    Assert.assertEquals(0, afterDeleteModes1.size());
    // check participant 2
    List<AssessmentMode> afterDeleteModes2 = assessmentModeMgr.getAssessmentModeFor(participant2);
    Assert.assertNotNull(afterDeleteModes2);
    Assert.assertEquals(1, afterDeleteModes2.size());
    Assert.assertTrue(afterDeleteModes2.contains(mode));
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) BusinessGroup(org.olat.group.BusinessGroup) AssessmentModeToGroup(org.olat.course.assessment.AssessmentModeToGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Aggregations

AssessmentModeToGroup (org.olat.course.assessment.AssessmentModeToGroup)22 BusinessGroup (org.olat.group.BusinessGroup)22 RepositoryEntry (org.olat.repository.RepositoryEntry)18 Test (org.junit.Test)16 Identity (org.olat.core.id.Identity)16 AssessmentMode (org.olat.course.assessment.AssessmentMode)16 BGArea (org.olat.group.area.BGArea)10 AssessmentModeToArea (org.olat.course.assessment.AssessmentModeToArea)8 HashSet (java.util.HashSet)4 Target (org.olat.course.assessment.AssessmentMode.Target)4 ArrayList (java.util.ArrayList)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 ICourse (org.olat.course.ICourse)2 Status (org.olat.course.assessment.AssessmentMode.Status)2 CourseNode (org.olat.course.nodes.CourseNode)2 CourseEditorTreeModel (org.olat.course.tree.CourseEditorTreeModel)2