use of uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl in project openolat by klemens.
the class QTI12To21Converter method convert.
public AssessmentTest convert(VFSContainer originalContainer, QTIDocument doc, QTI21DeliveryOptions qti21Options) throws URISyntaxException {
Assessment assessment = doc.getAssessment();
AssessmentTest assessmentTest = new AssessmentTest();
String assessmentTestIdentifier = IdentifierGenerator.newAssessmentTestFilename();
File testFile = new File(unzippedDirRoot, assessmentTestIdentifier + ".xml");
manifest.appendAssessmentTest(testFile.getName());
assessmentTest.setIdentifier(assessmentTestIdentifier);
assessmentTest.setTitle(assessment.getTitle());
assessmentTest.setToolName(QTI21Constants.TOOLNAME);
assessmentTest.setToolVersion(Settings.getVersion());
convertDuration((Duration) assessment.getDuration(), assessmentTest);
TestPart testPart = AssessmentTestFactory.createTestPart(assessmentTest);
ItemSessionControl itemSessionControl = testPart.getItemSessionControl();
Control tmpControl = QTIEditHelper.getControl(assessment);
if (tmpControl.getSolution() == Control.CTRL_YES) {
itemSessionControl.setShowSolution(Boolean.TRUE);
}
if (qti21Options != null) {
qti21Options.setHideFeedbacks(false);
if (assessment.isInheritControls() && tmpControl.getFeedback() != Control.CTRL_YES) {
qti21Options.setHideFeedbacks(true);
}
}
AssessmentTestBuilder assessmentTestBuilder = new AssessmentTestBuilder(assessmentTest);
// root
List<Section> sections = assessment.getSections();
for (Section section : sections) {
convert(section, testPart);
}
// this are lost in QTI 2.1
// assessment.getSelection_ordering().getOrderType();
// assessment.getSelection_ordering().getSelectionNumber();
OutcomesProcessing outcomesProcessing = assessment.getOutcomes_processing();
if (outcomesProcessing != null) {
String cutValue = outcomesProcessing.getField(OutcomesProcessing.CUTVALUE);
if (StringHelper.containsNonWhitespace(cutValue)) {
try {
assessmentTestBuilder.setCutValue(Double.valueOf(cutValue));
} catch (NumberFormatException e) {
log.error("Cannot parse cut value: " + cutValue, e);
}
}
}
assessmentTestBuilder.setMaxScore(atomicMaxScore.doubleValue());
assessmentTest = assessmentTestBuilder.build();
persistAssessmentObject(testFile, assessmentTest);
manifest.write(new File(unzippedDirRoot, "imsmanifest.xml"));
copyMaterial(originalContainer);
return assessmentTest;
}
use of uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl in project openolat by klemens.
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);
}
}
use of uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl in project openolat by klemens.
the class ItemSessionControlController method formOK.
@Override
protected void formOK(UserRequest ureq) {
// can be null
ItemSessionControl itemSessionControl = part.getItemSessionControl();
// need to be first!
if (allowSkippingEl.isOneSelected()) {
if (allowSkippingEl.isSelected(0)) {
// yes
checkNotNull(itemSessionControl).setAllowSkipping(Boolean.TRUE);
} else if (allowSkippingEl.isSelected(1)) {
// no
checkNotNull(itemSessionControl).setAllowSkipping(Boolean.FALSE);
} else if (itemSessionControl != null) {
// inherit
itemSessionControl.setAllowSkipping(null);
}
}
if (allowCommentEl.isOneSelected()) {
if (allowCommentEl.isSelected(0)) {
checkNotNull(itemSessionControl).setAllowComment(Boolean.TRUE);
} else if (allowCommentEl.isSelected(1)) {
checkNotNull(itemSessionControl).setAllowComment(Boolean.FALSE);
} else if (itemSessionControl != null) {
itemSessionControl.setAllowComment(null);
}
}
if (allowReviewEl.isOneSelected()) {
if (allowReviewEl.isSelected(0)) {
checkNotNull(itemSessionControl).setAllowReview(Boolean.TRUE);
} else if (allowReviewEl.isSelected(1)) {
checkNotNull(itemSessionControl).setAllowReview(Boolean.FALSE);
} else if (itemSessionControl != null) {
itemSessionControl.setAllowReview(null);
}
}
if (showSolutionEl.isOneSelected()) {
if (showSolutionEl.isSelected(0)) {
checkNotNull(itemSessionControl).setShowSolution(Boolean.TRUE);
} else if (showSolutionEl.isSelected(1)) {
checkNotNull(itemSessionControl).setShowSolution(Boolean.FALSE);
} else if (itemSessionControl != null) {
itemSessionControl.setShowSolution(null);
}
}
if (limitAttemptsEl.isSelected(0) && maxAttemptsEl != null && maxAttemptsEl.isVisible() && StringHelper.isLong(maxAttemptsEl.getValue())) {
int maxAttempts = Integer.parseInt(maxAttemptsEl.getValue());
checkNotNull(itemSessionControl).setMaxAttempts(new Integer(maxAttempts));
} else if (limitAttemptsEl.isSelected(1)) {
checkNotNull(itemSessionControl).setMaxAttempts(0);
} else if (itemSessionControl != null) {
itemSessionControl.setMaxAttempts(null);
}
}
Aggregations