Search in sources :

Example 11 with UserCourseEnvironmentImpl

use of org.olat.course.run.userview.UserCourseEnvironmentImpl in project OpenOLAT by OpenOLAT.

the class AssessmentManagerTest method testSaveScoreEvaluation.

/**
 * Tests the AssessmentManager methods.
 */
@Test
public void testSaveScoreEvaluation() {
    log.info("Start testSaveScoreEvaluation");
    assertNotNull(course);
    // find an assessableCourseNode
    List<CourseNode> assessableNodeList = AssessmentHelper.getAssessableNodes(course.getEditorTreeModel(), null);
    Iterator<CourseNode> nodesIterator = assessableNodeList.iterator();
    boolean testNodeFound = false;
    while (nodesIterator.hasNext()) {
        CourseNode currentNode = nodesIterator.next();
        if (currentNode instanceof AssessableCourseNode) {
            if (currentNode.getType().equalsIgnoreCase("iqtest")) {
                log.info("Yes, we found a test node! - currentNode.getType(): " + currentNode.getType());
                assessableCourseNode = (AssessableCourseNode) currentNode;
                testNodeFound = true;
                break;
            }
        }
    }
    assertTrue("found no test-node of type 'iqtest' (hint: add one to DemoCourse) ", testNodeFound);
    assessmentManager = course.getCourseEnvironment().getAssessmentManager();
    Long assessmentID = new Long("123456");
    Integer attempts = 1;
    String coachComment = "SomeUselessCoachComment";
    String userComment = "UselessUserComment";
    // store ScoreEvaluation for the assessableCourseNode and student
    ScoreEvaluation scoreEvaluation = new ScoreEvaluation(score, passed, fullyAssessed, assessmentID);
    IdentityEnvironment ienv = new IdentityEnvironment();
    ienv.setIdentity(student);
    UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
    boolean incrementAttempts = true;
    assessmentManager.saveScoreEvaluation(assessableCourseNode, tutor, student, scoreEvaluation, userCourseEnv, incrementAttempts, Role.coach);
    DBFactory.getInstance().closeSession();
    // the attempts mut have been incremented
    assertEquals(attempts, assessmentManager.getNodeAttempts(assessableCourseNode, student));
    assessmentManager.saveNodeCoachComment(assessableCourseNode, student, coachComment);
    assessmentManager.saveNodeComment(assessableCourseNode, tutor, student, userComment);
    attempts++;
    assessmentManager.saveNodeAttempts(assessableCourseNode, tutor, student, attempts, Role.coach);
    assertEquals(attempts, assessmentManager.getNodeAttempts(assessableCourseNode, student));
    assertEquals(score, assessmentManager.getNodeScore(assessableCourseNode, student));
    assertEquals(passed, assessmentManager.getNodePassed(assessableCourseNode, student));
    assertEquals(assessmentID, assessmentManager.getAssessmentID(assessableCourseNode, student));
    assertEquals(coachComment, assessmentManager.getNodeCoachComment(assessableCourseNode, student));
    assertEquals(userComment, assessmentManager.getNodeComment(assessableCourseNode, student));
    log.info("Finish testing AssessmentManager read/write methods");
    checkEfficiencyStatementManager();
    assertNotNull("no course at the end of test", course);
    try {
        course = CourseFactory.loadCourse(course.getResourceableId());
    } catch (Exception ex) {
        fail("Could not load course at the end of test Exception=" + ex);
    }
    assertNotNull("no course after loadCourse", course);
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) IOException(java.io.IOException) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseNode(org.olat.course.nodes.CourseNode) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) Test(org.junit.Test)

Example 12 with UserCourseEnvironmentImpl

use of org.olat.course.run.userview.UserCourseEnvironmentImpl in project OpenOLAT by OpenOLAT.

the class PFManagerTest method provideParticipantContainer.

@Test
public void provideParticipantContainer() {
    // prepare
    Identity initialAuthor = JunitTestHelper.createAndPersistIdentityAsRndUser("check-15");
    IdentityEnvironment ienv = new IdentityEnvironment();
    ienv.setIdentity(initialAuthor);
    PFCourseNode pfNode = new PFCourseNode();
    pfNode.getModuleConfiguration().setBooleanEntry(PFCourseNode.CONFIG_KEY_COACHBOX, true);
    pfNode.getModuleConfiguration().setBooleanEntry(PFCourseNode.CONFIG_KEY_PARTICIPANTBOX, true);
    // import "Demo course" into the bcroot_junittest
    RepositoryEntry entry = JunitTestHelper.deployDemoCourse(initialAuthor);
    Long resourceableId = entry.getOlatResource().getResourceableId();
    ICourse course = CourseFactory.loadCourse(resourceableId);
    UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
    Identity check3 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-3");
    repositoryEntryRelationDao.addRole(check3, entry, GroupRoles.participant.name());
    VFSContainer vfsContainer = pfManager.provideCoachOrParticipantContainer(pfNode, userCourseEnv, check3, false);
    Assert.assertNotNull(vfsContainer);
    Assert.assertTrue(vfsContainer.exists());
}
Also used : PFCourseNode(org.olat.course.nodes.PFCourseNode) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) VFSContainer(org.olat.core.util.vfs.VFSContainer) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) Test(org.junit.Test)

Example 13 with UserCourseEnvironmentImpl

use of org.olat.course.run.userview.UserCourseEnvironmentImpl in project OpenOLAT by OpenOLAT.

the class PFManagerTest method provideCoachContainer.

@Test
public void provideCoachContainer() {
    // prepare
    Identity initialAuthor = JunitTestHelper.createAndPersistIdentityAsRndUser("check-16");
    IdentityEnvironment ienv = new IdentityEnvironment();
    ienv.setIdentity(initialAuthor);
    PFCourseNode pfNode = new PFCourseNode();
    pfNode.getModuleConfiguration().setBooleanEntry(PFCourseNode.CONFIG_KEY_COACHBOX, true);
    pfNode.getModuleConfiguration().setBooleanEntry(PFCourseNode.CONFIG_KEY_PARTICIPANTBOX, true);
    // import "Demo course" into the bcroot_junittest
    RepositoryEntry entry = JunitTestHelper.deployDemoCourse(initialAuthor);
    Long resourceableId = entry.getOlatResource().getResourceableId();
    ICourse course = CourseFactory.loadCourse(resourceableId);
    UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
    Identity check4 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-4");
    repositoryEntryRelationDao.addRole(check4, entry, GroupRoles.coach.name());
    VFSContainer vfsContainer = pfManager.provideCoachOrParticipantContainer(pfNode, userCourseEnv, check4, false);
    Assert.assertNotNull(vfsContainer);
}
Also used : PFCourseNode(org.olat.course.nodes.PFCourseNode) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) VFSContainer(org.olat.core.util.vfs.VFSContainer) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) Test(org.junit.Test)

Example 14 with UserCourseEnvironmentImpl

use of org.olat.course.run.userview.UserCourseEnvironmentImpl in project OpenOLAT by OpenOLAT.

the class CheckListAssessmentController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormDescription("coach.desc");
    setFormContextHelp("Assessment#_checklist_manage");
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        if (dueDate != null) {
            layoutCont.contextPut("dueDate", dueDate);
        }
    }
    FlexiTableSortOptions options = new FlexiTableSortOptions();
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    if (isAdministrativeUser) {
        options.setDefaultOrderBy(new SortKey(Cols.username.name(), true));
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.username.i18nKey(), Cols.username.ordinal(), true, Cols.username.name()));
    }
    int i = 0;
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        int colIndex = CheckListAssessmentDataModel.USER_PROPS_OFFSET + i++;
        if (userPropertyHandler == null)
            continue;
        String propName = userPropertyHandler.getName();
        boolean visible = userManager.isMandatoryUserProperty(USER_PROPS_ID, userPropertyHandler);
        if (visible) {
            FlexiColumnModel col;
            if (UserConstants.FIRSTNAME.equals(propName) || UserConstants.LASTNAME.equals(propName)) {
                col = new DefaultFlexiColumnModel(userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex, userPropertyHandler.getName(), true, propName, new StaticFlexiCellRenderer(userPropertyHandler.getName(), new TextFlexiCellRenderer()));
            } else {
                col = new DefaultFlexiColumnModel(true, userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex, true, propName);
            }
            columnsModel.addFlexiColumnModel(col);
            if (options.getDefaultOrderBy() == null) {
                options.setDefaultOrderBy(new SortKey(propName, true));
            }
        }
    }
    int numOfCheckbox = checkboxList.getNumOfCheckbox();
    List<Checkbox> boxList = checkboxList.getList();
    int j = 0;
    for (Checkbox box : boxList) {
        int colIndex = CheckListAssessmentDataModel.CHECKBOX_OFFSET + j++;
        String colName = "checkbox_" + colIndex;
        DefaultFlexiColumnModel column = new DefaultFlexiColumnModel(true, colName, colIndex, true, colName);
        column.setHeaderLabel(StringHelper.escapeHtml(box.getTitle()));
        columnsModel.addFlexiColumnModel(column);
    }
    if (withScore) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.totalPoints.i18nKey(), Cols.totalPoints.ordinal(), true, "points"));
    }
    if (coachCourseEnv.isCourseReadOnly()) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.view.checkbox", translate("table.header.view.checkbox"), "view"));
    } else {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.edit.checkbox", translate("table.header.edit.checkbox"), "edit"));
    }
    model = new CheckListAssessmentDataModel(checkboxList, new ArrayList<>(), columnsModel, getLocale());
    table = uifactory.addTableElement(getWindowControl(), "checkbox-list", model, getTranslator(), formLayout);
    if (coachCourseEnv instanceof UserCourseEnvironmentImpl) {
        UserCourseEnvironmentImpl env = (UserCourseEnvironmentImpl) coachCourseEnv;
        List<BusinessGroup> coachedGroups = env.getCoachedGroups();
        List<FlexiTableFilter> filters = new ArrayList<>(coachedGroups.size() + 1);
        filters.add(new FlexiTableFilter(translate("filter.all"), "all"));
        for (int k = 0; k < coachedGroups.size(); k++) {
            BusinessGroup group = coachedGroups.get(k);
            String groupName = StringHelper.escapeHtml(group.getName());
            filters.add(new FlexiTableFilter(groupName, group.getKey().toString()));
        }
        table.setFilters("participants", filters, false);
    }
    table.setExportEnabled(true);
    table.setCustomizeColumns(true);
    FlexiTableSortOptions sortOptions = new FlexiTableSortOptions();
    table.setSortSettings(sortOptions);
    table.setAndLoadPersistedPreferences(ureq, "checklist-assessment");
    pdfExportButton = uifactory.addFormLink("pdf.export", formLayout, Link.BUTTON);
    pdfExportButton.setEnabled(numOfCheckbox > 0);
    checkedPdfExportButton = uifactory.addFormLink("pdf.export.checked", formLayout, Link.BUTTON);
    checkedPdfExportButton.setEnabled(numOfCheckbox > 0);
    editButton = uifactory.addFormLink("edit", formLayout, Link.BUTTON);
    editButton.setEnabled(numOfCheckbox > 0);
    editButton.setVisible(!coachCourseEnv.isCourseReadOnly());
    saveButton = uifactory.addFormSubmitButton("save", formLayout);
    saveButton.getComponent().setSpanAsDomReplaceable(true);
    saveButton.setVisible(false);
    cancelButton = uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
    cancelButton.setVisible(false);
    boxAssessmentButton = uifactory.addFormLink("box.assessment", formLayout, Link.BUTTON);
    boxAssessmentButton.setEnabled(numOfCheckbox > 0);
    boxAssessmentButton.setVisible(!coachCourseEnv.isCourseReadOnly());
}
Also used : FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) BusinessGroup(org.olat.group.BusinessGroup) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) FlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) SortKey(org.olat.core.commons.persistence.SortKey) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) Checkbox(org.olat.course.nodes.cl.model.Checkbox) FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) TextFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 15 with UserCourseEnvironmentImpl

use of org.olat.course.run.userview.UserCourseEnvironmentImpl in project OpenOLAT by OpenOLAT.

the class ScormAPIMapper method checkForLms.

private final void checkForLms() {
    check();
    if (scormNode == null) {
        int sep = courseIdNodeId.indexOf('-');
        String courseId = courseIdNodeId.substring(0, sep);
        String nodeId = courseIdNodeId.substring(sep + 1);
        ICourse course = CourseFactory.loadCourse(Long.parseLong(courseId));
        scormNode = (ScormCourseNode) course.getRunStructure().getNode(nodeId);
        IdentityEnvironment identityEnvironment = new IdentityEnvironment();
        identityEnvironment.setIdentity(identity);
        userCourseEnv = new UserCourseEnvironmentImpl(identityEnvironment, course.getCourseEnvironment());
    }
}
Also used : UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) ICourse(org.olat.course.ICourse) IdentityEnvironment(org.olat.core.id.IdentityEnvironment)

Aggregations

UserCourseEnvironmentImpl (org.olat.course.run.userview.UserCourseEnvironmentImpl)84 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)60 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)58 ICourse (org.olat.course.ICourse)40 Identity (org.olat.core.id.Identity)32 RepositoryEntry (org.olat.repository.RepositoryEntry)28 CourseNode (org.olat.course.nodes.CourseNode)24 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)22 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)22 Roles (org.olat.core.id.Roles)14 ArrayList (java.util.ArrayList)12 NodeEvaluation (org.olat.course.run.userview.NodeEvaluation)12 VisibleTreeFilter (org.olat.course.run.userview.VisibleTreeFilter)12 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)10 BusinessGroup (org.olat.group.BusinessGroup)10 VFSContainer (org.olat.core.util.vfs.VFSContainer)8 TreeEvaluation (org.olat.course.run.userview.TreeEvaluation)8 Test (org.junit.Test)7 WebApplicationException (javax.ws.rs.WebApplicationException)6 TreeNode (org.olat.core.gui.components.tree.TreeNode)6