Search in sources :

Example 91 with StudentAttributes

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);
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) Test(org.testng.annotations.Test)

Example 92 with StudentAttributes

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;
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 93 with StudentAttributes

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);
    }
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 94 with StudentAttributes

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);
            }
        }
    }
}
Also used : InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Const(teammates.common.util.Const) Date(java.util.Date) FeedbackSessionResultsBundle(teammates.common.datatransfer.FeedbackSessionResultsBundle) CourseRoster(teammates.common.datatransfer.CourseRoster) FeedbackSessionType(teammates.common.datatransfer.FeedbackSessionType) SanitizationHelper(teammates.common.util.SanitizationHelper) HashMap(java.util.HashMap) FeedbackSessionQuestionsBundle(teammates.common.datatransfer.FeedbackSessionQuestionsBundle) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType) UserRole(teammates.common.datatransfer.UserRole) ExceedingRangeException(teammates.common.exception.ExceedingRangeException) Map(java.util.Map) TeammatesException(teammates.common.exception.TeammatesException) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) Logger(teammates.common.util.Logger) InvalidParametersException(teammates.common.exception.InvalidParametersException) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) TimeHelper(teammates.common.util.TimeHelper) FeedbackSessionDetailsBundle(teammates.common.datatransfer.FeedbackSessionDetailsBundle) FeedbackQuestionDetails(teammates.common.datatransfer.questions.FeedbackQuestionDetails) Set(java.util.Set) FeedbackSessionResponseStatus(teammates.common.datatransfer.FeedbackSessionResponseStatus) StringHelper(teammates.common.util.StringHelper) Instant(java.time.Instant) FeedbackSessionsDb(teammates.storage.api.FeedbackSessionsDb) EntityAlreadyExistsException(teammates.common.exception.EntityAlreadyExistsException) SystemParams(teammates.common.util.Const.SystemParams) List(java.util.List) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) Assumption(teammates.common.util.Assumption) Entry(java.util.Map.Entry) Comparator(java.util.Comparator) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) HashSet(java.util.HashSet)

Example 95 with StudentAttributes

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));
    }
}
Also used : EmailGenerator(teammates.logic.api.EmailGenerator) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) TeammatesException(teammates.common.exception.TeammatesException) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) EmailWrapper(teammates.common.util.EmailWrapper)

Aggregations

StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)241 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)85 Test (org.testng.annotations.Test)80 ArrayList (java.util.ArrayList)55 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)33 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)33 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)30 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)27 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)22 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)17 ShowPageResult (teammates.ui.controller.ShowPageResult)15 HashMap (java.util.HashMap)14 TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)14 InvalidParametersException (teammates.common.exception.InvalidParametersException)14 EmailWrapper (teammates.common.util.EmailWrapper)13 RedirectResult (teammates.ui.controller.RedirectResult)12 List (java.util.List)11 StatusMessage (teammates.common.util.StatusMessage)10 HashSet (java.util.HashSet)9 StudentEnrollDetails (teammates.common.datatransfer.StudentEnrollDetails)9