Search in sources :

Example 76 with FeedbackQuestionAttributes

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

the class FeedbackSessionsLogicTest method getQuestionFromDatastore.

private FeedbackQuestionAttributes getQuestionFromDatastore(String jsonId) {
    FeedbackQuestionAttributes questionToGet = dataBundle.feedbackQuestions.get(jsonId);
    questionToGet = fqLogic.getFeedbackQuestion(questionToGet.feedbackSessionName, questionToGet.courseId, questionToGet.questionNumber);
    return questionToGet;
}
Also used : FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Example 77 with FeedbackQuestionAttributes

use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes 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 78 with FeedbackQuestionAttributes

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

the class FeedbackQuestionsLogicTest method testIsQuestionHasResponses.

private void testIsQuestionHasResponses() {
    FeedbackQuestionAttributes questionWithResponse;
    FeedbackQuestionAttributes questionWithoutResponse;
    ______TS("Check that a question has some responses");
    questionWithResponse = getQuestionFromDatastore("qn1InSession2InCourse2");
    assertTrue(fqLogic.areThereResponsesForQuestion(questionWithResponse.getId()));
    ______TS("Check that a question has no responses");
    questionWithoutResponse = getQuestionFromDatastore("qn2InSession2InCourse2");
    assertFalse(fqLogic.areThereResponsesForQuestion(questionWithoutResponse.getId()));
}
Also used : FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Example 79 with FeedbackQuestionAttributes

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

the class FeedbackQuestionsLogicTest method testDeleteQuestionsForCourse.

private void testDeleteQuestionsForCourse() throws EntityDoesNotExistException {
    ______TS("standard case");
    // test that questions are deleted
    String courseId = "idOfTypicalCourse2";
    FeedbackQuestionAttributes deletedQuestion = getQuestionFromDatastore("qn1InSession2InCourse2");
    assertNotNull(deletedQuestion);
    List<FeedbackQuestionAttributes> questions = fqLogic.getFeedbackQuestionsForSession("Instructor feedback session", courseId);
    assertFalse(questions.isEmpty());
    questions = fqLogic.getFeedbackQuestionsForSession("Private feedback session", courseId);
    assertFalse(questions.isEmpty());
    fqLogic.deleteFeedbackQuestionsForCourse(courseId);
    deletedQuestion = getQuestionFromDatastore("qn1InSession2InCourse2");
    assertNull(deletedQuestion);
    questions = fqLogic.getFeedbackQuestionsForSession("Instructor feedback session", courseId);
    assertEquals(0, questions.size());
    questions = fqLogic.getFeedbackQuestionsForSession("Private feedback session", courseId);
    assertEquals(0, questions.size());
    // test that questions in other courses are unaffected
    assertNotNull(getQuestionFromDatastore("qn1InSessionInArchivedCourse"));
    assertNotNull(getQuestionFromDatastore("qn1InSession4InCourse1"));
}
Also used : FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Example 80 with FeedbackQuestionAttributes

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

the class FeedbackQuestionsLogicTest method testUpdateQuestionNumber.

private void testUpdateQuestionNumber() throws Exception {
    ______TS("shift question up");
    List<FeedbackQuestionAttributes> expectedList = new ArrayList<>();
    FeedbackQuestionAttributes q1 = getQuestionFromDatastore("qn1InSession1InCourse1");
    q1.questionNumber = 2;
    FeedbackQuestionAttributes q2 = getQuestionFromDatastore("qn2InSession1InCourse1");
    q2.questionNumber = 3;
    FeedbackQuestionAttributes q3 = getQuestionFromDatastore("qn3InSession1InCourse1");
    q3.questionNumber = 1;
    FeedbackQuestionAttributes q4 = getQuestionFromDatastore("qn4InSession1InCourse1");
    q4.questionNumber = 4;
    FeedbackQuestionAttributes q5 = getQuestionFromDatastore("qn5InSession1InCourse1");
    q5.questionNumber = 5;
    expectedList.add(q3);
    expectedList.add(q1);
    expectedList.add(q2);
    expectedList.add(q4);
    expectedList.add(q5);
    FeedbackQuestionAttributes questionToUpdate = getQuestionFromDatastore("qn3InSession1InCourse1");
    questionToUpdate.questionNumber = 1;
    fqLogic.updateFeedbackQuestionNumber(questionToUpdate);
    List<FeedbackQuestionAttributes> actualList = fqLogic.getFeedbackQuestionsForSession(questionToUpdate.feedbackSessionName, questionToUpdate.courseId);
    assertEquals(actualList.size(), expectedList.size());
    for (int i = 0; i < actualList.size(); i++) {
        assertEquals(actualList.get(i), expectedList.get(i));
    }
    ______TS("shift question down");
    expectedList = new ArrayList<>();
    q1 = getQuestionFromDatastore("qn1InSession1InCourse1");
    q1.questionNumber = 1;
    q2 = getQuestionFromDatastore("qn2InSession1InCourse1");
    q2.questionNumber = 2;
    q3 = getQuestionFromDatastore("qn3InSession1InCourse1");
    q3.questionNumber = 3;
    q4 = getQuestionFromDatastore("qn4InSession1InCourse1");
    q4.questionNumber = 4;
    q5 = getQuestionFromDatastore("qn5InSession1InCourse1");
    q5.questionNumber = 5;
    expectedList.add(q1);
    expectedList.add(q2);
    expectedList.add(q3);
    expectedList.add(q4);
    expectedList.add(q5);
    questionToUpdate = getQuestionFromDatastore("qn3InSession1InCourse1");
    questionToUpdate.questionNumber = 3;
    fqLogic.updateFeedbackQuestionNumber(questionToUpdate);
    actualList = fqLogic.getFeedbackQuestionsForSession(questionToUpdate.feedbackSessionName, questionToUpdate.courseId);
    assertEquals(actualList.size(), expectedList.size());
    for (int i = 0; i < actualList.size(); i++) {
        assertEquals(expectedList.get(i), actualList.get(i));
    }
}
Also used : ArrayList(java.util.ArrayList) 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