Search in sources :

Example 91 with UserCourseEnvironment

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

the class UserCalendarWebService method getCalendars.

private void getCalendars(CalendarVisitor calVisitor, UserRequest ureq) {
    Roles roles = ureq.getUserSession().getRoles();
    Identity retrievedUser = ureq.getIdentity();
    CalendarModule calendarModule = CoreSpringFactory.getImpl(CalendarModule.class);
    if (calendarModule.isEnabled()) {
        if (calendarModule.isEnablePersonalCalendar()) {
            KalendarRenderWrapper personalWrapper = getPersonalCalendar(ureq.getIdentity());
            calVisitor.visit(personalWrapper);
        }
        if (calendarModule.isEnableCourseToolCalendar() || calendarModule.isEnableCourseElementCalendar()) {
            RepositoryManager rm = RepositoryManager.getInstance();
            ACService acManager = CoreSpringFactory.getImpl(ACService.class);
            SearchRepositoryEntryParameters repoParams = new SearchRepositoryEntryParameters(retrievedUser, roles, "CourseModule");
            repoParams.setOnlyExplicitMember(true);
            repoParams.setIdentity(retrievedUser);
            IdentityEnvironment ienv = new IdentityEnvironment();
            ienv.setIdentity(retrievedUser);
            ienv.setRoles(roles);
            List<RepositoryEntry> entries = rm.genericANDQueryWithRolesRestriction(repoParams, 0, -1, true);
            for (RepositoryEntry entry : entries) {
                AccessResult result = acManager.isAccessible(entry, retrievedUser, false);
                if (result.isAccessible()) {
                    try {
                        final ICourse course = CourseFactory.loadCourse(entry);
                        CourseConfig config = course.getCourseEnvironment().getCourseConfig();
                        UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
                        if (config.isCalendarEnabled()) {
                            KalendarRenderWrapper wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
                            calVisitor.visit(wrapper);
                        } else {
                            CalCourseNodeVisitor visitor = new CalCourseNodeVisitor();
                            new CourseTreeVisitor(course, ienv).visit(visitor, new VisibleTreeFilter());
                            if (visitor.isFound()) {
                                KalendarRenderWrapper wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
                                calVisitor.visit(wrapper);
                            }
                        }
                    } catch (Exception e) {
                        log.error("", e);
                    }
                }
            }
        }
        if (calendarModule.isEnableGroupCalendar()) {
            CollaborationManager collaborationManager = CoreSpringFactory.getImpl(CollaborationManager.class);
            // start found forums in groups
            BusinessGroupService bgm = CoreSpringFactory.getImpl(BusinessGroupService.class);
            SearchBusinessGroupParams params = new SearchBusinessGroupParams(retrievedUser, true, true);
            params.addTools(CollaborationTools.TOOL_CALENDAR);
            List<BusinessGroup> groups = bgm.findBusinessGroups(params, null, 0, -1);
            for (BusinessGroup group : groups) {
                KalendarRenderWrapper wrapper = collaborationManager.getCalendar(group, ureq, false);
                calVisitor.visit(wrapper);
            }
        }
    }
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) BusinessGroup(org.olat.group.BusinessGroup) VisibleTreeFilter(org.olat.course.run.userview.VisibleTreeFilter) CourseTreeVisitor(org.olat.course.run.userview.CourseTreeVisitor) Roles(org.olat.core.id.Roles) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) WebApplicationException(javax.ws.rs.WebApplicationException) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams) CourseConfig(org.olat.course.config.CourseConfig) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) BusinessGroupService(org.olat.group.BusinessGroupService) ACService(org.olat.resource.accesscontrol.ACService) AccessResult(org.olat.resource.accesscontrol.AccessResult) CalendarModule(org.olat.commons.calendar.CalendarModule) RepositoryManager(org.olat.repository.RepositoryManager) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) CollaborationManager(org.olat.collaboration.CollaborationManager)

Example 92 with UserCourseEnvironment

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

the class GTACoachController method stepRevision.

@Override
protected Task stepRevision(UserRequest ureq, Task assignedTask) {
    assignedTask = super.stepRevision(ureq, assignedTask);
    boolean revisions = false;
    if (config.getBooleanSafe(GTACourseNode.GTASK_ASSIGNMENT) || config.getBooleanSafe(GTACourseNode.GTASK_SUBMIT) || config.getBooleanSafe(GTACourseNode.GTASK_REVIEW_AND_CORRECTION)) {
        if (assignedTask == null || assignedTask.getTaskStatus() == TaskProcess.assignment || assignedTask.getTaskStatus() == TaskProcess.submit || assignedTask.getTaskStatus() == TaskProcess.review) {
            mainVC.contextPut("revisionCssClass", "");
        } else if (assignedTask.getTaskStatus() == TaskProcess.revision || assignedTask.getTaskStatus() == TaskProcess.correction) {
            mainVC.contextPut("revisionCssClass", "o_active");
            revisions = true;
        } else if (assignedTask.getRevisionLoop() == 0) {
            mainVC.contextPut("skipRevisions", Boolean.TRUE);
            revisions = false;
        } else {
            mainVC.contextPut("revisionCssClass", "o_done");
            revisions = true;
        }
    } else if (assignedTask == null || assignedTask.getTaskStatus() == TaskProcess.revision || assignedTask.getTaskStatus() == TaskProcess.correction) {
        mainVC.contextPut("revisionCssClass", "o_active");
        revisions = true;
    } else {
        mainVC.contextPut("revisionCssClass", "o_done");
        revisions = true;
    }
    if (revisions) {
        if (GTAType.individual.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
            UserCourseEnvironment assessedUserCourseEnv = getAssessedUserCourseEnvironment();
            revisionDocumentsCtrl = new GTACoachRevisionAndCorrectionsController(ureq, getWindowControl(), courseEnv, assignedTask, gtaNode, coachCourseEnv, assessedGroup, assessedIdentity, assessedUserCourseEnv, taskListEventResource);
        } else {
            revisionDocumentsCtrl = new GTACoachRevisionAndCorrectionsController(ureq, getWindowControl(), courseEnv, assignedTask, gtaNode, coachCourseEnv, assessedGroup, null, null, taskListEventResource);
        }
        listenTo(revisionDocumentsCtrl);
        mainVC.put("revisionDocs", revisionDocumentsCtrl.getInitialComponent());
    }
    return assignedTask;
}
Also used : UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment)

Example 93 with UserCourseEnvironment

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

the class GTACoachRevisionAndCorrectionsController method doCollect.

private void doCollect() {
    assignedTask = gtaManager.updateTask(assignedTask, TaskProcess.correction, gtaNode, Role.coach);
    gtaManager.log("Collect revision", "revision collected", assignedTask, getIdentity(), assessedIdentity, assessedGroup, courseEnv, gtaNode);
    ICourse course = CourseFactory.loadCourse(courseEnv.getCourseResourceableId());
    if (businessGroupTask) {
        List<Identity> identities = businessGroupService.getMembers(assessedGroup, GroupRoles.participant.name());
        for (Identity identity : identities) {
            UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(identity, course);
            gtaNode.incrementUserAttempts(userCourseEnv, Role.coach);
        }
    } else {
        gtaNode.incrementUserAttempts(assessedUserCourseEnv, Role.coach);
    }
    TaskMultiUserEvent event = new TaskMultiUserEvent(TaskMultiUserEvent.SUBMIT_REVISION, assessedGroup == null ? getIdentity() : null, assessedGroup, getIdentity());
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, taskListEventResource);
}
Also used : UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) TaskMultiUserEvent(org.olat.course.nodes.gta.ui.events.TaskMultiUserEvent) ICourse(org.olat.course.ICourse) Identity(org.olat.core.id.Identity)

Example 94 with UserCourseEnvironment

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

the class IQIdentityListCourseNodeController method doUpdateCourseNode.

private void doUpdateCourseNode(List<AssessmentTestSession> testSessionsToComplete, AssessmentTest assessmentTest, AssessmentEntryStatus status) {
    if (testSessionsToComplete == null || testSessionsToComplete.isEmpty())
        return;
    Double cutValue = QtiNodesExtractor.extractCutValue(assessmentTest);
    for (AssessmentTestSession testSession : testSessionsToComplete) {
        UserCourseEnvironment assessedUserCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(testSession.getIdentity(), getCourseEnvironment());
        ScoreEvaluation scoreEval = ((IQTESTCourseNode) courseNode).getUserScoreEvaluation(assessedUserCourseEnv);
        BigDecimal finalScore = testSession.getFinalScore();
        Float score = finalScore == null ? null : finalScore.floatValue();
        Boolean passed = scoreEval.getPassed();
        if (testSession.getManualScore() != null && finalScore != null && cutValue != null) {
            boolean calculated = finalScore.compareTo(BigDecimal.valueOf(cutValue.doubleValue())) >= 0;
            passed = Boolean.valueOf(calculated);
        }
        AssessmentEntryStatus finalStatus = status == null ? scoreEval.getAssessmentStatus() : status;
        ScoreEvaluation manualScoreEval = new ScoreEvaluation(score, passed, finalStatus, scoreEval.getUserVisible(), scoreEval.getFullyAssessed(), scoreEval.getCurrentRunCompletion(), scoreEval.getCurrentRunStatus(), testSession.getKey());
        ((IQTESTCourseNode) courseNode).updateUserScoreEvaluation(manualScoreEval, assessedUserCourseEnv, getIdentity(), false, Role.coach);
    }
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) AssessmentEntryStatus(org.olat.modules.assessment.model.AssessmentEntryStatus) BigDecimal(java.math.BigDecimal)

Example 95 with UserCourseEnvironment

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

the class GroupAssessmentController method applyChangesForEveryMemberGroup.

private void applyChangesForEveryMemberGroup(List<AssessmentRow> rows, boolean setAsDone, boolean userVisible) {
    ICourse course = CourseFactory.loadCourse(courseEntry);
    for (AssessmentRow row : rows) {
        UserCourseEnvironment userCourseEnv = row.getUserCourseEnvironment(course);
        Float score = null;
        if (withScore) {
            String value = row.getScoreEl().getValue();
            if (StringHelper.containsNonWhitespace(value)) {
                score = Float.parseFloat(value);
            }
        }
        Boolean passed = null;
        if (withPassed) {
            if (cutValue == null) {
                passed = row.getPassedEl().isSelected(0);
            } else if (score != null) {
                passed = (score.floatValue() >= cutValue.floatValue()) ? Boolean.TRUE : Boolean.FALSE;
            }
        }
        ScoreEvaluation newScoreEval;
        if (setAsDone) {
            newScoreEval = new ScoreEvaluation(score, passed, AssessmentEntryStatus.done, userVisible, true, null, null, null);
        } else {
            newScoreEval = new ScoreEvaluation(score, passed, null, userVisible, null, null, null, null);
        }
        gtaNode.updateUserScoreEvaluation(newScoreEval, userCourseEnv, getIdentity(), false, Role.coach);
        if (withComment) {
            String comment = row.getComment();
            if (StringHelper.containsNonWhitespace(comment)) {
                gtaNode.updateUserUserComment(comment, userCourseEnv, getIdentity());
            }
        }
    }
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse)

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