use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.
the class InstructorFeedbackEditCopyActionTest method testAccessControl.
@Override
@Test
protected void testAccessControl() throws Exception {
String[] params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, "First feedback session", Const.ParamsNames.COURSE_ID, "idOfTypicalCourse1", Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "Session with valid name", Const.ParamsNames.COPIED_COURSES_ID, "idOfTypicalCourse2", Const.ParamsNames.COPIED_COURSES_ID, "idOfSampleCourse-demo" };
verifyUnaccessibleWithoutViewSessionInSectionsPrivilege(params);
FeedbackSessionAttributes fs = dataBundle.feedbackSessions.get("openSession");
CourseAttributes course = dataBundle.courses.get("course");
______TS("Failure case: copying from course with insufficient permission");
InstructorAttributes instructor = dataBundle.instructors.get("teammates.test.instructor3");
String instructorId = instructor.googleId;
gaeSimulation.loginAsInstructor(instructorId);
params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "valid name", Const.ParamsNames.COPIED_COURSES_ID, course.getId() };
InstructorFeedbackEditCopyAction a = getAction(params);
try {
a.executeAndPostProcess();
signalFailureToDetectException();
} catch (UnauthorizedAccessException uae) {
String expectedString = "Course [FeedbackEditCopy.CS2104] is not accessible to instructor " + "[tmms.instr.cust@course.tmt] for privilege [canviewsessioninsection]";
assertEquals(expectedString, uae.getMessage());
}
gaeSimulation.logoutUser();
______TS("Failure case: copying to course with insufficient permission");
instructor = dataBundle.instructors.get("teammates.test.instructor2");
instructorId = instructor.googleId;
gaeSimulation.loginAsInstructor(instructorId);
params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "valid name", Const.ParamsNames.COPIED_COURSES_ID, "FeedbackEditCopy.CS2107" };
a = getAction(params);
try {
a.executeAndPostProcess();
signalFailureToDetectException();
} catch (UnauthorizedAccessException uae) {
String expectedString = "Course [FeedbackEditCopy.CS2107] is not accessible to instructor " + "[tmms.instr@course.tmt] for privilege [canmodifysession]";
assertEquals(expectedString, uae.getMessage());
}
}
use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.
the class InstructorFeedbackEditCopyPageActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
InstructorAttributes instructor = dataBundle.instructors.get("teammates.test.instructor2");
String instructorId = instructor.googleId;
gaeSimulation.loginAsInstructor(instructorId);
______TS("Successful case");
String[] submissionParams = { Const.ParamsNames.COURSE_ID, "valid course id", Const.ParamsNames.FEEDBACK_SESSION_NAME, "valid fs name" };
InstructorFeedbackEditCopyPageAction a = getAction(submissionParams);
ShowPageResult r = getShowPageResult(a);
assertFalse(r.isError);
InstructorFeedbackEditCopyPageData pageData = (InstructorFeedbackEditCopyPageData) r.data;
assertEquals(4, pageData.getCourses().size());
List<String> idOfCourses = new ArrayList<>();
for (CourseAttributes course : pageData.getCourses()) {
idOfCourses.add(course.getId());
}
// course is archived
assertFalse(idOfCourses.contains("FeedbackEditCopy.CS1101"));
// instructor does not have sufficient permissions
assertFalse(idOfCourses.contains("FeedbackEditCopy.CS2107"));
assertTrue(idOfCourses.contains("FeedbackEditCopy.CS2102"));
assertTrue(idOfCourses.contains("FeedbackEditCopy.CS2103"));
assertTrue(idOfCourses.contains("FeedbackEditCopy.CS2103R"));
assertTrue(idOfCourses.contains("FeedbackEditCopy.CS2104"));
}
use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.
the class InstructorCourseDeleteActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
InstructorAttributes instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
String instructorId = instructor1OfCourse1.googleId;
gaeSimulation.loginAsInstructor(instructorId);
______TS("Not enough parameters");
verifyAssumptionFailure();
______TS("Typical case, 2 courses, redirect to homepage");
CoursesLogic.inst().createCourseAndInstructor(instructorId, "icdct.tpa.id1", "New course", "UTC");
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId, Const.ParamsNames.NEXT_URL, Const.ActionURIs.INSTRUCTOR_HOME_PAGE };
assertTrue(CoursesLogic.inst().isCoursePresent("icdct.tpa.id1"));
InstructorCourseDeleteAction deleteAction = getAction(submissionParams);
RedirectResult redirectResult = getRedirectResult(deleteAction);
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_HOME_PAGE, false, "idOfInstructor1OfCourse1"), redirectResult.getDestinationWithParams());
assertFalse(redirectResult.isError);
assertEquals("The course idOfTypicalCourse1 has been deleted.", redirectResult.getStatusMessage());
List<CourseAttributes> courseList = CoursesLogic.inst().getCoursesForInstructor(instructorId);
assertEquals(1, courseList.size());
assertEquals("icdct.tpa.id1", courseList.get(0).getId());
String expectedLogMessage = "TEAMMATESLOG|||instructorCourseDelete|||instructorCourseDelete|||true|||" + "Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||" + "instr1@course1.tmt|||Course deleted: idOfTypicalCourse1|||" + "/page/instructorCourseDelete";
AssertHelper.assertLogMessageEquals(expectedLogMessage, deleteAction.getLogMessage());
______TS("Masquerade mode, delete last course, redirect to Courses page");
String adminUserId = "admin.user";
gaeSimulation.loginAsAdmin(adminUserId);
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, "icdct.tpa.id1", Const.ParamsNames.NEXT_URL, Const.ActionURIs.INSTRUCTOR_COURSES_PAGE };
deleteAction = getAction(addUserIdToParams(instructorId, submissionParams));
redirectResult = getRedirectResult(deleteAction);
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_COURSES_PAGE, false, "idOfInstructor1OfCourse1"), redirectResult.getDestinationWithParams());
assertFalse(redirectResult.isError);
assertEquals("The course icdct.tpa.id1 has been deleted.", redirectResult.getStatusMessage());
courseList = CoursesLogic.inst().getCoursesForInstructor(instructorId);
assertEquals(0, courseList.size());
expectedLogMessage = "TEAMMATESLOG|||instructorCourseDelete|||instructorCourseDelete|||true|||Instructor(M)|||" + "Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Course deleted: icdct.tpa.id1|||/page/instructorCourseDelete";
AssertHelper.assertLogMessageEqualsInMasqueradeMode(expectedLogMessage, deleteAction.getLogMessage(), adminUserId);
______TS("Masquerade mode, delete last course, no next URL, redirect to Courses page");
CoursesLogic.inst().createCourseAndInstructor(instructorId, "icdct.tpa.id2", "New course", "UTC");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, "icdct.tpa.id2" };
deleteAction = getAction(addUserIdToParams(instructorId, submissionParams));
redirectResult = getRedirectResult(deleteAction);
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_COURSES_PAGE, false, "idOfInstructor1OfCourse1"), redirectResult.getDestinationWithParams());
assertFalse(redirectResult.isError);
assertEquals("The course icdct.tpa.id2 has been deleted.", redirectResult.getStatusMessage());
courseList = CoursesLogic.inst().getCoursesForInstructor(instructorId);
assertEquals(0, courseList.size());
expectedLogMessage = "TEAMMATESLOG|||instructorCourseDelete|||instructorCourseDelete|||true|||Instructor(M)|||" + "Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Course deleted: icdct.tpa.id2|||/page/instructorCourseDelete";
AssertHelper.assertLogMessageEqualsInMasqueradeMode(expectedLogMessage, deleteAction.getLogMessage(), adminUserId);
}
use of teammates.common.datatransfer.attributes.CourseAttributes 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.CourseAttributes in project teammates by TEAMMATES.
the class CourseJoinAuthenticatedAbstractAction method sendCourseRegisteredEmail.
protected void sendCourseRegisteredEmail(String name, String emailAddress, boolean isInstructor, String courseId) {
CourseAttributes course = logic.getCourse(courseId);
EmailWrapper email = new EmailGenerator().generateUserCourseRegisteredEmail(name, emailAddress, account.googleId, isInstructor, course);
try {
emailSender.sendEmail(email);
} catch (EmailSendingException e) {
log.severe("User course register email failed to send: " + TeammatesException.toStringWithStackTrace(e));
}
}
Aggregations