Search in sources :

Example 16 with Choice

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice in project openolat by klemens.

the class AssessmentObjectVelocityRenderDecorator method getVisibleOrderedChoices.

/*
	  <xsl:function name="qw:get-visible-ordered-choices" as="element()*">
	    <xsl:param name="interaction" as="element()"/>
	    <xsl:param name="choices" as="element()*"/>
	    <xsl:variable name="orderedChoices" as="element()*">
	      <xsl:choose>
	        <xsl:when test="$interaction/@shuffle='true'">
	          <xsl:for-each select="qw:get-shuffled-choice-order($interaction)">
	            <xsl:sequence select="$choices[@identifier=current()]"/>
	          </xsl:for-each>
	        </xsl:when>
	        <xsl:otherwise>
	          <xsl:sequence select="$choices"/>
	        </xsl:otherwise>
	      </xsl:choose>
	    </xsl:variable>
	    <xsl:sequence select="qw:filter-visible($orderedChoices)"/>
	  </xsl:function>
	  */
public List<InlineChoice> getVisibleOrderedChoices(InlineChoiceInteraction interaction) {
    List<InlineChoice> choices;
    if (interaction.getShuffle()) {
        // <xsl:variable name="shuffledChoiceOrders" select="$itemSessionState/qw:shuffledInteractionChoiceOrder"
        // as="element(qw:shuffledInteractionChoiceOrder)*"/>
        // <xsl:variable name="choiceSequence" as="xs:string?"
        // select="$shuffledChoiceOrders[@responseIdentifier=$interaction/@responseIdentifier]/@choiceSequence"/>
        List<Identifier> choiceOrders = itemSessionState.getShuffledInteractionChoiceOrder(interaction.getResponseIdentifier());
        choices = new ArrayList<>();
        for (Identifier choiceOrder : choiceOrders) {
            choices.add(interaction.getInlineChoice(choiceOrder));
        }
    } else {
        choices = interaction.getInlineChoices();
    }
    return choices.stream().filter((choice) -> isVisible(choice, itemSessionState)).collect(Collectors.toList());
}
Also used : URLBuilder(org.olat.core.gui.render.URLBuilder) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) GraphicAssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicAssociateInteraction) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) Choice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice) Map(java.util.Map) Flow(uk.ac.ed.ph.jqtiplus.node.content.basic.Flow) InlineChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction) StringOutput(org.olat.core.gui.render.StringOutput) OLog(org.olat.core.logging.OLog) ListValue(uk.ac.ed.ph.jqtiplus.value.ListValue) FlowStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.FlowStatic) HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) Translator(org.olat.core.gui.translator.Translator) InlineChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.InlineChoice) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) FormJSHelper(org.olat.core.gui.components.form.flexible.impl.FormJSHelper) AssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.AssociateInteraction) StringInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.StringInteraction) Value(uk.ac.ed.ph.jqtiplus.value.Value) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) AssociableHotspot(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.AssociableHotspot) Collectors(java.util.stream.Collectors) GapImg(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapImg) List(java.util.List) BlockStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.BlockStatic) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) AssessmentRenderFunctions.renderValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderValue) TextOrVariable(uk.ac.ed.ph.jqtiplus.node.content.variable.TextOrVariable) BaseType(uk.ac.ed.ph.jqtiplus.value.BaseType) VelocityRenderDecorator(org.olat.core.gui.render.velocity.VelocityRenderDecorator) RecordValue(uk.ac.ed.ph.jqtiplus.value.RecordValue) GraphicOrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicOrderInteraction) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) Settings(org.olat.core.helpers.Settings) Orientation(uk.ac.ed.ph.jqtiplus.value.Orientation) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode) GapChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapChoice) QueryUtils(uk.ac.ed.ph.jqtiplus.utils.QueryUtils) CandidateSessionContext(org.olat.ims.qti21.ui.CandidateSessionContext) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) HashMap(java.util.HashMap) StringMultipleAttribute(uk.ac.ed.ph.jqtiplus.attribute.value.StringMultipleAttribute) Prompt(uk.ac.ed.ph.jqtiplus.node.item.interaction.Prompt) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ResponseData(uk.ac.ed.ph.jqtiplus.types.ResponseData) ArrayList(java.util.ArrayList) Gap(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Gap) SliderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SliderInteraction) Cardinality(uk.ac.ed.ph.jqtiplus.value.Cardinality) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) OrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.OrderInteraction) StringHelper(org.olat.core.util.StringHelper) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) Iterator(java.util.Iterator) SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) IOException(java.io.IOException) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Shape(uk.ac.ed.ph.jqtiplus.node.expression.operator.Shape) GraphicGapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction) NullValue(uk.ac.ed.ph.jqtiplus.value.NullValue) GapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction) Tracing(org.olat.core.logging.Tracing) FileValue(uk.ac.ed.ph.jqtiplus.value.FileValue) BodyElement(uk.ac.ed.ph.jqtiplus.node.content.BodyElement) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) InlineChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.InlineChoice)

Example 17 with Choice

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice in project openolat by klemens.

the class ChoiceInteractionStatisticsController method getMultipleChoice.

private Series getMultipleChoice(StatisticsItem itemStats) {
    List<ChoiceStatistics> statisticResponses = getChoiceInteractionStatistics();
    BarSeries d1 = new BarSeries("bar_green", "green", translate("answer.correct"));
    BarSeries d2 = new BarSeries("bar_red", "red", translate("answer.false"));
    BarSeries d3 = new BarSeries("bar_grey", "grey", translate("answer.noanswer"));
    boolean survey = QTIType.survey.equals(resourceResult.getType());
    int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
    int notAnswered = numOfParticipants - (itemStats == null ? 0 : itemStats.getNumOfResults());
    List<Identifier> correctAnswers = CorrectResponsesUtil.getCorrectIdentifierResponses(assessmentItem, interaction);
    int i = 0;
    List<ResponseInfos> responseInfos = new ArrayList<>();
    for (ChoiceStatistics statisticResponse : statisticResponses) {
        Choice choice = statisticResponse.getChoice();
        String text = getAnswerText(choice);
        boolean correct = correctAnswers.contains(choice.getIdentifier());
        double answersPerAnswerOption = statisticResponse.getCount();
        double rightA;
        double wrongA;
        if (survey) {
            rightA = answersPerAnswerOption;
            wrongA = 0d;
        } else if (correct) {
            rightA = answersPerAnswerOption;
            wrongA = numOfParticipants - notAnswered - answersPerAnswerOption;
        } else {
            // minus negative points are not answered right?
            rightA = numOfParticipants - notAnswered - answersPerAnswerOption;
            wrongA = answersPerAnswerOption;
        }
        String label = Integer.toString(++i);
        d1.add(rightA, label);
        d2.add(wrongA, label);
        d3.add(notAnswered, label);
        Float pointsObj;
        if (survey) {
            pointsObj = null;
        } else {
            Double mappedValue = CorrectResponsesUtil.getMappedValue(assessmentItem, interaction, choice);
            if (mappedValue != null) {
                pointsObj = mappedValue.floatValue();
            } else {
                pointsObj = correct ? 1.0f : 0.0f;
            }
        }
        responseInfos.add(new ResponseInfos(label, text, pointsObj, correct, survey, false));
    }
    List<BarSeries> serieList = new ArrayList<>(3);
    serieList.add(d1);
    if (!survey) {
        serieList.add(d2);
        serieList.add(d3);
    }
    Series series = new Series(serieList, responseInfos, numOfParticipants, !survey);
    series.setChartType(survey ? SeriesFactory.BAR_ANSWERED : SeriesFactory.BAR_CORRECT_WRONG_NOT);
    series.setItemCss("o_qti_scitem");
    return series;
}
Also used : Choice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice) ArrayList(java.util.ArrayList) BarSeries(org.olat.core.gui.components.chart.BarSeries) ChoiceStatistics(org.olat.ims.qti21.model.statistics.ChoiceStatistics) Series(org.olat.ims.qti.statistics.ui.Series) BarSeries(org.olat.core.gui.components.chart.BarSeries) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ResponseInfos(org.olat.ims.qti.statistics.ui.ResponseInfos)

Example 18 with Choice

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice in project openolat by klemens.

the class ChoiceInteractionStatisticsController method getSingleChoice.

private Series getSingleChoice() {
    List<ChoiceStatistics> statisticResponses = getChoiceInteractionStatistics();
    boolean survey = QTIType.survey.equals(resourceResult.getType());
    int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
    List<Identifier> correctAnswers = CorrectResponsesUtil.getCorrectIdentifierResponses(assessmentItem, interaction);
    int i = 0;
    long numOfResults = 0;
    BarSeries d1 = new BarSeries();
    List<ResponseInfos> responseInfos = new ArrayList<>();
    for (ChoiceStatistics statisticResponse : statisticResponses) {
        Choice choice = statisticResponse.getChoice();
        String text = getAnswerText(choice);
        double ans_count = statisticResponse.getCount();
        numOfResults += statisticResponse.getCount();
        boolean correct = correctAnswers.contains(choice.getIdentifier());
        Float points;
        String cssColor;
        if (survey) {
            points = null;
            cssColor = "bar_default";
        } else {
            Double mappedValue = CorrectResponsesUtil.getMappedValue(assessmentItem, interaction, choice);
            if (mappedValue != null) {
                points = mappedValue.floatValue();
            } else {
                // response.getPoints();
                points = correct ? 1.0f : 0.0f;
            }
            cssColor = correct ? "bar_green" : "bar_red";
        }
        String label = Integer.toString(++i);
        d1.add(ans_count, label, cssColor);
        responseInfos.add(new ResponseInfos(label, text, points, correct, survey, false));
    }
    if (numOfResults != numOfParticipants) {
        long notAnswered = numOfParticipants - numOfResults;
        if (notAnswered > 0) {
            String label = Integer.toString(++i);
            String text = translate("user.not.answer");
            responseInfos.add(new ResponseInfos(label, text, null, false, survey, false));
            d1.add(notAnswered, label, "bar_grey");
        }
    }
    List<BarSeries> serieList = Collections.singletonList(d1);
    Series series = new Series(serieList, responseInfos, numOfParticipants, false);
    series.setChartType(SeriesFactory.BAR_CORRECT);
    series.setItemCss("o_qti_scitem");
    return series;
}
Also used : Choice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice) ArrayList(java.util.ArrayList) BarSeries(org.olat.core.gui.components.chart.BarSeries) ChoiceStatistics(org.olat.ims.qti21.model.statistics.ChoiceStatistics) Series(org.olat.ims.qti.statistics.ui.Series) BarSeries(org.olat.core.gui.components.chart.BarSeries) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ResponseInfos(org.olat.ims.qti.statistics.ui.ResponseInfos)

Aggregations

Choice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice)18 ArrayList (java.util.ArrayList)12 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)12 HottextInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction)12 Interaction (uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)12 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)12 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)10 IOException (java.io.IOException)8 HashMap (java.util.HashMap)8 Iterator (java.util.Iterator)8 List (java.util.List)8 Map (java.util.Map)8 Collectors (java.util.stream.Collectors)8 FormJSHelper (org.olat.core.gui.components.form.flexible.impl.FormJSHelper)8 StringOutput (org.olat.core.gui.render.StringOutput)8 URLBuilder (org.olat.core.gui.render.URLBuilder)8 VelocityRenderDecorator (org.olat.core.gui.render.velocity.VelocityRenderDecorator)8 Translator (org.olat.core.gui.translator.Translator)8 Settings (org.olat.core.helpers.Settings)8 OLog (org.olat.core.logging.OLog)8