Search in sources :

Example 36 with UserCourseEnvironment

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

the class EPFrontendManager method submitMap.

private void submitMap(PortfolioStructureMap map, boolean logActivity, Role by) {
    // add an exception
    if (!(map instanceof EPStructuredMap))
        return;
    EPStructuredMap submittedMap = (EPStructuredMap) map;
    structureManager.submitMap(submittedMap);
    EPTargetResource resource = submittedMap.getTargetResource();
    OLATResourceable courseOres = resource.getOLATResourceable();
    ICourse course = CourseFactory.loadCourse(courseOres);
    AssessmentManager am = course.getCourseEnvironment().getAssessmentManager();
    CourseNode courseNode = course.getRunStructure().getNode(resource.getSubPath());
    List<Identity> owners = policyManager.getOwners(submittedMap);
    for (Identity owner : owners) {
        if (courseNode != null) {
            // courseNode might have been deleted meanwhile
            IdentityEnvironment ienv = new IdentityEnvironment();
            ienv.setIdentity(owner);
            UserCourseEnvironment uce = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
            if (logActivity) {
                am.incrementNodeAttempts(courseNode, owner, uce, by);
            } else {
                am.incrementNodeAttemptsInBackground(courseNode, owner, uce);
            }
            RepositoryEntry referenceEntry = courseNode.getReferencedRepositoryEntry();
            RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
            assessmentService.updateAssessmentEntry(owner, courseEntry, courseNode.getIdent(), referenceEntry, AssessmentEntryStatus.inReview);
        }
        assessmentNotificationsHandler.markPublisherNews(owner, course.getResourceableId());
        log.audit("Map " + map + " from " + owner.getName() + " has been submitted.");
    }
}
Also used : EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) EPTargetResource(org.olat.portfolio.model.structel.EPTargetResource) OLATResourceable(org.olat.core.id.OLATResourceable) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) AssessmentManager(org.olat.course.assessment.AssessmentManager) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment)

Example 37 with UserCourseEnvironment

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

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 38 with UserCourseEnvironment

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

the class QTI21RetrieveTestsController method doRetrieveTest.

private void doRetrieveTest(AssessmentTestSession session) {
    session = qtiService.getAssessmentTestSession(session.getKey());
    session = qtiService.pullSession(session, getSignatureOptions(session), getIdentity());
    if (courseNode != null) {
        RepositoryEntry courseEntry = session.getRepositoryEntry();
        CourseEnvironment courseEnv = CourseFactory.loadCourse(courseEntry).getCourseEnvironment();
        UserCourseEnvironment assessedUserCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(session.getIdentity(), courseEnv);
        courseNode.pullAssessmentTestSession(session, assessedUserCourseEnv, getIdentity(), Role.coach);
    }
}
Also used : CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 39 with UserCourseEnvironment

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

the class CourseTemplateSearchController method loadModel.

private void loadModel(UserRequest ureq) {
    IdentityEnvironment identityEnv = ureq.getUserSession().getIdentityEnvironment();
    List<Binder> currentBinders = portfolioService.searchOwnedBindersFromCourseTemplate(getIdentity());
    Set<CurrentBinder> currentSet = new HashSet<>();
    for (Binder currentBinder : currentBinders) {
        Long courseEntryKey = currentBinder.getEntry().getKey();
        String nodeIdent = currentBinder.getSubIdent();
        currentSet.add(new CurrentBinder(courseEntryKey, nodeIdent));
    }
    List<RepositoryEntry> entries = portfolioService.searchCourseWithBinderTemplates(getIdentity());
    List<CourseTemplateRow> rows = new ArrayList<>(entries.size());
    for (RepositoryEntry entry : entries) {
        ICourse course = CourseFactory.loadCourse(entry);
        UserCourseEnvironment uce = new UserCourseEnvironmentImpl(identityEnv, course.getCourseEnvironment());
        uce.getScoreAccounting().evaluateAll();
        CourseNode rootNode = uce.getCourseEnvironment().getRunStructure().getRootNode();
        loadCourseModel(rootNode, uce, rows, currentSet);
    }
    model.setObjects(rows);
    tableEl.reset();
    tableEl.reloadData();
}
Also used : UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) CourseTemplateRow(org.olat.modules.portfolio.ui.model.CourseTemplateRow) Binder(org.olat.modules.portfolio.Binder) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) CourseNode(org.olat.course.nodes.CourseNode) PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) HashSet(java.util.HashSet)

Example 40 with UserCourseEnvironment

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

the class PortfolioServiceImpl method setAssessmentStatus.

@Override
public void setAssessmentStatus(Identity assessedIdentity, BinderRef binderRef, AssessmentEntryStatus status, Identity coachingIdentity) {
    Boolean fullyAssessed = Boolean.FALSE;
    if (status == AssessmentEntryStatus.done) {
        fullyAssessed = Boolean.TRUE;
    }
    Binder binder = binderDao.loadByKey(binderRef.getKey());
    RepositoryEntry entry = binder.getEntry();
    if ("CourseModule".equals(entry.getOlatResource().getResourceableTypeName())) {
        ICourse course = CourseFactory.loadCourse(entry);
        CourseNode courseNode = course.getRunStructure().getNode(binder.getSubIdent());
        if (courseNode instanceof PortfolioCourseNode) {
            PortfolioCourseNode pfNode = (PortfolioCourseNode) courseNode;
            UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
            AssessmentEvaluation eval = pfNode.getUserScoreEvaluation(userCourseEnv);
            ScoreEvaluation scoreEval = new ScoreEvaluation(eval.getScore(), eval.getPassed(), status, true, fullyAssessed, null, null, binder.getKey());
            pfNode.updateUserScoreEvaluation(scoreEval, userCourseEnv, coachingIdentity, false, Role.coach);
        }
    } else {
        OLATResource resource = ((BinderImpl) binder.getTemplate()).getOlatResource();
        RepositoryEntry referenceEntry = repositoryService.loadByResourceKey(resource.getKey());
        AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, binder.getEntry(), binder.getSubIdent(), referenceEntry);
        assessmentEntry.setFullyAssessed(fullyAssessed);
        assessmentEntry.setAssessmentStatus(status);
        assessmentService.updateAssessmentEntry(assessmentEntry);
    }
}
Also used : Binder(org.olat.modules.portfolio.Binder) AssessedBinder(org.olat.modules.portfolio.model.AssessedBinder) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) AssessmentEvaluation(org.olat.course.run.scoring.AssessmentEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) OLATResource(org.olat.resource.OLATResource) BinderImpl(org.olat.modules.portfolio.model.BinderImpl) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) CourseNode(org.olat.course.nodes.CourseNode) PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry)

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