Search in sources :

Example 21 with UserCourseEnvironment

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

the class PFManagerTest method provideParticipantContainer.

@Test
public void provideParticipantContainer() {
    // prepare
    Identity initialAuthor = JunitTestHelper.createAndPersistIdentityAsRndUser("check-15");
    IdentityEnvironment ienv = new IdentityEnvironment();
    ienv.setIdentity(initialAuthor);
    PFCourseNode pfNode = new PFCourseNode();
    pfNode.getModuleConfiguration().setBooleanEntry(PFCourseNode.CONFIG_KEY_COACHBOX, true);
    pfNode.getModuleConfiguration().setBooleanEntry(PFCourseNode.CONFIG_KEY_PARTICIPANTBOX, true);
    // import "Demo course" into the bcroot_junittest
    RepositoryEntry entry = JunitTestHelper.deployDemoCourse(initialAuthor);
    Long resourceableId = entry.getOlatResource().getResourceableId();
    ICourse course = CourseFactory.loadCourse(resourceableId);
    UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
    Identity check3 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-3");
    repositoryEntryRelationDao.addRole(check3, entry, GroupRoles.participant.name());
    VFSContainer vfsContainer = pfManager.provideCoachOrParticipantContainer(pfNode, userCourseEnv, check3, false);
    Assert.assertNotNull(vfsContainer);
    Assert.assertTrue(vfsContainer.exists());
}
Also used : PFCourseNode(org.olat.course.nodes.PFCourseNode) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) VFSContainer(org.olat.core.util.vfs.VFSContainer) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) Test(org.junit.Test)

Example 22 with UserCourseEnvironment

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

the class PFManagerTest method provideCoachContainer.

@Test
public void provideCoachContainer() {
    // prepare
    Identity initialAuthor = JunitTestHelper.createAndPersistIdentityAsRndUser("check-16");
    IdentityEnvironment ienv = new IdentityEnvironment();
    ienv.setIdentity(initialAuthor);
    PFCourseNode pfNode = new PFCourseNode();
    pfNode.getModuleConfiguration().setBooleanEntry(PFCourseNode.CONFIG_KEY_COACHBOX, true);
    pfNode.getModuleConfiguration().setBooleanEntry(PFCourseNode.CONFIG_KEY_PARTICIPANTBOX, true);
    // import "Demo course" into the bcroot_junittest
    RepositoryEntry entry = JunitTestHelper.deployDemoCourse(initialAuthor);
    Long resourceableId = entry.getOlatResource().getResourceableId();
    ICourse course = CourseFactory.loadCourse(resourceableId);
    UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
    Identity check4 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-4");
    repositoryEntryRelationDao.addRole(check4, entry, GroupRoles.coach.name());
    VFSContainer vfsContainer = pfManager.provideCoachOrParticipantContainer(pfNode, userCourseEnv, check4, false);
    Assert.assertNotNull(vfsContainer);
}
Also used : PFCourseNode(org.olat.course.nodes.PFCourseNode) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) VFSContainer(org.olat.core.util.vfs.VFSContainer) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) Test(org.junit.Test)

Example 23 with UserCourseEnvironment

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

the class GTAAbstractController method doUpdateAttempts.

protected void doUpdateAttempts() {
    Role by = getDoer();
    if (businessGroupTask) {
        List<Identity> identities = businessGroupService.getMembers(assessedGroup, GroupRoles.participant.name());
        ICourse course = CourseFactory.loadCourse(courseEnv.getCourseGroupManager().getCourseEntry());
        for (Identity identity : identities) {
            UserCourseEnvironment uce = AssessmentHelper.createAndInitUserCourseEnvironment(identity, course);
            gtaNode.incrementUserAttempts(uce, by);
        }
    } else {
        UserCourseEnvironment assessedUserCourseEnv = getAssessedUserCourseEnvironment();
        gtaNode.incrementUserAttempts(assessedUserCourseEnv, by);
    }
}
Also used : Role(org.olat.modules.assessment.Role) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) Identity(org.olat.core.id.Identity)

Example 24 with UserCourseEnvironment

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

the class GTANotifications method createAssessmentItem.

private void createAssessmentItem(Task task, Identity assessedIdentity, boolean coach) {
    if (task == null || task.getGraduationDate() == null)
        return;
    if (task.getGraduationDate().after(compareDate)) {
        RepositoryEntry courseEntry = courseEnv.getCourseGroupManager().getCourseEntry();
        AssessmentEntry assessment = courseNodeAssessmentDao.loadAssessmentEntry(assessedIdentity, courseEntry, gtaNode.getIdent());
        boolean resultsVisible = assessment != null && (assessment.getUserVisibility() == null || assessment.getUserVisibility().booleanValue());
        if (resultsVisible) {
            String score = null;
            String status = null;
            if (gtaNode.hasScoreConfigured() && assessment.getScore() != null) {
                score = AssessmentHelper.getRoundedScore(assessment.getScore());
            }
            if (gtaNode.hasPassedConfigured() && assessment.getPassed() != null) {
                status = assessment.getPassed().booleanValue() ? translator.translate("notifications.assessment.passed.true") : translator.translate("notifications.assessment.passed.false");
            }
            Date graduationDate = task.getGraduationDate();
            String[] params = new String[] { getTaskName(task), courseEntry.getDisplayname(), score, status };
            if (score != null && status != null) {
                if (assessment.getPassed().booleanValue()) {
                    appendSubscriptionItem("notifications.assessment.score.passed", params, assessedIdentity, graduationDate, coach);
                } else {
                    appendSubscriptionItem("notifications.assessment.score.notpassed", params, assessedIdentity, graduationDate, coach);
                }
            } else if (score != null) {
                appendSubscriptionItem("notifications.assessment.score", params, assessedIdentity, graduationDate, coach);
            } else if (status != null) {
                appendSubscriptionItem("notifications.assessment.passed", params, assessedIdentity, graduationDate, coach);
            }
            ICourse course = CourseFactory.loadCourse(courseEnv.getCourseGroupManager().getCourseEntry());
            UserCourseEnvironment assessedUserCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
            List<File> docs = gtaNode.getIndividualAssessmentDocuments(assessedUserCourseEnv);
            for (File doc : docs) {
                String[] docParams = new String[] { getTaskName(task), courseEntry.getDisplayname(), doc.getName() };
                appendSubscriptionItemForFile("notifications.assessment.doc", docParams, assessedIdentity, "[assessment:0]", doc, graduationDate, coach);
            }
        }
    }
}
Also used : UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) File(java.io.File) Date(java.util.Date) TaskRevisionDate(org.olat.course.nodes.gta.TaskRevisionDate) DueDate(org.olat.course.nodes.gta.model.DueDate)

Example 25 with UserCourseEnvironment

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

the class GTANotifications method doUpdateAttempts.

private void doUpdateAttempts(Identity assessedIdentity, BusinessGroup assessedGroup) {
    ICourse course = CourseFactory.loadCourse(courseEnv.getCourseGroupManager().getCourseEntry());
    if (GTAType.group.name().equals(gtaNode.getModuleConfiguration().getStringValue(GTACourseNode.GTASK_TYPE))) {
        List<Identity> identities = businessGroupService.getMembers(assessedGroup, GroupRoles.participant.name());
        for (Identity identity : identities) {
            UserCourseEnvironment uce = AssessmentHelper.createAndInitUserCourseEnvironment(identity, course);
            gtaNode.incrementUserAttempts(uce, Role.auto);
        }
    } else {
        UserCourseEnvironment assessedUserCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
        gtaNode.incrementUserAttempts(assessedUserCourseEnv, Role.auto);
    }
}
Also used : UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) Identity(org.olat.core.id.Identity)

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