Search in sources :

Example 26 with AssessmentItemEvent

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

the class MultipleChoiceEditorController 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) {
        // correct response
        String[] correctAnswers = ureq.getHttpReq().getParameterValues("correct");
        List<Identifier> correctAnswerList = new ArrayList<>();
        if (correctAnswers != null) {
            for (String correctAnswer : correctAnswers) {
                correctAnswerList.add(Identifier.parseString(correctAnswer));
            }
        }
        itemBuilder.setCorrectAnswers(correctAnswerList);
        // shuffle
        itemBuilder.setShuffle(shuffleEl.isOneSelected() && shuffleEl.isSelected(0));
        // orientation
        itemBuilder.setOrientation(Orientation.valueOf(orientationEl.getSelectedKey()));
        // alignment
        if (alignmentEl.isOneSelected() && alignmentEl.isSelected(1)) {
            itemBuilder.addClass(QTI21Constants.CHOICE_ALIGN_RIGHT);
        } else {
            itemBuilder.removeClass(QTI21Constants.CHOICE_ALIGN_RIGHT);
        }
    }
    // replace simple choices
    List<SimpleChoice> choiceList = new ArrayList<>();
    for (SimpleChoiceWrapper choiceWrapper : choiceWrappers) {
        SimpleChoice choice = choiceWrapper.getSimpleChoice();
        // text
        String answer = choiceWrapper.getAnswer().getRawValue();
        itemBuilder.getHtmlHelper().appendHtml(choice, answer);
        choiceList.add(choice);
    }
    itemBuilder.setSimpleChoices(choiceList);
    fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem(), QTI21QuestionType.sc));
}
Also used : SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ArrayList(java.util.ArrayList) AssessmentItemEvent(org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent)

Example 27 with AssessmentItemEvent

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

the class AssessmentItemEditorController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (event instanceof AssessmentItemEvent) {
        AssessmentItemEvent aie = (AssessmentItemEvent) event;
        if (AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED.equals(aie.getCommand())) {
            doBuildAndSaveAssessmentItem();
            doBuildAndCommitMetadata();
            fireEvent(ureq, new AssessmentItemEvent(aie.getCommand(), aie.getAssessmentItem(), itemRef, aie.getQuestionType()));
        } else if (AssessmentItemEvent.ASSESSMENT_ITEM_NEED_RELOAD.equals(aie.getCommand())) {
            fireEvent(ureq, event);
        }
    } else if (poolEditor == source) {
        if (event instanceof DetachFromPoolEvent) {
            fireEvent(ureq, event);
        }
    }
    super.event(ureq, source, event);
}
Also used : DetachFromPoolEvent(org.olat.ims.qti21.ui.editor.events.DetachFromPoolEvent) AssessmentItemEvent(org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent)

Example 28 with AssessmentItemEvent

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

the class MinimalScoreController 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));
    fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem()));
}
Also used : AssessmentItemEvent(org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent)

Example 29 with AssessmentItemEvent

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

the class DrawingEditorController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    if (readOnly)
        return;
    // title
    itemBuilder.setTitle(titleEl.getValue());
    File objectImg = null;
    if (backgroundImage != null) {
        objectImg = backgroundImage;
    } else if (initialBackgroundImage != null) {
        objectImg = initialBackgroundImage;
    }
    if (objectImg != null) {
        String filename = objectImg.getName();
        String mimeType = WebappHelper.getMimeType(filename);
        Size size = imageService.getSize(new LocalFileImpl(objectImg), null);
        int height = -1;
        int width = -1;
        if (size != null) {
            height = size.getHeight();
            width = size.getWidth();
        }
        itemBuilder.setBackground(filename, mimeType, height, width);
    }
    // question
    String questionText = textEl.getRawValue();
    itemBuilder.setQuestion(questionText);
    fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem(), QTI21QuestionType.drawing));
}
Also used : 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 30 with AssessmentItemEvent

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

the class UnkownItemEditorController method doConvertItem.

private void doConvertItem(UserRequest ureq, QTI21QuestionType alternativeType) {
    item.setToolName(QTI21Constants.TOOLNAME);
    item.setToolVersion(Settings.getVersion());
    if (alternativeType == QTI21QuestionType.matchdraganddrop) {
        addClassToInteraction(QTI21Constants.CSS_MATCH_DRAG_AND_DROP);
    }
    qtiService.updateAssesmentObject(itemFileRef, resolvedAssessmentItem);
    fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_NEED_RELOAD, item));
}
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