Search in sources :

Example 21 with CorruptedCourseException

use of org.olat.course.CorruptedCourseException in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_8_2_0 method upgradeCourseConditions.

private boolean upgradeCourseConditions(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
    if (!uhd.getBooleanDataValue(TASK_CONDITIONS)) {
        int counter = 0;
        List<RepositoryEntry> entries;
        SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters();
        params.setRoles(new Roles(true, false, false, false, false, false, false));
        params.addResourceTypes("CourseModule");
        do {
            entries = repositoryManager.genericANDQueryWithRolesRestriction(params, counter, REPO_ENTRIES_BATCH_SIZE, true);
            for (RepositoryEntry entry : entries) {
                try {
                    ICourse course = CourseFactory.loadCourse(entry.getOlatResource());
                    CourseEnvironmentMapper envMapper = getCourseEnvironmentMapper(entry);
                    course.postImport(null, envMapper);
                } catch (CorruptedCourseException e) {
                    log.error("Course seems corrupt: " + entry.getOlatResource().getResourceableId());
                } catch (Exception e) {
                    log.error("Course seems highly corrupt: " + entry.getOlatResource().getResourceableId());
                }
            }
            dbInstance.intermediateCommit();
            counter += entries.size();
            log.audit("Processed repository entries: " + entries.size());
        } while (entries.size() == REPO_ENTRIES_BATCH_SIZE);
        uhd.setBooleanDataValue(TASK_CONDITIONS, true);
        upgradeManager.setUpgradesHistory(uhd, VERSION);
    }
    return true;
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) CorruptedCourseException(org.olat.course.CorruptedCourseException) Roles(org.olat.core.id.Roles) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) CourseEnvironmentMapper(org.olat.course.export.CourseEnvironmentMapper) CorruptedCourseException(org.olat.course.CorruptedCourseException)

Example 22 with CorruptedCourseException

use of org.olat.course.CorruptedCourseException in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_11_2_1 method processCourse.

private boolean processCourse(RepositoryEntry entry) {
    try {
        ICourse course = CourseFactory.loadCourse(entry);
        CourseNode rootNode = course.getRunStructure().getRootNode();
        final List<TACourseNode> taskNodes = new ArrayList<>();
        new TreeVisitor(new Visitor() {

            @Override
            public void visit(INode node) {
                if (node instanceof TACourseNode) {
                    taskNodes.add((TACourseNode) node);
                }
            }
        }, rootNode, false).visitAll();
        for (TACourseNode taskNode : taskNodes) {
            processTaskCourseNode(course, entry, taskNode);
        }
        return true;
    } catch (CorruptedCourseException e) {
        log.warn("Corrupted course: " + entry.getDisplayname() + " (" + entry.getKey() + ")", e);
        return true;
    } catch (Exception e) {
        log.error("", e);
        return true;
    }
}
Also used : TreeVisitor(org.olat.core.util.tree.TreeVisitor) INode(org.olat.core.util.nodes.INode) TreeVisitor(org.olat.core.util.tree.TreeVisitor) Visitor(org.olat.core.util.tree.Visitor) CorruptedCourseException(org.olat.course.CorruptedCourseException) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) CorruptedCourseException(org.olat.course.CorruptedCourseException)

Example 23 with CorruptedCourseException

use of org.olat.course.CorruptedCourseException in project OpenOLAT by OpenOLAT.

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 24 with CorruptedCourseException

use of org.olat.course.CorruptedCourseException in project OpenOLAT by OpenOLAT.

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 25 with CorruptedCourseException

use of org.olat.course.CorruptedCourseException in project OpenOLAT by OpenOLAT.

the class CourseNodeFactory method launchReferencedRepoEntryEditor.

/**
 * Launch an editor for the repository entry which is referenced in the given
 * course node. The editor is launched in a new tab.
 *
 * @param ureq
 * @param node
 */
public boolean launchReferencedRepoEntryEditor(UserRequest ureq, WindowControl wControl, CourseNode node) {
    RepositoryEntry repositoryEntry = node.getReferencedRepositoryEntry();
    if (repositoryEntry == null) {
        // do nothing
        return false;
    }
    RepositoryHandler typeToEdit = RepositoryHandlerFactory.getInstance().getRepositoryHandler(repositoryEntry);
    if (typeToEdit.supportsEdit(repositoryEntry.getOlatResource()) == EditionSupport.no) {
        log.error("Trying to edit repository entry which has no associated editor: " + typeToEdit);
        return false;
    }
    try {
        String businessPath = "[RepositoryEntry:" + repositoryEntry.getKey() + "][Editor:0]";
        NewControllerFactory.getInstance().launch(businessPath, ureq, wControl);
        return true;
    } catch (CorruptedCourseException e) {
        log.error("Course corrupted: " + repositoryEntry.getKey() + " (" + repositoryEntry.getOlatResource().getResourceableId() + ")", e);
        return false;
    }
}
Also used : CorruptedCourseException(org.olat.course.CorruptedCourseException) RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryHandler(org.olat.repository.handlers.RepositoryHandler)

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