Package org.olat.ims.qti.editor.beecom.objects

Examples of org.olat.ims.qti.editor.beecom.objects.Question


  public QTIObject getUnderlyingQTIObject() {
    return item;
  }

  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 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 ids = new ArrayList();
    List asTexts = new ArrayList();
    List feedbacks = new ArrayList();
    List responses = question.getResponses();
    for (Iterator iter = responses.iterator(); iter.hasNext();) {
      Response resp = (Response) iter.next();
      if (isFIB) {
        if (FIBResponse.TYPE_BLANK.equals(((FIBResponse) resp).getType())) {
          asTexts.add(formatFIBResponseAsText((FIBResponse) resp));
View Full Code Here


    }

    // Update item
    item.setTitle(newTitle);
    item.setObjectives(newObjectives); // trust authors, don't to XSS filtering
    Question q = item.getQuestion();
    if (layout != null) {
      ((ChoiceQuestion) q).setFlowLabelClass(layout.getSelectedKey() == "h" ? ChoiceQuestion.BLOCK : ChoiceQuestion.LIST);
    }
    if (!isSurvey && !isRestrictedEditMode) {
      q.setShuffle(shuffle.getSelected() == 0);
      Control itemControl = (Control) item.getItemcontrols().get(0);
      itemControl.setFeedback(itemControl.getFeedback() == Control.CTRL_UNDEF ? Control.CTRL_NO : itemControl.getFeedback());
      itemControl.setHint(showHints.getSelected() == 0 ? Control.CTRL_YES : Control.CTRL_NO);
      itemControl.setSolution(showSolution.getSelected() == 0 ? Control.CTRL_YES : Control.CTRL_NO);
      q.setHintText(conditionalCommentFilter.filter(hint.getRawValue())); // trust authors, don't to XSS filtering
      q.setSolutionText(conditionalCommentFilter.filter(solution.getRawValue())); // trust authors, don't to XSS filtering
      if (limitTime.getSelectedKey().equals("y")) {
        item.setDuration(new Duration(1000 * timeSec.getIntValue() + 1000 * 60 * timeMin.getIntValue()));
      } else {
        item.setDuration(null);
      }
View Full Code Here

    RichTextConfiguration richTextConfig = desc.getEditorConfiguration();
    // set upload dir to the media dir
    richTextConfig.setFileBrowserUploadRelPath("media");

    // Layout/Alignment
    Question q = item.getQuestion();
    // alignment of KPRIM is only horizontal
    if (q instanceof ChoiceQuestion && item.getQuestion().getType() != Question.TYPE_KPRIM) {
      String[] layoutKeys = new String[] { "h", "v" };
      String[] layoutValues = new String[] { translate("form.imd.layout.horizontal"), translate("form.imd.layout.vertical") };
      //layout = uifactory.addDropdownSingleselect("form.imd.layout", formLayout, layoutKeys, layoutValues, null);
View Full Code Here

      //
      String oldObjectives = (String) qtiState.get("OBJECTIVES");
      String newObjectives = item.getObjectives();
      String objectChange = null;
      //
      Question question = item.getQuestion();
      boolean isFIB = question.getType() == Question.TYPE_FIB;
      boolean isESSAY = question.getType() == Question.TYPE_ESSAY;
      String oldHinttext = (String) qtiState.get("QUESTION.HINTTEXT");
      String newHinttext = question.getHintText();
      String hinttextChange = null;
      //
      String oldQuestion = (String) qtiState.get("QUESTION.MATERIAL.ASTEXT");
      String newQuestion = question.getQuestion().renderAsText();
      String questionChange = null;
      // feedback
      String feedbackChanges = "";
      String oldFeedbackMastery = (String) qtiState.get("FEEDBACK.MASTERY");
      String newFeedbackMastery = QTIEditHelper.getFeedbackMasteryText(item);
      String oldFeedbackFail = (String) qtiState.get("FEEDBACK.FAIL");
      String newFeedbackFail = QTIEditHelper.getFeedbackFailText(item);
      Control control = (Control) QTIEditHelper.getControl(item);
      Boolean oldHasFeedback = (Boolean) qtiState.get("FEEDBACK.ENABLED");
      Boolean newHasFeedback = control != null ? new Boolean(control.getFeedback() == 1) : null;
      //
      List asTexts = (List) qtiState.get("QUESTION.RESPONSES.ASTEXT");
      List feedbacks = (List) qtiState.get("QUESTION.RESPONSES.FEEDBACK");
      String oldResp = null;
      String newResp = null;
      String oldFeedback = null;
      String newFeedback = null;
      String responsesChanges = "";
      List responses = question.getResponses();
      int i = 0;
      boolean nothingToDo = false;
      for (Iterator iter = responses.iterator(); iter.hasNext();) {
        nothingToDo = false;
        Response resp = (Response) iter.next();
View Full Code Here

   
    // FEEDBACKS
    List feedbacksXML = element.elements("itemfeedback");
    List feedbacks = new ArrayList();
    item.setItemfeedbacks(feedbacks);
    Question question = item.getQuestion();
    for (Iterator i = feedbacksXML.iterator(); i.hasNext();) {
      Element el_feedback = (Element)i.next();
      if (el_feedback.element("solution") != null) { // fetch solution
        Element el_solution = el_feedback.element("solution");
        question.setSolutionText(getMaterialAsString(el_solution));
      } else if (el_feedback.element("hint") != null) { // fetch hint
        Element el_hint = el_feedback.element("hint");
        question.setHintText(getMaterialAsString(el_hint));
      } else {
        QTIObject tmpObj = (QTIObject) parserManager.parse(el_feedback);
        if (tmpObj != null) feedbacks.add(tmpObj);
      }
    }
View Full Code Here

        // Item qtiItem =
        // (Item)xstream.fromXML(xstream.toXML(selectedNode.getUnderlyingQTIObject()));
        Item toClone = (Item) selectedNode.getUnderlyingQTIObject();
        Item qtiItem = (Item) XStreamHelper.xstreamClone(toClone);
        // copy flow label class too, olat-2791
        Question orgQuestion = toClone.getQuestion();
        if (orgQuestion instanceof ChoiceQuestion) {
          String flowLabelClass = ((ChoiceQuestion)orgQuestion).getFlowLabelClass();
          Question copyQuestion =  qtiItem.getQuestion();
          if (copyQuestion instanceof ChoiceQuestion) {
            ((ChoiceQuestion)copyQuestion).setFlowLabelClass(flowLabelClass);
          } else {
            throw new AssertException("Could not copy flow-label-class, wrong type of copy question , must be 'ChoiceQuestion' but is " +copyQuestion);
          }
View Full Code Here

          } else if (node instanceof ItemNode) {
            ItemNode in = (ItemNode) node;
            SectionNode sn = (SectionNode) in.getParent();
            String parentSectkey = ((Section) ((SectionNode) in.getParent()).getUnderlyingQTIObject()).getIdent();
            Item item = (Item) in.getUnderlyingQTIObject();
            Question question = item.getQuestion();
            String itemKey = item.getIdent();
            String prefixKey = "null/" + itemKey;
            String questionIdent = question != null ? question.getQuestion().getId() : "null";
            String key = prefixKey + "/" + questionIdent + "/null";
            StringBuilder changeMessage = new StringBuilder();
            boolean hasChanges = false;

            if (!itemMap.containsKey(itemKey)) {
              Memento questMem = null;
              Memento respMem = null;
              if (history.containsKey(key)) {
                // question changed!
                questMem = (Memento) history.get(key);
                hasChanges = true;
              }
              // if(!hasChanges){
              // check if a response changed
              // new prefix for responses
              prefixKey += "/null/";
              // list contains org.olat.ims.qti.editor.beecom.objects.Response
              List responses = question != null ? question.getResponses() : null;
              if (responses != null && responses.size() > 0) {
                // check for changes in each response
                for (Iterator iter = responses.iterator(); iter.hasNext();) {
                  Response resp = (Response) iter.next();
                  if (history.containsKey(prefixKey + resp.getIdent())) {
View Full Code Here

TOP

Related Classes of org.olat.ims.qti.editor.beecom.objects.Question

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.