Search in sources :

Example 46 with OLATRuntimeException

use of org.olat.core.logging.OLATRuntimeException in project OpenOLAT by OpenOLAT.

the class ProjectBrokerCourseNode method getMinScoreConfiguration.

/**
 * @see org.olat.course.nodes.AssessableCourseNode#getMinScoreConfiguration()
 */
@Override
public Float getMinScoreConfiguration() {
    if (!hasScoreConfigured()) {
        throw new OLATRuntimeException(ProjectBrokerCourseNode.class, "getMinScore not defined when hasScore set to false", null);
    }
    ModuleConfiguration config = getModuleConfiguration();
    Float min = (Float) config.get(MSCourseNode.CONFIG_KEY_SCORE_MIN);
    return min;
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException)

Example 47 with OLATRuntimeException

use of org.olat.core.logging.OLATRuntimeException in project OpenOLAT by OpenOLAT.

the class ProjectBrokerCourseNode method getMaxScoreConfiguration.

/**
 * @see org.olat.course.nodes.AssessableCourseNode#getMaxScoreConfiguration()
 */
@Override
public Float getMaxScoreConfiguration() {
    if (!hasScoreConfigured()) {
        throw new OLATRuntimeException(ProjectBrokerCourseNode.class, "getMaxScore not defined when hasScore set to false", null);
    }
    ModuleConfiguration config = getModuleConfiguration();
    Float max = (Float) config.get(MSCourseNode.CONFIG_KEY_SCORE_MAX);
    return max;
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException)

Example 48 with OLATRuntimeException

use of org.olat.core.logging.OLATRuntimeException in project OpenOLAT by OpenOLAT.

the class AssessmentItemComponentRenderer method renderItemEvent.

private void renderItemEvent(AssessmentRenderer renderer, StringOutput sb, AssessmentItemComponent component, CandidateEvent candidateEvent, ItemSessionState itemSessionState, URLBuilder ubu, Translator translator) {
    final CandidateItemEventType itemEventType = candidateEvent.getItemEventType();
    /* If session has terminated, render appropriate state and exit */
    if (itemSessionState.isExited()) {
        renderTerminated(sb, translator);
        return;
    }
    if (itemEventType == CandidateItemEventType.SOLUTION) {
        renderer.setSolutionMode(true);
    }
    /* Now set candidate action permissions depending on state of session */
    if (itemEventType == CandidateItemEventType.SOLUTION || itemSessionState.isEnded()) {
        /* Item session is ended (closed) */
        renderer.setEndAllowed(false);
        renderer.setHardResetAllowed(false);
        renderer.setSoftResetAllowed(false);
        renderer.setSolutionAllowed(true);
        renderer.setCandidateCommentAllowed(false);
    } else if (itemSessionState.isOpen()) {
        /* Item session is open (interacting) */
        renderer.setEndAllowed(true);
        renderer.setHardResetAllowed(false);
        renderer.setSoftResetAllowed(false);
        renderer.setSolutionAllowed(true);
        renderer.setCandidateCommentAllowed(false);
    } else {
        throw new OLATRuntimeException("Item has not been entered yet. We do not currently support rendering of this state.", null);
    }
    // final List<CandidateEventNotification> notifications = candidateEvent.getNotifications();
    try {
        renderTestItemBody(renderer, sb, component, itemSessionState, ubu, translator);
    } catch (final RuntimeException e) {
        /* Rendering is complex and may trigger an unexpected Exception (due to a bug in the XSLT).
             * In this case, the best we can do for the candidate is to 'explode' the session.
             * See bug #49.
             */
        log.error("", e);
        renderExploded(sb, translator);
    }
}
Also used : CandidateItemEventType(org.olat.ims.qti21.model.audit.CandidateItemEventType) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException)

Example 49 with OLATRuntimeException

use of org.olat.core.logging.OLATRuntimeException in project OpenOLAT by OpenOLAT.

the class ScoDocument method getScoModel.

/**
 * getScoModel() - This method searches the CMI xml file that was created when
 * a scorm package was imported. It first gets all part_a elements that appear
 * in every sco file. It then looks for any <objective> elements, then looks
 * for part_b elements. Finally it then looks for any <interactions>. All of
 * these values are added to a vector (in the correct order). The vector is
 * then copied into a 2_D array, the first index representing an element/value
 * combination. The second index of this 2-D array allows us to get at our
 * name/value combinations (i.e. the second index only contains 2 elements 0 -
 * being the element name, 1 being its value)
 *
 * @return - a 2-D array of name value pairs.
 */
public String[][] getScoModel() {
    // if a sco was previously failed, then generate a clean model first...
    if (isFailed) {
        try {
            setDocument(formatCleanScoModel());
            // need to set the total time here
            saveDocument();
        } catch (IOException ex) {
            throw new OLATRuntimeException(this.getClass(), "Error: could not reset sco to its original state", ex);
        }
    }
    Vector<String[]> allElements = new Vector<String[]>();
    // first add all part A cmi model components...
    for (int i = 0; i < _cmivalues_a.length; i++) {
        String[] _cmicomponents = new String[2];
        _cmicomponents[0] = _cmivalues_a[i];
        _cmicomponents[1] = getElement(getDocument().getRootElement(), _cmivalues_a[i]).getText();
        allElements.add(_cmicomponents);
    }
    // next find if there are any objectives in the model
    Element objectivesCount = getElement(getDocument().getRootElement(), OBJECTIVES_COUNT);
    if (objectivesCount != null) {
        int noOfObjectives = Integer.parseInt(objectivesCount.getText());
        String[] _cmiobjectivescount = new String[2];
        _cmiobjectivescount[0] = OBJECTIVES_COUNT;
        _cmiobjectivescount[1] = objectivesCount.getText();
        allElements.add(_cmiobjectivescount);
        if (noOfObjectives > 0) {
            allElements.addAll(getObjectivesNodesFromModel(noOfObjectives));
        }
    }
    // next add all part B cmi model components...
    for (int i = 0; i < _cmivalues_b.length; i++) {
        String[] _cmicomponents = new String[2];
        _cmicomponents[0] = _cmivalues_b[i];
        _cmicomponents[1] = getElement(getDocument().getRootElement(), _cmivalues_b[i]).getText();
        allElements.add(_cmicomponents);
    }
    // next find if there are any interaction in the model
    Element interactionsCount = getElement(getDocument().getRootElement(), INTERACTIONS_COUNT);
    if (interactionsCount != null) {
        int noOfInteractions = Integer.parseInt(interactionsCount.getText());
        String[] _cmiinteractionscount = new String[2];
        _cmiinteractionscount[0] = INTERACTIONS_COUNT;
        _cmiinteractionscount[1] = interactionsCount.getText();
        allElements.add(_cmiinteractionscount);
        if (noOfInteractions > 0) {
            allElements.addAll(getInteractionsNodesFromModel());
        }
    }
    // finally copy the vector into our _cmiValuesForThisDoc string array
    // above so a complete list for this sco is available
    String[][] _cmiValuesForThisDoc = new String[allElements.size()][2];
    allElements.copyInto(_cmiValuesForThisDoc);
    // check for updates that may be needed in datamodel
    return doFinalPreUpdate(_cmiValuesForThisDoc, true);
}
Also used : OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) Element(org.jdom.Element) IOException(java.io.IOException) Vector(java.util.Vector)

Example 50 with OLATRuntimeException

use of org.olat.core.logging.OLATRuntimeException in project OpenOLAT by OpenOLAT.

the class SequencerModel method updateDiskModel.

/**
 * Method to commit the navigation xml file to disk
 *
 * @param sco
 * @param status
 */
public void updateDiskModel(String sco, String status) {
    List itemList = getDocument().getRootElement().getChildren(ITEM_NODE);
    Iterator itemListElement = itemList.iterator();
    while (itemListElement.hasNext()) {
        Element anItem = (Element) itemListElement.next();
        if (anItem.getAttributeValue(ITEM_IDENTIFIER).equals(sco)) {
            anItem.setText(status);
        }
    }
    try {
        saveDocument();
    } catch (IOException ex) {
        throw new OLATRuntimeException(this.getClass(), "could not save sequencer model.", ex);
    }
}
Also used : OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) Element(org.jdom.Element) Iterator(java.util.Iterator) List(java.util.List) IOException(java.io.IOException)

Aggregations

OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)268 IOException (java.io.IOException)104 File (java.io.File)50 ModuleConfiguration (org.olat.modules.ModuleConfiguration)26 ArrayList (java.util.ArrayList)22 AssertException (org.olat.core.logging.AssertException)22 FileOutputStream (java.io.FileOutputStream)20 OutputStream (java.io.OutputStream)20 Properties (java.util.Properties)20 FileInputStream (java.io.FileInputStream)18 HashMap (java.util.HashMap)18 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)18 QTIItemObject (org.olat.ims.qti.export.helper.QTIItemObject)18 DefaultElement (org.dom4j.tree.DefaultElement)16 Element (org.jdom.Element)16 InputStream (java.io.InputStream)14 BufferedInputStream (java.io.BufferedInputStream)12 List (java.util.List)12 Document (org.dom4j.Document)12 CPItem (org.olat.ims.cp.objects.CPItem)12