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;
}
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);
}
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()));
}
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"));
}
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));
}
}
Aggregations