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