use of uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback in project openolat by klemens.
the class AssessmentItemFactory method createModalFeedback.
public static ModalFeedback createModalFeedback(AssessmentItem assessmentItem, Identifier outcomeIdentifier, Identifier identifier, String title, String text) {
/*
<modalFeedback identifier="Feedback1041659806" outcomeIdentifier="FEEDBACKMODAL" showHide="show" title="Wrong answer">
<p>Feedback answer</p>
</modalFeedback>
*/
ModalFeedback modalFeedback = new ModalFeedback(assessmentItem);
modalFeedback.setIdentifier(identifier);
modalFeedback.setOutcomeIdentifier(outcomeIdentifier);
modalFeedback.setVisibilityMode(VisibilityMode.parseVisibilityMode("show"));
modalFeedback.getAttributes().getStringAttribute(ModalFeedback.ATTR_TITLE_NAME).setValue(title);
new AssessmentHtmlBuilder().appendHtml(modalFeedback, text);
return modalFeedback;
}
use of uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback in project openolat by klemens.
the class AlienItemAnalyzer method checkFeedbackModalResponseProcessing.
private void checkFeedbackModalResponseProcessing(Report report) {
if (report.getType() != QTI21QuestionType.unkown) {
boolean allOk = true;
List<ModalFeedback> feedbacks = item.getModalFeedbacks();
for (ModalFeedback feedback : feedbacks) {
ModalFeedbackBuilder feedbackBuilder = new ModalFeedbackBuilder(item, feedback);
if (feedbackBuilder.isCorrectRule() || feedbackBuilder.isIncorrectRule()) {
// ok
} else if (feedbackBuilder.isCorrectSolutionRule() || (feedback.getOutcomeIdentifier() != null && QTI21Constants.CORRECT_SOLUTION_IDENTIFIER.equals(feedback.getOutcomeIdentifier()))) {
// ok
} else if (feedbackBuilder.isEmptyRule() || feedbackBuilder.isAnsweredRule() || feedbackBuilder.isHint()) {
// ok
} else {
List<ModalFeedbackCondition> conditions = feedbackBuilder.getFeedbackConditons();
if (conditions == null || conditions.isEmpty()) {
allOk &= false;
}
}
}
if (!allOk) {
report.addWarning(ReportWarningEnum.unsupportedFeedbacks);
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback in project openolat by klemens.
the class AlienItemAnalyzer method checkFeedback.
private void checkFeedback(Report report) {
if (item.getModalFeedbacks() != null && item.getModalFeedbacks().size() > 0) {
Set<Identifier> outcomeIdentifiers = new HashSet<>();
List<ModalFeedback> feedbacks = item.getModalFeedbacks();
for (ModalFeedback feedback : feedbacks) {
if (feedback.getOutcomeIdentifier() != null) {
outcomeIdentifiers.add(feedback.getOutcomeIdentifier());
}
}
if (outcomeIdentifiers.size() == 1) {
if (outcomeIdentifiers.iterator().next().equals(QTI21Constants.FEEDBACKMODAL_IDENTIFIER)) {
checkFeedbackModalResponseProcessing(report);
} else {
report.addWarning(ReportWarningEnum.alienFeedbacks);
}
} else {
// Onyx and OpenOLAT only use one outcome identifier for the feedbacks
// Taotesting use several different identifiers. And we don't
// understand feedbacks without outcome identifiers
report.addWarning(ReportWarningEnum.alienFeedbacks);
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback in project openolat by klemens.
the class QTI21WordExport method renderCorrectSolutionForWord.
private static void renderCorrectSolutionForWord(AssessmentItem item, OpenXMLDocument document, Translator translator, AssessmentHtmlBuilder htmlBuilder) {
List<ModalFeedback> feedbacks = item.getModalFeedbacks();
if (feedbacks != null && feedbacks.size() > 0) {
for (ModalFeedback feedback : feedbacks) {
if (feedback.getOutcomeIdentifier() != null && QTI21Constants.CORRECT_SOLUTION_IDENTIFIER.equals(feedback.getOutcomeIdentifier())) {
Attribute<?> title = feedback.getAttributes().get("title");
String feedbackTitle = null;
if (title != null && title.getValue() != null) {
feedbackTitle = title.getValue().toString();
}
if (!StringHelper.containsNonWhitespace(feedbackTitle)) {
feedbackTitle = translator.translate("correct.solution");
}
document.appendHeading2(feedbackTitle, null);
String html = htmlBuilder.flowStaticString(feedback.getFlowStatics());
document.appendHtmlText(html, true);
}
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback in project openolat by klemens.
the class FeedbackResultComponentRenderer method render.
@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
FeedbackResultComponent cmp = (FeedbackResultComponent) source;
ResolvedAssessmentItem resolvedAssessmentItem = cmp.getResolvedAssessmentItem();
ItemSessionState itemSessionState = cmp.getItemSessionState();
AssessmentRenderer assessmentRenderer = new AssessmentRenderer(renderer);
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
for (ModalFeedback modalFeedback : assessmentItem.getModalFeedbacks()) {
Identifier outcomeIdentifier = modalFeedback.getOutcomeIdentifier();
if (QTI21Constants.CORRECT_SOLUTION_IDENTIFIER.equals(outcomeIdentifier)) {
sb.append("<div class='modalFeedback'>");
renderAssessmentItemCorrectSolutionModalFeedback(assessmentRenderer, sb, modalFeedback, cmp, resolvedAssessmentItem, itemSessionState, ubu, translator);
sb.append("</div>");
}
}
}
Aggregations