use of teammates.logic.core.FeedbackQuestionsLogic 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);
}
use of teammates.logic.core.FeedbackQuestionsLogic 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.logic.core.FeedbackQuestionsLogic in project teammates by TEAMMATES.
the class FeedbackConstantSumQuestionDetails method validateResponseAttributes.
@Override
public List<String> validateResponseAttributes(List<FeedbackResponseAttributes> responses, int numRecipients) {
List<String> errors = new ArrayList<>();
if (responses.isEmpty()) {
// No responses, no errors.
return errors;
}
String fqId = responses.get(0).feedbackQuestionId;
FeedbackQuestionsLogic fqLogic = FeedbackQuestionsLogic.inst();
FeedbackQuestionAttributes fqa = fqLogic.getFeedbackQuestion(fqId);
int numOfResponseSpecific = fqa.numberOfEntitiesToGiveFeedbackTo;
int maxResponsesPossible = numRecipients;
if (numOfResponseSpecific == Const.MAX_POSSIBLE_RECIPIENTS || numOfResponseSpecific > maxResponsesPossible) {
numOfResponseSpecific = maxResponsesPossible;
}
int numOptions = distributeToRecipients ? numOfResponseSpecific : constSumOptions.size();
int totalPoints = pointsPerOption ? points * numOptions : points;
int sum = 0;
for (FeedbackResponseAttributes response : responses) {
FeedbackConstantSumResponseDetails frd = (FeedbackConstantSumResponseDetails) response.getResponseDetails();
// Check that all response points are >= 0
for (Integer i : frd.getAnswerList()) {
if (i < 0) {
errors.add(Const.FeedbackQuestion.CONST_SUM_ERROR_NEGATIVE);
return errors;
}
}
// Check that points sum up properly
if (distributeToRecipients) {
sum += frd.getAnswerList().get(0);
} else {
sum = 0;
for (Integer i : frd.getAnswerList()) {
sum += i;
}
if (sum != totalPoints || frd.getAnswerList().size() != constSumOptions.size()) {
errors.add(Const.FeedbackQuestion.CONST_SUM_ERROR_MISMATCH);
return errors;
}
}
Set<Integer> answerSet = new HashSet<>();
if (this.forceUnevenDistribution) {
for (int i : frd.getAnswerList()) {
if (answerSet.contains(i)) {
errors.add(Const.FeedbackQuestion.CONST_SUM_ERROR_UNIQUE);
return errors;
}
answerSet.add(i);
}
}
}
if (distributeToRecipients && sum != totalPoints) {
errors.add(Const.FeedbackQuestion.CONST_SUM_ERROR_MISMATCH + sum + "/" + totalPoints);
return errors;
}
return errors;
}
Aggregations