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

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


    //      || element.getName().equalsIgnoreCase("assessmentfeedback");

    List materialsXML = element.selectNodes(".//material");
    if (materialsXML.size() == 0) return null;

    Feedback feedback = new Feedback();
    // attributes
    Attribute tmp = element.attribute("ident");
    if(tmp!=null) feedback.setIdent(tmp.getValue());
    tmp = element.attribute("title");
    if(tmp!=null) feedback.setTitle(tmp.getValue());
    tmp = element.attribute("view");
    if(tmp!=null) feedback.setView(tmp.getValue());
   
    // get type
    if (element.element("solution") != null) return null;
    else if (element.element("hint") != null) return null;
   
    // parse Material
    //MATERIAL
    List materials = new ArrayList();
    for(Iterator i = materialsXML.iterator();i.hasNext();) {
      materials.add(parserManager.parse((Element)i.next()))
    }
    feedback.setMaterials(materials);
    return feedback;
  }
View Full Code Here


   * @param object
   * @param sIdent
   * @return feedback
   */
  public static String getFeedbackText(QTIObject object, String sIdent) {
    Feedback feedback = getFeedback(object, sIdent);
    try {
      Material mat = (Material) feedback.getMaterials().get(0);
      return mat.renderAsText();
    } catch (Exception e) {
      // 
    }
    return "";
View Full Code Here

   * @param object
   * @param sIdent
   * @return
   */
  public static Material getFeedbackMaterial(QTIObject object, String sIdent) {
    Feedback feedback = getFeedback(object, sIdent);
    Material mat = null;
    try {
      mat = (Material) feedback.getMaterials().get(0);
    } catch (NullPointerException e) {
      // feedback is null
    }
    return mat;
  }
View Full Code Here

   * @param feedback
   * @param feedbacks
   * @return
   */
  private static Feedback getFeedback(String sIdent, List<Feedback> feedbacks) {
    Feedback feedback = null;
    for (Feedback tmp :feedbacks) {
      if (tmp.getIdent().equalsIgnoreCase(sIdent)) {
        if (tmp.getView() != null) {
          if (tmp.getView().equalsIgnoreCase("all")) {
            feedback = tmp;
View Full Code Here

   * @param feedbackString
   * @param sIdent
   */
  public static void setFeedback(QTIObject object, String feedbackString, String sIdent) {
    List feedbacks = getFeedbacks(object);
    Feedback feedback = getFeedback(sIdent, feedbacks);

    if (feedbackString == null || feedbackString.trim().length() == 0) {
      feedbacks.remove(feedback);
      return;
    }

    if (feedback != null) {
      feedbackString = feedbackString.trim();
      List matList = feedback.getMaterials();
      if (matList.size() > 0) {
        Material mat = (Material) feedback.getMaterials().get(0);
        if (mat == null) {
          mat = new Material();
          mat.getElements().add(new Mattext(feedbackString));
          feedback.getMaterials().add(mat);
        } else if (mat.getElements().size() > 0) {
          mat.getElements().set(0, new Mattext(feedbackString));
        } else {
          mat.getElements().add(new Mattext(feedbackString));
        }
      } else {
        Material mat = new Material();
        mat.getElements().add(new Mattext(feedbackString));
        feedback.getMaterials().add(mat);
      }
    } else {
      Feedback newFeedback = new Feedback();
      newFeedback.setIdent(sIdent);
      newFeedback.setView("All");
      Mattext newMattext = new Mattext(feedbackString);

      ArrayList newMattextL = new ArrayList();
      newMattextL.add(newMattext);

      Material material = new Material();
      material.setElements(newMattextL);

      ArrayList newMaterialL = new ArrayList();
      newMaterialL.add(material);
      newFeedback.setMaterials(newMaterialL);
      feedbacks.add(newFeedback);
    }

  }
View Full Code Here

TOP

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

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.