Search in sources :

Example 96 with UserCourseEnvironment

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

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

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

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

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

the class QTI21ResetDataController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    if (courseNode instanceof IQTESTCourseNode) {
        IQTESTCourseNode testCourseNode = (IQTESTCourseNode) courseNode;
        RepositoryEntry testEntry = courseNode.getReferencedRepositoryEntry();
        RepositoryEntry courseEntry = courseEnv.getCourseGroupManager().getCourseEntry();
        ICourse course = CourseFactory.loadCourse(courseEntry);
        archiveData(course, options);
        qtiService.deleteAssessmentTestSession(identities, testEntry, courseEntry, courseNode.getIdent());
        for (Identity identity : identities) {
            ScoreEvaluation scoreEval = new ScoreEvaluation(null, null, AssessmentEntryStatus.notStarted, null, Boolean.FALSE, 0.0d, AssessmentRunStatus.notStarted, null);
            IdentityEnvironment ienv = new IdentityEnvironment(identity, studentRoles);
            UserCourseEnvironment uce = new UserCourseEnvironmentImpl(ienv, courseEnv);
            testCourseNode.updateUserScoreEvaluation(scoreEval, uce, getIdentity(), false, Role.coach);
            testCourseNode.updateCurrentCompletion(uce, getIdentity(), null, AssessmentRunStatus.notStarted, Role.coach);
        }
    } else if (assessedEntry != null) {
        archiveData(assessedEntry);
        qtiService.deleteAssessmentTestSession(identities, assessedEntry, null, null);
    }
    fireEvent(ureq, Event.CHANGED_EVENT);
}
Also used : IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment)

Example 99 with UserCourseEnvironment

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

the class IdentityListCourseNodeController method doSetDone.

private void doSetDone(UserRequest ureq) {
    Set<Integer> selections = tableEl.getMultiSelectedIndex();
    List<AssessedIdentityElementRow> rows = new ArrayList<>(selections.size());
    for (Integer i : selections) {
        AssessedIdentityElementRow row = usersTableModel.getObject(i.intValue());
        if (row != null && row.getAssessmentStatus() != AssessmentEntryStatus.done) {
            rows.add(row);
        }
    }
    if (rows == null || rows.isEmpty()) {
        showWarning("warning.bulk.done");
    } else if (courseNode instanceof AssessableCourseNode) {
        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(), AssessmentEntryStatus.done, null, scoreEval.getFullyAssessed(), scoreEval.getCurrentRunCompletion(), scoreEval.getCurrentRunStatus(), scoreEval.getAssessmentID());
            assessableCourseNode.updateUserScoreEvaluation(doneEval, assessedUserCourseEnv, getIdentity(), false, Role.coach);
        }
        loadModel(ureq);
    }
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) AssessedIdentityElementRow(org.olat.modules.assessment.ui.AssessedIdentityElementRow) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) Roles(org.olat.core.id.Roles) CalculatedAssessableCourseNode(org.olat.course.nodes.CalculatedAssessableCourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment)

Example 100 with UserCourseEnvironment

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

the class IdentityCertificatesController method doGenerateCertificate.

private void doGenerateCertificate(UserRequest ureq) {
    ICourse course = CourseFactory.loadCourse(courseEntry);
    CourseNode rootNode = course.getRunStructure().getRootNode();
    Roles roles = securityManager.getRoles(assessedIdentity);
    IdentityEnvironment identityEnv = new IdentityEnvironment(assessedIdentity, roles);
    UserCourseEnvironment assessedUserCourseEnv = new UserCourseEnvironmentImpl(identityEnv, course.getCourseEnvironment());
    ScoreAccounting scoreAccounting = assessedUserCourseEnv.getScoreAccounting();
    scoreAccounting.evaluateAll();
    ScoreEvaluation scoreEval = scoreAccounting.evalCourseNode((AssessableCourseNode) rootNode);
    CertificateTemplate template = null;
    Long templateKey = course.getCourseConfig().getCertificateTemplate();
    if (templateKey != null) {
        template = certificatesManager.getTemplateById(templateKey);
    }
    Float score = scoreEval == null ? null : scoreEval.getScore();
    Boolean passed = scoreEval == null ? null : scoreEval.getPassed();
    CertificateInfos certificateInfos = new CertificateInfos(assessedIdentity, score, passed);
    certificatesManager.generateCertificate(certificateInfos, courseEntry, template, true);
    loadList();
    showInfo("msg.certificate.pending");
    fireEvent(ureq, Event.CHANGED_EVENT);
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CertificateTemplate(org.olat.course.certificate.CertificateTemplate) CertificateInfos(org.olat.course.certificate.model.CertificateInfos) ICourse(org.olat.course.ICourse) Roles(org.olat.core.id.Roles) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) ScoreAccounting(org.olat.course.run.scoring.ScoreAccounting) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseNode(org.olat.course.nodes.CourseNode) IdentityEnvironment(org.olat.core.id.IdentityEnvironment)

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