use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project openolat by klemens.
the class AssessmentItemFactory method appendSimpleAssociableChoice.
public static void appendSimpleAssociableChoice(SimpleMatchSet matchSet, String value, int matchMax, int matchMin) {
SimpleAssociableChoice choice = new SimpleAssociableChoice(matchSet);
choice.setMatchMax(matchMax);
choice.setMatchMin(matchMin);
choice.setIdentifier(IdentifierGenerator.newNumberAsIdentifier(value));
P question = getParagraph(choice, value);
choice.getFlowStatics().add(question);
matchSet.getSimpleAssociableChoices().add(choice);
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project openolat by klemens.
the class CSVToAssessmentItemConverter method processChoice_kprim.
private void processChoice_kprim(String[] parts, KPrimAssessmentItemBuilder kprimBuilder) {
String firstPart = parts[0].toLowerCase();
String answer = parts[1];
Identifier correctIncorrectIdentifier;
if ("+".equals(firstPart)) {
correctIncorrectIdentifier = QTI21Constants.CORRECT_IDENTIFIER;
} else {
correctIncorrectIdentifier = QTI21Constants.WRONG_IDENTIFIER;
}
List<SimpleAssociableChoice> choices = kprimBuilder.getKprimChoices();
SimpleAssociableChoice choice = choices.get(kprimPosition);
P choiceText = AssessmentItemFactory.getParagraph(choice, answer);
choice.getFlowStatics().clear();
choice.getFlowStatics().add(choiceText);
kprimBuilder.setAssociation(choice.getIdentifier(), correctIncorrectIdentifier);
kprimPosition++;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project openolat by klemens.
the class CSVToAssessmentItemConverter method processChoice_match.
private void processChoice_match(String[] parts, MatchAssessmentItemBuilder matchBuilder) {
List<SimpleAssociableChoice> targetChoices = matchBuilder.getTargetChoices();
if (targetChoices == null || targetChoices.isEmpty()) {
for (int i = 1; i < parts.length; i++) {
String answer = parts[i];
SimpleAssociableChoice choice = AssessmentItemFactory.createSimpleAssociableChoice(answer, matchBuilder.getTargetMatchSet());
targetChoices.add(choice);
}
} else {
String answer = parts[0];
if (StringHelper.containsNonWhitespace(answer)) {
SimpleAssociableChoice sourceChoice = AssessmentItemFactory.createSimpleAssociableChoice(answer, matchBuilder.getSourceMatchSet());
matchBuilder.getSourceChoices().add(sourceChoice);
// correct answer and points
for (int i = 1; i < parts.length && i < (targetChoices.size() + 1); i++) {
double point = parseFloat(parts[i], 0.0f);
SimpleAssociableChoice targetChoice = targetChoices.get(i - 1);
DirectedPairValue directedPair = new DirectedPairValue(sourceChoice.getIdentifier(), targetChoice.getIdentifier());
matchBuilder.addScore(directedPair, Double.valueOf(point));
if (point > 0.0) {
matchBuilder.addAssociation(sourceChoice.getIdentifier(), targetChoice.getIdentifier());
}
}
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project openolat by klemens.
the class MatchEditorController method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (readOnly)
return;
// title
itemBuilder.setTitle(titleEl.getValue());
// question
String questionText = textEl.getRawValue();
itemBuilder.setQuestion(questionText);
if (!restrictedEdit) {
boolean singleChoice = singleMultiEl.isOneSelected() && singleMultiEl.isSelected(0);
itemBuilder.setMultipleChoice(!singleChoice);
}
// shuffle
if (!restrictedEdit) {
itemBuilder.setShuffle(shuffleEl.isOneSelected() && shuffleEl.isSelected(0));
}
// layout
if (!restrictedEdit && layoutEl != null) {
itemBuilder.removeMatchInteractionClass(layoutKeys);
String cssClass = layoutEl.getSelectedKey();
itemBuilder.addMatchInteractionClass(cssClass);
}
// update
for (MatchWrapper sourceWrapper : sourceWrappers) {
SimpleAssociableChoice choice = sourceWrapper.getSimpleChoice();
String answer = sourceWrapper.getText().getRawValue();
itemBuilder.getHtmlHelper().appendHtml(choice, answer);
}
for (MatchWrapper sourceWrapper : targetWrappers) {
SimpleAssociableChoice choice = sourceWrapper.getSimpleChoice();
String answer = sourceWrapper.getText().getRawValue();
itemBuilder.getHtmlHelper().appendHtml(choice, answer);
}
// correct answers
commitAssociations(ureq);
fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_CHANGED, itemBuilder.getAssessmentItem(), QTI21QuestionType.match));
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project openolat by klemens.
the class MatchEditorController method doAddSourceRow.
private void doAddSourceRow(UserRequest ureq) {
SimpleAssociableChoice newChoice = createSimpleAssociableChoice("Text", itemBuilder.getSourceMatchSet());
if (singleMultiEl.isOneSelected() && singleMultiEl.isSelected(0)) {
newChoice.setMatchMax(1);
} else {
newChoice.setMatchMax(0);
}
itemBuilder.getSourceMatchSet().getSimpleAssociableChoices().add(newChoice);
wrapAnswer(ureq, newChoice, sourceWrappers);
answersCont.setDirty(true);
}
Aggregations