@UiConstructor
  public PreviewResourceView(CollectionItemDo collectionItemDo, int itemIndex) {
    initWidget(uiBinder.createAndBindUi(this));
    resourceThumbContainer.getElement().setId("fpnlResourceThumbContainer");
    resourceImageContainer.getElement().setId("fpnlResourceImageContainer");
    resourceThumbnail.getElement().setId("imgResourceThumbnail");
    resourceTypeImage.getElement().setId("lblResourceTypeImage");
    resourceNumber.getElement().setId("lblResourceNumber");
    resourceTitle.getElement().setId("htmlResourceTitle");
    resourceIndex.getElement().setId("lblResourceIndex");
    resourceHoverTitle.getElement().setId("htmlResourceHoverTitle");
    resourceCategory.getElement().setId("lblResourceCategory");
    resourceSourceName.getElement().setId("lblResourceSourceName");
    ratingWidgetPanel.getElement().setId("fpnlRatingWidgetPanel");
    this.collectionItemDo = collectionItemDo;
    setNavigationResourceTitle(collectionItemDo.getResource().getTitle());
    if (collectionItemDo.getResource().getResourceFormat() != null) {
      setResourceTypeIcon(collectionItemDo.getResource().getResourceFormat().getDisplayName());
    }
    setResourceCategory();
    setReourceSourceName();
    setResourceSequence(itemIndex + 1);
    setResourcePlayLink();

    if (AppClientFactory.getCurrentPlaceToken().equalsIgnoreCase(PlaceTokens.COLLECTION_PLAY)) {
      setAvgRatingWidget();
      AppClientFactory.getEventBus()
          .addHandler(UpdateRatingsInRealTimeEvent.TYPE, setRatingWidgetMetaData);
    }
  }
 public String getResourceLink() {
   String collectionId = AppClientFactory.getPlaceManager().getRequestParameter("id", null);
   if (collectionItemDo.getNarration() != null
       && !collectionItemDo.getNarration().trim().equals("")) {
     String resourceLink =
         "#"
             + AppClientFactory.getCurrentPlaceToken()
             + "&id="
             + collectionId
             + "&rid="
             + collectionItemDo.getCollectionItemId()
             + "&tab=narration";
     resourceLink += PreviewPlayerPresenter.setConceptPlayerParameters();
     return resourceLink;
   } else {
     String resourceLink =
         "#"
             + AppClientFactory.getCurrentPlaceToken()
             + "&id="
             + collectionId
             + "&rid="
             + collectionItemDo.getCollectionItemId();
     resourceLink += PreviewPlayerPresenter.setConceptPlayerParameters();
     return resourceLink;
   }
 }
  public void setResourceCategory() {
    if (collectionItemDo.getResource().getResourceFormat() != null) {
      String resourceType = collectionItemDo.getResource().getResourceFormat().getDisplayName();
      resourceType = resourceType.toLowerCase();

      if (resourceType.equalsIgnoreCase("lesson")
          || resourceType.equalsIgnoreCase("textbook")
          || resourceType.equalsIgnoreCase("handout")) {
        resourceType =
            resourceType
                .replaceAll("lesson", "text")
                .replaceAll("textbook", "text")
                .replaceAll("handout", "text");
      }
      if (resourceType.equalsIgnoreCase("slide")) {
        resourceType = resourceType.replaceAll("slide", "image");
      }
      if (resourceType.equalsIgnoreCase("exam")
          || resourceType.equalsIgnoreCase("website")
          || resourceType.equalsIgnoreCase("challenge")) {
        resourceType =
            resourceType
                .replaceAll("exam", "webpage")
                .replaceAll("website", "webpage")
                .replaceAll("challenge", "webpage");
      }
      resourceCategory.setText(resourceType);
      resourceCategory.getElement().setAttribute("alt", resourceType);
      resourceCategory.getElement().setAttribute("title", resourceType);
    }
  }
 @UiHandler("resourceThumbnail")
 public void onErrorResourceImage(ErrorEvent errorEvent) {
   resourceThumbnail.setUrl("images/resource_trans.png");
   if (collectionItemDo.getResource().getResourceFormat() != null) {
     String resourceType = collectionItemDo.getResource().getResourceFormat().getDisplayName();
     resourceType = resourceType.toLowerCase();
     if (resourceType.equalsIgnoreCase("lesson")
         || resourceType.equalsIgnoreCase("textbook")
         || resourceType.equalsIgnoreCase("handout")) {
       resourceType =
           resourceType
               .replaceAll("lesson", "text")
               .replaceAll("textbook", "text")
               .replaceAll("handout", "text");
     }
     if (resourceType.equalsIgnoreCase("slide")) {
       resourceType = resourceType.replaceAll("slide", "image");
     }
     if (resourceType.equalsIgnoreCase("exam")
         || resourceType.equalsIgnoreCase("website")
         || resourceType.equalsIgnoreCase("challenge")) {
       resourceType =
           resourceType
               .replaceAll("exam", "webpage")
               .replaceAll("website", "webpage")
               .replaceAll("challenge", "webpage");
     }
     resourceThumbnail.setStyleName(getResourceDefaultImage(resourceType));
   }
 }
 @UiHandler("explanaionButton")
 public void ClickOnExplanationButton(ClickEvent clickEvent) {
   if (explanaionButton.getStyleName().equals(oeStyle.hintsActiveButton())) {
     explanationContainer.add(getHTML(collectionItemDo.getResource().getExplanation()));
     explanationContainer.addStyleName(oeStyle.explanationTextBorder());
     explanaionButton.setStyleName(oeStyle.hintsInActiveButton());
     startExplanationDataLogEvent(collectionItemDo.getResource().getExplanation());
   }
 }
 public void setReourceSourceName() {
   if (collectionItemDo.getResource().getResourceSource() != null) {
     if ((!collectionItemDo.getResource().getUrl().startsWith("https://docs.google.com"))
         && (!collectionItemDo.getResource().getUrl().startsWith("http://docs.google.com"))) {
       resourceSourceName.setText(
           collectionItemDo.getResource().getResourceSource().getAttribution() != null
               ? collectionItemDo.getResource().getResourceSource().getAttribution()
               : "");
       resourceSourceName
           .getElement()
           .setAttribute(
               "alt",
               collectionItemDo.getResource().getResourceSource().getAttribution() != null
                   ? collectionItemDo.getResource().getResourceSource().getAttribution()
                   : "");
       resourceSourceName
           .getElement()
           .setAttribute(
               "title",
               collectionItemDo.getResource().getResourceSource().getAttribution() != null
                   ? collectionItemDo.getResource().getResourceSource().getAttribution()
                   : "");
     }
   } else {
     resourceSourceName.setText("");
   }
 }
 @Override
 public void updateRatingInRealTime(String gooruOid, double average, Integer count) {
   if (collectionItemDo != null
       && collectionItemDo.getResource() != null
       && collectionItemDo.getResource().getGooruOid() != null
       && collectionItemDo.getResource().getGooruOid().equals(gooruOid)) {
     collectionItemDo.getResource().getRatings().setCount(count);
     collectionItemDo.getResource().getRatings().setAverage(average);
     setAvgRatingWidget();
   }
 }
 /** Average star ratings widget will get integrated. */
 private void setAvgRatingWidget() {
   ratingWidgetView = new RatingWidgetView();
   if (collectionItemDo.getResource().getRatings() != null) {
     if (collectionItemDo.getResource().getRatings().getCount() != null
         && collectionItemDo.getResource().getRatings().getCount() != 0) {
       ratingWidgetView.getRatingCountOpenBrace().setText(i18n.GL_SPL_OPEN_SMALL_BRACKET());
       ratingWidgetView
           .getRatingCountLabel()
           .setText(collectionItemDo.getResource().getRatings().getCount().toString());
       ratingWidgetView.getRatingCountCloseBrace().setText(i18n.GL_SPL_CLOSE_SMALL_BRACKET());
       ratingWidgetView.setAvgStarRating(collectionItemDo.getResource().getRatings().getAverage());
       ratingWidgetPanel.getElement().setId("fpnlRatingWidgetPanel");
     }
   }
   ratingWidgetPanel.clear();
   ratingWidgetPanel.add(ratingWidgetView);
 }
 @Override
 public void onLoad() {
   if (collectionItemDo
       .getResource()
       .getResourceType()
       .getName()
       .equalsIgnoreCase("assessment-question")) {
     resourceThumbnail.setUrl(getQuestionImage());
   } else if (collectionItemDo
       .getResource()
       .getResourceType()
       .getName()
       .equalsIgnoreCase("video/youtube")) {
     resourceThumbnail.setUrl(
         ResourceImageUtil.youtubeImageLink(
             ResourceImageUtil.getYoutubeVideoId(collectionItemDo.getResource().getUrl()),
             Window.Location.getProtocol()));
   } else {
     resourceThumbnail.setUrl(collectionItemDo.getResource().getThumbnails().getUrl());
   }
 }
 @UiHandler("hintsButton")
 public void ClickOnHintButton(ClickEvent clickEvent) {
   if (hintsButton.getStyleName().equals(oeStyle.hintsActiveButton())) {
     if (collectionItemDo.getResource().getHints().size() > hintsLength) {
       startHintDataLogEvent(getQuestionHintsDo(hintsLength).getHintId());
       hintsContainer.add(
           getHTML(getQuestionHintsDo(hintsLength).getHintText(), oeStyle.hintsText()));
       hintsButton.setText(
           ""
               + i18n.GL0317()
               + " ("
               + ((collectionItemDo.getResource().getHints().size() - hintsLength) - 1)
               + " Left)");
       hintsButton
           .getElement()
           .setAttribute(
               "alt",
               " "
                   + i18n.GL0317()
                   + " ("
                   + collectionItemDo.getResource().getHints().size()
                   + " Left)");
       hintsButton
           .getElement()
           .setAttribute(
               "title",
               " "
                   + i18n.GL0317()
                   + " ("
                   + collectionItemDo.getResource().getHints().size()
                   + " Left)");
       hintsLength++;
       if (collectionItemDo.getResource().getHints().size() == hintsLength) {
         hintsButton.setStyleName(oeStyle.hintsInActiveButton());
       }
     } else {
       hintsButton.setStyleName(oeStyle.hintsInActiveButton());
     }
   }
 }
 public QuestionHintsDo getQuestionHintsDo(int hintPosition) {
   TreeSet<QuestionHintsDo> questionHintsList = collectionItemDo.getResource().getHints();
   Iterator<QuestionHintsDo> it = questionHintsList.iterator();
   int i = 0;
   QuestionHintsDo currentQuestionHintsDo = null;
   while (it.hasNext()) {
     currentQuestionHintsDo = it.next();
     if (i == hintPosition) {
       return currentQuestionHintsDo;
     }
     i++;
   }
   return currentQuestionHintsDo;
 }
 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(e.getMessage());
   }
   return thumbnailImage != null ? thumbnailImage : "images/defaultRes.png";
 }
 private void renderAnswerView(AttemptedAnswersDo attemptedAnswerDo) {
   clearAnswerOptionsContainer();
   if (collectionItemDo != null && collectionItemDo.getResource() != null) {
     if (collectionItemDo.getResource().getType() == 1
         || collectionItemDo.getResource().getType() == 3) {
       multipleChoicesQuestionWidget =
           new MultipleChoicesQuestionWidget(collectionItemDo, attemptedAnswerDo);
       questionContainer.add(multipleChoicesQuestionWidget);
     } else if (collectionItemDo.getResource().getType() == 6) {
       opendEndedQuestionWidget =
           new OpendEndedQuestionWidget(collectionItemDo, attemptedAnswerDo);
       questionContainer.add(opendEndedQuestionWidget);
     } else if (collectionItemDo.getResource().getType() == 4) {
       fillInTheBlankQuestionWidget =
           new FillInTheBlankQuestionWidget(collectionItemDo, attemptedAnswerDo);
       questionContainer.add(fillInTheBlankQuestionWidget);
     } else if (collectionItemDo.getResource().getType() == 7) {
       multipleAnswersQuestionWidget =
           new MultipleAnswersQuestionWidget(collectionItemDo, attemptedAnswerDo);
       questionContainer.add(multipleAnswersQuestionWidget);
     }
   }
 }
示例#14
0
  public void collection(HttpServletRequest request, HttpServletResponse response)
      throws IOException {
    String id = request.getParameter("id");
    StringBuffer htmlOutput = new StringBuffer();
    PrintWriter out = response.getWriter();
    response.setContentType("text/html");
    if (id != null) {
      String protocolRequest = request.getScheme();
      String homeEndPoint = resourceService.getHomeEndPointForEmbed();
      String restEndPoint = resourceService.getRestEndPointForEmbed();
      String cssEndPoint =
          homeEndPoint
              .replaceAll(MessageProperties.HTTP + ":", "")
              .replaceAll(MessageProperties.HTTPS + ":", "");

      if (protocolRequest.equalsIgnoreCase(MessageProperties.HTTPS)) {
        homeEndPoint = homeEndPoint.replaceAll(MessageProperties.HTTP, MessageProperties.HTTPS);
        restEndPoint = restEndPoint.replaceAll(MessageProperties.HTTP, MessageProperties.HTTPS);
      }

      CollectionDo collectionDo = resourceService.getCollectionFromEmbed(id, restEndPoint);
      if (collectionDo != null && collectionDo.getGooruOid() != null) {
        int resourceCount = 0;
        int questoionResourceCount = 0;
        for (CollectionItemDo collectionItemDo : collectionDo.getCollectionItems()) {
          if (collectionItemDo.getResource().getCategory().equalsIgnoreCase("Question")) {
            questoionResourceCount++;
          } else {
            resourceCount++;
          }
        }
        String resourcesString = resourceCount == 1 ? "1 resource," : resourceCount + " resources,";
        String questoionResourceCountString =
            questoionResourceCount == 1 ? "1 question" : questoionResourceCount + " questions";
        String collectionItems = resourcesString + " " + questoionResourceCountString;
        htmlOutput
            .append(" <!DOCTYPE html>")
            .append("<html><head>")
            .append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />")
            .append(
                "<link rel=\"stylesheet\" type=\"text/css\" href=\""
                    + cssEndPoint
                    + "/css/embed.css\">")
            .append("</head>")
            .append(
                "<body><div class=\"embed-container\"><div class=\"collection-image\"><a href=\""
                    + homeEndPoint
                    + "/#collection-play&id="
                    + collectionDo.getGooruOid()
                    + "\"target=\"_blank\" class=\"collectionImage\"><image onerror=\"this.src='"
                    + homeEndPoint
                    + "/images/collection-default-image.png'\" src="
                    + collectionDo.getThumbnails().getUrl()
                    + " width=\"310px\" height=\"208px\"><div class=\"button\">Study</div></a></div>")
            .append("<div class=\"metadata\">")
            .append(
                "<h1 class=\"title\"><a href=\""
                    + homeEndPoint
                    + "/#collection-play&id="
                    + collectionDo.getGooruOid()
                    + "\"target=\"_blank\">"
                    + collectionDo.getTitle()
                    + "</a></h1>")
            .append(
                "<div class=\"description\"><span class=\"label\">Description: </span>"
                    + collectionDo.getGoals()
                    + "</div>")
            .append(
                "<div class=\"resources\">"
                    + collectionItems
                    + "</div></div></div></div> </body></html>");
      }
    }
    out.println(htmlOutput.toString());
  }
  /**
   * @function openResurceLink
   * @created_date : Jan 2, 2014
   * @description To open original resource link in new tab.
   * @parm(s) : @param ClickEvent
   * @return : void
   * @throws : <Mentioned if any exceptions>
   */
  @UiHandler("btnResourceLink")
  public void openResurceLink(ClickEvent event) {
    MixpanelUtil.mixpanelEvent("Player_Click_Linked_Out_Resource");

    Window.open(collectionItemDo.getResource().getUrl(), "_blank", "");
  }
  /** @param collectionItemDo */
  @UiConstructor
  public ResourceFrameBreakerView(final CollectionItemDo collectionItemDo, boolean isGoogleFile) {
    initWidget(uiBinder.createAndBindUi(this));
    PlayerBundle.INSTANCE.getPlayerStyle().ensureInjected();
    this.collectionItemDo = collectionItemDo;
    if (!isGoogleFile) {
      setLabelsAndIds();
      supportTip.setStyleName(PlayerBundle.INSTANCE.getPlayerStyle().supportTip());
      supportTip.setText(i18n.GL1453());
      supportTip.getElement().setId("lblSupportTip");
      supportTip.getElement().setAttribute("alt", i18n.GL1453());
      supportTip.getElement().setAttribute("title", i18n.GL1453());
      btnResourceLink.addStyleName(PlayerBundle.INSTANCE.getPlayerStyle().btnResourceLink());
    } else {
      btnResourceLink.removeFromParent();
    }
    imgFieldTrip.setUrl(collectionItemDo.getResource().getThumbnailUrl());
    if (collectionItemDo.getResource().getResourceFormat() != null) {
      defaultResourceCategory = collectionItemDo.getResource().getResourceFormat().getDisplayName();
    }
    if (defaultResourceCategory != null) {
      if (defaultResourceCategory.equalsIgnoreCase("Lesson")
          || defaultResourceCategory.equalsIgnoreCase("Textbook")
          || defaultResourceCategory.equalsIgnoreCase("Handout")) {
        defaultResourceCategory =
            defaultResourceCategory
                .replaceAll("Lesson", "Text")
                .replaceAll("Textbook", "Text")
                .replaceAll("Handout", "Text")
                .replaceAll("lesson", "Text")
                .replaceAll("textbook", "Text")
                .replaceAll("handout", "Text");
      }
      if (defaultResourceCategory.equalsIgnoreCase("Slide")) {
        defaultResourceCategory =
            defaultResourceCategory.replaceAll("Slide", "Image").replaceAll("slide", "Image");
      }
      if (defaultResourceCategory.equalsIgnoreCase("Exam")
          || defaultResourceCategory.equalsIgnoreCase("Challenge")
          || defaultResourceCategory.equalsIgnoreCase("Website")) {
        defaultResourceCategory =
            defaultResourceCategory
                .replaceAll("Exam", "Webpage")
                .replaceAll("Challenge", "Webpage")
                .replaceAll("exam", "Webpage")
                .replaceAll("challenge", "Webpage");
      }
    }
    imgFieldTrip.addErrorHandler(
        new ErrorHandler() {

          @Override
          public void onError(ErrorEvent event) {
            imgFieldTrip.setUrl(DEFULT_IMAGE_PREFIX + defaultResourceCategory.toLowerCase() + PNG);
          }
        });
    if (collectionItemDo.getResource().getResourceFormat() != null) {
      resourceCategory.addStyleName(
          getResourceTypeImage(
              collectionItemDo.getResource().getResourceFormat().getDisplayName()));
    }
  }
 private void renderQuestionView() {
   hintsLength = 0;
   if (collectionItemDo != null && collectionItemDo.getResource() != null) {
     String titlelbl1 =
         InfoUtil.removeQuestionTagsOnBoldClick(
             StringUtil.isEmpty(collectionItemDo.getResource().getQuestionText())
                 ? ""
                 : collectionItemDo.getResource().getQuestionText());
     openEndedQuestionText.setHTML(removeHtmlTags(titlelbl1));
     openEndedQuestionText
         .getElement()
         .setAttribute(
             "alt",
             StringUtil.removeAllHtmlCss(
                 StringUtil.isEmpty(collectionItemDo.getResource().getQuestionText())
                     ? ""
                     : collectionItemDo.getResource().getQuestionText()));
     openEndedQuestionText
         .getElement()
         .setAttribute(
             "title",
             StringUtil.removeAllHtmlCss(
                 StringUtil.isEmpty(collectionItemDo.getResource().getQuestionText())
                     ? ""
                     : collectionItemDo.getResource().getQuestionText()));
     if (collectionItemDo.getResource().getHints() != null
         && collectionItemDo.getResource().getHints().size() > 0) {
       hintsButton.setText(
           " "
               + i18n.GL0317()
               + " ("
               + collectionItemDo.getResource().getHints().size()
               + " Left)");
       hintsButton
           .getElement()
           .setAttribute(
               "alt",
               " "
                   + i18n.GL0317()
                   + " ("
                   + collectionItemDo.getResource().getHints().size()
                   + " Left)");
       hintsButton
           .getElement()
           .setAttribute(
               "title",
               " "
                   + i18n.GL0317()
                   + " ("
                   + collectionItemDo.getResource().getHints().size()
                   + " Left)");
     } else {
       hintsButton.setStyleName(oeStyle.hintsInActiveButton());
     }
     if (collectionItemDo.getResource().getExplanation() != null
         && collectionItemDo.getResource().getExplanation().trim().length() > 0) {
     } else {
       explanaionButton.setStyleName(oeStyle.hintsInActiveButton());
     }
     if (!StringUtil.isEmpty(getQuestionImage())) {
       openEndedQuestionImage.setUrl(getQuestionImage());
     }
   }
 }