use of teammates.common.datatransfer.attributes.AccountAttributes in project teammates by TEAMMATES.
the class CoursesLogic method createCourseAndInstructor.
/**
* Creates a Course object and an Instructor object for the Course.
*/
public void createCourseAndInstructor(String instructorGoogleId, String courseId, String courseName, String courseTimeZone) throws InvalidParametersException, EntityAlreadyExistsException {
AccountAttributes courseCreator = accountsLogic.getAccount(instructorGoogleId);
Assumption.assertNotNull("Trying to create a course for a non-existent instructor :" + instructorGoogleId, courseCreator);
Assumption.assertTrue("Trying to create a course for a person who doesn't have instructor privileges :" + instructorGoogleId, courseCreator.isInstructor);
createCourse(courseId, courseName, courseTimeZone);
/* Create the initial instructor for the course */
InstructorPrivileges privileges = new InstructorPrivileges(Const.InstructorPermissionRoleNames.INSTRUCTOR_PERMISSION_ROLE_COOWNER);
InstructorAttributes instructor = InstructorAttributes.builder(instructorGoogleId, courseId, courseCreator.name, courseCreator.email).withPrivileges(privileges).build();
try {
instructorsLogic.createInstructor(instructor);
} catch (EntityAlreadyExistsException | InvalidParametersException e) {
// roll back the transaction
coursesDb.deleteCourse(courseId);
String errorMessage = "Unexpected exception while trying to create instructor for a new course " + System.lineSeparator() + instructor.toString() + System.lineSeparator() + TeammatesException.toStringWithStackTrace(e);
Assumption.fail(errorMessage);
}
}
use of teammates.common.datatransfer.attributes.AccountAttributes in project teammates by TEAMMATES.
the class AdminSearchPageAction method putInstructorInstituteIntoMap.
private AdminSearchPageData putInstructorInstituteIntoMap(List<InstructorAttributes> instructors, AdminSearchPageData data) {
for (InstructorAttributes instructor : instructors) {
if (tempCourseIdToInstituteMap.get(instructor.courseId) != null) {
data.instructorInstituteMap.put(instructor.getIdentificationString(), tempCourseIdToInstituteMap.get(instructor.courseId));
continue;
}
String googleId = findAvailableInstructorGoogleIdForCourse(instructor.courseId);
AccountAttributes account = logic.getAccount(googleId);
if (account == null) {
continue;
}
String institute = account.institute.trim().isEmpty() ? "None" : account.institute;
tempCourseIdToInstituteMap.put(instructor.courseId, institute);
data.instructorInstituteMap.put(instructor.getIdentificationString(), institute);
}
return data;
}
use of teammates.common.datatransfer.attributes.AccountAttributes in project teammates by TEAMMATES.
the class AdminSessionsPageAction method createAdminSessionPageResult.
private ActionResult createAdminSessionPageResult(List<FeedbackSessionAttributes> allOpenFeedbackSessionsList) {
HashMap<String, List<FeedbackSessionAttributes>> map = new HashMap<>();
this.totalOngoingSessions = allOpenFeedbackSessionsList.size();
this.totalOpenStatusSessions = getTotalNumOfOpenStatusSession(allOpenFeedbackSessionsList);
this.totalClosedStatusSessions = getTotalNumOfCloseStatusSession(allOpenFeedbackSessionsList);
this.totalWaitToOpenStatusSessions = getTotalNumOfWaitToOpenStatusSession(allOpenFeedbackSessionsList);
for (FeedbackSessionAttributes fs : allOpenFeedbackSessionsList) {
List<InstructorAttributes> instructors = logic.getInstructorsForCourse(fs.getCourseId());
if (instructors.isEmpty()) {
putIntoUnknownList(map, fs);
} else {
AccountAttributes account = getRegisteredInstructorAccountFromInstructors(instructors);
if (account == null) {
putIntoUnknownList(map, fs);
continue;
}
if (map.get(account.institute) == null) {
List<FeedbackSessionAttributes> newList = new ArrayList<>();
newList.add(fs);
map.put(account.institute, newList);
} else {
map.get(account.institute).add(fs);
}
}
}
this.map = map;
this.totalInstitutes = getTotalInstitutes(map);
statusToAdmin = "Admin Sessions Page Load<br>" + "<span class=\"bold\">Total Ongoing Sessions:</span> " + this.totalOngoingSessions + "<span class=\"bold\">Total Opened Sessions:</span> " + this.totalOpenStatusSessions;
constructSessionToInstructorIdMap();
data.init(this.map, this.sessionToInstructorIdMap, this.totalOngoingSessions, this.totalOpenStatusSessions, this.totalClosedStatusSessions, this.totalWaitToOpenStatusSessions, this.totalInstitutes, this.rangeStart, this.rangeEnd, this.zone, this.isShowAll);
return createShowPageResult(Const.ViewURIs.ADMIN_SESSIONS, data);
}
use of teammates.common.datatransfer.attributes.AccountAttributes in project teammates by TEAMMATES.
the class InstructorCourseJoinEmailWorkerAction method execute.
@Override
public void execute() {
String inviterId = getRequestParamValue(ParamsNames.INVITER_ID);
Assumption.assertPostParamNotNull(ParamsNames.INVITER_ID, inviterId);
String courseId = getRequestParamValue(ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(ParamsNames.COURSE_ID, courseId);
String instructorEmail = getRequestParamValue(ParamsNames.INSTRUCTOR_EMAIL);
Assumption.assertPostParamNotNull(ParamsNames.INSTRUCTOR_EMAIL, instructorEmail);
AccountAttributes inviter = logic.getAccount(inviterId);
Assumption.assertNotNull(inviter);
CourseAttributes course = logic.getCourse(courseId);
Assumption.assertNotNull(course);
InstructorAttributes instructor = logic.getInstructorForEmail(courseId, instructorEmail);
Assumption.assertNotNull(instructor);
EmailWrapper email = new EmailGenerator().generateInstructorCourseJoinEmail(inviter, instructor, course);
try {
emailSender.sendEmail(email);
} catch (Exception e) {
Assumption.fail("Unexpected error while sending email" + TeammatesException.toStringWithStackTrace(e));
}
}
Aggregations