Search in sources :

Example 61 with FeedbackResponseAttributes

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

the class FeedbackSessionsLogic method getFeedbackSessionResultsSummaryInSectionAsCsv.

public String getFeedbackSessionResultsSummaryInSectionAsCsv(String feedbackSessionName, String courseId, String userEmail, String section, String questionId, boolean isMissingResponsesShown, boolean isStatsShown) throws EntityDoesNotExistException, ExceedingRangeException {
    FeedbackSessionResultsBundle results;
    int indicatedRange = section == null ? Const.INSTRUCTOR_VIEW_RESPONSE_LIMIT : -1;
    if (questionId == null) {
        results = getFeedbackSessionResultsForInstructorInSectionWithinRangeFromView(feedbackSessionName, courseId, userEmail, section, indicatedRange, Const.FeedbackSessionResults.GRQ_SORT_TYPE);
    } else if (section == null) {
        results = getFeedbackSessionResultsForInstructorFromQuestion(feedbackSessionName, courseId, userEmail, questionId);
    } else {
        results = getFeedbackSessionResultsForInstructorFromQuestionInSection(feedbackSessionName, courseId, userEmail, questionId, section);
    }
    if (!results.isComplete) {
        throw new ExceedingRangeException(ERROR_NUMBER_OF_RESPONSES_EXCEEDS_RANGE);
    }
    // sort responses by giver > recipient > qnNumber
    results.responses.sort(results.compareByGiverRecipientQuestion);
    StringBuilder exportBuilder = new StringBuilder(100);
    exportBuilder.append(String.format("Course,%s", SanitizationHelper.sanitizeForCsv(results.feedbackSession.getCourseId()))).append(System.lineSeparator()).append(String.format("Session Name,%s", SanitizationHelper.sanitizeForCsv(results.feedbackSession.getFeedbackSessionName()))).append(System.lineSeparator());
    if (section != null) {
        exportBuilder.append(String.format("Section Name,%s", SanitizationHelper.sanitizeForCsv(section))).append(System.lineSeparator());
    }
    exportBuilder.append(System.lineSeparator()).append(System.lineSeparator());
    Set<Entry<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>>> entrySet = results.getQuestionResponseMap().entrySet();
    for (Map.Entry<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> entry : entrySet) {
        exportBuilder.append(getFeedbackSessionResultsForQuestionInCsvFormat(results, entry, isMissingResponsesShown, isStatsShown, section));
    }
    return exportBuilder.toString();
}
Also used : Entry(java.util.Map.Entry) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ExceedingRangeException(teammates.common.exception.ExceedingRangeException) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) FeedbackSessionResultsBundle(teammates.common.datatransfer.FeedbackSessionResultsBundle)

Example 62 with FeedbackResponseAttributes

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

the class FeedbackResponseAdjustmentWorkerAction method execute.

@Override
public void execute() {
    String courseId = getRequestParamValue(ParamsNames.COURSE_ID);
    Assumption.assertPostParamNotNull(ParamsNames.COURSE_ID, courseId);
    String sessionName = getRequestParamValue(ParamsNames.FEEDBACK_SESSION_NAME);
    Assumption.assertPostParamNotNull(ParamsNames.FEEDBACK_SESSION_NAME, sessionName);
    String enrollmentDetails = getRequestParamValue(ParamsNames.ENROLLMENT_DETAILS);
    Assumption.assertPostParamNotNull(ParamsNames.ENROLLMENT_DETAILS, enrollmentDetails);
    log.info("Adjusting submissions for feedback session :" + sessionName + "in course : " + courseId);
    FeedbackSessionAttributes feedbackSession = logic.getFeedbackSession(sessionName, courseId);
    String errorString = "Error encountered while adjusting feedback session responses of %s in course %s: %s%n%s";
    if (feedbackSession == null) {
        log.severe(String.format(errorString, sessionName, courseId, "feedback session is null", ""));
        setForRetry();
        return;
    }
    List<FeedbackResponseAttributes> allResponses = logic.getFeedbackResponsesForSession(feedbackSession.getFeedbackSessionName(), feedbackSession.getCourseId());
    List<StudentEnrollDetails> enrollmentList = JsonUtils.fromJson(enrollmentDetails, new TypeToken<List<StudentEnrollDetails>>() {
    }.getType());
    for (FeedbackResponseAttributes response : allResponses) {
        try {
            logic.adjustFeedbackResponseForEnrollments(enrollmentList, response);
        } catch (Exception e) {
            String url = HttpRequestHelper.getRequestedUrl(request);
            Map<String, String[]> params = HttpRequestHelper.getParameterMap(request);
            // no logged-in user for worker
            String logMessage = new LogMessageGenerator().generateActionFailureLogMessage(url, params, e, null);
            log.severe(String.format(errorString, sessionName, courseId, e.getMessage(), logMessage));
            setForRetry();
            return;
        }
    }
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) TypeToken(com.google.gson.reflect.TypeToken) LogMessageGenerator(teammates.common.util.LogMessageGenerator) StudentEnrollDetails(teammates.common.datatransfer.StudentEnrollDetails) Map(java.util.Map)

Example 63 with FeedbackResponseAttributes

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

the class StudentsLogicTest method testAdjustFeedbackResponseForEnrollments.

private void testAdjustFeedbackResponseForEnrollments() throws Exception {
    // the case below will not cause the response to be deleted
    // because the studentEnrollDetails'email is not the same as giver or recipient
    ______TS("adjust feedback response: no change of team");
    String course1Id = dataBundle.courses.get("typicalCourse1").getId();
    StudentAttributes student1InCourse1 = dataBundle.students.get("student1InCourse1");
    StudentAttributes student2InCourse1 = dataBundle.students.get("student2InCourse1");
    ArrayList<StudentEnrollDetails> enrollmentList = new ArrayList<>();
    StudentEnrollDetails studentDetails1 = new StudentEnrollDetails(StudentUpdateStatus.MODIFIED, course1Id, student1InCourse1.email, student1InCourse1.team, student1InCourse1.team + "tmp", student1InCourse1.section, student1InCourse1.section + "tmp");
    enrollmentList.add(studentDetails1);
    FeedbackResponseAttributes feedbackResponse1InBundle = dataBundle.feedbackResponses.get("response1ForQ2S2C1");
    FeedbackResponsesLogic frLogic = FeedbackResponsesLogic.inst();
    FeedbackQuestionsLogic fqLogic = FeedbackQuestionsLogic.inst();
    FeedbackQuestionAttributes feedbackQuestionInDb = fqLogic.getFeedbackQuestion(feedbackResponse1InBundle.feedbackSessionName, feedbackResponse1InBundle.courseId, Integer.parseInt(feedbackResponse1InBundle.feedbackQuestionId));
    FeedbackResponseAttributes responseBefore = frLogic.getFeedbackResponse(feedbackQuestionInDb.getId(), feedbackResponse1InBundle.giver, feedbackResponse1InBundle.recipient);
    studentsLogic.adjustFeedbackResponseForEnrollments(enrollmentList, responseBefore);
    FeedbackResponseAttributes responseAfter = frLogic.getFeedbackResponse(feedbackQuestionInDb.getId(), feedbackResponse1InBundle.giver, feedbackResponse1InBundle.recipient);
    assertEquals(responseBefore.getId(), responseAfter.getId());
    // the case below will not cause the response to be deleted
    // because the studentEnrollDetails'email is not the same as giver or recipient
    ______TS("adjust feedback response: unmodified status");
    enrollmentList = new ArrayList<>();
    studentDetails1 = new StudentEnrollDetails(StudentUpdateStatus.UNMODIFIED, course1Id, student1InCourse1.email, student1InCourse1.team, student1InCourse1.team + "tmp", student1InCourse1.section, student1InCourse1.section + "tmp");
    enrollmentList.add(studentDetails1);
    feedbackQuestionInDb = fqLogic.getFeedbackQuestion(feedbackResponse1InBundle.feedbackSessionName, feedbackResponse1InBundle.courseId, Integer.parseInt(feedbackResponse1InBundle.feedbackQuestionId));
    responseBefore = frLogic.getFeedbackResponse(feedbackQuestionInDb.getId(), feedbackResponse1InBundle.giver, feedbackResponse1InBundle.recipient);
    studentsLogic.adjustFeedbackResponseForEnrollments(enrollmentList, responseBefore);
    responseAfter = frLogic.getFeedbackResponse(feedbackQuestionInDb.getId(), feedbackResponse1InBundle.giver, feedbackResponse1InBundle.recipient);
    assertEquals(responseBefore.getId(), responseAfter.getId());
    // the code below will cause the feedback to be deleted because
    // recipient's e-mail is the same as the one in studentEnrollDetails
    // and the question's recipient's type is own team members
    ______TS("adjust feedback response: delete after adjustment");
    studentDetails1 = new StudentEnrollDetails(StudentUpdateStatus.MODIFIED, course1Id, student2InCourse1.email, student1InCourse1.team, student1InCourse1.team + "tmp", student1InCourse1.section, student1InCourse1.section + "tmp");
    enrollmentList = new ArrayList<>();
    enrollmentList.add(studentDetails1);
    feedbackQuestionInDb = fqLogic.getFeedbackQuestion(feedbackResponse1InBundle.feedbackSessionName, feedbackResponse1InBundle.courseId, Integer.parseInt(feedbackResponse1InBundle.feedbackQuestionId));
    responseBefore = frLogic.getFeedbackResponse(feedbackQuestionInDb.getId(), feedbackResponse1InBundle.giver, feedbackResponse1InBundle.recipient);
    studentsLogic.adjustFeedbackResponseForEnrollments(enrollmentList, responseBefore);
    responseAfter = frLogic.getFeedbackResponse(feedbackQuestionInDb.getId(), feedbackResponse1InBundle.giver, feedbackResponse1InBundle.recipient);
    assertNull(responseAfter);
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) FeedbackResponsesLogic(teammates.logic.core.FeedbackResponsesLogic) FeedbackQuestionsLogic(teammates.logic.core.FeedbackQuestionsLogic) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) StudentEnrollDetails(teammates.common.datatransfer.StudentEnrollDetails) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 64 with FeedbackResponseAttributes

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

the class FeedbackSubmissionEditPageDataTest method setDummyQuestionId.

private void setDummyQuestionId(FeedbackQuestionAttributes question, List<FeedbackResponseAttributes> responses) {
    String dummyQuestionId = "dummy";
    question.setId(dummyQuestionId);
    for (FeedbackResponseAttributes response : responses) {
        response.feedbackQuestionId = dummyQuestionId;
    }
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes)

Example 65 with FeedbackResponseAttributes

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

the class FeedbackResponseCommentsLogicTest method getResponseIdInDataBundle.

private String getResponseIdInDataBundle(String responseInDataBundle, String questionInDataBundle) {
    FeedbackResponseAttributes response = dataBundle.feedbackResponses.get(responseInDataBundle);
    response = frLogic.getFeedbackResponse(getQuestionIdInDataBundle(questionInDataBundle), response.giver, response.recipient);
    return response.getId();
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes)

Aggregations

FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)143 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)70 ArrayList (java.util.ArrayList)63 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)36 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)35 List (java.util.List)29 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)28 HashMap (java.util.HashMap)27 FeedbackResponseCommentAttributes (teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes)22 HashSet (java.util.HashSet)20 LinkedHashMap (java.util.LinkedHashMap)20 Map (java.util.Map)18 Test (org.testng.annotations.Test)18 FeedbackQuestionsDb (teammates.storage.api.FeedbackQuestionsDb)18 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)18 Text (com.google.appengine.api.datastore.Text)15 Set (java.util.Set)11 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)10 Comparator (java.util.Comparator)9 FeedbackParticipantType (teammates.common.datatransfer.FeedbackParticipantType)9