Search in sources :

Example 61 with FeedbackQuestionAttributes

use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes 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 62 with FeedbackQuestionAttributes

use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.

the class InstructorFeedbackResultsPageData method buildResponsePanels.

private List<InstructorFeedbackResultsResponsePanel> buildResponsePanels(final String additionalInfoId, int primaryParticipantIndex, int secondaryRecipientIndex, List<FeedbackResponseAttributes> giverResponses) {
    List<InstructorFeedbackResultsResponsePanel> responsePanels = new ArrayList<>();
    for (int responseIndex = 0; responseIndex < giverResponses.size(); responseIndex++) {
        FeedbackResponseAttributes response = giverResponses.get(responseIndex);
        String questionId = response.feedbackQuestionId;
        FeedbackQuestionAttributes question = bundle.questions.get(questionId);
        String questionText = bundle.getQuestionText(questionId);
        int giverIndex = viewType.isPrimaryGroupingOfGiverType() ? primaryParticipantIndex : secondaryRecipientIndex;
        int recipientIndex = viewType.isPrimaryGroupingOfGiverType() ? secondaryRecipientIndex : primaryParticipantIndex;
        String additionalInfoText = questionToDetailsMap.get(question).getQuestionAdditionalInfoHtml(question.getQuestionNumber(), String.format(additionalInfoId, giverIndex, recipientIndex));
        String displayableResponse = bundle.getResponseAnswerHtml(response, question);
        String giverName = bundle.getNameForEmail(response.giver);
        String recipientName = bundle.getNameForEmail(response.recipient);
        String giverTeam = bundle.getTeamNameForEmail(response.giver);
        String recipientTeam = bundle.getTeamNameForEmail(response.recipient);
        giverName = bundle.appendTeamNameToName(giverName, giverTeam);
        recipientName = bundle.appendTeamNameToName(recipientName, recipientTeam);
        List<FeedbackResponseCommentRow> comments = buildResponseComments(giverName, recipientName, question, response);
        boolean isAllowedToSubmitSessionsInBothSection = instructor.isAllowedForPrivilege(response.giverSection, response.feedbackSessionName, Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS) && instructor.isAllowedForPrivilege(response.recipientSection, response.feedbackSessionName, Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS);
        boolean isCommentsOnResponsesAllowed = question.getQuestionDetails().isCommentsOnResponsesAllowed();
        Matcher matcher = sectionIdPattern.matcher(additionalInfoId);
        if (matcher.find()) {
            sectionId = Integer.parseInt(matcher.group(1));
        }
        InstructorFeedbackResultsResponsePanel responsePanel = new InstructorFeedbackResultsResponsePanel(question, response, questionText, sectionId, additionalInfoText, null, displayableResponse, comments, isAllowedToSubmitSessionsInBothSection, isCommentsOnResponsesAllowed);
        responsePanel.setCommentsIndexes(recipientIndex, giverIndex, responseIndex + 1);
        if (isCommentsOnResponsesAllowed) {
            Map<FeedbackParticipantType, Boolean> responseVisibilityMap = getResponseVisibilityMap(question);
            FeedbackResponseCommentRow frcForAdding = buildFeedbackResponseCommentAddForm(question, response, responseVisibilityMap, giverName, recipientName);
            responsePanel.setFrcForAdding(frcForAdding);
        }
        responsePanels.add(responsePanel);
    }
    return responsePanels;
}
Also used : InstructorFeedbackResultsResponsePanel(teammates.ui.template.InstructorFeedbackResultsResponsePanel) Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) FeedbackResponseCommentRow(teammates.ui.template.FeedbackResponseCommentRow)

Example 63 with FeedbackQuestionAttributes

use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.

the class InstructorFeedbackResultsPageData method initCommonVariables.

private void initCommonVariables(InstructorAttributes instructor, String selectedSection, String showStats, String groupByTeam, boolean isMissingResponsesShown) {
    Assumption.assertNotNull(bundle);
    this.instructor = instructor;
    this.selectedSection = selectedSection;
    this.showStats = showStats;
    this.groupByTeam = groupByTeam;
    this.isMissingResponsesShown = isMissingResponsesShown;
    for (FeedbackQuestionAttributes question : bundle.questions.values()) {
        FeedbackQuestionDetails questionDetails = question.getQuestionDetails();
        questionToDetailsMap.put(question, questionDetails);
    }
    this.sections = getSectionsFromBundle();
    displayableFsName = sanitizeForHtml(bundle.feedbackSession.getFeedbackSessionName());
    displayableCourseId = sanitizeForHtml(bundle.feedbackSession.getCourseId());
}
Also used : FeedbackQuestionDetails(teammates.common.datatransfer.questions.FeedbackQuestionDetails) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Example 64 with FeedbackQuestionAttributes

use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.

the class InstructorSearchPageData method createQuestionTables.

private List<QuestionTable> createQuestionTables(String fsName, FeedbackResponseCommentSearchResultBundle frcSearchResultBundle) {
    List<QuestionTable> questionTables = new ArrayList<>();
    List<FeedbackQuestionAttributes> questionList = frcSearchResultBundle.questions.get(fsName);
    for (FeedbackQuestionAttributes question : questionList) {
        int questionNumber = question.questionNumber;
        String questionText = question.getQuestionDetails().getQuestionText();
        String additionalInfo = question.getQuestionDetails().getQuestionAdditionalInfoHtml(questionNumber, "");
        questionTables.add(new QuestionTable(questionNumber, questionText, additionalInfo, createResponseRows(question, frcSearchResultBundle)));
    }
    return questionTables;
}
Also used : ArrayList(java.util.ArrayList) QuestionTable(teammates.ui.template.QuestionTable) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Example 65 with FeedbackQuestionAttributes

use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.

the class InstructorFeedbackQuestionCopyPageData method buildCopyQuestionsModalRows.

private List<FeedbackQuestionTableRow> buildCopyQuestionsModalRows(List<FeedbackQuestionAttributes> copiableQuestions) {
    List<FeedbackQuestionTableRow> copyQuestionRows = new ArrayList<>();
    for (FeedbackQuestionAttributes question : copiableQuestions) {
        String courseId = question.courseId;
        String fsName = question.feedbackSessionName;
        FeedbackQuestionDetails questionDetails = question.getQuestionDetails();
        String qnType = questionDetails.getQuestionTypeDisplayName();
        String qnText = questionDetails.getQuestionText();
        String qnId = question.getId();
        FeedbackQuestionTableRow row = new FeedbackQuestionTableRow(courseId, fsName, qnType, qnText, qnId);
        copyQuestionRows.add(row);
    }
    return copyQuestionRows;
}
Also used : FeedbackQuestionDetails(teammates.common.datatransfer.questions.FeedbackQuestionDetails) FeedbackQuestionTableRow(teammates.ui.template.FeedbackQuestionTableRow) ArrayList(java.util.ArrayList) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Aggregations

FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)154 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)64 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)48 ArrayList (java.util.ArrayList)47 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)38 Test (org.testng.annotations.Test)35 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)25 List (java.util.List)23 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)23 FeedbackQuestionsDb (teammates.storage.api.FeedbackQuestionsDb)19 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)18 HashMap (java.util.HashMap)17 RedirectResult (teammates.ui.controller.RedirectResult)17 HashSet (java.util.HashSet)12 FeedbackResponseCommentAttributes (teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes)12 Text (com.google.appengine.api.datastore.Text)11 Map (java.util.Map)10 FeedbackQuestionDetails (teammates.common.datatransfer.questions.FeedbackQuestionDetails)10 LinkedHashMap (java.util.LinkedHashMap)9 DataBundle (teammates.common.datatransfer.DataBundle)9