if (questionList.size() == 0) questionList.addAll(studentTestQuestionExample.getQuestion().getMetadata().getVisibleQuestions()); Question question = getStudentQuestion(questionList); if (question == null) { throw new InvalidArgumentsServiceException(); } studentTestQuestion.setQuestion(question); questionList.remove(question);
if (questionList.size() == 0) questionList.addAll(studentTestQuestionExample.getQuestion().getMetadata() .getVisibleQuestions()); Question question = getStudentQuestion(questionList); if (question == null) { throw new InvalidArgumentsServiceException(); } if (question.getSubQuestions().size() >= 1 && question.getSubQuestions().get(0).getItemId() != null) { studentTestQuestion.setItemId(question.getSubQuestions().get(0).getItemId()); } studentTestQuestion.setQuestion(question); questionList.remove(question);
    public Integer run(Integer executionCourseId, Integer distributedTestId, List infoStudentList, String contextPath) throws ExcepcaoPersistencia,            InvalidArgumentsServiceException {        if (infoStudentList == null || infoStudentList.size() == 0)            return null;        this.contextPath = contextPath.replace('\\', '/');        DistributedTest distributedTest = rootDomainObject.readDistributedTestByOID(distributedTestId);        if (distributedTest == null)            throw new InvalidArgumentsServiceException();        Set<StudentTestQuestion> studentTestQuestions = distributedTest.findStudentTestQuestionsOfFirstStudentOrderedByTestQuestionOrder();        for (StudentTestQuestion studentTestQuestionExample : studentTestQuestions) {            List<Question> questionList = new ArrayList<Question>();            questionList.addAll(studentTestQuestionExample.getQuestion().getMetadata().getVisibleQuestions());            for (int j = 0; j < infoStudentList.size(); j++) {                Registration registration = rootDomainObject.readRegistrationByOID(                        ((InfoStudent) infoStudentList.get(j)).getIdInternal());                    StudentTestQuestion studentTestQuestion = new StudentTestQuestion();                    studentTestQuestion.setStudent(registration);                    studentTestQuestion.setDistributedTest(distributedTest);                    studentTestQuestion.setTestQuestionOrder(studentTestQuestionExample.getTestQuestionOrder());                    studentTestQuestion.setTestQuestionValue(studentTestQuestionExample.getTestQuestionValue());                    studentTestQuestion.setCorrectionFormula(studentTestQuestionExample.getCorrectionFormula());                    studentTestQuestion.setTestQuestionMark(new Double(0));                    studentTestQuestion.setResponse(null);                    if (questionList.size() == 0)                        questionList.addAll(studentTestQuestionExample.getQuestion().getMetadata().getVisibleQuestions());                    Question question = getStudentQuestion(questionList);                    if (question == null) {                        throw new InvalidArgumentsServiceException();                    }                    studentTestQuestion.setQuestion(question);                    questionList.remove(question);            }        }        // create advisory for new students        Advisory advisory = createTestAdvisory(distributedTest);        DistributedTestAdvisory distributedTestAdvisory = new DistributedTestAdvisory();        distributedTestAdvisory.setAdvisory(advisory);        distributedTestAdvisory.setDistributedTest(distributedTest);        return advisory.getIdInternal();    }