use of teammates.common.datatransfer.attributes.StudentAttributes 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.StudentAttributes in project teammates by TEAMMATES.
the class AdminStudentGoogleIdResetAction method execute.
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
gateKeeper.verifyAdminPrivileges(account);
String studentEmail = getRequestParamValue(Const.ParamsNames.STUDENT_EMAIL);
String studentCourseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
String wrongGoogleId = getRequestParamValue(Const.ParamsNames.STUDENT_ID);
AdminStudentGoogleIdResetPageData data = new AdminStudentGoogleIdResetPageData(account, sessionToken);
if (studentEmail != null && studentCourseId != null) {
try {
logic.resetStudentGoogleId(studentEmail, studentCourseId);
taskQueuer.scheduleCourseRegistrationInviteToStudent(studentCourseId, studentEmail, true);
} catch (InvalidParametersException e) {
statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_GOOGLEID_RESET_FAIL, StatusMessageColor.DANGER));
statusToAdmin = Const.StatusMessages.STUDENT_GOOGLEID_RESET_FAIL + "<br>" + "Email: " + studentEmail + "<br>" + "CourseId: " + studentCourseId + "<br>" + "Failed with error<br>" + e.getMessage();
isError = true;
}
StudentAttributes updatedStudent = logic.getStudentForEmail(studentCourseId, studentEmail);
if (updatedStudent.googleId == null || updatedStudent.googleId.isEmpty()) {
statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_GOOGLEID_RESET, StatusMessageColor.SUCCESS));
statusToUser.add(new StatusMessage("Email : " + studentEmail, StatusMessageColor.SUCCESS));
statusToUser.add(new StatusMessage("CourseId : " + studentCourseId, StatusMessageColor.SUCCESS));
statusToAdmin = Const.StatusMessages.STUDENT_GOOGLEID_RESET + "<br>" + "Email: " + studentEmail + "<br>" + "CourseId: " + studentCourseId;
data.statusForAjax = Const.StatusMessages.STUDENT_GOOGLEID_RESET + "<br>" + "Email : " + studentEmail + "<br>" + "CourseId : " + studentCourseId;
data.isGoogleIdReset = true;
deleteAccountIfNeeded(wrongGoogleId);
} else {
data.isGoogleIdReset = false;
statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_GOOGLEID_RESET_FAIL, StatusMessageColor.DANGER));
statusToAdmin = Const.StatusMessages.STUDENT_GOOGLEID_RESET_FAIL + "<br>" + "Email: " + studentEmail + "<br>" + "CourseId: " + studentCourseId + "<br>";
data.statusForAjax = Const.StatusMessages.STUDENT_GOOGLEID_RESET_FAIL + "<br>" + "Email : " + studentEmail + "<br>" + "CourseId : " + studentCourseId;
}
isError = false;
return createAjaxResult(data);
}
isError = true;
return createAjaxResult(data);
}
use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.
the class FeedbackSubmissionEditSaveAction method extractFeedbackResponseData.
private FeedbackResponseAttributes extractFeedbackResponseData(Map<String, String[]> requestParameters, int questionIndx, int responseIndx, FeedbackQuestionAttributes feedbackQuestionAttributes) {
FeedbackQuestionDetails questionDetails = feedbackQuestionAttributes.getQuestionDetails();
FeedbackResponseAttributes response = new FeedbackResponseAttributes();
// This field can be null if the response is new
response.setId(getRequestParamValue(Const.ParamsNames.FEEDBACK_RESPONSE_ID + "-" + questionIndx + "-" + responseIndx));
response.feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, response.feedbackSessionName);
response.courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, response.courseId);
response.feedbackQuestionId = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID + "-" + questionIndx);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_QUESTION_ID + "-" + questionIndx, response.feedbackQuestionId);
Assumption.assertEquals("feedbackQuestionId Mismatch", feedbackQuestionAttributes.getId(), response.feedbackQuestionId);
response.recipient = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-" + questionIndx + "-" + responseIndx);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-" + questionIndx + "-" + responseIndx, response.recipient);
String feedbackQuestionType = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-" + questionIndx);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-" + questionIndx, feedbackQuestionType);
response.feedbackQuestionType = FeedbackQuestionType.valueOf(feedbackQuestionType);
FeedbackParticipantType recipientType = feedbackQuestionAttributes.recipientType;
if (recipientType == FeedbackParticipantType.INSTRUCTORS || recipientType == FeedbackParticipantType.NONE) {
response.recipientSection = Const.DEFAULT_SECTION;
} else if (recipientType == FeedbackParticipantType.TEAMS) {
response.recipientSection = logic.getSectionForTeam(courseId, response.recipient);
} else if (recipientType == FeedbackParticipantType.STUDENTS) {
StudentAttributes student = logic.getStudentForEmail(courseId, response.recipient);
response.recipientSection = student == null ? Const.DEFAULT_SECTION : student.section;
} else {
response.recipientSection = getUserSectionForCourse();
}
// This field can be null if the question is skipped
String paramName = Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-" + questionIndx + "-" + responseIndx;
String[] answer = getRequestParamValues(paramName);
if (questionDetails.isQuestionSkipped(answer)) {
response.responseMetaData = new Text("");
} else {
FeedbackResponseDetails responseDetails = FeedbackResponseDetails.createResponseDetails(answer, questionDetails.getQuestionType(), questionDetails, requestParameters, questionIndx, responseIndx);
response.setResponseDetails(responseDetails);
}
return response;
}
use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.
the class InstructorCourseRemindAction method execute.
@Override
public ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
CourseAttributes course = logic.getCourse(courseId);
if (course == null) {
throw new EntityDoesNotExistException("Course with ID " + courseId + " does not exist!");
}
String studentEmail = getRequestParamValue(Const.ParamsNames.STUDENT_EMAIL);
String instructorEmail = getRequestParamValue(Const.ParamsNames.INSTRUCTOR_EMAIL);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
boolean isSendingToStudent = studentEmail != null;
boolean isSendingToInstructor = instructorEmail != null;
if (isSendingToStudent) {
gateKeeper.verifyAccessible(instructor, course, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
} else if (isSendingToInstructor) {
gateKeeper.verifyAccessible(instructor, course, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR);
} else {
// this is sending registration emails to all students in the course and we will check if the instructor
// canmodifystudent for course level since for modifystudent privilege there is only course level setting for now
gateKeeper.verifyAccessible(instructor, course, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
}
/* Process sending emails and setup status to be shown to user and admin */
Map<String, JoinEmailData> emailDataMap = new TreeMap<>();
String redirectUrl = "";
if (isSendingToStudent) {
taskQueuer.scheduleCourseRegistrationInviteToStudent(courseId, studentEmail, false);
StudentAttributes studentData = logic.getStudentForEmail(courseId, studentEmail);
if (studentData == null) {
throw new EntityDoesNotExistException("Student with email " + studentEmail + " does not exist " + "in course " + courseId + "!");
}
emailDataMap.put(studentEmail, new JoinEmailData(studentData.getName(), extractStudentRegistrationKey(studentData)));
statusToUser.add(new StatusMessage(Const.StatusMessages.COURSE_REMINDER_SENT_TO + studentEmail, StatusMessageColor.SUCCESS));
redirectUrl = Const.ActionURIs.INSTRUCTOR_COURSE_DETAILS_PAGE;
} else if (isSendingToInstructor) {
taskQueuer.scheduleCourseRegistrationInviteToInstructor(loggedInUser.googleId, instructorEmail, courseId);
InstructorAttributes instructorData = logic.getInstructorForEmail(courseId, instructorEmail);
if (instructorData == null) {
throw new EntityDoesNotExistException("Instructor with email " + instructorEmail + " does not exist " + "in course " + courseId + "!");
}
emailDataMap.put(instructorEmail, new JoinEmailData(instructorData.getName(), StringHelper.encrypt(instructorData.key)));
statusToUser.add(new StatusMessage(Const.StatusMessages.COURSE_REMINDER_SENT_TO + instructorEmail, StatusMessageColor.SUCCESS));
redirectUrl = Const.ActionURIs.INSTRUCTOR_COURSE_EDIT_PAGE;
} else {
List<StudentAttributes> studentDataList = logic.getUnregisteredStudentsForCourse(courseId);
for (StudentAttributes student : studentDataList) {
taskQueuer.scheduleCourseRegistrationInviteToStudent(course.getId(), student.getEmail(), false);
emailDataMap.put(student.getEmail(), new JoinEmailData(student.getName(), extractStudentRegistrationKey(student)));
}
statusToUser.add(new StatusMessage(Const.StatusMessages.COURSE_REMINDERS_SENT, StatusMessageColor.SUCCESS));
redirectUrl = Const.ActionURIs.INSTRUCTOR_COURSE_DETAILS_PAGE;
}
statusToAdmin = generateStatusToAdmin(emailDataMap, courseId);
/* Create redirection with URL based on type of sending email */
RedirectResult response = createRedirectResult(redirectUrl);
response.addResponseParam(Const.ParamsNames.COURSE_ID, courseId);
return response;
}
use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.
the class InstructorCourseStudentDetailsPageAction method execute.
@Override
public ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
String studentEmail = getRequestParamValue(Const.ParamsNames.STUDENT_EMAIL);
Assumption.assertPostParamNotNull(Const.ParamsNames.STUDENT_EMAIL, studentEmail);
StudentAttributes student = logic.getStudentForEmail(courseId, studentEmail);
if (student == null) {
statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_NOT_FOUND_FOR_COURSE_DETAILS, StatusMessageColor.DANGER));
isError = true;
return createRedirectResult(Const.ActionURIs.INSTRUCTOR_HOME_PAGE);
}
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId), student.section, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS);
boolean hasSection = logic.hasIndicatedSections(courseId);
StudentProfileAttributes studentProfile = loadStudentProfile(student, instructor);
InstructorCourseStudentDetailsPageData data = new InstructorCourseStudentDetailsPageData(account, sessionToken, student, studentProfile, hasSection);
statusToAdmin = "instructorCourseStudentDetails Page Load<br>" + "Viewing details for Student <span class=\"bold\">" + studentEmail + "</span> in Course <span class=\"bold\">[" + courseId + "]</span>";
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_COURSE_STUDENT_DETAILS, data);
}
Aggregations