Search in sources :

Example 1 with FeedbackSessionDetailsBundle

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

the class InstructorFeedbackQuestionEditActionTest method testExecuteAndPostProcessResponseRate.

@Test
public void testExecuteAndPostProcessResponseRate() throws Exception {
    removeAndRestoreTypicalDataBundle();
    gaeSimulation.loginAsInstructor(typicalBundle.instructors.get("instructor1OfCourse1").googleId);
    FeedbackSessionsLogic fsLogic = FeedbackSessionsLogic.inst();
    FeedbackQuestionsLogic fqLogic = FeedbackQuestionsLogic.inst();
    FeedbackSessionAttributes fs = typicalBundle.feedbackSessions.get("session1InCourse1");
    int numStudentRespondents = 3;
    int numInstructorRespondents = 1;
    int totalStudents = 5;
    int totalInstructors = 5;
    ______TS("Check response rate before editing question 1");
    fs = fsLogic.getFeedbackSession(fs.getFeedbackSessionName(), fs.getCourseId());
    FeedbackSessionDetailsBundle details = fsLogic.getFeedbackSessionDetails(fs);
    assertEquals(numStudentRespondents + numInstructorRespondents, details.stats.submittedTotal);
    assertEquals(totalStudents + totalInstructors, details.stats.expectedTotal);
    ______TS("Change the feedback path of a question with no unique respondents");
    FeedbackQuestionAttributes fq = fqLogic.getFeedbackQuestion(fs.getFeedbackSessionName(), fs.getCourseId(), 1);
    String[] params1 = { Const.ParamsNames.COURSE_ID, fq.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, fq.feedbackSessionName, Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, Integer.toString(fq.questionNumber), Const.ParamsNames.FEEDBACK_QUESTION_TYPE, fq.getQuestionType().toString(), Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "What is the best selling point of your product?", Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION, "more details", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "1", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit", Const.ParamsNames.FEEDBACK_QUESTION_ID, fq.getId() };
    InstructorFeedbackQuestionEditAction a = getAction(params1);
    a.executeAndPostProcess();
    // Response rate should not change because other questions have the same respondents
    fs = fsLogic.getFeedbackSession(fs.getFeedbackSessionName(), fs.getCourseId());
    details = fsLogic.getFeedbackSessionDetails(fs);
    assertEquals(numStudentRespondents + numInstructorRespondents, details.stats.submittedTotal);
    assertEquals(totalStudents + totalInstructors, details.stats.expectedTotal);
    ______TS("Change the feedback path of a question with a unique instructor respondent");
    fq = fqLogic.getFeedbackQuestion(fs.getFeedbackSessionName(), fs.getCourseId(), 3);
    String[] params3 = { Const.ParamsNames.COURSE_ID, fq.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, fq.feedbackSessionName, Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, fq.getGiverType().toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, Integer.toString(fq.questionNumber), Const.ParamsNames.FEEDBACK_QUESTION_TYPE, fq.getQuestionType().toString(), Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "My comments on the class", Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION, "more details", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "1", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit", Const.ParamsNames.FEEDBACK_QUESTION_ID, fq.getId() };
    a = getAction(params3);
    a.executeAndPostProcess();
    // Response rate should decrease by 1 because the response of the unique instructor respondent is deleted
    fs = fsLogic.getFeedbackSession(fs.getFeedbackSessionName(), fs.getCourseId());
    details = fsLogic.getFeedbackSessionDetails(fs);
    assertEquals(numStudentRespondents, details.stats.submittedTotal);
    assertEquals(totalStudents + totalInstructors, details.stats.expectedTotal);
    ______TS("Change the feedback path of a question so that some possible respondents are removed");
    fq = fqLogic.getFeedbackQuestion(fs.getFeedbackSessionName(), fs.getCourseId(), 4);
    String[] params4 = { Const.ParamsNames.COURSE_ID, fq.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, fq.feedbackSessionName, Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, FeedbackParticipantType.NONE.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, Integer.toString(fq.questionNumber), Const.ParamsNames.FEEDBACK_QUESTION_TYPE, fq.getQuestionType().toString(), Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "Instructor comments on the class", Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION, "more details", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "1", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit", Const.ParamsNames.FEEDBACK_QUESTION_ID, fq.getId() };
    a = getAction(params4);
    a.executeAndPostProcess();
    // Total possible respondents should decrease because instructors
    // (except session creator) are no longer possible respondents
    fs = fsLogic.getFeedbackSession(fs.getFeedbackSessionName(), fs.getCourseId());
    details = fsLogic.getFeedbackSessionDetails(fs);
    assertEquals(numStudentRespondents, details.stats.submittedTotal);
    assertEquals(totalStudents + 1, details.stats.expectedTotal);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) InstructorFeedbackQuestionEditAction(teammates.ui.controller.InstructorFeedbackQuestionEditAction) FeedbackSessionsLogic(teammates.logic.core.FeedbackSessionsLogic) FeedbackQuestionsLogic(teammates.logic.core.FeedbackQuestionsLogic) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) FeedbackSessionDetailsBundle(teammates.common.datatransfer.FeedbackSessionDetailsBundle) Test(org.testng.annotations.Test)

Example 2 with FeedbackSessionDetailsBundle

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

the class StudentHomePageData method createSessionRows.

private List<HomeFeedbackSessionRow> createSessionRows(List<FeedbackSessionDetailsBundle> feedbackSessions, Map<FeedbackSessionAttributes, Boolean> sessionSubmissionStatusMap, int startingSessionIdx) {
    List<HomeFeedbackSessionRow> rows = new ArrayList<>();
    int sessionIdx = startingSessionIdx;
    for (FeedbackSessionDetailsBundle session : feedbackSessions) {
        FeedbackSessionAttributes feedbackSession = session.feedbackSession;
        String sessionName = feedbackSession.getFeedbackSessionName();
        boolean hasSubmitted = sessionSubmissionStatusMap.get(feedbackSession);
        rows.add(new StudentHomeFeedbackSessionRow(PageData.sanitizeForHtml(sessionName), getStudentSubmissionsTooltipForSession(feedbackSession, hasSubmitted), getStudentPublishedTooltipForSession(feedbackSession), getStudentSubmissionStatusForSession(feedbackSession, hasSubmitted), getStudentPublishedStatusForSession(feedbackSession), TimeHelper.formatDateTimeForSessions(feedbackSession.getEndTime(), feedbackSession.getTimeZone()), feedbackSession.getEndTimeInIso8601UtcFormat(), getStudentFeedbackSessionActions(feedbackSession, hasSubmitted), sessionIdx));
        ++sessionIdx;
    }
    return rows;
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) StudentHomeFeedbackSessionRow(teammates.ui.template.StudentHomeFeedbackSessionRow) HomeFeedbackSessionRow(teammates.ui.template.HomeFeedbackSessionRow) StudentHomeFeedbackSessionRow(teammates.ui.template.StudentHomeFeedbackSessionRow) ArrayList(java.util.ArrayList) FeedbackSessionDetailsBundle(teammates.common.datatransfer.FeedbackSessionDetailsBundle)

Example 3 with FeedbackSessionDetailsBundle

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

the class FeedbackSessionsLogic method getFeedbackSessionDetailsForCourse.

private List<FeedbackSessionDetailsBundle> getFeedbackSessionDetailsForCourse(String courseId, String instructorEmail) throws EntityDoesNotExistException {
    List<FeedbackSessionDetailsBundle> fsDetailsWithoutPrivate = new ArrayList<>();
    List<FeedbackSessionAttributes> fsInCourse = fsDb.getFeedbackSessionsForCourse(courseId);
    for (FeedbackSessionAttributes fsa : fsInCourse) {
        if (!fsa.isPrivateSession() || fsa.isCreator(instructorEmail)) {
            fsDetailsWithoutPrivate.add(getFeedbackSessionDetails(fsa));
        }
    }
    return fsDetailsWithoutPrivate;
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) ArrayList(java.util.ArrayList) FeedbackSessionDetailsBundle(teammates.common.datatransfer.FeedbackSessionDetailsBundle)

Example 4 with FeedbackSessionDetailsBundle

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

the class FeedbackSessionsLogic method getFeedbackSessionDetailsForInstructor.

/**
 * Returns a {@code List} of all feedback sessions bundled with their
 * response statistics for a instructor given by his googleId.<br>
 * Does not return private sessions unless the instructor is the creator.
 * <br>
 * Omits archived sessions if omitArchived == true
 */
public List<FeedbackSessionDetailsBundle> getFeedbackSessionDetailsForInstructor(String googleId, boolean omitArchived) throws EntityDoesNotExistException {
    List<FeedbackSessionDetailsBundle> fsDetails = new ArrayList<>();
    List<InstructorAttributes> instructors = instructorsLogic.getInstructorsForGoogleId(googleId, omitArchived);
    for (InstructorAttributes instructor : instructors) {
        fsDetails.addAll(getFeedbackSessionDetailsForCourse(instructor.courseId, instructor.email));
    }
    return fsDetails;
}
Also used : ArrayList(java.util.ArrayList) FeedbackSessionDetailsBundle(teammates.common.datatransfer.FeedbackSessionDetailsBundle) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Example 5 with FeedbackSessionDetailsBundle

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

the class FeedbackSessionsLogicTest method testGetFeedbackSessionDetailsForInstructor.

private void testGetFeedbackSessionDetailsForInstructor() throws Exception {
    // This file contains a session with a private session + a standard
    // session + a special session with all questions without recipients.
    DataBundle newDataBundle = loadDataBundle("/FeedbackSessionDetailsTest.json");
    removeAndRestoreDataBundle(newDataBundle);
    Map<String, FeedbackSessionDetailsBundle> detailsMap = new HashMap<>();
    String instrGoogleId = newDataBundle.instructors.get("instructor1OfCourse1").googleId;
    List<FeedbackSessionDetailsBundle> detailsList = fsLogic.getFeedbackSessionDetailsForInstructor(instrGoogleId);
    List<String> expectedSessions = new ArrayList<>();
    expectedSessions.add(newDataBundle.feedbackSessions.get("standard.session").toString());
    expectedSessions.add(newDataBundle.feedbackSessions.get("no.responses.session").toString());
    expectedSessions.add(newDataBundle.feedbackSessions.get("no.recipients.session").toString());
    expectedSessions.add(newDataBundle.feedbackSessions.get("private.session").toString());
    StringBuilder actualSessionsBuilder = new StringBuilder();
    for (FeedbackSessionDetailsBundle details : detailsList) {
        actualSessionsBuilder.append(details.feedbackSession.toString());
        detailsMap.put(details.feedbackSession.getFeedbackSessionName() + "%" + details.feedbackSession.getCourseId(), details);
    }
    String actualSessions = actualSessionsBuilder.toString();
    ______TS("standard session");
    assertEquals(4, detailsList.size());
    AssertHelper.assertContains(expectedSessions, actualSessions);
    FeedbackSessionStats stats = detailsMap.get(newDataBundle.feedbackSessions.get("standard.session").getFeedbackSessionName() + "%" + newDataBundle.feedbackSessions.get("standard.session").getCourseId()).stats;
    // 2 instructors, 6 students = 8
    assertEquals(8, stats.expectedTotal);
    // 1 instructor, 1 student, did not respond => 8-2=6
    assertEquals(6, stats.submittedTotal);
    ______TS("No recipients session");
    stats = detailsMap.get(newDataBundle.feedbackSessions.get("no.recipients.session").getFeedbackSessionName() + "%" + newDataBundle.feedbackSessions.get("no.recipients.session").getCourseId()).stats;
    // 2 instructors, 6 students = 8
    assertEquals(8, stats.expectedTotal);
    // only 1 student responded
    assertEquals(1, stats.submittedTotal);
    ______TS("No responses session");
    stats = detailsMap.get(newDataBundle.feedbackSessions.get("no.responses.session").getFeedbackSessionName() + "%" + newDataBundle.feedbackSessions.get("no.responses.session").getCourseId()).stats;
    // 1 instructors, 1 students = 2
    assertEquals(2, stats.expectedTotal);
    // no responses
    assertEquals(0, stats.submittedTotal);
    ______TS("private session with questions");
    stats = detailsMap.get(newDataBundle.feedbackSessions.get("private.session").getFeedbackSessionName() + "%" + newDataBundle.feedbackSessions.get("private.session").getCourseId()).stats;
    assertEquals(1, stats.expectedTotal);
    // For private sessions, we mark as completed only when creator has finished all questions.
    assertEquals(0, stats.submittedTotal);
    ______TS("change private session to non-private");
    FeedbackSessionAttributes privateSession = newDataBundle.feedbackSessions.get("private.session");
    privateSession.setSessionVisibleFromTime(privateSession.getStartTime());
    privateSession.setEndTime(TimeHelper.parseInstant("2015-04-01 2:00 PM +0000"));
    privateSession.setFeedbackSessionType(FeedbackSessionType.STANDARD);
    fsLogic.updateFeedbackSession(privateSession);
    // Re-read details
    detailsList = fsLogic.getFeedbackSessionDetailsForInstructor(newDataBundle.instructors.get("instructor1OfCourse1").googleId);
    for (FeedbackSessionDetailsBundle details : detailsList) {
        if (details.feedbackSession.getFeedbackSessionName().equals(newDataBundle.feedbackSessions.get("private.session").getFeedbackSessionName())) {
            stats = details.stats;
            break;
        }
    }
    // 1 instructor (creator only), 6 students = 8
    assertEquals(7, stats.expectedTotal);
    // 1 instructor, 1 student responded
    assertEquals(2, stats.submittedTotal);
    ______TS("private session without questions");
    expectedSessions.clear();
    expectedSessions.add(newDataBundle.feedbackSessions.get("private.session.noquestions").toString());
    expectedSessions.add(newDataBundle.feedbackSessions.get("private.session.done").toString());
    detailsList = fsLogic.getFeedbackSessionDetailsForInstructor(newDataBundle.instructors.get("instructor2OfCourse1").googleId);
    detailsMap.clear();
    actualSessionsBuilder = new StringBuilder();
    for (FeedbackSessionDetailsBundle details : detailsList) {
        actualSessionsBuilder.append(details.feedbackSession.toString());
        detailsMap.put(details.feedbackSession.getFeedbackSessionName() + "%" + details.feedbackSession.getCourseId(), details);
    }
    actualSessions = actualSessionsBuilder.toString();
    AssertHelper.assertContains(expectedSessions, actualSessions);
    stats = detailsMap.get(newDataBundle.feedbackSessions.get("private.session.noquestions").getFeedbackSessionName() + "%" + newDataBundle.feedbackSessions.get("private.session.noquestions").getCourseId()).stats;
    assertEquals(0, stats.expectedTotal);
    assertEquals(0, stats.submittedTotal);
    ______TS("completed private session");
    stats = detailsMap.get(newDataBundle.feedbackSessions.get("private.session.done").getFeedbackSessionName() + "%" + newDataBundle.feedbackSessions.get("private.session.done").getCourseId()).stats;
    assertEquals(1, stats.expectedTotal);
    assertEquals(1, stats.submittedTotal);
    ______TS("private session with questions with no recipients");
    expectedSessions.clear();
    expectedSessions.add(newDataBundle.feedbackSessions.get("private.session.norecipients").toString());
    detailsList = fsLogic.getFeedbackSessionDetailsForInstructor(newDataBundle.instructors.get("instructor1OfCourse3").googleId);
    detailsMap.clear();
    actualSessions = "";
    actualSessionsBuilder = new StringBuilder();
    for (FeedbackSessionDetailsBundle details : detailsList) {
        actualSessionsBuilder.append(details.feedbackSession.toString());
        detailsMap.put(details.feedbackSession.getFeedbackSessionName() + "%" + details.feedbackSession.getCourseId(), details);
    }
    actualSessions = actualSessionsBuilder.toString();
    AssertHelper.assertContains(expectedSessions, actualSessions);
    stats = detailsMap.get(newDataBundle.feedbackSessions.get("private.session.norecipients").getFeedbackSessionName() + "%" + newDataBundle.feedbackSessions.get("private.session.norecipients").getCourseId()).stats;
    assertEquals(0, stats.expectedTotal);
    assertEquals(0, stats.submittedTotal);
    ______TS("instructor does not exist");
    assertTrue(fsLogic.getFeedbackSessionDetailsForInstructor("non-existent.google.id").isEmpty());
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackSessionStats(teammates.common.datatransfer.FeedbackSessionStats) DataBundle(teammates.common.datatransfer.DataBundle) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FeedbackSessionDetailsBundle(teammates.common.datatransfer.FeedbackSessionDetailsBundle)

Aggregations

FeedbackSessionDetailsBundle (teammates.common.datatransfer.FeedbackSessionDetailsBundle)8 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)2 CourseDetailsBundle (teammates.common.datatransfer.CourseDetailsBundle)2 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)2 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)2 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)2 Test (org.testng.annotations.Test)1 DataBundle (teammates.common.datatransfer.DataBundle)1 FeedbackSessionStats (teammates.common.datatransfer.FeedbackSessionStats)1 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)1 FeedbackQuestionsLogic (teammates.logic.core.FeedbackQuestionsLogic)1 FeedbackSessionsLogic (teammates.logic.core.FeedbackSessionsLogic)1 InstructorFeedbackQuestionEditAction (teammates.ui.controller.InstructorFeedbackQuestionEditAction)1 HomeFeedbackSessionRow (teammates.ui.template.HomeFeedbackSessionRow)1 StudentHomeFeedbackSessionRow (teammates.ui.template.StudentHomeFeedbackSessionRow)1