use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest in project OpenOLAT by OpenOLAT.
the class CorrectionIdentityAssessmentItemListController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (tableEl == source) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
String cmd = se.getCommand();
if ("select".equals(cmd)) {
CorrectionIdentityAssessmentItemRow row = tableModel.getObject(se.getIndex());
doSelect(ureq, row);
}
}
} else if (saveButton == source) {
List<AssessmentTestSession> sessions = Collections.singletonList(candidateSession);
AssessmentTest assessmentTest = model.getResolvedAssessmentTest().getRootNodeLookup().extractIfSuccessful();
fireEvent(ureq, new CompleteAssessmentTestSessionEvent(sessions, assessmentTest, AssessmentEntryStatus.done));
}
super.formInnerEvent(ureq, source, event);
}
use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest in project OpenOLAT by OpenOLAT.
the class QTI21RuntimeController method getAssessableElement.
private AssessableResource getAssessableElement(RepositoryEntry testEntry) {
FileResourceManager frm = FileResourceManager.getInstance();
File fUnzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
ResolvedAssessmentTest resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(fUnzippedDirRoot, false, false);
AssessmentTest assessmentTest = resolvedAssessmentTest.getRootNodeLookup().extractIfSuccessful();
Double maxScore = QtiNodesExtractor.extractMaxScore(assessmentTest);
Double minScore = QtiNodesExtractor.extractMinScore(assessmentTest);
boolean hasScore = assessmentTest.getOutcomeDeclaration(QTI21Constants.SCORE_IDENTIFIER) != null;
boolean hasPassed = assessmentTest.getOutcomeDeclaration(QTI21Constants.PASS_IDENTIFIER) != null;
return new QTI21AssessableResource(hasScore, hasPassed, true, true, minScore, maxScore, null);
}
use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest 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.AssessmentTest in project openolat by klemens.
the class QTI21AssessmentTestHandler method createMinimalAssessmentTest.
public void createMinimalAssessmentTest(String displayName, File directory, Locale locale) {
ManifestBuilder manifestBuilder = ManifestBuilder.createAssessmentTestBuilder();
Translator translator = Util.createPackageTranslator(AssessmentTestComposerController.class, locale);
// single choice
File itemFile = new File(directory, IdentifierGenerator.newAsString(QTI21QuestionType.sc.getPrefix()) + ".xml");
AssessmentItem assessmentItem = AssessmentItemFactory.createSingleChoice(translator.translate("new.sc"), translator.translate("new.answer"));
QtiSerializer qtiSerializer = qtiService.qtiSerializer();
manifestBuilder.appendAssessmentItem(itemFile.getName());
// test
File testFile = new File(directory, IdentifierGenerator.newAssessmentTestFilename());
AssessmentTest assessmentTest = AssessmentTestFactory.createAssessmentTest(displayName, translator.translate("new.section"));
manifestBuilder.appendAssessmentTest(testFile.getName());
// item -> test
try {
AssessmentSection section = assessmentTest.getTestParts().get(0).getAssessmentSections().get(0);
AssessmentTestFactory.appendAssessmentItem(section, itemFile.getName());
} catch (URISyntaxException e) {
log.error("", e);
}
try (FileOutputStream out = new FileOutputStream(itemFile)) {
qtiSerializer.serializeJqtiObject(assessmentItem, out);
} catch (Exception e) {
log.error("", e);
}
try (FileOutputStream out = new FileOutputStream(testFile)) {
qtiSerializer.serializeJqtiObject(assessmentTest, out);
} catch (Exception e) {
log.error("", e);
}
manifestBuilder.write(new File(directory, "imsmanifest.xml"));
}
use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest in project openolat by klemens.
the class QTI21WordExport method prepare.
@Override
public void prepare(HttpServletResponse hres) {
try {
hres.setCharacterEncoding(encoding);
} catch (Exception e) {
log.error("", e);
}
AssessmentTest assessmentTest = resolvedAssessmentTest.getRootNodeLookup().extractIfSuccessful();
String label = assessmentTest.getTitle();
String secureLabel = StringHelper.transformDisplayNameToFileSystemName(label);
String file = secureLabel + ".zip";
hres.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + StringHelper.urlEncodeUTF8(file));
hres.setHeader("Content-Description", StringHelper.urlEncodeUTF8(label));
try (ZipOutputStream zout = new ZipOutputStream(hres.getOutputStream())) {
zout.setLevel(9);
ZipEntry test = new ZipEntry(secureLabel + ".docx");
zout.putNextEntry(test);
exportTest(assessmentTest, label, zout, false);
zout.closeEntry();
ZipEntry responses = new ZipEntry(secureLabel + "_responses.docx");
zout.putNextEntry(responses);
exportTest(assessmentTest, label, zout, true);
zout.closeEntry();
} catch (Exception e) {
log.error("", e);
} finally {
latch.countDown();
}
}
Aggregations