use of uk.ac.ed.ph.jqtiplus.node.test.TestPart in project openolat by klemens.
the class AssessmentTestHelper method needManualCorrection.
public static boolean needManualCorrection(ResolvedAssessmentTest resolvedAssessmentTest) {
AssessmentTest test = resolvedAssessmentTest.getRootNodeLookup().extractIfSuccessful();
boolean needManualCorrection = false;
List<TestPart> parts = test.getChildAbstractParts();
for (TestPart part : parts) {
List<AssessmentSection> sections = part.getAssessmentSections();
for (AssessmentSection section : sections) {
if (needManualCorrection(section, resolvedAssessmentTest)) {
needManualCorrection = true;
break;
}
}
}
return needManualCorrection;
}
use of uk.ac.ed.ph.jqtiplus.node.test.TestPart 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.TestPart in project openolat by klemens.
the class AssessmentTestDisplayController method confirmAdvanceTestPart.
/**
* In the case of a multi-part test, the entry to the first part
* must not be confirmed.
* @param ureq
*/
private void confirmAdvanceTestPart(UserRequest ureq) {
TestPlanNode nextTestPart = testSessionController.findNextEnterableTestPart();
if (nextTestPart == null) {
String title = translate("confirm.close.test.title");
String text = translate("confirm.close.test.text");
advanceTestPartDialog = activateOkCancelDialog(ureq, title, text, advanceTestPartDialog);
} else {
TestPart currentTestPart = testSessionController.getCurrentTestPart();
if (currentTestPart == null) {
processAdvanceTestPart(ureq);
} else {
String title = translate("confirm.advance.testpart.title");
String text = translate("confirm.advance.testpart.text");
advanceTestPartDialog = activateOkCancelDialog(ureq, title, text, advanceTestPartDialog);
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.test.TestPart in project openolat by klemens.
the class AssessmentTestDisplayController method enterSession.
// private CandidateSession enterCandidateSession(final CandidateSession candidateSession)
private TestSessionController enterSession(UserRequest ureq) {
/* Set up listener to record any notifications */
final NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
/* Create fresh JQTI+ state & controller for it */
testSessionController = createNewTestSessionStateAndController(notificationRecorder);
if (testSessionController == null) {
return null;
}
/* Initialise test state and enter test */
final TestSessionState testSessionState = testSessionController.getTestSessionState();
final Date timestamp = ureq.getRequestTimestamp();
try {
testSessionController.initialize(timestamp);
final int testPartCount = testSessionController.enterTest(timestamp);
if (testPartCount == 1) {
/* If there is only testPart, then enter this (if possible).
* (Note that this may cause the test to exit immediately if there is a failed
* preCondition on this part.)
*/
testSessionController.enterNextAvailableTestPart(timestamp);
} else {
/* Don't enter first testPart yet - we shall tell candidate that
* there are multiple parts and let them enter manually.
*/
}
} catch (final RuntimeException e) {
logError("", e);
return null;
}
/* Record and log event */
final CandidateEvent candidateEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry, CandidateTestEventType.ENTER_TEST, testSessionState, notificationRecorder);
candidateAuditLogger.logCandidateEvent(candidateEvent);
this.lastEvent = candidateEvent;
boolean ended = testSessionState.isEnded();
/* Record current result state */
final AssessmentResult assessmentResult = computeAndRecordTestAssessmentResult(timestamp, testSessionState, ended);
/* Handle immediate end of test session */
if (ended) {
candidateSession = qtiService.finishTestSession(candidateSession, testSessionState, assessmentResult, timestamp, getDigitalSignatureOptions(), getIdentity());
} else {
TestPart currentTestPart = testSessionController.getCurrentTestPart();
if (currentTestPart != null && currentTestPart.getNavigationMode() == NavigationMode.NONLINEAR) {
// go to the first assessment item
if (testSessionController.hasFollowingNonLinearItem()) {
testSessionController.selectFollowingItemNonLinear(currentRequestTimestamp);
}
}
}
return testSessionController;
}
use of uk.ac.ed.ph.jqtiplus.node.test.TestPart in project openolat by klemens.
the class AssessmentTestComponentRenderer method renderTestPartFeedback.
private void renderTestPartFeedback(AssessmentRenderer renderer, StringOutput sb, AssessmentTestComponent component, URLBuilder ubu, Translator translator) {
sb.append("<div class='qtiworks o_assessmenttest testFeedback'>").append("<h1>");
if (component.hasMultipleTestParts()) {
sb.append(translator.translate("test.part.complete"));
} else {
sb.append(translator.translate("test.complete"));
}
sb.append("</h1>");
// Show 'atEnd' testPart feedback
TestPlanNode currentTestPartNode = component.getCurrentTestPartNode();
TestPart currentTestPart = component.getTestPart(currentTestPartNode.getIdentifier());
renderTestFeebacks(renderer, sb, currentTestPart.getTestFeedbacks(), component, TestFeedbackAccess.AT_END, ubu, translator);
// Show 'atEnd' test feedback f there's only 1 testPart
// if(!component.hasMultipleTestParts()) {
renderTestFeebacks(renderer, sb, component.getAssessmentTest().getTestFeedbacks(), component, TestFeedbackAccess.AT_END, ubu, translator);
// }
// test part review
component.getTestSessionController().getTestSessionState().getTestPlan().getTestPartNodes().forEach((testPartNode) -> renderReview(renderer, sb, component, testPartNode, ubu, translator));
// controls
/*
sb.append("<div class='o_button_group'>");
String title = component.hasMultipleTestParts()
? translator.translate("assessment.test.end.testPart") : translator.translate("assessment.test.end.test");
renderControl(sb, component, title, "o_sel_end_testpart",
new NameValuePair("cid", Event.advanceTestPart.name()));
sb.append("</div>");
*/
sb.append("</div>");
}
Aggregations