コード例 #1
0
  /**
   * This method is used to set scored questions data.
   *
   * @param scoredQuestionsData
   * @param sortableTable
   * @param isPrint
   */
  void setSortedData(
      ArrayList<UserDataDo> scoredQuestionsData, SortTable sortableTable, boolean isPrint) {
    for (int i = 1; i <= scoredQuestionsData.size(); i++) {
      sortableTable.setValue(i, 0, scoredQuestionsData.get(i - 1).getItemSequence());
      Label questionTitle =
          new Label(
              AnalyticsUtil.html2text(
                  scoredQuestionsData.get(i - 1).getTitle() != null
                      ? scoredQuestionsData.get(i - 1).getTitle()
                      : ""));
      questionTitle.setStyleName(res.css().alignCenterAndBackground());
      questionTitle.addStyleName(res.css().alignLeft());
      sortableTable.setWidget(i, 1, questionTitle);
      VerticalPanel answerBreakDownpnl = new VerticalPanel();
      if (scoredQuestionsData.get(i - 1).getType() != null) {
        String getQuestionType = scoredQuestionsData.get(i - 1).getType();
        if (MC.equalsIgnoreCase(getQuestionType)
            || TF.equalsIgnoreCase(getQuestionType)
            || TSLASHF.equalsIgnoreCase(getQuestionType)) {
          if ((scoredQuestionsData.get(i - 1).getMetaData() != null)
              && (scoredQuestionsData.get(i - 1).getMetaData().size() != 0)) {
            int metaDataSize = scoredQuestionsData.get(i - 1).getMetaData().size();
            int totalcount = scoredQuestionsData.get(i - 1).getAttempts();
            for (int j = 0; j < metaDataSize; j++) {
              MetaDataDo metaData = scoredQuestionsData.get(i - 1).getMetaData().get(j);
              HorizontalPanel datagrap = new HorizontalPanel();
              Label tickmarklbl = new Label();
              tickmarklbl.setStyleName(res.css().tickMarkImgCss());
              datagrap.add(tickmarklbl);
              String questionSequence = AnalyticsUtil.getCharForNumber(metaData.getSequence() - 1);
              int attemptCount = 0;
              Label sequenceCharlbl = new Label(questionSequence + ")");
              sequenceCharlbl.setStyleName(res.css().barGraphCharacter());
              datagrap.add(sequenceCharlbl);
              if (scoredQuestionsData.get(i - 1).getOptions() != null) {
                Map<String, Integer> authorObject = scoredQuestionsData.get(i - 1).getOptions();
                /*JSONValue value = JSONParser.parseStrict(scoredQuestionsData.get(i-1).getOptions().toString());
                JSONObject authorObject = value.isObject();*/
                if (authorObject.keySet().size() != 0
                    && authorObject.get(questionSequence) != null) {
                  attemptCount = (int) authorObject.get(questionSequence).doubleValue();
                }
              }

              Label progressBarlbl = new Label("");
              if (metaData.getIsCorrect() == 1) {
                tickmarklbl.addStyleName(res.css().tickMarkImg());
                progressBarlbl.addStyleName(res.css().assignment_quesiton_ans_bar());
              } else {
                progressBarlbl.addStyleName(res.css().wrongSelectStyle());
              }
              float setWidth = ((float) attemptCount / (float) totalcount) * 100;
              setWidth = (setWidth == 0.0 ? 1 : setWidth);
              progressBarlbl.getElement().getStyle().setWidth(setWidth, Unit.PX);
              datagrap.add(progressBarlbl);

              Label countlbl = new Label("(" + attemptCount + ")");
              datagrap.add(countlbl);
              answerBreakDownpnl.add(datagrap);
            }
          }
        } else if ((OE.equalsIgnoreCase(getQuestionType)
                || FIB.equalsIgnoreCase(getQuestionType)
                || MA.equalsIgnoreCase(getQuestionType))
            && !isPrint) {
          Label viewResponselbl = new Label(i18n.GL2286());
          viewResponselbl.getElement().setAttribute("labelType", "View Response");
          viewResponselbl
              .getElement()
              .setAttribute(
                  "resourceGooruId", scoredQuestionsData.get(i - 1).getResourceGooruOId());
          viewResponselbl
              .getElement()
              .setAttribute("questionType", scoredQuestionsData.get(i - 1).getType());
          viewResponselbl.setStyleName(res.css().viewResponseTextOpended());
          viewResponselbl.addClickHandler(new ClickOnTableCell());
          answerBreakDownpnl.add(viewResponselbl);
        }

        sortableTable.setWidget(i, 3, answerBreakDownpnl);
        sortableTable.setValue(
            i,
            4,
            AnalyticsUtil.getTimeStampLabel(scoredQuestionsData.get(i - 1).getAvgTimeSpent())
                .getText());
        sortableTable.setWidget(
            i, 5, new AnalyticsReactionWidget(scoredQuestionsData.get(i - 1).getAvgReaction()));

        int[] pieChatValues = new int[4];
        pieChatValues[0] = scoredQuestionsData.get(i - 1).getTotalInCorrectCount();
        pieChatValues[1] = scoredQuestionsData.get(i - 1).getTotalCorrectCount();
        pieChatValues[2] = scoredQuestionsData.get(i - 1).getSkip();
        pieChatValues[3] = pieChatValues[0] + pieChatValues[1] + pieChatValues[2];

        // set row style
        if (i % 2 == 0) {
          sortableTable.getRowFormatter().addStyleName(i, res.css().tableRowOdd());
          sortableTable.setWidget(
              i, 2, new HCBarChart().pieChart("#fafafa", pieChatValues, isPrint));
        } else {
          sortableTable.getRowFormatter().addStyleName(i, res.css().tableRowEven());
          sortableTable.setWidget(i, 2, new HCBarChart().pieChart("#fff", pieChatValues, isPrint));
        }
      }
    }
  }
コード例 #2
0
  /* (non-Javadoc)
   * @see org.ednovo.gooru.client.mvp.analytics.collectionSummaryTeacher.IsCollectionSummaryTeacherView#setTeacherResourceData(java.util.ArrayList, org.ednovo.gooru.shared.model.analytics.CollectionSummaryMetaDataDo, com.google.gwt.user.client.ui.HTMLPanel)
   */
  @Override
  public void setTeacherResourceData(
      ArrayList<UserDataDo> resourcesData,
      CollectionSummaryMetaDataDo collectionMetaData,
      HTMLPanel loadingImage) {
    this.collectionMetaData = collectionMetaData;

    teacherTabContainer.clearStyles();
    teacherTabContainer.setScoredQuestionsHilight();
    hideAllPanels();
    teacherResourceBreakdownDatapnl.setVisible(true);

    teacherScoredData.clear();
    teacherOpenendedData.clear();
    teacherResourceBreakdownData.clear();
    questionsData.clear();
    openendedData.clear();

    collectionProgressCount = 0;
    questionRowIndex.clear();
    resourceRowIndex.clear();
    // Set collection meta data
    if (collectionMetaData != null) {
      collectionOverViewWidget.setData(collectionMetaData, true);
      collectionSummaryWidget.setDataAnalyticsData(collectionMetaData, null);
      printWidget.add(collectionSummaryWidget);
      printWidget.add(collectionOverViewWidget);
      totalTimeSpentlbl.setText(getTimeSpent(collectionMetaData.getAvgTimeSpent()));
      totalViewlbl.setText(Integer.toString(collectionMetaData.getViews()));
      totalAvgReactionlbl.clear();
      totalAvgReactionlbl.add(new AnalyticsReactionWidget(collectionMetaData.getAvgReaction()));
    }
    Collections.sort(
        resourcesData,
        new Comparator<UserDataDo>() {
          public int compare(UserDataDo o1, UserDataDo o2) {
            Integer obj1 = new Integer(o1.getItemSequence());
            Integer obj2 = new Integer(o2.getItemSequence());
            return obj1.compareTo(obj2);
          }
        });
    // This is used for segrate data based on the category
    for (UserDataDo userDataDo : resourcesData) {
      if (QUESTION.equalsIgnoreCase(userDataDo.getResourceFormat())) {
        if (OE.equalsIgnoreCase(userDataDo.getType())) {
          openendedData.add(userDataDo);
        } else {
          questionsData.add(userDataDo);
        }
        questionRowIndex.add(collectionProgressCount);
      } else {
        resourceData.add(userDataDo);
        resourceRowIndex.add(collectionProgressCount);
      }
      collectionProgressCount++;
    }
    this.allData = resourcesData;
    setScoredQuestionsData(questionsData);
    setQuestionsPrintData(questionsData);
    setOpenendedQuestionsData(openendedData);
    setOpenendedQuestionsPrintData(openendedData);
    setCollectionBreakDown(resourcesData, loadingImage);
    setCollectionBreakDownPrintData(resourcesData);
  }