Skip to content
Snippets Groups Projects
Commit 6ca8a61d authored by srosse's avatar srosse
Browse files

OO-3948,OO-3949: render the responses in stats with the QTI 2.1 renderer

parent f04968b2
No related branches found
No related tags found
No related merge requests found
Showing
with 364 additions and 85 deletions
......@@ -47,7 +47,7 @@ import uk.ac.ed.ph.jqtiplus.xmlutils.locators.ResourceLocator;
public abstract class AssessmentObjectFormItem extends FormItemImpl implements FormItemCollection {
private final FormSubmit submitButton;
private Map<String,FormItem> components = new HashMap<String,FormItem>();
private Map<String,FormItem> components = new HashMap<>();
public AssessmentObjectFormItem(String name, FormSubmit submitButton) {
super(name);
......@@ -116,7 +116,7 @@ public abstract class AssessmentObjectFormItem extends FormItemImpl implements F
}
protected Map<Identifier, StringResponseData> extractStringResponseData() {
final Map<Identifier, StringResponseData> responseMap = new HashMap<Identifier, StringResponseData>();
final Map<Identifier, StringResponseData> responseMap = new HashMap<>();
final Set<String> parameterNames = getRootForm().getRequestParameterSet();
for (final String name : parameterNames) {
......@@ -140,7 +140,7 @@ public abstract class AssessmentObjectFormItem extends FormItemImpl implements F
}
protected Map<Identifier, MultipartFileInfos> extractFileResponseData() {
Map<Identifier, MultipartFileInfos> fileResponseMap = new HashMap<Identifier, MultipartFileInfos>();
Map<Identifier, MultipartFileInfos> fileResponseMap = new HashMap<>();
Set<String> parameterNames = new HashSet<>(getRootForm().getRequestMultipartFilesSet());
parameterNames.addAll(getRootForm().getRequestParameterSet());
......
......@@ -40,7 +40,7 @@ import uk.ac.ed.ph.jqtiplus.state.ItemSessionState;
*/
public class FlowComponent extends AssessmentObjectComponent {
private final static FlowComponentRenderer RENDERER = new FlowComponentRenderer();
private static final FlowComponentRenderer RENDERER = new FlowComponentRenderer();
private ResolvedAssessmentTest resolvedAssessmentTest;
private final File assessmentItemFile;
......@@ -51,6 +51,13 @@ public class FlowComponent extends AssessmentObjectComponent {
private List<FlowStatic> flowStatics;
private List<InlineStatic> inlineStatics;
public FlowComponent(String name, File assessmentItemFile) {
super(name);
qtiItem = null;
this.assessmentItemFile = assessmentItemFile;
setDomReplacementWrapperRequired(false);
}
public FlowComponent(String name, File assessmentItemFile, FlowFormItem qtiItem) {
super(name);
this.qtiItem = qtiItem;
......@@ -116,9 +123,7 @@ public class FlowComponent extends AssessmentObjectComponent {
relativePathString = relativePath.toString();
}
if(relativePathString.isEmpty()) {
return relativePathString;
} else if(relativePathString.endsWith("/")) {
if(relativePathString.isEmpty() || relativePathString.endsWith("/")) {
return relativePathString;
}
return relativePathString.concat("/");
......
......@@ -27,6 +27,8 @@ import org.olat.core.gui.render.URLBuilder;
import org.olat.core.gui.translator.Translator;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.core.util.Formatter;
import org.olat.core.util.WebappHelper;
import uk.ac.ed.ph.jqtiplus.node.content.variable.PrintedVariable;
import uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem;
......@@ -71,6 +73,11 @@ public class FlowComponentRenderer extends AssessmentObjectComponentRenderer {
log.error("", e);
}
}
if(aRenderer.isMathJax()
|| (WebappHelper.isMathJaxMarkers() && (target.contains("\\(") || target.contains("\\[") || target.contains("$$")))) {
target.append(Formatter.elementLatexFormattingScript("o_c".concat(avc.getDispatchID())));
}
}
@Override
......
......@@ -25,6 +25,8 @@ import org.olat.core.gui.render.Renderer;
import org.olat.core.gui.render.StringOutput;
import org.olat.core.gui.render.URLBuilder;
import org.olat.core.gui.translator.Translator;
import org.olat.core.util.Formatter;
import org.olat.core.util.WebappHelper;
import uk.ac.ed.ph.jqtiplus.node.content.variable.PrintedVariable;
import uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem;
......@@ -60,6 +62,11 @@ public class ItemBodyResultComponentRenderer extends AssessmentObjectComponentRe
assessmentItem.getItemBody().getBlocks().forEach(block
-> renderBlock(assessmentRenderer, sb, cmp, resolvedAssessmentItem, itemSessionState, block, ubu, translator));
if(assessmentRenderer.isMathJax()
|| (WebappHelper.isMathJaxMarkers() && (sb.contains("\\(") || sb.contains("\\[") || sb.contains("$$")))) {
sb.append(Formatter.elementLatexFormattingScript("o_c".concat(cmp.getDispatchID())));
}
}
@Override
......
......@@ -74,7 +74,8 @@ public class QTI21AssessmentItemStatisticsController extends BasicController {
private final VelocityContainer mainVC;
private UserFilterController filterCtrl;
private final String mapperUri;
private final AssessmentItem item;
private final AssessmentItemRef itemRef;
private final QTI21StatisticSearchParams searchParams;
......@@ -86,7 +87,8 @@ public class QTI21AssessmentItemStatisticsController extends BasicController {
private QTI21StatisticsManager qtiStatisticsManager;
public QTI21AssessmentItemStatisticsController(UserRequest ureq, WindowControl wControl,
AssessmentItemRef itemRef, ResolvedAssessmentItem resolvedAssessmentItem, String sectionTitle, QTI21StatisticResourceResult resourceResult,
AssessmentItemRef itemRef, ResolvedAssessmentItem resolvedAssessmentItem,
String sectionTitle, QTI21StatisticResourceResult resourceResult,
boolean withFilter, boolean printMode) {
super(ureq, wControl);
......@@ -94,14 +96,14 @@ public class QTI21AssessmentItemStatisticsController extends BasicController {
this.itemRef = itemRef;
this.resourceResult = resourceResult;
searchParams = resourceResult.getSearchParams();
mainVC = createVelocityContainer("statistics_item");
mainVC.put("d3loader", new StatisticsComponent("d3loader"));
mainVC.contextPut("title", item.getTitle());
if(StringHelper.containsNonWhitespace(sectionTitle)) {
mainVC.contextPut("sectionTitle", sectionTitle);
}
mainVC.contextPut("printMode", new Boolean(printMode));
mainVC.contextPut("printMode", Boolean.valueOf(printMode));
QTI21QuestionType type = QTI21QuestionType.getTypeRelax(item);
if(type != null) {
......@@ -121,6 +123,7 @@ public class QTI21AssessmentItemStatisticsController extends BasicController {
itemBodyCtrl = new QTI21ItemBodyController(ureq, getWindowControl(), itemRef, resolvedAssessmentItem, resourceResult);
listenTo(itemBodyCtrl);
mainVC.put("question", itemBodyCtrl.getInitialComponent());
mapperUri = itemBodyCtrl.getMapperUri();
putInitialPanel(mainVC);
updateData(ureq);
......@@ -155,7 +158,7 @@ public class QTI21AssessmentItemStatisticsController extends BasicController {
}
}
if(textEntryInteractions.size() > 0) {
if(!textEntryInteractions.isEmpty()) {
Controller interactionCtrl = new TextEntryInteractionsStatisticsController(ureq, getWindowControl(), itemRef, item, textEntryInteractions, resourceResult);
listenTo(interactionCtrl);
String componentId = "interaction" + counter++;
......@@ -171,26 +174,24 @@ public class QTI21AssessmentItemStatisticsController extends BasicController {
if(interaction instanceof ChoiceInteraction) {
interactionCtrl = new SimpleChoiceInteractionStatisticsController(ureq, getWindowControl(),
itemRef, item, (ChoiceInteraction)interaction, itemStats, resourceResult);
itemRef, item, (ChoiceInteraction)interaction, itemStats, resourceResult, mapperUri);
} else if(interaction instanceof MatchInteraction) {
String responseIdentifier = interaction.getResponseIdentifier().toString();
if(responseIdentifier.startsWith("KPRIM_")
|| QTI21QuestionType.hasClass(interaction, QTI21Constants.CSS_MATCH_KPRIM)) {
interactionCtrl = new KPrimStatisticsController(ureq, getWindowControl(),
itemRef, item, (MatchInteraction)interaction, resourceResult);
itemRef, item, (MatchInteraction)interaction, resourceResult, mapperUri);
} else {
interactionCtrl = new MatchStatisticsController(ureq, getWindowControl(),
itemRef, item, (MatchInteraction)interaction, resourceResult);
itemRef, item, (MatchInteraction)interaction, resourceResult, mapperUri);
}
} else if(interaction instanceof HotspotInteraction) {
interactionCtrl = new HotspotInteractionStatisticsController(ureq, getWindowControl(),
itemRef, item, (HotspotInteraction)interaction, itemStats, resourceResult);
} else if(interaction instanceof HottextInteraction) {
interactionCtrl = new HottextInteractionStatisticsController(ureq, getWindowControl(),
itemRef, item, (HottextInteraction)interaction, itemStats, resourceResult);
itemRef, item, (HottextInteraction)interaction, itemStats, resourceResult, mapperUri);
}
if(interactionCtrl == null) {
interactionCtrl = new UnsupportedInteractionController(ureq, getWindowControl(),
......
......@@ -88,6 +88,10 @@ public class QTI21ItemBodyController extends FormBasicController {
initForm(ureq);
}
public String getMapperUri() {
return mapperUri;
}
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
......
......@@ -352,7 +352,9 @@ public class QTI21StatisticResourceResult implements StatisticResourceResult {
private Controller createAssessmentItemController(UserRequest ureq, WindowControl wControl,
AssessmentItemRef assessmentItemRef, String sectionTitle, boolean printMode) {
ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(assessmentItemRef);
Controller ctrl = new QTI21AssessmentItemStatisticsController(ureq, wControl, assessmentItemRef, resolvedAssessmentItem, sectionTitle, this, withFilter, printMode);
Controller ctrl = new QTI21AssessmentItemStatisticsController(ureq, wControl,
assessmentItemRef, resolvedAssessmentItem, sectionTitle, this, withFilter, printMode);
String iconCssClass = "o_mi_qtisc";
if(courseNode != null) {
ctrl = TitledWrapperHelper.getWrapper(ureq, wControl, ctrl, courseNode, iconCssClass);
......
......@@ -33,11 +33,10 @@ import org.olat.core.gui.control.controller.BasicController;
import org.olat.core.util.Util;
import org.olat.ims.qti.statistics.QTIType;
import org.olat.ims.qti.statistics.model.StatisticsItem;
import org.olat.ims.qti.statistics.ui.ResponseInfos;
import org.olat.ims.qti.statistics.ui.Series;
import org.olat.ims.qti21.QTI21StatisticsManager;
import org.olat.ims.qti21.manager.CorrectResponsesUtil;
import org.olat.ims.qti21.model.statistics.ChoiceStatistics;
import org.olat.ims.qti21.ui.components.FlowComponent;
import org.olat.ims.qti21.ui.statistics.QTI21AssessmentItemStatisticsController;
import org.olat.ims.qti21.ui.statistics.QTI21StatisticResourceResult;
import org.olat.ims.qti21.ui.statistics.SeriesFactory;
......@@ -60,6 +59,10 @@ import uk.ac.ed.ph.jqtiplus.value.Cardinality;
*/
public abstract class ChoiceInteractionStatisticsController extends BasicController {
protected final VelocityContainer mainVC;
protected int count = 0;
protected final String mapperUri;
protected final Interaction interaction;
protected final AssessmentItemRef itemRef;
protected final AssessmentItem assessmentItem;
......@@ -70,14 +73,15 @@ public abstract class ChoiceInteractionStatisticsController extends BasicControl
public ChoiceInteractionStatisticsController(UserRequest ureq, WindowControl wControl,
AssessmentItemRef itemRef, AssessmentItem assessmentItem, Interaction interaction,
StatisticsItem itemStats, QTI21StatisticResourceResult resourceResult) {
StatisticsItem itemStats, QTI21StatisticResourceResult resourceResult, String mapperUri) {
super(ureq, wControl, Util.createPackageTranslator(QTI21AssessmentItemStatisticsController.class, ureq.getLocale()));
this.interaction = interaction;
this.itemRef = itemRef;
this.assessmentItem = assessmentItem;
this.resourceResult = resourceResult;
this.mapperUri = mapperUri;
VelocityContainer mainVC = createVelocityContainer("statistics_interaction");
mainVC = createVelocityContainer("statistics_interaction");
Series series;
if(isMultipleChoice()) {
series = getMultipleChoice(itemStats);
......@@ -126,8 +130,8 @@ public abstract class ChoiceInteractionStatisticsController extends BasicControl
List<ResponseInfos> responseInfos = new ArrayList<>();
for (ChoiceStatistics statisticResponse:statisticResponses) {
Choice choice = statisticResponse.getChoice();
String text = getAnswerText(choice);
double ans_count = statisticResponse.getCount();
FlowComponent text = getAnswerText(choice);
double ansCount = statisticResponse.getCount();
numOfResults += statisticResponse.getCount();
boolean correct = correctAnswers.contains(choice.getIdentifier());
......@@ -147,7 +151,7 @@ public abstract class ChoiceInteractionStatisticsController extends BasicControl
}
String label = Integer.toString(++i);
d1.add(ans_count, label, cssColor);
d1.add(ansCount, label, cssColor);
responseInfos.add(new ResponseInfos(label, text, points, correct, survey, false));
}
......@@ -157,7 +161,7 @@ public abstract class ChoiceInteractionStatisticsController extends BasicControl
if(notAnswered > 0) {
String label = Integer.toString(++i);
String text = translate("user.not.answer");
responseInfos.add(new ResponseInfos(label, text, null, false, survey, false));
responseInfos.add(new ResponseInfos(label, text, null, null, null, false, survey, false));
d1.add(notAnswered, label, "bar_grey");
}
}
......@@ -185,7 +189,7 @@ public abstract class ChoiceInteractionStatisticsController extends BasicControl
List<ResponseInfos> responseInfos = new ArrayList<>();
for(ChoiceStatistics statisticResponse:statisticResponses) {
Choice choice = statisticResponse.getChoice();
String text = getAnswerText(choice);
FlowComponent text = getAnswerText(choice);
boolean correct = correctAnswers.contains(choice.getIdentifier());
double answersPerAnswerOption = statisticResponse.getCount();
......@@ -238,7 +242,7 @@ public abstract class ChoiceInteractionStatisticsController extends BasicControl
protected abstract List<ChoiceStatistics> getChoiceInteractionStatistics();
protected abstract String getAnswerText(Choice choice);
protected abstract FlowComponent getAnswerText(Choice choice);
}
......@@ -44,8 +44,6 @@ import org.olat.core.util.vfs.LocalFileImpl;
import org.olat.core.util.vfs.VFSMediaResource;
import org.olat.ims.qti.statistics.QTIType;
import org.olat.ims.qti.statistics.model.StatisticsItem;
import org.olat.ims.qti.statistics.ui.ResponseInfos;
import org.olat.ims.qti.statistics.ui.Series;
import org.olat.ims.qti21.QTI21StatisticsManager;
import org.olat.ims.qti21.manager.CorrectResponsesUtil;
import org.olat.ims.qti21.model.statistics.HotspotChoiceStatistics;
......@@ -203,7 +201,7 @@ public class HotspotInteractionStatisticsController extends BasicController {
String label = Integer.toString(++i);
d1.add(ans_count, label, cssColor);
responseInfos.add(new ResponseInfos(label, text, points, correct, survey, false));
responseInfos.add(new ResponseInfos(label, text, null, null, points, correct, survey, false));
}
if(numOfResults != numOfParticipants) {
......@@ -211,7 +209,7 @@ public class HotspotInteractionStatisticsController extends BasicController {
if(notAnswered > 0) {
String label = Integer.toString(++i);
String text = translate("user.not.answer");
responseInfos.add(new ResponseInfos(label, text, null, false, survey, false));
responseInfos.add(new ResponseInfos(label, text, null, null, null, false, survey, false));
d1.add(notAnswered, label, "bar_grey");
}
}
......@@ -263,7 +261,7 @@ public class HotspotInteractionStatisticsController extends BasicController {
d3.add(notAnswered, label);
Float pointsObj = survey ? null : (correct ? 1.0f : 0.0f);
responseInfos.add(new ResponseInfos(label, text, pointsObj, correct, survey, false));
responseInfos.add(new ResponseInfos(label, text, null, null, pointsObj, correct, survey, false));
}
List<BarSeries> serieList = new ArrayList<>(3);
......
......@@ -23,11 +23,9 @@ import java.util.List;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.util.Formatter;
import org.olat.core.util.StringHelper;
import org.olat.ims.qti.statistics.model.StatisticsItem;
import org.olat.ims.qti21.model.statistics.ChoiceStatistics;
import org.olat.ims.qti21.model.xml.AssessmentHtmlBuilder;
import org.olat.ims.qti21.ui.components.FlowComponent;
import org.olat.ims.qti21.ui.statistics.QTI21StatisticResourceResult;
import uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem;
......@@ -44,14 +42,11 @@ import uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef;
*/
public class HottextInteractionStatisticsController extends ChoiceInteractionStatisticsController {
public HottextInteractionStatisticsController(UserRequest ureq, WindowControl wControl,
AssessmentItemRef itemRef, AssessmentItem assessmentItem, HottextInteraction interaction,
StatisticsItem itemStats, QTI21StatisticResourceResult resourceResult) {
super(ureq, wControl, itemRef, assessmentItem, interaction, itemStats, resourceResult);
StatisticsItem itemStats, QTI21StatisticResourceResult resourceResult, String mapperUri) {
super(ureq, wControl, itemRef, assessmentItem, interaction, itemStats, resourceResult, mapperUri);
}
@Override
protected List<ChoiceStatistics> getChoiceInteractionStatistics() {
......@@ -61,12 +56,20 @@ public class HottextInteractionStatisticsController extends ChoiceInteractionSta
}
@Override
protected String getAnswerText(Choice choice) {
String text = choice.getLabel();
protected FlowComponent getAnswerText(Choice choice) {
String cmpId = "hot_" + (count++);
FlowComponent cmp = new FlowComponent(cmpId, resourceResult.getAssessmentItemFile(itemRef));
cmp.setMapperUri(mapperUri);
cmp.setInlineStatics(((Hottext)choice).getInlineStatics());
cmp.setResolvedAssessmentTest(resourceResult.getResolvedAssessmentTest());
mainVC.put(cmpId, cmp);
/*String text = choice.getLabel();
if(!StringHelper.containsNonWhitespace(text)) {
text = new AssessmentHtmlBuilder().inlineStaticString(((Hottext)choice).getInlineStatics());
text = Formatter.formatLatexFormulas(text);
}
return text;
}*/
return cmp;
}
}
......@@ -29,14 +29,11 @@ import org.olat.core.gui.components.velocity.VelocityContainer;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.controller.BasicController;
import org.olat.core.util.Formatter;
import org.olat.core.util.Util;
import org.olat.ims.qti.statistics.QTIType;
import org.olat.ims.qti.statistics.ui.ResponseInfos;
import org.olat.ims.qti.statistics.ui.Series;
import org.olat.ims.qti21.QTI21StatisticsManager;
import org.olat.ims.qti21.model.statistics.KPrimStatistics;
import org.olat.ims.qti21.model.xml.AssessmentHtmlBuilder;
import org.olat.ims.qti21.ui.components.FlowComponent;
import org.olat.ims.qti21.ui.statistics.QTI21AssessmentItemStatisticsController;
import org.olat.ims.qti21.ui.statistics.QTI21StatisticResourceResult;
import org.olat.ims.qti21.ui.statistics.SeriesFactory;
......@@ -57,26 +54,29 @@ import uk.ac.ed.ph.jqtiplus.types.Identifier;
*/
public class KPrimStatisticsController extends BasicController {
private final VelocityContainer mainVC;
private int count = 0;
private final String mapperUri;
private final MatchInteraction interaction;
private final AssessmentItemRef itemRef;
private final AssessmentItem assessmentItem;
private final QTI21StatisticResourceResult resourceResult;
private final AssessmentHtmlBuilder assessmentHtmlBuilder;
@Autowired
private QTI21StatisticsManager qtiStatisticsManager;
public KPrimStatisticsController(UserRequest ureq, WindowControl wControl,
AssessmentItemRef itemRef, AssessmentItem assessmentItem, MatchInteraction interaction,
QTI21StatisticResourceResult resourceResult) {
QTI21StatisticResourceResult resourceResult, String mapperUri) {
super(ureq, wControl, Util.createPackageTranslator(QTI21AssessmentItemStatisticsController.class, ureq.getLocale()));
this.interaction = interaction;
this.itemRef = itemRef;
this.assessmentItem = assessmentItem;
this.resourceResult = resourceResult;
assessmentHtmlBuilder = new AssessmentHtmlBuilder();
this.mapperUri = mapperUri;
VelocityContainer mainVC = createVelocityContainer("kprim_interaction");
mainVC = createVelocityContainer("kprim_interaction");
Series series = getKPrim();
VelocityContainer vc = createVelocityContainer("hbar_item");
vc.contextPut("series", series);
......@@ -100,7 +100,6 @@ public class KPrimStatisticsController extends BasicController {
List<KPrimStatistics> statisticResponses = qtiStatisticsManager
.getKPrimStatistics(itemRef.getIdentifier().toString(), assessmentItem, interaction, resourceResult.getSearchParams());
//TODO String mediaBaseURL = resourceResult.getMediaBaseURL();
boolean survey = QTIType.survey.equals(resourceResult.getType());
int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
List<SimpleMatchSet> matchSets = interaction.getSimpleMatchSets();
......@@ -125,11 +124,15 @@ public class KPrimStatisticsController extends BasicController {
d2.add(wrong, label);
d3.add(notanswered, label);
String text = "";
FlowComponent text = null;
for(SimpleAssociableChoice choice:fourMatchSet.getSimpleAssociableChoices()) {
if(choice.getIdentifier().equals(choiceIdentifier)) {
String textFlow = assessmentHtmlBuilder.flowStaticString(choice.getFlowStatics());
text = Formatter.formatLatexFormulas(textFlow);
String textName = "kprims_" + (count++);
text = new FlowComponent(textName, resourceResult.getAssessmentItemFile(itemRef));
text.setFlowStatics(choice.getFlowStatics());
text.setMapperUri(mapperUri);
text.setResolvedAssessmentTest(resourceResult.getResolvedAssessmentTest());
mainVC.put(textName, text);
}
}
responseInfos.add(new ResponseInfos(label, text, null, correctRight, survey, true));
......
......@@ -33,8 +33,8 @@ import org.olat.core.gui.control.controller.BasicController;
import org.olat.core.util.Util;
import org.olat.ims.qti21.QTI21StatisticsManager;
import org.olat.ims.qti21.model.statistics.MatchStatistics;
import org.olat.ims.qti21.model.xml.AssessmentHtmlBuilder;
import org.olat.ims.qti21.model.xml.QtiNodesExtractor;
import org.olat.ims.qti21.ui.components.FlowComponent;
import org.olat.ims.qti21.ui.statistics.QTI21AssessmentItemStatisticsController;
import org.olat.ims.qti21.ui.statistics.QTI21StatisticResourceResult;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -54,13 +54,14 @@ import uk.ac.ed.ph.jqtiplus.types.Identifier;
*/
public class MatchStatisticsController extends BasicController {
private int count = 0;
private final VelocityContainer mainVC;
private final String mapperUri;
private final MatchInteraction interaction;
private final AssessmentItemRef itemRef;
private final AssessmentItem assessmentItem;
private final QTI21StatisticResourceResult resourceResult;
private final AssessmentHtmlBuilder assessmentHtmlBuilder;
private final List<ChoiceWrapper> sourceWrappers = new ArrayList<>();
private final List<ChoiceWrapper> targetWrappers = new ArrayList<>();
......@@ -71,13 +72,13 @@ public class MatchStatisticsController extends BasicController {
public MatchStatisticsController(UserRequest ureq, WindowControl wControl,
AssessmentItemRef itemRef, AssessmentItem assessmentItem, MatchInteraction interaction,
QTI21StatisticResourceResult resourceResult) {
QTI21StatisticResourceResult resourceResult, String mapperUri) {
super(ureq, wControl, Util.createPackageTranslator(QTI21AssessmentItemStatisticsController.class, ureq.getLocale()));
this.interaction = interaction;
this.itemRef = itemRef;
this.assessmentItem = assessmentItem;
this.resourceResult = resourceResult;
assessmentHtmlBuilder = new AssessmentHtmlBuilder();
this.mapperUri = mapperUri;
mainVC = createVelocityContainer("match_interaction");
......@@ -230,13 +231,18 @@ public class MatchStatisticsController extends BasicController {
public class ChoiceWrapper {
private final Identifier choiceIdentifier;
private final SimpleAssociableChoice choice;
private final String summary;
private final FlowComponent summary;
public ChoiceWrapper(SimpleAssociableChoice choice) {
this.choice = choice;
this.choiceIdentifier = choice.getIdentifier();
summary = assessmentHtmlBuilder.flowStaticString(choice.getFlowStatics());
String summaryName = "sum_" + (count++);
summary = new FlowComponent(summaryName, resourceResult.getAssessmentItemFile(itemRef));
summary.setMapperUri(mapperUri);
summary.setFlowStatics(choice.getFlowStatics());
summary.setResolvedAssessmentTest(resourceResult.getResolvedAssessmentTest());
mainVC.put(summaryName, summary);
}
public Identifier getChoiceIdentifier() {
......@@ -247,7 +253,7 @@ public class MatchStatisticsController extends BasicController {
return choice;
}
public String getSummary() {
public FlowComponent getSummary() {
return summary;
}
}
......
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.ims.qti21.ui.statistics.interactions;
import java.util.Collections;
import java.util.List;
import org.olat.core.util.StringHelper;
import org.olat.course.assessment.AssessmentHelper;
import org.olat.ims.qti21.ui.components.FlowComponent;
/**
*
* Initial date: 10.03.2014<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class ResponseInfos {
private final String label;
private final String text;
private final FlowComponent textComponent;
private final Float points;
private final boolean correct;
private final boolean survey;
private final boolean kprim;
private final List<String> wrongAnswers;
public ResponseInfos(String label, FlowComponent textComponent, Float points, boolean correct, boolean survey, boolean kprim) {
this(label, null, textComponent, Collections.<String>emptyList(), points, correct, survey, kprim);
}
public ResponseInfos(String label, String text, FlowComponent textComponent, List<String> wrongAnswers, Float points,
boolean correct, boolean survey, boolean kprim) {
this.label = label;
this.text = text;
this.textComponent = textComponent;
this.points = points;
this.survey = survey;
this.kprim = kprim;
this.correct = correct;
this.wrongAnswers = wrongAnswers;
}
public String getLabel() {
return label;
}
public String getText() {
return text;
}
public FlowComponent getTextComponent() {
return textComponent;
}
public Float getPoints() {
return points;
}
public String getFormattedPoints() {
if(points == null) {
return "";
}
return AssessmentHelper.getRoundedScore(points);
}
public boolean isWrongAnswersAvailable() {
return wrongAnswers != null && wrongAnswers.size() > 0;
}
public List<String> getWrongAnswers() {
return wrongAnswers;
}
public String getFormattedWrongAnswers() {
if(wrongAnswers != null && wrongAnswers.size() > 0) {
StringBuilder sb = new StringBuilder();
for(String answer:wrongAnswers) {
if(sb.length() > 0) sb.append(", ");
if(StringHelper.containsNonWhitespace(answer)) {
sb.append(StringHelper.escapeHtml(answer));
} else {
sb.append("\"\"");
}
}
return sb.toString();
}
return "";
}
public boolean isSurvey() {
return survey;
}
public boolean isKprim() {
return kprim;
}
public boolean isCorrect() {
return correct;
}
}
\ No newline at end of file
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.ims.qti21.ui.statistics.interactions;
import java.util.List;
import org.olat.core.gui.components.chart.BarSeries;
import org.olat.core.gui.components.chart.BarSeries.Stringuified;
/**
*
* Initial date: 10.03.2014<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class Series {
private final boolean legend;
private String itemCss;
private String chartType;
private final List<BarSeries> series;
private final List<ResponseInfos> responseInfos;
private final int numOfParticipants;
private Stringuified datas;
public Series(List<BarSeries> series, List<ResponseInfos> responseInfos,
int numOfParticipants, boolean legend) {
this.legend = legend;
this.series = series;
this.responseInfos = responseInfos;
this.numOfParticipants = numOfParticipants;
}
public boolean isLegend() {
return legend;
}
public String getItemCss() {
return itemCss;
}
public void setItemCss(String itemCss) {
this.itemCss = itemCss;
}
public String getChartType() {
return chartType;
}
public void setChartType(String chartType) {
this.chartType = chartType;
}
public int getNumOfParticipants() {
return numOfParticipants;
}
public List<BarSeries> getSeries() {
return series;
}
public List<ResponseInfos> getResponseInfos() {
return responseInfos;
}
public boolean isColorsCustom() {
Stringuified d = getDatas();
return d.getColors().length() > 3;
}
public Stringuified getDatas() {
if(datas == null) {
datas = BarSeries.getDatasAndColors(series, "bar_default");
}
return datas;
}
}
......@@ -23,11 +23,9 @@ import java.util.List;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.util.Formatter;
import org.olat.core.util.StringHelper;
import org.olat.ims.qti.statistics.model.StatisticsItem;
import org.olat.ims.qti21.model.statistics.ChoiceStatistics;
import org.olat.ims.qti21.model.xml.AssessmentHtmlBuilder;
import org.olat.ims.qti21.ui.components.FlowComponent;
import org.olat.ims.qti21.ui.statistics.QTI21StatisticResourceResult;
import uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem;
......@@ -46,11 +44,10 @@ public class SimpleChoiceInteractionStatisticsController extends ChoiceInteracti
public SimpleChoiceInteractionStatisticsController(UserRequest ureq, WindowControl wControl,
AssessmentItemRef itemRef, AssessmentItem assessmentItem, ChoiceInteraction interaction,
StatisticsItem itemStats, QTI21StatisticResourceResult resourceResult) {
super(ureq, wControl, itemRef, assessmentItem, interaction, itemStats, resourceResult);
StatisticsItem itemStats, QTI21StatisticResourceResult resourceResult, String mapperUri) {
super(ureq, wControl, itemRef, assessmentItem, interaction, itemStats, resourceResult, mapperUri);
}
@Override
protected List<ChoiceStatistics> getChoiceInteractionStatistics() {
return qtiStatisticsManager
......@@ -58,12 +55,21 @@ public class SimpleChoiceInteractionStatisticsController extends ChoiceInteracti
}
@Override
protected String getAnswerText(Choice choice) {
protected FlowComponent getAnswerText(Choice choice) {
String cmpId = "sc_" + (count++);
FlowComponent cmp = new FlowComponent(cmpId, resourceResult.getAssessmentItemFile(itemRef));
cmp.setMapperUri(mapperUri);
cmp.setFlowStatics(((SimpleChoice)choice).getFlowStatics());
cmp.setResolvedAssessmentTest(resourceResult.getResolvedAssessmentTest());
mainVC.put(cmpId, cmp);
/*
String text = choice.getLabel();
if(!StringHelper.containsNonWhitespace(text)) {
text = new AssessmentHtmlBuilder().flowStaticString(((SimpleChoice)choice).getFlowStatics());
text = Formatter.formatLatexFormulas(text);
}
return text;
*/
return cmp;
}
}
......@@ -32,8 +32,6 @@ import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.controller.BasicController;
import org.olat.core.util.Util;
import org.olat.ims.qti.statistics.QTIType;
import org.olat.ims.qti.statistics.ui.ResponseInfos;
import org.olat.ims.qti.statistics.ui.Series;
import org.olat.ims.qti21.QTI21StatisticsManager;
import org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics;
import org.olat.ims.qti21.model.statistics.TextEntryInteractionStatistics;
......@@ -123,7 +121,7 @@ public class TextEntryInteractionsStatisticsController extends BasicController {
}
Float score = entry.getPoints() == null ? null : entry.getPoints().floatValue();
responseInfos.add(new ResponseInfos(label, text.toString(), entry.getWrongAnswers(), score, true, survey, false));
responseInfos.add(new ResponseInfos(label, text.toString(), null, entry.getWrongAnswers(), score, true, survey, false));
}
List<BarSeries> serieList = Collections.singletonList(d1);
......
<div class="o_qti_statistics_interaction">
<h4>$r.translate("chart.responses")</h4>
$r.render("questionChart")
<ul>
<ul class="o_qti_statistics_answers">
#foreach($responseInfo in $series.responseInfos)
<li class="o_qti_statistics-correct">
<strong>$responseInfo.label</strong>
<span class="o_qti_statistics_answer"><strong>$responseInfo.text</strong></span>
#if($responseInfo.wrongAnswersAvailable)
<p class="o_qti_statistics_wrong_answer">#if($responseInfo.survey)
<p class="o_qti_statistics_wrong_answer">FIB #if($responseInfo.survey)
<i>$r.translate("fib.answer")</i>
#else
<i>$r.translate("fib.wrong.answer")</i>
......
<div class="o_qti_statistics_interaction">
<h4>$r.translate("chart.responses")</h4>
$r.render("questionChart")
<ul>
<ul class="o_qti_statistics_answers">
#foreach($responseInfo in $series.responseInfos)
#if($responseInfo.correct)
<li class="o_qti_statistics-kplus">
#else
<li class="o_qti_statistics-kminus">
#end
<strong>$responseInfo.label</strong> <span class="o_qti_statistics_answer">$responseInfo.text</span>
<strong>$responseInfo.label</strong> <span class="o_qti_statistics_answer">
#if($r.isNotNull($responseInfo.textComponent))
$r.render($responseInfo.textComponent)
#else
$responseInfo.text
#end
</span>
</li>
#end
</ul>
......
......@@ -5,14 +5,14 @@
<tr>
<th></th>
#foreach($targetChoice in $targetChoices)
<th>$r.formatLatexFormulas(${targetChoice.getSummary()})</th>
<th>$r.render(${targetChoice.getSummary()})</th>
#end
</tr>
</thead>
<tbody>
#foreach($sourceChoice in $sourceChoices)
<tr>
<th>$r.formatLatexFormulas(${sourceChoice.getSummary()})</th>
<th>$r.render(${sourceChoice.getSummary()})</th>
#foreach($targetChoice in $targetChoices)
<td>
#set($scoreWrapper = $r.get("${sourceChoice.getChoiceIdentifier().toString()}-${targetChoice.getChoiceIdentifier().toString()}"))
......
......@@ -16,7 +16,7 @@
#if($r.available("questionChart"))
$r.render("questionChart")
#end
<ul>
<ul class="o_qti_statistics_answers">
#foreach($responseInfo in $series.responseInfos)
#if($responseInfo.survey)
<li class="o_qti_statistics-survey-item">
......@@ -36,7 +36,13 @@
<strong>$responseInfo.label.</strong>
#if($r.isNotNull($responseInfo.points)) $r.translate("answer.points", $responseInfo.formattedPoints) #end
#if($responseInfo.wrongAnswersAvailable)
<span class="o_qti_statistics_answer"><strong>$responseInfo.text</strong></span>
<span class="o_qti_statistics_answer">
#if($r.isNotNull($responseInfo.textComponent))
$r.render($responseInfo.textComponent)
#else
<strong>$responseInfo.text</strong>
#end
</span>
<p class="o_qti_statistics_wrong_answer">#if($responseInfo.survey)
<i>$r.translate("fib.answer")</i>
#else
......@@ -44,7 +50,12 @@
#end
$responseInfo.formattedWrongAnswers</p>
#else
<span class="o_qti_statistics_answer">$responseInfo.text</span>
<span class="o_qti_statistics_answer">
#if($r.isNotNull($responseInfo.textComponent))
$r.render($responseInfo.textComponent)
#else
$responseInfo.text
#end</span>
#end
</li>
#end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment