Esempio n. 1
0
  protected Item getCurrentItem() {
    if (oItem == null) {
      oItem = mainBean.getPregunta();
      if (oItem != null) {
        // Actualitzar pregunta
        String sTitle = getParameter(TITLE_PARAM);
        if (sTitle != null) {
          oItem.setTitle(sTitle);
        }
        String sEnunciat = getParameter(ENUNCIAT_PREGUNTA_PARAM);
        if (sEnunciat != null) {
          oItem.setStatement(sEnunciat);
        }
        String sInteractionswitch = getParameter(P_INTERACTIONSWITCH);
        if (sInteractionswitch != null && sInteractionswitch.trim().length() > 0) {
          QTIUtil.setInteractionswitch(oItem, sInteractionswitch);
        }

        String sHotspotType = getParameter(P_HOTSPOT_TYPE);
        if (sHotspotType != null) {
          setHotspotType(oItem, sHotspotType);
        }

        if (getParameter(P_MIN_NUMBER) != null && getParameter(P_MAX_NUMBER) != null) {
          int iMinNumber = mainBean.getIntParameter(P_MIN_NUMBER, 1);
          int iMaxNumber = mainBean.getIntParameter(P_MAX_NUMBER, -1);
          setResponseNumber(oItem, iMinNumber, iMaxNumber);
        }

        String sBackgroundImage = getParameter(P_BACKGROUND_IMAGE);
        if (sBackgroundImage != null && !"".equals(sBackgroundImage)) {
          int iWidth = mainBean.getIntParameter(P_WIDTH, -1);
          int iHeight = mainBean.getIntParameter(P_HEIGHT, -1);
          setBackgroundImage(oItem, sBackgroundImage, iWidth, iHeight);
        }
        setStyle();
        updateFeedback();
        updatePuntuation();
      } else {
        // Crear nova pregunta
        oItem = QTIUtil.createHotspotItem();
      }

      // -->Albert
      String sOrdreItem = getParameter(ITEM_ORDER_PARAM);
      if (sOrdreItem != null) {
        // System.out.println("l'estableixo a sOrdreItem:"+sOrdreItem+" idItem:"+oItem.getIdent());
        QTIUtil.setItemSelectionOrdering(mainBean.getFull(), oItem, sOrdreItem);
      }
      // ordre_pregunta
      // <--

    }
    return oItem;
  }
Esempio n. 2
0
 public String getBackgroundImage() {
   String sURI = null;
   RenderHotspot oRender = QTIUtil.getRenderHotspot((Item) getBeanObject());
   if (oRender != null) {
     Material oMaterial = QTIUtil.getFirstMaterial(oRender);
     if (oMaterial != null) {
       Matimage oMat = QTIUtil.getMatimage(oMaterial);
       if (oMat != null) {
         sURI = oMat.getURI();
       }
     }
   }
   return sURI;
 }
Esempio n. 3
0
 protected void setResponseNumber(Item oItem, int iMinNumber, int iMaxNumber) {
   QTISuperResponse oResponse = QTIUtil.getResponse(oItem);
   RenderHotspot oRender = QTIUtil.getRenderHotspot(oResponse);
   if (oRender != null) {
     if (iMinNumber > iMaxNumber) iMinNumber = iMaxNumber;
     oRender.setMinNumber(iMinNumber);
     oRender.setMaxNumber(iMaxNumber);
     if (iMaxNumber == 1) {
       oResponse.setCardinality("Single");
     } else {
       oResponse.setCardinality("Multiple");
     }
   }
 }
Esempio n. 4
0
 public void setStyle() {
   String sStyle = "";
   // border-color
   String sBorderColor = getParameter(P_STYLE_BORDER_COLOR);
   if (sBorderColor != null && isColor(sBorderColor)) {
     sStyle += "border-color:" + sBorderColor + ",";
   }
   // background
   String sBgType = getParameter(P_STYLE_BACKGROUND_TYPE);
   if (sBgType != null) {
     String sAction = getParameter(ACTION_PARAM);
     if (BACKGROUND_IMAGE_TYPE.equals(sBgType) && !A_SET_HOTSPOT_BACKGROUND_TYPE.equals(sAction)) {
       String sBgImage = getParameter(P_STYLE_BACKGROUND_IMAGE);
       if (sBgImage != null) {
         sStyle += "background:url(" + sBgImage + "),";
       }
     } else {
       String sBgColor = getParameter(P_STYLE_BACKGROUND_COLOR);
       if (sBgColor != null && isColor(sBgColor)) {
         sStyle += "background:" + sBgColor + ",";
       }
     }
     QTIUtil.setStyle(getBeanObject(), sStyle);
   }
 }
Esempio n. 5
0
 protected void setHotspotType(Item oItem, String sType) {
   String sCurrentType = getHotspotType();
   if (!sCurrentType.equals(sType)) {
     RenderHotspot oRender = QTIUtil.getRenderHotspot(oItem);
     if (oRender != null) {
       if (ZONE_HOTSPOT_TYPE.equals(sType)) {
         oRender.setShowDraw("No");
         oRender.setShowOptions("Yes");
         oRender.setTransp("Yes");
       } else if (OPTION_HOTSPOT_TYPE.equals(sType)) {
         oRender.setShowDraw("No");
         oRender.setShowOptions("Yes");
         oRender.setTransp("No");
       } else if (DOT_HOTSPOT_TYPE.equals(sType)) {
         oRender.setShowDraw("Yes");
         oRender.setShowOptions("Yes");
         oRender.setTransp("No");
       } else if (FREE_HOTSPOT_TYPE.equals(sType)) {
         oRender.setShowDraw("No");
         oRender.setShowOptions("No");
         oRender.setTransp("No");
       }
       QVHotspotListControl.updateConditions(mainBean.request, oItem);
     }
   }
 }
Esempio n. 6
0
 public int getMaxNumber() {
   int iNumber = 1;
   RenderHotspot oRender = QTIUtil.getRenderHotspot((Item) getBeanObject());
   if (oRender != null) {
     iNumber = oRender.getMaxNumber();
   }
   if (iNumber <= 0) iNumber = -1;
   return iNumber;
 }
Esempio n. 7
0
 protected void setBackgroundImage(Item oItem, String sURI, int iWidth, int iHeight) {
   RenderHotspot oRender = QTIUtil.getRenderHotspot(oItem);
   if (oRender != null && sURI != null) {
     Material oMaterial = QTIUtil.getFirstMaterial(oRender);
     if (oMaterial != null) {
       Matimage oMat = QTIUtil.getMatimage(oMaterial);
       if (oMat != null) {
         oMat.setURI(sURI);
         oMat.setWidth(iWidth);
         oMat.setHeight(iHeight);
       }
     } else {
       oMaterial = Material.createWithMatimage(null, sURI, iWidth, iHeight);
       oRender.addMaterial(oMaterial);
       oRender.setObjectPosition(
           oRender.getContents(), oMaterial, oRender.getContentPosition(oMaterial), 0);
     }
   }
 }
Esempio n. 8
0
 protected String getBackgroundStyle() {
   String sBgStyle = null;
   String sStyle = QTIUtil.getStyle(getBeanObject());
   if (sStyle != null) {
     StringTokenizer st = new StringTokenizer(sStyle, ",");
     while (st.hasMoreTokens()) {
       String s = st.nextToken();
       if (s.trim().startsWith("background:")) {
         sBgStyle = s.substring(s.indexOf("background:") + 11);
       }
     }
   }
   return sBgStyle;
 }
Esempio n. 9
0
 public String getBorderColorStyle() {
   return QTIUtil.getBorderColorStyle((Item) getBeanObject());
 }
Esempio n. 10
0
 public String getHotspotType() {
   return QTIUtil.getHotspotType((Item) getBeanObject());
 }