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