Search in sources :

Example 6 with EssayResponse

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

the class ItemNode method createMemento.

public Memento createMemento() {
    Question question = item.getQuestion();
    // special case switches as question types are encoded into integers!!
    boolean isFIB = question.getType() == Question.TYPE_FIB;
    boolean isESSAY = question.getType() == Question.TYPE_ESSAY;
    // Item metadata
    QtiNodeMemento qnm = new QtiNodeMemento();
    Map<String, Object> qtiState = new HashMap<>();
    qtiState.put("ID", item.getIdent());
    qtiState.put("TITLE", item.getTitle());
    qtiState.put("OBJECTIVES", item.getObjectives());
    // question and responses
    qtiState.put("QUESTION.ID", question.getIdent());
    qtiState.put("QUESTION.HINTTEXT", question.getHintText());
    Material questMaterial = question.getQuestion();
    qtiState.put("QUESTION.MATERIAL.ASTEXT", questMaterial.renderAsText());
    List<String> ids = new ArrayList<String>();
    List<String> asTexts = new ArrayList<String>();
    List<String> feedbacks = new ArrayList<String>();
    List<Response> responses = question.getResponses();
    for (Iterator<Response> iter = responses.iterator(); iter.hasNext(); ) {
        Response resp = iter.next();
        if (isFIB) {
            if (FIBResponse.TYPE_BLANK.equals(((FIBResponse) resp).getType())) {
                asTexts.add(formatFIBResponseAsText((FIBResponse) resp));
                ids.add(resp.getIdent());
                feedbacks.add(QTIEditHelper.getFeedbackOlatRespText(item, resp.getIdent()));
            }
        } else if (isESSAY) {
            asTexts.add(formatESSAYResponseAsText((EssayResponse) resp));
            ids.add(resp.getIdent());
            feedbacks.add(QTIEditHelper.getFeedbackOlatRespText(item, resp.getIdent()));
        } else {
            // not a FIB or ESSAY response
            asTexts.add(resp.getContent().renderAsText());
            ids.add(resp.getIdent());
            feedbacks.add(QTIEditHelper.getFeedbackOlatRespText(item, resp.getIdent()));
        }
    }
    qtiState.put("QUESTION.RESPONSES.IDS", ids);
    qtiState.put("QUESTION.RESPONSES.ASTEXT", asTexts);
    qtiState.put("QUESTION.RESPONSES.FEEDBACK", feedbacks);
    // feedback
    qtiState.put("FEEDBACK.MASTERY", QTIEditHelper.getFeedbackMasteryText(item));
    qtiState.put("FEEDBACK.FAIL", QTIEditHelper.getFeedbackFailText(item));
    Control control = QTIEditHelper.getControl(item);
    qtiState.put("FEEDBACK.ENABLED", control.getFeedback() == 1 ? Boolean.TRUE : Boolean.FALSE);
    // 
    qnm.setQtiState(qtiState);
    // 
    return qnm;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Material(org.olat.ims.qti.editor.beecom.objects.Material) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) EssayResponse(org.olat.ims.qti.editor.beecom.objects.EssayResponse) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Control(org.olat.ims.qti.editor.beecom.objects.Control) WindowControl(org.olat.core.gui.control.WindowControl) Question(org.olat.ims.qti.editor.beecom.objects.Question) QTIObject(org.olat.ims.qti.editor.beecom.objects.QTIObject)

Example 7 with EssayResponse

use of org.olat.ims.qti.editor.beecom.objects.EssayResponse 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 8 with EssayResponse

use of org.olat.ims.qti.editor.beecom.objects.EssayResponse 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

EssayResponse (org.olat.ims.qti.editor.beecom.objects.EssayResponse)8 ArrayList (java.util.ArrayList)6 Control (org.olat.ims.qti.editor.beecom.objects.Control)6 WindowControl (org.olat.core.gui.control.WindowControl)4 EssayQuestion (org.olat.ims.qti.editor.beecom.objects.EssayQuestion)4 FIBResponse (org.olat.ims.qti.editor.beecom.objects.FIBResponse)4 Material (org.olat.ims.qti.editor.beecom.objects.Material)4 QTIObject (org.olat.ims.qti.editor.beecom.objects.QTIObject)4 Question (org.olat.ims.qti.editor.beecom.objects.Question)4 Response (org.olat.ims.qti.editor.beecom.objects.Response)4 HashMap (java.util.HashMap)2 List (java.util.List)2 VFSItem (org.olat.core.util.vfs.VFSItem)2 Item (org.olat.ims.qti.editor.beecom.objects.Item)2 Mattext (org.olat.ims.qti.editor.beecom.objects.Mattext)2 EssayAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder)2