public void testForSingleMemberClassWithEmptyAssessment() throws Exception { // given Group group = createClass(1); Assessment a = createAssessment(group, 0, 0); // when AssessmentGradebook g = gradebookService.getForAssessment(a); // then BaseTestCase.assertEquals(0, g.getQuestionCount()); BaseTestCase.assertEquals("averages", array(0), g.getAverages()); assertResults(g, 0); }
public void testForEmptyClassWithAssessmentWithManyQuestionsAndReinforcements() throws Exception { // given Group group = createClass(0); Assessment a = createAssessment(group, 3, 7); // when AssessmentGradebook g = gradebookService.getForAssessment(a); // then BaseTestCase.assertEquals(3, g.getQuestionCount()); BaseTestCase.assertEquals("averages", array(0, 0, 0, 0), g.getAverages()); BaseTestCase.assertEquals(0, g.getResults().length); }
public void testForSingleMemberClassWithAssessmentWithAQuestionAndAReinforcementAndAResponse() throws Exception { // given Group group = createClass(1); Contact c = getContacts(group)[0]; Assessment a = createAssessment(group, 1, 1); createResponse(c, a, 0, true); // when AssessmentGradebook g = gradebookService.getForAssessment(a); // then BaseTestCase.assertEquals(1, g.getQuestionCount()); BaseTestCase.assertEquals("averages", array(100, 100), g.getAverages()); assertResults(g, 0, 100); }
public void testForSingleMemberClassWithAssessmentWithManyQuestionsAndReinforcementsAndSomeResponses() throws Exception { // given Group group = createClass(1); Contact c = getContacts(group)[0]; Assessment a = createAssessment(group, 3, 7); createResponse(c, a, 0, true); createResponse(c, a, 2, false); // when AssessmentGradebook g = gradebookService.getForAssessment(a); // then BaseTestCase.assertEquals(3, g.getQuestionCount()); BaseTestCase.assertEquals("averages", array(100, 0, 0, 33), g.getAverages()); assertResults(g, array(0, null, 1, 33)); }
private void assertResults(AssessmentGradebook g, Integer[]... results) { StudentTopicResult[] strs = g.getResults(); assertEquals("results length", results.length, strs.length); for (int i = 0; i < results.length; ++i) { StudentTopicResult str = strs[i]; Integer[] individualResults = results[i]; for (int j = 0; j < individualResults.length - 1; j++) { AssessmentMessageResponse amr = str.getResponses()[j]; Integer answer = amr == null ? null : amr.getAnswer(); assertEquals("result #" + i, individualResults[j], answer); } assertEquals(individualResults[individualResults.length - 1].intValue(), str.getScore()); } }