コード例 #1
0
 private String getQuestionImage() {
   String thumbnailImage = "";
   String assetName = "";
   try {
     if (collectionItemDo.getResource().getAssets() != null
         && collectionItemDo.getResource().getAssets().size() > 0) {
       assetName = collectionItemDo.getResource().getAssets().get(0).getAsset().getName();
       thumbnailImage =
           collectionItemDo.getResource().getAssetURI()
               + collectionItemDo.getResource().getFolder()
               + assetName;
     } else {
       thumbnailImage = collectionItemDo.getResource().getThumbnails().getUrl();
     }
   } catch (Exception e) {
     AppClientFactory.printSevereLogger("PreviewResourceView getQuestionImage:::" + e);
   }
   return thumbnailImage != null ? thumbnailImage : "images/defaultRes.png";
 }
コード例 #2
0
  /**
   * This method is used to print collection breakdown data
   *
   * @param result
   */
  void setCollectionBreakDownPrintData(ArrayList<UserDataDo> result) {
    try {
      printResourceData.clear();
      UserDataDo maxAvgValue =
          Collections.max(
              result,
              new Comparator<UserDataDo>() {
                public int compare(UserDataDo o1, UserDataDo o2) {
                  Long obj1 = new Long(o1.getTimeSpent());
                  Long obj2 = new Long(o2.getTimeSpent());
                  return obj1.compareTo(obj2);
                }
              });

      final AdvancedFlexTable adTable = new AdvancedFlexTable();
      adTable.getElement().setAttribute("style", "background: #fff; width: 1000px;");

      adTable.setHeaderWidget(0, getHeaderLbl(i18n.GL3259(), 35));
      adTable.setHeaderWidget(1, getHeaderLbl(i18n.GL0308(), 55));
      adTable.setHeaderWidget(2, getHeaderLbl(i18n.GL3260(), 600));
      adTable.setHeaderWidget(3, getHeaderLbl(i18n.GL2084(), 110));
      adTable.setHeaderWidget(4, getHeaderLbl(i18n.GL3261(), 50));
      adTable.setHeaderWidget(5, getHeaderLbl(i18n.GL3273(), 60));

      int rowVal = 0;
      for (int i = 0; i < result.size(); i++) {
        adTable.setWidget(rowVal, 0, new Label(String.valueOf(result.get(i).getItemSequence())));

        // set Format
        String resourceCategory =
            result.get(i).getResourceFormat() != null
                ? result.get(i).getResourceFormat().trim()
                : "";
        String categoryStyle = "";
        if (resourceCategory.equalsIgnoreCase("website")
            || resourceCategory.equalsIgnoreCase("webpage")) {
          resourceCategory = "webpage";
          categoryStyle = res.css().category_new_type_webpage();
        } else if (resourceCategory.equalsIgnoreCase("slide")
            || resourceCategory.equalsIgnoreCase("image")) {
          resourceCategory = "image";
          categoryStyle = res.css().category_new_type_image();
        } else if (resourceCategory.equalsIgnoreCase("handout")
            || resourceCategory.equalsIgnoreCase("lesson")
            || resourceCategory.equalsIgnoreCase("textbook")
            || resourceCategory.equalsIgnoreCase("text")) {
          resourceCategory = "text";
          categoryStyle = res.css().category_new_type_text();
        } else if (resourceCategory.equalsIgnoreCase("exam")) {
          resourceCategory = "webpage";
          categoryStyle = res.css().category_new_type_webpage();
        } else if (resourceCategory.equalsIgnoreCase("video")) {
          resourceCategory = "video";
          categoryStyle = res.css().category_new_type_video();
        } else if (resourceCategory.equalsIgnoreCase("interactive")) {
          resourceCategory = "webpage";
          categoryStyle = res.css().category_new_type_interactive();
        } else if (resourceCategory.equalsIgnoreCase("audio")) {
          resourceCategory = "audio";
          categoryStyle = res.css().category_new_type_audio();
        } else {
          categoryStyle = res.css().category_new_type_other();
        }
        Label categorylbl = new Label();
        categorylbl.addStyleName(categoryStyle);
        categorylbl.addStyleName(res.css().setMarginAuto());
        adTable.setWidget(rowVal, 1, categorylbl);

        // Set Question Title
        Label questionTitle = new Label(AnalyticsUtil.html2text(result.get(i).getTitle()));
        questionTitle.setStyleName(res.css().alignCenterAndBackground());
        questionTitle.addStyleName(res.css().alignLeft());
        adTable.setWidget(rowVal, 2, questionTitle);

        // Set time spent
        HorizontalPanel timeSpentpnl = new HorizontalPanel();
        timeSpentpnl.add(AnalyticsUtil.getTimeStampLabel(result.get(i).getAvgTimeSpent()));
        Label progressBar = new Label();
        progressBar.setStyleName(res.css().setProgressBar());
        timeSpentpnl.add(progressBar);
        double maxAvgVal =
            ((double) result.get(i).getAvgTimeSpent()) / ((double) maxAvgValue.getTimeSpent());
        progressBar.getElement().getStyle().setWidth(maxAvgVal * 100, Unit.PX);
        adTable.setWidget(rowVal, 3, timeSpentpnl);

        // set Views label
        // HorizontalPanel viewpnl=new HorizontalPanel();
        Label viewlbl = new Label(Integer.toString(result.get(i).getViews()));
        viewlbl.setStyleName(res.css().alignCenterAndBackground());
        /* viewpnl.add(viewlbl);
        Label viewProgressBar=new Label();
        viewProgressBar.setStyleName(res.css().setProgressBar());
        viewpnl.add(viewProgressBar);
        float maxViewVal = ((float) result.get(i).getViews())/((float) maxViews.getViews());
        viewProgressBar.getElement().getStyle().setWidth(maxViewVal*100, Unit.PX);*/
        adTable.setWidget(rowVal, 4, viewlbl);

        // Set reactions
        int reaction = result.get(i).getAvgReaction();
        HTMLPanel reactionpnl = new HTMLPanel("");
        reactionpnl.add(new AnalyticsReactionWidget(reaction));
        Label reactioncount = new Label();
        reactionpnl.add(reactioncount);
        reactioncount.setText(reaction + "/5");
        reactioncount.setStyleName(res.css().alignCenterAndBackground());
        adTable.setWidget(rowVal, 5, reactionpnl);
        rowVal++;
      }
      printResourceData.add(adTable);
      printWidget.add(printResourceData);
    } catch (Exception e) {
      AppClientFactory.printSevereLogger(
          "CollectionSummaryTeacherView : setCollectionBreakDownPrintData : " + e.getMessage());
    }
  }
コード例 #3
0
  /**
   * This is used to print opened questions data
   *
   * @param result
   */
  void setOpenendedQuestionsPrintData(ArrayList<UserDataDo> result) {
    try {
      printOpendedData.clear();
      int totalUserCount = collectionMetaData.getUserCount();

      final AdvancedFlexTable adTable = new AdvancedFlexTable();
      adTable.getElement().setAttribute("style", "background: #fff; width: 1000px;");

      adTable.setHeaderWidget(0, getHeaderLbl(i18n.GL3259(), 25));
      adTable.setHeaderWidget(1, getHeaderLbl(i18n.GL0308(), 35));
      adTable.setHeaderWidget(2, getHeaderLbl(i18n.GL3260(), 500));
      adTable.setHeaderWidget(3, getHeaderLbl(i18n.GL2084(), 70));
      adTable.setHeaderWidget(4, getHeaderLbl(i18n.GL3261(), 30));
      adTable.setHeaderWidget(5, getHeaderLbl(i18n.GL3273(), 80));

      if (result.size() != 0) {
        for (int i = 0; i < result.size(); i++) {
          adTable.setWidget(i, 0, new Label(String.valueOf(result.get(i).getItemSequence())));

          // Set Question Title
          Label questionTitle =
              new Label(
                  AnalyticsUtil.html2text(
                      result.get(i).getTitle() != null ? result.get(i).getTitle() : ""));
          questionTitle.setStyleName(res.css().alignCenterAndBackground());
          questionTitle.addStyleName(res.css().alignLeft());
          adTable.setWidget(i, 1, questionTitle);

          // Set completion
          HTMLPanel completionpnl = new HTMLPanel("");
          Label progressBar = new Label();
          progressBar.setStyleName(res.css().setProgressBar());
          completionpnl.add(progressBar);
          Label incompleteProgressBar = new Label();
          incompleteProgressBar.setStyleName(res.css().setIncorrectProgressBar());
          completionpnl.add(incompleteProgressBar);
          int attemptedCount = result.get(i).getTotalAttemptUserCount();
          float maxAvgVal = ((float) attemptedCount) / ((float) totalUserCount);
          progressBar.getElement().getStyle().setWidth(maxAvgVal * 100, Unit.PX);
          incompleteProgressBar.getElement().getStyle().setWidth((100 - maxAvgVal * 100), Unit.PX);
          Label studentTextlbl = new Label(attemptedCount + "/" + totalUserCount + " Students");
          studentTextlbl.setStyleName(res.css().alignCenterAndBackground());
          studentTextlbl.getElement().getStyle().setWidth(100, Unit.PX);
          completionpnl.add(studentTextlbl);
          adTable.setWidget(i, 2, completionpnl);

          // Set time spent
          adTable.setWidget(i, 3, AnalyticsUtil.getTimeStampLabel(result.get(i).getAvgTimeSpent()));

          // Set reactions
          int reaction = result.get(i).getAvgReaction();
          HTMLPanel reactionpnl = new HTMLPanel("");
          reactionpnl.add(new AnalyticsReactionWidget(reaction));
          Label reactioncount = new Label();
          reactionpnl.add(reactioncount);
          reactioncount.setText(reaction + "/5");
          reactioncount.setStyleName(res.css().alignCenterAndBackground());
          adTable.setWidget(i, 4, reactionpnl);

          // set View response label
          Label viewResponselbl = new Label("");
          viewResponselbl.setStyleName(res.css().viewResponseTextOpended());
          adTable.setWidget(i, 5, viewResponselbl);
        }
      }
      adTable.getElement().setId("opendedData");
      printOpendedData.add(adTable);
      if (result.size() == 0) {
        Label erroeMsg = new Label();
        erroeMsg.setStyleName(res.css().displayMessageTextForOEQuestions());
        erroeMsg.setText(i18n.GL3264());
        printOpendedData.add(erroeMsg);
      }
      // To add OE questions
      opendedQuestionHeading.setText(i18n.GL3266());
      opendedQuestionHeading.getElement().getStyle().setPaddingTop(15, Unit.PX);
      opendedQuestionHeading.getElement().getStyle().setPaddingBottom(20, Unit.PX);
      opendedQuestionHeading.getElement().getStyle().setTextAlign(TextAlign.LEFT);
      printWidget.add(opendedQuestionHeading);
      printWidget.add(printOpendedData);
      printOpendedData.getElement().getStyle().setPaddingBottom(20, Unit.PX);
    } catch (Exception e) {
      AppClientFactory.printSevereLogger(
          "CollectionSummaryTeacherView : setOpenendedQuestionsPrintData : " + e.getMessage());
    }
  }