Search in sources :

Example 36 with CorruptedCourseException

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

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)

Example 37 with CorruptedCourseException

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

the class EditorMainController method requestForClose.

@Override
public boolean requestForClose(UserRequest ureq) {
    boolean immediateClose = true;
    try {
        ICourse course = CourseFactory.loadCourse(ores.getResourceableId());
        if (hasPublishableChanges(course)) {
            doQuickPublish(ureq, course);
            immediateClose = false;
        }
    } catch (CorruptedCourseException | NullPointerException e) {
        logError("Error request on close: " + ores, e);
    }
    return immediateClose;
}
Also used : CorruptedCourseException(org.olat.course.CorruptedCourseException) ICourse(org.olat.course.ICourse)

Example 38 with CorruptedCourseException

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

the class CertificatesManagerImpl method isCertificationAllowed.

@Override
public boolean isCertificationAllowed(Identity identity, RepositoryEntry entry) {
    boolean allowed = false;
    try {
        ICourse course = CourseFactory.loadCourse(entry);
        CourseConfig config = course.getCourseEnvironment().getCourseConfig();
        if (config.isRecertificationEnabled()) {
            Certificate certificate = getLastCertificate(identity, entry.getOlatResource().getKey());
            if (certificate == null) {
                allowed = true;
            } else {
                Calendar cal = Calendar.getInstance();
                Date now = cal.getTime();
                Date nextCertificationDate = getDateNextRecertification(certificate, config);
                allowed = (nextCertificationDate != null ? nextCertificationDate.before(now) : false);
            }
        } else {
            allowed = !hasCertificate(identity, entry.getOlatResource().getKey());
        }
    } catch (CorruptedCourseException e) {
        log.error("", e);
    }
    return allowed;
}
Also used : CorruptedCourseException(org.olat.course.CorruptedCourseException) Calendar(java.util.Calendar) ICourse(org.olat.course.ICourse) Date(java.util.Date) CourseConfig(org.olat.course.config.CourseConfig) Certificate(org.olat.course.certificate.Certificate)

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