Search in sources :

Example 86 with UserCourseEnvironment

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

the class OLATUpgrade_12_0_0 method processCourseAssessmentLastModified.

private boolean processCourseAssessmentLastModified(RepositoryEntry entry) {
    try {
        ICourse course = CourseFactory.loadCourse(entry);
        CourseNode rootNode = course.getRunStructure().getRootNode();
        Set<Identity> changeSet = new HashSet<>();
        processCourseNodeAssessmentLastModified(course, entry, rootNode, changeSet);
        dbInstance.commitAndCloseSession();
        // update structure nodes and efficiency statement if any
        Set<Identity> identitiesWithEfficiencyStatements = findIdentitiesWithEfficiencyStatements(entry);
        for (Identity assessedIdentity : changeSet) {
            UserCourseEnvironment userCourseEnv = AssessmentHelper.createInitAndUpdateUserCourseEnvironment(assessedIdentity, course);
            if (identitiesWithEfficiencyStatements.contains(assessedIdentity)) {
                efficiencyStatementManager.updateUserEfficiencyStatement(userCourseEnv);
            }
            dbInstance.commitAndCloseSession();
        }
    } catch (CorruptedCourseException e) {
        log.error("Corrupted course: " + entry.getKey(), e);
    } catch (Exception e) {
        log.error("Unexpected error", e);
    } finally {
        dbInstance.commitAndCloseSession();
    }
    return true;
}
Also used : CorruptedCourseException(org.olat.course.CorruptedCourseException) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) MSCourseNode(org.olat.course.nodes.MSCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) ScormCourseNode(org.olat.course.nodes.ScormCourseNode) Identity(org.olat.core.id.Identity) CorruptedCourseException(org.olat.course.CorruptedCourseException) HashSet(java.util.HashSet)

Example 87 with UserCourseEnvironment

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

the class EditCommentController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    String comment = commentEl.getValue();
    row.setComment(comment);
    ICourse course = CourseFactory.loadCourse(courseOres);
    UserCourseEnvironment userCourseEnv = row.getUserCourseEnvironment(course);
    gtaNode.updateUserUserComment(comment, userCourseEnv, getIdentity());
    if (StringHelper.containsNonWhitespace(comment)) {
        row.getCommentEditLink().setIconLeftCSS("o_icon o_icon_comments");
    } else {
        row.getCommentEditLink().setIconLeftCSS("o_icon o_icon_comments_none");
    }
    fireEvent(ureq, Event.DONE_EVENT);
}
Also used : UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse)

Example 88 with UserCourseEnvironment

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

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

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

the class PortfolioServiceImpl method updateAssessmentEntry.

private void updateAssessmentEntry(Identity assessedIdentity, Binder binder, Set<AssessmentSection> assessmentSections, Identity coachingIdentity) {
    boolean allPassed = true;
    int totalSectionPassed = 0;
    int totalSectionClosed = 0;
    BigDecimal totalScore = new BigDecimal("0.0");
    AssessmentEntryStatus binderStatus = null;
    for (AssessmentSection assessmentSection : assessmentSections) {
        if (assessmentSection.getScore() != null) {
            totalScore = totalScore.add(assessmentSection.getScore());
        }
        if (assessmentSection.getPassed() != null && assessmentSection.getPassed().booleanValue()) {
            allPassed &= true;
            totalSectionPassed++;
        }
        Section section = assessmentSection.getSection();
        if (section.getSectionStatus() == SectionStatus.closed) {
            totalSectionClosed++;
        }
    }
    Boolean totalPassed = null;
    if (totalSectionClosed == assessmentSections.size()) {
        totalPassed = new Boolean(allPassed);
    } else {
        if (assessmentSections.size() == totalSectionPassed) {
            totalPassed = Boolean.TRUE;
        }
        binderStatus = AssessmentEntryStatus.inProgress;
    }
    // order status from the entry / section
    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;
            ScoreEvaluation scoreEval = new ScoreEvaluation(totalScore.floatValue(), totalPassed, binderStatus, true, true, null, null, binder.getKey());
            UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
            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.setScore(totalScore);
        assessmentEntry.setPassed(totalPassed);
        assessmentEntry.setAssessmentStatus(binderStatus);
        assessmentService.updateAssessmentEntry(assessmentEntry);
    }
}
Also used : PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) OLATResource(org.olat.resource.OLATResource) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) AssessmentEntryStatus(org.olat.modules.assessment.model.AssessmentEntryStatus) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) BigDecimal(java.math.BigDecimal) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) BinderImpl(org.olat.modules.portfolio.model.BinderImpl) CourseNode(org.olat.course.nodes.CourseNode) PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean)

Example 90 with UserCourseEnvironment

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

the class UserCalendarWebService method getCalendar.

private KalendarRenderWrapper getCalendar(UserRequest ureq, String calendarId) {
    int typeIndex = calendarId.indexOf('_');
    if (typeIndex <= 0 || (typeIndex + 1 >= calendarId.length())) {
        return null;
    }
    CalendarModule calendarModule = CoreSpringFactory.getImpl(CalendarModule.class);
    if (!calendarModule.isEnabled()) {
        return null;
    }
    String type = calendarId.substring(0, typeIndex);
    String id = calendarId.substring(typeIndex + 1);
    KalendarRenderWrapper wrapper = null;
    if ("group".equals(type) && calendarModule.isEnableGroupCalendar()) {
        Long groupId = Long.parseLong(id);
        BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
        BusinessGroup group = bgs.loadBusinessGroup(groupId);
        if (bgs.isIdentityInBusinessGroup(ureq.getIdentity(), group)) {
            CollaborationManager collaborationManager = CoreSpringFactory.getImpl(CollaborationManager.class);
            wrapper = collaborationManager.getCalendar(group, ureq, false);
        }
    } else if ("course".equals(type) && (calendarModule.isEnableCourseElementCalendar() || calendarModule.isEnableCourseToolCalendar())) {
        Long courseId = Long.parseLong(id);
        IdentityEnvironment ienv = new IdentityEnvironment();
        ienv.setIdentity(ureq.getIdentity());
        ienv.setRoles(ureq.getUserSession().getRoles());
        ICourse course = CourseFactory.loadCourse(courseId);
        UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
        wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
    } else if ("user".equals(type) && calendarModule.isEnablePersonalCalendar()) {
        if (id.equals(ureq.getIdentity().getName())) {
            wrapper = getPersonalCalendar(ureq.getIdentity());
        } else if (isAdmin(ureq.getHttpReq())) {
            Identity identity = BaseSecurityManager.getInstance().findIdentityByName(id);
            wrapper = getPersonalCalendar(identity);
        }
    }
    return wrapper;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) BusinessGroupService(org.olat.group.BusinessGroupService) CalendarModule(org.olat.commons.calendar.CalendarModule) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) CollaborationManager(org.olat.collaboration.CollaborationManager)

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