use of teammates.common.datatransfer.attributes.InstructorAttributes in project teammates by TEAMMATES.
the class InstructorCourseStudentDeleteAllActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
InstructorAttributes instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
______TS("success: delete all students");
gaeSimulation.loginAsInstructor(instructor1OfCourse1.googleId);
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId };
InstructorCourseStudentDeleteAllAction action = getAction(submissionParams);
RedirectResult redirectResult = getRedirectResult(action);
assertEquals(Const.ActionURIs.INSTRUCTOR_COURSE_DETAILS_PAGE, redirectResult.destination);
assertFalse(redirectResult.isError);
assertEquals(Const.StatusMessages.STUDENTS_DELETED, redirectResult.getStatusMessage());
AssertHelper.assertLogMessageEquals("TEAMMATESLOG|||instructorCourseStudentDeleteAll|||" + "instructorCourseStudentDeleteAll|||true|||Instructor|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||All the Students in Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span> are deleted.|||" + "/page/instructorCourseStudentDeleteAll", action.getLogMessage());
}
use of teammates.common.datatransfer.attributes.InstructorAttributes 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.InstructorAttributes in project teammates by TEAMMATES.
the class AdminInstructorAccountAddAction method execute.
@Override
protected ActionResult execute() {
gateKeeper.verifyAdminPrivileges(account);
AdminHomePageData data = new AdminHomePageData(account, sessionToken);
data.instructorName = getNonNullRequestParamValue(Const.ParamsNames.INSTRUCTOR_NAME).trim();
data.instructorEmail = getNonNullRequestParamValue(Const.ParamsNames.INSTRUCTOR_EMAIL).trim();
data.instructorInstitution = getNonNullRequestParamValue(Const.ParamsNames.INSTRUCTOR_INSTITUTION).trim();
data.isInstructorAddingResultForAjax = true;
data.statusForAjax = "";
data.instructorName = data.instructorName.trim();
data.instructorEmail = data.instructorEmail.trim();
data.instructorInstitution = data.instructorInstitution.trim();
try {
logic.verifyInputForAdminHomePage(data.instructorName, data.instructorInstitution, data.instructorEmail);
} catch (InvalidParametersException e) {
data.statusForAjax = e.getMessage().replace(System.lineSeparator(), Const.HTML_BR_TAG);
data.isInstructorAddingResultForAjax = false;
statusToUser.add(new StatusMessage(data.statusForAjax, StatusMessageColor.DANGER));
return createAjaxResult(data);
}
String courseId = null;
try {
courseId = importDemoData(data);
} catch (Exception e) {
String retryUrl = Const.ActionURIs.ADMIN_INSTRUCTORACCOUNT_ADD;
retryUrl = Url.addParamToUrl(retryUrl, Const.ParamsNames.INSTRUCTOR_NAME, data.instructorName);
retryUrl = Url.addParamToUrl(retryUrl, Const.ParamsNames.INSTRUCTOR_EMAIL, data.instructorEmail);
retryUrl = Url.addParamToUrl(retryUrl, Const.ParamsNames.INSTRUCTOR_INSTITUTION, data.instructorInstitution);
retryUrl = Url.addParamToUrl(retryUrl, Const.ParamsNames.SESSION_TOKEN, data.getSessionToken());
StringBuilder errorMessage = new StringBuilder(100);
String retryLink = "<a href=" + retryUrl + ">Exception in Importing Data, Retry</a>";
errorMessage.append(retryLink);
statusToUser.add(new StatusMessage(errorMessage.toString(), StatusMessageColor.DANGER));
String message = "<span class=\"text-danger\">Servlet Action failure in AdminInstructorAccountAddAction" + "<br>" + e.getClass() + ": " + TeammatesException.toStringWithStackTrace(e) + "<br></span>";
errorMessage.append("<br>").append(message);
statusToUser.add(new StatusMessage("<br>" + message, StatusMessageColor.DANGER));
statusToAdmin = message;
data.isInstructorAddingResultForAjax = false;
data.statusForAjax = errorMessage.toString();
return createAjaxResult(data);
}
List<InstructorAttributes> instructorList = logic.getInstructorsForCourse(courseId);
String joinLink = Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_COURSE_JOIN).withRegistrationKey(StringHelper.encrypt(instructorList.get(0).key)).withInstructorInstitution(data.instructorInstitution).toAbsoluteString();
EmailWrapper email = new EmailGenerator().generateNewInstructorAccountJoinEmail(instructorList.get(0).email, data.instructorName, joinLink);
try {
emailSender.sendEmail(email);
} catch (EmailSendingException e) {
log.severe("Instructor welcome email failed to send: " + TeammatesException.toStringWithStackTrace(e));
}
data.statusForAjax = "Instructor " + SanitizationHelper.sanitizeForHtml(data.instructorName) + " has been successfully created " + "<a href=" + joinLink + ">" + Const.JOIN_LINK + "</a>";
statusToUser.add(new StatusMessage(data.statusForAjax, StatusMessageColor.SUCCESS));
statusToAdmin = "A New Instructor <span class=\"bold\">" + SanitizationHelper.sanitizeForHtmlTag(data.instructorName) + "</span> has been created.<br>" + "<span class=\"bold\">Id: </span>" + "ID will be assigned when the verification link was clicked and confirmed" + "<br>" + "<span class=\"bold\">Email: </span>" + SanitizationHelper.sanitizeForHtmlTag(data.instructorEmail) + "<span class=\"bold\">Institution: </span>" + SanitizationHelper.sanitizeForHtmlTag(data.instructorInstitution);
return createAjaxResult(data);
}
use of teammates.common.datatransfer.attributes.InstructorAttributes in project teammates by TEAMMATES.
the class AdminSearchPageAction method putInstructorHomePageLinkIntoMap.
private AdminSearchPageData putInstructorHomePageLinkIntoMap(List<InstructorAttributes> instructors, AdminSearchPageData data) {
for (InstructorAttributes instructor : instructors) {
if (instructor.googleId == null) {
continue;
}
String curLink = Url.addParamToUrl(Const.ActionURIs.INSTRUCTOR_HOME_PAGE, Const.ParamsNames.USER_ID, instructor.googleId);
data.instructorHomePageLinkMap.put(instructor.googleId, curLink);
}
return data;
}
use of teammates.common.datatransfer.attributes.InstructorAttributes in project teammates by TEAMMATES.
the class FeedbackSessionStatsPageAction method execute.
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
FeedbackSessionStatsPageData data = new FeedbackSessionStatsPageData(account, sessionToken);
FeedbackSessionAttributes fsa = logic.getFeedbackSession(feedbackSessionName, courseId);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
gateKeeper.verifyAccessible(instructor, fsa, false);
data.sessionDetails = logic.getFeedbackSessionDetails(feedbackSessionName, courseId);
return createAjaxResult(data);
}
Aggregations