use of uk.ac.ed.ph.jqtiplus.node.test.TestPart 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;
}
use of uk.ac.ed.ph.jqtiplus.node.test.TestPart in project openolat by klemens.
the class AssessmentTestFactory method createAssessmentTest.
/**
* Create an assessmentTest object but without items
*
* @param title
* @return
*/
public static AssessmentTest createAssessmentTest(String title, String sectionTitle) {
AssessmentTest assessmentTest = new AssessmentTest();
assessmentTest.setIdentifier(IdentifierGenerator.newAsString("test"));
assessmentTest.setTitle(title);
assessmentTest.setToolName(QTI21Constants.TOOLNAME);
assessmentTest.setToolVersion(Settings.getVersion());
// outcome score
OutcomeDeclaration scoreOutcomeDeclaration = new OutcomeDeclaration(assessmentTest);
scoreOutcomeDeclaration.setIdentifier(QTI21Constants.SCORE_IDENTIFIER);
scoreOutcomeDeclaration.setCardinality(Cardinality.SINGLE);
scoreOutcomeDeclaration.setBaseType(BaseType.FLOAT);
assessmentTest.getOutcomeDeclarations().add(scoreOutcomeDeclaration);
// test part
TestPart part = createTestPart(assessmentTest);
appendAssessmentSection(sectionTitle, part);
// outcome processing
OutcomeProcessing outcomeProcessing = new OutcomeProcessing(assessmentTest);
assessmentTest.setOutcomeProcessing(outcomeProcessing);
SetOutcomeValue outcomeRule = new SetOutcomeValue(outcomeProcessing);
outcomeRule.setIdentifier(QTI21Constants.SCORE_IDENTIFIER);
Sum sum = new Sum(outcomeRule);
outcomeRule.getExpressions().add(sum);
TestVariables testVariables = new TestVariables(sum);
testVariables.setVariableIdentifier(QTI21Constants.SCORE_IDENTIFIER);
sum.getExpressions().add(testVariables);
outcomeProcessing.getOutcomeRules().add(outcomeRule);
return assessmentTest;
}
use of uk.ac.ed.ph.jqtiplus.node.test.TestPart in project openolat by klemens.
the class AssessmentTestDisplayController method confirmEndTestPart.
private void confirmEndTestPart(UserRequest ureq) {
TestPlanNode nextTestPart = testSessionController.findNextEnterableTestPart();
if (nextTestPart == null) {
String title = translate("confirm.finish.test.title");
String text = translate("confirm.finish.test.text");
endTestPartDialog = activateOkCancelDialog(ureq, title, text, endTestPartDialog);
} else {
TestPart currentTestPart = testSessionController.getCurrentTestPart();
if (currentTestPart == null) {
processEndTestPart(ureq);
} else {
String title = translate("confirm.finish.testpart.title");
String text = translate("confirm.finish.testpart.text");
endTestPartDialog = activateOkCancelDialog(ureq, title, text, endTestPartDialog);
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.test.TestPart in project openolat by klemens.
the class QTI21WordExport method exportTest.
private void exportTest(AssessmentTest assessmentTest, String header, ZipOutputStream out, boolean withResponses) {
try (ShieldOutputStream sout = new ShieldOutputStream(out);
ZipOutputStream zout = new ZipOutputStream(sout)) {
zout.setLevel(9);
OpenXMLDocument document = new OpenXMLDocument();
document.setMediaContainer(mediaContainer);
document.setDocumentHeader(header);
Translator translator = Util.createPackageTranslator(AssessmentTestDisplayController.class, locale, Util.createPackageTranslator(AssessmentTestComposerController.class, locale));
renderAssessmentTest(assessmentTest, document, translator);
for (TestPart testPart : assessmentTest.getChildAbstractParts()) {
List<AssessmentSection> assessmentSections = testPart.getAssessmentSections();
for (AssessmentSection assessmentSection : assessmentSections) {
renderAssessmentSection(assessmentSection, document, withResponses, translator);
}
}
OpenXMLDocumentWriter writer = new OpenXMLDocumentWriter();
writer.createDocument(zout, document);
} catch (Exception e) {
log.error("", e);
}
}
use of uk.ac.ed.ph.jqtiplus.node.test.TestPart in project openolat by klemens.
the class AssessmentTestHelper method visit.
/**
* Go through the assessmentTest, visit recursively its test parts, sections and
* assessment item refs.
*
* @param assessmentTest The assessment test to visit
* @param visitor The visitor
*/
public static void visit(AssessmentTest assessmentTest, AssessmentTestVisitor visitor) {
List<TestPart> testParts = assessmentTest.getTestParts();
if (testParts != null && testParts.size() > 0) {
for (TestPart testPart : testParts) {
visitor.visit(testPart);
List<AssessmentSection> sections = testPart.getAssessmentSections();
if (sections != null && sections.size() > 0) {
for (AssessmentSection section : sections) {
visit(section, visitor);
}
}
}
}
}
Aggregations