use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class BackDoorLogic method processResponsesAndPopulateMap.
private void processResponsesAndPopulateMap(Collection<FeedbackResponseAttributes> responses, SetMultimap<String, FeedbackResponseAttributes> sessionResponsesMap) {
for (FeedbackResponseAttributes response : responses) {
String sessionKey = makeSessionKey(response.feedbackSessionName, response.courseId);
sessionResponsesMap.put(sessionKey, response);
}
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class BackDoorServlet method executeBackEndAction.
// no default so that each case is accounted for
@SuppressWarnings("PMD.SwitchStmtsShouldHaveDefault")
private String executeBackEndAction(HttpServletRequest req, BackDoorOperation opCode) throws IOException, InvalidParametersException, EntityDoesNotExistException {
BackDoorLogic backDoorLogic = new BackDoorLogic();
switch(opCode) {
case OPERATION_DELETE_ACCOUNT:
String googleId = req.getParameter(BackDoorOperation.PARAMETER_GOOGLE_ID);
backDoorLogic.deleteAccount(googleId);
break;
case OPERATION_DELETE_COURSE:
String courseId = req.getParameter(BackDoorOperation.PARAMETER_COURSE_ID);
backDoorLogic.deleteCourse(courseId);
break;
case OPERATION_DELETE_FEEDBACK_QUESTION:
String questionId = req.getParameter(BackDoorOperation.PARAMETER_FEEDBACK_QUESTION_ID);
backDoorLogic.deleteFeedbackQuestion(questionId);
break;
case OPERATION_DELETE_FEEDBACK_RESPONSE:
String feedbackQuestionId = req.getParameter(BackDoorOperation.PARAMETER_FEEDBACK_QUESTION_ID);
String giverEmail = req.getParameter(BackDoorOperation.PARAMETER_GIVER_EMAIL);
String recipient = req.getParameter(BackDoorOperation.PARAMETER_RECIPIENT);
FeedbackResponseAttributes fr = backDoorLogic.getFeedbackResponse(feedbackQuestionId, giverEmail, recipient);
backDoorLogic.deleteFeedbackResponse(fr);
break;
case OPERATION_DELETE_FEEDBACK_SESSION:
String feedbackSessionName = req.getParameter(BackDoorOperation.PARAMETER_FEEDBACK_SESSION_NAME);
courseId = req.getParameter(BackDoorOperation.PARAMETER_COURSE_ID);
backDoorLogic.deleteFeedbackSession(feedbackSessionName, courseId);
break;
case OPERATION_DELETE_INSTRUCTOR:
String instructorEmail = req.getParameter(BackDoorOperation.PARAMETER_INSTRUCTOR_EMAIL);
courseId = req.getParameter(BackDoorOperation.PARAMETER_COURSE_ID);
backDoorLogic.deleteInstructor(courseId, instructorEmail);
break;
case OPERATION_DELETE_STUDENT:
courseId = req.getParameter(BackDoorOperation.PARAMETER_COURSE_ID);
String studentEmail = req.getParameter(BackDoorOperation.PARAMETER_STUDENT_EMAIL);
backDoorLogic.deleteStudent(courseId, studentEmail);
break;
case OPERATION_EDIT_FEEDBACK_QUESTION:
String newValues = req.getParameter(BackDoorOperation.PARAMETER_JSON_STRING);
backDoorLogic.editFeedbackQuestionAsJson(newValues);
break;
case OPERATION_EDIT_FEEDBACK_SESSION:
newValues = req.getParameter(BackDoorOperation.PARAMETER_JSON_STRING);
backDoorLogic.editFeedbackSessionAsJson(newValues);
break;
case OPERATION_EDIT_STUDENT:
studentEmail = req.getParameter(BackDoorOperation.PARAMETER_STUDENT_EMAIL);
newValues = req.getParameter(BackDoorOperation.PARAMETER_JSON_STRING);
backDoorLogic.editStudentAsJson(studentEmail, newValues);
break;
case OPERATION_EDIT_STUDENT_PROFILE_PICTURE:
String pictureDataJsonString = req.getParameter(BackDoorOperation.PARAMETER_PICTURE_DATA);
byte[] pictureData = JsonUtils.fromJson(pictureDataJsonString, byte[].class);
googleId = req.getParameter(BackDoorOperation.PARAMETER_GOOGLE_ID);
backDoorLogic.uploadAndUpdateStudentProfilePicture(googleId, pictureData);
break;
case OPERATION_GET_ACCOUNT_AS_JSON:
googleId = req.getParameter(BackDoorOperation.PARAMETER_GOOGLE_ID);
return backDoorLogic.getAccountAsJson(googleId);
case OPERATION_GET_COURSE_AS_JSON:
courseId = req.getParameter(BackDoorOperation.PARAMETER_COURSE_ID);
return backDoorLogic.getCourseAsJson(courseId);
case OPERATION_GET_ENCRYPTED_KEY_FOR_INSTRUCTOR:
courseId = req.getParameter(BackDoorOperation.PARAMETER_COURSE_ID);
studentEmail = req.getParameter(BackDoorOperation.PARAMETER_INSTRUCTOR_EMAIL);
return backDoorLogic.getEncryptedKeyForInstructor(courseId, studentEmail);
case OPERATION_GET_ENCRYPTED_KEY_FOR_STUDENT:
courseId = req.getParameter(BackDoorOperation.PARAMETER_COURSE_ID);
studentEmail = req.getParameter(BackDoorOperation.PARAMETER_STUDENT_EMAIL);
return backDoorLogic.getEncryptedKeyForStudent(courseId, studentEmail);
case OPERATION_GET_FEEDBACK_QUESTION_AS_JSON:
feedbackSessionName = req.getParameter(BackDoorOperation.PARAMETER_FEEDBACK_SESSION_NAME);
courseId = req.getParameter(BackDoorOperation.PARAMETER_COURSE_ID);
int qnNumber = Integer.parseInt(req.getParameter(BackDoorOperation.PARAMETER_FEEDBACK_QUESTION_NUMBER));
return backDoorLogic.getFeedbackQuestionAsJson(feedbackSessionName, courseId, qnNumber);
case OPERATION_GET_FEEDBACK_QUESTION_FOR_ID_AS_JSON:
questionId = req.getParameter(BackDoorOperation.PARAMETER_FEEDBACK_QUESTION_ID);
return backDoorLogic.getFeedbackQuestionForIdAsJson(questionId);
case OPERATION_GET_FEEDBACK_RESPONSE_AS_JSON:
feedbackQuestionId = req.getParameter(BackDoorOperation.PARAMETER_FEEDBACK_QUESTION_ID);
giverEmail = req.getParameter(BackDoorOperation.PARAMETER_GIVER_EMAIL);
recipient = req.getParameter(BackDoorOperation.PARAMETER_RECIPIENT);
return backDoorLogic.getFeedbackResponseAsJson(feedbackQuestionId, giverEmail, recipient);
case OPERATION_GET_FEEDBACK_RESPONSES_FOR_GIVER_AS_JSON:
courseId = req.getParameter(BackDoorOperation.PARAMETER_COURSE_ID);
giverEmail = req.getParameter(BackDoorOperation.PARAMETER_GIVER_EMAIL);
return backDoorLogic.getFeedbackResponsesForGiverAsJson(courseId, giverEmail);
case OPERATION_GET_FEEDBACK_RESPONSES_FOR_RECEIVER_AS_JSON:
courseId = req.getParameter(BackDoorOperation.PARAMETER_COURSE_ID);
recipient = req.getParameter(BackDoorOperation.PARAMETER_RECIPIENT);
return backDoorLogic.getFeedbackResponsesForReceiverAsJson(courseId, recipient);
case OPERATION_GET_FEEDBACK_SESSION_AS_JSON:
feedbackSessionName = req.getParameter(BackDoorOperation.PARAMETER_FEEDBACK_SESSION_NAME);
courseId = req.getParameter(BackDoorOperation.PARAMETER_COURSE_ID);
return backDoorLogic.getFeedbackSessionAsJson(feedbackSessionName, courseId);
case OPERATION_GET_INSTRUCTOR_AS_JSON_BY_ID:
googleId = req.getParameter(BackDoorOperation.PARAMETER_GOOGLE_ID);
courseId = req.getParameter(BackDoorOperation.PARAMETER_COURSE_ID);
return backDoorLogic.getInstructorAsJsonById(googleId, courseId);
case OPERATION_GET_INSTRUCTOR_AS_JSON_BY_EMAIL:
instructorEmail = req.getParameter(BackDoorOperation.PARAMETER_INSTRUCTOR_EMAIL);
courseId = req.getParameter(BackDoorOperation.PARAMETER_COURSE_ID);
return backDoorLogic.getInstructorAsJsonByEmail(instructorEmail, courseId);
case OPERATION_GET_STUDENT_AS_JSON:
courseId = req.getParameter(BackDoorOperation.PARAMETER_COURSE_ID);
studentEmail = req.getParameter(BackDoorOperation.PARAMETER_STUDENT_EMAIL);
return backDoorLogic.getStudentAsJson(courseId, studentEmail);
case OPERATION_GET_STUDENTS_AS_JSON:
courseId = req.getParameter(BackDoorOperation.PARAMETER_COURSE_ID);
return backDoorLogic.getAllStudentsAsJson(courseId);
case OPERATION_GET_STUDENTPROFILE_AS_JSON:
googleId = req.getParameter(BackDoorOperation.PARAMETER_GOOGLE_ID);
return backDoorLogic.getStudentProfileAsJson(googleId);
case OPERATION_IS_PICTURE_PRESENT_IN_GCS:
String pictureKey = req.getParameter(BackDoorOperation.PARAMETER_PICTURE_KEY);
return String.valueOf(backDoorLogic.isPicturePresentInGcs(pictureKey));
case OPERATION_CREATE_FEEDBACK_RESPONSE:
String feedbackResponseJsonString = req.getParameter(BackDoorOperation.PARAMETER_FEEDBACK_RESPONSE_JSON);
FeedbackResponseAttributes feedbackResponse = JsonUtils.fromJson(feedbackResponseJsonString, FeedbackResponseAttributes.class);
return backDoorLogic.createFeedbackResponseAndUpdateSessionRespondents(feedbackResponse);
case OPERATION_PERSIST_DATABUNDLE:
String dataBundleJsonString = req.getParameter(BackDoorOperation.PARAMETER_DATABUNDLE_JSON);
DataBundle dataBundle = JsonUtils.fromJson(dataBundleJsonString, DataBundle.class);
backDoorLogic.persistDataBundle(dataBundle);
break;
case OPERATION_PUT_DOCUMENTS:
dataBundleJsonString = req.getParameter(BackDoorOperation.PARAMETER_DATABUNDLE_JSON);
dataBundle = JsonUtils.fromJson(dataBundleJsonString, DataBundle.class);
backDoorLogic.putDocuments(dataBundle);
break;
case OPERATION_REMOVE_AND_RESTORE_DATABUNDLE:
dataBundleJsonString = req.getParameter(BackDoorOperation.PARAMETER_DATABUNDLE_JSON);
dataBundle = JsonUtils.fromJson(dataBundleJsonString, DataBundle.class);
backDoorLogic.removeDataBundle(dataBundle);
backDoorLogic.persistDataBundle(dataBundle);
break;
case OPERATION_REMOVE_DATABUNDLE:
dataBundleJsonString = req.getParameter(BackDoorOperation.PARAMETER_DATABUNDLE_JSON);
dataBundle = JsonUtils.fromJson(dataBundleJsonString, DataBundle.class);
backDoorLogic.removeDataBundle(dataBundle);
break;
case OPERATION_IS_GROUP_LIST_FILE_PRESENT_IN_GCS:
String groupListKey = req.getParameter(BackDoorOperation.PARAMETER_GROUP_LIST_FILE_KEY);
return String.valueOf(backDoorLogic.isGroupListFilePresentInGcs(groupListKey));
case OPERATION_DELETE_GROUP_LIST_FILE:
String groupListFileKey = req.getParameter(BackDoorOperation.PARAMETER_GROUP_LIST_FILE_KEY);
backDoorLogic.deleteGroupListFile(groupListFileKey);
break;
}
return Const.StatusCodes.BACKDOOR_STATUS_SUCCESS;
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackContributionQuestionDetails method getQuestionResultStatisticsHtmlStudentView.
private String getQuestionResultStatisticsHtmlStudentView(List<FeedbackResponseAttributes> responses, FeedbackQuestionAttributes question, String studentEmail, FeedbackSessionResultsBundle bundle) {
if (responses.isEmpty()) {
return "";
}
String currentUserTeam = bundle.emailTeamNameTable.get(studentEmail);
List<FeedbackResponseAttributes> actualResponses = getActualResponses(question, bundle);
// List of teams with at least one response
List<String> teamNames = getTeamsWithAtLeastOneResponse(actualResponses, bundle);
// Each team's member(email) list
Map<String, List<String>> teamMembersEmail = getTeamMembersEmail(bundle, teamNames);
// Each team's responses
Map<String, List<FeedbackResponseAttributes>> teamResponses = getTeamResponses(actualResponses, bundle, teamNames);
// Get each team's submission array. -> int[teamSize][teamSize]
// Where int[0][1] refers points from student 0 to student 1
// Where student 0 is the 0th student in the list in teamMembersEmail
Map<String, int[][]> teamSubmissionArray = getTeamSubmissionArray(teamNames, teamMembersEmail, teamResponses);
// Each team's contribution question results.
Map<String, TeamEvalResult> teamResults = getTeamResults(teamNames, teamSubmissionArray, teamMembersEmail);
TeamEvalResult currentUserTeamResults = teamResults.get(currentUserTeam);
if (currentUserTeamResults == null) {
return "";
}
int currentUserIndex = teamMembersEmail.get(currentUserTeam).indexOf(studentEmail);
int selfClaim = currentUserTeamResults.claimed[currentUserIndex][currentUserIndex];
int teamClaim = currentUserTeamResults.denormalizedAveragePerceived[currentUserIndex][currentUserIndex];
String contribAdditionalInfo = Templates.populateTemplate(FormTemplates.CONTRIB_ADDITIONAL_INFO, Slots.MORE, "[how to interpret, etc..]", Slots.LESS, "[less]", Slots.QUESTION_NUMBER, Integer.toString(question.questionNumber), Slots.ADDITIONAL_INFO_ID, "contributionInfo", Slots.QUESTION_ADDITIONAL_INFO, FormTemplates.CONTRIB_RESULT_STATS_STUDENT_INFO);
return Templates.populateTemplate(FormTemplates.CONTRIB_RESULT_STATS_STUDENT, Slots.CONTRIB_ADDITIONAL_INFO, contribAdditionalInfo, Slots.CONTRIB_MY_VIEW_OF_ME, getPointsAsColorizedHtml(selfClaim), Slots.CONTRIB_MY_VIEW_OF_OTHERS, getNormalizedPointsListColorizedDescending(currentUserTeamResults.claimed[currentUserIndex], currentUserIndex), Slots.CONTRIB_TEAM_VIEW_OF_ME, getPointsAsColorizedHtml(teamClaim), Slots.CONTRIB_TEAM_VIEW_OF_OTHERS, getNormalizedPointsListColorizedDescending(currentUserTeamResults.denormalizedAveragePerceived[currentUserIndex], currentUserIndex));
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackContributionQuestionDetails method getTeamSubmissionArray.
private Map<String, int[][]> getTeamSubmissionArray(List<String> teamNames, Map<String, List<String>> teamMembersEmail, Map<String, List<FeedbackResponseAttributes>> teamResponses) {
Map<String, int[][]> teamSubmissionArray = new LinkedHashMap<>();
for (String team : teamNames) {
int teamSize = teamMembersEmail.get(team).size();
teamSubmissionArray.put(team, new int[teamSize][teamSize]);
// Initialize all as not submitted.
for (int i = 0; i < teamSize; i++) {
for (int j = 0; j < teamSize; j++) {
teamSubmissionArray.get(team)[i][j] = Const.POINTS_NOT_SUBMITTED;
}
}
// Fill in submitted points
List<FeedbackResponseAttributes> teamResponseList = teamResponses.get(team);
List<String> memberEmailList = teamMembersEmail.get(team);
for (FeedbackResponseAttributes response : teamResponseList) {
int giverIndx = memberEmailList.indexOf(response.giver);
int recipientIndx = memberEmailList.indexOf(response.recipient);
if (giverIndx == -1 || recipientIndx == -1) {
continue;
}
int points = ((FeedbackContributionResponseDetails) response.getResponseDetails()).getAnswer();
teamSubmissionArray.get(team)[giverIndx][recipientIndx] = points;
}
}
return teamSubmissionArray;
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackContributionQuestionDetails method getActualResponses.
private List<FeedbackResponseAttributes> getActualResponses(FeedbackQuestionAttributes question, FeedbackSessionResultsBundle bundle) {
List<FeedbackResponseAttributes> responses;
String questionId = question.getId();
// Get all actual responses for this question.
responses = new ArrayList<>();
for (FeedbackResponseAttributes response : bundle.actualResponses) {
if (response.feedbackQuestionId.equals(questionId)) {
responses.add(response);
}
}
responses.sort(bundle.compareByGiverRecipientQuestion);
return responses;
}
Aggregations