df.getDecimalFormatSymbols().setDecimalSeparator('.'); String grade = df.format(Math.max(0, totalMark)).replace(',', '.');
DecimalFormatSymbols decimalFormatSymbols = df.getDecimalFormatSymbols(); decimalFormatSymbols.setDecimalSeparator('.'); df.setDecimalFormatSymbols(decimalFormatSymbols); String grade = df.format(Math.max(0, totalMark));
    public InfoSiteStudentTestFeedback run(String userName, Integer studentNumber, Integer distributedTestId, Response[] response, String path)            throws FenixServiceException, ExcepcaoPersistencia {        String logIdString = StringAppender.append("student n ", studentNumber.toString(), " testId ", distributedTestId.toString());        InfoSiteStudentTestFeedback infoSiteStudentTestFeedback = new InfoSiteStudentTestFeedback();        this.path = path.replace('\\', '/');        ISuportePersistente persistentSuport = PersistenceSupportFactory.getDefaultPersistenceSupport();        IStudent student = persistentSuport.getIPersistentStudent().readByUsername(userName);        if (student == null)            throw new FenixServiceException();        if (student.getNumber().compareTo(studentNumber) != 0)            throw new NotAuthorizedStudentToDoTestException();        IDistributedTest distributedTest = (IDistributedTest) persistentSuport.getIPersistentDistributedTest().readByOID(DistributedTest.class,                distributedTestId);        if (distributedTest == null)            throw new FenixServiceException();        String event = getLogString(response);        double totalMark = 0;        int responseNumber = 0;        int notResponseNumber = 0;        List<String> errors = new ArrayList<String>();        if (compareDates(distributedTest.getEndDate(), distributedTest.getEndHour())) {            List<IStudentTestQuestion> studentTestQuestionList = persistentSuport.getIPersistentStudentTestQuestion()                    .readByStudentAndDistributedTest(student.getIdInternal(), distributedTest.getIdInternal());            if (studentTestQuestionList.size() == 0)                throw new FenixServiceException();            ParseQuestion parse = new ParseQuestion();            for (IStudentTestQuestion studentTestQuestion : studentTestQuestionList) {                InfoStudentTestQuestion infoStudentTestQuestion = InfoStudentTestQuestionWithInfoQuestionAndInfoDistributedTest                        .newInfoFromDomain(studentTestQuestion);                infoStudentTestQuestion.setResponse(response[studentTestQuestion.getTestQuestionOrder().intValue() - 1]);                if (logger.isDebugEnabled())                    logger.debug(StringAppender.append(logIdString, " infoStudentTestQuestion.getResonse()= ",                            getLogString(new Response[] { infoStudentTestQuestion.getResponse() })));                if (infoStudentTestQuestion.getResponse().isResponsed()) {                    responseNumber++;                    if (studentTestQuestion.getResponse() != null && distributedTest.getTestType().getType().intValue() == TestType.EVALUATION) {                        totalMark += infoStudentTestQuestion.getTestQuestionMark().doubleValue();                        // no pode aceitar nova resposta                    } else {                        try {                            infoStudentTestQuestion = parse.parseStudentTestQuestion(infoStudentTestQuestion, this.path);                            infoStudentTestQuestion.setQuestion(correctQuestionValues(infoStudentTestQuestion.getQuestion(), new Double(                                    infoStudentTestQuestion.getTestQuestionValue().doubleValue())));                        } catch (Exception e) {                            throw new FenixServiceException(e);                        }                        IQuestionCorrectionStrategyFactory questionCorrectionStrategyFactory = QuestionCorrectionStrategyFactory.getInstance();                        IQuestionCorrectionStrategy questionCorrectionStrategy = questionCorrectionStrategyFactory                                .getQuestionCorrectionStrategy(infoStudentTestQuestion);                        String error = questionCorrectionStrategy.validResponse(infoStudentTestQuestion);                        if (error == null) {                            if ((!distributedTest.getTestType().equals(new TestType(TestType.INQUIRY)))                                    && infoStudentTestQuestion.getQuestion().getResponseProcessingInstructions().size() != 0) {                                infoStudentTestQuestion = questionCorrectionStrategy.getMark(infoStudentTestQuestion);                            }                            totalMark += infoStudentTestQuestion.getTestQuestionMark().doubleValue();                            ByteArrayOutputStream out = new ByteArrayOutputStream();                            XMLEncoder encoder = new XMLEncoder(out);                            if (logger.isDebugEnabled())                                logger.debug(StringAppender.append(logIdString, " order= ",                                        infoStudentTestQuestion.getTestQuestionOrder().toString(), " ", dateFormat.format(Calendar.getInstance()                                                .getTime()), " before write: infoStudentTestQuestion.getResonse()= ",                                        getLogString(new Response[] { infoStudentTestQuestion.getResponse() })));                            encoder.writeObject(infoStudentTestQuestion.getResponse());                            encoder.close();                            final String outString = out.toString();                            if (logger.isDebugEnabled())                                logger.debug(StringAppender.append(logIdString, " out.toString()= ", outString));                            studentTestQuestion.setResponse(outString);                            studentTestQuestion.setTestQuestionMark(infoStudentTestQuestion.getTestQuestionMark());                        } else {                            notResponseNumber++;                            responseNumber--;                            errors.add(error);                        }                    }                } else {                    if (studentTestQuestion.getResponse() != null) {                        responseNumber++;                        if (distributedTest.getTestType().getType().intValue() == TestType.EVALUATION) {                            totalMark += studentTestQuestion.getTestQuestionMark().doubleValue();                        }                    } else {                        notResponseNumber++;                    }                }            }            if (distributedTest.getTestType().equals(new TestType(TestType.EVALUATION))) {                IOnlineTest onlineTest = (IOnlineTest) persistentSuport.getIPersistentOnlineTest().readByDistributedTest(distributedTestId);                IAttends attend = persistentSuport.getIFrequentaPersistente().readByAlunoAndDisciplinaExecucao(student.getIdInternal(),                        ((IExecutionCourse) distributedTest.getTestScope().getDomainObject()).getIdInternal());                IMark mark = persistentSuport.getIPersistentMark().readBy(onlineTest, attend);                if (mark == null) {                    mark = DomainFactory.makeMark();                    mark.setAttend(attend);                    mark.setEvaluation(onlineTest);                }                DecimalFormat df = new DecimalFormat("#0.##");                df.getDecimalFormatSymbols().setDecimalSeparator('.');                String grade = df.format(Math.max(0, totalMark)).replace(',', '.');                System.out.println("GRADE ----------------------> " + student.getNumber() + " " + grade);                mark.setMark(grade);            }            IStudentTestLog studentTestLog = DomainFactory.makeStudentTestLog();            studentTestLog.setDistributedTest(distributedTest);            studentTestLog.setStudent(student);            studentTestLog.setDate(Calendar.getInstance().getTime());            studentTestLog.setEvent(event);        } else            throw new NotAuthorizedException();        infoSiteStudentTestFeedback.setResponseNumber(new Integer(responseNumber));        infoSiteStudentTestFeedback.setNotResponseNumber(new Integer(notResponseNumber));        infoSiteStudentTestFeedback.setErrors(errors);        return infoSiteStudentTestFeedback;    }