Package org.olat.ims.qti.editor.tree

Examples of org.olat.ims.qti.editor.tree.SectionNode


        // fetch new object
        if (cmd.equals(CMD_TOOLS_ADD_SECTION)) {
          Section newSection = QTIEditHelper.createSection(getTranslator());
          Item newItem = QTIEditHelper.createSCItem(getTranslator());
          newSection.getItems().add(newItem);
          SectionNode scNode = new SectionNode(newSection, qtiPackage);
          ItemNode itemNode = new ItemNode(newItem, qtiPackage);
          scNode.addChild(itemNode);
          insertObject = scNode;
        } else if (cmd.equals(CMD_TOOLS_ADD_SINGLECHOICE)) insertObject = new ItemNode(QTIEditHelper.createSCItem(getTranslator()), qtiPackage);
        else if (cmd.equals(CMD_TOOLS_ADD_MULTIPLECHOICE)) insertObject = new ItemNode(QTIEditHelper.createMCItem(getTranslator()), qtiPackage);
        else if (cmd.equals(CMD_TOOLS_ADD_KPRIM)) insertObject = new ItemNode(QTIEditHelper.createKPRIMItem(getTranslator()), qtiPackage);
        else if (cmd.equals(CMD_TOOLS_ADD_FIB)) insertObject = new ItemNode(QTIEditHelper.createFIBItem(getTranslator()), qtiPackage);
View Full Code Here


              Memento mem = (Memento) history.get(key);
              result.append("---+ Changes in test " + formatVariable(startedWithTitle) + ":");
              result.append(an.createChangeMessage(mem));
            }
          } else if (node instanceof SectionNode) {
            SectionNode sn = (SectionNode) node;
            String tmpKey = ((Section) sn.getUnderlyingQTIObject()).getIdent();
            String key = tmpKey + "/null/null/null";
            if (history.containsKey(key)) {
              // some section only data changed
              Memento mem = (Memento) history.get(key);
              result.append("\n---++ Section " + formatVariable(sn.getAltText()) + " changes:");
              result.append(sn.createChangeMessage(mem));
            }
          } 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())) {
                    // this response changed!
                    Memento tmpMem = (Memento) history.get(prefixKey + resp.getIdent());
                    if (respMem != null) {
                      respMem = respMem.getTimestamp() > tmpMem.getTimestamp() ? tmpMem : respMem;
                    } else {
                      hasChanges = true;
                      respMem = tmpMem;
                    }
                  }
                }
              }
              // }
              // output message
              if (hasChanges) {
                Memento mem = null;
                if (questMem != null && respMem != null) {
                  // use the earlier memento
                  mem = questMem.getTimestamp() > respMem.getTimestamp() ? respMem : questMem;
                } else if (questMem != null) {
                  mem = questMem;
                } else if (respMem != null) {
                  mem = respMem;
                }
                changeMessage.append(in.createChangeMessage(mem));
                itemMap.put(itemKey, itemKey);
                if (!parentSectkey.equals(sectionKey)) {
                  // either this item belongs to a new section or no section
                  // is active
                  result.append("\n---++ Section " + formatVariable(sn.getAltText()) + " changes:");
                  result.append("\n").append(changeMessage);
                  sectionKey = parentSectkey;
                } else {
                  result.append("\n").append(changeMessage);
                }
View Full Code Here

TOP

Related Classes of org.olat.ims.qti.editor.tree.SectionNode

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.