Search in sources :

Example 1 with InstructorFeedbackResultsQuestionTable

use of teammates.ui.template.InstructorFeedbackResultsQuestionTable in project teammates by TEAMMATES.

the class InstructorFeedbackResultsPageData method initForViewByQuestion.

/**
 * Prepares question tables for viewing.
 *
 * <p>{@code bundle} should be set before this method
 */
public void initForViewByQuestion(InstructorAttributes instructor, String selectedSection, String showStats, String groupByTeam, boolean isMissingResponsesShown) {
    this.viewType = InstructorFeedbackResultsPageViewType.QUESTION;
    this.sortType = InstructorFeedbackResultsPageViewType.QUESTION.toString();
    initCommonVariables(instructor, selectedSection, showStats, groupByTeam, isMissingResponsesShown);
    Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> questionToResponseMap = bundle.getQuestionResponseMap();
    questionPanels = new ArrayList<>();
    // if there is more than one question, we omit generation of responseRows,
    // and load them by ajax question by question
    boolean isLoadingStructureOnly = questionToResponseMap.size() > 1;
    questionToResponseMap.forEach((question, responses) -> {
        InstructorFeedbackResultsQuestionTable questionPanel;
        if (isLoadingStructureOnly) {
            questionPanel = buildQuestionTableWithoutResponseRows(question, responses, "");
            questionPanel.setHasResponses(false);
        } else {
            questionPanel = buildQuestionTableAndResponseRows(question, responses, "");
        }
        questionPanels.add(questionPanel);
    });
}
Also used : FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) ArrayList(java.util.ArrayList) List(java.util.List) InstructorFeedbackResultsQuestionTable(teammates.ui.template.InstructorFeedbackResultsQuestionTable)

Example 2 with InstructorFeedbackResultsQuestionTable

use of teammates.ui.template.InstructorFeedbackResultsQuestionTable in project teammates by TEAMMATES.

the class InstructorFeedbackResultsPageData method buildQuestionTableAndResponseRows.

/**
 * Builds a question table for given question, and response rows for the given responses.
 *
 * @param participantIdentifier  for viewTypes * > Question > *, constructs missing response rows
 *                               only for the given participant
 * @param isShowingResponseRows  if false, hides the response rows
 */
private InstructorFeedbackResultsQuestionTable buildQuestionTableAndResponseRows(FeedbackQuestionAttributes question, List<FeedbackResponseAttributes> responses, String additionalInfoId, String participantIdentifier, boolean isShowingResponseRows) {
    List<ElementTag> columnTags = new ArrayList<>();
    Map<String, Boolean> isSortable = new HashMap<>();
    boolean isCollapsible = true;
    List<InstructorFeedbackResultsResponseRow> responseRows = null;
    FeedbackQuestionDetails questionDetails = questionToDetailsMap.get(question);
    if (isShowingResponseRows) {
        switch(viewType) {
            case QUESTION:
                buildTableColumnHeaderForQuestionView(columnTags, isSortable);
                responseRows = buildResponseRowsForQuestion(question, responses);
                break;
            case GIVER_QUESTION_RECIPIENT:
                buildTableColumnHeaderForGiverQuestionRecipientView(columnTags, isSortable);
                responseRows = buildResponseRowsForQuestionForSingleGiver(question, responses, participantIdentifier);
                isCollapsible = false;
                break;
            case RECIPIENT_QUESTION_GIVER:
                buildTableColumnHeaderForRecipientQuestionGiverView(columnTags, isSortable);
                responseRows = buildResponseRowsForQuestionForSingleRecipient(question, responses, participantIdentifier);
                isCollapsible = false;
                break;
            default:
                Assumption.fail("View type should not involve question tables");
                break;
        }
        // by default order (first by team name, then by display name)
        if (questionDetails.isQuestionSpecificSortingRequired()) {
            responseRows.sort(questionDetails.getResponseRowsSortOrder());
        } else {
            responseRows = InstructorFeedbackResultsResponseRow.sortListWithDefaultOrder(responseRows);
        }
    }
    String studentEmail = student == null ? null : student.email;
    String statisticsTable = questionDetails.getQuestionResultStatisticsHtml(responses, question, studentEmail, bundle, viewType.toString());
    String questionText = questionDetails.getQuestionText();
    String additionalInfoText = questionDetails.getQuestionAdditionalInfoHtml(question.questionNumber, additionalInfoId);
    InstructorFeedbackResultsQuestionTable questionTable = new InstructorFeedbackResultsQuestionTable(!responses.isEmpty(), statisticsTable, responseRows, question, questionText, additionalInfoText, columnTags, isSortable);
    if (viewType == InstructorFeedbackResultsPageViewType.QUESTION) {
        // setup classes, for loading responses by ajax
        // ajax_submit: user needs to click on the panel to load
        // ajax_auto: responses are loaded automatically
        questionTable.setAjaxClass(isLargeNumberOfResponses() ? " ajax_submit" : " ajax_auto");
    }
    questionTable.setShowResponseRows(isShowingResponseRows);
    questionTable.setCollapsible(isCollapsible);
    return questionTable;
}
Also used : InstructorFeedbackResultsResponseRow(teammates.ui.template.InstructorFeedbackResultsResponseRow) FeedbackQuestionDetails(teammates.common.datatransfer.questions.FeedbackQuestionDetails) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) ElementTag(teammates.ui.template.ElementTag) InstructorFeedbackResultsQuestionTable(teammates.ui.template.InstructorFeedbackResultsQuestionTable)

Example 3 with InstructorFeedbackResultsQuestionTable

use of teammates.ui.template.InstructorFeedbackResultsQuestionTable in project teammates by TEAMMATES.

the class InstructorFeedbackResultsPageData method buildTeamsStatisticsTableForSectionPanel.

/**
 * Constructs InstructorFeedbackResultsQuestionTable containing statistics for each team.
 * The statistics tables are added to the sectionPanel.
 */
private void buildTeamsStatisticsTableForSectionPanel(InstructorFeedbackResultsSectionPanel sectionPanel, Map<String, Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>>> responsesGroupedByTeam, Set<String> teamsInSection) {
    Map<String, List<InstructorFeedbackResultsQuestionTable>> teamToStatisticsTables = new HashMap<>();
    for (String team : teamsInSection) {
        // or if the team is an anonymous student's team or an anonymous team, or is "-"
        if (!responsesGroupedByTeam.containsKey(team) || !isTeamVisible(team)) {
            continue;
        }
        List<InstructorFeedbackResultsQuestionTable> statisticsTablesForTeam = new ArrayList<>();
        for (FeedbackQuestionAttributes question : bundle.questions.values()) {
            if (!responsesGroupedByTeam.get(team).containsKey(question)) {
                continue;
            }
            List<FeedbackResponseAttributes> responsesForTeamAndQuestion = responsesGroupedByTeam.get(team).get(question);
            InstructorFeedbackResultsQuestionTable statsTable = buildQuestionTableWithoutResponseRows(question, responsesForTeamAndQuestion, "");
            statsTable.setCollapsible(false);
            if (!statsTable.getQuestionStatisticsTable().isEmpty()) {
                statisticsTablesForTeam.add(statsTable);
            }
        }
        InstructorFeedbackResultsQuestionTable.sortByQuestionNumber(statisticsTablesForTeam);
        teamToStatisticsTables.put(team, statisticsTablesForTeam);
    }
    sectionPanel.setTeamStatisticsTable(teamToStatisticsTables);
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) ArrayList(java.util.ArrayList) List(java.util.List) InstructorFeedbackResultsQuestionTable(teammates.ui.template.InstructorFeedbackResultsQuestionTable)

Example 4 with InstructorFeedbackResultsQuestionTable

use of teammates.ui.template.InstructorFeedbackResultsQuestionTable in project teammates by TEAMMATES.

the class InstructorFeedbackResultsPageData method buildGroupByQuestionPanel.

private InstructorFeedbackResultsGroupByQuestionPanel buildGroupByQuestionPanel(String participantIdentifier, Entry<String, Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>>> recipientToGiverToResponsesMap, String additionalInfoId, int participantIndex) {
    List<InstructorFeedbackResultsQuestionTable> questionTables = new ArrayList<>();
    int questionIndex = 0;
    for (Entry<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> responsesForParticipantForQuestion : recipientToGiverToResponsesMap.getValue().entrySet()) {
        if (responsesForParticipantForQuestion.getValue().isEmpty()) {
            // participant has no responses for the current question
            continue;
        }
        questionIndex += 1;
        FeedbackQuestionAttributes currentQuestion = responsesForParticipantForQuestion.getKey();
        List<FeedbackResponseAttributes> responsesForQuestion = responsesForParticipantForQuestion.getValue();
        InstructorFeedbackResultsQuestionTable questionTable = buildQuestionTableAndResponseRows(currentQuestion, responsesForQuestion, String.format(additionalInfoId, participantIndex, questionIndex), participantIdentifier, true);
        questionTable.setBoldQuestionNumber(false);
        questionTables.add(questionTable);
    }
    InstructorFeedbackResultsQuestionTable.sortByQuestionNumber(questionTables);
    InstructorFeedbackResultsGroupByQuestionPanel participantPanel;
    // Construct InstructorFeedbackResultsGroupByQuestionPanel for the current giver
    if (viewType.isPrimaryGroupingOfGiverType() && (bundle.isParticipantIdentifierStudent(participantIdentifier) || bundle.isParticipantIdentifierInstructor(participantIdentifier))) {
        // Moderation button on the participant panels are only shown is the panel is a giver panel,
        // and if the participant is a student
        InstructorFeedbackResultsModerationButton moderationButton = buildModerationButtonForGiver(null, participantIdentifier, "btn btn-primary btn-xs", MODERATE_RESPONSES_FOR_GIVER);
        participantPanel = new InstructorFeedbackResultsGroupByQuestionPanel(participantIdentifier, bundle.getNameForEmail(participantIdentifier), questionTables, getStudentProfilePictureLink(participantIdentifier, instructor.courseId), true, moderationButton);
    } else {
        participantPanel = new InstructorFeedbackResultsGroupByQuestionPanel(questionTables, getStudentProfilePictureLink(participantIdentifier, instructor.courseId), viewType.isPrimaryGroupingOfGiverType(), participantIdentifier, bundle.getNameForEmail(participantIdentifier));
    }
    return participantPanel;
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) InstructorFeedbackResultsGroupByQuestionPanel(teammates.ui.template.InstructorFeedbackResultsGroupByQuestionPanel) ArrayList(java.util.ArrayList) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) ArrayList(java.util.ArrayList) List(java.util.List) InstructorFeedbackResultsModerationButton(teammates.ui.template.InstructorFeedbackResultsModerationButton) InstructorFeedbackResultsQuestionTable(teammates.ui.template.InstructorFeedbackResultsQuestionTable)

Aggregations

ArrayList (java.util.ArrayList)4 InstructorFeedbackResultsQuestionTable (teammates.ui.template.InstructorFeedbackResultsQuestionTable)4 List (java.util.List)3 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)2 FeedbackQuestionDetails (teammates.common.datatransfer.questions.FeedbackQuestionDetails)1 ElementTag (teammates.ui.template.ElementTag)1 InstructorFeedbackResultsGroupByQuestionPanel (teammates.ui.template.InstructorFeedbackResultsGroupByQuestionPanel)1 InstructorFeedbackResultsModerationButton (teammates.ui.template.InstructorFeedbackResultsModerationButton)1 InstructorFeedbackResultsResponseRow (teammates.ui.template.InstructorFeedbackResultsResponseRow)1