Search in sources :

Example 6 with Selection

use of uk.ac.ed.ph.jqtiplus.node.test.Selection in project openolat by klemens.

the class AssessmentSectionOptionsEditorController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    section.setTitle(titleEl.getValue());
    // rubrics
    List<RubricBlock> rubricBlocks = new ArrayList<>();
    for (RichTextElement rubricEl : rubricEls) {
        String rubric = rubricEl.getRawValue();
        if (htmlBuilder.containsSomething(rubric)) {
            RubricBlock rubricBlock = (RubricBlock) rubricEl.getUserObject();
            if (rubricBlock == null) {
                rubricBlock = new RubricBlock(section);
                rubricBlock.setViews(Collections.singletonList(View.CANDIDATE));
            }
            rubricBlock.getBlocks().clear();
            htmlBuilder.appendHtml(rubricBlock, rubric);
            rubricBlocks.add(rubricBlock);
        }
    }
    section.getRubricBlocks().clear();
    section.getRubricBlocks().addAll(rubricBlocks);
    // shuffle
    boolean shuffle = (shuffleEl.isOneSelected() && shuffleEl.isSelected(0));
    if (shuffle) {
        if (section.getOrdering() == null) {
            section.setOrdering(new Ordering(section));
        }
        section.getOrdering().setShuffle(shuffle);
    } else {
        section.setOrdering(null);
    }
    // number of selected questions
    Integer randomSelection = null;
    if (StringHelper.containsNonWhitespace(randomSelectedEl.getSelectedKey())) {
        randomSelection = new Integer(randomSelectedEl.getSelectedKey());
    }
    if (randomSelection == null || randomSelection.intValue() < 1) {
        section.setSelection(null);
    } else {
        if (section.getSelection() == null) {
            section.setSelection(new Selection(section));
        }
        section.getSelection().setSelect(randomSelection);
    }
    fireEvent(ureq, new AssessmentSectionEvent(AssessmentSectionEvent.ASSESSMENT_SECTION_CHANGED, section));
}
Also used : RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) Selection(uk.ac.ed.ph.jqtiplus.node.test.Selection) ArrayList(java.util.ArrayList) Ordering(uk.ac.ed.ph.jqtiplus.node.test.Ordering) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock) AssessmentSectionEvent(org.olat.ims.qti21.ui.editor.events.AssessmentSectionEvent)

Aggregations

RubricBlock (uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)6 Selection (uk.ac.ed.ph.jqtiplus.node.test.Selection)6 File (java.io.File)4 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)4 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)4 Ordering (uk.ac.ed.ph.jqtiplus.node.test.Ordering)4 FileOutputStream (java.io.FileOutputStream)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 Test (org.junit.Test)2 RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)2 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)2 VFSItem (org.olat.core.util.vfs.VFSItem)2 Item (org.olat.ims.qti.editor.beecom.objects.Item)2 AssessmentItemBuilder (org.olat.ims.qti21.model.xml.AssessmentItemBuilder)2 ManifestBuilder (org.olat.ims.qti21.model.xml.ManifestBuilder)2 EssayAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder)2 FIBAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder)2