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());
   }
 }
  private void createResponse(Contact c, Assessment a, int questionNumber, boolean correct) {
    AssessmentMessage am = null;
    for (AssessmentMessage m : a.getMessages()) {
      if (m.getTopicItem() instanceof Question) {
        if (--questionNumber < 0) {
          am = m;
          break;
        }
      }
    }
    if (am == null) throw new RuntimeException("Could not find question #" + questionNumber);

    Question q = (Question) am.getTopicItem();
    int answer = correct ? q.getCorrectAnswer() : q.getCorrectAnswer() + 1 % q.getAnswers().length;
    AssessmentMessageResponse r = new AssessmentMessageResponse();
    r.setStudent(c);
    r.setAnswer(answer);
    r.setAssessmentMessage(am);
    r.setCorrect(correct);
    assessmentMessageResponseDao.save(r);
  }