Search in sources :

Example 16 with Response

use of org.olat.ims.qti.editor.beecom.objects.Response in project openolat by klemens.

the class QTIStatisticsManagerImpl method getNumOfRightAnsweredMultipleChoice.

/**
 * calculates the percentage of participants that answered a answer option
 * correctly.<br>
 * Number at index 0 = answer option 1, Number at index 1 = answer option 2,
 * etc.
 *
 * @param item
 * @param numberOfParticipants
 * @param olatResource
 * @param olatResourceDetail
 * @return
 */
@Override
public List<StatisticChoiceOption> getNumOfRightAnsweredMultipleChoice(Item item, QTIStatisticSearchParams searchParams) {
    List<StatisticAnswerOption> answerToNumberList = getStatisticAnswerOptionsOfItem(item.getIdent(), searchParams);
    List<Response> responses = item.getQuestion().getResponses();
    List<StatisticChoiceOption> percentageRightAnswered = new ArrayList<StatisticChoiceOption>();
    for (Response response : responses) {
        String answerIdent = response.getIdent();
        long num = 0;
        for (StatisticAnswerOption answerToNumber : answerToNumberList) {
            String answer = answerToNumber.getAnswer();
            if (answer.indexOf(answerIdent) >= 0) {
                num += answerToNumber.getCount();
            }
        }
        percentageRightAnswered.add(new StatisticChoiceOption(response, num));
    }
    return percentageRightAnswered;
}
Also used : StatisticSurveyItemResponse(org.olat.ims.qti.statistics.model.StatisticSurveyItemResponse) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) StatisticAnswerOption(org.olat.ims.qti.statistics.model.StatisticAnswerOption) StatisticChoiceOption(org.olat.ims.qti.statistics.model.StatisticChoiceOption) ArrayList(java.util.ArrayList)

Example 17 with Response

use of org.olat.ims.qti.editor.beecom.objects.Response in project openolat by klemens.

the class QTIStatisticsManagerImpl method getNumOfAnswersPerSingleChoiceAnswerOption.

/**
 * calculates how many participants selected answer option 1 and/or option 2
 * and/or option 3...
 *
 * @param aQuestion
 * @param olatResource
 * @param olatResourceDetail
 * @return
 */
@Override
public List<StatisticChoiceOption> getNumOfAnswersPerSingleChoiceAnswerOption(Item item, QTIStatisticSearchParams searchParams) {
    List<StatisticAnswerOption> answerToNumberList = getStatisticAnswerOptionsOfItem(item.getIdent(), searchParams);
    List<Response> answerOptions = item.getQuestion().getResponses();
    List<StatisticChoiceOption> numOfAnswersPerOption = new ArrayList<>();
    for (int i = 0; i < answerOptions.size(); i++) {
        Response response = answerOptions.get(i);
        String responseIdent = response.getIdent();
        long num = 0;
        for (StatisticAnswerOption answerToNumber : answerToNumberList) {
            String answer = answerToNumber.getAnswer();
            if (answer.indexOf(responseIdent) >= 0) {
                num += answerToNumber.getCount();
            }
        }
        numOfAnswersPerOption.add(new StatisticChoiceOption(response, num));
    }
    return numOfAnswersPerOption;
}
Also used : StatisticSurveyItemResponse(org.olat.ims.qti.statistics.model.StatisticSurveyItemResponse) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) StatisticAnswerOption(org.olat.ims.qti.statistics.model.StatisticAnswerOption) StatisticChoiceOption(org.olat.ims.qti.statistics.model.StatisticChoiceOption) ArrayList(java.util.ArrayList)

Example 18 with Response

use of org.olat.ims.qti.editor.beecom.objects.Response in project openolat by klemens.

the class QTI12ItemStatisticsController method getQuestion.

private String getQuestion() {
    String question;
    if (item.getQuestion().getType() == Question.TYPE_FIB) {
        StringBuilder questionSb = new StringBuilder();
        List<Response> elements = item.getQuestion().getResponses();
        if (elements != null) {
            for (Response element : elements) {
                if (element instanceof FIBResponse) {
                    FIBResponse response = (FIBResponse) element;
                    if (FIBResponse.TYPE_CONTENT.equals(response.getType())) {
                        String content = response.getContent().renderAsHtml(mediaBaseURL);
                        questionSb.append(content);
                    } else if (FIBResponse.TYPE_BLANK.equals(response.getType())) {
                        questionSb.append(" ___________________ ");
                    }
                }
            }
        }
        question = questionSb.toString();
    } else {
        question = item.getQuestion().getQuestion().renderAsHtml(mediaBaseURL);
    }
    return question;
}
Also used : FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse)

Example 19 with Response

use of org.olat.ims.qti.editor.beecom.objects.Response in project openolat by klemens.

the class CSVToQuestionConverterTest method importMultipleChoice.

@Test
public void importMultipleChoice() throws IOException, URISyntaxException {
    URL importTxtUrl = CSVToQuestionConverterTest.class.getResource("question_import_mc.txt");
    Assert.assertNotNull(importTxtUrl);
    File importTxt = new File(importTxtUrl.toURI());
    String input = FileUtils.readFileToString(importTxt, "UTF-8");
    Translator translator = new KeyTranslator(Locale.ENGLISH);
    ImportOptions options = new ImportOptions();
    options.setShuffle(true);
    CSVToQuestionConverter converter = new CSVToQuestionConverter(translator, options);
    converter.parse(input);
    List<ItemAndMetadata> items = converter.getItems();
    Assert.assertNotNull(items);
    Assert.assertEquals(1, items.size());
    ItemAndMetadata importedItem = items.get(0);
    Item item = importedItem.getItem();
    Assert.assertNotNull(item);
    Assert.assertEquals("Fussball: Austragungsort", item.getTitle());
    Assert.assertEquals("Die Fussball WM wird alle vier Jahre von einem anderen Land ausgerichtet.", item.getObjectives());
    Assert.assertEquals(Question.TYPE_MC, item.getQuestion().getType());
    Assert.assertTrue(item.getQuestion() instanceof ChoiceQuestion);
    Material questionMat = item.getQuestion().getQuestion();
    Assert.assertNotNull(questionMat);
    Assert.assertNotNull(questionMat.getElements());
    Assert.assertEquals(1, questionMat.getElements().size());
    QTIObject questionMatEl = questionMat.getElements().get(0);
    Assert.assertTrue(questionMatEl instanceof Mattext);
    String text = ((Mattext) questionMatEl).getContent();
    Assert.assertEquals("In welchen L\u00E4ndern wurde zwischen dem Jahr 2000 und 2015 eine Fussball Weltmeisterschaft ausgetragen?", text);
    ChoiceQuestion question = (ChoiceQuestion) item.getQuestion();
    Assert.assertNotNull(question.getResponses());
    Assert.assertEquals(7, question.getResponses().size());
    List<Response> responses = question.getResponses();
    Assert.assertEquals(1.0f, responses.get(0).getPoints(), 0.0001);
    Assert.assertEquals(1.0f, responses.get(1).getPoints(), 0.0001);
    Assert.assertEquals(1.0f, responses.get(2).getPoints(), 0.0001);
    Assert.assertEquals(-1.0f, responses.get(3).getPoints(), 0.0001);
    Assert.assertEquals(-1.0f, responses.get(4).getPoints(), 0.0001);
    Assert.assertEquals(-1.0f, responses.get(5).getPoints(), 0.0001);
    Assert.assertEquals(-1.0f, responses.get(6).getPoints(), 0.0001);
    // after it will be set to true for all of them
    Assert.assertTrue(responses.get(0).isCorrect());
    Assert.assertTrue(responses.get(1).isCorrect());
    Assert.assertTrue(responses.get(2).isCorrect());
    Assert.assertFalse(responses.get(3).isCorrect());
    Assert.assertFalse(responses.get(4).isCorrect());
    Assert.assertFalse(responses.get(5).isCorrect());
    Assert.assertFalse(responses.get(6).isCorrect());
    String feedbackMastery = QTIEditHelper.getFeedbackMasteryText(item);
    Assert.assertEquals("Bravo! Die Antwort ich absolut korrekt.", feedbackMastery);
    String feedbackFail = QTIEditHelper.getFeedbackFailText(item);
    Assert.assertEquals("Leider falsch. Probieren Sie es noch einmal.", feedbackFail);
}
Also used : Material(org.olat.ims.qti.editor.beecom.objects.Material) URL(java.net.URL) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) Item(org.olat.ims.qti.editor.beecom.objects.Item) QTIObject(org.olat.ims.qti.editor.beecom.objects.QTIObject) Mattext(org.olat.ims.qti.editor.beecom.objects.Mattext) Translator(org.olat.core.gui.translator.Translator) KeyTranslator(org.olat.test.KeyTranslator) KeyTranslator(org.olat.test.KeyTranslator) ChoiceQuestion(org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion) File(java.io.File) Test(org.junit.Test)

Example 20 with Response

use of org.olat.ims.qti.editor.beecom.objects.Response in project openolat by klemens.

the class CSVToQuestionConverterTest method importFillInBlanck_en_metadata.

@Test
public void importFillInBlanck_en_metadata() throws IOException, URISyntaxException {
    URL importTxtUrl = CSVToQuestionConverterTest.class.getResource("question_import_fib_en_metadata.txt");
    Assert.assertNotNull(importTxtUrl);
    File importTxt = new File(importTxtUrl.toURI());
    String input = FileUtils.readFileToString(importTxt, "UTF-8");
    Translator translator = new KeyTranslator(Locale.ENGLISH);
    ImportOptions options = new ImportOptions();
    options.setShuffle(true);
    CSVToQuestionConverter converter = new CSVToQuestionConverter(translator, options);
    converter.parse(input);
    List<ItemAndMetadata> items = converter.getItems();
    Assert.assertNotNull(items);
    Assert.assertEquals(1, items.size());
    ItemAndMetadata importedItem = items.get(0);
    Item item = importedItem.getItem();
    Assert.assertNotNull(item);
    Assert.assertEquals(Question.TYPE_FIB, item.getQuestion().getType());
    Assert.assertTrue(item.getQuestion() instanceof FIBQuestion);
    FIBQuestion question = (FIBQuestion) item.getQuestion();
    List<Response> responses = question.getResponses();
    Assert.assertNotNull(responses);
    Assert.assertEquals(2, responses.size());
    // check java type
    for (Response response : responses) {
        Assert.assertTrue(response instanceof FIBResponse);
    }
    // check type
    Assert.assertEquals(FIBResponse.TYPE_CONTENT, ((FIBResponse) responses.get(0)).getType());
    Assert.assertEquals(FIBResponse.TYPE_BLANK, ((FIBResponse) responses.get(1)).getType());
    // check size
    Assert.assertEquals(20, ((FIBResponse) responses.get(1)).getSize());
    // check max length
    Assert.assertEquals(50, ((FIBResponse) responses.get(1)).getMaxLength());
}
Also used : URL(java.net.URL) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Item(org.olat.ims.qti.editor.beecom.objects.Item) Translator(org.olat.core.gui.translator.Translator) KeyTranslator(org.olat.test.KeyTranslator) KeyTranslator(org.olat.test.KeyTranslator) File(java.io.File) FIBQuestion(org.olat.ims.qti.editor.beecom.objects.FIBQuestion) Test(org.junit.Test)

Aggregations

Response (org.olat.ims.qti.editor.beecom.objects.Response)60 FIBResponse (org.olat.ims.qti.editor.beecom.objects.FIBResponse)44 ArrayList (java.util.ArrayList)32 ChoiceResponse (org.olat.ims.qti.editor.beecom.objects.ChoiceResponse)26 ChoiceQuestion (org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)22 Question (org.olat.ims.qti.editor.beecom.objects.Question)22 EssayResponse (org.olat.ims.qti.editor.beecom.objects.EssayResponse)20 Material (org.olat.ims.qti.editor.beecom.objects.Material)20 HashMap (java.util.HashMap)14 Item (org.olat.ims.qti.editor.beecom.objects.Item)14 EssayQuestion (org.olat.ims.qti.editor.beecom.objects.EssayQuestion)12 List (java.util.List)10 FIBQuestion (org.olat.ims.qti.editor.beecom.objects.FIBQuestion)10 StatisticSurveyItemResponse (org.olat.ims.qti.statistics.model.StatisticSurveyItemResponse)10 Mattext (org.olat.ims.qti.editor.beecom.objects.Mattext)8 StatisticAnswerOption (org.olat.ims.qti.statistics.model.StatisticAnswerOption)8 StatisticChoiceOption (org.olat.ims.qti.statistics.model.StatisticChoiceOption)8 File (java.io.File)6 URL (java.net.URL)6 Test (org.junit.Test)6