Search in sources :

Example 1 with FeedbackQuestionDetails

use of teammates.common.datatransfer.questions.FeedbackQuestionDetails 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 2 with FeedbackQuestionDetails

use of teammates.common.datatransfer.questions.FeedbackQuestionDetails in project teammates by TEAMMATES.

the class InstructorFeedbackQuestionAddAction method extractFeedbackQuestionData.

private FeedbackQuestionAttributes extractFeedbackQuestionData(String creatorEmail) {
    FeedbackQuestionAttributes newQuestion = new FeedbackQuestionAttributes();
    newQuestion.creatorEmail = creatorEmail;
    newQuestion.courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, newQuestion.courseId);
    newQuestion.feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, newQuestion.feedbackSessionName);
    String feedbackQuestionGiverType = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, feedbackQuestionGiverType);
    newQuestion.giverType = FeedbackParticipantType.valueOf(feedbackQuestionGiverType);
    String feedbackQuestionRecipientType = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, feedbackQuestionRecipientType);
    newQuestion.recipientType = FeedbackParticipantType.valueOf(feedbackQuestionRecipientType);
    String feedbackQuestionNumber = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_NUMBER);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, feedbackQuestionNumber);
    newQuestion.questionNumber = Integer.parseInt(feedbackQuestionNumber);
    Assumption.assertTrue("Invalid question number", newQuestion.questionNumber >= 1);
    String numberOfEntityTypes = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, numberOfEntityTypes);
    if ("custom".equals(numberOfEntityTypes) && (newQuestion.recipientType == FeedbackParticipantType.STUDENTS || newQuestion.recipientType == FeedbackParticipantType.TEAMS)) {
        String numberOfEntities = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIES);
        Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIES, numberOfEntities);
        newQuestion.numberOfEntitiesToGiveFeedbackTo = Integer.parseInt(numberOfEntities);
    } else {
        newQuestion.numberOfEntitiesToGiveFeedbackTo = Const.MAX_POSSIBLE_RECIPIENTS;
    }
    newQuestion.showResponsesTo = FeedbackParticipantType.getParticipantListFromCommaSeparatedValues(getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO));
    newQuestion.showGiverNameTo = FeedbackParticipantType.getParticipantListFromCommaSeparatedValues(getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO));
    newQuestion.showRecipientNameTo = FeedbackParticipantType.getParticipantListFromCommaSeparatedValues(getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO));
    String questionType = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_TYPE);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_QUESTION_TYPE, questionType);
    questionType = FeedbackQuestionType.standardizeIfConstSum(questionType);
    newQuestion.questionType = FeedbackQuestionType.valueOf(questionType);
    FeedbackQuestionDetails questionDetails = FeedbackQuestionDetails.createQuestionDetails(requestParameters, newQuestion.questionType);
    newQuestion.setQuestionDetails(questionDetails);
    String questionDescription = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION);
    newQuestion.setQuestionDescription(new Text(questionDescription));
    return newQuestion;
}
Also used : FeedbackQuestionDetails(teammates.common.datatransfer.questions.FeedbackQuestionDetails) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) Text(com.google.appengine.api.datastore.Text)

Example 3 with FeedbackQuestionDetails

use of teammates.common.datatransfer.questions.FeedbackQuestionDetails in project teammates by TEAMMATES.

the class InstructorFeedbackQuestionEditAction method extractFeedbackQuestionData.

private FeedbackQuestionAttributes extractFeedbackQuestionData() {
    FeedbackQuestionAttributes newQuestion = new FeedbackQuestionAttributes();
    newQuestion.setId(getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID));
    newQuestion.courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID);
    newQuestion.feedbackSessionName = getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    // TODO thoroughly investigate when and why these parameters can be null
    // and check all possibilities in the tests
    // should only be null when deleting. might be good to separate the delete action from this class
    // When editing, usually the following fields are not null. If they are null somehow(edit from browser),
    // Then the field will not update and take on its old value.
    // When deleting, the following fields are null.
    // numofrecipients
    // questiontext
    // numofrecipientstype
    // recipienttype
    // receiverLeaderCheckbox
    // givertype
    // Can be null
    String giverType = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE);
    if (giverType != null) {
        newQuestion.giverType = FeedbackParticipantType.valueOf(giverType);
    }
    // Can be null
    String recipientType = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE);
    if (recipientType != null) {
        newQuestion.recipientType = FeedbackParticipantType.valueOf(recipientType);
    }
    String questionNumber = getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_NUMBER);
    newQuestion.questionNumber = Integer.parseInt(questionNumber);
    Assumption.assertTrue("Invalid question number", newQuestion.questionNumber >= 1);
    // Can be null
    String nEntityTypes = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE);
    if (numberOfEntitiesIsUserDefined(newQuestion.recipientType, nEntityTypes)) {
        String nEntities = getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIES);
        newQuestion.numberOfEntitiesToGiveFeedbackTo = Integer.parseInt(nEntities);
    } else {
        newQuestion.numberOfEntitiesToGiveFeedbackTo = Const.MAX_POSSIBLE_RECIPIENTS;
    }
    newQuestion.showResponsesTo = FeedbackParticipantType.getParticipantListFromCommaSeparatedValues(getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO));
    newQuestion.showGiverNameTo = FeedbackParticipantType.getParticipantListFromCommaSeparatedValues(getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO));
    newQuestion.showRecipientNameTo = FeedbackParticipantType.getParticipantListFromCommaSeparatedValues(getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO));
    String questionType = getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_TYPE);
    newQuestion.questionType = FeedbackQuestionType.valueOf(questionType);
    // Can be null
    String questionText = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_TEXT);
    if (questionText != null && !questionText.isEmpty()) {
        FeedbackQuestionDetails questionDetails = FeedbackQuestionDetails.createQuestionDetails(requestParameters, newQuestion.questionType);
        newQuestion.setQuestionDetails(questionDetails);
    }
    String questionDescription = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION);
    newQuestion.setQuestionDescription(new Text(questionDescription));
    return newQuestion;
}
Also used : FeedbackQuestionDetails(teammates.common.datatransfer.questions.FeedbackQuestionDetails) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) Text(com.google.appengine.api.datastore.Text)

Example 4 with FeedbackQuestionDetails

use of teammates.common.datatransfer.questions.FeedbackQuestionDetails 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 5 with FeedbackQuestionDetails

use of teammates.common.datatransfer.questions.FeedbackQuestionDetails in project teammates by TEAMMATES.

the class InstructorFeedbackResultsPageData method buildMissingResponseRowsBetweenRecipientAndPossibleGivers.

/**
 * Construct missing response rows between the recipient identified by {@code recipientIdentifier} and
 * {@code possibleGivers}.
 */
private List<InstructorFeedbackResultsResponseRow> buildMissingResponseRowsBetweenRecipientAndPossibleGivers(FeedbackQuestionAttributes question, List<String> possibleGivers, String recipientIdentifier, String recipientName, String recipientTeam) {
    List<InstructorFeedbackResultsResponseRow> missingResponses = new ArrayList<>();
    FeedbackQuestionDetails questionDetails = questionToDetailsMap.get(question);
    for (String possibleGiver : possibleGivers) {
        String possibleGiverName = bundle.getFullNameFromRoster(possibleGiver);
        String possibleGiverTeam = bundle.getTeamNameFromRoster(possibleGiver);
        String textToDisplay = questionDetails.getNoResponseTextInHtml(recipientIdentifier, possibleGiver, bundle, question);
        if (questionDetails.shouldShowNoResponseText(question)) {
            InstructorFeedbackResultsModerationButton moderationButton = buildModerationButtonForGiver(question, possibleGiver, "btn btn-default btn-xs", MODERATE_SINGLE_RESPONSE);
            InstructorFeedbackResultsResponseRow missingResponse = new InstructorFeedbackResultsResponseRow(possibleGiverName, possibleGiverTeam, recipientName, recipientTeam, textToDisplay, moderationButton, true);
            missingResponse.setRowAttributes(new ElementTag("class", "pending_response_row"));
            configureResponseRow(possibleGiver, recipientIdentifier, missingResponse);
            missingResponses.add(missingResponse);
        }
    }
    return missingResponses;
}
Also used : InstructorFeedbackResultsResponseRow(teammates.ui.template.InstructorFeedbackResultsResponseRow) FeedbackQuestionDetails(teammates.common.datatransfer.questions.FeedbackQuestionDetails) ArrayList(java.util.ArrayList) InstructorFeedbackResultsModerationButton(teammates.ui.template.InstructorFeedbackResultsModerationButton) ElementTag(teammates.ui.template.ElementTag)

Aggregations

FeedbackQuestionDetails (teammates.common.datatransfer.questions.FeedbackQuestionDetails)18 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)10 ArrayList (java.util.ArrayList)9 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)5 Text (com.google.appengine.api.datastore.Text)4 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)3 ElementTag (teammates.ui.template.ElementTag)3 InstructorFeedbackResultsResponseRow (teammates.ui.template.InstructorFeedbackResultsResponseRow)3 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)2 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)2 StatusMessage (teammates.common.util.StatusMessage)2 FeedbackResultsResponseTable (teammates.ui.template.FeedbackResultsResponseTable)2 InstructorFeedbackResultsModerationButton (teammates.ui.template.InstructorFeedbackResultsModerationButton)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Test (org.testng.annotations.Test)1