Index: lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java =================================================================== diff -u -r1ad00988450cb1238e0f36f7f398ae3c45328951 -rab88b7ff6a0dbd05c91a29e135b11f9596674f4c --- lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java (.../GradebookService.java) (revision 1ad00988450cb1238e0f36f7f398ae3c45328951) +++ lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java (.../GradebookService.java) (revision ab88b7ff6a0dbd05c91a29e135b11f9596674f4c) @@ -1131,7 +1131,7 @@ ExcelRow lessonAverageMark = summarySheet.initRow(); lessonAverageMark.addCell(getMessage("gradebook.export.average.lesson.mark"), true); if (isWeighted) { - lessonAverageMark.addPercentageCell(lessonAverageMarkValue / 100.0); + lessonAverageMark.addPercentageCell(lessonAverageMarkValue == null ? null : lessonAverageMarkValue / 100.0); } else { lessonAverageMark.addCell(lessonAverageMarkValue); } @@ -1193,10 +1193,11 @@ userDataRow.addCell(userRow.getLogin()); userDataRow.addCell(getProgressMessage(userRow)); userDataRow.addCell(userRow.getTimeTakenSeconds()); + Double userMark = userRow.getMark(); if (isWeighted) { - userDataRow.addPercentageCell(userRow.getMark() / 100.0); + userDataRow.addPercentageCell(userMark == null ? null : userMark / 100.0); } else { - userDataRow.addCell(userRow.getMark()); + userDataRow.addCell(userMark); } } summarySheet.addEmptyRow(); @@ -1254,8 +1255,9 @@ } userDataRow.addCell(userActivityMark); } + Double userMark = userRow.getMark(); if (isWeighted) { - userDataRow.addPercentageCell(userRow.getMark() / 100.0); + userDataRow.addPercentageCell(userMark == null ? null : userMark / 100.0); } else { userDataRow.addCell(userRow.getMark()); } @@ -1568,7 +1570,7 @@ userDataRow.addCell(timeTakenSeconds); userDataRow.addCell(feedback); if (isWeightedLessonMap.get(lesson.getLessonId())) { - userDataRow.addPercentageCell(mark / 100.0); + userDataRow.addPercentageCell(mark == null ? null : mark / 100.0); } else { userDataRow.addCell(mark); } Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java =================================================================== diff -u -r670dd8e248dc4705c92031c79d05a99559e35024 -rab88b7ff6a0dbd05c91a29e135b11f9596674f4c --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision 670dd8e248dc4705c92031c79d05a99559e35024) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision ab88b7ff6a0dbd05c91a29e135b11f9596674f4c) @@ -2173,18 +2173,21 @@ || question.getType() == QbQuestion.TYPE_VERY_SHORT_ANSWERS || question.getType() == QbQuestion.TYPE_NUMERICAL) { for (QbOption option : question.getQbQuestion().getQbOptions()) { - Double optionPercentage = (double) summaryOfAnswers.get(option.getUid()) / total; + Double optionPercentage = total == 0 || summaryOfAnswers.get(option.getUid()) == null ? 0 + : (double) summaryOfAnswers.get(option.getUid()) / total; ExcelCell optionCell = summaryTableRow.addPercentageCell(optionPercentage); if (option.getMaxMark() > 0) { optionCell.setColor(IndexedColors.GREEN); } } } else { - Double correctPercentage = (double) summaryOfAnswers.get(trueKey) / total; + Double correctPercentage = total == 0 || summaryOfAnswers.get(trueKey) == null ? 0 + : (double) summaryOfAnswers.get(trueKey) / total; ExcelCell correctCell = summaryTableRow.addPercentageCell(correctPercentage); - - Double wrongPercentage = (double) summaryOfAnswers.get(falseKey) / total; + + Double wrongPercentage = total == 0 || summaryOfAnswers.get(falseKey) == null ? 0 + : (double) summaryOfAnswers.get(falseKey) / total; ExcelCell wrongCell = summaryTableRow.addPercentageCell(wrongPercentage); if (question.getQbQuestion().getCorrectAnswer()) { @@ -2193,7 +2196,8 @@ wrongCell.setColor(IndexedColors.GREEN); } } - Double summaryNAPercentage = (double) summaryNACount / total; + + Double summaryNAPercentage = total == 0 ? 0 : (double) summaryNACount / total; summaryTableRow.addPercentageCell(summaryNAPercentage); return summaryTableRow;