Search in sources :

Example 1 with FeedbackParticipantType

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

the class InstructorFeedbackEditPageUiTest method assertEnabledVisibilityOptionsIncludesOnly.

private void assertEnabledVisibilityOptionsIncludesOnly(List<FeedbackParticipantType> expectedTypes, int questionNumber) {
    Set<String> expectedEnabledOptions = new HashSet<>();
    for (FeedbackParticipantType expectedType : expectedTypes) {
        expectedEnabledOptions.add(expectedType.toString());
    }
    Set<String> actualEnableOptions = new HashSet<>();
    WebElement optionsTable = browser.driver.findElement(By.id("visibilityOptions-" + questionNumber));
    List<WebElement> enabledRows = optionsTable.findElements(By.cssSelector("tr:not([style='display: none;'])"));
    // remove the header row
    enabledRows.remove(0);
    for (WebElement enabledRow : enabledRows) {
        WebElement checkbox = enabledRow.findElement(By.cssSelector("input"));
        actualEnableOptions.add(checkbox.getAttribute("value"));
    }
    assertEquals(expectedEnabledOptions, actualEnableOptions);
}
Also used : FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType) WebElement(org.openqa.selenium.WebElement) HashSet(java.util.HashSet)

Example 2 with FeedbackParticipantType

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

the class FeedbackSubmissionEditSaveAction method extractFeedbackResponseData.

private FeedbackResponseAttributes extractFeedbackResponseData(Map<String, String[]> requestParameters, int questionIndx, int responseIndx, FeedbackQuestionAttributes feedbackQuestionAttributes) {
    FeedbackQuestionDetails questionDetails = feedbackQuestionAttributes.getQuestionDetails();
    FeedbackResponseAttributes response = new FeedbackResponseAttributes();
    // This field can be null if the response is new
    response.setId(getRequestParamValue(Const.ParamsNames.FEEDBACK_RESPONSE_ID + "-" + questionIndx + "-" + responseIndx));
    response.feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, response.feedbackSessionName);
    response.courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, response.courseId);
    response.feedbackQuestionId = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID + "-" + questionIndx);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_QUESTION_ID + "-" + questionIndx, response.feedbackQuestionId);
    Assumption.assertEquals("feedbackQuestionId Mismatch", feedbackQuestionAttributes.getId(), response.feedbackQuestionId);
    response.recipient = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-" + questionIndx + "-" + responseIndx);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-" + questionIndx + "-" + responseIndx, response.recipient);
    String feedbackQuestionType = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-" + questionIndx);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-" + questionIndx, feedbackQuestionType);
    response.feedbackQuestionType = FeedbackQuestionType.valueOf(feedbackQuestionType);
    FeedbackParticipantType recipientType = feedbackQuestionAttributes.recipientType;
    if (recipientType == FeedbackParticipantType.INSTRUCTORS || recipientType == FeedbackParticipantType.NONE) {
        response.recipientSection = Const.DEFAULT_SECTION;
    } else if (recipientType == FeedbackParticipantType.TEAMS) {
        response.recipientSection = logic.getSectionForTeam(courseId, response.recipient);
    } else if (recipientType == FeedbackParticipantType.STUDENTS) {
        StudentAttributes student = logic.getStudentForEmail(courseId, response.recipient);
        response.recipientSection = student == null ? Const.DEFAULT_SECTION : student.section;
    } else {
        response.recipientSection = getUserSectionForCourse();
    }
    // This field can be null if the question is skipped
    String paramName = Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-" + questionIndx + "-" + responseIndx;
    String[] answer = getRequestParamValues(paramName);
    if (questionDetails.isQuestionSkipped(answer)) {
        response.responseMetaData = new Text("");
    } else {
        FeedbackResponseDetails responseDetails = FeedbackResponseDetails.createResponseDetails(answer, questionDetails.getQuestionType(), questionDetails, requestParameters, questionIndx, responseIndx);
        response.setResponseDetails(responseDetails);
    }
    return response;
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionDetails(teammates.common.datatransfer.questions.FeedbackQuestionDetails) Text(com.google.appengine.api.datastore.Text) FeedbackResponseDetails(teammates.common.datatransfer.questions.FeedbackResponseDetails) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 3 with FeedbackParticipantType

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

the class FeedbackContributionQuestionDetails method getQuestionResultStatisticsCsv.

@Override
public String getQuestionResultStatisticsCsv(List<FeedbackResponseAttributes> responses, FeedbackQuestionAttributes question, FeedbackSessionResultsBundle bundle) {
    if (responses.isEmpty()) {
        return "";
    }
    List<FeedbackResponseAttributes> actualResponses = getActualResponses(question, bundle);
    // List of teams visible to the instructor and in the selected section
    List<String> teamNames = getTeamNames(bundle);
    // Each team's member(email) list
    Map<String, List<String>> teamMembersEmail = getTeamMembersEmail(bundle, teamNames);
    // Each team's responses
    Map<String, List<FeedbackResponseAttributes>> teamResponses = getTeamResponses(actualResponses, bundle, teamNames);
    // Get each team's submission array. -> int[teamSize][teamSize]
    // Where int[0][1] refers points from student 0 to student 1
    // Where student 0 is the 0th student in the list in teamMembersEmail
    Map<String, int[][]> teamSubmissionArray = getTeamSubmissionArray(teamNames, teamMembersEmail, teamResponses);
    // Each team's eval results.
    Map<String, TeamEvalResult> teamResults = getTeamResults(teamNames, teamSubmissionArray, teamMembersEmail);
    // Each person's results summary
    Map<String, StudentResultSummary> studentResults = getStudentResults(teamMembersEmail, teamResults);
    // Check visibility of recipient
    boolean hideRecipient = false;
    FeedbackParticipantType type = question.recipientType;
    for (FeedbackResponseAttributes response : actualResponses) {
        if (!bundle.visibilityTable.get(response.getId())[1] && type != FeedbackParticipantType.SELF && type != FeedbackParticipantType.NONE) {
            hideRecipient = true;
        }
    }
    StringBuilder contribFragments = new StringBuilder();
    Map<String, String> sortedMap = new LinkedHashMap<>();
    for (Map.Entry<String, StudentResultSummary> entry : studentResults.entrySet()) {
        StudentResultSummary summary = entry.getValue();
        String email = entry.getKey();
        String name = bundle.roster.getStudentForEmail(email).name;
        String team = bundle.roster.getStudentForEmail(email).team;
        List<String> teamEmails = teamMembersEmail.get(team);
        TeamEvalResult teamResult = teamResults.get(team);
        int studentIndx = teamEmails.indexOf(email);
        String displayName;
        String displayTeam;
        String displayEmail;
        if (hideRecipient) {
            displayName = FeedbackSessionResultsBundle.getAnonName(type, name);
            displayTeam = displayName + Const.TEAM_OF_EMAIL_OWNER;
            displayEmail = Const.USER_NOBODY_TEXT;
        } else {
            displayName = name;
            displayTeam = team;
            displayEmail = email;
        }
        int[] incomingPoints = new int[teamResult.normalizedPeerContributionRatio.length];
        for (int i = 0; i < incomingPoints.length; i++) {
            incomingPoints[i] = teamResult.normalizedPeerContributionRatio[i][studentIndx];
        }
        String contribFragmentString = SanitizationHelper.sanitizeForCsv(displayTeam) + "," + SanitizationHelper.sanitizeForCsv(displayName) + "," + SanitizationHelper.sanitizeForCsv(displayEmail) + "," + SanitizationHelper.sanitizeForCsv(Integer.toString(summary.claimedToInstructor)) + "," + SanitizationHelper.sanitizeForCsv(Integer.toString(summary.perceivedToInstructor)) + "," + SanitizationHelper.sanitizeForCsv(getNormalizedPointsListDescending(incomingPoints, studentIndx)) + System.lineSeparator();
        // Replace all Unset values
        contribFragmentString = contribFragmentString.replaceAll(Integer.toString(Const.INT_UNINITIALIZED), "N/A");
        contribFragmentString = contribFragmentString.replaceAll(Integer.toString(Const.POINTS_NOT_SURE), "Not Sure");
        contribFragmentString = contribFragmentString.replaceAll(Integer.toString(Const.POINTS_NOT_SUBMITTED), "Not Submitted");
        // For sorting purposes
        sortedMap.put(displayTeam + "-%-" + displayName, contribFragmentString);
    }
    sortedMap.forEach((key, value) -> contribFragments.append(value));
    String csvPointsExplanation = "In the points given below, an equal share is equal to 100 points. " + "e.g. 80 means \"Equal share - 20%\" and 110 means \"Equal share + 10%\"." + System.lineSeparator() + "Claimed Contribution (CC) = the contribution claimed by the student." + System.lineSeparator() + "Perceived Contribution (PC) = the average value of student's contribution " + "as perceived by the team members." + System.lineSeparator() + "Team, Name, Email, CC, PC, Ratings Recieved" + System.lineSeparator();
    return csvPointsExplanation + contribFragments + System.lineSeparator();
}
Also used : StudentResultSummary(teammates.common.datatransfer.StudentResultSummary) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType) LinkedHashMap(java.util.LinkedHashMap) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) TeamEvalResult(teammates.common.datatransfer.TeamEvalResult) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 4 with FeedbackParticipantType

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

the class FeedbackContributionQuestionDetails method getQuestionResultsStatisticsHtmlQuestionView.

private String getQuestionResultsStatisticsHtmlQuestionView(List<FeedbackResponseAttributes> responses, FeedbackQuestionAttributes question, FeedbackSessionResultsBundle bundle) {
    if (responses.isEmpty()) {
        return "";
    }
    List<FeedbackResponseAttributes> actualResponses = getActualResponses(question, bundle);
    // List of teams visible to the instructor and in the selected section
    List<String> teamNames = getTeamNames(bundle);
    // Each team's member(email) list
    Map<String, List<String>> teamMembersEmail = getTeamMembersEmail(bundle, teamNames);
    // Each team's responses
    Map<String, List<FeedbackResponseAttributes>> teamResponses = getTeamResponses(actualResponses, bundle, teamNames);
    // Get each team's submission array. -> int[teamSize][teamSize]
    // Where int[0][1] refers points from student 0 to student 1
    // Where student 0 is the 0th student in the list in teamMembersEmail
    Map<String, int[][]> teamSubmissionArray = getTeamSubmissionArray(teamNames, teamMembersEmail, teamResponses);
    // Each team's eval results.
    Map<String, TeamEvalResult> teamResults = getTeamResults(teamNames, teamSubmissionArray, teamMembersEmail);
    // Each person's results summary
    Map<String, StudentResultSummary> studentResults = getStudentResults(teamMembersEmail, teamResults);
    // Check visibility of recipient
    boolean hideRecipient = false;
    FeedbackParticipantType type = question.recipientType;
    for (FeedbackResponseAttributes response : actualResponses) {
        if (!bundle.visibilityTable.get(response.getId())[1] && type != FeedbackParticipantType.SELF && type != FeedbackParticipantType.NONE) {
            hideRecipient = true;
        }
    }
    StringBuilder contribFragments = new StringBuilder();
    for (Map.Entry<String, StudentResultSummary> entry : studentResults.entrySet()) {
        StudentResultSummary summary = entry.getValue();
        String email = entry.getKey();
        String name = bundle.roster.getStudentForEmail(email).name;
        String team = bundle.roster.getStudentForEmail(email).team;
        List<String> teamEmails = teamMembersEmail.get(team);
        TeamEvalResult teamResult = teamResults.get(team);
        int studentIndx = teamEmails.indexOf(email);
        String displayName = name;
        String displayTeam = team;
        if (hideRecipient) {
            displayName = FeedbackSessionResultsBundle.getAnonName(type, name);
            displayTeam = displayName + Const.TEAM_OF_EMAIL_OWNER;
        }
        int[] incomingPoints = new int[teamResult.normalizedPeerContributionRatio.length];
        for (int i = 0; i < incomingPoints.length; i++) {
            incomingPoints[i] = teamResult.normalizedPeerContributionRatio[i][studentIndx];
        }
        contribFragments.append(Templates.populateTemplate(FormTemplates.CONTRIB_RESULT_STATS_FRAGMENT, Slots.CONTRIB_STUDENT_TEAM, SanitizationHelper.sanitizeForHtml(displayTeam), Slots.CONTRIB_STUDENT_NAME, SanitizationHelper.sanitizeForHtml(displayName), Slots.CONTRIB_CC, getPointsAsColorizedHtml(summary.claimedToInstructor), Slots.CONTRIB_PC, getPointsAsColorizedHtml(summary.perceivedToInstructor), Slots.CONTRIB_DIFF, getPointsDiffAsHtml(summary), Slots.CONTRIB_RR, getNormalizedPointsListColorizedDescending(incomingPoints, studentIndx), Slots.CONTRIB_PARAM_STUDENT_NAME, Const.ParamsNames.STUDENT_NAME));
    }
    return Templates.populateTemplate(FormTemplates.CONTRIB_RESULT_STATS, Slots.CONTRIB_FRAGMENTS, contribFragments.toString(), Slots.CONTRIB_TOOLTIPS_CLAIMED, SanitizationHelper.sanitizeForHtml(Const.Tooltips.CLAIMED), Slots.CONTRIB_TOOLTIPS_PERCEIVED, Const.Tooltips.PERCEIVED, Slots.CONTRIB_TOOLTIPS_POINTS_RECEIVED, Const.Tooltips.FEEDBACK_CONTRIBUTION_POINTS_RECEIVED, Slots.CONTRIB_TOOLTIPS_DIFF, Const.Tooltips.FEEDBACK_CONTRIBUTION_DIFF);
}
Also used : StudentResultSummary(teammates.common.datatransfer.StudentResultSummary) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) TeamEvalResult(teammates.common.datatransfer.TeamEvalResult) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 5 with FeedbackParticipantType

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

the class FieldValidator method getValidityInfoForFeedbackResponseVisibility.

public List<String> getValidityInfoForFeedbackResponseVisibility(List<FeedbackParticipantType> showResponsesTo, List<FeedbackParticipantType> showGiverNameTo, List<FeedbackParticipantType> showRecipientNameTo) {
    Assumption.assertNotNull("Non-null value expected", showResponsesTo);
    Assumption.assertNotNull("Non-null value expected", showGiverNameTo);
    Assumption.assertNotNull("Non-null value expected", showRecipientNameTo);
    Assumption.assertTrue("Non-null value expected", !showResponsesTo.contains(null));
    Assumption.assertTrue("Non-null value expected", !showGiverNameTo.contains(null));
    Assumption.assertTrue("Non-null value expected", !showRecipientNameTo.contains(null));
    List<String> errors = new LinkedList<>();
    for (FeedbackParticipantType type : showGiverNameTo) {
        if (!type.isValidViewer()) {
            errors.add(String.format(PARTICIPANT_TYPE_ERROR_MESSAGE, type.toString(), VIEWER_TYPE_NAME));
        }
        if (!showResponsesTo.contains(type)) {
            errors.add("Trying to show giver name to " + type.toString() + " without showing response first.");
        }
    }
    for (FeedbackParticipantType type : showRecipientNameTo) {
        if (!type.isValidViewer()) {
            errors.add(String.format(PARTICIPANT_TYPE_ERROR_MESSAGE, type.toString(), VIEWER_TYPE_NAME));
        }
        if (!showResponsesTo.contains(type)) {
            errors.add("Trying to show recipient name to " + type.toString() + " without showing response first.");
        }
    }
    for (FeedbackParticipantType type : showResponsesTo) {
        if (!type.isValidViewer()) {
            errors.add(String.format(PARTICIPANT_TYPE_ERROR_MESSAGE, type.toString(), VIEWER_TYPE_NAME));
        }
    }
    return errors;
}
Also used : FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType) LinkedList(java.util.LinkedList)

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