Search in sources :

Example 16 with AccountAttributes

use of teammates.common.datatransfer.attributes.AccountAttributes in project teammates by TEAMMATES.

the class BaseTestCaseWithDatastoreAccess method verifyPresentInDatastore.

protected void verifyPresentInDatastore(DataBundle data) {
    Map<String, AccountAttributes> accounts = data.accounts;
    for (AccountAttributes account : accounts.values()) {
        verifyPresentInDatastore(account);
    }
    Map<String, InstructorAttributes> instructors = data.instructors;
    for (InstructorAttributes instructor : instructors.values()) {
        verifyPresentInDatastore(instructor);
    }
    Map<String, CourseAttributes> courses = data.courses;
    for (CourseAttributes course : courses.values()) {
        verifyPresentInDatastore(course);
    }
    Map<String, StudentAttributes> students = data.students;
    for (StudentAttributes student : students.values()) {
        verifyPresentInDatastore(student);
    }
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 17 with AccountAttributes

use of teammates.common.datatransfer.attributes.AccountAttributes in project teammates by TEAMMATES.

the class AdminSearchPageAction method putStudentInstituteIntoMap.

private AdminSearchPageData putStudentInstituteIntoMap(List<StudentAttributes> students, AdminSearchPageData data) {
    for (StudentAttributes student : students) {
        if (tempCourseIdToInstituteMap.get(student.course) != null) {
            data.studentInstituteMap.put(student.getIdentificationString(), tempCourseIdToInstituteMap.get(student.course));
            continue;
        }
        String instructorForCourseGoogleId = findAvailableInstructorGoogleIdForCourse(student.course);
        AccountAttributes account = logic.getAccount(instructorForCourseGoogleId);
        if (account == null) {
            continue;
        }
        String institute = account.institute.trim().isEmpty() ? "None" : account.institute;
        tempCourseIdToInstituteMap.put(student.course, institute);
        data.studentInstituteMap.put(student.getIdentificationString(), institute);
    }
    return data;
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 18 with AccountAttributes

use of teammates.common.datatransfer.attributes.AccountAttributes in project teammates by TEAMMATES.

the class Logic method createInstructorAccount.

/**
 * Creates an instructor and an new account if the instructor doesn't not have account yet.<br>
 * Used as a shorthand when the account entity is not important and is
 * only needed for completeness<br>
 * <b>Note: Now used for the purpose of testing only.</b><br>
 * Preconditions: <br>
 * * All parameters are non-null.
 */
@Deprecated
public void createInstructorAccount(String googleId, String courseId, String name, String email, Boolean isArchived, String roleParam, boolean isDisplayedToStudents, String displayedNameParam, String privileges, String institute) throws EntityAlreadyExistsException, InvalidParametersException {
    Assumption.assertNotNull(googleId);
    Assumption.assertNotNull(courseId);
    Assumption.assertNotNull(name);
    Assumption.assertNotNull(email);
    Assumption.assertNotNull(institute);
    if (accountsLogic.getAccount(googleId) == null) {
        AccountAttributes account = AccountAttributes.builder().withGoogleId(googleId).withName(name).withEmail(email).withInstitute(institute).withIsInstructor(true).withDefaultStudentProfileAttributes(googleId).build();
        accountsLogic.createAccount(account);
    }
    // In case when roleParam is null, default values used both for role and for privileges.
    // If privileges is null and roleParam is not null, for privileges will be created value based on roleParam
    InstructorAttributes instructor = InstructorAttributes.builder(googleId, courseId, name, email).withRole(roleParam).withDisplayedName(displayedNameParam).withPrivileges(privileges).withIsDisplayedToStudents(isDisplayedToStudents).withIsArchived(isArchived).build();
    instructorsLogic.createInstructor(instructor);
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Example 19 with AccountAttributes

use of teammates.common.datatransfer.attributes.AccountAttributes in project teammates by TEAMMATES.

the class AccountsLogic method createStudentAccount.

private void createStudentAccount(StudentAttributes student) throws InvalidParametersException {
    AccountAttributes account = AccountAttributes.builder().withGoogleId(student.googleId).withEmail(student.email).withName(student.name).withIsInstructor(false).withInstitute(getCourseInstitute(student.course)).withStudentProfileAttributes(StudentProfileAttributes.builder(student.googleId).withInstitute(getCourseInstitute(student.course)).build()).build();
    accountsDb.createAccount(account);
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes)

Example 20 with AccountAttributes

use of teammates.common.datatransfer.attributes.AccountAttributes in project teammates by TEAMMATES.

the class AccountsLogic method joinCourseForInstructorWithInstitute.

/**
 * Institute is set only if it is not null. If it is null, this instructor
 * is given the institute of an existing instructor of the same course.
 */
private void joinCourseForInstructorWithInstitute(String encryptedKey, String googleId, String institute) throws JoinCourseException, InvalidParametersException, EntityDoesNotExistException {
    confirmValidJoinCourseRequest(encryptedKey, googleId);
    InstructorAttributes instructor = instructorsLogic.getInstructorForRegistrationKey(encryptedKey);
    AccountAttributes account = accountsDb.getAccount(googleId);
    String instituteToSave = institute == null ? getCourseInstitute(instructor.courseId) : institute;
    if (account == null) {
        createAccount(AccountAttributes.builder().withGoogleId(googleId).withName(instructor.name).withEmail(instructor.email).withInstitute(instituteToSave).withIsInstructor(true).withDefaultStudentProfileAttributes(googleId).build());
    } else {
        makeAccountInstructor(googleId);
    }
    instructor.googleId = googleId;
    instructorsLogic.updateInstructorByEmail(instructor.email, instructor);
    // Update the goolgeId of the student entity for the instructor which was created from sampleData.
    StudentAttributes student = studentsLogic.getStudentForEmail(instructor.courseId, instructor.email);
    if (student != null) {
        student.googleId = googleId;
        studentsLogic.updateStudentCascade(instructor.email, student);
    }
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Aggregations

AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)84 Test (org.testng.annotations.Test)53 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)28 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)16 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)15 ArrayList (java.util.ArrayList)13 StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)11 HashMap (java.util.HashMap)7 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)6 InvalidParametersException (teammates.common.exception.InvalidParametersException)6 UnauthorizedAccessException (teammates.common.exception.UnauthorizedAccessException)5 CourseDetailsBundle (teammates.common.datatransfer.CourseDetailsBundle)4 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)4 EmailWrapper (teammates.common.util.EmailWrapper)4 RedirectResult (teammates.ui.controller.RedirectResult)4 List (java.util.List)3 EmailGenerator (teammates.logic.api.EmailGenerator)3 AccountsDb (teammates.storage.api.AccountsDb)3 Account (teammates.storage.entity.Account)3 ShowPageResult (teammates.ui.controller.ShowPageResult)3