Search in sources :

Example 6 with FeedbackParticipantType

use of teammates.common.datatransfer.FeedbackParticipantType in project teammates by TEAMMATES.

the class FeedbackQuestionsLogicTest method testUpdateQuestion.

private void testUpdateQuestion() throws Exception {
    ______TS("standard update, no existing responses, with 'keep existing' policy");
    FeedbackQuestionAttributes questionToUpdate = getQuestionFromDatastore("qn2InSession2InCourse2");
    questionToUpdate.questionMetaData = new Text("new question text");
    questionToUpdate.questionNumber = 3;
    List<FeedbackParticipantType> newVisibility = new LinkedList<>();
    newVisibility.add(FeedbackParticipantType.INSTRUCTORS);
    questionToUpdate.showResponsesTo = newVisibility;
    // Check keep existing policy.
    String originalCourseId = questionToUpdate.courseId;
    questionToUpdate.courseId = null;
    fqLogic.updateFeedbackQuestion(questionToUpdate);
    questionToUpdate.courseId = originalCourseId;
    FeedbackQuestionAttributes updatedQuestion = fqLogic.getFeedbackQuestion(questionToUpdate.getId());
    assertEquals(updatedQuestion.toString(), questionToUpdate.toString());
    ______TS("cascading update, non-destructive changes, existing responses are preserved");
    questionToUpdate = getQuestionFromDatastore("qn2InSession1InCourse1");
    questionToUpdate.questionMetaData = new Text("new question text 2");
    questionToUpdate.numberOfEntitiesToGiveFeedbackTo = 2;
    int numberOfResponses = frLogic.getFeedbackResponsesForQuestion(questionToUpdate.getId()).size();
    fqLogic.updateFeedbackQuestion(questionToUpdate);
    updatedQuestion = fqLogic.getFeedbackQuestion(questionToUpdate.getId());
    assertEquals(updatedQuestion.toString(), questionToUpdate.toString());
    assertEquals(frLogic.getFeedbackResponsesForQuestion(questionToUpdate.getId()).size(), numberOfResponses);
    ______TS("cascading update, destructive changes, delete all existing responses");
    questionToUpdate = getQuestionFromDatastore("qn2InSession1InCourse1");
    questionToUpdate.questionMetaData = new Text("new question text 3");
    questionToUpdate.recipientType = FeedbackParticipantType.INSTRUCTORS;
    assertFalse(frLogic.getFeedbackResponsesForQuestion(questionToUpdate.getId()).isEmpty());
    fqLogic.updateFeedbackQuestion(questionToUpdate);
    updatedQuestion = fqLogic.getFeedbackQuestion(questionToUpdate.getId());
    assertEquals(updatedQuestion.toString(), questionToUpdate.toString());
    assertEquals(frLogic.getFeedbackResponsesForQuestion(questionToUpdate.getId()).size(), 0);
    ______TS("failure: question does not exist");
    questionToUpdate = getQuestionFromDatastore("qn3InSession1InCourse1");
    fqLogic.deleteFeedbackQuestionCascade(questionToUpdate.getId());
    try {
        fqLogic.updateFeedbackQuestion(questionToUpdate);
        signalFailureToDetectException("Expected EntityDoesNotExistException not caught.");
    } catch (EntityDoesNotExistException e) {
        assertEquals(e.getMessage(), "Trying to update a feedback question that does not exist.");
    }
    ______TS("failure: invalid parameters");
    questionToUpdate = getQuestionFromDatastore("qn3InSession1InCourse1");
    questionToUpdate.giverType = FeedbackParticipantType.TEAMS;
    questionToUpdate.recipientType = FeedbackParticipantType.OWN_TEAM_MEMBERS;
    try {
        fqLogic.updateFeedbackQuestion(questionToUpdate);
        signalFailureToDetectException("Expected InvalidParametersException not caught.");
    } catch (InvalidParametersException e) {
        assertEquals(e.getMessage(), String.format(FieldValidator.PARTICIPANT_TYPE_TEAM_ERROR_MESSAGE, questionToUpdate.recipientType.toDisplayRecipientName(), questionToUpdate.giverType.toDisplayGiverName()));
    }
}
Also used : FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) Text(com.google.appengine.api.datastore.Text) InvalidParametersException(teammates.common.exception.InvalidParametersException) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType) LinkedList(java.util.LinkedList) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 7 with FeedbackParticipantType

use of teammates.common.datatransfer.FeedbackParticipantType in project teammates by TEAMMATES.

the class InstructorFeedbackResponseCommentAjaxPageData method getResponseVisibilities.

private Map<FeedbackParticipantType, Boolean> getResponseVisibilities() {
    FeedbackParticipantType[] relevantTypes = { FeedbackParticipantType.RECEIVER, FeedbackParticipantType.OWN_TEAM_MEMBERS, FeedbackParticipantType.RECEIVER_TEAM_MEMBERS, FeedbackParticipantType.STUDENTS, FeedbackParticipantType.INSTRUCTORS };
    Map<FeedbackParticipantType, Boolean> responseVisibilities = new HashMap<>();
    for (FeedbackParticipantType type : relevantTypes) {
        responseVisibilities.put(type, isResponseVisibleTo(type, question));
    }
    return responseVisibilities;
}
Also used : HashMap(java.util.HashMap) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType)

Example 8 with FeedbackParticipantType

use of teammates.common.datatransfer.FeedbackParticipantType in project teammates by TEAMMATES.

the class InstructorFeedbackResultsPageData method buildFeedbackResponseCommentAddForm.

private FeedbackResponseCommentRow buildFeedbackResponseCommentAddForm(FeedbackQuestionAttributes question, FeedbackResponseAttributes response, Map<FeedbackParticipantType, Boolean> responseVisibilityMap, String giverName, String recipientName) {
    FeedbackResponseCommentAttributes frca = FeedbackResponseCommentAttributes.builder(question.courseId, question.feedbackSessionName, "", new Text("")).withFeedbackResponseId(response.getId()).withFeedbackQuestionId(question.getId()).build();
    FeedbackParticipantType[] relevantTypes = { FeedbackParticipantType.GIVER, FeedbackParticipantType.RECEIVER, FeedbackParticipantType.OWN_TEAM_MEMBERS, FeedbackParticipantType.RECEIVER_TEAM_MEMBERS, FeedbackParticipantType.STUDENTS, FeedbackParticipantType.INSTRUCTORS };
    frca.showCommentTo = new ArrayList<>();
    frca.showGiverNameTo = new ArrayList<>();
    for (FeedbackParticipantType type : relevantTypes) {
        if (isResponseCommentVisibleTo(question, type)) {
            frca.showCommentTo.add(type);
        }
        if (isResponseCommentGiverNameVisibleTo(question, type)) {
            frca.showGiverNameTo.add(type);
        }
    }
    return new FeedbackResponseCommentRow(frca, giverName, recipientName, getResponseCommentVisibilityString(question), getResponseCommentGiverNameVisibilityString(question), responseVisibilityMap, bundle.getTimeZone());
}
Also used : FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) FeedbackResponseCommentRow(teammates.ui.template.FeedbackResponseCommentRow) Text(com.google.appengine.api.datastore.Text) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType)

Example 9 with FeedbackParticipantType

use of teammates.common.datatransfer.FeedbackParticipantType 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 10 with FeedbackParticipantType

use of teammates.common.datatransfer.FeedbackParticipantType in project teammates by TEAMMATES.

the class InstructorFeedbackResultsPageData method buildResponseComment.

private FeedbackResponseCommentRow buildResponseComment(String giverName, String recipientName, FeedbackQuestionAttributes question, FeedbackResponseAttributes response, FeedbackResponseCommentAttributes frcAttributes) {
    boolean isInstructorGiver = instructor.email.equals(frcAttributes.giverEmail);
    boolean isInstructorWithPrivilegesToModify = instructor.isAllowedForPrivilege(response.giverSection, response.feedbackSessionName, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS) && instructor.isAllowedForPrivilege(response.recipientSection, response.feedbackSessionName, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS);
    boolean isInstructorAllowedToEditAndDeleteComment = isInstructorGiver || isInstructorWithPrivilegesToModify;
    Map<FeedbackParticipantType, Boolean> responseVisibilityMap = getResponseVisibilityMap(question);
    String whoCanSeeComment = null;
    boolean isVisibilityIconShown = false;
    if (bundle.feedbackSession.isPublished()) {
        boolean isResponseCommentPublicToRecipient = !frcAttributes.showCommentTo.isEmpty();
        isVisibilityIconShown = isResponseCommentPublicToRecipient;
        if (isVisibilityIconShown) {
            whoCanSeeComment = getTypeOfPeopleCanViewComment(frcAttributes, question);
        }
    }
    FeedbackResponseCommentRow frc = new FeedbackResponseCommentRow(frcAttributes, frcAttributes.giverEmail, giverName, recipientName, getResponseCommentVisibilityString(frcAttributes, question), getResponseCommentGiverNameVisibilityString(frcAttributes, question), responseVisibilityMap, bundle.instructorEmailNameTable, bundle.getTimeZone());
    frc.setVisibilityIcon(isVisibilityIconShown, whoCanSeeComment);
    if (isInstructorAllowedToEditAndDeleteComment) {
        frc.enableEditDelete();
    }
    return frc;
}
Also used : FeedbackResponseCommentRow(teammates.ui.template.FeedbackResponseCommentRow) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType)

Aggregations

FeedbackParticipantType (teammates.common.datatransfer.FeedbackParticipantType)25 ArrayList (java.util.ArrayList)8 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)8 HashMap (java.util.HashMap)7 Text (com.google.appengine.api.datastore.Text)4 LinkedHashMap (java.util.LinkedHashMap)4 FeedbackResponseCommentRow (teammates.ui.template.FeedbackResponseCommentRow)4 Map (java.util.Map)3 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)3 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)3 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 StudentResultSummary (teammates.common.datatransfer.StudentResultSummary)2 TeamEvalResult (teammates.common.datatransfer.TeamEvalResult)2 DecimalFormat (java.text.DecimalFormat)1 Matcher (java.util.regex.Matcher)1 WebElement (org.openqa.selenium.WebElement)1 Test (org.testng.annotations.Test)1 TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)1