mark.setPublishedMark(markValue);
if (mark.getPublishedMark() != null) { mark.setPublishedMark(markValue); }
    public List<InfoSiteDistributedTestAdvisory> run(Integer executionCourseId, Integer distributedTestId, Double newMark, Integer questionId,            Integer studentId, TestQuestionStudentsChangesType studentsType, String path) throws FenixServiceException, ExcepcaoPersistencia {        List<InfoSiteDistributedTestAdvisory> infoSiteDistributedTestAdvisoryList = new ArrayList<InfoSiteDistributedTestAdvisory>();        ISuportePersistente persistentSuport = PersistenceSupportFactory.getDefaultPersistenceSupport();        path = path.replace('\\', '/');        IPersistentStudentTestQuestion persistentStudentTestQuestion = persistentSuport.getIPersistentStudentTestQuestion();        List<StudentTestQuestion> studentsTestQuestionList = new ArrayList<StudentTestQuestion>();        if (studentsType.getType().intValue() == TestQuestionStudentsChangesType.THIS_STUDENT) {            studentsTestQuestionList.add(persistentStudentTestQuestion.readByQuestionAndStudentAndDistributedTest(questionId, studentId,                    distributedTestId));        } else if (studentsType.getType().intValue() == TestQuestionStudentsChangesType.STUDENTS_FROM_TEST_VARIATION) {            studentsTestQuestionList.addAll(persistentStudentTestQuestion.readByQuestionAndDistributedTest(questionId, distributedTestId));        } else if (studentsType.getType().intValue() == TestQuestionStudentsChangesType.STUDENTS_FROM_TEST) {            StudentTestQuestion studentTestQuestion = persistentStudentTestQuestion.readByQuestionAndStudentAndDistributedTest(questionId,                    studentId, distributedTestId);            studentsTestQuestionList.addAll(persistentStudentTestQuestion.readByOrderAndDistributedTest(studentTestQuestion.getTestQuestionOrder(),                    distributedTestId));        } else if (studentsType.getType().intValue() == TestQuestionStudentsChangesType.ALL_STUDENTS) {            studentsTestQuestionList.addAll(persistentStudentTestQuestion.readByQuestion(questionId));        }        for (StudentTestQuestion studentTestQuestion : studentsTestQuestionList) {            InfoSiteDistributedTestAdvisory infoSiteDistributedTestAdvisory = new InfoSiteDistributedTestAdvisory();            infoSiteDistributedTestAdvisory.setInfoDistributedTest(InfoDistributedTest.newInfoFromDomain(studentTestQuestion.getDistributedTest()));            infoSiteDistributedTestAdvisory.setInfoAdvisory(null);            List<InfoStudent> group = new ArrayList<InfoStudent>();            studentTestQuestion.setTestQuestionMark(newMark);            if (!group.contains(studentTestQuestion.getStudent().getPerson()))                group.add(InfoStudent.newInfoFromDomain(studentTestQuestion.getStudent()));            if (studentTestQuestion.getDistributedTest().getTestType().equals(new TestType(TestType.EVALUATION))) {                if (studentTestQuestion.getResponse() == null) {                    Response response = null;                    InfoStudentTestQuestion infoStudentTestQuestion = InfoStudentTestQuestionWithInfoQuestionAndInfoDistributedTest                            .newInfoFromDomain(studentTestQuestion);                    try {                        ParseQuestion parse = new ParseQuestion();                        infoStudentTestQuestion = parse.parseStudentTestQuestion(infoStudentTestQuestion, path);                    } catch (Exception e) {                        throw new FenixServiceException(e);                    }                    if (infoStudentTestQuestion.getQuestion().getQuestionType().getType().intValue() == QuestionType.STR) {                        response = new ResponseSTR("");                    } else if (infoStudentTestQuestion.getQuestion().getQuestionType().getType().intValue() == QuestionType.NUM) {                        response = new ResponseNUM("");                    } else if (infoStudentTestQuestion.getQuestion().getQuestionType().getType().intValue() == QuestionType.LID) {                        response = new ResponseLID(new String[] { null });                    }                    response.setResponsed();                    ByteArrayOutputStream out = new ByteArrayOutputStream();                    XMLEncoder encoder = new XMLEncoder(out);                    encoder.writeObject(response);                    encoder.close();                    final String outString = out.toString();                    studentTestQuestion.setResponse(outString);                } else {                    OnlineTest onlineTest = (OnlineTest) persistentSuport.getIPersistentOnlineTest().readByDistributedTest(                            studentTestQuestion.getDistributedTest().getIdInternal());                    ExecutionCourse executionCourse = (ExecutionCourse) persistentSuport.getIPersistentExecutionCourse().readByOID(                            ExecutionCourse.class, executionCourseId);                    Attends attend = persistentSuport.getIFrequentaPersistente().readByAlunoAndDisciplinaExecucao(                            studentTestQuestion.getStudent().getIdInternal(), executionCourse.getIdInternal());                    Mark mark = persistentSuport.getIPersistentMark().readBy(onlineTest, attend);                    final String markValue = getNewStudentMark(persistentSuport, studentTestQuestion.getDistributedTest(), studentTestQuestion.getStudent());                    if (mark == null) {                        mark = DomainFactory.makeMark(attend, onlineTest, markValue);                    } else {                        mark.setMark(markValue);                                            }                    mark.setPublishedMark(markValue);                }            }            StudentTestLog studentTestLog = DomainFactory.makeStudentTestLog();            studentTestLog.setDistributedTest(studentTestQuestion.getDistributedTest());            studentTestLog.setStudent(studentTestQuestion.getStudent());            studentTestLog.setDate(Calendar.getInstance().getTime());            ResourceBundle bundle = ResourceBundle.getBundle("ServidorApresentacao.ApplicationResources");            studentTestLog.setEvent(MessageFormat.format(bundle.getString("message.changeStudentMarkLogMessage"), new Object[] { newMark }));            infoSiteDistributedTestAdvisory.setInfoStudentList(group);            infoSiteDistributedTestAdvisoryList.add(infoSiteDistributedTestAdvisory);        }        return infoSiteDistributedTestAdvisoryList;    }