Search in sources :

Example 1 with AssessmentItemEvent

use of org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent in project OpenOLAT by OpenOLAT.

the class AssessmentTestComposerController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (event instanceof AssessmentTestEvent) {
        AssessmentTestEvent ate = (AssessmentTestEvent) event;
        if (ate == AssessmentTestEvent.ASSESSMENT_TEST_CHANGED_EVENT) {
            doSaveAssessmentTest(ureq, null);
        }
    } else if (event instanceof AssessmentTestPartEvent) {
        AssessmentTestPartEvent atpe = (AssessmentTestPartEvent) event;
        if (atpe == AssessmentTestPartEvent.ASSESSMENT_TEST_PART_CHANGED_EVENT) {
            doSaveAssessmentTest(ureq, null);
        }
    } else if (event instanceof AssessmentSectionEvent) {
        AssessmentSectionEvent ase = (AssessmentSectionEvent) event;
        if (AssessmentSectionEvent.ASSESSMENT_SECTION_CHANGED.equals(ase.getCommand())) {
            doSaveAssessmentTest(ureq, null);
            doUpdate(ase.getSection().getIdentifier(), ase.getSection().getTitle());
            doSaveManifest();
        }
    } else if (event instanceof AssessmentItemEvent) {
        AssessmentItemEvent aie = (AssessmentItemEvent) event;
        if (AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED.equals(aie.getCommand())) {
            assessmentChanged(ureq);
            doSaveAssessmentTest(ureq, null);
            doUpdate(aie.getAssessmentItemRef().getIdentifier(), aie.getAssessmentItem().getTitle());
            doSaveManifest();
        } else if (AssessmentItemEvent.ASSESSMENT_ITEM_METADATA_CHANGED.equals(aie.getCommand())) {
            doSaveManifest();
        } else if (AssessmentItemEvent.ASSESSMENT_ITEM_NEED_RELOAD.equals(aie.getCommand())) {
            doReloadItem(ureq);
        }
    } else if (event instanceof DetachFromPoolEvent) {
        DetachFromPoolEvent dfpe = (DetachFromPoolEvent) event;
        doDetachItemFromPool(ureq, dfpe.getItemRef());
    } else if (selectQItemCtrl == source) {
        cmc.deactivate();
        cleanUp();
        if (event instanceof QItemViewEvent) {
            QItemViewEvent e = (QItemViewEvent) event;
            List<QuestionItemView> items = e.getItemList();
            doInsert(ureq, items);
        }
    } else if (importTableWizard == source) {
        AssessmentItemsPackage importPackage = (AssessmentItemsPackage) importTableWizard.getRunContext().get("importPackage");
        getWindowControl().pop();
        cleanUp();
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            doInsert(ureq, importPackage);
        }
    } else if (confirmDeleteCtrl == source) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            // yes, delete
            doDelete(ureq, (TreeNode) confirmDeleteCtrl.getUserObject());
        }
        cleanUp();
    } else if (cmc == source) {
        cleanUp();
    }
    super.event(ureq, source, event);
}
Also used : AssessmentTestEvent(org.olat.ims.qti21.ui.editor.events.AssessmentTestEvent) DetachFromPoolEvent(org.olat.ims.qti21.ui.editor.events.DetachFromPoolEvent) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) AssessmentItemsPackage(org.olat.ims.qti21.questionimport.AssessmentItemsPackage) ArrayList(java.util.ArrayList) List(java.util.List) QItemViewEvent(org.olat.modules.qpool.ui.events.QItemViewEvent) AssessmentSectionEvent(org.olat.ims.qti21.ui.editor.events.AssessmentSectionEvent) AssessmentTestPartEvent(org.olat.ims.qti21.ui.editor.events.AssessmentTestPartEvent) AssessmentItemEvent(org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent)

Example 2 with AssessmentItemEvent

use of org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent in project OpenOLAT by OpenOLAT.

the class HotspotEditorController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    if (readOnly)
        return;
    itemBuilder.setTitle(titleEl.getValue());
    // set the question with the text entries
    String questionText = textEl.getRawValue();
    itemBuilder.setQuestion(questionText);
    itemBuilder.setResponsive(responsiveEl.isAtLeastSelected(1));
    File objectImg = null;
    if (backgroundImage != null) {
        objectImg = backgroundImage;
    } else if (initialBackgroundImage != null) {
        objectImg = initialBackgroundImage;
    }
    if (cardinalityEl.isOneSelected()) {
        String selectedCardinality = cardinalityEl.getSelectedKey();
        itemBuilder.setCardinality(Cardinality.valueOf(selectedCardinality));
    }
    boolean updateHotspot = true;
    if (objectImg != null) {
        String filename = objectImg.getName();
        String mimeType = WebappHelper.getMimeType(filename);
        Size currentSize = imageService.getSize(new LocalFileImpl(objectImg), null);
        Size size = currentSize;
        if (resizeEl.isVisible() && !resizeEl.isSelected(0)) {
            int maxSize = Integer.parseInt(resizeEl.getSelectedKey());
            if (maxSize < currentSize.getHeight() || maxSize < currentSize.getWidth()) {
                String extension = FileUtils.getFileSuffix(filename);
                size = imageService.scaleImage(objectImg, extension, objectImg, maxSize, maxSize, false);
                setBackgroundSize(size);
                scaleHotspot(currentSize, size);
                optimizeResizeEl(size, false);
                updateHotspot = false;
            }
        }
        int height = -1;
        int width = -1;
        if (size != null) {
            height = size.getHeight();
            width = size.getWidth();
        }
        String relPath = itemFile.getParentFile().toPath().relativize(objectImg.toPath()).toString();
        itemBuilder.setBackground(relPath, mimeType, height, width);
    }
    if (updateHotspot) {
        updateHotspots(ureq);
    }
    if (layoutEl.isOneSelected()) {
        String selectedLayout = layoutEl.getSelectedKey();
        for (HotspotLayouts layout : HotspotLayouts.values()) {
            itemBuilder.removeHotspotInteractionClass(layout.cssClass());
        }
        itemBuilder.addHotspotInteractionClass(selectedLayout);
    }
    if (shadowEl.isAtLeastSelected(1)) {
        itemBuilder.removeHotspotInteractionClass(QTI21Constants.CSS_HOTSPOT_DISABLE_SHADOW);
    } else {
        itemBuilder.addHotspotInteractionClass(QTI21Constants.CSS_HOTSPOT_DISABLE_SHADOW);
    }
    fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem(), QTI21QuestionType.hotspot));
}
Also used : HotspotLayouts(org.olat.ims.qti21.QTI21Constants.HotspotLayouts) Size(org.olat.core.commons.services.image.Size) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) File(java.io.File) AssessmentItemEvent(org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent)

Example 3 with AssessmentItemEvent

use of org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent in project OpenOLAT by OpenOLAT.

the class MatchEditorController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    if (readOnly)
        return;
    // title
    itemBuilder.setTitle(titleEl.getValue());
    // question
    String questionText = textEl.getRawValue();
    itemBuilder.setQuestion(questionText);
    if (!restrictedEdit) {
        boolean singleChoice = singleMultiEl.isOneSelected() && singleMultiEl.isSelected(0);
        itemBuilder.setMultipleChoice(!singleChoice);
    }
    // shuffle
    if (!restrictedEdit) {
        itemBuilder.setShuffle(shuffleEl.isOneSelected() && shuffleEl.isSelected(0));
    }
    // layout
    if (!restrictedEdit && layoutEl != null) {
        itemBuilder.removeMatchInteractionClass(layoutKeys);
        String cssClass = layoutEl.getSelectedKey();
        itemBuilder.addMatchInteractionClass(cssClass);
    }
    // update
    for (MatchWrapper sourceWrapper : sourceWrappers) {
        SimpleAssociableChoice choice = sourceWrapper.getSimpleChoice();
        String answer = sourceWrapper.getText().getRawValue();
        itemBuilder.getHtmlHelper().appendHtml(choice, answer);
    }
    for (MatchWrapper sourceWrapper : targetWrappers) {
        SimpleAssociableChoice choice = sourceWrapper.getSimpleChoice();
        String answer = sourceWrapper.getText().getRawValue();
        itemBuilder.getHtmlHelper().appendHtml(choice, answer);
    }
    // correct answers
    commitAssociations(ureq);
    fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem(), QTI21QuestionType.match));
}
Also used : AssessmentItemFactory.createSimpleAssociableChoice(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createSimpleAssociableChoice) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) AssessmentItemEvent(org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent)

Example 4 with AssessmentItemEvent

use of org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent in project OpenOLAT by OpenOLAT.

the class TrueFalseEditorController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    if (readOnly)
        return;
    // title
    itemBuilder.setTitle(titleEl.getValue());
    // question
    String questionText = textEl.getRawValue();
    itemBuilder.setQuestion(questionText);
    if (!restrictedEdit) {
        itemBuilder.setMultipleChoice(false);
        itemBuilder.setShuffle(false);
    }
    // update
    for (SourceWrapper sourceWrapper : sourceWrappers) {
        SimpleAssociableChoice choice = sourceWrapper.getSimpleChoice();
        String answer = sourceWrapper.getText().getRawValue();
        itemBuilder.getHtmlHelper().appendHtml(choice, answer);
    }
    // correct answers
    commitAssociations(ureq);
    fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem(), QTI21QuestionType.match));
}
Also used : AssessmentItemFactory.createSimpleAssociableChoice(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createSimpleAssociableChoice) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) AssessmentItemEvent(org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent)

Example 5 with AssessmentItemEvent

use of org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent in project OpenOLAT by OpenOLAT.

the class FIBScoreController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    if (restrictedEdit || readOnly)
        return;
    super.formOK(ureq);
    String maxScoreValue = maxScoreEl.getValue();
    Double maxScore = Double.parseDouble(maxScoreValue);
    itemBuilder.setMaxScore(maxScore);
    itemBuilder.setMinScore(new Double(0d));
    if (assessmentModeEl.isOneSelected() && assessmentModeEl.isSelected(1)) {
        itemBuilder.setScoreEvaluationMode(ScoreEvaluation.perAnswer);
        for (FIBEntryWrapper wrapper : wrappers) {
            String pointsStr = wrapper.getPointsEl().getValue();
            Double points = new Double(pointsStr);
            wrapper.getEntry().setScore(points);
        }
    } else {
        itemBuilder.setScoreEvaluationMode(ScoreEvaluation.allCorrectAnswers);
    }
    fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem(), null));
}
Also used : AssessmentItemEvent(org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent)

Aggregations

AssessmentItemEvent (org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent)42 ArrayList (java.util.ArrayList)9 SimpleAssociableChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice)6 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)6 File (java.io.File)4 Size (org.olat.core.commons.services.image.Size)4 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)4 AssessmentItemFactory.createSimpleAssociableChoice (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createSimpleAssociableChoice)4 DetachFromPoolEvent (org.olat.ims.qti21.ui.editor.events.DetachFromPoolEvent)4 SimpleChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice)4 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)2 TreeNode (org.olat.core.gui.components.tree.TreeNode)2 HotspotLayouts (org.olat.ims.qti21.QTI21Constants.HotspotLayouts)2 ModalFeedbackBuilder (org.olat.ims.qti21.model.xml.ModalFeedbackBuilder)2 AssessmentItemsPackage (org.olat.ims.qti21.questionimport.AssessmentItemsPackage)2 AssessmentSectionEvent (org.olat.ims.qti21.ui.editor.events.AssessmentSectionEvent)2 AssessmentTestEvent (org.olat.ims.qti21.ui.editor.events.AssessmentTestEvent)2