Search in sources :

Example 1 with EnhancedStatus

use of org.olat.course.assessment.model.EnhancedStatus in project OpenOLAT by OpenOLAT.

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)

Example 2 with EnhancedStatus

use of org.olat.course.assessment.model.EnhancedStatus in project OpenOLAT by OpenOLAT.

the class ModeStatusCellRenderer method render.

@Override
public void render(Renderer renderer, StringOutput sb, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator translator) {
    if (cellValue instanceof Status) {
        Status status = (Status) cellValue;
        renderStatus(status, sb);
    } else if (cellValue instanceof EnhancedStatus) {
        EnhancedStatus enStatus = (EnhancedStatus) cellValue;
        renderWarning(enStatus.getWarnings(), sb);
        renderStatus(enStatus.getStatus(), sb);
    }
}
Also used : EnhancedStatus(org.olat.course.assessment.model.EnhancedStatus) Status(org.olat.course.assessment.AssessmentMode.Status) EnhancedStatus(org.olat.course.assessment.model.EnhancedStatus)

Example 3 with EnhancedStatus

use of org.olat.course.assessment.model.EnhancedStatus 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)

Example 4 with EnhancedStatus

use of org.olat.course.assessment.model.EnhancedStatus in project openolat by klemens.

the class ModeStatusCellRenderer method render.

@Override
public void render(Renderer renderer, StringOutput sb, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator translator) {
    if (cellValue instanceof Status) {
        Status status = (Status) cellValue;
        renderStatus(status, sb);
    } else if (cellValue instanceof EnhancedStatus) {
        EnhancedStatus enStatus = (EnhancedStatus) cellValue;
        renderWarning(enStatus.getWarnings(), sb);
        renderStatus(enStatus.getStatus(), sb);
    }
}
Also used : EnhancedStatus(org.olat.course.assessment.model.EnhancedStatus) Status(org.olat.course.assessment.AssessmentMode.Status) EnhancedStatus(org.olat.course.assessment.model.EnhancedStatus)

Aggregations

Status (org.olat.course.assessment.AssessmentMode.Status)4 EnhancedStatus (org.olat.course.assessment.model.EnhancedStatus)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 CorruptedCourseException (org.olat.course.CorruptedCourseException)2 ICourse (org.olat.course.ICourse)2 CourseNode (org.olat.course.nodes.CourseNode)2