Search in sources :

Example 71 with UserCourseEnvironment

use of org.olat.course.run.userview.UserCourseEnvironment in project openolat by klemens.

the class ConfirmReopenController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    testSession = qtiService.reopenAssessmentTestSession(testSession, getIdentity());
    if (testSession == null) {
        showWarning("");
    } else {
        UserCourseEnvironment assessedUserCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(testSession.getIdentity(), courseEnv);
        ScoreEvaluation scoreEval = courseNode.getUserScoreEvaluation(assessedUserCourseEnv);
        ScoreEvaluation reopenedScoreEval = new ScoreEvaluation(scoreEval.getScore(), scoreEval.getPassed(), AssessmentEntryStatus.inProgress, scoreEval.getUserVisible(), scoreEval.getFullyAssessed(), scoreEval.getCurrentRunCompletion(), AssessmentRunStatus.running, testSession.getKey());
        courseNode.updateUserScoreEvaluation(reopenedScoreEval, assessedUserCourseEnv, getIdentity(), false, Role.coach);
        ThreadLocalUserActivityLogger.log(QTI21LoggingAction.QTI_REOPEN_IN_COURSE, getClass());
    }
    fireEvent(ureq, Event.DONE_EVENT);
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment)

Example 72 with UserCourseEnvironment

use of org.olat.course.run.userview.UserCourseEnvironment in project openolat by klemens.

the class CheckListCourseNode method updateScorePassedOnPublish.

private void updateScorePassedOnPublish(Identity assessedIdentity, Identity coachIdentity, CheckboxManager checkboxManager, ICourse course) {
    AssessmentManager am = course.getCourseEnvironment().getAssessmentManager();
    Float currentScore = am.getNodeScore(this, assessedIdentity);
    Boolean currentPassed = am.getNodePassed(this, assessedIdentity);
    Float updatedScore = null;
    Boolean updatedPassed = null;
    ModuleConfiguration config = getModuleConfiguration();
    Boolean scoreGrantedBool = (Boolean) config.get(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD);
    if (scoreGrantedBool != null && scoreGrantedBool.booleanValue()) {
        updatedScore = checkboxManager.calculateScore(assessedIdentity, course, getIdent());
    } else {
        updatedScore = null;
    }
    Boolean passedBool = (Boolean) config.get(MSCourseNode.CONFIG_KEY_HAS_PASSED_FIELD);
    if (passedBool != null && passedBool.booleanValue()) {
        Float cutValue = (Float) config.get(MSCourseNode.CONFIG_KEY_PASSED_CUT_VALUE);
        Boolean sumCheckbox = (Boolean) config.get(CheckListCourseNode.CONFIG_KEY_PASSED_SUM_CHECKBOX);
        if (sumCheckbox != null && sumCheckbox.booleanValue()) {
            Integer minValue = (Integer) config.get(CheckListCourseNode.CONFIG_KEY_PASSED_SUM_CUTVALUE);
            int checkedBox = checkboxManager.countChecked(assessedIdentity, course, getIdent());
            if (minValue != null && minValue.intValue() <= checkedBox) {
                updatedPassed = Boolean.TRUE;
            } else {
                updatedPassed = Boolean.FALSE;
            }
        } else if (cutValue != null) {
            if (updatedScore == null) {
                updatedScore = checkboxManager.calculateScore(assessedIdentity, course, getIdent());
            }
            if (updatedScore != null && cutValue.floatValue() <= updatedScore.floatValue()) {
                updatedPassed = Boolean.TRUE;
            } else {
                updatedPassed = Boolean.FALSE;
            }
        }
    } else {
        updatedPassed = null;
    }
    boolean needUpdate = false;
    Boolean manualCorrection = (Boolean) config.get(CheckListCourseNode.CONFIG_KEY_PASSED_MANUAL_CORRECTION);
    if (manualCorrection == null || !manualCorrection.booleanValue()) {
        // update passed
        if ((currentPassed == null && updatedPassed != null && updatedScore != null && updatedScore.floatValue() > 0f) || (currentPassed != null && updatedPassed == null) || (currentPassed != null && !currentPassed.equals(updatedPassed))) {
            needUpdate = true;
        }
    }
    if ((currentScore == null && updatedScore != null && updatedScore.floatValue() > 0f) || (currentScore != null && updatedScore == null) || (currentScore != null && !currentScore.equals(updatedScore))) {
        needUpdate = true;
    }
    if (needUpdate) {
        ScoreEvaluation scoreEval = new ScoreEvaluation(updatedScore, updatedPassed);
        IdentityEnvironment identityEnv = new IdentityEnvironment(assessedIdentity, null);
        UserCourseEnvironment uce = new UserCourseEnvironmentImpl(identityEnv, course.getCourseEnvironment());
        am.saveScoreEvaluation(this, coachIdentity, assessedIdentity, scoreEval, uce, false, Role.coach);
    }
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) ModuleConfiguration(org.olat.modules.ModuleConfiguration) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) AssessmentManager(org.olat.course.assessment.AssessmentManager) IdentityEnvironment(org.olat.core.id.IdentityEnvironment)

Example 73 with UserCourseEnvironment

use of org.olat.course.run.userview.UserCourseEnvironment in project openolat by klemens.

the class CourseRuntimeController method initSettingsTools.

@Override
protected void initSettingsTools(Dropdown settings) {
    boolean courseAuthorRight = reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_COURSEEDITOR);
    if (courseAuthorRight || hasCourseRight(CourseRights.RIGHT_ASSESSMENT_MODE)) {
        boolean managed = RepositoryEntryManagedFlag.isManaged(getRepositoryEntry(), RepositoryEntryManagedFlag.editcontent);
        UserCourseEnvironment uce = getUserCourseEnvironment();
        if (uce == null) {
            logError("User course environnment is null: " + getRepositoryEntry(), null);
            // cannot edit settings without uce
            return;
        }
        settings.setElementCssClass("o_sel_course_settings");
        if (courseAuthorRight) {
            editDescriptionLink = LinkFactory.createToolLink("settings.cmd", translate("command.settings"), this, "o_icon_details");
            editDescriptionLink.setElementCssClass("o_sel_course_settings");
            editDescriptionLink.setEnabled(!managed);
            settings.addComponent(editDescriptionLink);
            accessLink = LinkFactory.createToolLink("access.cmd", translate("command.access"), this, "o_icon_password");
            accessLink.setElementCssClass("o_sel_course_access");
            accessLink.setEnabled(!managed);
            settings.addComponent(accessLink);
        }
        // course author right or the assessment mode access right
        assessmentModeLink = LinkFactory.createToolLink("assessment.mode.cmd", translate("command.assessment.mode"), this, "o_icon_assessment_mode");
        assessmentModeLink.setElementCssClass("o_sel_course_assessment_mode");
        assessmentModeLink.setEnabled(!managed);
        assessmentModeLink.setVisible(assessmentModule.isAssessmentModeEnabled() && !uce.isCourseReadOnly());
        settings.addComponent(assessmentModeLink);
        if (courseAuthorRight) {
            catalogLink = LinkFactory.createToolLink("access.cmd", translate("command.catalog"), this, "o_icon_catalog");
            catalogLink.setElementCssClass("o_sel_course_catalog");
            catalogLink.setVisible(repositoryModule.isCatalogEnabled());
            settings.addComponent(catalogLink);
            settings.addComponent(new Spacer(""));
            boolean layoutManaged = RepositoryEntryManagedFlag.isManaged(getRepositoryEntry(), RepositoryEntryManagedFlag.layout);
            layoutLink = LinkFactory.createToolLink("access.cmd", translate("command.layout"), this, "o_icon_layout");
            layoutLink.setElementCssClass("o_sel_course_layout");
            layoutLink.setEnabled(!layoutManaged);
            layoutLink.setVisible(!uce.isCourseReadOnly());
            settings.addComponent(layoutLink);
            optionsLink = LinkFactory.createToolLink("access.cmd", translate("command.options"), this, "o_icon_options");
            optionsLink.setElementCssClass("o_sel_course_options");
            optionsLink.setVisible(!uce.isCourseReadOnly());
            settings.addComponent(optionsLink);
            certificatesOptionsLink = LinkFactory.createToolLink("certificates.cmd", translate("command.options.certificates"), this, "o_icon_certificate");
            certificatesOptionsLink.setElementCssClass("o_sel_course_options_certificates");
            certificatesOptionsLink.setVisible(!uce.isCourseReadOnly());
            settings.addComponent(certificatesOptionsLink);
        }
        if (courseAuthorRight && reminderModule.isEnabled()) {
            reminderLink = LinkFactory.createToolLink("reminders.cmd", translate("command.options.reminders"), this, "o_icon_reminder");
            reminderLink.setElementCssClass("o_sel_course_reminders");
            reminderLink.setVisible(!uce.isCourseReadOnly());
            settings.addComponent(reminderLink);
        }
        if (courseAuthorRight && lectureModule.isEnabled()) {
            lecturesAdminLink = LinkFactory.createToolLink("lectures.admin.cmd", translate("command.options.lectures.admin"), this, "o_icon_lecture");
            lecturesAdminLink.setElementCssClass("o_sel_course_lectures_admin");
            lecturesAdminLink.setVisible(!uce.isCourseReadOnly());
            settings.addComponent(lecturesAdminLink);
        }
    }
}
Also used : UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) Spacer(org.olat.core.gui.components.dropdown.Dropdown.Spacer)

Example 74 with UserCourseEnvironment

use of org.olat.course.run.userview.UserCourseEnvironment in project openolat by klemens.

the class PassedRuleSPI method filter.

@Override
public void filter(RepositoryEntry entry, List<Identity> identities, ReminderRule rule) {
    if (rule instanceof ReminderRuleImpl) {
        ReminderRuleImpl r = (ReminderRuleImpl) rule;
        String nodeIdent = r.getLeftOperand();
        String status = r.getRightOperand();
        ICourse course = CourseFactory.loadCourse(entry);
        CourseNode courseNode = course.getRunStructure().getNode(nodeIdent);
        if (courseNode == null) {
            identities.clear();
            log.error("Passed rule in course " + entry.getKey() + " (" + entry.getDisplayname() + ") is missing a course element");
            return;
        }
        Map<Long, Boolean> passeds;
        if (courseNode instanceof STCourseNode) {
            passeds = new HashMap<>();
            STCourseNode structureNode = (STCourseNode) courseNode;
            if (structureNode.hasPassedConfigured()) {
                for (Identity identity : identities) {
                    UserCourseEnvironment uce = AssessmentHelper.createAndInitUserCourseEnvironment(identity, course);
                    ScoreEvaluation scoreEval = structureNode.getUserScoreEvaluation(uce);
                    Boolean passed = scoreEval.getPassed();
                    if (passed != null) {
                        passeds.put(identity.getKey(), passed);
                    }
                }
            }
        } else {
            passeds = helperDao.getPassed(entry, courseNode, identities);
        }
        if ("passed".equals(status)) {
            for (Iterator<Identity> identityIt = identities.iterator(); identityIt.hasNext(); ) {
                Boolean passed = passeds.get(identityIt.next().getKey());
                if (passed == null || !passed.booleanValue()) {
                    identityIt.remove();
                }
            }
        } else if ("failed".equals(status)) {
            for (Iterator<Identity> identityIt = identities.iterator(); identityIt.hasNext(); ) {
                Boolean passed = passeds.get(identityIt.next().getKey());
                if (passed != null && passed.booleanValue()) {
                    identityIt.remove();
                }
            }
        }
    }
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) STCourseNode(org.olat.course.nodes.STCourseNode) Iterator(java.util.Iterator) STCourseNode(org.olat.course.nodes.STCourseNode) CourseNode(org.olat.course.nodes.CourseNode) Identity(org.olat.core.id.Identity)

Example 75 with UserCourseEnvironment

use of org.olat.course.run.userview.UserCourseEnvironment in project openolat by klemens.

the class ConvertToGTACourseNode method convertAssessmentDatas.

private void convertAssessmentDatas(TaskList taskList, TACourseNode sourceNode, GTACourseNode gtaNode, ICourse course) {
    CourseEnvironment courseEnv = course.getCourseEnvironment();
    CoursePropertyManager propertyMgr = courseEnv.getCoursePropertyManager();
    Map<Long, AssessmentEntry> datas = new HashMap<>();
    List<AssessmentEntry> properties = courseEnv.getAssessmentManager().getAssessmentEntries(sourceNode);
    for (AssessmentEntry property : properties) {
        Identity identity = property.getIdentity();
        datas.put(identity.getKey(), property);
    }
    properties = null;
    DBFactory.getInstance().getCurrentEntityManager().clear();
    AssessmentManager assessmentMgr = courseEnv.getAssessmentManager();
    for (AssessmentEntry assessmentData : datas.values()) {
        Identity assessedIdentity = securityManager.loadIdentityByKey(assessmentData.getIdentity().getKey());
        if (assessmentData.getPassed() != null || assessmentData.getScore() != null) {
            UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
            Float score = assessmentData.getScore() == null ? null : assessmentData.getScore().floatValue();
            ScoreEvaluation scoreEval = new ScoreEvaluation(score, assessmentData.getPassed());
            assessmentMgr.saveScoreEvaluation(gtaNode, null, assessedIdentity, scoreEval, userCourseEnv, false, Role.auto);
            // set graded
            Task task = gtaManager.getTask(assessedIdentity, taskList);
            if (task == null) {
                gtaManager.createTask(null, taskList, TaskProcess.graded, null, assessedIdentity, gtaNode);
            } else {
                gtaManager.updateTask(task, TaskProcess.graded, gtaNode, Role.auto);
            }
        }
        if (assessmentData.getAttempts() != null) {
            assessmentMgr.saveNodeAttempts(gtaNode, null, assessedIdentity, assessmentData.getAttempts().intValue(), Role.auto);
        }
        if (StringHelper.containsNonWhitespace(assessmentData.getCoachComment())) {
            assessmentMgr.saveNodeCoachComment(gtaNode, assessedIdentity, assessmentData.getCoachComment());
        }
        if (StringHelper.containsNonWhitespace(assessmentData.getComment())) {
            assessmentMgr.saveNodeComment(gtaNode, null, assessedIdentity, assessmentData.getComment());
        }
    }
    DBFactory.getInstance().getCurrentEntityManager().clear();
    // copy log entries
    List<Property> logEntries = propertyMgr.listCourseNodeProperties(sourceNode, null, null, UserNodeAuditManager.LOG_IDENTIFYER);
    for (Property logEntry : logEntries) {
        String logText = logEntry.getTextValue();
        Identity identity = securityManager.loadIdentityByKey(logEntry.getIdentity().getKey());
        Property targetProp = propertyMgr.findCourseNodeProperty(gtaNode, identity, null, UserNodeAuditManager.LOG_IDENTIFYER);
        if (targetProp == null) {
            targetProp = propertyMgr.createCourseNodePropertyInstance(gtaNode, identity, null, UserNodeAuditManager.LOG_IDENTIFYER, null, null, null, logText);
        } else {
            targetProp.setTextValue(logText);
        }
        propertyMgr.saveProperty(targetProp);
    }
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) Task(org.olat.course.nodes.gta.Task) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) HashMap(java.util.HashMap) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) AssessmentManager(org.olat.course.assessment.AssessmentManager) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Identity(org.olat.core.id.Identity) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Aggregations

UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)158 ICourse (org.olat.course.ICourse)84 Identity (org.olat.core.id.Identity)60 UserCourseEnvironmentImpl (org.olat.course.run.userview.UserCourseEnvironmentImpl)58 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)54 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)52 CourseNode (org.olat.course.nodes.CourseNode)42 RepositoryEntry (org.olat.repository.RepositoryEntry)42 Test (org.junit.Test)28 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)24 ConditionInterpreter (org.olat.course.condition.interpreter.ConditionInterpreter)20 CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)16 Roles (org.olat.core.id.Roles)14 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)14 ArrayList (java.util.ArrayList)12 VFSContainer (org.olat.core.util.vfs.VFSContainer)12 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)12 OLATResource (org.olat.resource.OLATResource)12 Date (java.util.Date)10 AssessmentManager (org.olat.course.assessment.AssessmentManager)10