Example usage for com.google.gwt.user.client.ui Label setText

List of usage examples for com.google.gwt.user.client.ui Label setText

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Label setText.

Prototype

public void setText(String text) 

Source Link

Document

Sets the label's content to the given text.

Usage

From source file:org.ednovo.gooru.client.mvp.analytics.collectionSummaryTeacher.CollectionSummaryTeacherView.java

License:Open Source License

/**
 * This method is used to print collection breakdown data
 * @param result// w  w w .java2 s  .com
 */
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 DataTable data = DataTable.create();
        data.addColumn(ColumnType.NUMBER, i18n.GL3259());
        data.addColumn(ColumnType.STRING, i18n.GL3267());
        data.addColumn(ColumnType.STRING, i18n.GL3182());
        data.addColumn(ColumnType.STRING, i18n.GL3268());
        data.addColumn(ColumnType.STRING, i18n.GL0934());
        data.addColumn(ColumnType.STRING, i18n.GL3261());
        int rowCount = 0, rowVal = 0;
        for (int i = 0; i < result.size(); i++) {
            rowCount = rowCount + 1;
        }
        data.addRows(rowCount);

        for (int i = 0; i < result.size(); i++) {
            data.setCell(rowVal, 0, result.get(i).getItemSequence(), null, getPropertiesCell());
            //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());
            data.setValue(rowVal, 1, categorylbl.toString());

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

            //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);
            data.setValue(rowVal, 3, timeSpentpnl.toString());

            //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);*/
            data.setValue(rowVal, 4, viewlbl.toString());

            //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());
            data.setValue(rowVal, 5, reactionpnl.toString());
            rowVal++;
        }
        final Options options = Options.create();
        options.setAllowHtml(true);
        Table table = new Table(data, options);
        printResourceData.add(table);
        printWidget.add(printResourceData);
    } catch (Exception e) {
        AppClientFactory.printSevereLogger(
                "CollectionSummaryTeacherView : setCollectionBreakDownPrintData : " + e.getMessage());
    }
}

From source file:org.ednovo.gooru.client.mvp.analytics.collectionSummaryTeacher.CollectionSummaryTeacherView.java

License:Open Source License

/**
 * This method is used to display collection break down data.
 * @param result//  w  ww . j  a v a 2 s .c o  m
 * @param loadingImage
 */
void setCollectionBreakDown(ArrayList<UserDataDo> result, HTMLPanel loadingImage) {

    final int[] primitivesQuestions = AnalyticsUtil.toIntArray(questionRowIndex);
    final int[] primitivesResources = AnalyticsUtil.toIntArray(resourceRowIndex);

    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 DataTable data = DataTable.create();
    data.addColumn(ColumnType.NUMBER, i18n.GL3259());
    data.addColumn(ColumnType.STRING, i18n.GL3267());
    data.addColumn(ColumnType.STRING, i18n.GL3182());
    data.addColumn(ColumnType.STRING, i18n.GL3268());
    data.addColumn(ColumnType.STRING, i18n.GL0934());
    data.addColumn(ColumnType.STRING, i18n.GL3261());
    int rowCount = 0, rowVal = 0;
    for (int i = 0; i < result.size(); i++) {
        rowCount = rowCount + 1;
    }
    data.addRows(rowCount);
    for (int i = 0; i < result.size(); i++) {
        data.setCell(rowVal, 0, result.get(i).getItemSequence(), null, getPropertiesCell());
        //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());
        data.setValue(rowVal, 1, categorylbl.toString());

        //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());
        data.setValue(rowVal, 2, questionTitle.toString());

        //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);
        data.setValue(rowVal, 3, timeSpentpnl.toString());

        //set Views label
        Label viewlbl = new Label(Integer.toString(result.get(i).getViews()));
        viewlbl.setStyleName(res.css().alignCenterAndBackground());

        data.setValue(rowVal, 4, viewlbl.toString());

        //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());
        data.setValue(rowVal, 5, reactionpnl.toString());
        rowVal++;
    }
    final Options options = Options.create();
    options.setAllowHtml(true);
    Table table = new Table(data, options);
    table.getElement().setId("collectionBreakDown");
    teacherResourceBreakdownData.add(table);
    table.getElement().getFirstChildElement().getFirstChildElement().getFirstChildElement().getStyle()
            .setProperty("width", "98% !important");
    filterDropDown.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            teacherResourceBreakdownData.clear();
            int selectedIndex = filterDropDown.getSelectedIndex();
            operationsView = DataView.create(data);
            Table table = new Table(operationsView, options);
            table.setStyleName("collectionProgressTable");
            table.getElement().setId("collectionBreakDown");
            if (selectedIndex == 1) {
                operationsView.hideRows(primitivesResources);
                teacherResourceBreakdownData.add(table);
                if (primitivesQuestions.length == 0) {
                    Label erroeMsg = new Label();
                    erroeMsg.setStyleName(res.css().displayMessageTextForOEQuestions());
                    erroeMsg.setText(i18n.GL3274());
                    teacherResourceBreakdownData.add(erroeMsg);
                }
            } else if (selectedIndex == 2) {
                operationsView.hideRows(primitivesQuestions);
                teacherResourceBreakdownData.add(table);
                if (primitivesResources.length == 0) {
                    Label erroeMsg = new Label();
                    erroeMsg.setStyleName(res.css().displayMessageTextForOEQuestions());
                    erroeMsg.setText(i18n.GL3275());
                    teacherResourceBreakdownData.add(erroeMsg);
                }
            } else {
                teacherResourceBreakdownData.add(table);
            }
            table.addDomHandler(new ClickOnTableCell(), ClickEvent.getType());
        }
    });
    loadingImage.setVisible(false);

}

From source file:org.ednovo.gooru.client.mvp.analytics.collectionSummaryTeacher.CollectionSummaryTeacherView.java

License:Open Source License

/**
 * This method is used to print scored questions data
 * @param scoredQuestionsData/*  ww w .  ja va 2  s  . c  o m*/
 */
void setQuestionsPrintData(ArrayList<UserDataDo> scoredQuestionsData) {
    scoredPrintWidget.clear();
    final SortTable sortableTable = new SortTable();
    sortableTable.setStyleName(res.css().tableMain());
    sortableTable.getElement().setId("results");
    sortableTable.setBorderWidth(1);
    sortableTable.setCellPadding(4);
    sortableTable.setCellSpacing(1);
    sortableTable.addColumnHeader(i18n.GL3259(), 0);
    sortableTable.addColumnHeader(i18n.GL0308(), 1);
    sortableTable.addColumnHeader(i18n.GL2229(), 2);
    sortableTable.addColumnHeader(i18n.GL3269(), 3);
    sortableTable.addColumnHeader(i18n.GL2084(), 4);
    sortableTable.addColumnHeader(i18n.GL3261(), 5);
    sortableTable.getRowFormatter().addStyleName(0, res.css().tableHeader());
    //To add scored questions
    scoredQuestionHeading.setText(i18n.GL2282());
    scoredQuestionHeading.getElement().getStyle().setClear(Clear.BOTH);
    scoredQuestionHeading.getElement().getStyle().setPaddingTop(15, Unit.PX);
    scoredQuestionHeading.getElement().getStyle().setPaddingBottom(20, Unit.PX);
    scoredQuestionHeading.getElement().getStyle().setTextAlign(TextAlign.LEFT);
    printWidget.add(scoredQuestionHeading);
    scoredPrintWidget.add(sortableTable);
    scoredPrintWidget.getElement().getStyle().setPaddingTop(15, Unit.PX);
    if (scoredQuestionsData.size() != 0) {
        setSortedData(scoredQuestionsData, sortableTable, true);
    } else {
        Label erroeMsg = new Label();
        erroeMsg.setStyleName(res.css().displayMessageTextForScoredQuestions());
        erroeMsg.setText(i18n.GL3265());
        scoredPrintWidget.add(erroeMsg);
    }
    scoredPrintWidget.setVisible(false);
}

From source file:org.ednovo.gooru.client.mvp.analytics.collectionSummaryTeacher.CollectionSummaryTeacherView.java

License:Open Source License

/**
 * This method is used to display scored data
 * @param scoredQuestionsData/*from   w w  w  .ja  v a  2s  . c om*/
 */
void setScoredQuestionsData(ArrayList<UserDataDo> scoredQuestionsData) {
    teacherScoredData.clear();
    final SortTable sortableTable = new SortTable();
    sortableTable.setStyleName(res.css().tableMain());
    sortableTable.getElement().setId("results");
    sortableTable.setBorderWidth(1);
    sortableTable.setCellPadding(4);
    sortableTable.setCellSpacing(1);
    sortableTable.setWidth("800");
    sortableTable.addColumnHeader(i18n.GL3259(), 0);
    sortableTable.addColumnHeader(i18n.GL0308(), 1);
    sortableTable.addColumnHeader(i18n.GL3276(), 2);
    sortableTable.addColumnHeader(i18n.GL3277(), 3);
    sortableTable.addColumnHeader(i18n.GL2084(), 4);
    sortableTable.addColumnHeader(i18n.GL3261(), 5);
    sortableTable.getRowFormatter().addStyleName(0, res.css().tableHeader());
    teacherScoredData.add(sortableTable);
    if (scoredQuestionsData.size() != 0) {
        setSortedData(scoredQuestionsData, sortableTable, false);
    } else {
        Label erroeMsg = new Label();
        erroeMsg.setStyleName(res.css().displayMessageTextForScoredQuestions());
        erroeMsg.setText(i18n.GL3265());
        teacherScoredData.add(erroeMsg);
    }
}

From source file:org.ednovo.gooru.client.mvp.analytics.util.ViewResponseUserWidget.java

License:Open Source License

/**
 * This method is used to set the data./*from   w w  w .  j  a  va2 s . c  o m*/
 * @param oetextDataDO
 * @param resourceGooruId
 * @param collectionId
 * @param classpageId
 * @param pathwayId
 * @param questionType
 * @param isSummary
 */
void setData(final OetextDataDO oetextDataDO, final String resourceGooruId, final String collectionId,
        final String classpageId, final String pathwayId, String questionType, boolean isSummary,
        final String session, ClasspageItemDo classpageItemDo) {
    this.oetextDataDO = oetextDataDO;
    giveFeedBackpnl.setVisible(false);
    editFeedBackpnl.setVisible(false);
    userAnswerspnl.setVisible(false);
    userResponselbl.setVisible(false);
    if (isSummary) {
        spnEdit.setVisible(true);
        spnDelete.setVisible(true);
    } else {
        spnEdit.setVisible(false);
        spnDelete.setVisible(false);
    }
    if (classpageItemDo != null && classpageItemDo.getUserNameDispaly() != null) {
        teacherName.setText(
                classpageItemDo.getUserNameDispaly() + i18n.GL_GRR_ALPHABET_APOSTROPHE() + " " + i18n.GL0195());
        if (classpageItemDo.getProfileImageUrl() != null) {
            userProfileImage.setUrl(classpageItemDo.getProfileImageUrl());
            userProfileImage1.setUrl(classpageItemDo.getProfileImageUrl());
        } else {
            userProfileImage.setUrl("../images/settings/setting-user-image.png");
            userProfileImage1.setUrl("../images/settings/setting-user-image.png");
        }
    } else {
        teacherName.setText(AppClientFactory.getLoggedInUser().getUsernameDisplay()
                + i18n.GL_GRR_ALPHABET_APOSTROPHE() + " " + i18n.GL0195());
        if (AppClientFactory.getLoggedInUser().getProfileImageUrl() != null) {
            userProfileImage.setUrl(AppClientFactory.getLoggedInUser().getProfileImageUrl());
            userProfileImage1.setUrl(AppClientFactory.getLoggedInUser().getProfileImageUrl());
        } else {
            userProfileImage.setUrl("../images/settings/setting-user-image.png");
            userProfileImage1.setUrl("../images/settings/setting-user-image.png");
        }
    }

    userProfileImage.addErrorHandler(new OnErrorProfileImage());
    userProfileImage1.addErrorHandler(new OnErrorProfileImage());

    usernamelbl.setText(oetextDataDO.getUserName());
    String oeText = oetextDataDO.getOEText();
    if (questionType.equalsIgnoreCase("MA") || questionType.equalsIgnoreCase("FIB")) {
        userAnswerspnl.setVisible(true);
        if (oetextDataDO.getAnswerObject() != null) {
            JSONValue value = JSONParser.parseStrict(oetextDataDO.getAnswerObject());
            JSONObject answerObject = value.isObject();
            Set<String> keys = answerObject.keySet();
            Iterator<String> itr = keys.iterator();
            while (itr.hasNext()) {
                userAnswerspnl.clear();
                JSONArray attemptsObj = (JSONArray) answerObject.get(itr.next().toString());
                for (int j = 0; j < attemptsObj.size(); j++) {
                    Label answerChoice = new Label();
                    boolean skip = attemptsObj.get(j).isObject().get("skip").isBoolean().booleanValue();
                    String status = attemptsObj.get(j).isObject().get("status").isString().stringValue();
                    String matext = attemptsObj.get(j).isObject().get("text").isString().stringValue();
                    String colorCode = "", text = "";
                    if (status.equalsIgnoreCase("1")) {
                        colorCode = "#4E9746";
                    } else {
                        colorCode = "#FF0000";
                    }
                    if (questionType.equalsIgnoreCase("MA")) {
                        if (matext.equalsIgnoreCase("1")) {
                            text = "Yes";
                        } else {
                            text = "No";
                        }
                    } else if (questionType.equalsIgnoreCase("FIB")) {
                        text = text + " " + matext;
                    }
                    if (skip == false) {
                        answerChoice.setText(text + ",");
                        answerChoice.getElement().getStyle().setColor(colorCode);
                        answerChoice.getElement().getStyle().setFloat(Float.LEFT);
                        answerChoice.getElement().getStyle().setPaddingRight(1, Unit.PX);
                        answerChoice.getElement().getStyle().setFontWeight(FontWeight.BOLD);
                        answerChoice.getElement().getStyle().setFontSize(14, Unit.PX);
                        userAnswerspnl.add(answerChoice);
                    } else {
                        answerChoice.setText(i18n.GL3115());
                        userAnswerspnl.add(answerChoice);
                        break;
                    }
                }
            }
        } else {
            Label answerChoice = new Label();
            answerChoice.setText(i18n.GL3115());
            userAnswerspnl.add(answerChoice);
        }
    } else {
        userResponselbl.setVisible(true);
        String feedBackStatus = oetextDataDO.getFeedbackStatus();
        if (oeText == null || oeText.trim().isEmpty()) {
            userResponselbl.setText(i18n.GL3116());
        } else {
            userResponselbl.setText(oetextDataDO.getOEText());
        }
        if ((isSummary && feedBackStatus != null && feedBackStatus.equalsIgnoreCase("false"))
                && (oeText != null && !oeText.trim().isEmpty())) {
            giveFeedBackpnl.setVisible(true);
        }
        if ((feedBackStatus != null && feedBackStatus.equalsIgnoreCase("true"))
                && (oeText != null && !oeText.trim().isEmpty())) {
            editFeedBackpnl.setVisible(true);
            editedText.setText(oetextDataDO.getFeedbackText());
            feedBacktxt.setText(oetextDataDO.getFeedbackText());
            createOn.setText(AnalyticsUtil.getCreatedTime(Long.toString(oetextDataDO.getFeedbackTimestamp())));
        }
        final String classCode = Document.get().getElementById("txtClassCode") != null
                ? Document.get().getElementById("txtClassCode").getInnerText()
                : "";
        btnSubmit.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                AppClientFactory.getInjector().getAnalyticsService().postTeacherFeedBackToStudent(
                        feedBacktxt.getText(), resourceGooruId, collectionId, classpageId, pathwayId,
                        oetextDataDO.getGooruUId(), session, "", "", classCode,
                        AppClientFactory.getLoggedInUser().getGooruUId(),
                        new AsyncCallback<FeedBackResponseDataDO>() {
                            @Override
                            public void onSuccess(FeedBackResponseDataDO result) {
                                if (result != null) {
                                    giveFeedBackpnl.setVisible(false);
                                    editFeedBackpnl.setVisible(true);
                                    editedText.setText(result.getFreeText());
                                    feedBacktxt.setText(result.getFreeText());
                                    createOn.setText(
                                            AnalyticsUtil.getCreatedTime(Long.toString(result.getCreatedOn())));
                                }
                            }

                            @Override
                            public void onFailure(Throwable caught) {
                            }
                        });
            }
        });
        spnDelete.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                AppClientFactory.getInjector().getAnalyticsService().postTeacherFeedBackToStudent("",
                        resourceGooruId, collectionId, classpageId, pathwayId, oetextDataDO.getGooruUId(),
                        session, "commentsDelete", "", classCode,
                        AppClientFactory.getLoggedInUser().getGooruUId(),
                        new AsyncCallback<FeedBackResponseDataDO>() {
                            @Override
                            public void onSuccess(FeedBackResponseDataDO result) {
                                if (result != null) {
                                    giveFeedBackpnl.setVisible(true);
                                    editFeedBackpnl.setVisible(false);
                                    editedText.setText(result.getFreeText());
                                    feedBacktxt.setText(result.getFreeText());
                                    createOn.setText(
                                            AnalyticsUtil.getCreatedTime(Long.toString(result.getCreatedOn())));
                                }
                            }

                            @Override
                            public void onFailure(Throwable caught) {
                            }
                        });
            }
        });
        spnEdit.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                giveFeedBackpnl.setVisible(true);
                editFeedBackpnl.setVisible(false);
            }
        });
    }
}

From source file:org.ednovo.gooru.client.mvp.assessments.play.collection.end.AssessmentsEndView.java

License:Open Source License

@Override
public void setQuestionsData(final ArrayList<UserDataDo> result) {

    loadingImageLabel.setVisible(false);
    questionsTable.setVisible(true);//from w w w. j a  va  2s .  c  o m
    questionsTable.clear();
    if (isTableToDestroy) {
        isTableToDestroy = false;
        destoryTables();
    }

    if (result.size() > 0) {
        final AdvancedFlexTable adTable = new AdvancedFlexTable();
        adTable.removeAllRows();
        adTable.getElement().setId("report-student-assessment-report");
        adTable.addStyleName("table table-bordered reportTableStyle");
        questionsTable.add(adTable);

        Label heading1 = new Label(i18n.GL3259());
        Label heading2 = new Label(i18n.GL0308());
        Label heading3 = new Label(i18n.GL0315());
        Label heading4 = new Label(i18n.GL2288());
        Label heading5 = new Label(i18n.GL2084());
        Label heading6 = new Label(i18n.GL3271());

        heading1.addStyleName("headingLabel");
        heading2.addStyleName("headingLabel");
        heading3.addStyleName("headingLabel");
        heading4.addStyleName("headingLabel");
        heading5.addStyleName("headingLabel");
        heading6.addStyleName("headingLabel");

        adTable.setHeaderWidget(0, heading1);
        adTable.setHeaderWidget(1, heading2);
        adTable.setHeaderWidget(2, heading3);
        adTable.setHeaderWidget(3, heading4);
        adTable.setHeaderWidget(4, heading5);
        adTable.setHeaderWidget(5, heading6);
        for (int i = 0; i < result.size(); i++) {
            Label questionTitle = new Label(
                    AnalyticsUtil.html2text(result.get(i).getTitle() != null ? result.get(i).getTitle() : ""));
            questionTitle.setStyleName(STYLE_TABLE_CENTER);
            questionTitle.setStyleName(STYLE_TXTLEFT);
            adTable.setWidget(i, 0, new Label(String.valueOf(i + 1)));
            adTable.setWidget(i, 1, questionTitle);

            int noOfAttempts = result.get(i).getAttempts();
            String scoreStatus = result.get(i).getStatus();

            //Set Answer choices
            String questionType = result.get(i).getType();
            if (questionType.equalsIgnoreCase("HS")) {
                questionType = result.get(i).getQuestionType();
            }
            if (MC.equalsIgnoreCase(questionType) || TF.equalsIgnoreCase(questionType)
                    || TSLASHF.equalsIgnoreCase(questionType)) {
                Label anserlbl = new Label();
                if (result.get(i).getMetaData() != null && result.get(i).getOptions() != null) {
                    Map<String, Integer> authorObject = result.get(i).getOptions();

                    for (Map.Entry<String, Integer> entry : authorObject.entrySet()) {
                        String userSelectedOption = entry.getKey();
                        // int ansStatus=entry.getValue();
                        if (userSelectedOption != null) {
                            anserlbl.setText(userSelectedOption);
                            if (STATUS_CORRECT.equalsIgnoreCase(scoreStatus) && noOfAttempts == 1) {
                                anserlbl.getElement().getStyle().setColor(CORRECT);
                            } else if (STATUS_CORRECT.equalsIgnoreCase(scoreStatus) && noOfAttempts > 1) {
                                anserlbl.getElement().getStyle().setColor(ONMULTIPULEATTEMPTS);
                            } else {
                                anserlbl.getElement().getStyle().setColor(INCORRECT);
                            }
                        }
                    }
                }
                anserlbl.setStyleName(STYLE_TABLE_CENTER);
                adTable.setWidget(i, 2, anserlbl);
            } else if (FIB.equalsIgnoreCase(questionType)) {
                VerticalPanel answerspnl = new VerticalPanel();
                if (result.get(i).getMetaData() != null && result.get(i).getOptions() != null) {
                    String answerTextFormat = "";
                    String[] answersArry = null;
                    ArrayList<MetaDataDo> questionList = result.get(i).getMetaData();

                    for (MetaDataDo metaDataDo : questionList) {

                        String answerText = "";
                        if ((metaDataDo.getAnswerText() != null)) {
                            String text = StringUtil.removeAllHtmlCss(removeHtmlTags(
                                    InfoUtil.removeQuestionTagsOnBoldClick(metaDataDo.getAnswerText())));
                            answerText = text;
                        }
                        answerTextFormat += '[' + answerText + ']';
                        if (questionList.size() != metaDataDo.getSequence()) {
                            answerTextFormat += ",";
                        }
                    }
                    String[] userFibOption = null;
                    if (result.get(i).getText() != null) {
                        answersArry = answerTextFormat.split(",");
                        userFibOption = result.get(i).getText().split(",");
                    }
                    if (answersArry != null && userFibOption != null) {
                        for (int k = 0; k < answersArry.length; k++) {
                            Label answerChoice = new Label();
                            if (answersArry[k] != null && k < userFibOption.length) {
                                if ((answersArry[k].toLowerCase().trim()
                                        .equalsIgnoreCase(userFibOption[k].toLowerCase().trim()))
                                        && (noOfAttempts == 1)) {
                                    answerChoice.setText(userFibOption[k]);
                                    answerChoice.getElement().getStyle().setColor(CORRECT);
                                } else if ((answersArry[k].toLowerCase().trim()
                                        .equalsIgnoreCase(userFibOption[k].toLowerCase().trim()))
                                        && (noOfAttempts > 1)) {
                                    answerChoice.setText(userFibOption[k]);
                                    answerChoice.getElement().getStyle().setColor(ONMULTIPULEATTEMPTS);
                                } else {
                                    answerChoice.setText(userFibOption[k]);
                                    answerChoice.getElement().getStyle().setColor(INCORRECT);
                                }
                                answerChoice.setStyleName(STYLE_TABLE_CENTER);
                                answerspnl.add(answerChoice);
                            }
                        }
                    }
                }
                answerspnl.setStyleName(STYLE_MARGIN_AUTO);
                adTable.setWidget(i, 2, answerspnl);
                //data.setValue(i, 2, answerspnl.toString());
            } else if (MA.equalsIgnoreCase(questionType)) {
                VerticalPanel answerspnl = new VerticalPanel();
                if (result.get(i).getAnswerObject() != null) {
                    JSONValue value = JSONParser.parseStrict(result.get(i).getAnswerObject());
                    JSONObject answerObject = value.isObject();
                    Set<String> keys = answerObject.keySet();
                    Iterator<String> itr = keys.iterator();
                    while (itr.hasNext()) {
                        answerspnl.clear();
                        JSONArray attemptsObj = (JSONArray) answerObject.get(itr.next().toString());
                        for (int j = 0; j < attemptsObj.size(); j++) {
                            Label answerChoice = new Label();
                            String showMessage = null;
                            boolean skip = attemptsObj.get(j).isObject().get("skip").isBoolean().booleanValue();
                            String status = attemptsObj.get(j).isObject().get("status").isString()
                                    .stringValue();
                            String matext = attemptsObj.get(j).isObject().get("text").isString().stringValue();
                            if (skip == false) {
                                if (ZERO_NUMERIC.equalsIgnoreCase(matext)) {
                                    showMessage = i18n.GL_GRR_NO();
                                } else if (ONE.equalsIgnoreCase(matext)) {
                                    showMessage = i18n.GL_GRR_YES();
                                }
                                answerChoice.setText(showMessage);
                                if (ZERO_NUMERIC.equalsIgnoreCase(status)) {
                                    answerChoice.getElement().getStyle().setColor(INCORRECT);
                                } else if (ONE.equalsIgnoreCase(status) && (noOfAttempts == 1)) {
                                    answerChoice.getElement().getStyle().setColor(CORRECT);
                                } else if (ONE.equalsIgnoreCase(status) && (noOfAttempts > 1)) {
                                    answerChoice.getElement().getStyle().setColor(ONMULTIPULEATTEMPTS);
                                }
                            }
                            answerChoice.setStyleName(STYLE_TABLE_CENTER);
                            answerspnl.add(answerChoice);
                        }
                    }
                }
                answerspnl.setStyleName(STYLE_MARGIN_AUTO);
                adTable.setWidget(i, 2, answerspnl);
            } else if (HT_RO.equalsIgnoreCase(questionType) || HT_HL.equalsIgnoreCase(questionType)
                    || HS_TXT.equalsIgnoreCase(questionType) || HS_IMG.equalsIgnoreCase(questionType)) {
                if (result.get(i).getAnswerObject() != null
                        && !result.get(i).getStatus().equalsIgnoreCase("skipped")) {
                    Label viewResponselbl = new Label(VIEWRESPONSE);
                    viewResponselbl.setStyleName("summaryViewResponse");
                    viewResponselbl.getElement().setAttribute("resourceGooruId",
                            result.get(i).getResourceGooruOId());
                    viewResponselbl.getElement().setAttribute("questionType", result.get(i).getType());
                    viewResponselbl.getElement().setAttribute("answerObj", result.get(i).getAnswerObject());
                    viewResponselbl.getElement().setAttribute("attempts", String.valueOf(noOfAttempts));
                    viewResponselbl.addClickHandler(new SummaryPopupClick(result.get(i)));
                    adTable.setWidget(i, 2, viewResponselbl);
                }
            }

            //Set attempts
            Label attempts = new Label(i18n.GL2269());
            attempts.setStyleName(STYLE_TABLE_CENTER);
            attempts.getElement().getStyle().setColor(ONMULTIPULEATTEMPTS);

            if (STATUS_INCORRECT.equalsIgnoreCase(scoreStatus)) {
                adTable.setWidget(i, 3, attempts);
                adTable.getRowFormatter().addStyleName(i, STYLE_WHITE);
            } else if (STATUS_CORRECT.equalsIgnoreCase(scoreStatus)) {
                Image correctImg = new Image();
                correctImg.setUrl(urlDomain + "/images/analytics/tick.png");
                adTable.setWidget(i, 3, correctImg);
                adTable.getRowFormatter().addStyleName(i, STYLE_GREEN);
            }

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

            //Set reactions
            int reaction = result.get(i).getReaction();
            adTable.setWidget(i, 5, new AnalyticsReactionWidget(reaction));
        }
        //         sortAndFixed();

    } else {
        Label erroeMsg = new Label();
        erroeMsg.setStyleName(STYLE_ERROR_MSG);
        erroeMsg.setText(i18n.GL3265());
        questionsTable.add(erroeMsg);
    }

}

From source file:org.ednovo.gooru.client.mvp.assessments.play.collection.end.AssessmentsEndView.java

License:Open Source License

@Override
public void setQuestionsPrintData(final ArrayList<UserDataDo> result) {
    loadingImageLabel.setVisible(false);
    try {//from   w  ww.j  a  v  a 2s  .  c o  m
        printScoredData.clear();
        boolean isTickdisplay = false;
        DataTable data = DataTable.create();
        data.addColumn(ColumnType.NUMBER, i18n.GL3259());
        data.addColumn(ColumnType.STRING, i18n.GL0308());
        data.addColumn(ColumnType.STRING, i18n.GL2288());
        data.addColumn(ColumnType.STRING, i18n.GL3269());
        //         data.addColumn(ColumnType.STRING, i18n.GL3270());
        data.addColumn(ColumnType.STRING, i18n.GL2084());
        data.addColumn(ColumnType.STRING, i18n.GL3271());

        data.addRows(result.size());
        if (result.size() != 0) {
            for (int i = 0; i < result.size(); i++) {
                isTickdisplay = false;
                data.setCell(i, 0, result.get(i).getSequence(), null, getPropertiesCell());

                Label questionTitle = new Label(AnalyticsUtil
                        .html2text(result.get(i).getTitle() != null ? result.get(i).getTitle() : ""));
                questionTitle.setStyleName(STYLE_TABLE_CENTER);
                questionTitle.setStyleName(STYLE_TXTLEFT);
                data.setValue(i, 1, questionTitle.toString());
                int noOfAttempts = result.get(i).getAttempts();
                String scoreStatus = result.get(i).getStatus();

                //Set Answer choices
                String questionType = result.get(i).getType();
                if (questionType.equalsIgnoreCase("HS")) {
                    questionType = result.get(i).getQuestionType();
                }
                if (questionType.equalsIgnoreCase(MC) || questionType.equalsIgnoreCase(TF)
                        || questionType.equalsIgnoreCase(TSLASHF)) {
                    Label anserlbl = new Label();
                    if (result.get(i).getMetaData() != null && result.get(i).getOptions() != null) {
                        Map<String, Integer> authorObject = result.get(i).getOptions();
                        for (Map.Entry<String, Integer> entry : authorObject.entrySet()) {
                            String userSelectedOption = entry.getKey();

                            if (userSelectedOption != null) {
                                anserlbl.setText(userSelectedOption);
                                if (STATUS_CORRECT.equalsIgnoreCase(scoreStatus) && noOfAttempts == 1) {
                                    anserlbl.getElement().getStyle().setColor(CORRECT);
                                    isTickdisplay = true;
                                } else if (STATUS_CORRECT.equalsIgnoreCase(scoreStatus) && noOfAttempts > 1) {
                                    anserlbl.getElement().getStyle().setColor(ONMULTIPULEATTEMPTS);
                                } else {
                                    anserlbl.getElement().getStyle().setColor(INCORRECT);
                                }
                            }
                        }
                    }
                    anserlbl.setStyleName(STYLE_TABLE_CENTER);
                    data.setValue(i, 3, anserlbl.toString());
                } else if (FIB.equalsIgnoreCase(questionType)) {
                    VerticalPanel answerspnl = new VerticalPanel();
                    if (result.get(i).getMetaData() != null && result.get(i).getOptions() != null) {
                        String answerTextFormat = "";
                        String[] answersArry = null;
                        ArrayList<MetaDataDo> questionList = result.get(i).getMetaData();
                        for (MetaDataDo metaDataDo : questionList) {
                            String answerText = "";
                            if ((metaDataDo.getAnswerText() != null)) {
                                String text = StringUtil.removeAllHtmlCss(removeHtmlTags(
                                        InfoUtil.removeQuestionTagsOnBoldClick(metaDataDo.getAnswerText())));
                                answerText = text;
                            }
                            answerTextFormat += '[' + answerText + ']';
                            if (questionList.size() != metaDataDo.getSequence()) {
                                answerTextFormat += ",";
                            }
                        }
                        String[] userFibOption = null;
                        if (result.get(i).getText() != null) {
                            answersArry = answerTextFormat.split(",");
                            userFibOption = result.get(i).getText().split(",");
                        }
                        if (answersArry != null && userFibOption != null) {
                            boolean isCorrect = false;
                            for (int k = 0; k < answersArry.length; k++) {
                                Label answerChoice = new Label();
                                if (answersArry[k] != null && k < userFibOption.length) {
                                    if ((answersArry[k].toLowerCase().trim()
                                            .equalsIgnoreCase(userFibOption[k].toLowerCase().trim()))
                                            && (noOfAttempts == 1)) {
                                        answerChoice.setText(userFibOption[k]);
                                        answerChoice.getElement().getStyle().setColor(CORRECT);
                                    } else if ((answersArry[k].toLowerCase().trim()
                                            .equalsIgnoreCase(userFibOption[k].toLowerCase().trim()))
                                            && (noOfAttempts > 1)) {
                                        answerChoice.setText(userFibOption[k]);
                                        answerChoice.getElement().getStyle().setColor(ONMULTIPULEATTEMPTS);
                                        isCorrect = true;
                                    } else {
                                        answerChoice.setText(userFibOption[k]);
                                        answerChoice.getElement().getStyle().setColor(INCORRECT);
                                        isCorrect = true;
                                    }
                                    answerChoice.setStyleName(STYLE_TABLE_CENTER);
                                    answerspnl.add(answerChoice);
                                }
                            }
                            if (!isCorrect) {
                                isTickdisplay = true;
                            }
                        }
                    }
                    answerspnl.setStyleName(STYLE_MARGIN_AUTO);
                    data.setValue(i, 3, answerspnl.toString());
                } else if (MA.equalsIgnoreCase(questionType)) {
                    VerticalPanel answerspnl = new VerticalPanel();
                    if (result.get(i).getAnswerObject() != null) {
                        JSONValue value = JSONParser.parseStrict(result.get(i).getAnswerObject());
                        JSONObject answerObject = value.isObject();
                        Set<String> keys = answerObject.keySet();
                        Iterator<String> itr = keys.iterator();
                        boolean isCorrect = false;
                        while (itr.hasNext()) {
                            answerspnl.clear();
                            JSONArray attemptsObj = (JSONArray) answerObject.get(itr.next().toString());
                            for (int j = 0; j < attemptsObj.size(); j++) {
                                Label answerChoice = new Label();
                                String showMessage = null;
                                boolean skip = attemptsObj.get(j).isObject().get("skip").isBoolean()
                                        .booleanValue();
                                String status = attemptsObj.get(j).isObject().get("status").isString()
                                        .stringValue();
                                String matext = attemptsObj.get(j).isObject().get("text").isString()
                                        .stringValue();
                                if (skip == false) {
                                    if (ZERO_NUMERIC.equalsIgnoreCase(matext)) {
                                        showMessage = i18n.GL_GRR_NO();
                                    } else if (ONE.equalsIgnoreCase(matext)) {
                                        showMessage = i18n.GL_GRR_YES();
                                    }
                                    answerChoice.setText(showMessage);
                                    if (ZERO_NUMERIC.equalsIgnoreCase(status)) {
                                        answerChoice.getElement().getStyle().setColor(INCORRECT);
                                        isCorrect = true;
                                    } else if (ONE.equalsIgnoreCase(status) && (noOfAttempts == 1)) {
                                        answerChoice.getElement().getStyle().setColor(CORRECT);
                                    } else if (ONE.equalsIgnoreCase(status) && (noOfAttempts > 1)) {
                                        answerChoice.getElement().getStyle().setColor(ONMULTIPULEATTEMPTS);
                                    }
                                } else {
                                    isCorrect = true;
                                }
                                answerChoice.setStyleName(STYLE_TABLE_CENTER);
                                answerspnl.add(answerChoice);
                            }
                        }
                        if (!isCorrect) {
                            isTickdisplay = true;
                        }
                    }
                    answerspnl.setStyleName(STYLE_MARGIN_AUTO);
                    data.setValue(i, 3, answerspnl.toString());
                } else if (HT_RO.equalsIgnoreCase(questionType) || HT_HL.equalsIgnoreCase(questionType)
                        || HS_TXT.equalsIgnoreCase(questionType) || HS_IMG.equalsIgnoreCase(questionType)) {
                    VerticalPanel answerspnl = new VerticalPanel();
                    if (result.get(i).getAnswerObject() != null
                            && !result.get(i).getStatus().equalsIgnoreCase("skipped")) {
                        Label viewResponselbl = new Label(VIEWRESPONSE);
                        viewResponselbl.setStyleName("summaryViewResponse");
                        viewResponselbl.getElement().setAttribute("resourceGooruId",
                                result.get(i).getResourceGooruOId());
                        viewResponselbl.getElement().setAttribute("questionType", result.get(i).getType());
                        viewResponselbl.getElement().setAttribute("answerObj", result.get(i).getAnswerObject());
                        viewResponselbl.getElement().setAttribute("attempts", String.valueOf(noOfAttempts));
                        answerspnl.add(viewResponselbl);
                    }
                    answerspnl.setStyleName(STYLE_MARGIN_AUTO);
                    data.setValue(i, 3, answerspnl.toString());
                }

                Image correctImg = new Image();
                if (isTickdisplay) {
                    correctImg.setUrl(urlDomain + "/images/analytics/tick.png");
                } else {
                    correctImg.setUrl(urlDomain + "/images/analytics/wrong.png");
                }
                data.setCell(i, 2, correctImg.toString(), null, getPropertiesCell());
                //Set attempts
                //               Label attempts=new Label(Integer.toString(noOfAttempts));
                //               attempts.setStyleName(STYLE_TABLE_CENTER);
                //               data.setValue(i, 4, attempts.toString());

                //Set time spent
                data.setValue(i, 4, AnalyticsUtil.getTimeStampLabel(result.get(i).getTimeSpent()).toString());

                //Set reactions
                int reaction = result.get(i).getReaction();
                data.setValue(i, 5, new AnalyticsReactionWidget(reaction).toString());
            }
        }
        Options options = Options.create();
        options.setAllowHtml(true);
        Table table = new Table(data, options);
        printScoredData.add(table);
        if (result.size() == 0) {
            Label erroeMsg = new Label();
            erroeMsg.setStyleName(STYLE_ERROR_MSG);
            erroeMsg.setText(i18n.GL3265());
            printScoredData.add(erroeMsg);
        }
    } catch (Exception e) {
        AppClientFactory.printSevereLogger("AnalyticsEndview : setQuestionsPrintData : " + e.getMessage());
    }
}

From source file:org.ednovo.gooru.client.mvp.assessments.play.collection.end.AssessmentsEndView.java

License:Open Source License

@Override
public void errorMsg() {
    Label erroeMsg = new Label();
    erroeMsg.setStyleName(STYLE_ERROR_MSG);
    erroeMsg.setText(i18n.GL3265());
    questionsTable.clear();//from   w  ww  .  ja  v  a 2  s .  c  o m
    questionsTable.add(erroeMsg);
}

From source file:org.ednovo.gooru.client.mvp.assessments.play.resource.add.AddResourceAssessmentsView.java

License:Open Source License

public void updateWorkSpaceLink(String collectionId) {
    showSuccessWidget(true);/*from  w ww  .  j a  v  a2 s .c  o  m*/
    addingLabel.setVisible(false);
    addResourceToCollectionButton.setVisible(true);
    if (getAddResourceToCollectionButton().getText().equalsIgnoreCase("Add Again")) {
        successMessageLabelText.setText(i18n.GL0699());
        successMessageLabelText.getElement().setAttribute("alt", i18n.GL0699());
        successMessageLabelText.getElement().setAttribute("title", i18n.GL0699());
    } else {
        successMessageLabelText.setText(i18n.GL0663());
        successMessageLabelText.getElement().setAttribute("alt", i18n.GL0663());
        successMessageLabelText.getElement().setAttribute("title", i18n.GL0663());
        addResourceToCollectionButton.setText(i18n.GL0691());
        addResourceToCollectionButton.getElement().setAttribute("alt", i18n.GL0691());
        addResourceToCollectionButton.getElement().setAttribute("title", i18n.GL0691());
    }
    workSpaceBtn.setText(i18n.GL1630());
    workSpaceBtn.getElement().setAttribute("alt", i18n.GL1630());
    workSpaceBtn.getElement().setAttribute("title", i18n.GL1630());

    this.collectionId = collectionId;
    addCollectionInsteadLabelContainer.clear();
    Label colletionIsteadButton = getAddCollectionViewButton();
    colletionIsteadButton.setText(i18n.GL0664());
    colletionIsteadButton.getElement().setAttribute("alt", i18n.GL0664());
    colletionIsteadButton.getElement().setAttribute("title", i18n.GL0664());
    colletionIsteadButton.getElement().getStyle().setMarginRight(138, Unit.PX);

    addCollectionInsteadLabelContainer.add(colletionIsteadButton);

}

From source file:org.ednovo.gooru.client.mvp.assessments.play.resource.add.AddResourceAssessmentsView.java

License:Open Source License

public void changeButtonText() {
    showSuccessWidget(false);//  w  ww  .j av  a2 s.c o m
    addingLabel.setVisible(false);
    errorMessage.setVisible(false);
    addResourceToCollectionButton.setVisible(true);
    addResourceToCollectionButton.setText(i18n.GL0590());
    addResourceToCollectionButton.getElement().setAttribute("alt", i18n.GL0590());
    addResourceToCollectionButton.getElement().setAttribute("title", i18n.GL0590());
    addCollectionContainer.clear();
    Label colletionIsteadButton = getAddCollectionViewButton();
    colletionIsteadButton.getElement().getStyle().clearMarginRight();
    colletionIsteadButton.getElement().getStyle().clearMarginTop();
    colletionIsteadButton.setText(i18n.GL0664());
    colletionIsteadButton.getElement().setAttribute("alt", i18n.GL0664());
    colletionIsteadButton.getElement().setAttribute("title", i18n.GL0664());
    addCollectionContainer.add(colletionIsteadButton);
}