Search in sources :

Example 66 with FeedbackQuestionAttributes

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

the class FeedbackSubmissionEditPageData method createQuestionsWithResponses.

private void createQuestionsWithResponses() {
    questionsWithResponses = new ArrayList<>();
    int qnIndx = 1;
    for (FeedbackQuestionAttributes questionAttributes : bundle.getSortedQuestions()) {
        int numOfResponseBoxes = questionAttributes.numberOfEntitiesToGiveFeedbackTo;
        int maxResponsesPossible = bundle.recipientList.get(questionAttributes.getId()).size();
        if (numOfResponseBoxes == Const.MAX_POSSIBLE_RECIPIENTS || numOfResponseBoxes > maxResponsesPossible) {
            numOfResponseBoxes = maxResponsesPossible;
        }
        FeedbackSubmissionEditQuestion question = createQuestion(questionAttributes, qnIndx);
        List<FeedbackSubmissionEditResponse> responses = createResponses(questionAttributes, qnIndx, numOfResponseBoxes);
        questionsWithResponses.add(new StudentFeedbackSubmissionEditQuestionsWithResponses(question, responses, numOfResponseBoxes, maxResponsesPossible));
        qnIndx++;
    }
}
Also used : FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) FeedbackSubmissionEditQuestion(teammates.ui.template.FeedbackSubmissionEditQuestion) FeedbackSubmissionEditResponse(teammates.ui.template.FeedbackSubmissionEditResponse) StudentFeedbackSubmissionEditQuestionsWithResponses(teammates.ui.template.StudentFeedbackSubmissionEditQuestionsWithResponses)

Example 67 with FeedbackQuestionAttributes

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

the class StudentFeedbackResultsPageAction method execute.

@Override
protected ActionResult execute() throws EntityDoesNotExistException {
    String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    if (courseId == null || feedbackSessionName == null) {
        return createRedirectResult(Const.ActionURIs.STUDENT_HOME_PAGE);
    }
    if (!isJoinedCourse(courseId)) {
        return createPleaseJoinCourseResponse(courseId);
    }
    gateKeeper.verifyAccessible(getCurrentStudent(courseId), logic.getFeedbackSession(feedbackSessionName, courseId));
    StudentFeedbackResultsPageData data = new StudentFeedbackResultsPageData(account, student, sessionToken);
    data.student = getCurrentStudent(courseId);
    data.setBundle(logic.getFeedbackSessionResultsForStudent(feedbackSessionName, courseId, data.student.email));
    if (data.getBundle() == null) {
        // leave this here as a safety net on the off cases that GateKeeper fails to catch the Exception
        throw new EntityDoesNotExistException("Feedback session " + feedbackSessionName + " does not exist in " + courseId + ".");
    }
    if (!data.getBundle().feedbackSession.isPublished()) {
        throw new UnauthorizedAccessException("This feedback session is not yet visible.");
    }
    if (data.getBundle().isStudentHasSomethingNewToSee(data.student)) {
        statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_RESULTS_SOMETHINGNEW, StatusMessageColor.INFO));
    } else {
        statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_RESULTS_NOTHINGNEW, StatusMessageColor.WARNING));
    }
    statusToAdmin = "Show student feedback result page<br>" + "Session Name: " + feedbackSessionName + "<br>" + "Course ID: " + courseId;
    Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> questionsWithResponses = data.getBundle().getQuestionResponseMapSortedByRecipient();
    data.init(questionsWithResponses);
    return createShowPageResult(Const.ViewURIs.STUDENT_FEEDBACK_RESULTS, data);
}
Also used : UnauthorizedAccessException(teammates.common.exception.UnauthorizedAccessException) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) List(java.util.List) StudentFeedbackResultsPageData(teammates.ui.pagedata.StudentFeedbackResultsPageData) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException) StatusMessage(teammates.common.util.StatusMessage)

Example 68 with FeedbackQuestionAttributes

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

the class FeedbackQuestionsLogic method shiftQuestionNumbersDown.

// Shifts all question numbers after questionNumberToShiftFrom down by one.
private void shiftQuestionNumbersDown(int questionNumberToShiftFrom, List<FeedbackQuestionAttributes> questionsToShift) {
    for (FeedbackQuestionAttributes question : questionsToShift) {
        if (question.questionNumber > questionNumberToShiftFrom) {
            question.questionNumber -= 1;
            updateFeedbackQuestionWithoutResponseRateUpdate(question);
        }
    }
}
Also used : FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Example 69 with FeedbackQuestionAttributes

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

the class FeedbackResponsesLogic method updateFeedbackResponseForChangingTeam.

public boolean updateFeedbackResponseForChangingTeam(StudentEnrollDetails enrollment, FeedbackResponseAttributes response) throws InvalidParametersException, EntityDoesNotExistException {
    FeedbackQuestionAttributes question = fqLogic.getFeedbackQuestion(response.feedbackQuestionId);
    boolean isGiverSameForResponseAndEnrollment = response.giver.equals(enrollment.email);
    boolean isReceiverSameForResponseAndEnrollment = response.recipient.equals(enrollment.email);
    boolean shouldDeleteByChangeOfGiver = isGiverSameForResponseAndEnrollment && (question.giverType == FeedbackParticipantType.TEAMS || isRecipientTypeTeamMembers(question));
    boolean shouldDeleteByChangeOfRecipient = isReceiverSameForResponseAndEnrollment && isRecipientTypeTeamMembers(question);
    boolean shouldDeleteResponse = shouldDeleteByChangeOfGiver || shouldDeleteByChangeOfRecipient;
    if (shouldDeleteResponse) {
        frDb.deleteEntity(response);
        updateSessionResponseRateForDeletingStudentResponse(enrollment.email, response.feedbackSessionName, enrollment.course);
    }
    return shouldDeleteResponse;
}
Also used : FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Example 70 with FeedbackQuestionAttributes

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

the class FeedbackResponsesLogic method deleteResponsesFromUserToTeam.

private void deleteResponsesFromUserToTeam(String courseId, String userEmail) {
    FeedbackQuestionAttributes question;
    List<FeedbackResponseAttributes> responsesFromUser = getFeedbackResponsesFromGiverForCourse(courseId, userEmail);
    for (FeedbackResponseAttributes response : responsesFromUser) {
        question = fqLogic.getFeedbackQuestion(response.feedbackQuestionId);
        if (question.giverType == FeedbackParticipantType.TEAMS || isRecipientTypeTeamMembers(question)) {
            frDb.deleteEntity(response);
        }
    }
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) 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