Search in sources :

Example 6 with ItemSessionControl

use of uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl in project OpenOLAT by OpenOLAT.

the class QTI12To21Converter method convertItemBasics.

private void convertItemBasics(Item item, AssessmentItemRef itemRef) {
    if (item.getMaxattempts() > 0) {
        ItemSessionControl itemSessionControl = itemRef.getItemSessionControl();
        if (itemSessionControl == null) {
            itemSessionControl = new ItemSessionControl(itemRef);
            itemRef.setItemSessionControl(itemSessionControl);
        }
        itemSessionControl.setMaxAttempts(item.getMaxattempts());
    }
    if (item.getDuration() != null && item.getDuration().isSet()) {
        TimeLimits timeLimits = itemRef.getTimeLimits();
        if (timeLimits == null) {
            timeLimits = new TimeLimits(itemRef);
            itemRef.setTimeLimits(timeLimits);
        }
        timeLimits.setMinimum(0.0d);
        double max = 0.0d;
        if (item.getDuration().getMin() > 0) {
            max += item.getDuration().getMin() * 60d;
        }
        if (item.getDuration().getSec() > 0) {
            max += item.getDuration().getSec();
        }
        timeLimits.setMaximum(max);
    }
}
Also used : ItemSessionControl(uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl) TimeLimits(uk.ac.ed.ph.jqtiplus.node.test.TimeLimits)

Example 7 with ItemSessionControl

use of uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl in project OpenOLAT by OpenOLAT.

the class AssessmentTestFactory method createTestPart.

public static TestPart createTestPart(AssessmentTest assessmentTest) {
    TestPart part = new TestPart(assessmentTest);
    part.setIdentifier(IdentifierGenerator.newAsIdentifier("tp"));
    part.setNavigationMode(NavigationMode.NONLINEAR);
    part.setSubmissionMode(SubmissionMode.INDIVIDUAL);
    assessmentTest.getTestParts().add(part);
    // test par item session control
    ItemSessionControl itemSessionControl = new ItemSessionControl(part);
    itemSessionControl.setAllowComment(Boolean.TRUE);
    itemSessionControl.setAllowReview(Boolean.FALSE);
    // default is true
    itemSessionControl.setAllowSkipping(Boolean.TRUE);
    itemSessionControl.setShowFeedback(Boolean.FALSE);
    itemSessionControl.setShowSolution(Boolean.FALSE);
    itemSessionControl.setMaxAttempts(0);
    part.setItemSessionControl(itemSessionControl);
    return part;
}
Also used : ItemSessionControl(uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart)

Example 8 with ItemSessionControl

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

the class AssessmentTestFactory method createTestPart.

public static TestPart createTestPart(AssessmentTest assessmentTest) {
    TestPart part = new TestPart(assessmentTest);
    part.setIdentifier(IdentifierGenerator.newAsIdentifier("tp"));
    part.setNavigationMode(NavigationMode.NONLINEAR);
    part.setSubmissionMode(SubmissionMode.INDIVIDUAL);
    assessmentTest.getTestParts().add(part);
    // test par item session control
    ItemSessionControl itemSessionControl = new ItemSessionControl(part);
    itemSessionControl.setAllowComment(Boolean.TRUE);
    itemSessionControl.setAllowReview(Boolean.FALSE);
    // default is true
    itemSessionControl.setAllowSkipping(Boolean.TRUE);
    itemSessionControl.setShowFeedback(Boolean.FALSE);
    itemSessionControl.setShowSolution(Boolean.FALSE);
    itemSessionControl.setMaxAttempts(0);
    part.setItemSessionControl(itemSessionControl);
    return part;
}
Also used : ItemSessionControl(uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart)

Example 9 with ItemSessionControl

use of uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl 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 10 with ItemSessionControl

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

the class ItemSessionControlController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    String[] yesNoValues = new String[] { translate("yes"), translate("no") };
    String[] yesNoInheritValues = new String[] { translate("yes"), translate("no"), translate("inherit") };
    // inherit is allowed?
    String[] aKeys = allowInherit ? yesNoInheritKeys : yesnoKeys;
    String[] aValues = allowInherit ? yesNoInheritValues : yesNoValues;
    // can be null
    ItemSessionControl itemSessionControl = part.getItemSessionControl();
    Integer maxAttempts = null;
    if (itemSessionControl != null) {
        maxAttempts = itemSessionControl.getMaxAttempts();
    }
    limitAttemptsEl = uifactory.addRadiosHorizontal("form.imd.limittries", formLayout, aKeys, aValues);
    limitAttemptsEl.addActionListener(FormEvent.ONCLICK);
    limitAttemptsEl.setHelpTextKey("item.session.control.attempts.hint", null);
    String maxAttemptsStr = maxAttempts == null ? "" : maxAttempts.toString();
    maxAttemptsEl = uifactory.addTextElement("attempts", "item.session.control.attempts", 4, maxAttemptsStr, formLayout);
    if (maxAttempts == null) {
        if (aKeys.length == 2) {
            limitAttemptsEl.select(YES, true);
            maxAttemptsEl.setValue("1");
        } else {
            limitAttemptsEl.select(INHERIT, true);
        }
    } else if (maxAttempts.intValue() == 0) {
        limitAttemptsEl.select(NO, true);
    } else {
        limitAttemptsEl.select(YES, true);
    }
    limitAttemptsEl.setEnabled(!restrictedEdit && editable);
    maxAttemptsEl.setVisible(limitAttemptsEl.isSelected(0));
    maxAttemptsEl.setEnabled(!restrictedEdit && editable);
    allowSkippingEl = uifactory.addRadiosHorizontal("item.session.control.allow.skipping", formLayout, aKeys, aValues);
    allowSkippingEl.addActionListener(FormEvent.ONCHANGE);
    allowSkippingEl.setEnabled(!restrictedEdit && editable);
    allowSkippingEl.setHelpText(translate("item.session.control.allow.skipping.hint"));
    // the default value is allowSkipping=true
    if (itemSessionControl != null && itemSessionControl.getAllowSkipping() != null) {
        String key = itemSessionControl.getAllowSkipping().booleanValue() ? YES : NO;
        allowSkippingEl.select(key, true);
    } else {
        String key = allowInherit ? INHERIT : YES;
        allowSkippingEl.select(key, true);
    }
    allowCommentEl = uifactory.addRadiosHorizontal("item.session.control.allow.comment", formLayout, aKeys, aValues);
    allowCommentEl.addActionListener(FormEvent.ONCHANGE);
    allowCommentEl.setEnabled(!restrictedEdit && editable);
    allowCommentEl.setHelpText(translate("item.session.control.allow.comment.hint"));
    if (itemSessionControl != null && itemSessionControl.getAllowComment() != null) {
        String key = itemSessionControl.getAllowComment().booleanValue() ? YES : NO;
        allowCommentEl.select(key, true);
    } else {
        String key = allowInherit ? INHERIT : YES;
        allowCommentEl.select(key, true);
    }
    allowReviewEl = uifactory.addRadiosHorizontal("item.session.control.allow.review", formLayout, aKeys, aValues);
    allowReviewEl.addActionListener(FormEvent.ONCHANGE);
    allowReviewEl.setEnabled(!restrictedEdit && editable);
    allowReviewEl.setHelpText(translate("item.session.control.allow.review.hint"));
    if (itemSessionControl != null && itemSessionControl.getAllowReview() != null) {
        String key = itemSessionControl.getAllowReview().booleanValue() ? YES : NO;
        allowReviewEl.select(key, true);
    } else {
        String key = allowInherit ? INHERIT : NO;
        allowReviewEl.select(key, true);
    }
    showSolutionEl = uifactory.addRadiosHorizontal("item.session.control.show.solution", formLayout, aKeys, aValues);
    showSolutionEl.addActionListener(FormEvent.ONCHANGE);
    showSolutionEl.setEnabled(!restrictedEdit && editable);
    showSolutionEl.setHelpText(translate("item.session.control.show.solution.hint"));
    if (itemSessionControl != null && itemSessionControl.getShowSolution() != null) {
        String key = itemSessionControl.getShowSolution().booleanValue() ? YES : NO;
        showSolutionEl.select(key, true);
    } else {
        String key = allowInherit ? INHERIT : NO;
        showSolutionEl.select(key, false);
    }
}
Also used : ItemSessionControl(uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl)

Aggregations

ItemSessionControl (uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl)18 TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)8 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)6 File (java.io.File)4 RubricBlock (uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)4 AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)4 Ordering (uk.ac.ed.ph.jqtiplus.node.test.Ordering)4 FileOutputStream (java.io.FileOutputStream)2 URISyntaxException (java.net.URISyntaxException)2 Date (java.util.Date)2 Test (org.junit.Test)2 Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)2 Control (org.olat.ims.qti.editor.beecom.objects.Control)2 OutcomesProcessing (org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing)2 Section (org.olat.ims.qti.editor.beecom.objects.Section)2 AssessmentTestBuilder (org.olat.ims.qti21.model.xml.AssessmentTestBuilder)2 ManifestBuilder (org.olat.ims.qti21.model.xml.ManifestBuilder)2 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)2 Selection (uk.ac.ed.ph.jqtiplus.node.test.Selection)2 TimeLimits (uk.ac.ed.ph.jqtiplus.node.test.TimeLimits)2