Search in sources :

Example 6 with RubricBlock

use of uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock in project openolat by klemens.

the class AssessmentTestFactory method appendAssessmentSectionInternal.

private static final AssessmentSection appendAssessmentSectionInternal(String title, AbstractPart part) {
    // section
    AssessmentSection section = new AssessmentSection(part);
    section.setFixed(Boolean.TRUE);
    section.setVisible(Boolean.TRUE);
    section.setTitle(title);
    section.setIdentifier(IdentifierGenerator.newAsIdentifier("sect"));
    if (part instanceof TestPart) {
        ((TestPart) part).getAssessmentSections().add(section);
    } else if (part instanceof AssessmentSection) {
        ((AssessmentSection) part).getSectionParts().add(section);
    }
    // section ordering
    Ordering ordering = new Ordering(section);
    ordering.setShuffle(false);
    section.setOrdering(ordering);
    // section rubric block
    RubricBlock rubricBlock = new RubricBlock(section);
    rubricBlock.setViews(Collections.singletonList(View.CANDIDATE));
    section.getRubricBlocks().add(rubricBlock);
    ItemSessionControl itemSessionControl = new ItemSessionControl(section);
    section.setItemSessionControl(itemSessionControl);
    return section;
}
Also used : ItemSessionControl(uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) Ordering(uk.ac.ed.ph.jqtiplus.node.test.Ordering) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)

Example 7 with RubricBlock

use of uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock in project openolat by klemens.

the class QTI12To21Converter method convert.

private void convert(Section section, TestPart testPart) throws URISyntaxException {
    AssessmentSection assessmentSection = AssessmentTestFactory.appendAssessmentSection("Section", testPart);
    assessmentSection.setTitle(section.getTitle());
    convertDuration(section.getDuration(), assessmentSection);
    RubricBlock rubricBlock = assessmentSection.getRubricBlocks().get(0);
    rubricBlock.getBlocks().clear();
    String objectives = section.getObjectives();
    htmlBuilder.appendHtml(rubricBlock, blockedHtml(objectives));
    boolean shuffle = SelectionOrdering.RANDOM.equals(section.getSelection_ordering().getOrderType());
    assessmentSection.getOrdering().setShuffle(shuffle);
    int selectionNum = section.getSelection_ordering().getSelectionNumber();
    if (selectionNum > 0) {
        Selection selection = new Selection(assessmentSection);
        selection.setSelect(selectionNum);
        assessmentSection.setSelection(selection);
    }
    List<Item> items = section.getItems();
    for (Item item : items) {
        AssessmentItemBuilder itemBuilder = null;
        if (item != null && item.getQuestion() != null) {
            int questionType = item.getQuestion().getType();
            switch(questionType) {
                case Question.TYPE_SC:
                    itemBuilder = convertSingleChoice(item);
                    break;
                case Question.TYPE_MC:
                    itemBuilder = convertMultipleChoice(item);
                    break;
                case Question.TYPE_KPRIM:
                    itemBuilder = convertKPrim(item);
                    break;
                case Question.TYPE_FIB:
                    itemBuilder = convertFIB(item);
                    break;
                case Question.TYPE_ESSAY:
                    itemBuilder = convertEssay(item);
                    break;
            }
        } else {
            errors.add(item.getTitle());
            log.error("Item without question: " + item);
        }
        if (itemBuilder != null) {
            itemBuilder.build();
            AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
            AssessmentItemRef itemRef = new AssessmentItemRef(assessmentSection);
            String itemId = IdentifierGenerator.newAsString(itemBuilder.getQuestionType().getPrefix());
            itemRef.setIdentifier(Identifier.parseString(itemId));
            convertItemBasics(item, itemRef);
            File itemFile = new File(unzippedDirRoot, itemId + ".xml");
            itemRef.setHref(new URI(itemFile.getName()));
            assessmentSection.getSectionParts().add(itemRef);
            persistAssessmentObject(itemFile, assessmentItem);
            appendResourceAndMetadata(item, itemBuilder, itemFile);
            // collect max score
            Double maxScore = QtiNodesExtractor.extractMaxScore(assessmentItem);
            if (maxScore != null && maxScore.doubleValue() > 0.0d) {
                atomicMaxScore.add(maxScore.doubleValue());
            }
        }
    }
}
Also used : Selection(uk.ac.ed.ph.jqtiplus.node.test.Selection) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder) AssessmentItemBuilder(org.olat.ims.qti21.model.xml.AssessmentItemBuilder) KPrimAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder) MultipleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder) SimpleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) URI(java.net.URI) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) Item(org.olat.ims.qti.editor.beecom.objects.Item) VFSItem(org.olat.core.util.vfs.VFSItem) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock) File(java.io.File)

Example 8 with RubricBlock

use of uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock in project openolat by klemens.

the class QTI21WordExport method renderAssessmentSection.

public void renderAssessmentSection(AssessmentSection assessmentSection, OpenXMLDocument document, boolean withResponses, Translator translator) {
    String title = assessmentSection.getTitle();
    document.appendHeading1(title, null);
    List<RubricBlock> rubricBlocks = assessmentSection.getRubricBlocks();
    for (RubricBlock rubricBlock : rubricBlocks) {
        String htmlRubric = htmlBuilder.blocksString(rubricBlock.getBlocks());
        document.appendHtmlText(htmlRubric, true);
    }
    for (SectionPart sectionPart : assessmentSection.getChildAbstractParts()) {
        if (sectionPart instanceof AssessmentSection) {
            renderAssessmentSection((AssessmentSection) sectionPart, document, withResponses, translator);
        } else if (sectionPart instanceof AssessmentItemRef) {
            AssessmentItemRef itemRef = (AssessmentItemRef) sectionPart;
            ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
            AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
            URI itemUri = resolvedAssessmentTest.getSystemIdByItemRefMap().get(itemRef);
            renderAssessmentItem(assessmentItem, new File(itemUri), mediaDir, document, withResponses, translator, htmlBuilder);
            document.appendPageBreak();
        }
    }
}
Also used : SectionPart(uk.ac.ed.ph.jqtiplus.node.test.SectionPart) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock) URI(java.net.URI) File(java.io.File)

Example 9 with RubricBlock

use of uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock in project openolat by klemens.

the class AssessmentSectionOptionsEditorController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    formLayout.setElementCssClass("o_sel_assessment_section_options");
    setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_section");
    if (!editable) {
        setFormWarning("warning.alien.assessment.test");
    }
    String title = section.getTitle();
    titleEl = uifactory.addTextElement("title", "form.metadata.title", 255, title, formLayout);
    titleEl.setEnabled(editable);
    titleEl.setMandatory(true);
    String relativePath = rootDirectory.toPath().relativize(testFile.toPath().getParent()).toString();
    VFSContainer itemContainer = (VFSContainer) rootContainer.resolve(relativePath);
    if (section.getRubricBlocks().isEmpty()) {
        RichTextElement rubricEl = uifactory.addRichTextElementForQTI21("rubric" + counter++, "form.imd.rubric", "", 12, -1, itemContainer, formLayout, ureq.getUserSession(), getWindowControl());
        rubricEl.getEditorConfiguration().setFileBrowserUploadRelPath("media");
        rubricEl.setEnabled(editable);
        rubricEls.add(rubricEl);
    } else {
        for (RubricBlock rubricBlock : section.getRubricBlocks()) {
            String rubric = htmlBuilder.blocksString(rubricBlock.getBlocks());
            RichTextElement rubricEl = uifactory.addRichTextElementForQTI21("rubric" + counter++, "form.imd.rubric", rubric, 12, -1, itemContainer, formLayout, ureq.getUserSession(), getWindowControl());
            rubricEl.getEditorConfiguration().setFileBrowserUploadRelPath("media");
            rubricEl.setEnabled(editable);
            rubricEl.setUserObject(rubricBlock);
            rubricEls.add(rubricEl);
        }
    }
    // shuffle
    String[] yesnoValues = new String[] { translate("yes"), translate("no") };
    shuffleEl = uifactory.addRadiosHorizontal("shuffle", "form.section.shuffle", formLayout, yesnoKeys, yesnoValues);
    if (section.getOrdering() != null && section.getOrdering().getShuffle()) {
        shuffleEl.select("y", true);
    } else {
        shuffleEl.select("n", true);
    }
    shuffleEl.setEnabled(!restrictedEdit && editable);
    int numOfItems = getNumOfQuestions(section);
    String[] theKeys = new String[numOfItems + 1];
    String[] theValues = new String[numOfItems + 1];
    theKeys[0] = "0";
    theValues[0] = translate("form.section.selection_all");
    for (int i = 0; i < numOfItems; i++) {
        theKeys[i + 1] = Integer.toString(i + 1);
        theValues[i + 1] = Integer.toString(i + 1);
    }
    randomSelectedEl = uifactory.addDropdownSingleselect("form.section.selection_pre", formLayout, theKeys, theValues, null);
    randomSelectedEl.setHelpText(translate("form.section.selection_pre.hover"));
    randomSelectedEl.setEnabled(!restrictedEdit && editable);
    int currentNum = section.getSelection() != null ? section.getSelection().getSelect() : 0;
    if (currentNum <= numOfItems) {
        randomSelectedEl.select(theKeys[currentNum], true);
    } else if (currentNum > numOfItems) {
        randomSelectedEl.select(theKeys[numOfItems], true);
    } else {
        randomSelectedEl.select(theKeys[0], true);
    }
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("butons", getTranslator());
    formLayout.add(buttonsCont);
    FormSubmit submit = uifactory.addFormSubmitButton("save", "save", buttonsCont);
    submit.setEnabled(editable);
}
Also used : RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) FormSubmit(org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit) VFSContainer(org.olat.core.util.vfs.VFSContainer) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)

Example 10 with RubricBlock

use of uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock in project OpenOLAT by OpenOLAT.

the class AssessmentTestComponentRenderer method renderAssessmentSectionRubrickBlock.

private void renderAssessmentSectionRubrickBlock(AssessmentRenderer renderer, StringOutput sb, AssessmentTestComponent component, TestPlanNode sectionNode, URLBuilder ubu, Translator translator) {
    AssessmentSection selectedSection = component.getAssessmentSection(sectionNode.getIdentifier());
    if (selectedSection != null && selectedSection.getRubricBlocks().size() > 0) {
        for (RubricBlock rubricBlock : selectedSection.getRubricBlocks()) {
            // @view (candidate)
            sb.append("<div class='rubric'>");
            rubricBlock.getBlocks().forEach((block) -> renderBlock(renderer, sb, component, null, null, block, ubu, translator));
            sb.append("</div>");
        }
    }
}
Also used : AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)

Aggregations

RubricBlock (uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)16 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)12 File (java.io.File)6 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)6 Ordering (uk.ac.ed.ph.jqtiplus.node.test.Ordering)6 Selection (uk.ac.ed.ph.jqtiplus.node.test.Selection)6 URI (java.net.URI)4 ArrayList (java.util.ArrayList)4 RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)4 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)4 ItemSessionControl (uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl)4 TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)4 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)4 FileOutputStream (java.io.FileOutputStream)2 URISyntaxException (java.net.URISyntaxException)2 Date (java.util.Date)2 Test (org.junit.Test)2 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)2 Form (org.olat.core.gui.components.form.flexible.impl.Form)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2