Search in sources :

Example 46 with CourseNode

use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.

the class PortfolioServiceImpl method getAssessmentStatus.

@Override
public AssessmentEntryStatus getAssessmentStatus(Identity assessedIdentity, BinderRef binderRef) {
    Binder binder = binderDao.loadByKey(binderRef.getKey());
    RepositoryEntry entry = binder.getEntry();
    AssessmentEntryStatus status = null;
    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);
            status = eval.getAssessmentStatus();
        }
    } else {
        OLATResource resource = ((BinderImpl) binder.getTemplate()).getOlatResource();
        RepositoryEntry referenceEntry = repositoryService.loadByResourceKey(resource.getKey());
        AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, binder.getEntry(), binder.getSubIdent(), referenceEntry);
        status = assessmentEntry.getAssessmentStatus();
    }
    return status;
}
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) 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) AssessmentEntryStatus(org.olat.modules.assessment.model.AssessmentEntryStatus) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry)

Example 47 with CourseNode

use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.

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)

Example 48 with CourseNode

use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.

the class PortfolioServiceImpl method updateAssessmentEntryLastModification.

private void updateAssessmentEntryLastModification(Binder binder, Identity doer, Role by) {
    if (binder.getEntry() == null)
        return;
    RepositoryEntry entry = binder.getEntry();
    List<Identity> assessedIdentities = getMembers(binder, PortfolioRoles.owner.name());
    // order status from the entry / section
    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;
            for (Identity assessedIdentity : assessedIdentities) {
                UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
                pfNode.updateLastModifications(userCourseEnv, doer, by);
            }
        }
    } else {
        OLATResource resource = ((BinderImpl) binder.getTemplate()).getOlatResource();
        RepositoryEntry referenceEntry = repositoryService.loadByResourceKey(resource.getKey());
        for (Identity assessedIdentity : assessedIdentities) {
            AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, binder.getEntry(), binder.getSubIdent(), referenceEntry);
            if (by == Role.coach) {
                assessmentEntry.setLastCoachModified(new Date());
            } else if (by == Role.user) {
                assessmentEntry.setLastUserModified(new Date());
            }
            assessmentService.updateAssessmentEntry(assessmentEntry);
        }
    }
}
Also used : PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) 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) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Date(java.util.Date)

Example 49 with CourseNode

use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.

the class GTAReminderRuleTest method getGTACourseNode.

private GTACourseNode getGTACourseNode(RepositoryEntry courseEntry) {
    ICourse course = CourseFactory.loadCourse(courseEntry);
    CourseNode rootNode = course.getRunStructure().getRootNode();
    for (int i = rootNode.getChildCount(); i-- > 0; ) {
        INode child = rootNode.getChildAt(i);
        if (child instanceof GTACourseNode) {
            return ((GTACourseNode) child);
        }
    }
    return null;
}
Also used : INode(org.olat.core.util.nodes.INode) GTACourseNode(org.olat.course.nodes.GTACourseNode) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) GTACourseNode(org.olat.course.nodes.GTACourseNode)

Example 50 with CourseNode

use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.

the class HourOfDayStatisticUpdateManagerTest method statistics_hourOfDay.

@Test
public void statistics_hourOfDay() {
    Assert.assertNotNull(statisticUpdateManager);
    statisticUpdateManager.setEnabled(true);
    Assert.assertTrue(statisticUpdateManager.isEnabled());
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("log-3");
    RepositoryEntry re1 = JunitTestHelper.deployBasicCourse(id);
    ICourse course1 = CourseFactory.loadCourse(re1);
    CourseNode rootNode1 = course1.getRunStructure().getRootNode();
    CourseNode firstNode1 = (CourseNode) course1.getRunStructure().getRootNode().getChildAt(0);
    RepositoryEntry re2 = JunitTestHelper.deployBasicCourse(id);
    ICourse course2 = CourseFactory.loadCourse(re2);
    CourseNode rootNode2 = course2.getRunStructure().getRootNode();
    CourseNode firstNode2 = (CourseNode) course2.getRunStructure().getRootNode().getChildAt(0);
    Calendar ref = Calendar.getInstance();
    String date1 = null;
    String date2 = null;
    cleanUpLog();
    for (int i = 0; i < 12; i++) {
        addLogEntry(re1, rootNode1, ref, 0, getSecuredNowRef(ref, 1, i + 1), 1, i + 1);
        addLogEntry(re2, firstNode2, ref, 0, getSecuredNowRef(ref, 1, i + 1), 1, i + 1);
    }
    for (int i = 0; i < 7; i++) {
        addLogEntry(re1, rootNode1, ref, 1, 3 + i, 1, 1);
        date2 = addLogEntry(re2, rootNode2, ref, 1, 3 + i, 1, 1);
    }
    for (int i = 0; i < 9; i++) {
        date1 = addLogEntry(re1, firstNode1, ref, 2, 3 + i, 13, 1);
    }
    setLastUpdate(ref, 12);
    dbInstance.commitAndCloseSession();
    updateStatistics();
    // first log analyze
    String date = getHourOfDay(ref);
    checkStatistics(course1, rootNode1, date);
    checkStatistics(course1, firstNode1, date1);
    checkStatistics(course2, rootNode2, date2);
    // add log the same day
    Calendar now = Calendar.getInstance();
    addLogEntry(re1, rootNode1, ref, 0, now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), now.get(Calendar.SECOND) + 1);
    addLogEntry(re1, rootNode1, ref, 0, now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), now.get(Calendar.SECOND) + 2);
    addLogEntry(re2, firstNode2, ref, 0, now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), now.get(Calendar.SECOND) + 2);
    dbInstance.commitAndCloseSession();
    sleep(5000);
    // update stats incremental
    updateStatistics();
    checkStatistics(course1, rootNode1, date);
    checkStatistics(course1, firstNode1, date1);
    checkStatistics(course2, rootNode2, date2);
    checkStatistics(course2, firstNode2, date);
    // update all stats, must be the same results
    updateAllStatistics();
    checkStatistics(course1, rootNode1, date);
    checkStatistics(course1, firstNode1, date1);
    checkStatistics(course2, rootNode2, date2);
    checkStatistics(course2, firstNode2, date);
}
Also used : Calendar(java.util.Calendar) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) CourseNode(org.olat.course.nodes.CourseNode) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Aggregations

CourseNode (org.olat.course.nodes.CourseNode)402 ICourse (org.olat.course.ICourse)182 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)98 Identity (org.olat.core.id.Identity)74 STCourseNode (org.olat.course.nodes.STCourseNode)72 ArrayList (java.util.ArrayList)68 RepositoryEntry (org.olat.repository.RepositoryEntry)64 CourseEditorTreeNode (org.olat.course.tree.CourseEditorTreeNode)54 INode (org.olat.core.util.nodes.INode)44 GTACourseNode (org.olat.course.nodes.GTACourseNode)44 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)42 TACourseNode (org.olat.course.nodes.TACourseNode)40 TreeNode (org.olat.core.gui.components.tree.TreeNode)38 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)36 MSCourseNode (org.olat.course.nodes.MSCourseNode)36 ScormCourseNode (org.olat.course.nodes.ScormCourseNode)30 Test (org.junit.Test)28 AbstractAccessableCourseNode (org.olat.course.nodes.AbstractAccessableCourseNode)28 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)28 CourseEditorTreeModel (org.olat.course.tree.CourseEditorTreeModel)26