Search in sources :

Example 31 with CorruptedCourseException

use of org.olat.course.CorruptedCourseException in project openolat by klemens.

the class OLATUpgrade_11_0_0 method upgradeEfficiencyStatementTable.

private boolean upgradeEfficiencyStatementTable(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
    boolean allOk = true;
    if (!uhd.getBooleanDataValue(EFFICIENCY_STATEMENT_DATAS)) {
        int counter = 0;
        final Roles roles = new Roles(true, true, true, true, false, true, false);
        final SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters();
        params.setRoles(roles);
        params.setResourceTypes(Collections.singletonList("CourseModule"));
        List<RepositoryEntry> courses;
        do {
            courses = repositoryManager.genericANDQueryWithRolesRestriction(params, counter, 50, true);
            for (RepositoryEntry course : courses) {
                try {
                    convertUserEfficiencyStatemen(course);
                } catch (CorruptedCourseException e) {
                    log.error("Corrupted course: " + course.getKey(), e);
                }
            }
            counter += courses.size();
            log.audit("Efficiency statement data migration processed: " + courses.size() + ", total courses processed (" + counter + ")");
            dbInstance.commitAndCloseSession();
        } while (courses.size() == BATCH_SIZE);
        uhd.setBooleanDataValue(EFFICIENCY_STATEMENT_DATAS, allOk);
        upgradeManager.setUpgradesHistory(uhd, VERSION);
    }
    return allOk;
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) CorruptedCourseException(org.olat.course.CorruptedCourseException) GroupRoles(org.olat.basesecurity.GroupRoles) Roles(org.olat.core.id.Roles) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 32 with CorruptedCourseException

use of org.olat.course.CorruptedCourseException in project openolat by klemens.

the class OLATUpgrade_11_0_0 method upgradeAssessmentPropertyTable.

private boolean upgradeAssessmentPropertyTable(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
    boolean allOk = true;
    if (!uhd.getBooleanDataValue(ASSESSMENT_DATAS)) {
        int counter = 0;
        final Roles roles = new Roles(true, true, true, true, false, true, false);
        final SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters();
        params.setRoles(roles);
        params.setResourceTypes(Collections.singletonList("CourseModule"));
        List<RepositoryEntry> courses;
        do {
            courses = repositoryManager.genericANDQueryWithRolesRestriction(params, counter, 50, true);
            for (RepositoryEntry course : courses) {
                try {
                    allOk &= processCourseAssessmentData(course);
                } catch (CorruptedCourseException e) {
                    log.error("Corrupted course: " + course.getKey(), e);
                }
            }
            counter += courses.size();
            log.audit("Assessment data migration processed: " + courses.size() + ", total courses processed (" + counter + ")");
            dbInstance.commitAndCloseSession();
        } while (courses.size() == BATCH_SIZE);
        uhd.setBooleanDataValue(ASSESSMENT_DATAS, allOk);
        upgradeManager.setUpgradesHistory(uhd, VERSION);
    }
    return allOk;
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) CorruptedCourseException(org.olat.course.CorruptedCourseException) GroupRoles(org.olat.basesecurity.GroupRoles) Roles(org.olat.core.id.Roles) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 33 with CorruptedCourseException

use of org.olat.course.CorruptedCourseException in project openolat by klemens.

the class BinderConfiguration method createConfig.

public static BinderConfiguration createConfig(Binder binder) {
    boolean withScore = false;
    boolean withPassed = false;
    boolean assessable = false;
    Float maxScore = null;
    Float minScore = null;
    String displayname;
    RepositoryEntry entry = binder.getEntry();
    if (binder.getSubIdent() != null) {
        try {
            ICourse course = CourseFactory.loadCourse(entry);
            displayname = course.getCourseTitle();
            CourseNode courseNode = course.getRunStructure().getNode(binder.getSubIdent());
            if (courseNode instanceof PortfolioCourseNode) {
                PortfolioCourseNode pfNode = (PortfolioCourseNode) courseNode;
                withScore = pfNode.hasScoreConfigured();
                if (withScore) {
                    maxScore = pfNode.getMaxScoreConfiguration();
                    minScore = pfNode.getMinScoreConfiguration();
                }
                withPassed = pfNode.hasPassedConfigured();
                assessable = withPassed || withScore;
            } else {
                withPassed = true;
                withScore = false;
                assessable = true;
            }
        } catch (CorruptedCourseException e) {
            displayname = entry.getDisplayname();
            withPassed = withScore = assessable = false;
            log.error("Corrupted course: " + entry, e);
        }
    } else if (entry != null) {
        displayname = entry.getDisplayname();
        withPassed = true;
        withScore = false;
        assessable = true;
    } else {
        displayname = null;
        withPassed = withScore = assessable = false;
    }
    return new BinderConfiguration(assessable, withScore, maxScore, minScore, withPassed, true, true, false, displayname);
}
Also used : PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) CorruptedCourseException(org.olat.course.CorruptedCourseException) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) CourseNode(org.olat.course.nodes.CourseNode) PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode)

Example 34 with CorruptedCourseException

use of org.olat.course.CorruptedCourseException in project openolat by klemens.

the class EfficiencyStatementManagerTest method testBigDatas.

@Test
public void testBigDatas() {
    SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters();
    params.setRoles(new Roles(true, false, false, false, false, false, false));
    params.setResourceTypes(Collections.singletonList("CourseModule"));
    List<RepositoryEntry> entries = repositoryManager.genericANDQueryWithRolesRestriction(params, 0, -1, true);
    List<Identity> loadIdentities = securityManager.getVisibleIdentitiesByPowerSearch(null, null, false, null, null, null, null, null, 0, 10000);
    int count = 0;
    for (RepositoryEntry entry : entries) {
        Long resourceableId = entry.getOlatResource().getResourceableId();
        try {
            ICourse course = CourseFactory.loadCourse(resourceableId);
            boolean enabled = course.getCourseEnvironment().getCourseConfig().isEfficencyStatementEnabled();
            if (!enabled) {
                course = CourseFactory.openCourseEditSession(entry.getOlatResource().getResourceableId());
                CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig();
                courseConfig.setEfficencyStatementIsEnabled(true);
                CourseFactory.setCourseConfig(course.getResourceableId(), courseConfig);
                CourseFactory.saveCourse(course.getResourceableId());
                CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
            }
            DBFactory.getInstance().commitAndCloseSession();
            try {
                int fromIndex = (int) (Math.random() * loadIdentities.size() - 1);
                if (fromIndex < 100) {
                    fromIndex = 100;
                }
                List<Identity> assessedIdentities = loadIdentities.subList(fromIndex - 100, fromIndex);
                // force the storing of the efficiencyStatement - this is usually done only at Learnresource/modify properties/Efficiency statement (ON)
                RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
                efficiencyStatementManager.updateEfficiencyStatements(courseEntry, assessedIdentities);
            } catch (Exception e) {
                e.printStackTrace();
            }
            DBFactory.getInstance().commitAndCloseSession();
            DBFactory.getInstance().closeSession();
        } catch (CorruptedCourseException e) {
            System.out.println("Error");
        }
        if (count++ % 100 == 0) {
            dbInstance.commitAndCloseSession();
        }
    }
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) Roles(org.olat.core.id.Roles) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) CorruptedCourseException(org.olat.course.CorruptedCourseException) CourseConfig(org.olat.course.config.CourseConfig) CorruptedCourseException(org.olat.course.CorruptedCourseException) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 35 with CorruptedCourseException

use of org.olat.course.CorruptedCourseException in project openolat by klemens.

the class AssessmentModeListModel method getValueAt.

@Override
public Object getValueAt(AssessmentMode mode, int col) {
    switch(Cols.values()[col]) {
        case status:
            {
                List<String> warnings = null;
                Status status = mode.getStatus();
                try {
                    if (StringHelper.containsNonWhitespace(mode.getStartElement())) {
                        ICourse course = CourseFactory.loadCourse(mode.getRepositoryEntry());
                        CourseNode node = course.getRunStructure().getNode(mode.getStartElement());
                        if (node == null) {
                            warnings = new ArrayList<>(2);
                            warnings.add(translator.translate("warning.missing.start.element"));
                        }
                    }
                    if (StringHelper.containsNonWhitespace(mode.getElementList())) {
                        ICourse course = CourseFactory.loadCourse(mode.getRepositoryEntry());
                        String elements = mode.getElementList();
                        for (String element : elements.split(",")) {
                            CourseNode node = course.getRunStructure().getNode(element);
                            if (node == null) {
                                if (warnings == null) {
                                    warnings = new ArrayList<>(2);
                                }
                                warnings.add(translator.translate("warning.missing.element"));
                                break;
                            }
                        }
                    }
                } catch (CorruptedCourseException e) {
                    log.error("", e);
                    if (warnings == null) {
                        warnings = new ArrayList<>(2);
                    }
                    warnings.add(translator.translate("cif.error.corrupted"));
                }
                return new EnhancedStatus(status, warnings);
            }
        case course:
            return mode.getRepositoryEntry().getDisplayname();
        case externalId:
            return mode.getRepositoryEntry().getExternalId();
        case externalRef:
            return mode.getRepositoryEntry().getExternalRef();
        case name:
            return mode.getName();
        case begin:
            return mode.getBegin();
        case end:
            return mode.getEnd();
        case leadTime:
            return mode.getLeadTime();
        case followupTime:
            return mode.getFollowupTime();
        case target:
            return mode.getTargetAudience();
        case start:
            {
                boolean canStart = mode.isManualBeginEnd();
                if (canStart) {
                    canStart = coordinationService.canStart(mode);
                }
                return canStart;
            }
        case stop:
            {
                boolean canStop = mode.isManualBeginEnd();
                if (canStop) {
                    canStop = coordinationService.canStop(mode);
                }
                return canStop;
            }
    }
    return null;
}
Also used : EnhancedStatus(org.olat.course.assessment.model.EnhancedStatus) Status(org.olat.course.assessment.AssessmentMode.Status) CorruptedCourseException(org.olat.course.CorruptedCourseException) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) EnhancedStatus(org.olat.course.assessment.model.EnhancedStatus)

Aggregations

CorruptedCourseException (org.olat.course.CorruptedCourseException)38 ICourse (org.olat.course.ICourse)24 RepositoryEntry (org.olat.repository.RepositoryEntry)22 Roles (org.olat.core.id.Roles)10 CourseNode (org.olat.course.nodes.CourseNode)10 SearchRepositoryEntryParameters (org.olat.repository.model.SearchRepositoryEntryParameters)10 Identity (org.olat.core.id.Identity)6 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 GroupRoles (org.olat.basesecurity.GroupRoles)4 CourseConfig (org.olat.course.config.CourseConfig)4 RepositoryHandler (org.olat.repository.handlers.RepositoryHandler)4 OLATResource (org.olat.resource.OLATResource)4 IOException (java.io.IOException)2 Calendar (java.util.Calendar)2 Date (java.util.Date)2 List (java.util.List)2 Test (org.junit.Test)2 CalendarUserConfiguration (org.olat.commons.calendar.model.CalendarUserConfiguration)2 KalendarRenderWrapper (org.olat.commons.calendar.ui.components.KalendarRenderWrapper)2