public void testQuestionAttributes() { StudentFeedbackSubmissionEditQuestionsWithResponses questionWithResponses = pageData.getQuestionsWithResponses().get(0); assertEquals(question.questionType, questionWithResponses.getQuestion().getQuestionType()); assertEquals(question.courseId, questionWithResponses.getQuestion().getCourseId()); assertEquals(question.questionNumber, questionWithResponses.getQuestion().getQuestionNumber()); assertEquals( question.getQuestionDetails().getQuestionText(), questionWithResponses.getQuestion().getQuestionText()); assertEquals( question.numberOfEntitiesToGiveFeedbackTo, questionWithResponses.getQuestion().getNumberOfEntitiesToGiveFeedbackTo()); assertEquals(question.getId(), questionWithResponses.getQuestion().getQuestionId()); }
public void createData(StudentAttributes student) { FeedbackSessionAttributes feedbackSession = dataBundle.feedbackSessions.get("session1InCourse1"); question = dataBundle.feedbackQuestions.get("qn1InSession1InCourse1"); responses.add(dataBundle.feedbackResponses.get("response1ForQ1S1C1")); responses.add(dataBundle.feedbackResponses.get("response2ForQ1S1C1")); questionResponseBundle.put(question, responses); recipients.put(student.email, Const.USER_NAME_FOR_SELF); recipientList.put(question.getId(), recipients); pageData.bundle = new FeedbackSessionQuestionsBundle(feedbackSession, questionResponseBundle, recipientList); pageData.bundle.questionResponseBundle.put(question, responses); }
@Test public void testAll() { ______TS("test typical case"); AccountAttributes studentAccount = dataBundle.accounts.get("student1InCourse1"); StudentAttributes student = dataBundle.students.get("student1InCourse1"); pageData = new FeedbackSubmissionEditPageData(studentAccount, student); createData(student); pageData.init(student.key, student.email, student.course); assertEquals( "You are submitting feedback as <span class='text-danger text-bold text-large'>" + "student1 In Course1</td></div>'\"</span>. " + "You may submit feedback for sessions that are currently open " + "and view results without logging in. " + "To access other features you need <a href='/page/studentCourseJoinAuthentication?" + "studentemail=student1InCourse1%40gmail.tmt&courseid=idOfTypicalCourse1' class='link'>" + "to login using a Google account</a> (recommended).", pageData.getRegisterMessage()); assertNull(pageData.getSubmitAction()); assertFalse(pageData.isModeration()); assertFalse(pageData.isSessionOpenForSubmission()); assertFalse(pageData.isSubmittable()); testQuestionAttributes(); ______TS("student in unregistered course"); student = dataBundle.students.get("student1InUnregisteredCourse"); pageData = new FeedbackSubmissionEditPageData(studentAccount, student); createData(student); pageData.init(student.key, student.email, student.course); assertEquals( "You are submitting feedback as <span class='text-danger text-bold text-large'>student1 " + "In unregisteredCourse</span>. You may submit feedback for sessions that are currently open " + "and view results without logging in. " + "To access other features you need <a href='/page/studentCourseJoinAuthentication?" + "key=regKeyForStuNotYetJoinCourse&studentemail=student1InUnregisteredCourse%40gmail.tmt&" + "courseid=idOfUnregisteredCourse' class='link'>to login using a Google account</a> " + "(recommended).", pageData.getRegisterMessage()); assertNull(pageData.getSubmitAction()); assertFalse(pageData.isModeration()); assertFalse(pageData.isSessionOpenForSubmission()); assertFalse(pageData.isSubmittable()); testQuestionAttributes(); ______TS("student in archived course"); student = dataBundle.students.get("student1InArchivedCourse"); pageData = new FeedbackSubmissionEditPageData(studentAccount, student); createData(student); pageData.init(student.key, student.email, student.course); assertEquals( "You are submitting feedback as <span class='text-danger text-bold text-large'>student1 In Course1" + "</span>. You may submit feedback for sessions that are currently open " + "and view results without logging in. To access other features " + "you need <a href='/page/studentCourseJoinAuthentication?studentemail=student1InArchivedCourse%40" + "gmail.tmt&courseid=idOfArchivedCourse' class='link'>to login using a Google account</a> " + "(recommended).", pageData.getRegisterMessage()); assertNull(pageData.getSubmitAction()); assertFalse(pageData.isModeration()); assertFalse(pageData.isSessionOpenForSubmission()); assertFalse(pageData.isSubmittable()); testQuestionAttributes(); ______TS("student submission open"); student = dataBundle.students.get("student1InCourse1"); pageData = new FeedbackSubmissionEditPageData(studentAccount, student); createData(student); pageData.setSessionOpenForSubmission(true); pageData.init(student.key, student.email, student.course); assertEquals( "You are submitting feedback as <span class='text-danger text-bold text-large'>" + "student1 In Course1</td></div>'\"</span>. " + "You may submit feedback for sessions that are currently open " + "and view results without logging in. " + "To access other features you need <a href='/page/studentCourseJoinAuthentication?" + "studentemail=student1InCourse1%40gmail.tmt&courseid=idOfTypicalCourse1' class='link'>" + "to login using a Google account</a> (recommended).", pageData.getRegisterMessage()); assertNull(pageData.getSubmitAction()); assertFalse(pageData.isModeration()); assertTrue(pageData.isSessionOpenForSubmission()); assertTrue(pageData.isSubmittable()); ______TS("instructor moderating a response - closed for submission"); AccountAttributes instructorAccount = dataBundle.accounts.get("instructor1OfCourse1"); InstructorAttributes instructor = dataBundle.instructors.get("instructor1OfCourse1"); student = dataBundle.students.get("student1InCourse1"); pageData = new FeedbackSubmissionEditPageData(instructorAccount, student); createData(student); pageData.setModeration(true); pageData.init("", student.email, student.course); assertNull(pageData.getSubmitAction()); assertTrue(pageData.isModeration()); assertFalse(pageData.isSessionOpenForSubmission()); assertTrue(pageData.isSubmittable()); testQuestionAttributes(); ______TS("instructor moderating a response - open for submission"); student = dataBundle.students.get("student1InCourse1"); pageData = new FeedbackSubmissionEditPageData(instructorAccount, student); createData(student); pageData.setModeration(true); pageData.setSessionOpenForSubmission(true); pageData.init("", student.email, student.course); assertNull(pageData.getSubmitAction()); assertTrue(pageData.isModeration()); assertTrue(pageData.isSessionOpenForSubmission()); assertTrue(pageData.isSubmittable()); testQuestionAttributes(); ______TS("instructor previewing a response"); pageData = new FeedbackSubmissionEditPageData(instructorAccount, student); createData(student); pageData.setPreview(true); pageData.setPreviewInstructor(instructor); pageData.init("", student.email, student.course); assertNull(pageData.getSubmitAction()); assertFalse(pageData.isModeration()); assertFalse(pageData.isSessionOpenForSubmission()); assertFalse(pageData.isSubmittable()); testQuestionAttributes(); }