use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.
the class BackDoorTest method testCreateStudent.
@Test
public void testCreateStudent() {
// only minimal testing because this is a wrapper method for
// another well-tested method.
StudentAttributes student = StudentAttributes.builder("tmapit.tcs.course", "name of tcs student", "tcsStudent@gmail.tmt").withSection("section name").withTeam("team name").withComments("").build();
BackDoor.deleteStudent(student.course, student.email);
verifyAbsentInDatastore(student);
BackDoor.createStudent(student);
verifyPresentInDatastore(student);
BackDoor.deleteStudent(student.course, student.email);
verifyAbsentInDatastore(student);
}
use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.
the class FeedbackResponsesLogic method getViewableFeedbackResponsesForStudentForQuestion.
private List<FeedbackResponseAttributes> getViewableFeedbackResponsesForStudentForQuestion(FeedbackQuestionAttributes question, String studentEmail) {
List<FeedbackResponseAttributes> viewableResponses = new ArrayList<>();
if (question.isResponseVisibleTo(FeedbackParticipantType.STUDENTS)) {
addNewResponses(viewableResponses, getFeedbackResponsesForQuestion(question.getId()));
// Early return as STUDENTS covers all other student types.
return viewableResponses;
}
StudentAttributes student = studentsLogic.getStudentForEmail(question.courseId, studentEmail);
if (question.recipientType.isTeam() && question.isResponseVisibleTo(FeedbackParticipantType.RECEIVER)) {
addNewResponses(viewableResponses, getFeedbackResponsesForReceiverForQuestion(question.getId(), student.team));
}
if (question.giverType == FeedbackParticipantType.TEAMS || question.isResponseVisibleTo(FeedbackParticipantType.OWN_TEAM_MEMBERS)) {
addNewResponses(viewableResponses, getFeedbackResponsesFromTeamForQuestion(question.getId(), question.courseId, student.team));
}
if (question.isResponseVisibleTo(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS)) {
addNewResponses(viewableResponses, getFeedbackResponsesForTeamMembersOfStudent(question.getId(), student));
}
return viewableResponses;
}
use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.
the class FeedbackResponsesLogic method deleteFeedbackResponsesForStudentAndCascade.
public void deleteFeedbackResponsesForStudentAndCascade(String courseId, String studentEmail) {
String studentTeam = "";
StudentAttributes student = studentsLogic.getStudentForEmail(courseId, studentEmail);
if (student != null) {
studentTeam = student.team;
}
List<FeedbackResponseAttributes> responses = getFeedbackResponsesFromGiverForCourse(courseId, studentEmail);
responses.addAll(getFeedbackResponsesForReceiverForCourse(courseId, studentEmail));
// Delete responses to team as well if student is last person in team.
if (studentsLogic.getStudentsForTeam(studentTeam, courseId).size() <= 1) {
responses.addAll(getFeedbackResponsesForReceiverForCourse(courseId, studentTeam));
}
for (FeedbackResponseAttributes response : responses) {
this.deleteFeedbackResponseAndCascade(response);
}
}
use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method addSectionTeamNamesToTable.
private void addSectionTeamNamesToTable(Map<String, Set<String>> sectionTeamNameTable, CourseRoster roster, String courseId, String userEmail, UserRole role, String feedbackSessionName, String sectionToView) {
InstructorAttributes instructor = getInstructor(courseId, userEmail, role);
if (instructor != null) {
for (StudentAttributes student : roster.getStudents()) {
boolean isVisibleResponse = instructor.isAllowedForPrivilege(student.section, feedbackSessionName, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_SESSION_IN_SECTIONS);
boolean isStudentInSelectedSection = student.section.equals(sectionToView);
boolean isViewingAllSections = sectionToView == null;
if (isVisibleResponse && (isViewingAllSections || isStudentInSelectedSection)) {
String section = student.section;
sectionTeamNameTable.computeIfAbsent(section, key -> new HashSet<>()).add(student.team);
}
}
}
}
use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.
the class StudentCourseJoinEmailWorkerAction method execute.
@Override
public void execute() {
String courseId = getRequestParamValue(ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(ParamsNames.COURSE_ID, courseId);
String studentEmail = getRequestParamValue(ParamsNames.STUDENT_EMAIL);
Assumption.assertPostParamNotNull(ParamsNames.STUDENT_EMAIL, studentEmail);
String isRejoinString = getRequestParamValue(ParamsNames.IS_STUDENT_REJOINING);
Assumption.assertPostParamNotNull(ParamsNames.IS_STUDENT_REJOINING, isRejoinString);
boolean isRejoin = Boolean.parseBoolean(isRejoinString);
CourseAttributes course = logic.getCourse(courseId);
Assumption.assertNotNull(course);
StudentAttributes student = logic.getStudentForEmail(courseId, studentEmail);
Assumption.assertNotNull(student);
EmailWrapper email = isRejoin ? new EmailGenerator().generateStudentCourseRejoinEmailAfterGoogleIdReset(course, student) : new EmailGenerator().generateStudentCourseJoinEmail(course, student);
try {
emailSender.sendEmail(email);
} catch (Exception e) {
Assumption.fail("Unexpected error while sending email" + TeammatesException.toStringWithStackTrace(e));
}
}
Aggregations