use of teammates.common.datatransfer.CourseDetailsBundle in project teammates by TEAMMATES.
the class InstructorFeedbackEditPageDataTest method allTests.
@Test
public void allTests() {
______TS("Typical case");
// Setup
InstructorFeedbackEditPageData data = new InstructorFeedbackEditPageData(dataBundle.accounts.get("instructor1OfCourse1"), dummySessionToken);
FeedbackSessionAttributes fs = dataBundle.feedbackSessions.get("session1InCourse1");
List<FeedbackQuestionAttributes> questions = new ArrayList<>();
questions.add(dataBundle.feedbackQuestions.get("qn1InSession1InCourse1"));
questions.add(dataBundle.feedbackQuestions.get("qn2InSession1InCourse1"));
questions.add(dataBundle.feedbackQuestions.get("qn3InSession1InCourse1"));
Map<String, Boolean> questionHasResponses = new HashMap<>();
questionHasResponses.put(dataBundle.feedbackQuestions.get("qn1InSession1InCourse1").getId(), true);
List<StudentAttributes> studentList = new ArrayList<>();
studentList.add(dataBundle.students.get("student1InCourse1"));
List<InstructorAttributes> instructorList = new ArrayList<>();
instructorList.add(dataBundle.instructors.get("instructor1OfCourse1"));
InstructorAttributes instructor = getInstructorFromBundle("instructor1OfCourse1");
CourseDetailsBundle courseDetails = new CourseDetailsBundle(dataBundle.courses.get("typicalCourse1"));
data.init(fs, questions, questionHasResponses, studentList, instructorList, instructor, true, instructorList.size(), courseDetails);
// Test fs form
FeedbackSessionsForm fsForm = data.getFsForm();
assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_COPY_PAGE).withUserId(instructor.googleId).toString(), fsForm.getCopyToLink());
assertEquals(fs.getCourseId(), fsForm.getCourseId());
assertNull(fsForm.getCourses());
assertNull(fsForm.getCoursesSelectField());
assertFalse(fsForm.isFeedbackSessionTypeEditable());
assertTrue(fsForm.isEditFsButtonsVisible());
assertNull(fsForm.getFeedbackSessionTypeOptions());
assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_SAVE).toString(), fsForm.getFormSubmitAction());
assertEquals(data.getInstructorFeedbackDeleteLink(fs.getCourseId(), fs.getFeedbackSessionName(), Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE), fsForm.getFsDeleteLink());
assertEquals(TimeHelper.formatDateForSessionsForm(fs.getEndTimeLocal()), fsForm.getFsEndDate());
assertEquals(fs.getFeedbackSessionName(), fsForm.getFsName());
assertEquals(TimeHelper.formatDateForSessionsForm(fs.getStartTimeLocal()), fsForm.getFsStartDate());
assertEquals(SanitizationHelper.sanitizeForHtml(fs.getInstructions().getValue()), fsForm.getInstructions());
assertEquals("Save Changes", fsForm.getSubmitButtonText());
assertFalse(fsForm.isCourseIdEditable());
assertFalse(fsForm.isShowNoCoursesMessage());
assertFalse(fsForm.isSubmitButtonVisible());
assertFalse(fsForm.isSubmitButtonDisabled());
FeedbackSessionsAdditionalSettingsFormSegment additionalSettings = data.getFsForm().getAdditionalSettings();
assertEquals(TimeHelper.formatDateForSessionsForm(fs.getResultsVisibleFromTimeLocal()), additionalSettings.getResponseVisibleDateValue());
assertEquals(TimeHelper.formatDateForSessionsForm(fs.getSessionVisibleFromTimeLocal()), additionalSettings.getSessionVisibleDateValue());
assertFalse(additionalSettings.isResponseVisiblePublishManuallyChecked());
assertTrue(additionalSettings.isResponseVisibleDateChecked());
assertFalse(additionalSettings.isResponseVisibleImmediatelyChecked());
assertFalse(additionalSettings.isResponseVisibleDateDisabled());
assertFalse(additionalSettings.isSessionVisibleAtOpenChecked());
assertFalse(additionalSettings.isSessionVisibleDateDisabled());
assertTrue(additionalSettings.isSessionVisibleDateButtonChecked());
assertFalse(additionalSettings.isSessionVisiblePrivateChecked());
assertTrue(additionalSettings.isSendClosingEmailChecked());
assertTrue(additionalSettings.isSendOpeningEmailChecked());
assertTrue(additionalSettings.isSendPublishedEmailChecked());
// test question edit forms
List<FeedbackQuestionEditForm> questionForms = data.getQnForms();
assertEquals(3, questionForms.size());
assertEquals(Const.ActionURIs.INSTRUCTOR_FEEDBACK_QUESTION_EDIT, questionForms.get(0).getAction());
assertEquals(fs.getCourseId(), questionForms.get(0).getCourseId());
assertEquals(fs.getFeedbackSessionName(), questionForms.get(0).getFeedbackSessionName());
String questionTextOfFirstQuestion = dataBundle.feedbackQuestions.get("qn1InSession1InCourse1").getQuestionDetails().getQuestionText();
assertEquals(questionTextOfFirstQuestion, questionForms.get(0).getQuestionText());
assertEquals(3, questionForms.get(0).getQuestionNumberOptions().size());
assertEquals("What is the best selling point of your product?", questionForms.get(0).getQuestionText());
FeedbackQuestionFeedbackPathSettings feedbackPath = questionForms.get(0).getFeedbackPathSettings();
assertTrue(feedbackPath.isNumberOfEntitiesToGiveFeedbackToChecked());
assertEquals(DEFAULT_NUM_ENTITIES_TO_GIVE_RESPONSES_TO, feedbackPath.getNumOfEntitiesToGiveFeedbackToValue());
assertEquals(1, questionForms.get(0).getQuestionIndex());
// Test visibility settings for the zero'th question form
FeedbackQuestionVisibilitySettings visibilitySettings = questionForms.get(0).getVisibilitySettings();
verifyMapContains(visibilitySettings.getResponseVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS));
verifyMapContains(visibilitySettings.getGiverNameVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS));
verifyMapContains(visibilitySettings.getRecipientNameVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS));
assertEquals("Rate 1 other student's product", questionForms.get(1).getQuestionText());
assertTrue(questionForms.get(1).getFeedbackPathSettings().isNumberOfEntitiesToGiveFeedbackToChecked());
assertEquals(DEFAULT_NUM_ENTITIES_TO_GIVE_RESPONSES_TO, questionForms.get(1).getFeedbackPathSettings().getNumOfEntitiesToGiveFeedbackToValue());
verifyMapContains(questionForms.get(1).getVisibilitySettings().getResponseVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS, FeedbackParticipantType.RECEIVER));
verifyMapContains(questionForms.get(1).getVisibilitySettings().getGiverNameVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS));
verifyMapContains(questionForms.get(1).getVisibilitySettings().getRecipientNameVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS, FeedbackParticipantType.RECEIVER));
assertEquals("My comments on the class", questionForms.get(2).getQuestionText());
assertEquals(3, questionForms.get(2).getQuestionIndex());
assertFalse(questionForms.get(2).getFeedbackPathSettings().isNumberOfEntitiesToGiveFeedbackToChecked());
assertEquals(DEFAULT_NUM_ENTITIES_TO_GIVE_RESPONSES_TO, questionForms.get(2).getFeedbackPathSettings().getNumOfEntitiesToGiveFeedbackToValue());
verifyMapContains(questionForms.get(2).getVisibilitySettings().getResponseVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS, FeedbackParticipantType.RECEIVER, FeedbackParticipantType.STUDENTS, FeedbackParticipantType.OWN_TEAM_MEMBERS));
verifyMapContains(questionForms.get(2).getVisibilitySettings().getGiverNameVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS, FeedbackParticipantType.RECEIVER, FeedbackParticipantType.STUDENTS, FeedbackParticipantType.OWN_TEAM_MEMBERS));
verifyMapContains(questionForms.get(2).getVisibilitySettings().getRecipientNameVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS, FeedbackParticipantType.RECEIVER, FeedbackParticipantType.STUDENTS, FeedbackParticipantType.OWN_TEAM_MEMBERS));
// TODO test specific question edit form html after it is no longer html in java
// test question add form
FeedbackQuestionEditForm newQuestionForm = data.getNewQnForm();
assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE).withUserId(instructor.googleId).withCourseId(fs.getCourseId()).withSessionName(fs.getFeedbackSessionName()).toString(), newQuestionForm.getDoneEditingLink());
assertFalse(newQuestionForm.getFeedbackPathSettings().isNumberOfEntitiesToGiveFeedbackToChecked());
assertEquals(-1, newQuestionForm.getQuestionIndex());
assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE).withUserId(instructor.googleId).withCourseId(fs.getCourseId()).withSessionName(fs.getFeedbackSessionName()).toString(), newQuestionForm.getDoneEditingLink());
// preview form
FeedbackSessionPreviewForm previewForm = data.getPreviewForm();
assertEquals(1, previewForm.getStudentToPreviewAsOptions().size());
assertEquals(1, previewForm.getInstructorToPreviewAsOptions().size());
______TS("empty feedback session");
// setup
data = new InstructorFeedbackEditPageData(dataBundle.accounts.get("instructor1OfCourse1"), dummySessionToken);
fs = dataBundle.feedbackSessions.get("empty.session");
fs.setPublishedEmailEnabled(false);
fs.setClosingEmailEnabled(false);
questions = new ArrayList<>();
questionHasResponses = new HashMap<>();
studentList = new ArrayList<>();
instructorList = new ArrayList<>();
instructor = getInstructorFromBundle("instructor1OfCourse1");
courseDetails = new CourseDetailsBundle(dataBundle.courses.get("typicalCourse1"));
data.init(fs, questions, questionHasResponses, studentList, instructorList, instructor, true, instructorList.size(), courseDetails);
fsForm = data.getFsForm();
assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_COPY_PAGE).withUserId(instructor.googleId).toString(), fsForm.getCopyToLink());
assertEquals(fs.getCourseId(), fsForm.getCourseId());
assertNull(fsForm.getCourses());
assertNull(fsForm.getCoursesSelectField());
assertFalse(fsForm.isFeedbackSessionTypeEditable());
assertTrue(fsForm.isEditFsButtonsVisible());
assertNull(fsForm.getFeedbackSessionTypeOptions());
additionalSettings = data.getFsForm().getAdditionalSettings();
assertEquals(TimeHelper.formatDateForSessionsForm(fs.getResultsVisibleFromTimeLocal()), additionalSettings.getResponseVisibleDateValue());
assertEquals(TimeHelper.formatDateForSessionsForm(fs.getSessionVisibleFromTimeLocal()), additionalSettings.getSessionVisibleDateValue());
assertFalse(additionalSettings.isResponseVisiblePublishManuallyChecked());
assertTrue(additionalSettings.isResponseVisibleDateChecked());
assertFalse(additionalSettings.isResponseVisibleImmediatelyChecked());
assertFalse(additionalSettings.isResponseVisibleDateDisabled());
assertFalse(additionalSettings.isSessionVisibleAtOpenChecked());
assertFalse(additionalSettings.isSessionVisibleDateDisabled());
assertTrue(additionalSettings.isSessionVisibleDateButtonChecked());
assertFalse(additionalSettings.isSessionVisiblePrivateChecked());
assertFalse(additionalSettings.isSendClosingEmailChecked());
assertTrue(additionalSettings.isSendOpeningEmailChecked());
assertFalse(additionalSettings.isSendPublishedEmailChecked());
questionForms = data.getQnForms();
assertEquals(questions.size(), questionForms.size());
previewForm = data.getPreviewForm();
assertEquals(studentList.size(), previewForm.getStudentToPreviewAsOptions().size());
assertEquals(instructorList.size(), previewForm.getInstructorToPreviewAsOptions().size());
newQuestionForm = data.getNewQnForm();
assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE).withUserId(instructor.googleId).withCourseId(fs.getCourseId()).withSessionName(fs.getFeedbackSessionName()).toString(), newQuestionForm.getDoneEditingLink());
assertFalse(newQuestionForm.getFeedbackPathSettings().isNumberOfEntitiesToGiveFeedbackToChecked());
assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE).withUserId(instructor.googleId).withCourseId(fs.getCourseId()).withSessionName(fs.getFeedbackSessionName()).toString(), newQuestionForm.getDoneEditingLink());
______TS("Resolved time fields map");
data = new InstructorFeedbackEditPageData(dataBundle.accounts.get("instructor1OfCourse1"), dummySessionToken);
assertNotNull("Should be empty map if unused", data.getResolvedTimeFields());
assertTrue(data.getResolvedTimeFields().isEmpty());
Map<String, String> expected = new HashMap<>();
String startDate = "start date";
String startTime = "start time";
expected.put(Const.ParamsNames.FEEDBACK_SESSION_STARTDATE, startDate);
expected.put(Const.ParamsNames.FEEDBACK_SESSION_STARTTIME, startTime);
data.putResolvedTimeField(Const.ParamsNames.FEEDBACK_SESSION_STARTDATE, startDate);
data.putResolvedTimeField(Const.ParamsNames.FEEDBACK_SESSION_STARTTIME, startTime);
assertEquals(expected, data.getResolvedTimeFields());
}
use of teammates.common.datatransfer.CourseDetailsBundle in project teammates by TEAMMATES.
the class StudentCourseDetailsPageDataTest method test.
@Test
public void test() {
______TS("typical success case");
AccountAttributes account = dataBundle.accounts.get("student1InCourse1");
StudentCourseDetailsPageData pageData = new StudentCourseDetailsPageData(account, dummySessionToken);
StudentAttributes student = dataBundle.students.get("student1InCourse1");
CourseAttributes course = dataBundle.courses.get("typicalCourse1");
CourseDetailsBundle courseDetails = new CourseDetailsBundle(course);
List<InstructorAttributes> instructors = new ArrayList<>();
instructors.add(dataBundle.instructors.get("instructor1OfCourse1"));
instructors.add(dataBundle.instructors.get("instructor2OfCourse1"));
instructors.add(dataBundle.instructors.get("helperOfCourse1"));
TeamDetailsBundle team = new TeamDetailsBundle();
team.name = student.team;
// Get team members of student
for (Entry<String, StudentAttributes> entry : dataBundle.students.entrySet()) {
StudentAttributes currStudent = entry.getValue();
if (currStudent.team.equals(team.name)) {
team.students.add(currStudent);
}
}
pageData.init(courseDetails, instructors, student, team);
List<InstructorAttributes> courseInstructors = pageData.getStudentCourseDetailsPanel().getInstructors();
List<StudentAttributes> teammates = pageData.getStudentCourseDetailsPanel().getTeammates();
assertEquals(courseDetails.course.getName(), pageData.getStudentCourseDetailsPanel().getCourseName());
assertEquals(courseDetails.course.getId(), pageData.getStudentCourseDetailsPanel().getCourseId());
assertFalse(courseInstructors.isEmpty());
assertFalse(teammates.isEmpty());
assertEquals(student.email, pageData.getStudentCourseDetailsPanel().getStudentEmail());
assertEquals(student.name, pageData.getStudentCourseDetailsPanel().getStudentName());
assertEquals(team.name, pageData.getStudentCourseDetailsPanel().getStudentTeam());
assertEquals(instructors.size(), courseInstructors.size());
assertEquals(instructors.get(0).name, courseInstructors.get(0).name);
assertEquals(instructors.get(1).name, courseInstructors.get(1).name);
assertEquals(instructors.get(2).name, courseInstructors.get(2).name);
assertEquals(instructors.get(0).displayedName, courseInstructors.get(0).displayedName);
assertEquals(instructors.get(1).displayedName, courseInstructors.get(1).displayedName);
assertEquals(instructors.get(2).displayedName, courseInstructors.get(2).displayedName);
assertEquals(team.students.size(), teammates.size());
______TS("student in unregistered course");
student = dataBundle.students.get("student1InUnregisteredCourse");
course = dataBundle.courses.get("unregisteredCourse");
courseDetails = new CourseDetailsBundle(course);
instructors = new ArrayList<>();
instructors.add(dataBundle.instructors.get("instructor5"));
team = new TeamDetailsBundle();
team.name = student.team;
// Get team members of student
for (Entry<String, StudentAttributes> entry : dataBundle.students.entrySet()) {
StudentAttributes currStudent = entry.getValue();
if (currStudent.team.equals(team.name)) {
team.students.add(currStudent);
}
}
pageData.init(courseDetails, instructors, student, team);
courseInstructors = pageData.getStudentCourseDetailsPanel().getInstructors();
teammates = pageData.getStudentCourseDetailsPanel().getTeammates();
assertEquals(courseDetails.course.getName(), pageData.getStudentCourseDetailsPanel().getCourseName());
assertEquals(courseDetails.course.getId(), pageData.getStudentCourseDetailsPanel().getCourseId());
assertFalse(courseInstructors.isEmpty());
assertFalse(teammates.isEmpty());
assertEquals(student.email, pageData.getStudentCourseDetailsPanel().getStudentEmail());
assertEquals(student.name, pageData.getStudentCourseDetailsPanel().getStudentName());
assertEquals(team.name, pageData.getStudentCourseDetailsPanel().getStudentTeam());
assertEquals(instructors.size(), courseInstructors.size());
assertEquals(instructors.get(0).name, courseInstructors.get(0).name);
assertEquals(instructors.get(0).displayedName, courseInstructors.get(0).displayedName);
assertEquals(team.students.size(), teammates.size());
______TS("student in archived course");
student = dataBundle.students.get("student1InArchivedCourse");
course = dataBundle.courses.get("archivedCourse");
courseDetails = new CourseDetailsBundle(course);
instructors = new ArrayList<>();
instructors.add(dataBundle.instructors.get("instructorOfArchivedCourse"));
team = new TeamDetailsBundle();
team.name = student.team;
// Get team members of student
for (Entry<String, StudentAttributes> entry : dataBundle.students.entrySet()) {
StudentAttributes currStudent = entry.getValue();
if (currStudent.team.equals(team.name)) {
team.students.add(currStudent);
}
}
pageData.init(courseDetails, instructors, student, team);
courseInstructors = pageData.getStudentCourseDetailsPanel().getInstructors();
teammates = pageData.getStudentCourseDetailsPanel().getTeammates();
assertEquals(courseDetails.course.getName(), pageData.getStudentCourseDetailsPanel().getCourseName());
assertEquals(courseDetails.course.getId(), pageData.getStudentCourseDetailsPanel().getCourseId());
assertFalse(courseInstructors.isEmpty());
assertFalse(teammates.isEmpty());
assertEquals(student.email, pageData.getStudentCourseDetailsPanel().getStudentEmail());
assertEquals(student.name, pageData.getStudentCourseDetailsPanel().getStudentName());
assertEquals(team.name, pageData.getStudentCourseDetailsPanel().getStudentTeam());
assertEquals(instructors.size(), courseInstructors.size());
assertEquals(instructors.get(0).name, courseInstructors.get(0).name);
assertEquals(instructors.get(0).displayedName, courseInstructors.get(0).displayedName);
assertEquals(team.students.size(), teammates.size());
}
use of teammates.common.datatransfer.CourseDetailsBundle in project teammates by TEAMMATES.
the class StudentHomePageDataTest method testCourseTables.
private void testCourseTables(List<CourseTable> courseTables) {
assertEquals(courses.size(), courseTables.size());
CourseDetailsBundle newCourse = courses.get(0);
CourseTable newCourseTable = courseTables.get(0);
testCourseTableMeta(newCourse.course, newCourseTable);
testNewCourseTable(newCourse, newCourseTable);
CourseDetailsBundle oldCourse = courses.get(1);
CourseTable oldCourseTable = courseTables.get(1);
testCourseTableMeta(oldCourse.course, oldCourseTable);
testOldCourseTable(oldCourse, oldCourseTable);
}
use of teammates.common.datatransfer.CourseDetailsBundle in project teammates by TEAMMATES.
the class StudentHomePageAction method execute.
@Override
public ActionResult execute() {
gateKeeper.verifyLoggedInUserPrivileges();
String recentlyJoinedCourseId = getRequestParamValue(Const.ParamsNames.CHECK_PERSISTENCE_COURSE);
List<CourseDetailsBundle> courses = new ArrayList<>();
Map<FeedbackSessionAttributes, Boolean> sessionSubmissionStatusMap = new HashMap<>();
try {
courses = logic.getCourseDetailsListForStudent(account.googleId);
sessionSubmissionStatusMap = generateFeedbackSessionSubmissionStatusMap(courses, account.googleId);
CourseDetailsBundle.sortDetailedCoursesByCourseId(courses);
statusToAdmin = "studentHome Page Load<br>" + "Total courses: " + courses.size();
boolean isDataConsistent = isCourseIncluded(recentlyJoinedCourseId, courses);
if (!isDataConsistent) {
addPlaceholderCourse(courses, recentlyJoinedCourseId, sessionSubmissionStatusMap);
}
for (CourseDetailsBundle course : courses) {
FeedbackSessionDetailsBundle.sortFeedbackSessionsByCreationTime(course.feedbackSessions);
}
} catch (EntityDoesNotExistException e) {
if (recentlyJoinedCourseId == null) {
statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_FIRST_TIME, StatusMessageColor.WARNING));
statusToAdmin = Const.ACTION_RESULT_FAILURE + " :" + e.getMessage();
} else {
addPlaceholderCourse(courses, recentlyJoinedCourseId, sessionSubmissionStatusMap);
}
}
StudentHomePageData data = new StudentHomePageData(account, sessionToken, courses, sessionSubmissionStatusMap);
return createShowPageResult(Const.ViewURIs.STUDENT_HOME, data);
}
use of teammates.common.datatransfer.CourseDetailsBundle in project teammates by TEAMMATES.
the class StudentHomePageData method setCourseTables.
private void setCourseTables(List<CourseDetailsBundle> courses, Map<FeedbackSessionAttributes, Boolean> sessionSubmissionStatusMap) {
courseTables = new ArrayList<>();
// incremented for each session row without resetting between courses
int startingSessionIdx = 0;
for (CourseDetailsBundle courseDetails : courses) {
CourseTable courseTable = new CourseTable(courseDetails.course, createCourseTableLinks(courseDetails.course.getId()), createSessionRows(courseDetails.feedbackSessions, sessionSubmissionStatusMap, startingSessionIdx));
startingSessionIdx += courseDetails.feedbackSessions.size();
courseTables.add(courseTable);
}
}
Aggregations