use of teammates.ui.pagedata.InstructorCourseDetailsPageData in project teammates by TEAMMATES.
the class InstructorCourseDetailsPageActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
InstructorAttributes instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
gaeSimulation.loginAsInstructor(instructor1OfCourse1.googleId);
______TS("Not enough parameters");
verifyAssumptionFailure();
______TS("Typical Case, Course with at least one student");
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId };
InstructorCourseDetailsPageAction pageAction = getAction(submissionParams);
ShowPageResult pageResult = getShowPageResult(pageAction);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_COURSE_DETAILS, false, "idOfInstructor1OfCourse1"), pageResult.getDestinationWithParams());
assertFalse(pageResult.isError);
assertEquals("", pageResult.getStatusMessage());
InstructorCourseDetailsPageData pageData = (InstructorCourseDetailsPageData) pageResult.data;
assertEquals(5, pageData.getInstructors().size());
assertEquals("idOfTypicalCourse1", pageData.getCourseDetails().course.getId());
assertEquals("Typical Course 1 with 2 Evals", pageData.getCourseDetails().course.getName());
assertEquals(2, pageData.getCourseDetails().stats.teamsTotal);
assertEquals(5, pageData.getCourseDetails().stats.studentsTotal);
assertEquals(0, pageData.getCourseDetails().stats.unregisteredTotal);
assertEquals(0, pageData.getCourseDetails().feedbackSessions.size());
String expectedLogMessage = "TEAMMATESLOG|||instructorCourseDetailsPage|||instructorCourseDetailsPage|||true" + "|||Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1" + "|||instr1@course1.tmt|||instructorCourseDetails Page Load<br>Viewing Course " + "Details for Course <span class=\"bold\">[idOfTypicalCourse1]</span>" + "|||/page/instructorCourseDetailsPage";
AssertHelper.assertLogMessageEquals(expectedLogMessage, pageAction.getLogMessage());
______TS("Masquerade mode, Course with no student");
String adminUserId = "admin.user";
gaeSimulation.loginAsAdmin(adminUserId);
InstructorAttributes instructor4 = typicalBundle.instructors.get("instructor4");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor4.courseId };
pageAction = getAction(addUserIdToParams(instructor4.googleId, submissionParams));
pageResult = getShowPageResult(pageAction);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_COURSE_DETAILS, false, "idOfInstructor4"), pageResult.getDestinationWithParams());
assertFalse(pageResult.isError);
assertEquals(String.format(Const.StatusMessages.INSTRUCTOR_COURSE_EMPTY, pageResult.data.getInstructorCourseEnrollLink(instructor4.courseId)), pageResult.getStatusMessage());
pageData = (InstructorCourseDetailsPageData) pageResult.data;
assertEquals(1, pageData.getInstructors().size());
assertEquals("idOfCourseNoEvals", pageData.getCourseDetails().course.getId());
assertEquals("Typical Course 3 with 0 Evals", pageData.getCourseDetails().course.getName());
assertEquals(0, pageData.getCourseDetails().stats.teamsTotal);
assertEquals(0, pageData.getCourseDetails().stats.studentsTotal);
assertEquals(0, pageData.getCourseDetails().stats.unregisteredTotal);
assertEquals(0, pageData.getCourseDetails().feedbackSessions.size());
expectedLogMessage = "TEAMMATESLOG|||instructorCourseDetailsPage|||instructorCourseDetailsPage|||true|||" + "Instructor(M)|||Instructor 4 of CourseNoEvals|||idOfInstructor4|||" + "instr4@coursenoevals.tmt|||instructorCourseDetails Page Load<br>Viewing Course " + "Details for Course <span class=\"bold\">[idOfCourseNoEvals]</span>|||" + "/page/instructorCourseDetailsPage";
AssertHelper.assertLogMessageEqualsInMasqueradeMode(expectedLogMessage, pageAction.getLogMessage(), adminUserId);
______TS("HTML Table needed");
instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
gaeSimulation.loginAsInstructor(instructor1OfCourse1.googleId);
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId, Const.ParamsNames.CSV_TO_HTML_TABLE_NEEDED, "true" };
pageAction = getAction(submissionParams);
AjaxResult ajaxResult = this.getAjaxResult(pageAction);
assertEquals(getPageResultDestination("", false, "idOfInstructor1OfCourse1"), ajaxResult.getDestinationWithParams());
assertFalse(pageResult.isError);
assertEquals("", ajaxResult.getStatusMessage());
pageData = (InstructorCourseDetailsPageData) ajaxResult.data;
assertEquals("<table class=\"table table-bordered table-striped table-condensed\">" + "<tr>" + "<td>Course ID</td>" + "<td>idOfTypicalCourse1</td>" + "</tr>" + "<tr>" + "<td>Course Name</td>" + "<td>Typical Course 1 with 2 Evals</td>" + "</tr>" + "<tr>" + "<td>Section</td>" + "<td>Team</td>" + "<td>Full Name</td>" + "<td>Last Name</td>" + "<td>Status</td>" + "<td>Email</td>" + "</tr>" + "<tr>" + "<td>Section 1</td>" + "<td>Team 1.1</td></div>'"</td>" + "<td>student1 In Course1</td></div>'"</td>" + "<td>Course1</td></div>'"</td>" + "<td>Joined</td>" + "<td>student1InCourse1@gmail.tmt</td>" + "</tr>" + "<tr>" + "<td>Section 1</td>" + "<td>Team 1.1</td></div>'"</td>" + "<td>student2 In Course1</td>" + "<td>Course1</td>" + "<td>Joined</td>" + "<td>student2InCourse1@gmail.tmt</td>" + "</tr>" + "<tr>" + "<td>Section 1</td>" + "<td>Team 1.1</td></div>'"</td>" + "<td>student3 In Course1</td>" + "<td>Course1</td>" + "<td>Joined</td>" + "<td>student3InCourse1@gmail.tmt</td>" + "</tr>" + "<tr>" + "<td>Section 1</td>" + "<td>Team 1.1</td></div>'"</td>" + "<td>student4 In Course1</td>" + "<td>Course1</td>" + "<td>Joined</td>" + "<td>student4InCourse1@gmail.tmt</td>" + "</tr>" + "<tr>" + "<td>Section 2</td>" + "<td>Team 1.2</td>" + "<td>student5 In Course1</td>" + "<td>Course1</td>" + "<td>Joined</td>" + "<td>student5InCourse1@gmail.tmt</td>" + "</tr>" + "</table>", pageData.getStudentListHtmlTableAsString());
}
use of teammates.ui.pagedata.InstructorCourseDetailsPageData in project teammates by TEAMMATES.
the class InstructorCourseDetailsPageDataTest method testAll.
@Test
public void testAll() {
______TS("test typical case");
AccountAttributes instructorAccount = dataBundle.accounts.get("instructor1OfCourse1");
InstructorCourseDetailsPageData pageData = new InstructorCourseDetailsPageData(instructorAccount, dummySessionToken);
InstructorAttributes curInstructor = dataBundle.instructors.get("instructor1OfCourse1");
List<InstructorAttributes> instructors = new ArrayList<>();
for (InstructorAttributes instructor : dataBundle.instructors.values()) {
if ("idOfTypicalCourse1".equals(instructor.courseId)) {
instructors.add(instructor);
}
}
CourseDetailsBundle courseDetails = new CourseDetailsBundle(dataBundle.courses.get("typicalCourse1"));
courseDetails.sections = new ArrayList<>();
SectionDetailsBundle sampleSection = new SectionDetailsBundle();
sampleSection.name = "Sample section name";
courseDetails.sections.add(sampleSection);
pageData.init(curInstructor, courseDetails, instructors);
assertEquals(instructors.size(), pageData.getInstructors().size());
assertNotNull(pageData.getCourseRemindButton());
assertFalse(pageData.getCourseRemindButton().getAttributes().isEmpty());
assertNull(pageData.getCourseRemindButton().getContent());
assertNotNull(pageData.getCourseDetails());
assertNotNull(pageData.getCurrentInstructor());
assertTrue(pageData.isHasSection());
assertEquals(1, pageData.getSections().size());
______TS("test data bundle with no section");
courseDetails.sections = new ArrayList<>();
sampleSection = new SectionDetailsBundle();
sampleSection.name = "None";
courseDetails.sections.add(sampleSection);
pageData.init(curInstructor, courseDetails, instructors);
assertFalse(pageData.isHasSection());
assertEquals(1, pageData.getSections().size());
______TS("test current instructor doesn't have any permission for the course");
String[] allPrivileges = { Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COURSE, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_SESSION_IN_SECTIONS, Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS };
for (String privilege : allPrivileges) {
curInstructor.privileges.updatePrivilege(privilege, false);
}
pageData.init(curInstructor, courseDetails, instructors);
assertEquals(instructors.size(), pageData.getInstructors().size());
assertNotNull(pageData.getCourseRemindButton());
assertFalse(pageData.getCourseRemindButton().getAttributes().isEmpty());
assertNull(pageData.getCourseRemindButton().getContent());
assertNotNull(pageData.getCourseDetails());
assertNotNull(pageData.getCurrentInstructor());
}
use of teammates.ui.pagedata.InstructorCourseDetailsPageData in project teammates by TEAMMATES.
the class InstructorCourseDetailsPageAction method execute.
@Override
public ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
// this is for ajax loading of the htm table in the modal
boolean isHtmlTableNeeded = getRequestParamAsBoolean(Const.ParamsNames.CSV_TO_HTML_TABLE_NEEDED);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId));
/* Setup page data for the "Course Details" page */
InstructorCourseDetailsPageData data = new InstructorCourseDetailsPageData(account, sessionToken);
if (isHtmlTableNeeded) {
String courseStudentListAsCsv = logic.getCourseStudentListAsCsv(courseId, account.googleId);
data.setStudentListHtmlTableAsString(StringHelper.csvToHtmlTable(courseStudentListAsCsv));
statusToAdmin = "instructorCourseDetails Page Ajax Html table Load<br>" + "Viewing Student List Table for Course <span class=\"bold\">[" + courseId + "]</span>";
return createAjaxResult(data);
}
CourseDetailsBundle courseDetails = logic.getCourseDetails(courseId);
List<InstructorAttributes> instructors = logic.getInstructorsForCourse(courseId);
data.init(instructor, courseDetails, instructors);
if (courseDetails.getStats().getStudentsTotal() == 0) {
String message = String.format(Const.StatusMessages.INSTRUCTOR_COURSE_EMPTY, data.getInstructorCourseEnrollLink(courseId));
statusToUser.add(new StatusMessage(message, StatusMessageColor.WARNING));
}
statusToAdmin = "instructorCourseDetails Page Load<br>" + "Viewing Course Details for Course <span class=\"bold\">[" + courseId + "]</span>";
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_COURSE_DETAILS, data);
}
Aggregations