Search in sources :

Example 1 with TimeLimits

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

the class AssessmentTestOptionsEditorController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_test");
    String title = assessmentTest.getTitle();
    titleEl = uifactory.addTextElement("title", "form.metadata.title", 255, title, formLayout);
    titleEl.setMandatory(true);
    titleEl.setEnabled(testBuilder.isEditable());
    // score
    String maxScore = testBuilder.getMaxScore() == null ? "" : AssessmentHelper.getRoundedScore(testBuilder.getMaxScore());
    maxScoreEl = uifactory.addTextElement("max.score", "max.score", 8, maxScore, formLayout);
    maxScoreEl.setEnabled(false);
    Double cutValue = testBuilder.getCutValue();
    String cutValueStr = cutValue == null ? "" : cutValue.toString();
    cutValueEl = uifactory.addTextElement("cut.value", "cut.value", 8, cutValueStr, formLayout);
    cutValueEl.setEnabled(!restrictedEdit && testBuilder.isEditable());
    TimeLimits timeLimits = assessmentTest.getTimeLimits();
    long maxInSeconds = -1;
    String timeMaxHour = "";
    String timeMaxMinute = "";
    if (timeLimits != null && timeLimits.getMaximum() != null && timeLimits.getMaximum().longValue() > 0) {
        maxInSeconds = timeLimits.getMaximum().longValue();
        timeMaxHour = Long.toString(maxInSeconds / 3600);
        timeMaxMinute = Long.toString((maxInSeconds % 3600) / 60);
    }
    maxTimeEl = uifactory.addCheckboxesVertical("time.limit.enable", "time.limit.max", formLayout, onKeys, onValues, 1);
    maxTimeEl.addActionListener(FormEvent.ONCHANGE);
    if (maxInSeconds > 0) {
        maxTimeEl.select(onKeys[0], true);
    }
    String page = velocity_root + "/max_time_limit.html";
    maxTimeCont = FormLayoutContainer.createCustomFormLayout("time.limit.cont", getTranslator(), page);
    maxTimeCont.setVisible(maxTimeEl.isAtLeastSelected(1));
    formLayout.add(maxTimeCont);
    timeMaxHour = timeMaxHour.equals("0") ? "" : timeMaxHour;
    maxTimeHourEl = uifactory.addTextElement("time.limit.hour", "time.limit.max", 4, timeMaxHour, maxTimeCont);
    maxTimeHourEl.setDomReplacementWrapperRequired(false);
    maxTimeHourEl.setDisplaySize(4);
    maxTimeHourEl.setEnabled(!restrictedEdit);
    maxTimeMinuteEl = uifactory.addTextElement("time.limit.minute", "time.limit.max", 4, timeMaxMinute, maxTimeCont);
    maxTimeMinuteEl.setDomReplacementWrapperRequired(false);
    maxTimeMinuteEl.setDisplaySize(4);
    maxTimeMinuteEl.setEnabled(!restrictedEdit);
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("butons", getTranslator());
    formLayout.add(buttonsCont);
    FormSubmit submit = uifactory.addFormSubmitButton("save", "save", buttonsCont);
    submit.setEnabled(testBuilder.isEditable());
}
Also used : FormSubmit(org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) TimeLimits(uk.ac.ed.ph.jqtiplus.node.test.TimeLimits)

Example 2 with TimeLimits

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

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

the class AssessmentTestBuilder method build.

public AssessmentTest build() {
    if (!editable) {
        return assessmentTest;
    }
    if (assessmentTest.getOutcomeProcessing() == null) {
        assessmentTest.setOutcomeProcessing(new OutcomeProcessing(assessmentTest));
    }
    if (maximumTimeLimits != null) {
        TimeLimits timeLimits = new TimeLimits(assessmentTest);
        timeLimits.setMaximum(maximumTimeLimits.doubleValue());
        assessmentTest.setTimeLimits(timeLimits);
    } else {
        assessmentTest.setTimeLimits(null);
    }
    buildScore();
    buildTestScore();
    buildCutValue();
    buildFeedback();
    // clean up
    if (assessmentTest.getOutcomeProcessing().getOutcomeRules().isEmpty()) {
        assessmentTest.setOutcomeProcessing(null);
    }
    return assessmentTest;
}
Also used : OutcomeProcessing(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeProcessing) TimeLimits(uk.ac.ed.ph.jqtiplus.node.test.TimeLimits)

Example 4 with TimeLimits

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

the class QTI12To21Converter method convertDuration.

private void convertDuration(Duration duration, ControlObject<?> parent) {
    if (duration != null && duration.isSet()) {
        TimeLimits timeLimits = new TimeLimits(parent);
        double timeInSeconds = (60 * duration.getMin()) + duration.getSec();
        timeLimits.setMaximum(timeInSeconds);
        parent.setTimeLimits(timeLimits);
    }
}
Also used : TimeLimits(uk.ac.ed.ph.jqtiplus.node.test.TimeLimits)

Example 5 with TimeLimits

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

the class AssessmentTestOptionsEditorController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_test");
    String title = assessmentTest.getTitle();
    titleEl = uifactory.addTextElement("title", "form.metadata.title", 255, title, formLayout);
    titleEl.setMandatory(true);
    titleEl.setEnabled(testBuilder.isEditable());
    // score
    String maxScore = testBuilder.getMaxScore() == null ? "" : AssessmentHelper.getRoundedScore(testBuilder.getMaxScore());
    maxScoreEl = uifactory.addTextElement("max.score", "max.score", 8, maxScore, formLayout);
    maxScoreEl.setEnabled(false);
    Double cutValue = testBuilder.getCutValue();
    String cutValueStr = cutValue == null ? "" : cutValue.toString();
    cutValueEl = uifactory.addTextElement("cut.value", "cut.value", 8, cutValueStr, formLayout);
    cutValueEl.setEnabled(!restrictedEdit && testBuilder.isEditable());
    TimeLimits timeLimits = assessmentTest.getTimeLimits();
    long maxInSeconds = -1;
    String timeMaxHour = "";
    String timeMaxMinute = "";
    if (timeLimits != null && timeLimits.getMaximum() != null && timeLimits.getMaximum().longValue() > 0) {
        maxInSeconds = timeLimits.getMaximum().longValue();
        timeMaxHour = Long.toString(maxInSeconds / 3600);
        timeMaxMinute = Long.toString((maxInSeconds % 3600) / 60);
    }
    maxTimeEl = uifactory.addCheckboxesVertical("time.limit.enable", "time.limit.max", formLayout, onKeys, onValues, 1);
    maxTimeEl.addActionListener(FormEvent.ONCHANGE);
    if (maxInSeconds > 0) {
        maxTimeEl.select(onKeys[0], true);
    }
    String page = velocity_root + "/max_time_limit.html";
    maxTimeCont = FormLayoutContainer.createCustomFormLayout("time.limit.cont", getTranslator(), page);
    maxTimeCont.setVisible(maxTimeEl.isAtLeastSelected(1));
    formLayout.add(maxTimeCont);
    timeMaxHour = timeMaxHour.equals("0") ? "" : timeMaxHour;
    maxTimeHourEl = uifactory.addTextElement("time.limit.hour", "time.limit.max", 4, timeMaxHour, maxTimeCont);
    maxTimeHourEl.setDomReplacementWrapperRequired(false);
    maxTimeHourEl.setDisplaySize(4);
    maxTimeHourEl.setEnabled(!restrictedEdit);
    maxTimeMinuteEl = uifactory.addTextElement("time.limit.minute", "time.limit.max", 4, timeMaxMinute, maxTimeCont);
    maxTimeMinuteEl.setDomReplacementWrapperRequired(false);
    maxTimeMinuteEl.setDisplaySize(4);
    maxTimeMinuteEl.setEnabled(!restrictedEdit);
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("butons", getTranslator());
    formLayout.add(buttonsCont);
    FormSubmit submit = uifactory.addFormSubmitButton("save", "save", buttonsCont);
    submit.setEnabled(testBuilder.isEditable());
}
Also used : FormSubmit(org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) TimeLimits(uk.ac.ed.ph.jqtiplus.node.test.TimeLimits)

Aggregations

TimeLimits (uk.ac.ed.ph.jqtiplus.node.test.TimeLimits)8 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 FormSubmit (org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit)2 ItemSessionControl (uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl)2 OutcomeProcessing (uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeProcessing)2