use of uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock 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.content.variable.RubricBlock in project openolat by klemens.
the class QTI12To21Converter method convert.
private void convert(Section section, TestPart testPart) throws URISyntaxException {
AssessmentSection assessmentSection = AssessmentTestFactory.appendAssessmentSection("Section", testPart);
assessmentSection.setTitle(section.getTitle());
convertDuration(section.getDuration(), assessmentSection);
RubricBlock rubricBlock = assessmentSection.getRubricBlocks().get(0);
rubricBlock.getBlocks().clear();
String objectives = section.getObjectives();
htmlBuilder.appendHtml(rubricBlock, blockedHtml(objectives));
boolean shuffle = SelectionOrdering.RANDOM.equals(section.getSelection_ordering().getOrderType());
assessmentSection.getOrdering().setShuffle(shuffle);
int selectionNum = section.getSelection_ordering().getSelectionNumber();
if (selectionNum > 0) {
Selection selection = new Selection(assessmentSection);
selection.setSelect(selectionNum);
assessmentSection.setSelection(selection);
}
List<Item> items = section.getItems();
for (Item item : items) {
AssessmentItemBuilder itemBuilder = null;
if (item != null && item.getQuestion() != null) {
int questionType = item.getQuestion().getType();
switch(questionType) {
case Question.TYPE_SC:
itemBuilder = convertSingleChoice(item);
break;
case Question.TYPE_MC:
itemBuilder = convertMultipleChoice(item);
break;
case Question.TYPE_KPRIM:
itemBuilder = convertKPrim(item);
break;
case Question.TYPE_FIB:
itemBuilder = convertFIB(item);
break;
case Question.TYPE_ESSAY:
itemBuilder = convertEssay(item);
break;
}
} else {
errors.add(item.getTitle());
log.error("Item without question: " + item);
}
if (itemBuilder != null) {
itemBuilder.build();
AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
AssessmentItemRef itemRef = new AssessmentItemRef(assessmentSection);
String itemId = IdentifierGenerator.newAsString(itemBuilder.getQuestionType().getPrefix());
itemRef.setIdentifier(Identifier.parseString(itemId));
convertItemBasics(item, itemRef);
File itemFile = new File(unzippedDirRoot, itemId + ".xml");
itemRef.setHref(new URI(itemFile.getName()));
assessmentSection.getSectionParts().add(itemRef);
persistAssessmentObject(itemFile, assessmentItem);
appendResourceAndMetadata(item, itemBuilder, itemFile);
// collect max score
Double maxScore = QtiNodesExtractor.extractMaxScore(assessmentItem);
if (maxScore != null && maxScore.doubleValue() > 0.0d) {
atomicMaxScore.add(maxScore.doubleValue());
}
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock in project openolat by klemens.
the class QTI21WordExport method renderAssessmentSection.
public void renderAssessmentSection(AssessmentSection assessmentSection, OpenXMLDocument document, boolean withResponses, Translator translator) {
String title = assessmentSection.getTitle();
document.appendHeading1(title, null);
List<RubricBlock> rubricBlocks = assessmentSection.getRubricBlocks();
for (RubricBlock rubricBlock : rubricBlocks) {
String htmlRubric = htmlBuilder.blocksString(rubricBlock.getBlocks());
document.appendHtmlText(htmlRubric, true);
}
for (SectionPart sectionPart : assessmentSection.getChildAbstractParts()) {
if (sectionPart instanceof AssessmentSection) {
renderAssessmentSection((AssessmentSection) sectionPart, document, withResponses, translator);
} else if (sectionPart instanceof AssessmentItemRef) {
AssessmentItemRef itemRef = (AssessmentItemRef) sectionPart;
ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
URI itemUri = resolvedAssessmentTest.getSystemIdByItemRefMap().get(itemRef);
renderAssessmentItem(assessmentItem, new File(itemUri), mediaDir, document, withResponses, translator, htmlBuilder);
document.appendPageBreak();
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock in project openolat by klemens.
the class AssessmentSectionOptionsEditorController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
formLayout.setElementCssClass("o_sel_assessment_section_options");
setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_section");
if (!editable) {
setFormWarning("warning.alien.assessment.test");
}
String title = section.getTitle();
titleEl = uifactory.addTextElement("title", "form.metadata.title", 255, title, formLayout);
titleEl.setEnabled(editable);
titleEl.setMandatory(true);
String relativePath = rootDirectory.toPath().relativize(testFile.toPath().getParent()).toString();
VFSContainer itemContainer = (VFSContainer) rootContainer.resolve(relativePath);
if (section.getRubricBlocks().isEmpty()) {
RichTextElement rubricEl = uifactory.addRichTextElementForQTI21("rubric" + counter++, "form.imd.rubric", "", 12, -1, itemContainer, formLayout, ureq.getUserSession(), getWindowControl());
rubricEl.getEditorConfiguration().setFileBrowserUploadRelPath("media");
rubricEl.setEnabled(editable);
rubricEls.add(rubricEl);
} else {
for (RubricBlock rubricBlock : section.getRubricBlocks()) {
String rubric = htmlBuilder.blocksString(rubricBlock.getBlocks());
RichTextElement rubricEl = uifactory.addRichTextElementForQTI21("rubric" + counter++, "form.imd.rubric", rubric, 12, -1, itemContainer, formLayout, ureq.getUserSession(), getWindowControl());
rubricEl.getEditorConfiguration().setFileBrowserUploadRelPath("media");
rubricEl.setEnabled(editable);
rubricEl.setUserObject(rubricBlock);
rubricEls.add(rubricEl);
}
}
// shuffle
String[] yesnoValues = new String[] { translate("yes"), translate("no") };
shuffleEl = uifactory.addRadiosHorizontal("shuffle", "form.section.shuffle", formLayout, yesnoKeys, yesnoValues);
if (section.getOrdering() != null && section.getOrdering().getShuffle()) {
shuffleEl.select("y", true);
} else {
shuffleEl.select("n", true);
}
shuffleEl.setEnabled(!restrictedEdit && editable);
int numOfItems = getNumOfQuestions(section);
String[] theKeys = new String[numOfItems + 1];
String[] theValues = new String[numOfItems + 1];
theKeys[0] = "0";
theValues[0] = translate("form.section.selection_all");
for (int i = 0; i < numOfItems; i++) {
theKeys[i + 1] = Integer.toString(i + 1);
theValues[i + 1] = Integer.toString(i + 1);
}
randomSelectedEl = uifactory.addDropdownSingleselect("form.section.selection_pre", formLayout, theKeys, theValues, null);
randomSelectedEl.setHelpText(translate("form.section.selection_pre.hover"));
randomSelectedEl.setEnabled(!restrictedEdit && editable);
int currentNum = section.getSelection() != null ? section.getSelection().getSelect() : 0;
if (currentNum <= numOfItems) {
randomSelectedEl.select(theKeys[currentNum], true);
} else if (currentNum > numOfItems) {
randomSelectedEl.select(theKeys[numOfItems], true);
} else {
randomSelectedEl.select(theKeys[0], true);
}
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("butons", getTranslator());
formLayout.add(buttonsCont);
FormSubmit submit = uifactory.addFormSubmitButton("save", "save", buttonsCont);
submit.setEnabled(editable);
}
use of uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock in project OpenOLAT by OpenOLAT.
the class AssessmentTestComponentRenderer method renderAssessmentSectionRubrickBlock.
private void renderAssessmentSectionRubrickBlock(AssessmentRenderer renderer, StringOutput sb, AssessmentTestComponent component, TestPlanNode sectionNode, URLBuilder ubu, Translator translator) {
AssessmentSection selectedSection = component.getAssessmentSection(sectionNode.getIdentifier());
if (selectedSection != null && selectedSection.getRubricBlocks().size() > 0) {
for (RubricBlock rubricBlock : selectedSection.getRubricBlocks()) {
// @view (candidate)
sb.append("<div class='rubric'>");
rubricBlock.getBlocks().forEach((block) -> renderBlock(renderer, sb, component, null, null, block, ubu, translator));
sb.append("</div>");
}
}
}
Aggregations