Search in sources :

Example 1 with EssayQuestion

use of org.olat.ims.qti.editor.beecom.objects.EssayQuestion in project OpenOLAT by OpenOLAT.

the class QTIWordExport method renderItem.

public static void renderItem(Item item, OpenXMLDocument document, boolean withResponses, Translator translator) {
    Element el = DocumentFactory.getInstance().createElement("dummy");
    item.addToElement(el);
    Element itemEl = (Element) el.elements().get(0);
    org.olat.ims.qti.container.qtielements.Item foo = new org.olat.ims.qti.container.qtielements.Item(itemEl);
    RenderInstructions renderInstructions = new RenderInstructions();
    renderInstructions.put(RenderInstructions.KEY_STATICS_PATH, "/");
    renderInstructions.put(RenderInstructions.KEY_LOCALE, translator.getLocale());
    renderInstructions.put(RenderInstructions.KEY_RENDER_TITLE, Boolean.TRUE);
    if (item.getQuestion() != null) {
        Map<String, String> iinput = new HashMap<String, String>();
        String questionType = null;
        String questionScore = null;
        Question question = item.getQuestion();
        if (question instanceof ChoiceQuestion) {
            ChoiceQuestion choice = (ChoiceQuestion) question;
            if (question.getType() == Question.TYPE_SC) {
                questionType = translator.translate("item.type.sc");
                fetchPointsOfMultipleChoices(itemEl, choice, iinput);
            } else if (question.getType() == Question.TYPE_MC) {
                questionType = translator.translate("item.type.mc");
                fetchPointsOfMultipleChoices(itemEl, choice, iinput);
            } else if (question.getType() == Question.TYPE_KPRIM) {
                questionType = translator.translate("item.type.kprim");
                fetchPointsOfKPrim(itemEl, choice, iinput);
            }
        } else if (question instanceof FIBQuestion) {
            questionType = translator.translate("item.type.sc");
            for (Response response : question.getResponses()) {
                FIBResponse fibResponse = (FIBResponse) response;
                if ("BLANK".equals(fibResponse.getType())) {
                    iinput.put(fibResponse.getIdent(), fibResponse.getCorrectBlank());
                }
            }
        } else if (question instanceof EssayQuestion) {
            questionType = translator.translate("item.type.essay");
        }
        if (question != null && question.getMaxValue() > 0.0f) {
            questionScore = AssessmentHelper.getRoundedScore(question.getMaxValue());
            questionScore = translator.translate("item.score.long", new String[] { questionScore });
        }
        renderInstructions.put(RenderInstructions.KEY_RENDER_CORRECT_RESPONSES, new Boolean(withResponses));
        renderInstructions.put(RenderInstructions.KEY_CORRECT_RESPONSES_MAP, iinput);
        renderInstructions.put(RenderInstructions.KEY_QUESTION_TYPE, questionType);
        renderInstructions.put(RenderInstructions.KEY_QUESTION_SCORE, questionScore);
        renderInstructions.put(RenderInstructions.KEY_QUESTION_OO_TYPE, new Integer(question.getType()));
    }
    foo.renderOpenXML(document, renderInstructions);
}
Also used : EssayQuestion(org.olat.ims.qti.editor.beecom.objects.EssayQuestion) HashMap(java.util.HashMap) Element(org.dom4j.Element) RenderInstructions(org.olat.ims.qti.container.qtielements.RenderInstructions) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Item(org.olat.ims.qti.editor.beecom.objects.Item) EssayQuestion(org.olat.ims.qti.editor.beecom.objects.EssayQuestion) FIBQuestion(org.olat.ims.qti.editor.beecom.objects.FIBQuestion) ChoiceQuestion(org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion) Question(org.olat.ims.qti.editor.beecom.objects.Question) ChoiceQuestion(org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion) FIBQuestion(org.olat.ims.qti.editor.beecom.objects.FIBQuestion)

Example 2 with EssayQuestion

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

the class QTI12To21Converter method convertEssay.

private AssessmentItemBuilder convertEssay(Item item) {
    EssayAssessmentItemBuilder itemBuilder = new EssayAssessmentItemBuilder("Essay", qtiSerializer);
    convertItemBasics(item, itemBuilder);
    EssayQuestion question = (EssayQuestion) item.getQuestion();
    EssayResponse response = question.getEssayResponse();
    int cols = response.getColumns();
    int rows = response.getRows();
    itemBuilder.setExpectedLength(cols * rows);
    itemBuilder.setExpectedLines(rows);
    double score = question.getMaxValue();
    itemBuilder.setMinScore(0.0d);
    itemBuilder.setMaxScore(score);
    return itemBuilder;
}
Also used : EssayQuestion(org.olat.ims.qti.editor.beecom.objects.EssayQuestion) EssayResponse(org.olat.ims.qti.editor.beecom.objects.EssayResponse) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder)

Example 3 with EssayQuestion

use of org.olat.ims.qti.editor.beecom.objects.EssayQuestion in project OpenOLAT by OpenOLAT.

the class QTIEditHelper method createEssayItem.

/**
 * Creates a new essay item
 * @param trans
 * @return New essay item.
 */
public static Item createEssayItem(Translator trans) {
    // create item
    Item newItem = new Item();
    newItem.setIdent(EDITOR_IDENT + ":" + ITEM_TYPE_ESSAY + ":" + String.valueOf(CodeHelper.getRAMUniqueID()));
    newItem.setTitle(trans.translate("editor.newquestion"));
    newItem.setLabel("");
    // conrols
    Control control = new Control();
    List<Control> controls = new ArrayList<Control>();
    controls.add(control);
    newItem.setItemcontrols(controls);
    QTIEditHelper.setFeedbackMastery(newItem, "");
    QTIEditHelper.setFeedbackFail(newItem, "");
    EssayQuestion essayquestion = new EssayQuestion();
    essayquestion.getQuestion().getElements().add(new Mattext(trans.translate("editor.newquestiontext")));
    essayquestion.setSingleCorrect(true);
    essayquestion.setSingleCorrectScore(1);
    EssayResponse response = new EssayResponse();
    Material mat = new Material();
    mat.add(new Mattext(trans.translate("editor.newtextelement")));
    response.setContent(mat);
    essayquestion.getResponses().add(response);
    newItem.setQuestion(essayquestion);
    return newItem;
}
Also used : EssayQuestion(org.olat.ims.qti.editor.beecom.objects.EssayQuestion) Item(org.olat.ims.qti.editor.beecom.objects.Item) VFSItem(org.olat.core.util.vfs.VFSItem) Control(org.olat.ims.qti.editor.beecom.objects.Control) Mattext(org.olat.ims.qti.editor.beecom.objects.Mattext) EssayResponse(org.olat.ims.qti.editor.beecom.objects.EssayResponse) ArrayList(java.util.ArrayList) Material(org.olat.ims.qti.editor.beecom.objects.Material)

Example 4 with EssayQuestion

use of org.olat.ims.qti.editor.beecom.objects.EssayQuestion in project OpenOLAT by OpenOLAT.

the class QTI12To21Converter method convertEssay.

private AssessmentItemBuilder convertEssay(Item item) {
    EssayAssessmentItemBuilder itemBuilder = new EssayAssessmentItemBuilder("Essay", qtiSerializer);
    convertItemBasics(item, itemBuilder);
    EssayQuestion question = (EssayQuestion) item.getQuestion();
    EssayResponse response = question.getEssayResponse();
    int cols = response.getColumns();
    int rows = response.getRows();
    itemBuilder.setExpectedLength(cols * rows);
    itemBuilder.setExpectedLines(rows);
    double score = question.getMaxValue();
    itemBuilder.setMinScore(0.0d);
    itemBuilder.setMaxScore(score);
    return itemBuilder;
}
Also used : EssayQuestion(org.olat.ims.qti.editor.beecom.objects.EssayQuestion) EssayResponse(org.olat.ims.qti.editor.beecom.objects.EssayResponse) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder)

Example 5 with EssayQuestion

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

the class QTIEditHelper method createEssayItem.

/**
 * Creates a new essay item
 * @param trans
 * @return New essay item.
 */
public static Item createEssayItem(Translator trans) {
    // create item
    Item newItem = new Item();
    newItem.setIdent(EDITOR_IDENT + ":" + ITEM_TYPE_ESSAY + ":" + String.valueOf(CodeHelper.getRAMUniqueID()));
    newItem.setTitle(trans.translate("editor.newquestion"));
    newItem.setLabel("");
    // conrols
    Control control = new Control();
    List<Control> controls = new ArrayList<Control>();
    controls.add(control);
    newItem.setItemcontrols(controls);
    QTIEditHelper.setFeedbackMastery(newItem, "");
    QTIEditHelper.setFeedbackFail(newItem, "");
    EssayQuestion essayquestion = new EssayQuestion();
    essayquestion.getQuestion().getElements().add(new Mattext(trans.translate("editor.newquestiontext")));
    essayquestion.setSingleCorrect(true);
    essayquestion.setSingleCorrectScore(1);
    EssayResponse response = new EssayResponse();
    Material mat = new Material();
    mat.add(new Mattext(trans.translate("editor.newtextelement")));
    response.setContent(mat);
    essayquestion.getResponses().add(response);
    newItem.setQuestion(essayquestion);
    return newItem;
}
Also used : EssayQuestion(org.olat.ims.qti.editor.beecom.objects.EssayQuestion) Item(org.olat.ims.qti.editor.beecom.objects.Item) VFSItem(org.olat.core.util.vfs.VFSItem) Control(org.olat.ims.qti.editor.beecom.objects.Control) Mattext(org.olat.ims.qti.editor.beecom.objects.Mattext) EssayResponse(org.olat.ims.qti.editor.beecom.objects.EssayResponse) ArrayList(java.util.ArrayList) Material(org.olat.ims.qti.editor.beecom.objects.Material)

Aggregations

EssayQuestion (org.olat.ims.qti.editor.beecom.objects.EssayQuestion)6 EssayResponse (org.olat.ims.qti.editor.beecom.objects.EssayResponse)4 Item (org.olat.ims.qti.editor.beecom.objects.Item)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 Element (org.dom4j.Element)2 VFSItem (org.olat.core.util.vfs.VFSItem)2 RenderInstructions (org.olat.ims.qti.container.qtielements.RenderInstructions)2 ChoiceQuestion (org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)2 Control (org.olat.ims.qti.editor.beecom.objects.Control)2 FIBQuestion (org.olat.ims.qti.editor.beecom.objects.FIBQuestion)2 FIBResponse (org.olat.ims.qti.editor.beecom.objects.FIBResponse)2 Material (org.olat.ims.qti.editor.beecom.objects.Material)2 Mattext (org.olat.ims.qti.editor.beecom.objects.Mattext)2 Question (org.olat.ims.qti.editor.beecom.objects.Question)2 Response (org.olat.ims.qti.editor.beecom.objects.Response)2 EssayAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder)2