Search in sources :

Example 11 with AssessableCourseNode

use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.

the class ChooseColumnsStepForm method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("chooseColumns.title");
    setFormDescription("chooseColumns.description");
    setFormContextHelp("Using Course Tools#bulkassessment_map");
    AssessableCourseNode courseNode = (AssessableCourseNode) getFromRunContext("courseNode");
    BulkAssessmentSettings settings = new BulkAssessmentSettings(courseNode);
    String[] usernameKeys = new String[numOfColumns];
    String[] usernameValues = new String[numOfColumns];
    String[] otherKeys = new String[numOfColumns + 1];
    String[] otherValues = new String[numOfColumns + 1];
    for (int i = 0; i < numOfColumns; i++) {
        usernameKeys[i] = "col" + i;
        usernameValues[i] = translate("column", Integer.toString(i + 1));
        otherKeys[i] = "col" + i;
        otherValues[i] = translate("column", Integer.toString(i + 1));
    }
    otherKeys[otherKeys.length - 1] = "col9999";
    otherValues[otherValues.length - 1] = translate("column.dontuse");
    FormLayoutContainer choosersCont = FormLayoutContainer.createDefaultFormLayout("choosers", getTranslator());
    choosersCont.setElementCssClass("o_sel_bulk_assessment_columns");
    choosersCont.setRootForm(mainForm);
    formLayout.add(choosersCont);
    int pos = 0;
    userNameColumnEl = uifactory.addDropdownSingleselect("table.header.identifier", choosersCont, usernameKeys, usernameValues, null);
    if (columnsSettings != null && columnsSettings.getUsernameColumn() < usernameKeys.length) {
        userNameColumnEl.select(getSelectedKey(pos++, columnsSettings.getUsernameColumn(), usernameKeys), true);
    } else if (usernameKeys.length > 0) {
        userNameColumnEl.select(usernameKeys[Math.min(pos++, usernameKeys.length - 1)], true);
    }
    if (settings.isHasScore()) {
        scoreColumnEl = uifactory.addDropdownSingleselect("table.header.score", choosersCont, otherKeys, otherValues, null);
        if (columnsSettings != null && columnsSettings.getScoreColumn() < otherKeys.length) {
            scoreColumnEl.select(getSelectedKey(pos++, columnsSettings.getScoreColumn(), otherKeys), true);
        } else if (otherKeys.length > 0) {
            scoreColumnEl.select(otherKeys[Math.min(pos++, otherKeys.length - 1)], true);
        }
    }
    if (settings.isHasPassed() && settings.getCut() == null) {
        passedColumnEl = uifactory.addDropdownSingleselect("table.header.passed", choosersCont, otherKeys, otherValues, null);
        if (columnsSettings != null && columnsSettings.getPassedColumn() < otherKeys.length) {
            passedColumnEl.select(getSelectedKey(pos++, columnsSettings.getPassedColumn(), otherKeys), true);
        } else if (otherKeys.length > 0) {
            passedColumnEl.select(otherKeys[Math.min(pos++, otherKeys.length - 1)], true);
        }
    }
    if (settings.isHasUserComment()) {
        commentColumnEl = uifactory.addDropdownSingleselect("table.header.comment", choosersCont, otherKeys, otherValues, null);
        if (columnsSettings != null && columnsSettings.getCommentColumn() < otherKeys.length) {
            commentColumnEl.select(getSelectedKey(pos++, columnsSettings.getCommentColumn(), otherKeys), true);
        } else if (otherKeys.length > 0) {
            commentColumnEl.select(otherKeys[Math.min(pos++, otherKeys.length - 1)], true);
        }
    }
    FlexiTableColumnModel tableColumnModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    for (int i = 0; i < numOfColumns; i++) {
        DefaultFlexiColumnModel colModel = new DefaultFlexiColumnModel("ccc" + (i + 1), i);
        tableColumnModel.addFlexiColumnModel(colModel);
    }
    overviewDataModel.setTableColumnModel(tableColumnModel);
    FlexiTableElement tableEl = uifactory.addTableElement(getWindowControl(), "overviewList", overviewDataModel, getTranslator(), formLayout);
    tableEl.setCustomizeColumns(false);
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) BulkAssessmentSettings(org.olat.course.assessment.model.BulkAssessmentSettings) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) FlexiTableElement(org.olat.core.gui.components.form.flexible.elements.FlexiTableElement)

Example 12 with AssessableCourseNode

use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.

the class CourseAssessmentManagerImpl method incrementNodeAttempts.

@Override
public void incrementNodeAttempts(CourseNode courseNode, Identity assessedIdentity, UserCourseEnvironment userCourseEnv, Role by) {
    ICourse course = CourseFactory.loadCourse(cgm.getCourseEntry());
    AssessmentEntry nodeAssessment = getOrCreate(assessedIdentity, courseNode);
    int attempts = nodeAssessment.getAttempts() == null ? 1 : nodeAssessment.getAttempts().intValue() + 1;
    nodeAssessment.setAttempts(attempts);
    if (by == Role.coach) {
        nodeAssessment.setLastCoachModified(new Date());
    } else if (by == Role.user) {
        nodeAssessment.setLastUserModified(new Date());
    }
    assessmentService.updateAssessmentEntry(nodeAssessment);
    DBFactory.getInstance().commit();
    userCourseEnv.getScoreAccounting().evaluateAll(true);
    DBFactory.getInstance().commit();
    if (courseNode instanceof AssessableCourseNode) {
        // Update users efficiency statement
        efficiencyStatementManager.updateUserEfficiencyStatement(userCourseEnv);
    }
    // notify about changes
    AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_ATTEMPTS_CHANGED, assessedIdentity);
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
    // user activity logging
    ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_ATTEMPTS_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiAttempts, "", String.valueOf(attempts)));
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessmentChangedEvent(org.olat.course.assessment.AssessmentChangedEvent) ICourse(org.olat.course.ICourse) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Date(java.util.Date)

Example 13 with AssessableCourseNode

use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.

the class CourseAssessmentManagerImpl method incrementNodeAttemptsInBackground.

@Override
public void incrementNodeAttemptsInBackground(CourseNode courseNode, Identity assessedIdentity, UserCourseEnvironment userCourseEnv) {
    ICourse course = CourseFactory.loadCourse(cgm.getCourseEntry());
    AssessmentEntry nodeAssessment = getOrCreate(assessedIdentity, courseNode);
    int attempts = nodeAssessment.getAttempts() == null ? 1 : nodeAssessment.getAttempts().intValue() + 1;
    nodeAssessment.setAttempts(attempts);
    assessmentService.updateAssessmentEntry(nodeAssessment);
    if (courseNode instanceof AssessableCourseNode) {
        // Update users efficiency statement
        efficiencyStatementManager.updateUserEfficiencyStatement(userCourseEnv);
    }
    // notify about changes
    AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_ATTEMPTS_CHANGED, assessedIdentity);
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessmentChangedEvent(org.olat.course.assessment.AssessmentChangedEvent) ICourse(org.olat.course.ICourse) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry)

Example 14 with AssessableCourseNode

use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.

the class CourseNodeSelectionController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == menuTree) {
        if (event instanceof TreeEvent) {
            TreeEvent te = (TreeEvent) event;
            if (TreeEvent.COMMAND_TREENODE_OPEN.equals(te.getSubCommand()) || TreeEvent.COMMAND_TREENODE_CLOSE.equals(te.getSubCommand())) {
                Object uo = menuTree.getSelectedNode().getUserObject();
                if (menuTree.getSelectedNode() == menuTree.getTreeModel().getRootNode()) {
                // do nothing
                } else if (uo instanceof AssessableCourseNode && !(uo instanceof STCourseNode)) {
                    AssessableCourseNode selectedNode = (AssessableCourseNode) uo;
                    fireEvent(ureq, new CourseNodeEvent(CourseNodeEvent.SELECT_COURSE_NODE, selectedNode.getIdent()));
                }
            } else if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
                Object uo = menuTree.getSelectedNode().getUserObject();
                if (menuTree.getSelectedNode() == menuTree.getTreeModel().getRootNode()) {
                    CourseNode rootNode = (CourseNode) uo;
                    fireEvent(ureq, new CourseNodeEvent(CourseNodeEvent.SELECT_COURSE_NODE, rootNode.getIdent()));
                } else if (uo instanceof AssessableCourseNode && !(uo instanceof STCourseNode)) {
                    AssessableCourseNode selectedNode = (AssessableCourseNode) uo;
                    fireEvent(ureq, new CourseNodeEvent(CourseNodeEvent.SELECT_COURSE_NODE, selectedNode.getIdent()));
                }
            }
        }
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) STCourseNode(org.olat.course.nodes.STCourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) STCourseNode(org.olat.course.nodes.STCourseNode) CourseNode(org.olat.course.nodes.CourseNode) CourseNodeEvent(org.olat.course.assessment.ui.tool.event.CourseNodeEvent)

Example 15 with AssessableCourseNode

use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.

the class IdentityListCourseNodeController method doSetVisibility.

private void doSetVisibility(UserRequest ureq, Boolean visibility, List<AssessedIdentityElementRow> rows) {
    ICourse course = CourseFactory.loadCourse(courseEntry);
    AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
    for (AssessedIdentityElementRow row : rows) {
        Identity assessedIdentity = securityManager.loadIdentityByKey(row.getIdentityKey());
        Roles roles = securityManager.getRoles(assessedIdentity);
        IdentityEnvironment identityEnv = new IdentityEnvironment(assessedIdentity, roles);
        UserCourseEnvironment assessedUserCourseEnv = new UserCourseEnvironmentImpl(identityEnv, course.getCourseEnvironment(), coachCourseEnv.isCourseReadOnly());
        assessedUserCourseEnv.getScoreAccounting().evaluateAll();
        ScoreEvaluation scoreEval = assessableCourseNode.getUserScoreEvaluation(assessedUserCourseEnv);
        ScoreEvaluation doneEval = new ScoreEvaluation(scoreEval.getScore(), scoreEval.getPassed(), scoreEval.getAssessmentStatus(), visibility, scoreEval.getFullyAssessed(), scoreEval.getCurrentRunCompletion(), scoreEval.getCurrentRunStatus(), scoreEval.getAssessmentID());
        assessableCourseNode.updateUserScoreEvaluation(doneEval, assessedUserCourseEnv, getIdentity(), false, Role.coach);
    }
    loadModel(ureq);
}
Also used : CalculatedAssessableCourseNode(org.olat.course.nodes.CalculatedAssessableCourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) AssessedIdentityElementRow(org.olat.modules.assessment.ui.AssessedIdentityElementRow) ICourse(org.olat.course.ICourse) Roles(org.olat.core.id.Roles) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment)

Aggregations

AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)118 CourseNode (org.olat.course.nodes.CourseNode)48 ICourse (org.olat.course.ICourse)40 Identity (org.olat.core.id.Identity)32 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)28 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)26 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)22 UserCourseEnvironmentImpl (org.olat.course.run.userview.UserCourseEnvironmentImpl)22 Date (java.util.Date)20 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)18 STCourseNode (org.olat.course.nodes.STCourseNode)18 ArrayList (java.util.ArrayList)16 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)16 CalculatedAssessableCourseNode (org.olat.course.nodes.CalculatedAssessableCourseNode)14 GTACourseNode (org.olat.course.nodes.GTACourseNode)12 File (java.io.File)10 IOException (java.io.IOException)10 WindowControl (org.olat.core.gui.control.WindowControl)10 MSCourseNode (org.olat.course.nodes.MSCourseNode)10 PersistentAssessableCourseNode (org.olat.course.nodes.PersistentAssessableCourseNode)10