public static List<PassageQuestionRecord> byPassageQuestionId(Long passageQuestionId) { List<PassageQuestionRecord> recs = PassageQuestionRecord.all(); List<PassageQuestionRecord> ret = new ArrayList<PassageQuestionRecord>(); for (PassageQuestionRecord r : recs) { if (r.question.id == passageQuestionId) ret.add(r); } return ret; }
public static int getNumQuestionsCleared(User user, SimplePassage passage) { int numQuestionsCleared = 0; Set<PassageQuestionRecord> qrs = PassageQuestionRecord.byUserAndPassage(user, passage); for (PassageQuestionRecord qr : qrs) { if (qr.cleared) { numQuestionsCleared++; } } return numQuestionsCleared; }
public static int getNumQuestionsCorrect(User user, SimplePassage passage, int timeTaken) { int numQuestionsCorrect = 0; int count = 0; // System.out.println("getting num questions correct for user " + user.id + "::: time = " + // timeTaken); for (PassageQuestion q : passage.questions) { count += 1; PassageQuestionRecord qr = PassageQuestionRecord.byTimeTaken(user, q, timeTaken); // System.out.println(qr); if (qr == null) { continue; } if (qr.responses == null) { // question hasn't even been cleared yet continue; } if (qr.responses.size() <= 0) { // question hasn't even been cleared yet continue; } PassageQuestionResponse PassageQuestionResponse = qr.responses.iterator().next(); // TODO: support multiple PassageQuestionResponses? PassageQuestionChoice correctChoice = PassageQuestionChoice.getCorrectChoice(qr.question.choices); if (PassageQuestionResponse.entity_id.equals(correctChoice.entity_id)) { numQuestionsCorrect++; } } return numQuestionsCorrect; }
public static PassageQuestionRecord create(PassageQuestionRecord courseRecord) { courseRecord.save(); return courseRecord; }